diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/operations/HttpManagementAddHandler.java b/host-controller/src/main/java/org/jboss/as/host/controller/operations/HttpManagementAddHandler.java index a14111978da..5bc437c6cd9 100644 --- a/host-controller/src/main/java/org/jboss/as/host/controller/operations/HttpManagementAddHandler.java +++ b/host-controller/src/main/java/org/jboss/as/host/controller/operations/HttpManagementAddHandler.java @@ -71,6 +71,7 @@ import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; +import org.wildfly.common.function.Functions; import org.wildfly.security.auth.server.HttpAuthenticationFactory; import org.wildfly.security.auth.server.SaslAuthenticationFactory; import org.xnio.XnioWorker; @@ -163,7 +164,7 @@ protected List installServices(OperationContext context, HttpInterf final Supplier scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null; final UndertowHttpManagementService service = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, null, null, null, ibSupplier, sibSupplier, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, port, securePort, commonPolicy.getAllowedOrigins(), consoleMode, - environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier); + Functions.constantSupplier(environment.getProductConfig().getConsoleSlot()), commonPolicy.getConstantHeaders(), caSupplier); builder.setInstance(service); builder.setInitialMode(onDemand ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.ACTIVE).install(); diff --git a/server/src/main/java/org/jboss/as/server/mgmt/UndertowHttpManagementService.java b/server/src/main/java/org/jboss/as/server/mgmt/UndertowHttpManagementService.java index 35a59068940..8916053826f 100644 --- a/server/src/main/java/org/jboss/as/server/mgmt/UndertowHttpManagementService.java +++ b/server/src/main/java/org/jboss/as/server/mgmt/UndertowHttpManagementService.java @@ -106,7 +106,7 @@ public class UndertowHttpManagementService implements Service { private final Supplier httpAuthFactorySupplier; private final Supplier sslContextSupplier; private final ConsoleMode consoleMode; - private final String consoleSlot; + private final Supplier consoleSlot; private final Map> constantHeaders; private final Supplier consoleAvailabilitySupplier; private final Supplier virtualSecurityDomainSupplier; @@ -220,7 +220,7 @@ public UndertowHttpManagementService(final Consumer httpManageme final Integer securePort, final Collection allowedOrigins, final ConsoleMode consoleMode, - final String consoleSlot, + final Supplier consoleSlot, final Map> constantHeaders, final Supplier consoleAvailabilitySupplier) { this(httpManagementConsumer, listenerRegistrySupplier, modelControllerSupplier, socketBindingSupplier, @@ -246,7 +246,7 @@ public UndertowHttpManagementService(final Consumer httpManageme final Integer securePort, final Collection allowedOrigins, final ConsoleMode consoleMode, - final String consoleSlot, + final Supplier consoleSlot, final Map> constantHeaders, final Supplier consoleAvailabilitySupplier, final Supplier virtualSecurityDomainSupplier, @@ -363,7 +363,7 @@ public synchronized void start(final StartContext context) throws StartException .setModelController(modelController) .setSSLContext(sslContext) .setConsoleMode(consoleMode) - .setConsoleSlot(consoleSlot) + .setConsoleSlot(consoleSlot.get()) .setChannelUpgradeHandler(upgradeHandler) .setManagementHttpRequestProcessor(requestProcessorSupplier.get()) .setAllowedOrigins(allowedOrigins) 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 24cffe813dd..d7786e45387 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 @@ -145,7 +145,6 @@ protected List installServices(OperationContext context, HttpInterf ServerLogger.ROOT_LOGGER.httpManagementInterfaceIsUnsecured(); } - ServerEnvironment environment = (ServerEnvironment) context.getServiceRegistry(false).getRequiredService(ServerEnvironmentService.SERVICE_NAME).getValue(); final CapabilityServiceBuilder builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY); final Consumer hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY); final Supplier lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY); @@ -158,6 +157,15 @@ 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 consoleSlot = new Supplier<>() { + @Override + public String get() { + return environment.get().getProductConfig().getConsoleSlot(); + } + }; Supplier virtualSecurityDomainSupplier = null; Supplier virtualMechanismFactorySupplier = null; if (VirtualDomainMarkerUtility.isVirtualDomainRequired(context)) { @@ -170,7 +178,7 @@ protected List installServices(OperationContext context, HttpInterf final Supplier scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null; final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, sbSupplier, ssbSupplier, sbmSupplier, null, null, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, null, null, commonPolicy.getAllowedOrigins(), consoleMode, - environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier); + consoleSlot, commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier); builder.setInstance(undertowService); builder.install();