了解 ejb-link 标记
我阅读了这篇关于 EJB-JNDI 映射最佳实践的精彩文章:
http: //www.ibm.com/developerworks/websphere/library/bestpractices/increase_app_portability.html
ejb-link 的概念我不清楚。
例如,假设我们有一个包含以下内容的 ejb-jar.xml:
<ejb-ref>
<ejb-ref-name>ejb/Bean2Home</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.ibm.wsc.Bean2Home</home>
<remote>com.ibm.wsc.Bean2</remote>
<ejb-link>Bean2</ejb-link>
</ejb-ref>
因此,可以确定目标 EJB 组件是 Bean2,并且这个简单的符号意味着必须在此 J2EE 应用程序包或 .ear 文件中找到 Bean2。
那么,如果 ejb-link 标记足以决定链接到良好 EJB 组件的正确方式,那么汇编器需要为该 ejb-ref 创建 JNDI 名称吗?
真的有用吗?
I read this great article about best-practice for EJB-JNDI mapping :
http://www.ibm.com/developerworks/websphere/library/bestpractices/increase_app_portability.html
The notion of ejb-link isn't clear for me.
For example, let's say we have an ejb-jar.xml containing this :
<ejb-ref>
<ejb-ref-name>ejb/Bean2Home</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.ibm.wsc.Bean2Home</home>
<remote>com.ibm.wsc.Bean2</remote>
<ejb-link>Bean2</ejb-link>
</ejb-ref>
Thus, it is precised that the targeted EJB component is Bean2 and this simple notation means that Bean2 must be find on this J2EE application package or .ear file.
So, if ejb-link markup is enough determinant to indicate the right way to link to the good EJB component, what is the need for assembler to create a JNDI name for this ejb-ref ?
Is it really useful?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是一些场景,希望能够阐明为什么
(或@EJB(beanName="...")
)和 EJB 引用绑定都是如此有用且互补:应用程序本身可以在逻辑上分解为组件,开发人员选择使用 EJB 来实现这些组件。在这种情况下,应用程序开发人员知道客户端想要使用的目标 EJB 组件。如果有多个组件实现相同的接口,则需要进行一些消歧,并且可以使用
。应用程序依赖于外部服务。在这种情况下,应用程序知道它依赖于外部服务,因此无法使用
,因为同一应用程序中不存在该服务实现。应用程序依赖于外部服务,但同一应用程序中提供了最小的实现。在这种情况下,开发人员可能会使用
(如#1 中所示),但部署者可以灵活地覆盖该选择(如#2 中所示)。Here are some scenarios that hopefully clarify why
<ejb-link/>
(or@EJB(beanName="...")
) and EJB ref bindings are both useful and complementary:An application can itself be logically broken up into components, and the developer chooses to use EJBs to implement those components. In this case, the application developer knows the target EJB component that the client wants to use. If there are multiple components implementing the same interface, then some disambiguation is required, and
<ejb-link/>
can be used.An application has a dependency on an external service. In this case, the application knows it has a dependency on an external service, so
<ejb-link/>
cannot be used since the service implementation does not exist in the same application.An application has a dependency on an external service, but a minimal implementation is provided in the same application. In this case, the developer might use an
<ejb-link/>
as in #1, but the deployer has the flexibility to override that choice as in #2.这可能有用:
http://www.theserverside.com/discussions/thread.tss?thread_id=2012
This could be maybe useful:
http://www.theserverside.com/discussions/thread.tss?thread_id=2012