diff --git a/controller/src/main/java/org/jboss/as/controller/AbstractControllerService.java b/controller/src/main/java/org/jboss/as/controller/AbstractControllerService.java index 3964142eced..9297117369e 100644 --- a/controller/src/main/java/org/jboss/as/controller/AbstractControllerService.java +++ b/controller/src/main/java/org/jboss/as/controller/AbstractControllerService.java @@ -126,14 +126,10 @@ private static int getBootStackSize() { } /** Capability in-vm users of the controller use to create clients */ - protected static final RuntimeCapability CLIENT_FACTORY_CAPABILITY = - RuntimeCapability.Builder.of("org.wildfly.management.model-controller-client-factory", ModelControllerClientFactory.class) - .build(); + protected static final RuntimeCapability CLIENT_FACTORY_CAPABILITY = RuntimeCapability.Builder.of(ModelControllerClientFactory.SERVICE_DESCRIPTOR).build(); /** Capability in-vm users of the controller use to register notification handlers */ - protected static final RuntimeCapability NOTIFICATION_REGISTRY_CAPABILITY = - RuntimeCapability.Builder.of("org.wildfly.management.notification-handler-registry", NotificationHandlerRegistry.class) - .build(); + protected static final RuntimeCapability NOTIFICATION_REGISTRY_CAPABILITY = RuntimeCapability.Builder.of(NotificationHandlerRegistry.SERVICE_DESCRIPTOR).build(); /** * Capability users of the controller use to coordinate changes to paths. @@ -156,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 PROCESS_STATE_NOTIFIER_CAPABILITY = - RuntimeCapability.Builder.of("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class) - .build(); + protected static final RuntimeCapability 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() diff --git a/controller/src/main/java/org/jboss/as/controller/ModelControllerClientFactory.java b/controller/src/main/java/org/jboss/as/controller/ModelControllerClientFactory.java index 38cff09607d..2c8ab585e05 100644 --- a/controller/src/main/java/org/jboss/as/controller/ModelControllerClientFactory.java +++ b/controller/src/main/java/org/jboss/as/controller/ModelControllerClientFactory.java @@ -7,6 +7,8 @@ import java.util.concurrent.Executor; +import org.wildfly.service.descriptor.NullaryServiceDescriptor; + /** * Factory for obtaining a {@link org.jboss.as.controller.client.ModelControllerClient} * for use in the same VM as the target {@link ModelController}. @@ -14,6 +16,7 @@ * @author Brian Stansberry */ public interface ModelControllerClientFactory { + NullaryServiceDescriptor SERVICE_DESCRIPTOR = NullaryServiceDescriptor.of("org.wildfly.management.model-controller-client-factory", ModelControllerClientFactory.class); /** * Create an in-VM client whose operations are executed with authorization checks performed diff --git a/controller/src/main/java/org/jboss/as/controller/ProcessStateNotifier.java b/controller/src/main/java/org/jboss/as/controller/ProcessStateNotifier.java index ce8ab3b1439..84b0321f0d0 100644 --- a/controller/src/main/java/org/jboss/as/controller/ProcessStateNotifier.java +++ b/controller/src/main/java/org/jboss/as/controller/ProcessStateNotifier.java @@ -7,6 +7,8 @@ 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. @@ -14,6 +16,7 @@ * @author Brian Stansberry (c) 2019 Red Hat Inc. */ public interface ProcessStateNotifier { + NullaryServiceDescriptor SERVICE_DESCRIPTOR = NullaryServiceDescriptor.of("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class); /** * Gets the current state of the controlled process. diff --git a/controller/src/main/java/org/jboss/as/controller/notification/NotificationHandlerRegistry.java b/controller/src/main/java/org/jboss/as/controller/notification/NotificationHandlerRegistry.java index 4392d759167..90f7ac25439 100644 --- a/controller/src/main/java/org/jboss/as/controller/notification/NotificationHandlerRegistry.java +++ b/controller/src/main/java/org/jboss/as/controller/notification/NotificationHandlerRegistry.java @@ -6,6 +6,7 @@ package org.jboss.as.controller.notification; import org.jboss.as.controller.PathAddress; +import org.wildfly.service.descriptor.NullaryServiceDescriptor; /** * The NotificationHandlerRegistry is used to register and unregister notification handlers. @@ -23,6 +24,7 @@ * @author Jeff Mesnil (c) 2014 Red Hat inc. */ public interface NotificationHandlerRegistry { + NullaryServiceDescriptor SERVICE_DESCRIPTOR = NullaryServiceDescriptor.of("org.wildfly.management.notification-handler-registry", NotificationHandlerRegistry.class); /** * Special path address to register a notification handler for any source. diff --git a/controller/src/test/java/org/jboss/as/controller/test/ReadFeatureDescriptionTestCase.java b/controller/src/test/java/org/jboss/as/controller/test/ReadFeatureDescriptionTestCase.java index 0c84e4065b7..5e3446da87c 100644 --- a/controller/src/test/java/org/jboss/as/controller/test/ReadFeatureDescriptionTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/test/ReadFeatureDescriptionTestCase.java @@ -41,6 +41,7 @@ import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ManagementModel; +import org.jboss.as.controller.ModelControllerClientFactory; import org.jboss.as.controller.ModelOnlyWriteAttributeHandler; import org.jboss.as.controller.ObjectListAttributeDefinition; import org.jboss.as.controller.ObjectTypeAttributeDefinition; @@ -54,6 +55,7 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PASSIVE; import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; +import org.jboss.as.controller.notification.NotificationHandlerRegistry; import org.jboss.as.controller.operations.global.ReadFeatureDescriptionHandler; import org.jboss.as.controller.registry.RuntimePackageDependency; import org.jboss.as.controller.registry.AliasEntry; @@ -83,8 +85,6 @@ public class ReadFeatureDescriptionTestCase extends AbstractControllerTestBase { private static final String MAIN_RESOURCE_REQUIRED_PACKAGE_NAME = "required-main-resource-package"; private static final String ROOT_CAPABILITY_NAME = "root-capability"; private static final String DYNAMIC_CAPABILITY_NAME = "dynamic-capability"; - private static final String CLIENT_FACTORY_CAPABILITY_NAME = "org.wildfly.management.model-controller-client-factory"; - private static final String NOTIFICATION_REGISTRY_CAPABILITY_NAME = "org.wildfly.management.notification-handler-registry"; private static final OperationStepHandler WRITE_HANDLER = new ModelOnlyWriteAttributeHandler(); @@ -403,8 +403,8 @@ public void testServerRoot() throws OperationFailedException { } Assert.assertTrue(providedCaps.contains(ROOT_CAPABILITY_NAME)); Assert.assertTrue(providedCaps.contains(DYNAMIC_CAPABILITY_NAME)); - Assert.assertTrue(providedCaps.contains(CLIENT_FACTORY_CAPABILITY_NAME)); - Assert.assertTrue(providedCaps.contains(NOTIFICATION_REGISTRY_CAPABILITY_NAME)); + Assert.assertTrue(providedCaps.contains(ModelControllerClientFactory.SERVICE_DESCRIPTOR.getName())); + Assert.assertTrue(providedCaps.contains(NotificationHandlerRegistry.SERVICE_DESCRIPTOR.getName())); } /** diff --git a/core-feature-pack/common/src/main/resources/modules/system/layers/base/org/wildfly/extension/core-management/main/module.xml b/core-feature-pack/common/src/main/resources/modules/system/layers/base/org/wildfly/extension/core-management/main/module.xml index b9a01ddec72..0b1774f32d1 100644 --- a/core-feature-pack/common/src/main/resources/modules/system/layers/base/org/wildfly/extension/core-management/main/module.xml +++ b/core-feature-pack/common/src/main/resources/modules/system/layers/base/org/wildfly/extension/core-management/main/module.xml @@ -25,5 +25,6 @@ + diff --git a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerResourceDefinition.java b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerResourceDefinition.java index 04316716dc1..3d7946ce0f5 100644 --- a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerResourceDefinition.java +++ b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerResourceDefinition.java @@ -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; @@ -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 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) diff --git a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerService.java b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerService.java index 655ded3ff05..e7d3006c71d 100644 --- a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerService.java +++ b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/ProcessStateListenerService.java @@ -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 properties, int timeout) { final CapabilityServiceBuilder builder = serviceTarget.addCapability(PROCESS_STATE_LISTENER_CAPABILITY.fromBaseCapability(listenerName)); - final Supplier psnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class); + final Supplier psnSupplier = builder.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR); final Supplier esSupplier = builder.requiresCapability("org.wildfly.management.executor", ExecutorService.class); final Supplier 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)); diff --git a/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/DeploymentScannerService.java b/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/DeploymentScannerService.java index 8c5fe6b6938..9053482584a 100644 --- a/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/DeploymentScannerService.java +++ b/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/DeploymentScannerService.java @@ -119,9 +119,9 @@ public static void addService(final OperationContext context, final PathAddress final CapabilityServiceBuilder sb = context.getCapabilityServiceTarget().addCapability(capName); final Consumer serviceConsumer = sb.provides(capName); final Supplier pathManager = sb.requires(PathManager.SERVICE_DESCRIPTOR); - final Supplier notificationRegistry = sb.requiresCapability("org.wildfly.management.notification-handler-registry", NotificationHandlerRegistry.class); - final Supplier clientFactory = sb.requiresCapability("org.wildfly.management.model-controller-client-factory", ModelControllerClientFactory.class); - final Supplier processStateNotifier = sb.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class); + final Supplier notificationRegistry = sb.requires(NotificationHandlerRegistry.SERVICE_DESCRIPTOR); + final Supplier clientFactory = sb.requires(ModelControllerClientFactory.SERVICE_DESCRIPTOR); + final Supplier 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, diff --git a/jmx/src/main/java/org/jboss/as/jmx/MBeanServerService.java b/jmx/src/main/java/org/jboss/as/jmx/MBeanServerService.java index 97f6ff02e0b..8f5f52a2efe 100644 --- a/jmx/src/main/java/org/jboss/as/jmx/MBeanServerService.java +++ b/jmx/src/main/java/org/jboss/as/jmx/MBeanServerService.java @@ -92,7 +92,7 @@ public static ServiceController addService(final OperationContext context, fi return context.getServiceTarget().addService(MBeanServerService.SERVICE_NAME, service) .setInitialMode(ServiceController.Mode.ACTIVE) .addDependency(modelControllerName, ModelController.class, service.modelControllerValue) - .addDependency(context.getCapabilityServiceName("org.wildfly.management.notification-handler-registry", null), NotificationHandlerRegistry.class, service.notificationRegistryValue) + .addDependency(context.getCapabilityServiceName(NotificationHandlerRegistry.SERVICE_DESCRIPTOR), NotificationHandlerRegistry.class, service.notificationRegistryValue) .addDependency(ManagementModelIntegration.SERVICE_NAME, ManagementModelIntegration.ManagementModelProvider.class, service.managementModelProviderValue) .addAliases(LEGACY_MBEAN_SERVER_NAME) .install(); diff --git a/server/src/main/java/org/jboss/as/server/ServerService.java b/server/src/main/java/org/jboss/as/server/ServerService.java index 1b81847d740..639c8062431 100644 --- a/server/src/main/java/org/jboss/as/server/ServerService.java +++ b/server/src/main/java/org/jboss/as/server/ServerService.java @@ -34,6 +34,7 @@ import org.jboss.as.controller.ControlledProcessState; import org.jboss.as.controller.DelegatingResourceDefinition; import org.jboss.as.controller.ManagementModel; +import org.jboss.as.controller.ModelControllerClientFactory; import org.jboss.as.controller.ModelControllerServiceInitialization; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; @@ -41,6 +42,7 @@ import org.jboss.as.controller.ProcessType; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.RunningModeControl; +import org.jboss.as.controller.ServiceNameFactory; import org.jboss.as.controller.access.management.DelegatingConfigurableAuthorizer; import org.jboss.as.controller.access.management.ManagementSecurityIdentitySupplier; import org.jboss.as.controller.audit.ManagedAuditLogger; @@ -136,7 +138,7 @@ public final class ServerService extends AbstractControllerService { /** Service is not for general use, so the service name is not declared in the more visible {@code Services} */ - public static final ServiceName JBOSS_SERVER_CLIENT_FACTORY = CLIENT_FACTORY_CAPABILITY.getCapabilityServiceName(); + public static final ServiceName JBOSS_SERVER_CLIENT_FACTORY = ServiceNameFactory.resolveServiceName(ModelControllerClientFactory.SERVICE_DESCRIPTOR); /** Service is not for general use, so the service name is not declared in the more visible {@code Services} */ public static final ServiceName JBOSS_SERVER_NOTIFICATION_REGISTRY = NOTIFICATION_REGISTRY_CAPABILITY.getCapabilityServiceName(); /** Service is not for general use, so the service name is not declared in the more visible {@code Services} */ diff --git a/testsuite/standalone/src/test/java/org/wildfly/core/test/standalone/extension/booterror/RootResourceDefinition.java b/testsuite/standalone/src/test/java/org/wildfly/core/test/standalone/extension/booterror/RootResourceDefinition.java index 31d80a282cf..56f912518f3 100644 --- a/testsuite/standalone/src/test/java/org/wildfly/core/test/standalone/extension/booterror/RootResourceDefinition.java +++ b/testsuite/standalone/src/test/java/org/wildfly/core/test/standalone/extension/booterror/RootResourceDefinition.java @@ -41,7 +41,7 @@ public class RootResourceDefinition extends SimpleResourceDefinition { static final RuntimeCapability CAPABILITY = RuntimeCapability.Builder.of("boot.error", Void.class) - .addRequirements("org.wildfly.management.model-controller-client-factory", "org.wildfly.management.executor") + .addRequirements(ModelControllerClientFactory.SERVICE_DESCRIPTOR.getName(), "org.wildfly.management.executor") .build(); static final SimpleAttributeDefinition ATTRIBUTE = new SimpleAttributeDefinitionBuilder("attribute", ModelType.STRING, true).build(); @@ -103,7 +103,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Res // Add a service that will invoke an op that produces a failure during start. The service // will start during boot so that simulates a non-boot op failing during boot CapabilityServiceBuilder builder = context.getCapabilityServiceTarget().addCapability(CAPABILITY); - Supplier mccf = builder.requiresCapability("org.wildfly.management.model-controller-client-factory", ModelControllerClientFactory.class); + Supplier mccf = builder.requires(ModelControllerClientFactory.SERVICE_DESCRIPTOR); Supplier executor = builder.requiresCapability("org.wildfly.management.executor", Executor.class); builder.setInstance(new BootErrorService(mccf, executor)).install(); } diff --git a/testsuite/standalone/src/test/resources/org/wildfly/core/test/standalone/extension/booterror/module.xml b/testsuite/standalone/src/test/resources/org/wildfly/core/test/standalone/extension/booterror/module.xml index 134780780de..c73550507c0 100644 --- a/testsuite/standalone/src/test/resources/org/wildfly/core/test/standalone/extension/booterror/module.xml +++ b/testsuite/standalone/src/test/resources/org/wildfly/core/test/standalone/extension/booterror/module.xml @@ -18,5 +18,6 @@ +