camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: re-use route definition
Date Fri, 22 Nov 2013 15:37:51 GMT
Yes if you use Java RouteBuilder class you can use OO inheritance etc.

Just create a abstract base class and add the shared logic in the
configure method.
And then extend this base class, and call super.configure() first.

On Fri, Nov 22, 2013 at 4:28 PM, Olaf <omgolafguhl@gmail.com> wrote:
> Hello,
>
> what is the best way to reuse a route with different parameters? Let's say I
> have many classes implementing RouteBuilder interface and add them all in
> camel-context.xml
>
>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>         <routeBuilder ref="Route1" />
>         <routeBuilder ref="Route2" />
>         ...
>         ....
>     </camelContext>
>
> Almost in every Route class I repeat the similar logic: from("file:" +
> in).process(new  DoWork()).to("file:" + out);
>
> Is it possible to reuse this part in each Route, to avoid code duplication?
> I'd have to configure in and out parameter in xml and  import this part into
> configure method of Route1,2 class. Are there any examples how to do it?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/re-use-route-definition-tp5743696.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message