Hi Yeah this nifty feature should at least be configurable so Camel just doesn't start whatever it finds as RouteBuilder in the classpath.
We have a ticket in JIRA for improving this configuration in spring xml, Jonathan created it. On Thu, Dec 11, 2008 at 6:17 PM, Adrian Trenaman <[EMAIL PROTECTED]> wrote: > Heya, > > Actually, I prefer to create my routes explicitly in the spring file and > then use routeBuilderRef. This allows me to inject configuration values into > the route before the configure() method is called. If you use the more > dynamic package approach then the routes are created using a default > constructor so you can't configure em'! Unless some can think of a neat way > to do it that I've missed? > > /Ade > > On 11 Dec 2008, at 17:44, Carlus Henry wrote: > >> Hey... >> >> I had a similar requirement, and I discovered that you don't even have to >> specify the routeBuilder as a reference point. In other words, by the >> mere >> fact that you defined an object that is a RouteBuilder in your spring >> file, >> it will automagically be added as a valid route within the Camel Context. >> >> I thought that this was a pretty nifty feature. >> >> Later. >> >> On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang >> <[EMAIL PROTECTED]>wrote: >> >>> Hi Doug >>> >>> Thanks for pointing out the issue. >>> I just update the wiki page[1] for it . >>> >>> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring >>> >>> Willem >>> >>> >>> dougly wrote: >>>> >>>> Hi William, >>>> Thanks for creating the JIRA. >>>> But I just looked at the xsd schema for camel context and discovered >>>> that >>>> camelContext can take a reference to the route builder bean! I did >>>> follow >>>> that and it works fine. Here's how: >>>> >>>> <camelContext id='' xmlns=".."> >>>> <routeBuilderRef ref="myBuilder" /> >>>> </camelContext> >>>> >>>> <bean id="myBuilder" class="..."></bean> >>>> >>>> I will update the JIRA with this info. >>>> >>>> Thanks and regards, >>>> >>>> Doug >>>> >>>> >>>> willem.jiang wrote: >>>>> >>>>> 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 >>>>> >>>>> >>>> >>> >>> Carlus Henry > > --- > Adrian Trenaman, Consultant Fellow, PS - Opensource Center of Competence > Progress Software Corp > Shelbourne Road, Dublin 4, Ireland > --- > +353-1-637-2659 (Office) > +353-1-637-2882 (Fax) > +353-86-6051026 (Mobile) > adrian.trenaman (Skype) > ---- > Blog: http://trenaman.blogspot.com > > > > > > > > > -- /Claus Ibsen Apache Camel Committer Blog: http://davsclaus.blogspot.com/
