当前位置: 首页>>代码示例>>Java>>正文


Java SingletonService类代码示例

本文整理汇总了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()
    ;
}
 
开发者ID:windup,项目名称:windup-rulesets,代码行数:19,代码来源:HATimerServiceActivator.java

示例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()
    ;
}
 
开发者ID:red-fox-mulder,项目名称:eap-6.1-quickstarts,代码行数:22,代码来源:HATimerServiceActivator.java

示例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()
    ;
}
 
开发者ID:wfink,项目名称:jboss-as-quickstart,代码行数:19,代码来源:HATimerServiceActivator.java


注:本文中的org.jboss.as.clustering.singleton.SingletonService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。