use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.
the class HttpManagementAddHandler method installServices.
@Override
protected List<ServiceName> installServices(OperationContext context, HttpInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException {
populateHostControllerInfo(hostControllerInfo, context, model);
CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
boolean onDemand = context.isBooting();
String interfaceName = hostControllerInfo.getHttpManagementInterface();
int port = hostControllerInfo.getHttpManagementPort();
String secureInterfaceName = hostControllerInfo.getHttpManagementSecureInterface();
int securePort = hostControllerInfo.getHttpManagementSecurePort();
ROOT_LOGGER.creatingHttpManagementService(interfaceName, port, securePort);
boolean consoleEnabled = HttpManagementResourceDefinition.CONSOLE_ENABLED.resolveModelAttribute(context, model).asBoolean();
ConsoleMode consoleMode = ConsoleMode.CONSOLE;
if (consoleEnabled) {
if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
consoleMode = ConsoleMode.ADMIN_ONLY;
} else if (!hostControllerInfo.isMasterDomainController()) {
consoleMode = ConsoleMode.SLAVE_HC;
}
} else {
consoleMode = ConsoleMode.NO_CONSOLE;
}
NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false));
// Track active requests
final ServiceName requestProcessorName = UndertowHttpManagementService.SERVICE_NAME.append("requests");
HttpManagementRequestsService.installService(requestProcessorName, serviceTarget);
final String httpAuthenticationFactory = commonPolicy.getHttpAuthenticationFactory();
final String sslContext = commonPolicy.getSSLContext();
if (httpAuthenticationFactory == null) {
ROOT_LOGGER.httpManagementInterfaceIsUnsecured();
}
final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
final Consumer<HttpManagement> hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
final Supplier<ListenerRegistry> lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
final Supplier<ModelController> mcSupplier = builder.requires(DomainModelControllerService.SERVICE_NAME);
final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, interfaceName);
final Supplier<NetworkInterfaceBinding> sibSupplier = builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, secureInterfaceName);
final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
final Supplier<ConsoleAvailability> caSupplier = builder.requiresCapability("org.wildfly.management.console-availability", ConsoleAvailability.class);
final Supplier<ManagementHttpRequestProcessor> rpSupplier = builder.requires(requestProcessorName);
final Supplier<XnioWorker> xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME);
final Supplier<Executor> eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME);
final Supplier<HttpAuthenticationFactory> hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null;
final Supplier<SSLContext> 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, cpsnSupplier, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, port, securePort, commonPolicy.getAllowedOrigins(), consoleMode, environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier);
builder.setInstance(service);
builder.setInitialMode(onDemand ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.ACTIVE).install();
// Add service preventing the server from shutting down
final ServiceName shutdownName = UndertowHttpManagementService.SERVICE_NAME.append("shutdown");
final ServiceBuilder<?> sb = serviceTarget.addService(shutdownName);
final Supplier<Executor> executorSupplier = sb.requires(HostControllerService.HC_EXECUTOR_SERVICE_NAME);
final Supplier<ManagementHttpRequestProcessor> processorSupplier = sb.requires(requestProcessorName);
final Supplier<ManagementChannelRegistryService> registrySupplier = sb.requires(ManagementChannelRegistryService.SERVICE_NAME);
sb.requires(UndertowHttpManagementService.SERVICE_NAME);
sb.setInstance(new HttpShutdownService(executorSupplier, processorSupplier, registrySupplier));
sb.install();
if (commonPolicy.isHttpUpgradeEnabled()) {
NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostControllerInfo.getLocalHostName(), context.getServiceRegistry(true), onDemand);
final String httpConnectorName;
if (port > -1 || securePort < 0) {
httpConnectorName = ManagementRemotingServices.HTTP_CONNECTOR;
} else {
httpConnectorName = ManagementRemotingServices.HTTPS_CONNECTOR;
}
RemotingHttpUpgradeService.installServices(context, ManagementRemotingServices.HTTP_CONNECTOR, httpConnectorName, ManagementRemotingServices.MANAGEMENT_ENDPOINT, commonPolicy.getConnectorOptions(), commonPolicy.getSaslAuthenticationFactory());
return Arrays.asList(UndertowHttpManagementService.SERVICE_NAME, HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
}
return Collections.singletonList(UndertowHttpManagementService.SERVICE_NAME);
}
use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.
the class AbstractChannelOpenListenerService method start.
@Override
public synchronized void start(StartContext context) throws StartException {
try {
closed = false;
RemotingLogger.ROOT_LOGGER.debugf("Registering channel listener for %s", channelName);
final ManagementChannelRegistryService registry = this.registrySupplier.get();
final Registration registration = endpointSupplier.get().registerService(channelName, this, optionMap);
// Add to global registry
registry.register(registration);
trackerService = registry.getTrackerService();
} catch (Exception e) {
throw RemotingLogger.ROOT_LOGGER.couldNotStartChanelListener(e);
}
}
use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.
the class HttpManagementAddHandler method installServices.
@Override
protected List<ServiceName> installServices(OperationContext context, HttpInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException {
final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
// Socket-binding reference based config
final String socketBindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asStringOrNull();
final String secureSocketBindingName = SECURE_SOCKET_BINDING.resolveModelAttribute(context, model).asStringOrNull();
// Log the config
if (socketBindingName != null) {
if (secureSocketBindingName != null) {
ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSocketAndSecureSocket(socketBindingName, secureSocketBindingName);
} else {
ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSocket(socketBindingName);
}
} else if (secureSocketBindingName != null) {
ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSecureSocket(secureSocketBindingName);
}
ConsoleMode consoleMode = consoleMode(commonPolicy.isConsoleEnabled(), context.getRunningMode() == RunningMode.ADMIN_ONLY);
// Track active requests
final ServiceName requestProcessorName = UndertowHttpManagementService.SERVICE_NAME.append("requests");
HttpManagementRequestsService.installService(requestProcessorName, serviceTarget);
NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false));
final String httpAuthenticationFactory = commonPolicy.getHttpAuthenticationFactory();
final String sslContext = commonPolicy.getSSLContext();
if (httpAuthenticationFactory == null) {
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<HttpManagement> hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
final Supplier<ListenerRegistry> lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
final Supplier<ModelController> mcSupplier = builder.requires(Services.JBOSS_SERVER_CONTROLLER);
final Supplier<SocketBinding> sbSupplier = socketBindingName != null ? builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, socketBindingName) : null;
final Supplier<SocketBinding> ssbSupplier = secureSocketBindingName != null ? builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, secureSocketBindingName) : null;
final Supplier<SocketBindingManager> sbmSupplier = builder.requiresCapability("org.wildfly.management.socket-binding-manager", SocketBindingManager.class);
final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
final Supplier<ConsoleAvailability> caSupplier = builder.requiresCapability("org.wildfly.management.console-availability", ConsoleAvailability.class);
final Supplier<ManagementHttpRequestProcessor> rpSupplier = builder.requires(requestProcessorName);
final Supplier<XnioWorker> xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME);
final Supplier<Executor> eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME);
final Supplier<HttpAuthenticationFactory> hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null;
final Supplier<SSLContext> 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, cpsnSupplier, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, null, null, commonPolicy.getAllowedOrigins(), consoleMode, environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier);
builder.setInstance(undertowService);
builder.install();
// Add service preventing the server from shutting down
final ServiceName shutdownName = UndertowHttpManagementService.SERVICE_NAME.append("shutdown");
final ServiceBuilder<?> sb = serviceTarget.addService(shutdownName);
final Supplier<Executor> executorSupplier = sb.requires(Services.JBOSS_SERVER_EXECUTOR);
final Supplier<ManagementHttpRequestProcessor> processorSupplier = sb.requires(requestProcessorName);
final Supplier<ManagementChannelRegistryService> registrySupplier = sb.requires(ManagementChannelRegistryService.SERVICE_NAME);
sb.requires(UndertowHttpManagementService.SERVICE_NAME);
sb.setInstance(new HttpShutdownService(executorSupplier, processorSupplier, registrySupplier));
sb.install();
if (commonPolicy.isHttpUpgradeEnabled()) {
final String hostName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);
NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostName, context.getServiceRegistry(false));
final String httpConnectorName;
if (socketBindingName != null || (secureSocketBindingName == null)) {
httpConnectorName = ManagementRemotingServices.HTTP_CONNECTOR;
} else {
httpConnectorName = ManagementRemotingServices.HTTPS_CONNECTOR;
}
RemotingHttpUpgradeService.installServices(context, ManagementRemotingServices.HTTP_CONNECTOR, httpConnectorName, ManagementRemotingServices.MANAGEMENT_ENDPOINT, commonPolicy.getConnectorOptions(), commonPolicy.getSaslAuthenticationFactory());
return Arrays.asList(UndertowHttpManagementService.SERVICE_NAME, HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
}
return Collections.singletonList(UndertowHttpManagementService.SERVICE_NAME);
}
Aggregations