Adding additional Camel components
At times you would like to leverage the vast component libraries offered by Camel. Say you would like to use the routes of ftp://, sftp:// etc., SwitchYard by default offers core and spring libraries. Any new component needs to be added manually as of now. Automating this is a bit difficult as the un-needed transitive dependencies would get added. Also AS7 would already be providing some of these dependecies. Let us see how to add the camel-ftp module to SwitchYard.
Camel ftp
First we need to find the dependecies for this component. The pom of this component helps, but not all of them are needed. All of these dependecies can be further modularized into their own modules (like jsch, commons-net). But for the sake of simplicity they are bundled here along with the org.apache.camel.ftp module. This gives us an isolated dependecy set that is only used by SwitchYard camel component. Here is how the module.xml file looks:
<module xmlns="urn:jboss:module:1.0" name="org.apache.camel.ftp"> <resources> <resource-root path="camel-ftp-2.6.0.jar"/> <resource-root path="jsch-0.1.41.jar"/> <resource-root path="commons-net-2.0.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="org.apache.commons.logging"/> <module name="org.apache.camel.core"/> </dependencies> </module>
Obtain these jars and place them along with this configuration above into AS7 directory:
${AS7_HOME}/modules/org/apache/camel/ftp/main
Integration
Now we need to include this additional Camel component as a dependecy to SwitchYard's camel component's module configuration. This is done as follows:
<module xmlns="urn:jboss:module:1.0" name="org.switchyard.component.camel"> ... <dependencies> .... <module name="org.apache.camel.core" export="true"/> <module name="org.apache.camel.spring" export="true"/> <module name="org.apache.camel.ftp" export="true"> <imports> <include path="META-INF/services/org/apache/camel/component"/> </imports> <exports> <include path="META-INF/services/org/apache/camel/component"/> </exports> </module> ... </dependencies></module>
Notice the usage of imports and exports path. We explicitly want the component resources to be imported, such as ftp, ftps and sftp.
Comments