我可以对同一个 Home 类和 Remote 类有多个 EJB 声明吗?

发布于 2024-08-03 23:57:09 字数 1501 浏览 3 评论 0原文

是否可以在 ejb-jar.xml在 EJB 1.1 中)部署描述符中声明多个具有不同名称但背后具有相同类的 bean?

例如:

<session>
    <ejb-name>AccountFacade</ejb-name>
    <home>com.something.ejb.AccountFacadeHome</home>
    <remote>com.something.ejb.AccountFacadeRemote</remote>
    <ejb-class>com.something.ejb.AccountFacadeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
</session>

<session>
    <ejb-name>RestrictiveAccountFacade</ejb-name>
    <home>com.something.ejb.AccountFacadeHome</home>
    <remote>com.something.ejb.AccountFacadeRemote</remote>
    <ejb-class>com.something.ejb.AccountFacadeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
</session>

对于 RestrictiveAccountFacade 我想在 orion-ejb-jar.xml 文件中设置更高的隔离级别,例如:

<entity-deployment name="AccountFacade" location="AccountFacade">
    <resource-ref-mapping location="..." name="jdbc/..."/>
</entity-deployment>

<entity-deployment name="RestrictiveAccountFacade" location="RestrictiveAccountFacade" isolation="serializable">
    <resource-ref-mapping location="..." name="jdbc/..."/>
</entity-deployment>

这样做是否存在风险,有任何副作用或未指定的行为吗?

Can one declare multiple beans in the ejb-jar.xml (in EJB 1.1) deployment descriptor with different names but the same classes behind?

For example:

<session>
    <ejb-name>AccountFacade</ejb-name>
    <home>com.something.ejb.AccountFacadeHome</home>
    <remote>com.something.ejb.AccountFacadeRemote</remote>
    <ejb-class>com.something.ejb.AccountFacadeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
</session>

<session>
    <ejb-name>RestrictiveAccountFacade</ejb-name>
    <home>com.something.ejb.AccountFacadeHome</home>
    <remote>com.something.ejb.AccountFacadeRemote</remote>
    <ejb-class>com.something.ejb.AccountFacadeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
</session>

For RestrictiveAccountFacade I want to set a higher isolation level in the orion-ejb-jar.xml file, something like:

<entity-deployment name="AccountFacade" location="AccountFacade">
    <resource-ref-mapping location="..." name="jdbc/..."/>
</entity-deployment>

<entity-deployment name="RestrictiveAccountFacade" location="RestrictiveAccountFacade" isolation="serializable">
    <resource-ref-mapping location="..." name="jdbc/..."/>
</entity-deployment>

Is there a risk involved in doing this, any side effects or unspecified behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如日中天 2024-08-10 23:57:09

正如您上面提到的那样,这是完全可以的。应该注意的是,对于每个容器而言,AccountFacadeRestrictiveAccountFacade 将是两个完全不相关的会话 bean。

但是,RestrictiveAccountFacade 具有对与 AccountFacade 相同的 jdbc 资源的事务可序列化访问,因此它们仅在事务隔离级别才会相互干扰。

因此,如果 AccountFacade 需要访问与参与 RestrictiveAccountFacade 事务的相同记录,则可能会被阻止。

同样,RestrictiveAccountFacade 事务将在与 AccountFacade 在其事务中使用的同一记录上被阻止。

This is totally OK to have it as you mentioned above. One should note that as per container is concerned AccountFacade and RestrictiveAccountFacade will be two totally unrelated session beans.

However RestrictiveAccountFacade has transaction serializable access to same jdbc resource as AccountFacade so they will interfere with each other only at transaction isolation level.

Hence AccountFacade may be blocked if it needs access to same record as that is participated in transaction of RestrictiveAccountFacade.

Similarly RestrictiveAccountFacade transaction will be blocked on same record as that is being used by AccountFacade in it's transaction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文