微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

依赖注入 – 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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐