本文整理了Java中io.micronaut.context.ApplicationContext.isRunning()
方法的一些代码示例,展示了ApplicationContext.isRunning()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.isRunning()
方法的具体详情如下:
包路径:io.micronaut.context.ApplicationContext
类名称:ApplicationContext
方法名:isRunning
暂无
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* @param context A platform specific context object
* @return Build the {@link ApplicationContext} to use
*/
protected ApplicationContext buildApplicationContext(@Nullable C context) {
if (applicationContext == null) {
final ApplicationContextBuilder contextBuilder = newApplicationContextBuilder();
final Package pkg = getClass().getPackage();
if (pkg != null) {
final String name = pkg.getName();
if (StringUtils.isNotEmpty(name)) {
contextBuilder.packages(name);
}
}
applicationContext = contextBuilder.build();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (applicationContext != null && applicationContext.isRunning()) {
applicationContext.close();
applicationContext = null;
}
}));
}
return applicationContext;
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Start the environment specified.
* @param applicationContext the application context with the environment
* @return The environment within the context
*/
protected Environment startEnvironment(ApplicationContext applicationContext) {
if (!applicationContext.isRunning()) {
if (this instanceof PropertySource) {
applicationContext.getEnvironment().addPropertySource((PropertySource) this);
}
return applicationContext
.start()
.getEnvironment();
} else {
return applicationContext.getEnvironment();
}
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
private void stopInternal() {
try {
workerGroup.shutdownGracefully()
.addListener(this::logShutdownErrorIfNecessary);
parentGroup.shutdownGracefully()
.addListener(this::logShutdownErrorIfNecessary);
webSocketSessions.close();
applicationContext.publishEvent(new ServerShutdownEvent(this));
if (serviceInstance != null) {
applicationContext.publishEvent(new ServiceShutdownEvent(serviceInstance));
}
if (applicationContext.isRunning()) {
applicationContext.stop();
}
} catch (Throwable e) {
if (LOG.isErrorEnabled()) {
LOG.error("Error stopping Micronaut server: " + e.getMessage(), e);
}
}
}
代码示例来源:origin: micronaut-projects/micronaut-spring
@Override
public boolean isRunning() {
return micronautContext.isRunning();
}
}
代码示例来源:origin: micronaut-projects/micronaut-examples
@Override
public void onTerminate() {
super.onTerminate();
if(ctx != null && ctx.isRunning()) {
ctx.stop();
}
}
代码示例来源:origin: io.micronaut/inject
@SuppressWarnings("unchecked")
@Override
default T stop() {
ApplicationContext applicationContext = getApplicationContext();
if (applicationContext != null && applicationContext.isRunning()) {
applicationContext.stop();
}
return (T) this;
}
}
代码示例来源:origin: io.micronaut/micronaut-inject
@SuppressWarnings("unchecked")
@Override
default T stop() {
ApplicationContext applicationContext = getApplicationContext();
if (applicationContext != null && applicationContext.isRunning()) {
applicationContext.stop();
}
return (T) this;
}
}
内容来源于网络,如有侵权,请联系作者删除!