You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/06/26 15:28:07 UTC

Can we retrieve an endpoint using the id ?

hi,

Can we retrieve an endpoint using the id defined in a Spring XML file?

<camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}" />

idea : exchange.getcontext().getEndpointId()

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com

Re: Can we retrieve an endpoint using the id ?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Charles look at this ticket
https://issues.apache.org/activemq/browse/CAMEL-1763

And its commit log how it was implemented and the wiki page how to use it.


On Fri, Jun 26, 2009 at 5:53 PM, Claus Ibsen<cl...@gmail.com> wrote:
> Try to let your POJO implements CamelContextAware
>
> We could like how Camel binds to Exchange, TypeConverter do the same
> for Registry so you just define one parameter as Registry
> public String doSomething(String body, Registry registry)
>
> And the same for CamelContext
> public String doSomething(String body, CamelContext context)
>
>
>
> On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cm...@gmail.com> wrote:
>> Thx.
>>
>> Can a java POJO/Bean obtain the camel context without using the exchange
>> (exchange.getContext()) object ?
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com> wrote:
>>
>>> context.getRegistry().lookup("myBeanId", Endpoint.class);
>>>
>>> Will lookup in the spring application context, and AFAIR the
>>> <endpoint> tag will register it as a spring bean also.
>>>
>>>
>>> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cm...@gmail.com>
>>> wrote:
>>> > How can I get the SpringCamelBuilder in a POJO.
>>> >
>>> > Regards,
>>> >
>>> > Charles Moulliard
>>> > Senior Enterprise Architect
>>> > Apache Camel Committer
>>> >
>>> > *****************************
>>> > blog : http://cmoulliard.blogspot.com
>>> >
>>> >
>>> > On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <willem.jiang@gmail.com
>>> >wrote:
>>> >
>>> >> Hi Charles,
>>> >>
>>> >> SpringCamelBuilder has a method to look up the bean's instance from the
>>> >> application context.
>>> >>
>>> >> Object bean(String beanName) in camel 1.x branch
>>> >>
>>> >> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>>> >>
>>> >> So I think you should have no trouble to do this job :)
>>> >>
>>> >> Willem
>>> >>
>>> >>
>>> >> Charles Moulliard wrote:
>>> >> > hi,
>>> >> >
>>> >> > Can we retrieve an endpoint using the id defined in a Spring XML file?
>>> >> >
>>> >> > <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}"
>>> />
>>> >> >
>>> >> > idea : exchange.getcontext().getEndpointId()
>>> >> >
>>> >> > Regards,
>>> >> >
>>> >> > Charles Moulliard
>>> >> > Senior Enterprise Architect
>>> >> > Apache Camel Committer
>>> >> >
>>> >> > *****************************
>>> >> > blog : http://cmoulliard.blogspot.com
>>> >> >
>>> >>
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Can we retrieve an endpoint using the id ?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah the CamelContextAware does not support multiple camel contexts.

So use spring IoC to inject the camel context you want. Then you can
pin point precisely which camel context to use.

And beware if you have 1 service helper and N camel context then its
only safe to either
- have N service helper as well, one for each camel context
- get the camel context from the exchange every thing you method is
invoked, then you got the right one
- or use the new CamelContext parameter binding



On Mon, Jun 29, 2009 at 10:51 AM, Charles Moulliard<cm...@gmail.com> wrote:
> What you propose is that I create a class like this :
>
> public class ServiceHelper implements CamelContextAware {
>
>   private CamelContext camelContext;
>
>   public Request createRequest(@Header(value = "messageType") String
> messageType,
>                                               @Header(value =
> "CamelFileNameOnly") String fileName,
>                                               @Body String body) {
>
>           // Here we can use camelContext
>           Endpoint endpoint = camelContext.getEndpoint("Endpoint name");
>           ....
>
>    }
>
>    // Using spring we will inject the camelContext Here
>    public void setCamelContext(CamelContext camelContext) {
>            this.camelContext = camelContext;
>    }
> }
>
> Proposition
>
> It could be interesting that we provide a method in the CamelContextAware to
> inject a list of CamelContext and not only !!!
>
> e.g.
>
> List<CamelContext> camelContexts = new ArrayList<CamelContext>();
>
> public void setCamelContexts(List camelContexts) {
>        this.camelContexts = camelContexts
> }
>
> or even better using the camelContext as id
>
> Map<String, CamelContext> camelContexts = new HashMap<String,
> CamelContext>();
>
> So in the method, we can use :
>
> camelContexts.get("camelcontext id") to retrieve the camelContext
>
>
> Regards,
>
> Charles
>
> On Mon, Jun 29, 2009 at 10:36 AM, Willem Jiang <wi...@gmail.com>wrote:
>
>> Hi Charles,
>>
>> If your POJO implements CamelContetAware, you don't need to pass the
>> CamelContext to every method of the POJO.
>> CamelContext provides a way to access the object as the JNDI,  but I
>> don't know how to get the JNDI context from your POJO. Can you get me
>> some hits ;)
>>
>> Willem
>>
>>
>> Charles Moulliard wrote:
>> > Is it not a bit overkill to pass CamelContext, Registry object to every
>> > method of a POJO to have access to route, endpoints, ... information ?
>> > Why can't we call (like in JNDI) a utility class to have access to the
>> > CamelContext, Registry published ?
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Fri, Jun 26, 2009 at 5:53 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> Try to let your POJO implements CamelContextAware
>> >>
>> >> We could like how Camel binds to Exchange, TypeConverter do the same
>> >> for Registry so you just define one parameter as Registry
>> >> public String doSomething(String body, Registry registry)
>> >>
>> >> And the same for CamelContext
>> >> public String doSomething(String body, CamelContext context)
>> >>
>> >>
>> >>
>> >> On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cmoulliard@gmail.com
>> >
>> >> wrote:
>> >>> Thx.
>> >>>
>> >>> Can a java POJO/Bean obtain the camel context without using the
>> exchange
>> >>> (exchange.getContext()) object ?
>> >>>
>> >>> Charles Moulliard
>> >>> Senior Enterprise Architect
>> >>> Apache Camel Committer
>> >>>
>> >>> *****************************
>> >>> blog : http://cmoulliard.blogspot.com
>> >>>
>> >>>
>> >>> On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com>
>> >> wrote:
>> >>>> context.getRegistry().lookup("myBeanId", Endpoint.class);
>> >>>>
>> >>>> Will lookup in the spring application context, and AFAIR the
>> >>>> <endpoint> tag will register it as a spring bean also.
>> >>>>
>> >>>>
>> >>>> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<
>> cmoulliard@gmail.com
>> >>>> wrote:
>> >>>>> How can I get the SpringCamelBuilder in a POJO.
>> >>>>>
>> >>>>> Regards,
>> >>>>>
>> >>>>> Charles Moulliard
>> >>>>> Senior Enterprise Architect
>> >>>>> Apache Camel Committer
>> >>>>>
>> >>>>> *****************************
>> >>>>> blog : http://cmoulliard.blogspot.com
>> >>>>>
>> >>>>>
>> >>>>> On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <
>> willem.jiang@gmail.com
>> >>>>> wrote:
>> >>>>>
>> >>>>>> Hi Charles,
>> >>>>>>
>> >>>>>> SpringCamelBuilder has a method to look up the bean's instance from
>> >> the
>> >>>>>> application context.
>> >>>>>>
>> >>>>>> Object bean(String beanName) in camel 1.x branch
>> >>>>>>
>> >>>>>> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>> >>>>>>
>> >>>>>> So I think you should have no trouble to do this job :)
>> >>>>>>
>> >>>>>> Willem
>> >>>>>>
>> >>>>>>
>> >>>>>> Charles Moulliard wrote:
>> >>>>>>> hi,
>> >>>>>>>
>> >>>>>>> Can we retrieve an endpoint using the id defined in a Spring XML
>> >> file?
>> >>>>>>> <camel:endpoint id="QuickFixStreamEndpoint"
>> >> uri="#{uriQuickFixStream}"
>> >>>> />
>> >>>>>>> idea : exchange.getcontext().getEndpointId()
>> >>>>>>>
>> >>>>>>> Regards,
>> >>>>>>>
>> >>>>>>> Charles Moulliard
>> >>>>>>> Senior Enterprise Architect
>> >>>>>>> Apache Camel Committer
>> >>>>>>>
>> >>>>>>> *****************************
>> >>>>>>> blog : http://cmoulliard.blogspot.com
>> >>>>>>>
>> >>>>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Claus Ibsen
>> >>>> Apache Camel Committer
>> >>>>
>> >>>> Open Source Integration: http://fusesource.com
>> >>>> Blog: http://davsclaus.blogspot.com/
>> >>>> Twitter: http://twitter.com/davsclaus
>> >>>>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> Apache Camel Committer
>> >>
>> >> Open Source Integration: http://fusesource.com
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Twitter: http://twitter.com/davsclaus
>> >>
>> >
>>
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Can we retrieve an endpoint using the id ?

Posted by Charles Moulliard <cm...@gmail.com>.
What you propose is that I create a class like this :

public class ServiceHelper implements CamelContextAware {

   private CamelContext camelContext;

   public Request createRequest(@Header(value = "messageType") String
messageType,
                                               @Header(value =
"CamelFileNameOnly") String fileName,
                                               @Body String body) {

           // Here we can use camelContext
           Endpoint endpoint = camelContext.getEndpoint("Endpoint name");
           ....

    }

    // Using spring we will inject the camelContext Here
    public void setCamelContext(CamelContext camelContext) {
            this.camelContext = camelContext;
    }
}

Proposition

It could be interesting that we provide a method in the CamelContextAware to
inject a list of CamelContext and not only !!!

e.g.

List<CamelContext> camelContexts = new ArrayList<CamelContext>();

public void setCamelContexts(List camelContexts) {
        this.camelContexts = camelContexts
}

or even better using the camelContext as id

Map<String, CamelContext> camelContexts = new HashMap<String,
CamelContext>();

So in the method, we can use :

camelContexts.get("camelcontext id") to retrieve the camelContext


Regards,

Charles

On Mon, Jun 29, 2009 at 10:36 AM, Willem Jiang <wi...@gmail.com>wrote:

> Hi Charles,
>
> If your POJO implements CamelContetAware, you don't need to pass the
> CamelContext to every method of the POJO.
> CamelContext provides a way to access the object as the JNDI,  but I
> don't know how to get the JNDI context from your POJO. Can you get me
> some hits ;)
>
> Willem
>
>
> Charles Moulliard wrote:
> > Is it not a bit overkill to pass CamelContext, Registry object to every
> > method of a POJO to have access to route, endpoints, ... information ?
> > Why can't we call (like in JNDI) a utility class to have access to the
> > CamelContext, Registry published ?
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jun 26, 2009 at 5:53 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> Try to let your POJO implements CamelContextAware
> >>
> >> We could like how Camel binds to Exchange, TypeConverter do the same
> >> for Registry so you just define one parameter as Registry
> >> public String doSomething(String body, Registry registry)
> >>
> >> And the same for CamelContext
> >> public String doSomething(String body, CamelContext context)
> >>
> >>
> >>
> >> On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cmoulliard@gmail.com
> >
> >> wrote:
> >>> Thx.
> >>>
> >>> Can a java POJO/Bean obtain the camel context without using the
> exchange
> >>> (exchange.getContext()) object ?
> >>>
> >>> Charles Moulliard
> >>> Senior Enterprise Architect
> >>> Apache Camel Committer
> >>>
> >>> *****************************
> >>> blog : http://cmoulliard.blogspot.com
> >>>
> >>>
> >>> On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com>
> >> wrote:
> >>>> context.getRegistry().lookup("myBeanId", Endpoint.class);
> >>>>
> >>>> Will lookup in the spring application context, and AFAIR the
> >>>> <endpoint> tag will register it as a spring bean also.
> >>>>
> >>>>
> >>>> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<
> cmoulliard@gmail.com
> >>>> wrote:
> >>>>> How can I get the SpringCamelBuilder in a POJO.
> >>>>>
> >>>>> Regards,
> >>>>>
> >>>>> Charles Moulliard
> >>>>> Senior Enterprise Architect
> >>>>> Apache Camel Committer
> >>>>>
> >>>>> *****************************
> >>>>> blog : http://cmoulliard.blogspot.com
> >>>>>
> >>>>>
> >>>>> On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <
> willem.jiang@gmail.com
> >>>>> wrote:
> >>>>>
> >>>>>> Hi Charles,
> >>>>>>
> >>>>>> SpringCamelBuilder has a method to look up the bean's instance from
> >> the
> >>>>>> application context.
> >>>>>>
> >>>>>> Object bean(String beanName) in camel 1.x branch
> >>>>>>
> >>>>>> <T> T lookup(String String beanName, Class<T> type) in camel trunk
> >>>>>>
> >>>>>> So I think you should have no trouble to do this job :)
> >>>>>>
> >>>>>> Willem
> >>>>>>
> >>>>>>
> >>>>>> Charles Moulliard wrote:
> >>>>>>> hi,
> >>>>>>>
> >>>>>>> Can we retrieve an endpoint using the id defined in a Spring XML
> >> file?
> >>>>>>> <camel:endpoint id="QuickFixStreamEndpoint"
> >> uri="#{uriQuickFixStream}"
> >>>> />
> >>>>>>> idea : exchange.getcontext().getEndpointId()
> >>>>>>>
> >>>>>>> Regards,
> >>>>>>>
> >>>>>>> Charles Moulliard
> >>>>>>> Senior Enterprise Architect
> >>>>>>> Apache Camel Committer
> >>>>>>>
> >>>>>>> *****************************
> >>>>>>> blog : http://cmoulliard.blogspot.com
> >>>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Claus Ibsen
> >>>> Apache Camel Committer
> >>>>
> >>>> Open Source Integration: http://fusesource.com
> >>>> Blog: http://davsclaus.blogspot.com/
> >>>> Twitter: http://twitter.com/davsclaus
> >>>>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>

Re: Can we retrieve an endpoint using the id ?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

If your POJO implements CamelContetAware, you don't need to pass the
CamelContext to every method of the POJO.
CamelContext provides a way to access the object as the JNDI,  but I
don't know how to get the JNDI context from your POJO. Can you get me
some hits ;)

Willem


Charles Moulliard wrote:
> Is it not a bit overkill to pass CamelContext, Registry object to every
> method of a POJO to have access to route, endpoints, ... information ?
> Why can't we call (like in JNDI) a utility class to have access to the
> CamelContext, Registry published ?
> 
> Regards,
> 
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
> 
> *****************************
> blog : http://cmoulliard.blogspot.com
> 
> 
> On Fri, Jun 26, 2009 at 5:53 PM, Claus Ibsen <cl...@gmail.com> wrote:
> 
>> Try to let your POJO implements CamelContextAware
>>
>> We could like how Camel binds to Exchange, TypeConverter do the same
>> for Registry so you just define one parameter as Registry
>> public String doSomething(String body, Registry registry)
>>
>> And the same for CamelContext
>> public String doSomething(String body, CamelContext context)
>>
>>
>>
>> On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cm...@gmail.com>
>> wrote:
>>> Thx.
>>>
>>> Can a java POJO/Bean obtain the camel context without using the exchange
>>> (exchange.getContext()) object ?
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>>
>>>
>>> On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>>>> context.getRegistry().lookup("myBeanId", Endpoint.class);
>>>>
>>>> Will lookup in the spring application context, and AFAIR the
>>>> <endpoint> tag will register it as a spring bean also.
>>>>
>>>>
>>>> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cmoulliard@gmail.com
>>>> wrote:
>>>>> How can I get the SpringCamelBuilder in a POJO.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Charles Moulliard
>>>>> Senior Enterprise Architect
>>>>> Apache Camel Committer
>>>>>
>>>>> *****************************
>>>>> blog : http://cmoulliard.blogspot.com
>>>>>
>>>>>
>>>>> On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <willem.jiang@gmail.com
>>>>> wrote:
>>>>>
>>>>>> Hi Charles,
>>>>>>
>>>>>> SpringCamelBuilder has a method to look up the bean's instance from
>> the
>>>>>> application context.
>>>>>>
>>>>>> Object bean(String beanName) in camel 1.x branch
>>>>>>
>>>>>> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>>>>>>
>>>>>> So I think you should have no trouble to do this job :)
>>>>>>
>>>>>> Willem
>>>>>>
>>>>>>
>>>>>> Charles Moulliard wrote:
>>>>>>> hi,
>>>>>>>
>>>>>>> Can we retrieve an endpoint using the id defined in a Spring XML
>> file?
>>>>>>> <camel:endpoint id="QuickFixStreamEndpoint"
>> uri="#{uriQuickFixStream}"
>>>> />
>>>>>>> idea : exchange.getcontext().getEndpointId()
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Charles Moulliard
>>>>>>> Senior Enterprise Architect
>>>>>>> Apache Camel Committer
>>>>>>>
>>>>>>> *****************************
>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>
>>>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
> 


Re: Can we retrieve an endpoint using the id ?

Posted by Charles Moulliard <cm...@gmail.com>.
Is it not a bit overkill to pass CamelContext, Registry object to every
method of a POJO to have access to route, endpoints, ... information ?
Why can't we call (like in JNDI) a utility class to have access to the
CamelContext, Registry published ?

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jun 26, 2009 at 5:53 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Try to let your POJO implements CamelContextAware
>
> We could like how Camel binds to Exchange, TypeConverter do the same
> for Registry so you just define one parameter as Registry
> public String doSomething(String body, Registry registry)
>
> And the same for CamelContext
> public String doSomething(String body, CamelContext context)
>
>
>
> On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cm...@gmail.com>
> wrote:
> > Thx.
> >
> > Can a java POJO/Bean obtain the camel context without using the exchange
> > (exchange.getContext()) object ?
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> context.getRegistry().lookup("myBeanId", Endpoint.class);
> >>
> >> Will lookup in the spring application context, and AFAIR the
> >> <endpoint> tag will register it as a spring bean also.
> >>
> >>
> >> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cmoulliard@gmail.com
> >
> >> wrote:
> >> > How can I get the SpringCamelBuilder in a POJO.
> >> >
> >> > Regards,
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >> >
> >> > On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <willem.jiang@gmail.com
> >> >wrote:
> >> >
> >> >> Hi Charles,
> >> >>
> >> >> SpringCamelBuilder has a method to look up the bean's instance from
> the
> >> >> application context.
> >> >>
> >> >> Object bean(String beanName) in camel 1.x branch
> >> >>
> >> >> <T> T lookup(String String beanName, Class<T> type) in camel trunk
> >> >>
> >> >> So I think you should have no trouble to do this job :)
> >> >>
> >> >> Willem
> >> >>
> >> >>
> >> >> Charles Moulliard wrote:
> >> >> > hi,
> >> >> >
> >> >> > Can we retrieve an endpoint using the id defined in a Spring XML
> file?
> >> >> >
> >> >> > <camel:endpoint id="QuickFixStreamEndpoint"
> uri="#{uriQuickFixStream}"
> >> />
> >> >> >
> >> >> > idea : exchange.getcontext().getEndpointId()
> >> >> >
> >> >> > Regards,
> >> >> >
> >> >> > Charles Moulliard
> >> >> > Senior Enterprise Architect
> >> >> > Apache Camel Committer
> >> >> >
> >> >> > *****************************
> >> >> > blog : http://cmoulliard.blogspot.com
> >> >> >
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: Can we retrieve an endpoint using the id ?

Posted by Claus Ibsen <cl...@gmail.com>.
Try to let your POJO implements CamelContextAware

We could like how Camel binds to Exchange, TypeConverter do the same
for Registry so you just define one parameter as Registry
public String doSomething(String body, Registry registry)

And the same for CamelContext
public String doSomething(String body, CamelContext context)



On Fri, Jun 26, 2009 at 5:33 PM, Charles Moulliard<cm...@gmail.com> wrote:
> Thx.
>
> Can a java POJO/Bean obtain the camel context without using the exchange
> (exchange.getContext()) object ?
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> context.getRegistry().lookup("myBeanId", Endpoint.class);
>>
>> Will lookup in the spring application context, and AFAIR the
>> <endpoint> tag will register it as a spring bean also.
>>
>>
>> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cm...@gmail.com>
>> wrote:
>> > How can I get the SpringCamelBuilder in a POJO.
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <willem.jiang@gmail.com
>> >wrote:
>> >
>> >> Hi Charles,
>> >>
>> >> SpringCamelBuilder has a method to look up the bean's instance from the
>> >> application context.
>> >>
>> >> Object bean(String beanName) in camel 1.x branch
>> >>
>> >> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>> >>
>> >> So I think you should have no trouble to do this job :)
>> >>
>> >> Willem
>> >>
>> >>
>> >> Charles Moulliard wrote:
>> >> > hi,
>> >> >
>> >> > Can we retrieve an endpoint using the id defined in a Spring XML file?
>> >> >
>> >> > <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}"
>> />
>> >> >
>> >> > idea : exchange.getcontext().getEndpointId()
>> >> >
>> >> > Regards,
>> >> >
>> >> > Charles Moulliard
>> >> > Senior Enterprise Architect
>> >> > Apache Camel Committer
>> >> >
>> >> > *****************************
>> >> > blog : http://cmoulliard.blogspot.com
>> >> >
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Can we retrieve an endpoint using the id ?

Posted by Charles Moulliard <cm...@gmail.com>.
Thx.

Can a java POJO/Bean obtain the camel context without using the exchange
(exchange.getContext()) object ?

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jun 26, 2009 at 5:26 PM, Claus Ibsen <cl...@gmail.com> wrote:

> context.getRegistry().lookup("myBeanId", Endpoint.class);
>
> Will lookup in the spring application context, and AFAIR the
> <endpoint> tag will register it as a spring bean also.
>
>
> On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cm...@gmail.com>
> wrote:
> > How can I get the SpringCamelBuilder in a POJO.
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <willem.jiang@gmail.com
> >wrote:
> >
> >> Hi Charles,
> >>
> >> SpringCamelBuilder has a method to look up the bean's instance from the
> >> application context.
> >>
> >> Object bean(String beanName) in camel 1.x branch
> >>
> >> <T> T lookup(String String beanName, Class<T> type) in camel trunk
> >>
> >> So I think you should have no trouble to do this job :)
> >>
> >> Willem
> >>
> >>
> >> Charles Moulliard wrote:
> >> > hi,
> >> >
> >> > Can we retrieve an endpoint using the id defined in a Spring XML file?
> >> >
> >> > <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}"
> />
> >> >
> >> > idea : exchange.getcontext().getEndpointId()
> >> >
> >> > Regards,
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >>
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: Can we retrieve an endpoint using the id ?

Posted by Claus Ibsen <cl...@gmail.com>.
context.getRegistry().lookup("myBeanId", Endpoint.class);

Will lookup in the spring application context, and AFAIR the
<endpoint> tag will register it as a spring bean also.


On Fri, Jun 26, 2009 at 5:23 PM, Charles Moulliard<cm...@gmail.com> wrote:
> How can I get the SpringCamelBuilder in a POJO.
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <wi...@gmail.com>wrote:
>
>> Hi Charles,
>>
>> SpringCamelBuilder has a method to look up the bean's instance from the
>> application context.
>>
>> Object bean(String beanName) in camel 1.x branch
>>
>> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>>
>> So I think you should have no trouble to do this job :)
>>
>> Willem
>>
>>
>> Charles Moulliard wrote:
>> > hi,
>> >
>> > Can we retrieve an endpoint using the id defined in a Spring XML file?
>> >
>> > <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}" />
>> >
>> > idea : exchange.getcontext().getEndpointId()
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>>
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Can we retrieve an endpoint using the id ?

Posted by Charles Moulliard <cm...@gmail.com>.
How can I get the SpringCamelBuilder in a POJO.

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Fri, Jun 26, 2009 at 3:50 PM, Willem Jiang <wi...@gmail.com>wrote:

> Hi Charles,
>
> SpringCamelBuilder has a method to look up the bean's instance from the
> application context.
>
> Object bean(String beanName) in camel 1.x branch
>
> <T> T lookup(String String beanName, Class<T> type) in camel trunk
>
> So I think you should have no trouble to do this job :)
>
> Willem
>
>
> Charles Moulliard wrote:
> > hi,
> >
> > Can we retrieve an endpoint using the id defined in a Spring XML file?
> >
> > <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}" />
> >
> > idea : exchange.getcontext().getEndpointId()
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
>
>

Re: Can we retrieve an endpoint using the id ?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

SpringCamelBuilder has a method to look up the bean's instance from the
application context.

Object bean(String beanName) in camel 1.x branch

<T> T lookup(String String beanName, Class<T> type) in camel trunk

So I think you should have no trouble to do this job :)

Willem


Charles Moulliard wrote:
> hi,
> 
> Can we retrieve an endpoint using the id defined in a Spring XML file?
> 
> <camel:endpoint id="QuickFixStreamEndpoint" uri="#{uriQuickFixStream}" />
> 
> idea : exchange.getcontext().getEndpointId()
> 
> Regards,
> 
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
> 
> *****************************
> blog : http://cmoulliard.blogspot.com
>