本文整理了Java中org.springframework.context.Lifecycle.isRunning()
方法的一些代码示例,展示了Lifecycle.isRunning()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lifecycle.isRunning()
方法的具体详情如下:
包路径:org.springframework.context.Lifecycle
类名称:Lifecycle
方法名:isRunning
[英]Check whether this component is currently running.
In the case of a container, this will return true only if all components that apply are currently running.
[中]检查此组件当前是否正在运行。
对于容器,仅当应用的所有组件当前都在运行时,才会返回true。
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean isRunning() {
if (this.webSocketClient instanceof Lifecycle) {
return ((Lifecycle) this.webSocketClient).isRunning();
}
else {
return this.running;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void stopInternal() throws Exception {
if (this.client instanceof Lifecycle && ((Lifecycle) this.client).isRunning()) {
((Lifecycle) this.client).stop();
}
super.stopInternal();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void startInternal() {
if (this.client instanceof Lifecycle && !((Lifecycle) this.client).isRunning()) {
((Lifecycle) this.client).start();
}
super.startInternal();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void start() {
if (!isRunning()) {
this.running = true;
for (Transport transport : this.transports) {
if (transport instanceof Lifecycle) {
Lifecycle lifecycle = (Lifecycle) transport;
if (!lifecycle.isRunning()) {
lifecycle.start();
}
}
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void stop() {
if (isRunning()) {
this.running = false;
for (Transport transport : this.transports) {
if (transport instanceof Lifecycle) {
Lifecycle lifecycle = (Lifecycle) transport;
if (lifecycle.isRunning()) {
lifecycle.stop();
}
}
}
}
}
代码示例来源:origin: spring-projects/spring-framework
if (bean.isRunning()) {
if (bean instanceof SmartLifecycle) {
if (logger.isTraceEnabled()) {
代码示例来源:origin: apache/incubator-dubbo
if (((Lifecycle) context).isRunning()) {
level = Status.Level.OK;
} else {
代码示例来源:origin: apache/incubator-dubbo
if (((Lifecycle) context).isRunning()) {
level = Status.Level.OK;
} else {
代码示例来源:origin: spring-projects/spring-framework
/**
* Start the specified bean as part of the given set of Lifecycle beans,
* making sure that any beans that it depends on are started first.
* @param lifecycleBeans a Map with bean name as key and Lifecycle instance as value
* @param beanName the name of the bean to start
*/
private void doStart(Map<String, ? extends Lifecycle> lifecycleBeans, String beanName, boolean autoStartupOnly) {
Lifecycle bean = lifecycleBeans.remove(beanName);
if (bean != null && bean != this) {
String[] dependenciesForBean = getBeanFactory().getDependenciesForBean(beanName);
for (String dependency : dependenciesForBean) {
doStart(lifecycleBeans, dependency, autoStartupOnly);
}
if (!bean.isRunning() &&
(!autoStartupOnly || !(bean instanceof SmartLifecycle) || ((SmartLifecycle) bean).isAutoStartup())) {
if (logger.isTraceEnabled()) {
logger.trace("Starting bean '" + beanName + "' of type [" + bean.getClass().getName() + "]");
}
try {
bean.start();
}
catch (Throwable ex) {
throw new ApplicationContextException("Failed to start bean '" + beanName + "'", ex);
}
if (logger.isDebugEnabled()) {
logger.debug("Successfully started bean '" + beanName + "'");
}
}
}
}
代码示例来源:origin: org.springframework/spring-context
if (bean.isRunning()) {
if (bean instanceof SmartLifecycle) {
if (logger.isTraceEnabled()) {
代码示例来源:origin: org.springframework/spring-context
/**
* Start the specified bean as part of the given set of Lifecycle beans,
* making sure that any beans that it depends on are started first.
* @param lifecycleBeans a Map with bean name as key and Lifecycle instance as value
* @param beanName the name of the bean to start
*/
private void doStart(Map<String, ? extends Lifecycle> lifecycleBeans, String beanName, boolean autoStartupOnly) {
Lifecycle bean = lifecycleBeans.remove(beanName);
if (bean != null && bean != this) {
String[] dependenciesForBean = getBeanFactory().getDependenciesForBean(beanName);
for (String dependency : dependenciesForBean) {
doStart(lifecycleBeans, dependency, autoStartupOnly);
}
if (!bean.isRunning() &&
(!autoStartupOnly || !(bean instanceof SmartLifecycle) || ((SmartLifecycle) bean).isAutoStartup())) {
if (logger.isTraceEnabled()) {
logger.trace("Starting bean '" + beanName + "' of type [" + bean.getClass().getName() + "]");
}
try {
bean.start();
}
catch (Throwable ex) {
throw new ApplicationContextException("Failed to start bean '" + beanName + "'", ex);
}
if (logger.isDebugEnabled()) {
logger.debug("Successfully started bean '" + beanName + "'");
}
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void singleLifecycleShutdown() throws Exception {
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
Lifecycle bean = new TestLifecycleBean(null, stoppedBeans);
StaticApplicationContext context = new StaticApplicationContext();
context.getBeanFactory().registerSingleton("bean", bean);
context.refresh();
assertFalse(bean.isRunning());
bean.start();
assertTrue(bean.isRunning());
context.stop();
assertEquals(1, stoppedBeans.size());
assertFalse(bean.isRunning());
assertEquals(bean, stoppedBeans.get(0));
}
代码示例来源:origin: spring-projects/spring-framework
context.getBeanFactory().registerSingleton("bean7", bean7);
context.refresh();
assertTrue(bean2.isRunning());
assertTrue(bean3.isRunning());
assertTrue(bean5.isRunning());
assertTrue(bean6.isRunning());
assertTrue(bean7.isRunning());
assertFalse(bean1.isRunning());
assertFalse(bean4.isRunning());
bean1.start();
bean4.start();
assertTrue(bean1.isRunning());
assertTrue(bean4.isRunning());
context.stop();
assertFalse(bean1.isRunning());
assertFalse(bean2.isRunning());
assertFalse(bean3.isRunning());
assertFalse(bean4.isRunning());
assertFalse(bean5.isRunning());
assertFalse(bean6.isRunning());
assertFalse(bean7.isRunning());
assertEquals(7, stoppedBeans.size());
assertEquals(Integer.MAX_VALUE, getPhase(stoppedBeans.get(0)));
代码示例来源:origin: spring-projects/spring-integration
IntegrationWebSocketConnectionManager(WebSocketClient client, String uriTemplate,
Object... uriVariables) {
super(uriTemplate, uriVariables);
this.client = client;
this.syncClientLifecycle = ((client instanceof Lifecycle) && !((Lifecycle) client).isRunning());
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public boolean isRunning() {
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public boolean isRunning() {
return this.handshakeHandler instanceof Lifecycle && ((Lifecycle) this.handshakeHandler).isRunning();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public boolean isRunning() {
return !(this.object instanceof Lifecycle) || ((Lifecycle) this.object).isRunning();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public boolean isRunning() {
return this.lifecycle.isRunning();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
@ManagedAttribute
public boolean isRunning() {
return this.lifecycle.isRunning();
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public boolean isRunning() {
T instance = get();
return !(instance instanceof Lifecycle) || ((Lifecycle) instance).isRunning();
}
内容来源于网络,如有侵权,请联系作者删除!