So when we're routing into a Protocol from the outside, we need to
decide what the URI parameters map to - is it configuring properties
on the protocol bean, or passing headers into the message? It could go
either way.

Typically we tend to configure a component (which can have many
possible endpoints) once through dependency injection
(spring/guice/jndi etc), then use uri parameters to configure the
actual Endpoint objects.

So when a Protocol is a Component we should follow suit; if you want
different Protocol instances with different configurations (with their
own sets of endpoints) then use different dependency injected beans
with different URI schemes.

So in your previous example we might use URIs "fooBar://in" &
"fooNoBar://in" on different component instances configured.

When a Protocol is exposed as just a single Endpoint (with a fixed
"in" endpoint), then the act of creating the Endpoint from the
Protocol could configure a new instance of the Protocol bean using URI
query parameters.

So in your example, "route:foo?foo=bar" could be instantiating the foo
bean, setting the foo property then invoking it's 'in' endpoint.

Incidentally, maybe using the term "Protocol" for the Component or
Endpoint use cases above is confusing. Maybe we say a Protocol is-a
Component with a URI scheme and multiple public input/output endpoints
and for the Endpoint case (in your example) we just call that a "Route
Endpoint" - I.e. turning a named RouteBuilder bean into an Endpoint
(then sending to it's first 'from')?


On Thursday, October 28, 2010, kristofsajdak <[email protected]> wrote:
>
>
> kristofsajdak wrote:
>>
>> I really think this adds a lot of value for non technical people (e.g.
>> solution consultants).
>> The developers would take care of configuring ProtocolBuilder 'templates'
>> and injecting them with global properties and middleware stuff. The
>> solution consultants would further enhance the Builders with
>> protocol stuff using the URI parameters.
>>
>> This saves them the trouble defining beans for every variation of a
>> particurlar ProtocolBuilder template.
>>
>> E.g.
>>
>>         <route>
>>             <from uri="direct:start"/>
>>             <to uri="route:foo?foo=bar"/>
>>             <to uri="route:foo?foo=noBar"/>
>>             <to uri="mock:result"/>
>>         </route>
>>
>> I guess you'd need to define the Builder with a prototype scope to pull
>> something like this off ?
>>
>
> Mixing things up a bit.
> I copy/pasted the snippet above from the customer poc codebase.
>
> Based on what was discussed in this topic, it could look like
>
>     <route>
>             <from uri="direct:start"/>
>             <to uri="foo://in?foo=bar"/>
>             <to uri="foo://in?foo=noBar"/>
>             <to uri="mock:result"/>
>         </route>
>
> were foo is a bean in spring, injected with let's say a BarService
> middleware depedency.
>
> 2 usages of foo in the route above results in 2 foo instances.
> one instance parameterized with foo = bar, the other one with foo = noBar.
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Abstracting-Routes-using-Components-tp3234703p3241229.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

-- 
James
-------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: jstrachan
Blog: http://macstrac.blogspot.com/

Open Source Integration

Reply via email to