Reading from a Properties file Switchyard
jcoders Apr 24, 2013 9:03 AMGood Morning,
I am a newbie when it comes to using switchyard and has been dabbling in it.I have a small application that i created using the switchyard tooling on top of Jboss developer Studio.It basically polls a ftp server, picks up the file, uses camel routing and writes it to a folder on the local disk.The following are the two questions i have
1) I currently have the ftp server, username etc hard coded in the xml file, how to i go about reading the values from a .properties file on the local disk ?I tried finding some samples but was not successful.The following is my switchyard.xml
<?xml version="1.0" encoding="UTF-8"?> <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0" xmlns:file="urn:switchyard-component-camel-file:config:1.0" xmlns:ftp="urn:switchyard-component-camel-ftp:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="switchyard-myFtp" targetNamespace="urn:com.example.switchyard:switchyard-myFtp:1.0"> <sca:composite name="switchyard-myFtp" targetNamespace="urn:com.example.switchyard:switchyard-myFtp:1.0"> <sca:component name="CamelServiceRoute"> <camel:implementation.camel> <camel:java class="com.example.switchyard.switchyard_myFtp.CamelServiceRoute"/> </camel:implementation.camel> <sca:service name="CamelService"> <sca:interface.java interface="com.example.switchyard.switchyard_myFtp.CamelService"/> </sca:service> <sca:reference name="FileWriter"> <sca:interface.java interface="com.example.switchyard.switchyard_myFtp.FileWriter"/> </sca:reference> </sca:component> <sca:service name="CamelService" promote="CamelServiceRoute/CamelService"> <sca:interface.java interface="com.example.switchyard.switchyard_myFtp.CamelService"/> <ftp:binding.ftp> <operationSelector operationName="acceptMessage"/> <ftp:contextMapper/> <ftp:directory>in</ftp:directory> <ftp:host>FTPHost</ftp:host> <ftp:username>{{userName}}</ftp:username> <ftp:password>pwd</ftp:password> <ftp:consume> <ftp:delete>true</ftp:delete> <ftp:recursive>true</ftp:recursive> </ftp:consume> </ftp:binding.ftp> </sca:service> <sca:reference name="FileWriter" multiplicity="0..1" promote="CamelServiceRoute/FileWriter"> <sca:interface.java interface="com.example.switchyard.switchyard_myFtp.FileWriter"/> <file:binding.file> <file:contextMapper/> <file:directory>D:/Temp/out</file:directory> <file:produce/> </file:binding.file> </sca:reference> <sca:property name="props" value="D:/Temp/route-parameters.properties"/> </sca:composite> </switchyard>
I tried the above approach but it errors out and does not work, not sure how to go about this.
2) While using Fuse/servicemix ESB i was able to use processors in routes to transform messages to the format we wanted, the traditional transformation class implemented a "Processor" interface n so forth, not sure how i go about this with switchyard.Do i create a simple bean that does the transformation/translation and expose it as a service and route the message through it ? or is there a better way ?
Thanks in advance