camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CAMEL-919) RouteBuilder.getRoutes does not return routes
Date Sun, 21 Sep 2008 07:26:52 GMT

    [ https://issues.apache.org/activemq/browse/CAMEL-919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45843#action_45843
] 

Claus Ibsen commented on CAMEL-919:
-----------------------------------

Thanks for reporting this.

The Route is hardly used in Camel as we use the model RoutesType to build the route paths.

> 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.


Mime
View raw message