热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.netflix.governator.guice.LifecycleInjector.getLifecycleManager()方法的使用及代码示例

本文整理了Java中com.netflix.governator.guice.LifecycleInjector.getLifecycleManager()方法的一些代

本文整理了Java中com.netflix.governator.guice.LifecycleInjector.getLifecycleManager()方法的一些代码示例,展示了LifecycleInjector.getLifecycleManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LifecycleInjector.getLifecycleManager()方法的具体详情如下:
包路径:com.netflix.governator.guice.LifecycleInjector
类名称:LifecycleInjector
方法名:getLifecycleManager

LifecycleInjector.getLifecycleManager介绍

[英]Return the internally created lifecycle manager
[中]返回内部创建的lifecycle manager

代码示例

代码示例来源:origin: net.spals.appbuilder/spals-appbuilder-app-core

private Injector buildServiceInjector(final LifecycleInjectorBuilder lifecycleInjectorBuilder) {
// 1. Startup the Governator LifecycleManager
final LifecycleInjector lifecycleInjector = lifecycleInjectorBuilder.build();
final LifecycleManager lifecycleManager = lifecycleInjector.getLifecycleManager();
try {
lifecycleManager.start();
} catch (Exception e) {
getLogger().error("Error during LifecycleManager start", e);
throw new RuntimeException(e);
}
// 2. Ensure that we shut everything down properly
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
getLogger().info("Shutting down {} application.", getName());
lifecycleManager.close();
}));
// 3. Grab the Guice injector from which we can get service references
return lifecycleInjector.createInjector();
}
}

代码示例来源:origin: org.brightify.torch/torch-compiler

@Override
public boolean process(Set annotations, RoundEnvironment roundEnv) {
if(annotations.size() == 0) {
return false;
}
LifecycleInjector lifecycleInjector = LifecycleInjector
.builder()
.withModules(new TorchCompilerModule(this, roundEnv))
.build();
try {
lifecycleInjector.getLifecycleManager().start();
} catch (Exception e) {
throw new RuntimeException(e);
}
Injector injector = lifecycleInjector.createInjector();
TorchAnnotationProcessor processor = injector.getInstance(TorchAnnotationProcessor.class);
boolean success = processor.process(annotations);
lifecycleInjector.getLifecycleManager().close();
return success;
}

推荐阅读
author-avatar
一切近乎完美
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有