The Class Mediator creates an instance of a custom-specified class and sets it as a mediator. The class must implement the
org.apache.synapse.api.Mediator interface. If any properties are specified, the corresponding setter methods are invoked once on the class during initialization.
The Class mediator is a custom Java class, which you need to maintain by yourself. Therefore, it is recommended to use the Class mediator only for not frequently re-used custom developments and very user-specific scenarios, for which, there is no built-in mediator that already provides the required functionality.
Your class mediator might not be picked up and updated if you use an existing package when creating it.
For best results, use WSO2 Developer Studio for debugging Class mediators.
Class Name: The name of the class. To load a class, enter the qualified name of the relevant class in this parameter and click Load Class.
In this configuration, the ESB profile sends the requested message to the endpoint specified via the Send mediator. This endpoint is the Axis2server running on port 9000. The response message is passed through a Class mediator before it is sent back to the client. Two parameters named
variable2 are passed to the instance mediator implementation class (
If you want, you can pass the same variables as a value or an expression:
- Example for passing the variable as a value:
<property name="variable1" value="10"/>
- Example for passing the variable as an expression:
<property name="variable2" expression="get-property('variable1')"/>
For more information on using the get property method, see the Property Mediator.
See the following sample Class Mediator and note the
SynapseMessageContext and the full Synapse API in there.
For more examples, see: