diff --git a/server/src/main/java/org/jboss/as/server/ServerEnvironmentService.java b/server/src/main/java/org/jboss/as/server/ServerEnvironmentService.java index 2a35b5a6210..1462aeec495 100644 --- a/server/src/main/java/org/jboss/as/server/ServerEnvironmentService.java +++ b/server/src/main/java/org/jboss/as/server/ServerEnvironmentService.java @@ -22,6 +22,7 @@ package org.jboss.as.server; +import static org.jboss.as.server.ServerService.SERVER_ENVIRONMENT_CAPABILITY; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; @@ -54,7 +55,10 @@ */ public class ServerEnvironmentService implements Service { + /** Standard ServiceName under which a ServerEnvironmentService would be registered */ + /** @deprecated Use {@link #SERVER_ENVIRONMENT_CAPABILITY.getCapabilityServiceName() instead} */ + @Deprecated public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("server", "environment"); /** @@ -65,8 +69,9 @@ public class ServerEnvironmentService implements Service { * @param target the batch builder. Cannot be {@code null} */ public static void addService(ServerEnvironment serverEnvironment, ServiceTarget target) { - target.addService(SERVICE_NAME, new ServerEnvironmentService(serverEnvironment)) - .install(); + target.addService(SERVER_ENVIRONMENT_CAPABILITY.getCapabilityServiceName(), new ServerEnvironmentService(serverEnvironment)) + .addAliases(SERVICE_NAME) + .install(); } private final ServerEnvironment serverEnvironment; 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 18c7932866d..7600028e079 100644 --- a/server/src/main/java/org/jboss/as/server/ServerService.java +++ b/server/src/main/java/org/jboss/as/server/ServerService.java @@ -178,6 +178,7 @@ public final class ServerService extends AbstractControllerService { static final String SUSPEND_CONTROLLER_CAPABILITY_NAME = "org.wildfly.server.suspend-controller"; static final String EXTERNAL_MODULE_CAPABILITY_NAME = "org.wildfly.management.external-module"; + public static final String SERVER_ENVIRONMENT_CAPABILITY_NAME = "org.wildfly.server.environment"; static final RuntimeCapability SUSPEND_CONTROLLER_CAPABILITY = RuntimeCapability.Builder.of(SUSPEND_CONTROLLER_CAPABILITY_NAME, SuspendController.class) @@ -186,6 +187,8 @@ public final class ServerService extends AbstractControllerService { static final RuntimeCapability EXTERNAL_MODULE_CAPABILITY = RuntimeCapability.Builder.of(EXTERNAL_MODULE_CAPABILITY_NAME, ExternalModule.class) .build(); + static final RuntimeCapability SERVER_ENVIRONMENT_CAPABILITY = RuntimeCapability.Builder.of(SERVER_ENVIRONMENT_CAPABILITY_NAME, ServerEnvironment.class).build(); + /** * Construct a new instance. @@ -504,6 +507,8 @@ protected void initModel(ManagementModel managementModel, Resource modelControll new RuntimeCapabilityRegistration(EXTERNAL_MODULE_CAPABILITY, CapabilityScope.GLOBAL,new RegistrationPoint(PathAddress.EMPTY_ADDRESS, null))); capabilityRegistry.registerCapability( new RuntimeCapabilityRegistration(CONSOLE_AVAILABILITY_CAPABILITY, CapabilityScope.GLOBAL, new RegistrationPoint(PathAddress.EMPTY_ADDRESS, null))); + capabilityRegistry.registerCapability( + new RuntimeCapabilityRegistration(SERVER_ENVIRONMENT_CAPABILITY, CapabilityScope.GLOBAL, new RegistrationPoint(PathAddress.EMPTY_ADDRESS, null))); // Record the core capabilities with the root MRR so reads of it will show it as their provider // This also gets them recorded as 'possible capabilities' in the capability registry @@ -514,6 +519,7 @@ protected void initModel(ManagementModel managementModel, Resource modelControll rootRegistration.registerCapability(PROCESS_STATE_NOTIFIER_CAPABILITY); rootRegistration.registerCapability(EXTERNAL_MODULE_CAPABILITY); rootRegistration.registerCapability(CONSOLE_AVAILABILITY_CAPABILITY); + rootRegistration.registerCapability(SERVER_ENVIRONMENT_CAPABILITY); } @Override diff --git a/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java b/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java index 72c771cb601..4481e270591 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java +++ b/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java @@ -201,7 +201,7 @@ public static void doDeploy(final OperationContext context, final String deploym contentService = ContentServitor.addService(serviceTarget, contentsServiceName, contents[0].hash); } else { isExplodedContent = true; - contentService = ManagedExplodedContentServitor.addService(serviceTarget, contentsServiceName, managementName, contents[0].hash); + contentService = ManagedExplodedContentServitor.addService(context, contentsServiceName, managementName, contents[0].hash); } } else { diff --git a/server/src/main/java/org/jboss/as/server/deployment/ManagedExplodedContentServitor.java b/server/src/main/java/org/jboss/as/server/deployment/ManagedExplodedContentServitor.java index 4dccc78422c..c036054e45b 100644 --- a/server/src/main/java/org/jboss/as/server/deployment/ManagedExplodedContentServitor.java +++ b/server/src/main/java/org/jboss/as/server/deployment/ManagedExplodedContentServitor.java @@ -16,6 +16,7 @@ package org.jboss.as.server.deployment; +import static org.jboss.as.server.ServerService.SERVER_ENVIRONMENT_CAPABILITY_NAME; import static org.jboss.as.server.Services.requireServerExecutor; import java.io.IOException; @@ -29,15 +30,14 @@ import java.util.function.Supplier; import java.util.stream.Stream; +import org.jboss.as.controller.OperationContext; import org.jboss.as.repository.ContentRepository; import org.jboss.as.repository.ExplodedContentException; import org.jboss.as.server.ServerEnvironment; -import org.jboss.as.server.ServerEnvironmentService; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; -import org.jboss.msc.service.ServiceTarget; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; @@ -61,11 +61,11 @@ class ManagedExplodedContentServitor implements Service { private final byte[] hash; private volatile Path deploymentRoot; - static ServiceController addService(final ServiceTarget serviceTarget, final ServiceName serviceName, final String managementName, final byte[] hash) { - final ServiceBuilder sb = serviceTarget.addService(serviceName); + static ServiceController addService(OperationContext context, final ServiceName serviceName, final String managementName, final byte[] hash) { + final ServiceBuilder sb = context.getCapabilityServiceTarget().addService(serviceName); final Consumer vfConsumer = sb.provides(serviceName); final Supplier crSupplier = sb.requires(ContentRepository.SERVICE_NAME); - final Supplier seSupplier = sb.requires(ServerEnvironmentService.SERVICE_NAME); + final Supplier seSupplier = sb.requires(context.getCapabilityServiceName(SERVER_ENVIRONMENT_CAPABILITY_NAME, ServerEnvironment.class)); final Supplier esSupplier = requireServerExecutor(sb); sb.setInstance(new ManagedExplodedContentServitor(managementName, hash, vfConsumer, crSupplier, seSupplier, esSupplier)); return sb.install(); diff --git a/server/src/main/java/org/jboss/as/server/operations/HttpManagementAddHandler.java b/server/src/main/java/org/jboss/as/server/operations/HttpManagementAddHandler.java index d7786e45387..00d1c28fbac 100644 --- a/server/src/main/java/org/jboss/as/server/operations/HttpManagementAddHandler.java +++ b/server/src/main/java/org/jboss/as/server/operations/HttpManagementAddHandler.java @@ -23,6 +23,7 @@ package org.jboss.as.server.operations; import static org.jboss.as.remoting.RemotingHttpUpgradeService.HTTP_UPGRADE_REGISTRY; +import static org.jboss.as.server.ServerService.SERVER_ENVIRONMENT_CAPABILITY_NAME; import static org.jboss.as.server.mgmt.HttpManagementResourceDefinition.SECURE_SOCKET_BINDING; import static org.jboss.as.server.mgmt.HttpManagementResourceDefinition.SOCKET_BINDING; import static org.jboss.as.server.mgmt.HttpManagementResourceDefinition.SOCKET_BINDING_CAPABILITY_NAME; @@ -58,7 +59,6 @@ import org.jboss.as.remoting.management.ManagementRemotingServices; import org.jboss.as.server.ExternalManagementRequestExecutor; import org.jboss.as.server.ServerEnvironment; -import org.jboss.as.server.ServerEnvironmentService; import org.jboss.as.server.Services; import org.jboss.as.server.logging.ServerLogger; import org.jboss.as.server.mgmt.HttpManagementRequestsService; @@ -157,9 +157,7 @@ protected List installServices(OperationContext context, HttpInterf final Supplier xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME); final Supplier eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME); final Supplier hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null; - // TODO WFCORE-6321 Expose ServerEnvironment via a capability - // Supplier environment = builder.requiresCapability("org.wildfly.server.environment", ServerEnvironment.class); - Supplier environment = builder.requires(ServerEnvironmentService.SERVICE_NAME); + Supplier environment = builder.requiresCapability(SERVER_ENVIRONMENT_CAPABILITY_NAME, ServerEnvironment.class); Supplier consoleSlot = new Supplier<>() { @Override public String get() {