You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/01/18 11:01:33 UTC
svn commit: r735421 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/util/MainSupport.java
components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
Author: davsclaus
Date: Sun Jan 18 02:01:32 2009
New Revision: 735421
URL: http://svn.apache.org/viewvc?rev=735421&view=rev
Log:
CAMEL-1270: MainSupport should complete when stopping.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MainSupport.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MainSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MainSupport.java?rev=735421&r1=735420&r2=735421&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MainSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MainSupport.java Sun Jan 18 02:01:32 2009
@@ -187,8 +187,6 @@
/**
* Sets the duration to run the application for in milliseconds until it
* should be terminated. Defaults to -1. Any value <= 0 will run forever.
- *
- * @param duration
*/
public void setDuration(long duration) {
this.duration = duration;
@@ -266,6 +264,12 @@
return null;
}
+ protected void doStop() throws Exception {
+ LOG.info("Apache Camel " + getVersion() + " stopping");
+ // call completed to properly stop as we count down the waiting latch
+ completed();
+ }
+
protected void doStart() throws Exception {
LOG.info("Apache Camel " + getVersion() + " starting");
}
@@ -282,7 +286,7 @@
latch.await();
}
} catch (InterruptedException e) {
- LOG.debug("Caught: " + e);
+ Thread.currentThread().interrupt();
}
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?rev=735421&r1=735420&r2=735421&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java Sun Jan 18 02:01:32 2009
@@ -20,7 +20,6 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
-
import javax.xml.bind.JAXBException;
import org.apache.camel.CamelContext;
@@ -125,7 +124,6 @@
@Override
public void enableTrace() {
- // TODO
super.enableTrace();
setParentApplicationContextUri("/META-INF/services/org/apache/camel/spring/trace.xml");
}
@@ -187,11 +185,20 @@
if (applicationContext == null) {
applicationContext = createDefaultApplicationContext();
}
+ LOG.debug("Starting Spring ApplicationContext: " + applicationContext.getId());
applicationContext.start();
postProcessContext();
}
+ protected void doStop() throws Exception {
+ super.doStop();
+ if (applicationContext != null) {
+ LOG.debug("Stopping Spring ApplicationContext: " + applicationContext.getId());
+ applicationContext.close();
+ }
+ }
+
protected ProducerTemplate findOrCreateCamelTemplate() {
String[] names = getApplicationContext().getBeanNamesForType(ProducerTemplate.class);
if (names != null && names.length > 0) {
@@ -215,7 +222,7 @@
return new FileSystemXmlApplicationContext(args);
}
}
-
+
// default to classpath based
String[] args = getApplicationContextUri().split(";");
ApplicationContext parentContext = getParentApplicationContext();
@@ -226,14 +233,6 @@
}
}
- protected void doStop() throws Exception {
- LOG.info("Apache Camel terminating");
-
- if (applicationContext != null) {
- applicationContext.close();
- }
- }
-
protected Map<String, CamelContext> getCamelContextMap() {
Map<String, SpringCamelContext> map = applicationContext.getBeansOfType(SpringCamelContext.class);
Set<Map.Entry<String, SpringCamelContext>> entries = map.entrySet();