RouteBuilder.getRoutes does not return routes
---------------------------------------------
Key: CAMEL-919
URL: https://issues.apache.org/activemq/browse/CAMEL-919
Project: Apache Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 1.4.0
Reporter: Atle Prange
Suspected reason:
Looking at the code reveals that the initalization of the routebuilder actually
sets the routes in the injected CamelContext, but does not populate the local
list of routes.
Consequence:
One is not able to replace routes in the CamelContext by fetching routes from
routebuilders, and then set the list of routes in the camel context.
{code}
List<Routes> routeList = new ArrayList();
//Some method fetching all my builders
List<Routes> routesList = getRouteBuilders();
//Build a list of all routes, thereby updating my camel context with fresh
routes...
for(Routes routes:routesList){
//Fetches an empty list, but the builder now sets the route in the context
List<Route> routeListFromBuilder = routes.getRouteList();
//I am now adding an empty list to my list of routes
routeList.addAll( routeListFromBuilder );
}
//Sets an empty list into the context, thereby clearing all routes
camleContext.setRoutes( routeList );
{code}
Possible solution:
in RouteBuilder replace:
{code}
protected void populateRoutes(List<Route> routes) throws Exception {
CamelContext camelContext = getContext();
if (camelContext == null) {
throw new IllegalArgumentException("No CamelContext has been
injected!");
}
routeCollection.setCamelContext(camelContext);
camelContext.addRouteDefinitions(routeCollection.getRoutes());
}
{code}
with
{code}
protected void populateRoutes(List<Route> routes) throws Exception {
CamelContext camelContext = getContext();
if (camelContext == null) {
throw new IllegalArgumentException("No CamelContext has been
injected!");
}
routeCollection.setCamelContext(camelContext);
routes.addAll(routeCollection.getRoutes());
}
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.