camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r766564 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/DefaultCamelContext.java test/java/org/apache/camel/impl/DefaultCamelContextTest.java
Date Mon, 20 Apr 2009 03:09:31 GMT
Author: ningjiang
Date: Mon Apr 20 03:09:31 2009
New Revision: 766564

URL: http://svn.apache.org/viewvc?rev=766564&view=rev
Log:
CAMEL-1544 clearing the RouteServices when the CamelContext is stopped.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=766564&r1=766563&r2=766564&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Mon
Apr 20 03:09:31 2009
@@ -85,7 +85,7 @@
     private static final String NAME_PREFIX = "camel-";
     private static int nameSuffix;
 
-    private String name;
+    private String name;  
     private final Map<String, Endpoint> endpoints = new HashMap<String, Endpoint>();
     private final Map<String, Component> components = new HashMap<String, Component>();
     private List<Route> routes;
@@ -881,13 +881,14 @@
     protected synchronized void doStop() throws Exception {
         LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") is stopping");
         stopServices(routeServices.values());
-
         stopServices(servicesToClose);
         if (components != null) {
             for (Component component : components.values()) {
                 stopServices(component);
             }
         }
+        routeServices.clear();
+        servicesToClose.clear();
         LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") stopped");
     }
 
@@ -1072,5 +1073,9 @@
             }
         }
     }
+    
+    protected Map<String, RouteService> getRouteServices() {
+        return routeServices;
+    }
 
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java?rev=766564&r1=766563&r2=766564&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextTest.java
Mon Apr 20 03:09:31 2009
@@ -23,6 +23,7 @@
 import org.apache.camel.Endpoint;
 import org.apache.camel.NoSuchEndpointException;
 import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.bean.BeanComponent;
 import org.apache.camel.util.CamelContextHelper;
 
@@ -80,5 +81,23 @@
             // expected
         }
     }
+    
+    public void testRestartCamelContext() throws Exception {
+        DefaultCamelContext ctx = new DefaultCamelContext();
+        ctx.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:endpointA").to("mock:endpointB");                
+            }            
+        });
+        ctx.start();
+        assertEquals("Should have one RouteService", ctx.getRouteServices().size(), 1);
+        ctx.stop();
+        assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(),
0);
+        ctx.start();
+        assertEquals("Should have one RouteService", ctx.getRouteServices().size(), 1);
+        ctx.stop();
+        assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(),
0);
+    }
 
 }



Mime
View raw message