Java Code Examples for org.jboss.msc.service.ServiceBuilder#setInstance()
The following examples show how to use
org.jboss.msc.service.ServiceBuilder#setInstance() .
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 |
/** * 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: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installConnectorServicesForSocketBinding(final ServiceTarget serviceTarget, final ServiceName endpointName, final String connectorName, final ServiceName socketBindingName, 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 = builder.requires(socketBindingManager); final Supplier<SocketBinding> sbSupplier = builder.requires(socketBindingName); builder.setInstance(new InjectedSocketBindingStreamServerService(streamServerConsumer, eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap)); builder.install(); }
Example 3
Source File: RemotingHttpUpgradeService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installServices(final OperationContext context, final String remotingConnectorName, final String httpConnectorName, final ServiceName endpointName, final OptionMap connectorPropertiesOptionMap, final String securityRealm, final String saslAuthenticationFactory) { final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName serviceName = UPGRADE_SERVICE_NAME.append(remotingConnectorName); final ServiceBuilder<?> sb = serviceTarget.addService(serviceName); final Consumer<RemotingHttpUpgradeService> serviceConsumer = sb.provides(serviceName); final Supplier<ChannelUpgradeHandler> urSupplier = sb.requires(HTTP_UPGRADE_REGISTRY.append(httpConnectorName)); final Supplier<ListenerRegistry> lrSupplier = sb.requires(RemotingServices.HTTP_LISTENER_REGISTRY); final Supplier<Endpoint> eSupplier = sb.requires(endpointName); final Supplier<org.jboss.as.domain.management.SecurityRealm> srSupplier = securityRealm != null ? sb.requires(org.jboss.as.domain.management.SecurityRealm.ServiceUtil.createServiceName(securityRealm)) : null; final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? sb.requires(context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactory, SaslAuthenticationFactory.class)) : null; sb.setInstance(new RemotingHttpUpgradeService(serviceConsumer, urSupplier, lrSupplier, eSupplier, srSupplier, safSupplier, httpConnectorName, endpointName.getSimpleName(), connectorPropertiesOptionMap)); sb.setInitialMode(ServiceController.Mode.PASSIVE); sb.install(); }
Example 4
Source File: AccessIdentityResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String securityDomain = SECURITY_DOMAIN.resolveModelAttribute(context, model).asString(); final ServiceBuilder<?> sb = context.getServiceTarget().addService(MANAGEMENT_IDENTITY_RUNTIME_CAPABILITY.getCapabilityServiceName()); final Supplier<SecurityDomain> sdSupplier = sb.requires(context.getCapabilityServiceName(RuntimeCapability.buildDynamicCapabilityName(SECURITY_DOMAIN_CAPABILITY, securityDomain), SecurityDomain.class)); sb.setInstance(new IdentityService(sdSupplier, securityIdentitySupplier)); sb.install(); //Let's verify that the IdentityService is correctly started. context.addStep((OperationContext context1, ModelNode operation1) -> { try { ServiceController<?> controller = context1.getServiceRegistry(false).getRequiredService(MANAGEMENT_IDENTITY_RUNTIME_CAPABILITY.getCapabilityServiceName()); if (controller == null || State.UP != controller.getState()) { context.setRollbackOnly(); } } catch (ServiceNotFoundException ex) { context.setRollbackOnly(); } }, OperationContext.Stage.VERIFY); }
Example 5
Source File: ManagementRemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Set up the services to create a channel listener and operation handler service. * @param serviceTarget the service target to install the services into * @param endpointName the endpoint name to install the services into * @param channelName the name of the channel * @param executorServiceName service name of the executor service to use in the operation handler service * @param scheduledExecutorServiceName service name of the scheduled executor service to use in the operation handler service */ public static void installManagementChannelServices( final ServiceTarget serviceTarget, final ServiceName endpointName, final ModelControllerOperationHandlerFactory operationHandlerServiceFactory, final ServiceName modelControllerName, final String channelName, final ServiceName executorServiceName, final ServiceName scheduledExecutorServiceName) { final OptionMap options = OptionMap.EMPTY; final ServiceName operationHandlerName = endpointName.append(channelName).append(ModelControllerClientOperationHandlerFactoryService.OPERATION_HANDLER_NAME_SUFFIX); final ServiceBuilder<?> builder = serviceTarget.addService(operationHandlerName); final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer = builder.provides(operationHandlerName); final Supplier<ModelController> mcSupplier = builder.requires(modelControllerName); final Supplier<ExecutorService> eSupplier = builder.requires(executorServiceName); final Supplier<ScheduledExecutorService> seSupplier = builder.requires(scheduledExecutorServiceName); builder.setInstance(operationHandlerServiceFactory.newInstance(serviceConsumer, mcSupplier, eSupplier, seSupplier)); builder.install(); installManagementChannelOpenListenerService(serviceTarget, endpointName, channelName, operationHandlerName, options, false); }
Example 6
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Supplier<SubjectSupplementalService> addPropertiesAuthorizationService(OperationContext context, ModelNode properties, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName propsServiceName = PropertiesSubjectSupplemental.ServiceUtil.createServiceName(realmName); final String path = PropertiesAuthorizationResourceDefinition.PATH.resolveModelAttribute(context, properties).asString(); final ModelNode relativeToNode = PropertiesAuthorizationResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, properties); final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null; final ServiceBuilder<?> builder = serviceTarget.addService(propsServiceName); final Consumer<SubjectSupplementalService> sssConsumer = builder.provides(propsServiceName); Supplier<PathManager> pmSupplier = null; if (relativeTo != null) { pmSupplier = builder.requires(context.getCapabilityServiceName(PATH_MANAGER_CAPABILITY, PathManager.class)); builder.requires(pathName(relativeTo)); } builder.setInstance(new PropertiesSubjectSupplemental(sssConsumer, pmSupplier, realmName, path, relativeTo)); builder.setInitialMode(ON_DEMAND); builder.install(); return SubjectSupplementalService.ServiceUtil.requires(realmBuilder, propsServiceName); }
Example 7
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@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 8
Source File: RemoteOutboundConnectionAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
void installRuntimeService(final OperationContext context, final ModelNode operation, final ModelNode fullModel) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final String connectionName = address.getLastElement().getValue(); final String outboundSocketBindingRef = RemoteOutboundConnectionResourceDefinition.OUTBOUND_SOCKET_BINDING_REF.resolveModelAttribute(context, operation).asString(); final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBindingRef, OutboundSocketBinding.class); final OptionMap connOpts = ConnectorUtils.getOptions(context, fullModel.get(CommonAttributes.PROPERTY)); final String username = RemoteOutboundConnectionResourceDefinition.USERNAME.resolveModelAttribute(context, fullModel).asStringOrNull(); final String securityRealm = fullModel.hasDefined(CommonAttributes.SECURITY_REALM) ? fullModel.require(CommonAttributes.SECURITY_REALM).asString() : null; final String authenticationContext = fullModel.hasDefined(CommonAttributes.AUTHENTICATION_CONTEXT) ? fullModel.require(CommonAttributes.AUTHENTICATION_CONTEXT).asString() : null; final String protocol = authenticationContext != null ? null : RemoteOutboundConnectionResourceDefinition.PROTOCOL.resolveModelAttribute(context, operation).asString(); // create the service final ServiceName serviceName = OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName); final ServiceName aliasServiceName = RemoteOutboundConnectionService.REMOTE_OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName); final ServiceName deprecatedName = AbstractOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName); final ServiceBuilder<?> builder = context.getServiceTarget().addService(serviceName); final Consumer<RemoteOutboundConnectionService> serviceConsumer = builder.provides(deprecatedName, aliasServiceName); final Supplier<OutboundSocketBinding> osbSupplier = builder.requires(outboundSocketBindingDependency); final Supplier<SecurityRealm> srSupplier = securityRealm != null ? SecurityRealm.ServiceUtil.requires(builder, securityRealm) : null; final Supplier<AuthenticationContext> acSupplier = authenticationContext != null ? builder.requires(context.getCapabilityServiceName(AUTHENTICATION_CONTEXT_CAPABILITY, authenticationContext, AuthenticationContext.class)) : null; builder.requires(RemotingServices.SUBSYSTEM_ENDPOINT); builder.setInstance(new RemoteOutboundConnectionService(serviceConsumer, osbSupplier, srSupplier, acSupplier, connOpts, username, protocol)); builder.install(); }
Example 9
Source File: ContentCleanerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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 10
Source File: ContentCleanerService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void addServiceOnHostController(final ServiceTarget serviceTarget, final ServiceName hostControllerServiceName, final ServiceName clientFactoryServiceName, final ServiceName hostControllerExecutorServiceName, final ServiceName scheduledExecutorServiceName) { final ServiceBuilder<?> builder = serviceTarget.addService(SERVICE_NAME); final Supplier<ModelControllerClientFactory> mccfSupplier = builder.requires(clientFactoryServiceName); final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME); final Supplier<ScheduledExecutorService> sesSupplier = builder.requires(scheduledExecutorServiceName); final Supplier<ExecutorService> esSupplier = builder.requires(hostControllerExecutorServiceName); builder.setInstance(new ContentCleanerService(false, mccfSupplier, cpsnSupplier, sesSupplier, esSupplier)); builder.install(); }
Example 11
Source File: AddServerExecutorDependencyTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Tests that Services.requireServerExecutor's dependency injection works regardless of what * ServiceTarget API was used for creating the target ServiceBuilder. */ @SuppressWarnings("deprecation") @Test public void testDifferentServiceBuilderTypes() { ServiceTarget serviceTarget = container.subTarget(); final Value<ExecutorService> value = new ImmediateValue<>(executorService); final Service<ExecutorService> mscExecutorService = new ValueService<>(value); ServiceController<?> executorController = serviceTarget.addService(ServerService.MANAGEMENT_EXECUTOR, mscExecutorService).install(); //TestService legacy = new TestService(); ServiceBuilder<?> legacyBuilder = serviceTarget.addService(ServiceName.of("LEGACY")); TestService legacy = new TestService(Services.requireServerExecutor(legacyBuilder)); legacyBuilder.setInstance(legacy); ServiceController<?> legacyController = legacyBuilder.install(); ServiceBuilder<?> currentBuilder = serviceTarget.addService(ServiceName.of("CURRENT")); TestService current = new TestService(Services.requireServerExecutor(currentBuilder)); currentBuilder.setInstance(current); ServiceController<?> currentController = currentBuilder.install(); try { container.awaitStability(60, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); Assert.fail("Interrupted"); } Assert.assertEquals(ServiceController.State.UP, executorController.getState()); Assert.assertEquals(ServiceController.State.UP, legacyController.getState()); Assert.assertEquals(ServiceController.State.UP, currentController.getState()); Assert.assertSame(executorService, legacy.getValue()); Assert.assertSame(executorService, current.getValue()); }
Example 12
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<SubjectSupplementalService> addPlugInAuthorizationService(OperationContext context, ModelNode model, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName plugInServiceName = PlugInSubjectSupplemental.ServiceUtil.createServiceName(realmName); final String pluginName = PlugInAuthorizationResourceDefinition.NAME.resolveModelAttribute(context, model).asString(); final Map<String, String> properties = resolveProperties(context, model); final ServiceBuilder<?> builder = serviceTarget.addService(plugInServiceName); final Consumer<SubjectSupplementalService> sssConsumer = builder.provides(plugInServiceName); final Supplier<PlugInLoaderService> pilSupplier = PlugInLoaderService.ServiceUtil.requires(builder, realmName); builder.setInstance(new PlugInSubjectSupplemental(sssConsumer, pilSupplier, realmName, pluginName, properties)); builder.setInitialMode(ON_DEMAND); builder.install(); return SubjectSupplementalService.ServiceUtil.requires(realmBuilder, plugInServiceName); }
Example 13
Source File: AbstractProxyControllerTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void setupController() throws Exception { executor = Executors.newCachedThreadPool(); container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); ControlledProcessState processState = new ControlledProcessState(true); ProxyModelControllerService proxyService = new ProxyModelControllerService(processState); target.addService(ServiceName.of("ProxyModelController")).setInstance(proxyService).install(); ServiceBuilder<?> mainBuilder = target.addService(ServiceName.of("MainModelController")); Supplier<ModelController> proxy = mainBuilder.requires(ServiceName.of("ProxyModelController")); MainModelControllerService mainService = new MainModelControllerService(proxy, processState); mainBuilder.setInstance(mainService); mainBuilder.install(); proxyService.awaitStartup(30, TimeUnit.SECONDS); mainService.awaitStartup(30, TimeUnit.SECONDS); // execute operation to initialize the controller model final ModelNode operation = new ModelNode(); operation.get(OP).set("setup"); operation.get(OP_ADDR).setEmptyList(); mainControllerClient = mainService.getValue().createClient(executor); mainControllerClient.execute(operation); proxiedControllerClient = proxyService.getValue().createClient(executor); proxiedControllerClient.execute(operation); }
Example 14
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void installRemotingManagementEndpoint(final ServiceTarget serviceTarget, final ServiceName endpointName, final String hostName, final EndpointService.EndpointType type, final OptionMap options) { final ServiceBuilder<?> builder = serviceTarget.addService(endpointName); final Consumer<Endpoint> endpointConsumer = builder.provides(endpointName); final Supplier<XnioWorker> workerSupplier = builder.requires(ServiceName.JBOSS.append("serverManagement", "controller", "management", "worker")); builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, hostName, type, options)); builder.install(); }
Example 15
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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 16
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addKerberosService(OperationContext context, ModelNode kerberos, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName kerberosServiceName = KerberosCallbackHandler.ServiceUtil.createServiceName(realmName); final boolean removeRealm = KerberosAuthenticationResourceDefinition.REMOVE_REALM.resolveModelAttribute(context, kerberos).asBoolean(); final ServiceBuilder<?> builder = serviceTarget.addService(kerberosServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(kerberosServiceName); builder.setInstance(new KerberosCallbackHandler(chsConsumer, removeRealm)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, kerberosServiceName); }
Example 17
Source File: ConsoleAvailabilityService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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 18
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void addPlugInLoaderService(String realmName, ModelNode plugInModel, ServiceTarget serviceTarget) { final ServiceName plugInLoaderName = PlugInLoaderService.ServiceUtil.createServiceName(realmName); final List<Property> plugIns = plugInModel.asPropertyList(); final ArrayList<String> knownNames = new ArrayList<String>(plugIns.size()); for (Property current : plugIns) { knownNames.add(current.getName()); } final ServiceBuilder<?> builder = serviceTarget.addService(plugInLoaderName); final Consumer<PlugInLoaderService> pilsConsumer = builder.provides(plugInLoaderName); builder.setInstance(new PlugInLoaderService(pilsConsumer, Collections.unmodifiableList(knownNames))); builder.setInitialMode(Mode.ON_DEMAND); builder.install(); }
Example 19
Source File: RemotingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private AdditionalInitialization createRuntimeAdditionalInitialization() { return new AdditionalInitialization() { @Override protected void setupController(ControllerInitializer controllerInitializer) { controllerInitializer.addSocketBinding("remoting", 27258); controllerInitializer.addRemoteOutboundSocketBinding("dummy-outbound-socket", "localhost", 6799); controllerInitializer.addRemoteOutboundSocketBinding("other-outbound-socket", "localhost", 1234); } @Override protected void addExtraServices(ServiceTarget target) { //Needed for initialization of the RealmAuthenticationProviderService AbsolutePathService.addService(ServerEnvironment.CONTROLLER_TEMP_DIR, new File("target/temp" + System.currentTimeMillis()).getAbsolutePath(), target); ServiceBuilder<?> builder = target.addService(IOServices.WORKER.append("default")); Consumer<XnioWorker> workerConsumer = builder.provides(IOServices.WORKER.append("default")); builder.setInstance(new WorkerService(workerConsumer, () -> Executors.newFixedThreadPool(1), Xnio.getInstance().createWorkerBuilder().setWorkerIoThreads(2))); builder.setInitialMode(ServiceController.Mode.ON_DEMAND); builder.install(); builder = target.addService(IOServices.WORKER.append("default-remoting")); workerConsumer = builder.provides(IOServices.WORKER.append("default-remoting")); builder.setInstance(new WorkerService(workerConsumer, () -> Executors.newFixedThreadPool(1), Xnio.getInstance().createWorkerBuilder().setWorkerIoThreads(2))); builder.setInitialMode(ServiceController.Mode.ON_DEMAND); builder.install(); } @Override protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) { super.initializeExtraSubystemsAndModel(extensionRegistry, rootResource, rootRegistration, capabilityRegistry); Map<String, Class> capabilities = new HashMap<>(); capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME, RemotingSubsystemRootResource.WORKER.getDefaultValue().asString()), XnioWorker.class); capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME, "default-remoting"), XnioWorker.class); AdditionalInitialization.registerServiceCapabilities(capabilityRegistry, capabilities); } }; }
Example 20
Source File: UndertowServiceActivator.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Create the Undertow service * */ protected void createService(String address, int port, HttpHandler handler, ServiceBuilder<?> builder) { UndertowService service = new UndertowService(address, port, handler); builder.setInstance(service); }