我可以对同一个 Home 类和 Remote 类有多个 EJB 声明吗?
是否可以在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您上面提到的那样,这是完全可以的。应该注意的是,对于每个容器而言,
AccountFacade
和RestrictiveAccountFacade
将是两个完全不相关的会话 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
andRestrictiveAccountFacade
will be two totally unrelated session beans.However
RestrictiveAccountFacade
has transaction serializable access to same jdbc resource asAccountFacade
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 ofRestrictiveAccountFacade
.Similarly
RestrictiveAccountFacade
transaction will be blocked on same record as that is being used byAccountFacade
in it's transaction.