ITeye博客

通过注解方式@EJB注入和JNDI查找方式并使用其他EJB或者服务

javaEEdevelop · 2013-03-21 08:31 · 开源软件 · Markdown

1.通过JNDI查找方式来查找其他的bean
InitialContext ctx = new InitialContext();
HelloWorld helloworld = (HelloWorld) ctx
.lookup("实现类的简单名称/remote");

 2.通过注解@EJB
 例如
 @EJB Other other;//现在就可以使用Other里面的公共方法了,条件是Other必须是一个EJB对像
 @Resource TimeService TimeService;//注入其他的对象,比如EJB3中TimeService类,@Resource类路径是javax.anontation.Resource;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。