You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Allan C." <al...@gmail.com> on 2016/11/01 03:58:30 UTC

Java DSL: How to inject object endpoint?

Hi,

I've never used Java DSL to define routes. Can anyone share or provide some
hints on how to perform the same thing below in Java code? i.e. inject
someInstance into the endpoint.

<from uri="foo://bar?foobar=#someInstance" />

Regards,
Allan C.

Re: Java DSL: How to inject object endpoint?

Posted by "Allan C." <al...@gmail.com>.
I see. Noted, thanks!

Regards,
Allan C.

On Tue, Nov 1, 2016 at 12:04 PM, Minh Tran <da...@gmail.com> wrote:

> Hi
>
> It’s still the same syntax
>
> from("foo://bar?foobar=#someInstance”).to (….
>
> You still declare the someInstance somewhere in your Spring context as you
> would have previously using xml DSL
>
> > On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
> >
> > P/S I am using RouteBuilder
> >
> > Regards,
> > Allan C.
> >
> > On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I've never used Java DSL to define routes. Can anyone share or provide
> >> some hints on how to perform the same thing below in Java code? i.e.
> inject
> >> someInstance into the endpoint.
> >>
> >> <from uri="foo://bar?foobar=#someInstance" />
> >>
> >> Regards,
> >> Allan C.
> >>
>
>

Re: Java DSL: How to inject object endpoint?

Posted by "Allan C." <al...@gmail.com>.
I'll look into this, thanks.

Regards,
Allan C.

On Tue, Nov 1, 2016 at 10:21 PM, Brad Johnson <br...@mediadriver.com>
wrote:

> You may also want to look at @EndpointInject with uri of the route you want
> to invoke.  That depends on the specific needs.  You might use that in the
> case where you want to iterate over items in a list, mutate some data or
> filter items and find it easier to do in a Java POJO than in the route
> builder or XML.  In that case the injection of the endpoint will permit you
> to invoke the next route from your Java code.
>
> I recently had a case where I received a List of items from a REST/SOAP
> route and needed to make sure that all the items were valid before sending
> back an OK or a rejection.  All the beans in the list had to be valid or
> none of them could be processed.  It could have been done in blueprint but
> it would have been a bit more fiddly and not as easy to unit test.
>
> That's the nice thing about Camel is it permits different mechanisms.
>
> On Mon, Oct 31, 2016 at 11:24 PM, Allan C. <al...@gmail.com> wrote:
>
> > Noted, thanks for the tips!
> >
> > Regards,
> > Allan C.
> >
> > On Tue, Nov 1, 2016 at 12:11 PM, Tomohisa Igarashi <
> tm.igarashi@gmail.com>
> > wrote:
> >
> > > Or migrate to @Named("someInstance") CDI bean with using camel-cdi?
> > > http://camel.apache.org/cdi.html
> > >
> > >
> > > On 11/01/2016 01:04 PM, Minh Tran wrote:
> > >
> > >> Hi
> > >>
> > >> It’s still the same syntax
> > >>
> > >> from("foo://bar?foobar=#someInstance”).to (….
> > >>
> > >> You still declare the someInstance somewhere in your Spring context as
> > >> you would have previously using xml DSL
> > >>
> > >> On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
> > >>>
> > >>> P/S I am using RouteBuilder
> > >>>
> > >>> Regards,
> > >>> Allan C.
> > >>>
> > >>> On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com>
> wrote:
> > >>>
> > >>> Hi,
> > >>>>
> > >>>> I've never used Java DSL to define routes. Can anyone share or
> provide
> > >>>> some hints on how to perform the same thing below in Java code? i.e.
> > >>>> inject
> > >>>> someInstance into the endpoint.
> > >>>>
> > >>>> <from uri="foo://bar?foobar=#someInstance" />
> > >>>>
> > >>>> Regards,
> > >>>> Allan C.
> > >>>>
> > >>>>
> > >>
> >
>

Re: Java DSL: How to inject object endpoint?

Posted by Brad Johnson <br...@mediadriver.com>.
You may also want to look at @EndpointInject with uri of the route you want
to invoke.  That depends on the specific needs.  You might use that in the
case where you want to iterate over items in a list, mutate some data or
filter items and find it easier to do in a Java POJO than in the route
builder or XML.  In that case the injection of the endpoint will permit you
to invoke the next route from your Java code.

I recently had a case where I received a List of items from a REST/SOAP
route and needed to make sure that all the items were valid before sending
back an OK or a rejection.  All the beans in the list had to be valid or
none of them could be processed.  It could have been done in blueprint but
it would have been a bit more fiddly and not as easy to unit test.

That's the nice thing about Camel is it permits different mechanisms.

On Mon, Oct 31, 2016 at 11:24 PM, Allan C. <al...@gmail.com> wrote:

> Noted, thanks for the tips!
>
> Regards,
> Allan C.
>
> On Tue, Nov 1, 2016 at 12:11 PM, Tomohisa Igarashi <tm...@gmail.com>
> wrote:
>
> > Or migrate to @Named("someInstance") CDI bean with using camel-cdi?
> > http://camel.apache.org/cdi.html
> >
> >
> > On 11/01/2016 01:04 PM, Minh Tran wrote:
> >
> >> Hi
> >>
> >> It’s still the same syntax
> >>
> >> from("foo://bar?foobar=#someInstance”).to (….
> >>
> >> You still declare the someInstance somewhere in your Spring context as
> >> you would have previously using xml DSL
> >>
> >> On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
> >>>
> >>> P/S I am using RouteBuilder
> >>>
> >>> Regards,
> >>> Allan C.
> >>>
> >>> On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:
> >>>
> >>> Hi,
> >>>>
> >>>> I've never used Java DSL to define routes. Can anyone share or provide
> >>>> some hints on how to perform the same thing below in Java code? i.e.
> >>>> inject
> >>>> someInstance into the endpoint.
> >>>>
> >>>> <from uri="foo://bar?foobar=#someInstance" />
> >>>>
> >>>> Regards,
> >>>> Allan C.
> >>>>
> >>>>
> >>
>

Re: Java DSL: How to inject object endpoint?

Posted by "Allan C." <al...@gmail.com>.
Noted, thanks for the tips!

Regards,
Allan C.

On Tue, Nov 1, 2016 at 12:11 PM, Tomohisa Igarashi <tm...@gmail.com>
wrote:

> Or migrate to @Named("someInstance") CDI bean with using camel-cdi?
> http://camel.apache.org/cdi.html
>
>
> On 11/01/2016 01:04 PM, Minh Tran wrote:
>
>> Hi
>>
>> It’s still the same syntax
>>
>> from("foo://bar?foobar=#someInstance”).to (….
>>
>> You still declare the someInstance somewhere in your Spring context as
>> you would have previously using xml DSL
>>
>> On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
>>>
>>> P/S I am using RouteBuilder
>>>
>>> Regards,
>>> Allan C.
>>>
>>> On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:
>>>
>>> Hi,
>>>>
>>>> I've never used Java DSL to define routes. Can anyone share or provide
>>>> some hints on how to perform the same thing below in Java code? i.e.
>>>> inject
>>>> someInstance into the endpoint.
>>>>
>>>> <from uri="foo://bar?foobar=#someInstance" />
>>>>
>>>> Regards,
>>>> Allan C.
>>>>
>>>>
>>

Re: Java DSL: How to inject object endpoint?

Posted by Tomohisa Igarashi <tm...@gmail.com>.
Or migrate to @Named("someInstance") CDI bean with using camel-cdi?
http://camel.apache.org/cdi.html

On 11/01/2016 01:04 PM, Minh Tran wrote:
> Hi
>
> It\u2019s still the same syntax
>
> from("foo://bar?foobar=#someInstance\u201d).to (\u2026.
>
> You still declare the someInstance somewhere in your Spring context as you would have previously using xml DSL
>
>> On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
>>
>> P/S I am using RouteBuilder
>>
>> Regards,
>> Allan C.
>>
>> On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I've never used Java DSL to define routes. Can anyone share or provide
>>> some hints on how to perform the same thing below in Java code? i.e. inject
>>> someInstance into the endpoint.
>>>
>>> <from uri="foo://bar?foobar=#someInstance" />
>>>
>>> Regards,
>>> Allan C.
>>>
>

Re: Java DSL: How to inject object endpoint?

Posted by Minh Tran <da...@gmail.com>.
Hi

It’s still the same syntax

from("foo://bar?foobar=#someInstance”).to (….

You still declare the someInstance somewhere in your Spring context as you would have previously using xml DSL

> On 1 Nov 2016, at 3:01 PM, Allan C. <al...@gmail.com> wrote:
> 
> P/S I am using RouteBuilder
> 
> Regards,
> Allan C.
> 
> On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:
> 
>> Hi,
>> 
>> I've never used Java DSL to define routes. Can anyone share or provide
>> some hints on how to perform the same thing below in Java code? i.e. inject
>> someInstance into the endpoint.
>> 
>> <from uri="foo://bar?foobar=#someInstance" />
>> 
>> Regards,
>> Allan C.
>> 


Re: Java DSL: How to inject object endpoint?

Posted by "Allan C." <al...@gmail.com>.
P/S I am using RouteBuilder

Regards,
Allan C.

On Tue, Nov 1, 2016 at 11:58 AM, Allan C. <al...@gmail.com> wrote:

> Hi,
>
> I've never used Java DSL to define routes. Can anyone share or provide
> some hints on how to perform the same thing below in Java code? i.e. inject
> someInstance into the endpoint.
>
> <from uri="foo://bar?foobar=#someInstance" />
>
> Regards,
> Allan C.
>