Skip to content

Commit

Permalink
WFCORE-6841 Create ServiceDescriptor for ProcessStateNotifier and rem…
Browse files Browse the repository at this point in the history
…ove redundant capability name strings.
  • Loading branch information
pferraro committed Jun 1, 2024
1 parent cf2c741 commit 8ebccc0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ private static int getBootStackSize() {
* This capability isn't necessarily directly related to this class but we declare it
* here as it's as good a place as any at this time.
*/
protected static final RuntimeCapability<Void> PROCESS_STATE_NOTIFIER_CAPABILITY =
RuntimeCapability.Builder.of("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class)
.build();
protected static final RuntimeCapability<Void> PROCESS_STATE_NOTIFIER_CAPABILITY = RuntimeCapability.Builder.of(ProcessStateNotifier.SERVICE_DESCRIPTOR).build();

private static final OperationDefinition INIT_CONTROLLER_OP = new SimpleOperationDefinitionBuilder("boottime-controller-initializer-step", null)
.setPrivateEntry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import java.beans.PropertyChangeListener;

import org.wildfly.service.descriptor.NullaryServiceDescriptor;

/**
* Allows callers to check the current {@link ControlledProcessState.State} of the process
* and to register for notifications of state changes.
*
* @author Brian Stansberry (c) 2019 Red Hat Inc.
*/
public interface ProcessStateNotifier {
NullaryServiceDescriptor<ProcessStateNotifier> SERVICE_DESCRIPTOR = NullaryServiceDescriptor.of("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);

/**
* Gets the current state of the controlled process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<module name="org.jboss.staxmapper"/>
<module name="org.wildfly.extension.core-management-client"/>
<module name="org.wildfly.security.elytron-private"/>
<module name="org.wildfly.service"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.controller.PropertiesAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
Expand All @@ -43,7 +44,7 @@ public class ProcessStateListenerResourceDefinition extends PersistentResourceDe
private static final String PROCESS_STATE_LISTENER_CAPABILITY_NAME = "org.wildfly.extension.core-management.process-state";
static final RuntimeCapability<Void> PROCESS_STATE_LISTENER_CAPABILITY =
RuntimeCapability.Builder.of(PROCESS_STATE_LISTENER_CAPABILITY_NAME, true, Void.class)
.addRequirements("org.wildfly.management.executor", "org.wildfly.management.process-state-notifier")
.addRequirements("org.wildfly.management.executor", ProcessStateNotifier.SERVICE_DESCRIPTOR.getName())
.build();

public static final PropertiesAttributeDefinition PROPERTIES = new PropertiesAttributeDefinition.Builder("properties", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void suspendTransition(Process.RunningState oldState, Process.RunningSta

static void install(CapabilityServiceTarget serviceTarget, ProcessType processType, RunningMode runningMode, String listenerName, ProcessStateListener listener, Map<String, String> properties, int timeout) {
final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(PROCESS_STATE_LISTENER_CAPABILITY.fromBaseCapability(listenerName));
final Supplier<ProcessStateNotifier> psnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
final Supplier<ProcessStateNotifier> psnSupplier = builder.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR);
final Supplier<ExecutorService> esSupplier = builder.requiresCapability("org.wildfly.management.executor", ExecutorService.class);
final Supplier<SuspendController> scSupplier = !processType.isHostController() ? builder.requiresCapability("org.wildfly.server.suspend-controller", SuspendController.class) : null;
builder.setInstance(new ProcessStateListenerService(processType, runningMode, listenerName, listener, properties, timeout, psnSupplier, scSupplier, esSupplier));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static void addService(final OperationContext context, final PathAddress
final Supplier<PathManager> pathManager = sb.requires(PathManager.SERVICE_DESCRIPTOR);
final Supplier<NotificationHandlerRegistry> notificationRegistry = sb.requires(NotificationHandlerRegistry.SERVICE_DESCRIPTOR);
final Supplier<ModelControllerClientFactory> clientFactory = sb.requires(ModelControllerClientFactory.SERVICE_DESCRIPTOR);
final Supplier<ProcessStateNotifier> processStateNotifier = sb.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
final Supplier<ProcessStateNotifier> processStateNotifier = sb.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR);
sb.requires(org.jboss.as.server.deployment.Services.JBOSS_DEPLOYMENT_CHAINS);
final DeploymentScannerService service = new DeploymentScannerService(
serviceConsumer, pathManager, notificationRegistry, clientFactory, processStateNotifier, scheduledExecutorService,
Expand Down

0 comments on commit 8ebccc0

Please sign in to comment.