如何在Spring中配置EJB

下面我来共同学习如何在Spring中进行配置来调用远程的EJB程序
首先,我们先写一个EJB程序,如下:
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
@Stateless(name = "helloBean")
@Remote( { TSorderService.class })
@Interceptors(ServiceLogger.class)
public class TSorderServiceBean {
 public void sayHello(String name){
  System.out.println("你好:"+name);
 }
}
将EJB程序打包为spring-ejb.ear文件放到JBOSS服务下
其次,新建一个ejb.properties文件,放置EJB配置信息
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url.mss=localhost\:1099
再次我们在Spring中配置对EJB的调用,在这里我们需要通过Spring读取ejb.properties文件的配置信息。
关于ejb.properties文件的读取,我之前写了一篇博客,详细阐述了这个问题。http://chengzhi-hong.iteye.com/blog/855531
<jee:remote-slsb id="sayHello"
 jndi-name="spring-ejb/helloBean/remote"
 business-interface="com.umpay.mss.service.TSorderService"
 cache-home="true" lookup-home-on-startup="false" resource-ref="true"
 refresh-home-on-connect-failure="true">
 <jee:environment>
  java.naming.factory.initial=${java.naming.factory.initial}
  java.naming.factory.url.pkgs=${java.naming.factory.url.pkgs}
  java.naming.provider.url=${java.naming.provider.url.mss}
 </jee:environment>
</jee:remote-slsb>
至此,我们就可以调用远端的EJB程序了。您可以自己在写一个程序试一试。余下的工作就交给您了,相信您不会让我失望的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值