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:
Code Block |
---|
|
<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:
Code Block |
---|
|
<jee:jndi-lookup id="mySingletonId" jndi-name="mySingletonJndiName" />
|
Don't forget to specify the jee namespace in the xbean.xml:
Code Block |
---|
|
<?xml version="1.0"?>
<beans <your other definitions>
xmlns:jee="http://www.springframework.org/schema/jee">
...
</beans>
|
Note |
---|
|
To use the JNDI lookup capability you need to add an additional dependency to your SU's pom.xml file. Code Block |
---|
|
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-remoting</artifactId>
<version>2.0.8</version> <!-- replace with another version if needed -->
</dependency>
|
This will add the spring-remoting.jar as a dependency. This is needed because the jee namespace is defined in there. |