use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class DistributedSingletonService method start.
@Override
public void start(StartContext context) throws StartException {
ServiceTarget target = context.getChildTarget();
this.primaryController = target.addService(this.serviceName.append("primary"), this.primaryService).setInitialMode(ServiceController.Mode.NEVER).install();
this.backupController = target.addService(this.serviceName.append("backup"), this.backupService.orElse(new PrimaryProxyService<>(this))).setInitialMode(ServiceController.Mode.ACTIVE).install();
this.dispatcher = this.dispatcherFactory.getValue().<SingletonContext<T>>createCommandDispatcher(this.serviceName, this);
this.registration = this.registry.getValue().register(this.serviceName, this);
this.started = true;
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class EJBRemoteInvocationPassByValueWriteHandler method updateDefaultLocalEJBReceiverService.
void updateDefaultLocalEJBReceiverService(final OperationContext context, final ModelNode model) throws OperationFailedException {
final ModelNode passByValueModel = this.attributeDefinition.resolveModelAttribute(context, model);
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName localTransportProviderServiceName;
if (passByValueModel.isDefined()) {
final boolean passByValue = passByValueModel.asBoolean(true);
if (passByValue) {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_REFERENCE_SERVICE_NAME;
}
} else {
localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME;
}
// uninstall the existing default local EJB receiver service
final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME);
if (existingDefaultLocalEJBReceiverServiceController != null) {
context.removeService(existingDefaultLocalEJBReceiverServiceController);
}
final ServiceTarget serviceTarget = context.getServiceTarget();
// now install the new default local EJB receiver service which points to an existing Local EJB receiver service
final ValueInjectionService<LocalTransportProvider> newDefaultLocalTransportProviderService = new ValueInjectionService<LocalTransportProvider>();
final ServiceBuilder<LocalTransportProvider> defaultLocalEJBReceiverServiceBuilder = serviceTarget.addService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, newDefaultLocalTransportProviderService);
defaultLocalEJBReceiverServiceBuilder.addDependency(localTransportProviderServiceName, LocalTransportProvider.class, newDefaultLocalTransportProviderService.getInjector());
// install the service
defaultLocalEJBReceiverServiceBuilder.install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ChannelServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String name = context.getCurrentAddressValue();
String stack = STACK.resolveModelAttribute(context, model).asString();
ServiceTarget target = context.getServiceTarget();
new ChannelClusterBuilder(JCHANNEL_CLUSTER.getServiceName(address), name).configure(context, model).build(target).install();
new ChannelBuilder(JCHANNEL.getServiceName(address), name).statisticsEnabled(STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean()).configure(context, model).build(target).install();
new AliasServiceBuilder<>(JCHANNEL_FACTORY.getServiceName(address), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stack), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
new ForkChannelFactoryBuilder(FORK_CHANNEL_FACTORY.getServiceName(address), name).configure(context, model).build(target).install();
new ModuleBuilder(JCHANNEL_MODULE.getServiceName(address), MODULE).configure(context, model).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(name), JGroupsRequirement.CHANNEL.getServiceName(context, name), JGroupsRequirement.CHANNEL.getType()).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(name), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, name), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
// Install group services for channel
for (GroupBuilderProvider provider : ServiceLoader.load(DistributedGroupBuilderProvider.class, DistributedGroupBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name)) {
JGroupsLogger.ROOT_LOGGER.debugf("Installing %s for channel %s", builder.getServiceName(), name);
builder.configure(context).build(target).install();
}
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ForkServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
super.installServices(context, model);
PathAddress address = context.getCurrentAddress();
String name = address.getLastElement().getValue();
String channel = address.getParent().getLastElement().getValue();
ServiceTarget target = context.getServiceTarget();
new AliasServiceBuilder<>(FORK_CHANNEL_SOURCE.getServiceName(address), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channel), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
new AliasServiceBuilder<>(FORK_CHANNEL_MODULE.getServiceName(address), JGroupsRequirement.CHANNEL_MODULE.getServiceName(context, channel), JGroupsRequirement.CHANNEL_MODULE.getType()).build(target).install();
new AliasServiceBuilder<>(FORK_CHANNEL_CLUSTER.getServiceName(address), JGroupsRequirement.CHANNEL_CLUSTER.getServiceName(context, channel), JGroupsRequirement.CHANNEL_CLUSTER.getType()).build(target).install();
new ChannelBuilder(FORK_CHANNEL.getServiceName(address), name).configure(context, model).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(name), JGroupsRequirement.CHANNEL.getServiceName(context, name), JGroupsRequirement.CHANNEL.getType()).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(name), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, name), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name, channel)) {
builder.configure(context).build(target).install();
}
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class JGroupsSubsystemServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
ROOT_LOGGER.activatingSubsystem(Version.printVersion());
ServiceTarget target = context.getServiceTarget();
PathAddress address = context.getCurrentAddress();
// In this case, the Infinispan subsystem may have already registered default group capabilities
if (context.getProcessType().isServer() && !context.isBooting()) {
Resource rootResource = context.readResourceFromRoot(address.getParent());
if (rootResource.hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"))) {
// Following restart, default group services will be installed by this handler, rather than the infinispan subsystem handler
context.addStep((ctx, operation) -> {
ctx.reloadRequired();
ctx.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
}, OperationContext.Stage.RUNTIME);
return;
}
}
new ProtocolDefaultsBuilder().build(target).install();
ModelNodes.optionalString(DEFAULT_CHANNEL.resolveModelAttribute(context, model)).ifPresent(defaultChannel -> {
CAPABILITIES.entrySet().forEach(entry -> new AliasServiceBuilder<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, defaultChannel), entry.getKey().getType()).build(target).install());
if (!defaultChannel.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL.getServiceName(context, defaultChannel), JGroupsRequirement.CHANNEL.getType()).build(target).install();
new BinderServiceBuilder<>(JGroupsBindingFactory.createChannelFactoryBinding(JndiNameFactory.DEFAULT_LOCAL_NAME), JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, defaultChannel), JGroupsRequirement.CHANNEL_FACTORY.getType()).build(target).install();
}
for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), null, defaultChannel)) {
builder.configure(context).build(target).install();
}
}
});
}
Aggregations