本文整理汇总了Java中org.jboss.as.clustering.singleton.SingletonService类的典型用法代码示例。如果您正苦于以下问题:Java SingletonService类的具体用法?Java SingletonService怎么用?Java SingletonService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingletonService类属于org.jboss.as.clustering.singleton包,在下文中一共展示了SingletonService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.jboss.as.clustering.singleton.SingletonService; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) {
log.info("HATimerService will be installed!");
HATimerService service = new HATimerService();
SingletonService<String> singleton = new SingletonService<String>(service, HATimerService.SINGLETON_SERVICE_NAME);
/*
* To pass a chain of election policies to the singleton, for example,
* to tell JGroups to prefer running the singleton on a node with a
* particular name, uncomment the following line:
*/
// singleton.setElectionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node1/singleton")));
singleton.build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry()))
.setInitialMode(ServiceController.Mode.ACTIVE)
.install()
;
}
示例2: activate
import org.jboss.as.clustering.singleton.SingletonService; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) {
log.info("HATimerService will be installed!");
HATimerService service = new HATimerService();
SingletonService<String> singleton = new SingletonService<String>(service, HATimerService.SINGLETON_SERVICE_NAME);
/*
* We can pass a chain of election policies to the singleton, for example to tell JGroups to prefer running the singleton on a node with a
* particular name
*/
// singleton.setElectionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node2/cluster")));
// Workaround for JBoss AS 7.1.2
// In later releases, SingleService.build(...) accepts a service target
singleton.build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry()))
// singleton.build(context.getServiceTarget())
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.env)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install()
;
}
示例3: activate
import org.jboss.as.clustering.singleton.SingletonService; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) {
log.info("HATimerService will be installed!");
HATimerService service = new HATimerService();
SingletonService<String> singleton = new SingletonService<String>(service, HATimerService.SINGLETON_SERVICE_NAME);
/*
* We can pass a chain of election policies to the singleton, for example to tell JGroups to prefer running the singleton on a node with a
* particular name
*/
// singleton.setElectionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node2/cluster")));
singleton.build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry()))
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.env)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install()
;
}