This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

The Spring Mediator exposes a spring bean as a mediator. The Spring Mediator creates an instance of a mediator, which is managed by Spring. This Spring bean must implement the Mediator interface for it to act as a Mediator.

Note the following:

  • Spring support in WSO2 ESB is based on Spring version 2.5.
  • The Spring mediator is a content aware mediator.


<spring:spring bean="exampleBean" key="string"/>

The attributes of the <spring> element:

  • key - References the Spring ApplicationContext/Configuration (i.e. spring configuration XML) used for the bean. This key can be a registry key or local entry key.
  • bean - Is used for looking up a Spring bean from the spring Application Context. Therefore, a bean with the same name must be in the given spring configuration. In addition, bean must implement the Mediator interface.

UI Configuration

These are the options for the Spring Mediator:

  • Bean - Is used for looking up a Spring bean from the spring Application Context.
  • Key - The registry reference to the spring Application-Context/Configuration used for the bean. You can select it by clicking the "Configuration Registry" or "Governance Registry" links.


You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.


<spring:spring bean="springtest" key="conf/sample/resources/spring/springsample.xml"/>

In the above configuration, the spring XML is in the registry and it can be looked up using the registry key conf/sample/resources/spring/springsample.xml. This spring XML (i.e springsample.xml) must contain a bean with the name springtest. The following figure shows an example that can be used as the registry resource - springsample.xml.

      <bean id="springtest" class="org.apache.synapse.mediators.spring.SpringTestBean" singleton="false">
         <property name="testProperty" value="100"/>

Also, you need to build the JAR file of the following Spring Bean class and place it in the <ESB_HOME>/repository/components/lib/ directory.

package org.apache.synapse.mediators.spring;

import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;

public class SpringTestBean extends AbstractMediator{
   private String testProperty;

   public void setTestProperty(String testProperty){
      this.testProperty = testProperty;

   public boolean mediate(MessageContext mc) {
            // Do somthing useful..
            // Note the access to the Synapse Message context
            return true;

For more examples, see Mediating with Spring.

  • No labels