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:06:14 UTC

svn commit: r735424 - in /activemq/camel/branches/camel-1.x: ./ 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:06:14 2009
New Revision: 735424

URL: http://svn.apache.org/viewvc?rev=735424&view=rev
Log:
Merged revisions 735421 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r735421 | davsclaus | 2009-01-18 11:01:32 +0100 (Sun, 18 Jan 2009) | 1 line
  
  CAMEL-1270: MainSupport should complete when stopping.
........

Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/MainSupport.java
    activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan 18 02:06:14 2009
@@ -1 +1 @@
-/activemq/camel/trunk:732943,733749,734053,734057-734058,734064,734130,734309,734340-734342,734348,734392,734422,734727,734903,734932
+/activemq/camel/trunk:732943,733749,734053,734057-734058,734064,734130,734309,734340-734342,734348,734392,734422,734727,734903,734932,735421

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/MainSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/MainSupport.java?rev=735424&r1=735423&r2=735424&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/MainSupport.java (original)
+++ activemq/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/util/MainSupport.java Sun Jan 18 02:06:14 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/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?rev=735424&r1=735423&r2=735424&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java Sun Jan 18 02:06:14 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();