En Spring Framework 6.0 se ha eliminado el acceso EJB dedicado. En Spring Framework 5.x el acceso a los EJBs se realiza mediante el módulo
LocalStatelessSessionProxyFactoryBean, SimpleRemoteStatelessSessionProxyFactoryBean,
LocalSlsbInvokerInterceptor y SimpleRemoteSlsbInvokerInterceptor que se encuentran en org.springframework.ejb.access paquete.
Estas clases pueden referenciarse en archivos XML de Spring como application-config.xml.
He aquí un ejemplo de este caso de uso:
<frijol id="myEjb" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
También se puede hacer referencia a ellos en los archivos Java de esta forma:
import org.springframework.ejb.access.*;
@Bean
public SimpleRemoteStatelessSessionProxyFactoryBean myEjb() {
SimpleRemoteStatelessSessionProxyFactoryBean factory = new SimpleRemoteStatelessSessionProxyFactoryBean();
}
Esta regla señala el uso del org.springframework.ejb.access paquete en Java .class archivos o .xml .
Para Spring 6.0 utilice JNDI directamente a través de JndiObjectFactoryBean en Java files o jee:jndi-lookup en .xml .
He aquí un ejemplo con JndiObjectFactoryBean:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jndi.JndiObjectFactoryBean;
import com.example.ejb.MyRemoteBean;
@Configuration
public class EjbJndiConfig {
@Bean
public JndiObjectFactoryBean myRemoteEjb() {
JndiObjectFactoryBean jndiBean = new JndiObjectFactoryBean();
jndiBean.setJndiName("java:global/myApp/MyRemoteBean!com.example.ejb.MyRemoteBean");
jndiBean.setProxyInterface(MyRemoteBean.class);
jndiBean.setLookupOnStartup(false); // delay lookup if needed
return jndiBean;
}
}
He aquí un ejemplo con jee-jndi-lookup:
<beans xmlns=" http://www.springframework.org/schema/beans " xmlns:jee=" http://www.springframework.org/schema/jee " xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance ".... <jee:jndi-lookup id="myEjb" jndi-name="java:global/myApp/MyRemoteBean!com.example.ejb.MyBean" proxy-interface="com.example.ejb.MyBean" /> </beans>
Para obtener más información, consulte los recursos siguientes: