camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Configure Route in Spring Context
Date Thu, 11 Dec 2008 00:31:24 GMT
It's an interesting requirement.
Basically camel will search <package> to lookup the builder class and
instantiate it, and you build up a MailRouteBuilder yourself in Spring
configuration by injecting some properties.

I think we could add new feature to let <camelContext> consumer the
builder instance at same time.

Here is the JIRA[1] that I just created according to your request.

[1]https://issues.apache.org/activemq/browse/CAMEL-1179

Willem

dougly wrote:
> Hi riders,
> 
> I have a couple of properties in my RouteBuilder class that needed to be
> initialized using Spring application context file.
> 
> public class MailRouteBuilder extends RouteBuilder
> {
> 
>     private static MailConfigure mailConfig;
>     private static IEmailMessageProcessor messageProcessor; 
> ...
> }
> 
> then in my Spring context file I have this
> 
> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>     <package>com.lyfam.component.mail</package>
>   </camelContext>
>     
>   <bean id="mailRoute" class="com.lyfam.component.mail.MailRouteBuilder">
>   	<property name="mailConfig" ref="mailConfigure" />
>   	<property name="messageProcessor" ref="messageProcessor" />
>   </bean>
> 
> Spring will try to create 2 instances of this MailRouteBuilder: one in the
> camel context initialization and the other for the bean "mailRoute".
> Obviously, this is not what I want.
> Can I reuse/instruct camelContext to use the existing bean after it is
> configured. In this case I need the camel context to use my "mailRoute"
> bean.
> 
> Thank you guys,
> Doug


Mime
View raw message