是否可以使用@EJB注释通过不同的服务器注入EJB? [英] Is it possible to use @EJB annotation to inject EJBs through different servers?

查看:80
本文介绍了是否可以使用@EJB注释通过不同的服务器注入EJB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个会话bean,OrderBean和InventoryBean,它们部署在不同的weblogic服务器上。

I have 2 session beans, OrderBean and InventoryBean which are deployed at different weblogic servers.

OrderBean需要访问InventoryBean以检查供应是否足够。

The OrderBean needs to access the InventoryBean to check if the supply is sufficient.

目前,我使用JNDI查找找到InventoryBean,它工作正常。

Currently, I use JNDI look up to locate the InventoryBean and it works fine.

现在我想知道是否可以通过在xml或其他地方提供JNDI名称和URL来使用@EJB来注入InventoryBean。

Now I'm wondering if it is possible to use @EJB to inject InventoryBean by providing the JNDI name and the URL in xml or somewhere else.

推荐答案

最后我找到了一种方法。

Finally I found a way to do this.

i 。在weblogic服务器上配置外部JNDI,并将远程EJB链接到本地​​JNDI名称。

i. Configure the foreign JNDI on the weblogic server and link the remote EJB to a local JNDI name.

例如:


Local JNDI:
InventoryBean#com.pkg.InventoryBean (MAPPEDNAME#FULLNAME)
link to
Remote JNDI:
ServiceBean#com.pkg.InventoryBean 

ii。在ejb-jar.xml中配置ejb-ref

ii. Configure ejb-ref in ejb-jar.xml


ejb-ref-name -> ejb/InventoryBean
remote -> com.pkg.InventoryService
mapped-name -> InventoryBean

iii。在OrderBean中添加@EJB注释

iii. Add the @EJB annotation in OrderBean


@EJB(name = "ejb/InventoryBean")
private InventoryService inventoryService;

这篇关于是否可以使用@EJB注释通过不同的服务器注入EJB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆