家庭/远程接口 EJB 3.1 的目的是什么
我最近开始阅读有关 Java EE6 的内容,在我遵循的示例中,我需要创建远程接口。这样做的目的是什么?我也读过有关家庭接口的内容,但我不明白。我以前从未做过企业编程,所以我也无法将其与其他东西联系起来。有人能给我解释一下这些接口吗?
I have recently started reading about Java EE6 and in the examples I follow I need to make remote interface. What is the purpose of this? I also read about home interfaces, but I don't understand. I have never done enterprise programming before so I can't relate it to something else either. Could someone explain me these interfaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,通过声明 @Local @Remote 接口,您可以指定哪些方法应可用于远程客户端,哪些方法应可用于同一 JVM 中的本地 bean。
Home 接口用于允许远程客户端创建、查找和删除 EJB 对象。
您可以在官方文档页面上轻松找到该信息,例如 EJBHome ,或者本地和远程的很好的概述这里
我强烈建议阅读Bill Burke、Richard Monson-Haefel。
Basically by declaring the @Local @Remote interfaces you specify which methods should be available for the remote clients and which for the local beans in the same JVM.
Home interface is used to allow a remote client to create, find, and remove EJB objects.
You can easily find that information on the official documentation pages, for example for EJBHome, or nice overview for local and remote here
I highly recommend reading EJB book by Bill Burke, Richard Monson-Haefel for starters.
每个会话 bean 都必须实现接口和 Bean 类。当用户请求时,JNDI 帮助查找该请求所需的接口。当您的 EJB 部署在同一个 EAR 中时,您应该更喜欢本地接口。
如果 EJB 位于同一 EAR 中,则应使用远程接口。
该接口将调用驻留在 Bean 类中的业务逻辑。 Home Interface 为远程接口创建并查找 EJB 对象。因此,首先您应该使用 create 方法创建 Home Interface,然后创建 Remote Interface。
Every Session bean has to implement Interface and Bean Class. When User requests then JNDI helps to lookup which Interface is required for that Request. When your EJBs are deployed in same EAR then you should prefer Local Interface.
If EJBs are in same EAR then Remote Interface should be used.
This Interface will call business logic which resides in Bean Class. Home Interface creates and finds EJB objects for Remote Interface. So first you should create Home Interface with create method and then Remote Interface.