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 2009/04/20 11:57:03 UTC
svn commit: r766633 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/impl/
main/java/org/apache/camel/processor/interceptor/
test/java/org/apache/camel/impl/
Author: ningjiang
Date: Mon Apr 20 09:57:03 2009
New Revision: 766633
URL: http://svn.apache.org/viewvc?rev=766633&view=rev
Log:
CAMEL-1547, CAMEL-1546 resolved some issues of restarting the CamelContext
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCaching.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=766633&r1=766632&r2=766633&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 09:57:03 2009
@@ -84,7 +84,7 @@
private static final transient Log LOG = LogFactory.getLog(DefaultCamelContext.class);
private static final String NAME_PREFIX = "camel-";
private static int nameSuffix;
-
+ private boolean routeDefinitionInitiated;
private String name;
private final Map<String, Endpoint> endpoints = new HashMap<String, Endpoint>();
private final Map<String, Component> components = new HashMap<String, Component>();
@@ -808,7 +808,7 @@
if (getStreamCache()) {
// only add a new stream cache if not already configured
- if (StreamCaching.getStreamCache(this) == null) {
+ if (StreamCaching.getStreamCaching(this) == null) {
LOG.debug("StreamCaching is enabled");
addInterceptStrategy(new StreamCaching());
}
@@ -855,7 +855,11 @@
startServices(component);
}
}
- startRouteDefinitions(routeDefinitions);
+ // To avoid initiating the routeDefinitions after stopping the camel context
+ if (!routeDefinitionInitiated) {
+ startRouteDefinitions(routeDefinitions);
+ routeDefinitionInitiated = true;
+ }
}
protected void startRouteDefinitions(Collection<RouteDefinition> list) throws Exception {
@@ -887,7 +891,7 @@
stopServices(component);
}
}
- routeServices.clear();
+
servicesToClose.clear();
LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") stopped");
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java?rev=766633&r1=766632&r2=766633&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java Mon Apr 20 09:57:03 2009
@@ -44,11 +44,11 @@
* @param context the camel context the delayer is connected to
* @return the delayer or null if none can be found
*/
- public static DelayInterceptor getDelayer(CamelContext context) {
+ public static Delayer getDelayer(CamelContext context) {
List<InterceptStrategy> list = context.getInterceptStrategies();
for (InterceptStrategy interceptStrategy : list) {
- if (interceptStrategy instanceof DelayInterceptor) {
- return (DelayInterceptor)interceptStrategy;
+ if (interceptStrategy instanceof Delayer) {
+ return (Delayer)interceptStrategy;
}
}
return null;
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCaching.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCaching.java?rev=766633&r1=766632&r2=766633&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCaching.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCaching.java Mon Apr 20 09:57:03 2009
@@ -34,17 +34,17 @@
}
/**
- * A helper method to return the StreamCacheInterceptor instance
+ * A helper method to return the StreamCaching instance
* for a given {@link org.apache.camel.CamelContext} if one is enabled
*
* @param context the camel context the stream cache is connected to
* @return the stream cache or null if none can be found
*/
- public static StreamCachingInterceptor getStreamCache(CamelContext context) {
+ public static StreamCaching getStreamCaching(CamelContext context) {
List<InterceptStrategy> list = context.getInterceptStrategies();
for (InterceptStrategy interceptStrategy : list) {
- if (interceptStrategy instanceof StreamCachingInterceptor) {
- return (StreamCachingInterceptor)interceptStrategy;
+ if (interceptStrategy instanceof StreamCaching) {
+ return (StreamCaching)interceptStrategy;
}
}
return null;
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=766633&r1=766632&r2=766633&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 09:57:03 2009
@@ -91,13 +91,18 @@
}
});
ctx.start();
- assertEquals("Should have one RouteService", ctx.getRouteServices().size(), 1);
- ctx.stop();
- assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(), 0);
+ assertEquals("Should have one RouteService", ctx.getRouteServices().size(), 1);
+ String routesString = ctx.getRoutes().toString();
+ System.out.println("The routes is " + ctx.getRoutes());
+ ctx.stop();
+ assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(), 1);
ctx.start();
assertEquals("Should have one RouteService", ctx.getRouteServices().size(), 1);
+ System.out.println("The routes is " + ctx.getRoutes());
+ assertEquals("The Routes should be same", routesString, ctx.getRoutes().toString());
ctx.stop();
- assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(), 0);
+ assertEquals("The RouteService should be removed ", ctx.getRouteServices().size(), 1);
+
}
}