You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rogelio_sevilla1 <ro...@gmail.com> on 2011/08/02 20:44:51 UTC

Re: Injecting data to routes loaded from xml file

Thanks for the answer mr. Claus,  "myVar1"  is an instance member variable
contained on the class that loads the xml route file.

MyRouteClass extends RouteBuilder{

*private String myVar1;
//getter and setter for myVar1*


public void configure() throws Exception {
                    FileInputStream fis = new
FileInputStream("myroute.xml");
                    RoutesDefinition routes =
 getContext().loadRoutesDefinition(fis);
 }

}

And in my xml file i have this:

<from uri="quartz://fetchUrl?cron=0+0/1+*+*+*+?"/>
            <setProperty propertyName="coolProperty">
                <simple>*myVar1*</simple>
            </setProperty>




I need to have the class written this way because each time i create an
instance, i need to pass different values to it. Is it possible to send the
values on the variable myVar1 to the routes defined on the spring file??


--
View this message in context: http://camel.465427.n5.nabble.com/Injecting-data-to-routes-loaded-from-xml-file-tp4639765p4659913.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Injecting data to routes loaded from xml file

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Aug 2, 2011 at 8:44 PM, rogelio_sevilla1
<ro...@gmail.com> wrote:
> Thanks for the answer mr. Claus,  "myVar1"  is an instance member variable
> contained on the class that loads the xml route file.
>
> MyRouteClass extends RouteBuilder{
>
> *private String myVar1;
> //getter and setter for myVar1*
>
>
> public void configure() throws Exception {
>                    FileInputStream fis = new
> FileInputStream("myroute.xml");
>                    RoutesDefinition routes =
>  getContext().loadRoutesDefinition(fis);
>  }
>
> }
>
> And in my xml file i have this:
>
> <from uri="quartz://fetchUrl?cron=0+0/1+*+*+*+?"/>
>            <setProperty propertyName="coolProperty">
>                <simple>*myVar1*</simple>
>            </setProperty>
>
>
>
>
> I need to have the class written this way because each time i create an
> instance, i need to pass different values to it. Is it possible to send the
> values on the variable myVar1 to the routes defined on the spring file??
>

No not easily, instead you can insert the myVar value directly into
the xml file you are loading.

Or you can adjust it directly on the model classes from the
RoutesDefinition you get loaded, eg using the API from the
org.apache.camel.model classes.



>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Injecting-data-to-routes-loaded-from-xml-file-tp4639765p4659913.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/