use of org.wildfly.clustering.singleton.SingletonPolicy in project wildfly by wildfly.
the class NodeServicePolicyActivator method activate.
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
try {
SingletonPolicy policy = (SingletonPolicy) context.getServiceRegistry().getRequiredService(ServiceName.parse(SingletonDefaultRequirement.SINGLETON_POLICY.getName())).awaitValue();
InjectedValue<Group> group = new InjectedValue<>();
NodeService service = new NodeService(group);
policy.createSingletonServiceBuilder(SERVICE_NAME, service).build(context.getServiceTarget()).addDependency(ServiceName.parse("org.wildfly.clustering.default-group"), Group.class, group).install();
} catch (InterruptedException e) {
throw new ServiceRegistryException(e);
}
}
use of org.wildfly.clustering.singleton.SingletonPolicy in project wildfly by wildfly.
the class ValueServiceActivator method activate.
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
try {
SingletonPolicy policy = (SingletonPolicy) context.getServiceRegistry().getRequiredService(ServiceName.parse(SingletonDefaultRequirement.SINGLETON_POLICY.getName())).awaitValue();
policy.createSingletonServiceBuilder(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(Boolean.TRUE)), new ValueService<>(new ImmediateValue<>(Boolean.FALSE))).build(context.getServiceTarget()).install();
} catch (InterruptedException e) {
throw new ServiceRegistryException(e);
}
}
use of org.wildfly.clustering.singleton.SingletonPolicy in project wildfly by wildfly.
the class SingletonDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
SingletonPolicy policy = context.getAttachment(POLICY_KEY);
if (policy != null) {
DeploymentUnit parent = context.getDeploymentUnit().getParent();
DeploymentUnitPhaseBuilder builder = (parent == null) ? new SingletonDeploymentUnitPhaseBuilder(policy) : new SingletonSubDeploymentUnitPhaseBuilder(parent, context.getPhase().next());
context.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, builder);
}
}
use of org.wildfly.clustering.singleton.SingletonPolicy in project wildfly by wildfly.
the class ClusteredSingletonServiceCreator method start.
@Override
public void start(StartContext context) throws StartException {
final ServiceTarget target = context.getChildTarget();
final SingletonPolicy singletonPolicyValue = singletonPolicy.getValue();
singletonPolicyValue.createSingletonServiceBuilder(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName(), Service.NULL).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Aggregations