I got to work this as below,
The class should extends AbstractMediator and override the mediate() method as follows,
package com.test.spring.mediator.workingexampleonspringmediator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class HelloWorld extends AbstractMediator{
private String message;
public void setMessage(String message){
this.message = message;
}
public boolean mediate(MessageContext arg0) {
System.out.println("HELLO "+message);
return true;
}
}
Then place the jar in [ESBHOME]/repository/components/lib folder
In mediate method it prints a message with the argument like HELLO 'arg'
And I added the following file to registry (/_system/config/repository/spring/springtest.xml)
,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="springtest" class="com.test.spring.mediator.workingexampleonspringmediator.HelloWorld" singleton="false">
<property name="message"><value>ISURU</value></property>
</bean>
</beans>
My proxy is as follows,
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testSpring" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="START" value="__________________________"/>
</log>
<spring:spring xmlns:spring="http://ws.apache.org/ns/synapse" bean="springtest" key="conf:/repository/spring/springtest.xml"/>
<log level="full">
<property name="END" value="______________________"/>
</log>
</inSequence>
</target>
<description></description>
</proxy>
In the proxy you can see the bean=[bean id of the springtest.xml]
and class=qualified name of the class
In my ESB terminal, I got the following out put with the given property value in springtest.xml,
[2013-11-07 17:38:30,654] INFO - LogMediator To: /services/testSpring.testSpringHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:bcae82e9-4027-43c5-bd7a-cbfa885aaf33, Direction: request, START = __________________________, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope>
HELLO ISURU
[2013-11-07 17:38:30,692] INFO - LogMediator To: /services/testSpring.testSpringHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:bcae82e9-4027-43c5-bd7a-cbfa885aaf33, Direction: request, END = ______________________, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope>
You must restart the ESB after placing the jar in repository/components/lib