Search in sources :

Example 1 with SingletonPolicy

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);
    }
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) Group(org.wildfly.clustering.group.Group) SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) ServiceRegistryException(org.jboss.msc.service.ServiceRegistryException)

Example 2 with SingletonPolicy

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);
    }
}
Also used : SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) ServiceRegistryException(org.jboss.msc.service.ServiceRegistryException) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Example 3 with SingletonPolicy

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);
    }
}
Also used : SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) DeploymentUnitPhaseBuilder(org.jboss.as.server.deployment.DeploymentUnitPhaseBuilder) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 4 with SingletonPolicy

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();
}
Also used : SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Aggregations

SingletonPolicy (org.wildfly.clustering.singleton.SingletonPolicy)4 ServiceRegistryException (org.jboss.msc.service.ServiceRegistryException)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitPhaseBuilder (org.jboss.as.server.deployment.DeploymentUnitPhaseBuilder)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 InjectedValue (org.jboss.msc.value.InjectedValue)1 Group (org.wildfly.clustering.group.Group)1