List of usage examples for org.springframework.context Lifecycle stop
void stop();
From source file:org.brekka.stillingar.spring.snapshot.SnapshotDeltaValueInterceptor.java
protected void destroyBean(Object value) { if (value instanceof DisposableBean) { DisposableBean disposableBean = (DisposableBean) value; try {// ww w . ja va2 s.co m disposableBean.destroy(); } catch (Exception e) { throw new ConfigurationException(String.format("Error while disposing bean '%s'", value), e); } if (log.isInfoEnabled()) { log.info(String.format("Stopped DisposableBean: %s", value)); } } else if (value instanceof Lifecycle) { Lifecycle lifecycle = (Lifecycle) value; lifecycle.stop(); if (log.isInfoEnabled()) { log.info(String.format("Stopped Lifecycle bean: %s", value)); } } }
From source file:hello.MetricsActivator.java
/** * Stops all inbound message producers (that are not {@link OrderlyShutdownCapable}) * - may cause interrupts./*from w w w . j a v a 2 s . c om*/ */ public void stopInboundMessageProducers() { for (Lifecycle producer : this.inboundLifecycleMessageProducers) { if (!(producer instanceof OrderlyShutdownCapable)) { if (logger.isInfoEnabled()) { logger.info("Stopping message producer " + producer); } producer.stop(); } } }
From source file:org.springframework.context.support.DefaultLifecycleProcessor.java
/** * Stop the specified bean as part of the given set of Lifecycle beans, * making sure that any beans that depends on it are stopped first. * @param lifecycleBeans Map with bean name as key and Lifecycle instance as value * @param beanName the name of the bean to stop */// w w w . j a v a 2s .c o m private void doStop(Map<String, ? extends Lifecycle> lifecycleBeans, final String beanName, final CountDownLatch latch, final Set<String> countDownBeanNames) { Lifecycle bean = lifecycleBeans.remove(beanName); if (bean != null) { String[] dependentBeans = getBeanFactory().getDependentBeans(beanName); for (String dependentBean : dependentBeans) { doStop(lifecycleBeans, dependentBean, latch, countDownBeanNames); } try { if (bean.isRunning()) { if (bean instanceof SmartLifecycle) { if (logger.isDebugEnabled()) { logger.debug( "Asking bean '" + beanName + "' of type [" + bean.getClass() + "] to stop"); } countDownBeanNames.add(beanName); ((SmartLifecycle) bean).stop(() -> { latch.countDown(); countDownBeanNames.remove(beanName); if (logger.isDebugEnabled()) { logger.debug("Bean '" + beanName + "' completed its stop procedure"); } }); } else { if (logger.isDebugEnabled()) { logger.debug("Stopping bean '" + beanName + "' of type [" + bean.getClass() + "]"); } bean.stop(); if (logger.isDebugEnabled()) { logger.debug("Successfully stopped bean '" + beanName + "'"); } } } else if (bean instanceof SmartLifecycle) { // don't wait for beans that aren't running latch.countDown(); } } catch (Throwable ex) { if (logger.isWarnEnabled()) { logger.warn("Failed to stop bean '" + beanName + "'", ex); } } } }
From source file:org.springframework.data.hadoop.config.common.annotation.configuration.AutowireBeanFactoryObjectPostProcessor.java
@Override public void stop() { for (Lifecycle bean : lifecycleBeans) { bean.stop(); } running = false; }
From source file:org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.java
public void stop() { for (Lifecycle lifecycle : this.lifecycles) { if (lifecycle.isRunning()) { lifecycle.stop(); }/* www . java2 s . c om*/ } this.running = false; }
From source file:org.springframework.integration.x.bus.MessageBusSupport.java
protected void stopBindings() { for (Lifecycle bean : this.bindings) { try {/*from w w w .j av a2s.c om*/ bean.stop(); } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn("failed to stop adapter", e); } } } }
From source file:org.springframework.integration.x.rabbit.RabbitChannelRegistry.java
@Override public void destroy() { for (Lifecycle bean : this.lifecycleBeans) { try {//w w w. j a v a2s. co m bean.stop(); } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn("failed to stop adapter", e); } } } }
From source file:org.springframework.statemachine.processor.StateMachineAnnotationPostProcessor.java
@Override public void stop() { for (Lifecycle lifecycle : this.lifecycles) { if (lifecycle.isRunning()) { lifecycle.stop(); }/*ww w. jav a2s . c o m*/ } this.running = false; }