依赖注入 – CDI可以注入我的Bean的远程实例吗?

前端之家收集整理的这篇文章主要介绍了依赖注入 – CDI可以注入我的Bean的远程实例吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
CDI可以在我的远程EJB客户端中注入EJB引用吗?

实际上我有一个JUnit测试用例,它在我的系统上本地运行并访问在独立JBoss AS上运行的EJB.我目前正在使用JNDI访问bean的远程业务接口并对其进行测试.

我想知道,如果@Inject可以帮助我在这里直接将我的EJB实例注入我的测试用例,这样我就可以避免JNDI查找并仍然访问EJB?

解决方法

不便携.从CDI规范:

The unrestricted set of bean types for
a session bean contains all local
interfaces of the bean and their
superinterfaces. If the session bean
has a bean class local view,the
unrestricted set of bean types
contains the bean class and all
superclasses. In addition,
java.lang.Object is a bean type of
every session bean.

Remote interfaces are not included in the set of bean types.

猜你在找的设计模式相关文章