Java Code Examples for org.jboss.msc.service.ServiceActivatorContext#getServiceTarget()
The following examples show how to use
org.jboss.msc.service.ServiceActivatorContext#getServiceTarget() .
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: 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 2
Source File: TopologyManagerActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); target.addService(TopologyManager.SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE))) .install(); BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 3
Source File: TopologyWebAppActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); if (!topologyWebAppFractionInstance.isUnsatisfied()) { serviceNames = topologyWebAppFractionInstance.get().proxiedServiceMappings().keySet(); } TopologyProxyService proxyService = new TopologyProxyService(serviceNames); ServiceBuilder<TopologyProxyService> serviceBuilder = target .addService(TopologyProxyService.SERVICE_NAME, proxyService) .addDependency(DefaultNamespaceContextSelectorService.SERVICE_NAME) .addDependency(TopologyManagerActivator.CONNECTOR_SERVICE_NAME) .addDependency(NamingService.SERVICE_NAME); for (String serviceName : serviceNames) { serviceBuilder.addDependency(proxyService.mscServiceNameForServiceProxy(serviceName), HttpHandler.class, proxyService.getHandlerInjectorFor(serviceName)); } serviceBuilder.install(); }
Example 4
Source File: RegistrationAdvertiserActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); forEachLine(TopologyArchive.REGISTRATION_CONF, registrationLine -> { int separatorIndex = registrationLine.indexOf(TopologyArchive.SERVICE_TAG_SEPARATOR); String serviceName = registrationLine; List<String> tags = Collections.emptyList(); if (separatorIndex > 0) { serviceName = registrationLine.substring(0, separatorIndex); tags = getTags(registrationLine.substring(separatorIndex + 1)); } RegistrationAdvertiser.install(target, serviceName, "http", tags); RegistrationAdvertiser.install(target, serviceName, "https", tags); }); }
Example 5
Source File: TopologyManagerActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); TopologyManager.INSTANCE.setServiceTarget(target); target.addService(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE))) .install(); BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 6
Source File: MetricsServiceActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException { ServiceTarget target = serviceActivatorContext.getServiceTarget(); MetricsService service = new MetricsService(); ServiceBuilder<MetricsService> metricsServiceBuilder = target.addService(MetricsService.SERVICE_NAME, service); ServiceBuilder<MetricsService> serviceBuilder = metricsServiceBuilder .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector()) .addDependency(ServiceName.parse("jboss.eclipse.microprofile.config.marker")) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE) .install(); BinderService binderService = new BinderService(SWARM_MP_METRICS, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, SWARM_MP_METRICS), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 7
Source File: DelayedBinderServiceActivator.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { BindInfo bindInfo = ContextNames.bindInfoFor("java:/spring/binding/test"); DelayedBinderService service = new DelayedBinderService(bindInfo.getBindName()); ManagedReferenceFactory managedReferenceFactory = new ImmediateManagedReferenceFactory(service); ServiceTarget serviceTarget = context.getServiceTarget(); serviceTarget.addService(bindInfo.getBinderServiceName(), service) .addInjection(service.getManagedObjectInjector(), managedReferenceFactory) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector()) .install(); }
Example 8
Source File: RegistrationAdvertiserActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(TopologyArchive.REGISTRATION_CONF); if (in == null) { return; } try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String serviceName = null; while ((serviceName = reader.readLine()) != null) { serviceName = serviceName.trim(); if (!serviceName.isEmpty()) { installAdvertiser( target, serviceName, "http" ); installAdvertiser( target, serviceName, "https" ); } } } catch (IOException e) { throw new ServiceRegistryException(e); } }
Example 9
Source File: ConsulTopologyConnectorActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); ConsulTopologyConnector connector = new ConsulTopologyConnector(this.url); target.addService(TopologyConnector.SERVICE_NAME, connector) //.addDependency(ServiceName.parse("org.wildfly.network.socket-binding.http"), SocketBinding.class, connector.getSocketBindingInjector()) .addDependency(TopologyManager.SERVICE_NAME, TopologyManager.class, connector.getTopologyManagerInjector()) .install(); }
Example 10
Source File: JGroupsTopologyConnectorActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); JGroupsTopologyConnector manager = new JGroupsTopologyConnector(); target.addService(TopologyConnector.SERVICE_NAME, manager) .addDependency(ServiceName.parse("jboss.clustering.dispatcher.default"), CommandDispatcherFactory.class, manager.getCommandDispatcherFactoryInjector()) //.addDependency(ServiceName.parse("org.wildfly.network.socket-binding.http"), SocketBinding.class, manager.getSocketBindingInjector()) .addDependency(TopologyManager.SERVICE_NAME, TopologyManager.class, manager.getTopologyManagerInjector()) .install(); }
Example 11
Source File: MonitorServiceActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { Optional<String> securityRealm = Optional.empty(); if (!monitorFractionInstance.isUnsatisfied()) { securityRealm = monitorFractionInstance.get().securityRealm(); } ServiceTarget target = context.getServiceTarget(); MonitorService service = new MonitorService(securityRealm); ServiceBuilder<MonitorService> monitorServiceServiceBuilder = target.addService(MonitorService.SERVICE_NAME, service); ServiceBuilder<MonitorService> serviceBuilder = monitorServiceServiceBuilder .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector()) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()); if (securityRealm.isPresent()) { // configured through the fraction interface serviceBuilder.addDependency( createRealmName(securityRealm.get()), SecurityRealm.class, service.getSecurityRealmInjector() ); } serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE) .install(); BinderService binderService = new BinderService(Monitor.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Monitor.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 12
Source File: MonitorServiceActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { Optional<String> securityRealm = Optional.empty(); if (!healthFractionInstance.isUnsatisfied()) { securityRealm = healthFractionInstance.get().securityRealm(); } ServiceTarget target = context.getServiceTarget(); MonitorService service = new MonitorService(securityRealm); ServiceBuilder<MonitorService> monitorServiceServiceBuilder = target.addService(MonitorService.SERVICE_NAME, service); ServiceBuilder<MonitorService> serviceBuilder = monitorServiceServiceBuilder .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector()) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()); if (securityRealm.isPresent()) { // configured through the fraction interface serviceBuilder.addDependency( createRealmName(securityRealm.get()), SecurityRealm.class, service.getSecurityRealmInjector() ); } serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE) .install(); BinderService binderService = new BinderService(Monitor.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Monitor.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 13
Source File: ConsulTopologyConnectorActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); ConsulTopologyConnector connector = new ConsulTopologyConnector(); target.addService(TopologyManagerActivator.CONNECTOR_SERVICE_NAME, connector) .addDependency(TopologyManagerActivator.SERVICE_NAME, TopologyManager.class, connector.getTopologyManagerInjector()) .addDependency(Advertiser.SERVICE_NAME, Advertiser.class, connector.getAdvertiserInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 14
Source File: AgentActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); ConsulService consul = new ConsulService(this.fraction.url()); target.addService(ConsulService.SERVICE_NAME, consul) .install(); HealthClientService healthClient = new HealthClientService(); target.addService(HealthClientService.SERIVCE_NAME, healthClient) .addDependency(ConsulService.SERVICE_NAME, Consul.class, healthClient.getConsulInjector()) .install(); CatalogClientService catalogClient = new CatalogClientService(); target.addService(CatalogClientService.SERVICE_NAME, catalogClient) .addDependency(ConsulService.SERVICE_NAME, Consul.class, catalogClient.getConsulInjector()) .install(); AgentClientService agentClient = new AgentClientService(); target.addService(AgentClientService.SERVICE_NAME, agentClient) .addDependency(ConsulService.SERVICE_NAME, Consul.class, agentClient.getConsulInjector()) .install(); Advertiser advertiser = new Advertiser(); advertiser.setCheckTTL(fraction.ttl()); target.addService(Advertiser.SERVICE_NAME, advertiser) .addDependency(AgentClientService.SERVICE_NAME, AgentClient.class, advertiser.getAgentClientInjector()) .install(); }
Example 15
Source File: OpenShiftTopologyConnectorActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); OpenShiftTopologyConnector connector = new OpenShiftTopologyConnector(); target.addService(TopologyManagerActivator.CONNECTOR_SERVICE_NAME, connector) .addDependency(TopologyManagerActivator.SERVICE_NAME, TopologyManager.class, connector.getTopologyManagerInjector()) .install(); }
Example 16
Source File: JGroupsTopologyConnectorActivator.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); JGroupsTopologyConnector manager = new JGroupsTopologyConnector(); target.addService(TopologyManagerActivator.CONNECTOR_SERVICE_NAME, manager) .addDependency(ServiceName.parse("org.wildfly.clustering.default-command-dispatcher-factory"), CommandDispatcherFactory.class, manager.getCommandDispatcherFactoryInjector()) //.addDependency(ServiceName.parse("org.wildfly.network.socket-binding.http"), SocketBinding.class, manager.getSocketBindingInjector()) .addDependency(TopologyManagerActivator.SERVICE_NAME, TopologyManager.class, manager.getTopologyManagerInjector()) .install(); }
Example 17
Source File: BraveServiceActivator.java From thorntail with Apache License 2.0 | 4 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); BraveService service = new BraveService(zipKinFractionInstance.get().getBraveInstance()); ServiceBuilder<BraveService> serviceBuilder = target.addService(BraveService.SERVICE_NAME, service); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); BinderService binderService = new BinderService(BraveLookup.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, BraveLookup.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 18
Source File: JoseServiceActivator.java From thorntail with Apache License 2.0 | 4 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); JoseService service = new JoseService(joseFractionInstance.get()); ServiceBuilder<JoseService> serviceBuilder = target.addService(JoseService.SERVICE_NAME, service); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); BinderService binderService = new BinderService(JoseLookup.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, JoseLookup.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example 19
Source File: ServerStartTask.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public AsyncFuture<ServiceContainer> run(final List<ServiceActivator> runServices) { final Bootstrap bootstrap = Bootstrap.Factory.newInstance(); final ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), home, properties); // Create server environment on the server, so that the system properties are getting initialized on the right side final ServerEnvironment providedEnvironment = new ServerEnvironment(hostControllerName, properties, WildFlySecurityManager.getSystemEnvironmentPrivileged(), null, null, ServerEnvironment.LaunchType.DOMAIN, RunningMode.NORMAL, productConfig, Module.getStartTime(), suspend, null, null, null); DomainServerCommunicationServices.updateOperationID(initialOperationID); // TODO perhaps have ConfigurationPersisterFactory as a Service final List<ServiceActivator> services = new ArrayList<ServiceActivator>(startServices); final ServerBootOperationsService service = new ServerBootOperationsService(); // ModelController.boot() will block on this future in order to get the boot updates. final Future<ModelNode> bootOperations = service.getFutureResult(); final ServiceActivator activator = new ServiceActivator() { @Override public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException { final ServiceTarget target = serviceActivatorContext.getServiceTarget(); final ServiceBuilder sb = target.addService(ServiceName.JBOSS.append("server-boot-operations"), service); sb.requires(Services.JBOSS_AS); sb.addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getServerController()); sb.addDependency(HostControllerConnectionService.SERVICE_NAME, HostControllerClient.class, service.getClientInjector()); sb.addDependency(Services.JBOSS_SERVER_EXECUTOR, Executor.class, service.getExecutorInjector()); sb.install(); } }; services.add(activator); final Bootstrap.Configuration configuration = new Bootstrap.Configuration(providedEnvironment); final ExtensionRegistry extensionRegistry = configuration.getExtensionRegistry(); final Bootstrap.ConfigurationPersisterFactory configurationPersisterFactory = new Bootstrap.ConfigurationPersisterFactory() { @Override public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) { ExtensibleConfigurationPersister persister = new AbstractConfigurationPersister(new StandaloneXml(configuration.getModuleLoader(), executorService, extensionRegistry)) { private final PersistenceResource pr = new PersistenceResource() { @Override public void commit() { } @Override public void rollback() { } }; @Override public PersistenceResource store(final ModelNode model, Set<PathAddress> affectedAddresses) throws ConfigurationPersistenceException { return pr; } @Override public List<ModelNode> load() throws ConfigurationPersistenceException { try { final ModelNode operations = bootOperations.get(); return operations.asList(); } catch (Exception e) { throw new ConfigurationPersistenceException(e); } } }; extensionRegistry.setWriterRegistry(persister); return persister; } }; configuration.setConfigurationPersisterFactory(configurationPersisterFactory); return bootstrap.bootstrap(configuration, services); }
Example 20
Source File: MyServiceActivator.java From thorntail with Apache License 2.0 | 4 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); target.addService(ServiceName.of("swarm", "test", "cheese"), new ValueService<>(new ImmediateValue<>("cheddar"))) .install(); }