Tuesday 19 February 2008

Accessing EJB 3 from Spring 2.5

Spring 2.5 now supports EJB 3 access, and it could not be any easier! Here is the spring xml snippet to achieve it:

<beans>
...
<!-- *** EJBs *** -->
<!-- REMOTE JNDI CONNECTION -->
<bean id="remoteJndiTemplate"
class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">
org.jnp.interfaces.NamingContextFactory
</prop>
<prop key="java.naming.provider.url">
localhost
</prop>
<prop key="java.naming.security.principal">
username
</prop>
<prop key="java.naming.security.credentials">
mycredentials
</prop>
</props>
</property>
</bean>

<bean id="abstractRemoteSlsb" abstract="true"
class="org.springframework.ejb.access.
SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="lookupHomeOnStartup" value="false">
<property name="jndiTemplate">
<ref bean="remoteJndiTemplate" />
</property>
</bean>

<bean id="myService" parent="abstractRemoteSlsb">
<property name="jndiName"
value="myapp/MySessionBeanImpl/remote">
<property name="businessInterface"
value="au.com.package.name.MySessionBean">
</bean>
...
</beans>
blog comments powered by Disqus
Share |