Switchyard Property delegation to remote service
mkoenig May 18, 2013 7:11 AMHello,
I have a main module(jar) with all service classes and a switchyard.xml which defines these main services.
Then I will have multiple other jars which will define own services by referencing the main services provided by the main module.
Now I want to delegate properties to these main service but it won't work. I tried different positions of the properties but none of them worked.
As example I created the following modules:
The main module: test-switchyard.jar which creates the following service
@Service(Properties.class)
public class PropertiesService implements Properties {
/** The target component. */
@Property(name = "target")
private String target;
/** The encoding. */
@Property(name = "encoding")
private String encoding;
/** The context. */
@Inject
private Context context;
/*
* (non-Javadoc)
*
* @see com.web4db.esb.services.Properties#readProperties(java.lang.String)
*/
@Override
public String readProperties(final String message) throws HandlerException {
return "Property encoding: " + encoding + " target: " + target + " context-encoding: " + context.getPropertyValue("encoding")
+ "context-target: " + context.getPropertyValue("target");
}
}
the switchyard.xml:
<sca:component name="Properties">
<bean:implementation.bean class="com.web4db.esb.services.PropertiesService" />
<sca:service name="Properties">
<sca:interface.java interface="com.web4db.esb.services.Properties" />
</sca:service>
</sca:component>
Then the sub-module CallTestProperties.jar
switchyard.xml:
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:swyd="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config: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">
<sca:composite name="testimport-esb" targetNamespace="urn:web4db-esb:core:0.1.0">
<sca:service name="TestImportService" promote="Route/TestImportService">
<ftp:binding.ftp>
<ftp:directory>/</ftp:directory>
<ftp:host>localhost</ftp:host>
<ftp:port>21</ftp:port>
<ftp:username>test</ftp:username>
<ftp:password>test</ftp:password>
<ftp:consume>
<ftp:delete>true</ftp:delete>
<ftp:include>.*</ftp:include>
<ftp:initialDelay>10</ftp:initialDelay>
</ftp:consume>
</ftp:binding.ftp>
</sca:service>
<sca:component name="Route">
<camel:implementation.camel>
<camel:xml path="/CallTestPropertiesRoute.xml"/>
</camel:implementation.camel>
<sca:service name="TestImportService">
<interface.esb inputType="java:java.lang.String"/>
</sca:service>
<sca:reference name="Properties">
<sca:interface.java interface="com.web4db.esb.services.Properties"/>
<sca:property name="target" value="TXT" />
<sca:property name="encoding" value="UTF-8" />
</sca:reference>
</sca:component>
</sca:composite>
</switchyard>
CallTestPropertiesRoute.xml
<route xmlns="http://camel.apache.org/schema/spring">
<from uri="switchyard://TestImportService" />
<to uri="switchyard://Properties" />
<log message="TestImport: ${body}" />
</route>
When I test it I get the following result:
12:31:32,036 INFO [route17] (Camel (camel-32) thread #66 - ftp://test:******@localhost:21//) TestImport: Property encoding: null target: null context-encoding: null
context-target: null
But I am expecting to get this:
TestImport: Property encoding: UTF-8 target: TXT context-encoding: null context-target: null
What I am doing wrong?
Thx
Marcel
-
modules.zip 7.3 KB