本文整理汇总了Java中com.netflix.governator.lifecycle.LifecycleManager.close方法的典型用法代码示例。如果您正苦于以下问题:Java LifecycleManager.close方法的具体用法?Java LifecycleManager.close怎么用?Java LifecycleManager.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.governator.lifecycle.LifecycleManager
的用法示例。
在下文中一共展示了LifecycleManager.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inject
import com.netflix.governator.lifecycle.LifecycleManager; //导入方法依赖的package包/类
@Test
public void inject() throws Exception {
Assume.assumeTrue("requires java 8", isJava8());
// On JDK 9:
// Caused by: java.lang.ClassNotFoundException: javax.annotation.Resource
// at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
// at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
// at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
Injector injector = LifecycleInjector.builder()
.usingBasePackages("com.netflix")
.build()
.createInjector();
LifecycleManager lcMgr = injector.getInstance(LifecycleManager.class);
lcMgr.start();
Assert.assertNotNull(injector.getInstance(Plugin.class));
lcMgr.close();
}
示例2: run
import com.netflix.governator.lifecycle.LifecycleManager; //导入方法依赖的package包/类
public static void run(Class<? extends AbstractModule> moduleClass, String appName) throws Exception {
Injector injector = LifecycleInjector.builder()
.withModuleClass(moduleClass)
.withBootstrapModule(new ConfigModule(appName))
.usingBasePackages("com.widowcrawler")
.build()
.createInjector();
LifecycleManager lifecycleManager = injector.getInstance(LifecycleManager.class);
lifecycleManager.start();
Dispatcher dispatcher = injector.getInstance(Dispatcher.class);
boolean cont = true;
while (cont) {
logger.info("Dispatching...");
cont = dispatcher.dispatch();
}
lifecycleManager.close();
}