Yes, if the route definition varies for each route, you are better off
creating a Helper class with static methods that build up whatever route
nodes you need.

Another way is to create a base abstract RouteBuilder class that takes care
of the common route definitions. The per-route arguments are provided by
calling abstract getters (e.g. getParameterA()), for which the concrete
classes provide an implementation returning the value of the parameter.

Regards,

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, May 3, 2013 at 11:50 AM, mdo <manfred.doh...@gmail.com> wrote:

> Hello horyna,
>
>
> horyna wrote
> > But how to get the parameters into the route? I dont want to store
> > everything into header, body ...this will grow up the code again
>
> as far as I understood your requirement it boils down to the fact that you
> have a couple of routes that share parts of their route definitions. Let's
> assume you had some from() endpoints with different values to be set for
> the
> header "h".
>
> from("file:///.../a")
> .setHeader("h", constant("a"));
>
> Extract the commons parts to a parameterized method:
> private RouteDefinition callCommonPart(RouteDefinition from, String value)
> {
>         return from.setHeader("h", constant(value));
> }
>
> And you can apply this in your route building like this:
> RouteDefinition from = from("file:///.../a");
> callCommonPart(from, "a");
>
> When doing this you can specify the parameters at time of the route
> definition, you don't have to loop values through header fields.
>
> Doesn't this suffice your requirements?
>
> Regards, mdo.
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Is-possible-to-wrap-a-part-of-route-tp5731917p5731964.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to