3 Replies Latest reply on Mar 8, 2011 4:03 AM by davsclaus

    Mixing DSL with Spring in Camel

    guest

      Looking specifically at the camel-osgi example, there's a mix of DSL and Spring based Camel routing.  Is there some sort of example where if I set up some beans within the Spring file, I can pass that to the DSL java so it can have a hook for a bean?

       

      i.e.

       

         

          <property name="prefix" value="$"/>

        </bean

       

       

      in my DSL..

       

      configure() {

        MyTransform t = //get the above bean

      }

       

      Thanks!

        • 1. Re: Mixing DSL with Spring in Camel
          davsclaus

          You can use any kind of IoC to inject beans from the XML file in your Java code. For example Spring have a number of annotations. Or you can use the @Resource annotation from JDK1.6.

           

          Something like this in the Java DSL class

          @Resource(name = "myTransform")
          private MyTransform myTransform
          

           

          You may need a getter/setter pair for it so the @Resource works. Can't remember if it can IoC without the setter.

          • 2. Re: Mixing DSL with Spring in Camel
            guest

            Doesnt look like that works.  I get null for myTransform, even with getter/setter.  It looks like the way the beans.xml in camel-osgi is configured, the DSL will get started first and the dependency injection never gets established for that attribute.  Am I missing something?  Thanks!

            • 3. Re: Mixing DSL with Spring in Camel
              davsclaus

              What version of Fuse ESB / or Camel are you using?

               

              And are you running the application in Fuse ESB or what other server?