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 2011/11/15 14:31:36 UTC

svn commit: r1202182 - in /camel/branches/camel-2.7.x: ./ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/impl/

Author: davsclaus
Date: Tue Nov 15 13:31:36 2011
New Revision: 1202182

URL: http://svn.apache.org/viewvc?rev=1202182&view=rev
Log:
CAMEL-4682: Improve restarting CamelContext to ensure lifecycle strategies is not lost.

Added:
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextRestartTest.java
      - copied unchanged from r1202171, camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextRestartTest.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
      - copied, changed from r1202171, camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
Modified:
    camel/branches/camel-2.7.x/   (props changed)
    camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java

Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 13:31:36 2011
@@ -1,2 +1,2 @@
-/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639
-/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597,1187221,1189693,1199137,1199703,1199739,1199804,1200861,1201623,1201637
+/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639,1202171
+/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597,1187221,1189693,1199137,1199703,1199739,1199804,1200861,1201623,1201637,1202167

Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Nov 15 13:31:36 2011
@@ -1 +1 @@
-/camel/branches/camel-2.8.x:1-1146127,1146608,1146653,1146771,1146903,1147216,1170965-1171083,1171085-1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639
+/camel/branches/camel-2.8.x:1-1146127,1146608,1146653,1146771,1146903,1147216,1170965-1171083,1171085-1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226,1189704,1199138,1199732,1199766,1199807,1200867,1201638-1201639,1202171

Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1202182&r1=1202181&r2=1202182&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Tue Nov 15 13:31:36 2011
@@ -1403,6 +1403,7 @@ public class DefaultCamelContext extends
         getManagementStrategy().start();
 
         // start lifecycle strategies
+        ServiceHelper.startServices(lifecycleStrategies);
         Iterator<LifecycleStrategy> it = lifecycleStrategies.iterator();
         while (it.hasNext()) {
             LifecycleStrategy strategy = it.next();
@@ -1506,6 +1507,8 @@ public class DefaultCamelContext extends
 
         // shutdown management as the last one
         shutdownServices(managementStrategy);
+        shutdownServices(lifecycleStrategies);
+        // do not clear lifecycleStrategies as we can start Camel again and get the route back as before
 
         // stop the lazy created so they can be re-created on restart
         forceStopLazyInitialization();

Copied: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java (from r1202171, camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java?p2=camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java&p1=camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java&r1=1202171&r2=1202182&rev=1202182&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java Tue Nov 15 13:31:36 2011
@@ -18,18 +18,17 @@ package org.apache.camel.impl;
 
 import java.util.Collection;
 import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
-import org.apache.camel.ErrorHandlerFactory;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.Service;
 import org.apache.camel.VetoCamelContextStartException;
+import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.RouteContext;
@@ -141,7 +140,7 @@ public class DefaultCamelContextWithLife
         }
 
         @Override
-        public void onErrorHandlerAdd(RouteContext routeContext, Processor errorHandler, ErrorHandlerFactory errorHandlerBuilder) {
+        public void onErrorHandlerAdd(RouteContext routeContext, Processor errorHandler, ErrorHandlerBuilder errorHandlerBuilder) {
         }
 
         @Override