You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Calvert, Zach (Zach)** CTR **" <zc...@motive.com> on 2012/02/14 18:46:43 UTC

Wiring a New Component Using Spring

I'm taking on a task of converting bean that we use along a camel route into an actual camel component.  I have everything working and wired up (simple processor component) but have one problem.  We use Spring to create a bean that we use to interface with various external systems and I want to inject that into my camel endpoint.

I have tagged the setter and the private local class instance of the bean with
@Autowired
@Required
(both spring annotations)

Now, it looks to me like the camel component definitions exists outside of Spring, and that's why I'm not getting this dependency injected.  This dependency is still accessible in the old way that I was using it, as a
bean:myBean?someMethod=try
along the camel route.

Is there a way that I can tell camel to inject the "myBean" instance into the endpoint that I've created using the component definition?




Thank you,
Zach Calvert

RE: Wiring a New Component Using Spring

Posted by "Calvert, Zach (Zach)** CTR **" <zc...@motive.com>.
Thank you Willem for the advice.  I'll be looking into the use of this method today.



Zach Calvert

-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: Tuesday, February 14, 2012 7:16 PM
To: users@camel.apache.org
Subject: Re: Wiring a New Component Using Spring

Camel supposes to look up the bean reference from the registry (name as the key and bean instance as the value) which could be provided by the Spring Application context.
If you want to inject a bean instance into the camel endpoint, you can use EndpointHelper#setReferenceProperties() to do this kind of job.

BTW, you should know the instance name to pass the reference to the endponit.
  
On Wed Feb 15 01:46:43 2012, Calvert, Zach (Zach)** CTR ** wrote:
> I'm taking on a task of converting bean that we use along a camel route into an actual camel component.  I have everything working and wired up (simple processor component) but have one problem.  We use Spring to create a bean that we use to interface with various external systems and I want to inject that into my camel endpoint.
>
> I have tagged the setter and the private local class instance of the 
> bean with @Autowired @Required (both spring annotations)
>
> Now, it looks to me like the camel component definitions exists 
> outside of Spring, and that's why I'm not getting this dependency 
> injected.  This dependency is still accessible in the old way that I was using it, as a bean:myBean?someMethod=try along the camel route.
>
> Is there a way that I can tell camel to inject the "myBean" instance into the endpoint that I've created using the component definition?
>
>
>
>
> Thank you,
> Zach Calvert
>



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang 


Re: Wiring a New Component Using Spring

Posted by Willem Jiang <wi...@gmail.com>.
Camel supposes to look up the bean reference from the registry (name as 
the key and bean instance as the value) which could be provided by the 
Spring Application context.
If you want to inject a bean instance into the camel endpoint, you can 
use EndpointHelper#setReferenceProperties() to do this kind of job.

BTW, you should know the instance name to pass the reference to the 
endponit.
  
On Wed Feb 15 01:46:43 2012, Calvert, Zach (Zach)** CTR ** wrote:
> I'm taking on a task of converting bean that we use along a camel route into an actual camel component.  I have everything working and wired up (simple processor component) but have one problem.  We use Spring to create a bean that we use to interface with various external systems and I want to inject that into my camel endpoint.
>
> I have tagged the setter and the private local class instance of the bean with
> @Autowired
> @Required
> (both spring annotations)
>
> Now, it looks to me like the camel component definitions exists outside of Spring, and that's why I'm not getting this dependency injected.  This dependency is still accessible in the old way that I was using it, as a
> bean:myBean?someMethod=try
> along the camel route.
>
> Is there a way that I can tell camel to inject the "myBean" instance into the endpoint that I've created using the component definition?
>
>
>
>
> Thank you,
> Zach Calvert
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang