How do I share a single object between different service units?
You need to register your singleton bean inside ServiceMix' internal JNDI registry. This is done by modifying the conf/jndi.xml configuration file:
<util:map id="jndiEntries">
...
<entry key="mySingletonJndiName">
<bean .... Put your singleton bean here ... />
</entry>
</util:map>
Then, in your xbean.xml files for your SUs, you can use:
<jee:jndi-lookup id="mySingletonId" jndi-name="mySingletonJndiName" />
Don't forget to specify the jee namespace in the xbean.xml:
<?xml version="1.0"?>
<beans <your other definitions>
xmlns:jee="http://www.springframework.org/schema/jee">
...
</beans>
![](http://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif) | Important note
To use the JNDI lookup capability you need to add an additional dependency to your SU's pom.xml file.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-remoting</artifactId>
<version>2.0.8</version>
</dependency>
This will add the spring-remoting.jar as a dependency. This is needed because the jee namespace is defined in there.
|