You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/03/22 05:50:41 UTC
svn commit: r925954 -
/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Author: ningjiang
Date: Mon Mar 22 04:50:41 2010
New Revision: 925954
URL: http://svn.apache.org/viewvc?rev=925954&view=rev
Log:
Merged revisions 925943 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r925943 | ningjiang | 2010-03-22 11:02:58 +0800 (Mon, 22 Mar 2010) | 1 line
CAMEL-2564 Should react to ContextStoppedEvent and invoke stop on CamelContext
........
Modified:
camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Modified: camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=925954&r1=925953&r2=925954&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java (original)
+++ camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java Mon Mar 22 04:50:41 2010
@@ -39,6 +39,7 @@ import org.springframework.context.Appli
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
@@ -124,6 +125,12 @@ public class SpringCamelContext extends
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
+ } else if (event instanceof ContextStoppedEvent) {
+ try {
+ maybeStop();
+ } catch (Exception e) {
+ throw wrapRuntimeCamelException(e);
+ }
}
if (eventEndpoint != null) {
@@ -216,6 +223,15 @@ public class SpringCamelContext extends
return shouldStartContext;
}
+ private void maybeStop() throws Exception {
+ if (!isStopping() && !isStopped()) {
+ stop();
+ } else {
+ // ignore as Camel is already stopped
+ LOG.trace("Ignoring maybeStop() as Apache Camel is already stopped");
+ }
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();