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.
<spring:spring bean="exampleBean" key="string"/>
The key will reference the Spring ApplicationContext/Configuration (i.e. spring configuration XML) used for the bean. This key can be a registry key or local entry key. The bean attribute is used for looking up a Spring bean from the spring Application Context. Therefore, a bean with same name must be in the given spring configuration. In additions, that bean must implement the Mediator interface.
Figure1: Spring Mediator
<spring:spring bean="springtest" key="conf/sample/resources/spring/springsample.xml"/>
In the above configuration, 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 can be used as the registry resource - springsample.xml.
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="springtest" class="org.apache.synapse.mediators.spring.SpringTestBean" singleton="false"> <property name="testProperty" value="100"/> </bean> </beans>