Java Code Examples for org.jboss.msc.service.ServiceBuilder#requires()

The following examples show how to use org.jboss.msc.service.ServiceBuilder#requires() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagementRemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
 *  @param serviceTarget the service target to install the services into
 * @param endpointName the name of the endpoint to install a channel listener into
 * @param channelName the name of the channel
 * @param operationHandlerName the name of the operation handler to handle request for this channel
 * @param options the remoting options
 * @param onDemand whether to install the services on demand
 */
public static void installManagementChannelOpenListenerService(
        final ServiceTarget serviceTarget,
        final ServiceName endpointName,
        final String channelName,
        final ServiceName operationHandlerName,
        final OptionMap options,
        final boolean onDemand) {

    final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
    final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
    builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
    builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
    builder.install();
}
 
Example 2
Source File: ConsoleAvailabilityUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void setupController() throws InterruptedException {
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();

    this.controlledProcessState = new ControlledProcessState(true);

    ServiceBuilder<?> sb = target.addService(ServiceName.of("ModelController"));
    this.caSupplier = sb.requires(CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName());

    ConsoleAvailabilityControllerTmp caService = new ConsoleAvailabilityControllerTmp(controlledProcessState);

    ControlledProcessStateService.addService(target, controlledProcessState);
    ConsoleAvailabilityService.addService(target, () -> {});

    sb.setInstance(caService)
            .install();

    caService.awaitStartup(30, TimeUnit.SECONDS);
}
 
Example 3
Source File: RemotingServices.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Deprecated
public static void installConnectorServicesForNetworkInterfaceBinding(final ServiceTarget serviceTarget,
                                                                      final ServiceName endpointName,
                                                                      final String connectorName,
                                                                      final ServiceName networkInterfaceBindingName,
                                                                      final int port,
                                                                      final OptionMap connectorPropertiesOptionMap,
                                                                      final ServiceName securityRealm,
                                                                      final ServiceName saslAuthenticationFactory,
                                                                      final ServiceName sslContext,
                                                                      final ServiceName socketBindingManager) {
    final ServiceName serviceName= serverServiceName(connectorName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null;
    final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null;
    final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext): null;
    final Supplier<SocketBindingManager> sbmSupplier = socketBindingManager != null ? builder.requires(socketBindingManager) : null;
    final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requires(networkInterfaceBindingName);
    builder.setInstance(new InjectedNetworkBindingStreamServerService(streamServerConsumer,
            eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, ibSupplier, connectorPropertiesOptionMap, port));
    builder.install();
}
 
Example 4
Source File: GenericOutboundConnectionAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
void installRuntimeService(final OperationContext context, final ModelNode operation, final ModelNode fullModel) throws OperationFailedException {
    final PathAddress pathAddress = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String connectionName = pathAddress.getLastElement().getValue();

    // Get the destination URI
    final URI uri = getDestinationURI(context, operation);

    // create the service
    final ServiceName serviceName = OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName);
    // also add an alias service name to easily distinguish between a generic, remote and local type of connection services
    final ServiceName aliasServiceName = GenericOutboundConnectionService.GENERIC_OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);
    final ServiceName deprecatedServiceName = AbstractOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);

    final ServiceBuilder<?> builder = context.getServiceTarget().addService(serviceName);
    final Consumer<GenericOutboundConnectionService> serviceConsumer = builder.provides(deprecatedServiceName, aliasServiceName);
    builder.setInstance(new GenericOutboundConnectionService(serviceConsumer, uri));
    builder.requires(RemotingServices.SUBSYSTEM_ENDPOINT);
    builder.install();
}
 
Example 5
Source File: DeploymentCompleteServiceProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if(deploymentUnit.getParent() == null) {
        for(final DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) {
            deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_COMPLETE_SERVICES, serviceName(subDeployment.getServiceName()));
        }
    }

    final ServiceBuilder<?> sb = phaseContext.getServiceTarget().addService(serviceName(deploymentUnit.getServiceName()), Service.NULL);
    final List<ServiceName> deploymentCompleteServices = deploymentUnit.getAttachmentList(Attachments.DEPLOYMENT_COMPLETE_SERVICES);
    if (deploymentCompleteServices != null) {
        for (final ServiceName deploymentCompleteService : deploymentCompleteServices) {
            sb.requires(deploymentCompleteService);
        }
    }
    sb.install();
}
 
Example 6
Source File: ManagementChannelRegistryService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void addService(final ServiceTarget serviceTarget, final ServiceName endpointName) {
    final ServiceBuilder<?> sb = serviceTarget.addService(SERVICE_NAME);
    final Consumer<ManagementChannelRegistryService> serviceConsumer = sb.provides(SERVICE_NAME);
    sb.setInstance(new ManagementChannelRegistryService(serviceConsumer));
    // Make sure the endpoint service does not close all connections
    sb.requires(endpointName);
    sb.install();
}
 
Example 7
Source File: ContentCleanerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void addService(final ServiceTarget serviceTarget, final ServiceName clientFactoryService, final ServiceName scheduledExecutorServiceName) {
    final ServiceBuilder<?> builder = serviceTarget.addService(SERVICE_NAME);
    final Supplier<ModelControllerClientFactory> mccfSupplier = builder.requires(clientFactoryService);
    final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME);
    final Supplier<ScheduledExecutorService> sesSupplier = builder.requires(scheduledExecutorServiceName);
    final Supplier<ExecutorService> esSupplier = Services.requireServerExecutor(builder);
    builder.setInstance(new ContentCleanerService(true, mccfSupplier, cpsnSupplier, sesSupplier, esSupplier));
    builder.install();
}
 
Example 8
Source File: SecurityRealmAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Supplier<CallbackHandlerService> addJaasService(OperationContext context, ModelNode jaas, String realmName, ServiceTarget serviceTarget,
                            boolean injectServerManager, ServiceBuilder<?> realmBuilder) throws OperationFailedException {
    final ServiceName jaasServiceName = JaasCallbackHandler.ServiceUtil.createServiceName(realmName);
    final String name = JaasAuthenticationResourceDefinition.NAME.resolveModelAttribute(context, jaas).asString();
    final boolean assignGroups = JaasAuthenticationResourceDefinition.ASSIGN_GROUPS.resolveModelAttribute(context, jaas).asBoolean();
    final ServiceBuilder<?> builder = serviceTarget.addService(jaasServiceName);
    final Consumer<CallbackHandlerService> chsConsumer = builder.provides(jaasServiceName);
    final Supplier<ServerSecurityManager> smSupplier = injectServerManager ? builder.requires(ServiceName.JBOSS.append("security", "simple-security-manager")) : null;
    builder.setInstance(new JaasCallbackHandler(chsConsumer, smSupplier, realmName, name, assignGroups));
    builder.setInitialMode(ON_DEMAND);
    builder.install();

    return CallbackHandlerService.ServiceUtil.requires(realmBuilder, jaasServiceName);
}
 
Example 9
Source File: RootResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    String osb = ATTRIBUTE.resolveModelAttribute(context, resource.getModel()).asString();
    Service<Void> service = new AbstractService<Void>() {};
    ServiceBuilder sb = context.getServiceTarget().addService(ServiceName.of("wfcore-1106"), service);
    sb.requires(context.getCapabilityServiceName("org.wildfly.network.outbound-socket-binding", osb, OutboundSocketBinding.class));
    sb.install();
}
 
Example 10
Source File: ConsoleAvailabilityService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void addService(ServiceTarget serviceTarget, LogAdminConsole logMessageAction) {
    ServiceName serviceName = CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName();

    ServiceBuilder<?> sb = serviceTarget.addService(serviceName);
    Consumer<ConsoleAvailability> caConsumer = sb.provides(serviceName);
    Supplier<ProcessStateNotifier> psnSupplier = sb.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME);

    ConsoleAvailabilityService consoleAvailabilityService = new ConsoleAvailabilityService(caConsumer, psnSupplier, logMessageAction);
    sb.setInstance(consoleAvailabilityService);

    sb.install();
}
 
Example 11
Source File: SSLContextService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Supplier<SSLContext> requires(final ServiceBuilder<?> sb, final ServiceName parentService, final boolean trustOnly) {
    return sb.requires(createServiceName(parentService, trustOnly));
}
 
Example 12
Source File: UndertowSSLServiceActivator.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void createService(String address, int port, HttpHandler handler, ServiceBuilder<?> builder) {
    Supplier<SSLContext> res = builder.requires(ServiceName.parse("org.wildfly.security.ssl-context.test-context"));
    UndertowSSLService service = new UndertowSSLService("0.0.0.0", port, handler, res);
    builder.setInstance(service);
}
 
Example 13
Source File: LdapConnectionManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Supplier<LdapConnectionManager> requires(final ServiceBuilder<?> sb, final String connectionName) {
    return sb.requires(createServiceName(connectionName));
}
 
Example 14
Source File: AbstractKeyManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Supplier<AbstractKeyManagerService> requires(final ServiceBuilder<?> sb, final ServiceName parentService) {
    return sb.requires(createServiceName(parentService));
}
 
Example 15
Source File: HttpManagementAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@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 securityRealm = commonPolicy.getSecurityRealm();
    final String sslContext = commonPolicy.getSSLContext();
    if (httpAuthenticationFactory == null && securityRealm == 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<SecurityRealm> srSupplier = securityRealm != null ? SecurityRealm.ServiceUtil.requires(builder, securityRealm) : 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, srSupplier, 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(), securityRealm, commonPolicy.getSaslAuthenticationFactory());

        return Arrays.asList(UndertowHttpManagementService.SERVICE_NAME, HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
    }
    return Collections.singletonList(UndertowHttpManagementService.SERVICE_NAME);
}
 
Example 16
Source File: AbstractTrustManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Supplier<TrustManager[]> requires(final ServiceBuilder<?> sb, final ServiceName parentService) {
    return sb.requires(createServiceName(parentService));
}
 
Example 17
Source File: ElytronDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static <T> ServiceBuilder<T>  commonRequirements(ServiceBuilder<T> serviceBuilder, boolean dependOnProperties, boolean dependOnProviderRegistration) {
    if (dependOnProperties) serviceBuilder.requires(SecurityPropertyService.SERVICE_NAME);
    if (dependOnProviderRegistration) serviceBuilder.requires(ProviderRegistrationService.SERVICE_NAME);
    return serviceBuilder;
}
 
Example 18
Source File: AuditResourceDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static ResourceDefinition getFileAuditLogResourceDefinition() {
    AttributeDefinition[] attributes = new AttributeDefinition[] { PATH, RELATIVE_TO, AUTOFLUSH, SYNCHRONIZED, FORMAT };
    AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {

        @Override
        protected ValueSupplier<SecurityEventListener> getValueSupplier(
                ServiceBuilder<SecurityEventListener> serviceBuilder, OperationContext context, ModelNode model)
                throws OperationFailedException {

            final boolean synv = SYNCHRONIZED.resolveModelAttribute(context, model).asBoolean();
            final boolean autoflush = AUTOFLUSH.resolveModelAttribute(context, model).asBoolean(synv);
            final Format format = Format.valueOf(FORMAT.resolveModelAttribute(context, model).asString());

            final InjectedValue<PathManager> pathManager = new InjectedValue<PathManager>();

            final String path = PATH.resolveModelAttribute(context, model).asString();
            final String relativeTo = RELATIVE_TO.resolveModelAttribute(context, model).asStringOrNull();

            if (relativeTo != null) {
                serviceBuilder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, pathManager);
                serviceBuilder.requires(pathName(relativeTo));
            }

            return new EndpointClosingEventListenerSupplier() {
                @Override
                public SecurityEventListener get() throws StartException {
                    PathResolver pathResolver = pathResolver();
                    pathResolver.path(path);
                    if (relativeTo != null) {
                        pathResolver.relativeTo(relativeTo, pathManager.getValue());
                    }
                    File resolvedPath = pathResolver.resolve();

                    final Supplier<DateTimeFormatter> dateTimeFormatterSupplier = () -> DateTimeFormatter.ofPattern(DATE_FORMAT).withZone(ZoneId.systemDefault());
                    final SecurityEventVisitor<?, String> formatter = Format.JSON == format ? JsonSecurityEventFormatter.builder().setDateTimeFormatterSupplier(dateTimeFormatterSupplier).build() : SimpleSecurityEventFormatter.builder().setDateTimeFormatterSupplier(dateTimeFormatterSupplier).build();
                    try {
                        endpoint = FileAuditEndpoint.builder().setLocation(resolvedPath.toPath())
                                .setSyncOnAccept(synv)
                                .setFlushOnAccept(autoflush)
                                .setDateTimeFormatterSupplier(dateTimeFormatterSupplier).build();
                    } catch (IOException e) {
                        throw ROOT_LOGGER.unableToStartService(e);
                    }

                    return SecurityEventListener.from(AuditLogger.builder()
                            .setPriorityMapper(m -> EventPriority.WARNING)
                            .setMessageFormatter(m -> m.accept(formatter, null))
                            .setAuditEndpoint(endpoint)
                            .build());
                }
            };
        }
    };

    return new TrivialResourceDefinition(FILE_AUDIT_LOG, add, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY);
}
 
Example 19
Source File: CallbackHandlerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Supplier<CallbackHandlerService> requires(final ServiceBuilder<?> sb, final ServiceName serviceName) {
    return sb.requires(serviceName);
}
 
Example 20
Source File: Services.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Creates dependency on management executor and returns supplier providing it.
 *
 * @param builder the builder to use for requirement
 * @return supplier providing server executor
 */
public static Supplier<ExecutorService> requireServerExecutor(final ServiceBuilder<?> builder) {
    return builder.requires(ServerService.MANAGEMENT_EXECUTOR);
}