Java Code Examples for org.jboss.msc.service.ServiceTarget#addService()
The following examples show how to use
org.jboss.msc.service.ServiceTarget#addService() .
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: CamelEndpointDeployerService.java From wildfly-camel with Apache License 2.0 | 6 votes |
public static ServiceController<CamelEndpointDeployerService> addService(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName deploymentInfoServiceName, ServiceName hostServiceName) { CamelEndpointDeployerService service = new CamelEndpointDeployerService(); ServiceBuilder<CamelEndpointDeployerService> sb = serviceTarget .addService(deployerServiceName(deploymentUnit.getServiceName()), service); sb.addDependency(hostServiceName, Host.class, service.hostSupplier); sb.addDependency(deploymentInfoServiceName, DeploymentInfo.class, service.deploymentInfoSupplier); sb.addDependency( CamelEndpointDeploymentSchedulerService.deploymentSchedulerServiceName(deploymentUnit.getServiceName()), CamelEndpointDeploymentSchedulerService.class, service.deploymentSchedulerServiceSupplier); sb.addDependency(UndertowService.SERVLET_CONTAINER.append("default"), ServletContainerService.class, service.servletContainerServiceSupplier); final EEModuleConfiguration moduleConfiguration = deploymentUnit .getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_CONFIGURATION); if (moduleConfiguration != null) { for (final ComponentConfiguration c : moduleConfiguration.getComponentConfigurations()) { sb.addDependency(c.getComponentDescription().getStartServiceName()); } } return sb.install(); }
Example 2
Source File: VirtualSecurityDomainProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null || !isVirtualDomainRequired(deploymentUnit)) { return; // Only interested in installation if this is really the root deployment. } ServiceName virtualDomainName = virtualDomainName(deploymentUnit); ServiceTarget serviceTarget = phaseContext.getServiceTarget(); ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualDomainName); final SecurityDomain virtualDomain = SecurityDomain.builder().build(); final Consumer<SecurityDomain> consumer = serviceBuilder.provides(virtualDomainName); serviceBuilder.setInstance(Service.newInstance(consumer, virtualDomain)); serviceBuilder.setInitialMode(Mode.ON_DEMAND); serviceBuilder.install(); }
Example 3
Source File: AbstractControllerTestBase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void setupController() throws InterruptedException { container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); if (useDelegateRootResourceDefinition) { initializer = createInitializer(); controllerService = new ModelControllerService(getAuditLogger(), rootResourceDefinition); } else { controllerService = new ModelControllerService(getAuditLogger()); } ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), controllerService); builder.install(); controllerService.awaitStartup(30, TimeUnit.SECONDS); controller = controllerService.getValue(); //ModelNode setup = Util.getEmptyOperation("setup", new ModelNode()); //controller.execute(setup, null, null, null); }
Example 4
Source File: DomainServerCommunicationServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void activate(final ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException { final ServiceTarget serviceTarget = serviceActivatorContext.getServiceTarget(); final ServiceName endpointName = managementSubsystemEndpoint ? RemotingServices.SUBSYSTEM_ENDPOINT : ManagementRemotingServices.MANAGEMENT_ENDPOINT; final EndpointService.EndpointType endpointType = managementSubsystemEndpoint ? EndpointService.EndpointType.SUBSYSTEM : EndpointService.EndpointType.MANAGEMENT; try { ManagementWorkerService.installService(serviceTarget); // TODO see if we can figure out a way to work in the vault resolver instead of having to use ExpressionResolver.SIMPLE @SuppressWarnings("deprecation") final OptionMap options = EndpointConfigFactory.create(ExpressionResolver.SIMPLE, endpointConfig, DEFAULTS); ManagementRemotingServices.installRemotingManagementEndpoint(serviceTarget, endpointName, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null), endpointType, options); // Install the communication services final ServiceBuilder<?> sb = serviceTarget.addService(HostControllerConnectionService.SERVICE_NAME); final Supplier<ExecutorService> esSupplier = Services.requireServerExecutor(sb); final Supplier<ScheduledExecutorService> sesSupplier = sb.requires(ServerService.JBOSS_SERVER_SCHEDULED_EXECUTOR); final Supplier<Endpoint> eSupplier = sb.requires(endpointName); final Supplier<ProcessStateNotifier> cpsnSupplier = sb.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME); sb.setInstance(new HostControllerConnectionService(managementURI, serverName, serverProcessName, authKey, initialOperationID, managementSubsystemEndpoint, sslContextSupplier, esSupplier, sesSupplier, eSupplier, cpsnSupplier)); sb.install(); } catch (OperationFailedException e) { throw new ServiceRegistryException(e); } }
Example 5
Source File: ConsoleAvailabilityUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@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 6
Source File: ModuleResolvePhaseService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static void installService(final ServiceTarget serviceTarget, final ModuleIdentifier moduleIdentifier, int phaseNumber, final Set<ModuleDependency> nextPhaseIdentifiers, final Set<ModuleIdentifier> nextAlreadySeen) { final ModuleResolvePhaseService nextPhaseService = new ModuleResolvePhaseService(moduleIdentifier, nextAlreadySeen, phaseNumber); ServiceBuilder<ModuleResolvePhaseService> builder = serviceTarget.addService(moduleSpecServiceName(moduleIdentifier, phaseNumber), nextPhaseService); for (ModuleDependency module : nextPhaseIdentifiers) { builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(module.getIdentifier()), ModuleDefinition.class, new Injector<ModuleDefinition>() { ModuleDefinition definition; @Override public synchronized void inject(final ModuleDefinition o) throws InjectionException { nextPhaseService.getModuleSpecs().add(o); this.definition = o; } @Override public synchronized void uninject() { nextPhaseService.getModuleSpecs().remove(definition); this.definition = null; } }); } builder.install(); }
Example 7
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 8
Source File: ControlledProcessStateService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@SuppressWarnings("unchecked") public static ServiceController<ControlledProcessStateService> addService(ServiceTarget target, ControlledProcessState processState) { final ControlledProcessStateService service = processState.getService(); final ServiceBuilder<?> sb = target.addService(INTERNAL_SERVICE_NAME); service.serviceConsumer = sb.provides(INTERNAL_SERVICE_NAME, SERVICE_NAME); sb.setInstance(service); return (ServiceController<ControlledProcessStateService>) sb.install(); }
Example 9
Source File: PlatformMBeanResourceUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@BeforeClass public static void setupController() throws InterruptedException { container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); PlatformMBeanTestModelControllerService svc = new PlatformMBeanTestModelControllerService(); ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc); builder.install(); svc.latch.await(30, TimeUnit.SECONDS); controller = svc.getValue(); ModelNode setup = Util.getEmptyOperation("setup", new ModelNode()); controller.execute(setup, null, null, null); client = controller.createClient(Executors.newSingleThreadExecutor()); }
Example 10
Source File: DeploymentMountProvider.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void addService(final ServiceTarget serviceTarget) { //ServerDeploymentRepositoryImpl service = new ServerDeploymentRepositoryImpl(); final ServiceBuilder<?> sb = serviceTarget.addService(DeploymentMountProvider.SERVICE_NAME); final Consumer<DeploymentMountProvider> dmpConsumer = sb.provides(DeploymentMountProvider.SERVICE_NAME); final Supplier<ExecutorService> esSupplier = org.jboss.as.server.Services.requireServerExecutor(sb); sb.setInstance(new ServerDeploymentRepositoryImpl(dmpConsumer, esSupplier)); sb.install(); }
Example 11
Source File: RealmMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = REALM_MAPPER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName realmMapperName = runtimeCapability.getCapabilityServiceName(RealmMapper.class); final String pattern = PATTERN_CAPTURE_GROUP.resolveModelAttribute(context, model).asString(); String delegateRealmMapper = DELEGATE_REALM_MAPPER.resolveModelAttribute(context, model).asStringOrNull(); final InjectedValue<RealmMapper> delegateRealmMapperInjector = new InjectedValue<RealmMapper>(); TrivialService<RealmMapper> realmMapperService = new TrivialService<RealmMapper>(() -> { RealmMapper delegate = delegateRealmMapperInjector.getOptionalValue(); Pattern compiledPattern = Pattern.compile(pattern); if (delegate == null) { return new SimpleRegexRealmMapper(compiledPattern); } else { return new SimpleRegexRealmMapper(compiledPattern, delegate); } }); ServiceBuilder<RealmMapper> realmMapperBuilder = serviceTarget.addService(realmMapperName, realmMapperService); if (delegateRealmMapper != null) { String delegateCapabilityName = RuntimeCapability.buildDynamicCapabilityName(REALM_MAPPER_CAPABILITY, delegateRealmMapper); ServiceName delegateServiceName = context.getCapabilityServiceName(delegateCapabilityName, RealmMapper.class); realmMapperBuilder.addDependency(delegateServiceName, RealmMapper.class, delegateRealmMapperInjector); } commonDependencies(realmMapperBuilder) .setInitialMode(Mode.LAZY) .install(); }
Example 12
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 13
Source File: RelativePathService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Installs a path service. * * @param name the name to use for the service * @param path the relative portion of the path * @param possiblyAbsolute {@code true} if {@code path} may be an {@link #isAbsoluteUnixOrWindowsPath(String) absolute path} * and should be {@link AbsolutePathService installed as such} if it is, with any * {@code relativeTo} parameter ignored * @param relativeTo the name of the path that {@code path} may be relative to * @param serviceTarget the {@link ServiceTarget} to use to install the service * @return the ServiceController for the path service */ public static ServiceController<?> addService(final ServiceName name, final String path, boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget); } final ServiceBuilder<?> builder = serviceTarget.addService(name); final Consumer<String> pathConsumer = builder.provides(name); final Supplier<String> injectedPath = builder.requires(pathNameOf(relativeTo)); builder.setInstance(new RelativePathService(path, pathConsumer, injectedPath)); return builder.install(); }
Example 14
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 15
Source File: CachingRealmDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName realmName = runtimeCapability.getCapabilityServiceName(SecurityRealm.class); String cacheableRealm = REALM_NAME.resolveModelAttribute(context, model).asString(); int maxEntries = MAXIMUM_ENTRIES.resolveModelAttribute(context, model).asInt(); long maxAge = MAXIMUM_AGE.resolveModelAttribute(context, model).asInt(); InjectedValue<SecurityRealm> cacheableRealmValue = new InjectedValue<>(); ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(realmName, createService(cacheableRealm, maxEntries, maxAge, cacheableRealmValue)); addRealmDependency(context, serviceBuilder, cacheableRealm, cacheableRealmValue); commonDependencies(serviceBuilder).setInitialMode(Mode.ACTIVE).install(); }
Example 16
Source File: ContextCreateHandlerRegistryService.java From wildfly-camel with Apache License 2.0 | 4 votes |
public static ServiceController<ContextCreateHandlerRegistry> addService(ServiceTarget serviceTarget, SubsystemState subsystemState) { ContextCreateHandlerRegistryService service = new ContextCreateHandlerRegistryService(subsystemState); ServiceBuilder<ContextCreateHandlerRegistry> builder = serviceTarget.addService(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, service); return builder.install(); }
Example 17
Source File: ServiceModuleLoader.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void installModuleResolvedService(ServiceTarget serviceTarget, ModuleIdentifier identifier) { final ValueService<ModuleIdentifier> resolvedService = new ValueService<ModuleIdentifier>(new ImmediateValue<ModuleIdentifier>(identifier)); final ServiceBuilder sb = serviceTarget.addService(ServiceModuleLoader.moduleResolvedServiceName(identifier), resolvedService); sb.requires(moduleSpecServiceName(identifier)); sb.install(); }
Example 18
Source File: SaslServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ResourceDefinition getMechanismProviderFilteringSaslServerFactory() { AttributeDefinition[] attributes = new AttributeDefinition[] { SASL_SERVER_FACTORY, ENABLING, MECH_PROVIDER_FILTERS }; AbstractAddStepHandler add = new SaslServerAddHandler(attributes) { @Override protected ServiceBuilder<SaslServerFactory> installService(OperationContext context, ServiceName saslServerFactoryName, ModelNode model) throws OperationFailedException { final String saslServerFactory = SASL_SERVER_FACTORY.resolveModelAttribute(context, model).asString(); BiPredicate<String, Provider> predicate = null; if (model.hasDefined(ElytronDescriptionConstants.FILTERS)) { List<ModelNode> nodes = model.require(ElytronDescriptionConstants.FILTERS).asList(); for (ModelNode current : nodes) { final String mechanismName = MECHANISM_NAME.resolveModelAttribute(context, current).asStringOrNull(); final String providerName = PROVIDER_NAME.resolveModelAttribute(context, current).asString(); final Double providerVersion = PROVIDER_VERSION.resolveModelAttribute(context, current).asDoubleOrNull(); final Predicate<Double> versionPredicate; if (providerVersion != null) { final Comparison comparison = Comparison .getComparison(VERSION_COMPARISON.resolveModelAttribute(context, current).asString()); versionPredicate = (Double d) -> comparison.getPredicate().test(d, providerVersion); } else { versionPredicate = null; } BiPredicate<String, Provider> thisPredicate = (String s, Provider p) -> { return (mechanismName == null || mechanismName.equals(s)) && providerName.equals(p.getName()) && (providerVersion == null || versionPredicate.test(p.getVersion())); }; predicate = predicate == null ? thisPredicate : predicate.or(thisPredicate); } boolean enabling = ENABLING.resolveModelAttribute(context, model).asBoolean(); if (enabling == false) { predicate = predicate.negate(); } } final BiPredicate<String, Provider> finalPredicate = predicate; final InjectedValue<SaslServerFactory> saslServerFactoryInjector = new InjectedValue<SaslServerFactory>(); TrivialService<SaslServerFactory> saslServiceFactoryService = new TrivialService<SaslServerFactory>(() -> { SaslServerFactory theFactory = saslServerFactoryInjector.getValue(); theFactory = finalPredicate != null ? new MechanismProviderFilteringSaslServerFactory(theFactory, finalPredicate) : theFactory; return theFactory; }); ServiceTarget serviceTarget = context.getServiceTarget(); ServiceBuilder<SaslServerFactory> serviceBuilder = serviceTarget.addService(saslServerFactoryName, saslServiceFactoryService); serviceBuilder.addDependency(context.getCapabilityServiceName( RuntimeCapability.buildDynamicCapabilityName(SASL_SERVER_FACTORY_CAPABILITY, saslServerFactory), SaslServerFactory.class), SaslServerFactory.class, saslServerFactoryInjector); return serviceBuilder; } }; return wrap(new SaslServerResourceDefinition(ElytronDescriptionConstants.MECHANISM_PROVIDER_FILTERING_SASL_SERVER_FACTORY, add, attributes), SaslServerDefinitions::getSaslServerAvailableMechanisms); }
Example 19
Source File: CamelBootstrapService.java From wildfly-camel with Apache License 2.0 | 4 votes |
public static ServiceController<Void> addService(ServiceTarget serviceTarget) { CamelBootstrapService service = new CamelBootstrapService(); ServiceBuilder<Void> builder = serviceTarget.addService(CamelConstants.CAMEL_SUBSYSTEM_SERVICE_NAME, service); return builder.install(); }
Example 20
Source File: CamelContextFactoryService.java From wildfly-camel with Apache License 2.0 | 4 votes |
public static ServiceController<CamelContextFactory> addService(ServiceTarget serviceTarget) { CamelContextFactoryService service = new CamelContextFactoryService(); ServiceBuilder<CamelContextFactory> builder = serviceTarget.addService(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, service); return builder.install(); }