gpt4 book ai didi

java - 创建供应商中立的 EJB3 客户端

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:47:34 26 4
gpt4 key购买 nike

是否可以创建一个访问 EJB3 bean 的客户端,并且该客户端不依赖于供应商 JAR 或配置?我们目前需要支持以下场景:我们的服务部署在 WebSphere 或 JBoss 服务器上,客户端作为应用程序部署在 WAS 或 JBoss 上,或者作为独立应用程序运行。

我过去可以使用 EJB2.x bean 来做到这一点,我只需要使用 RMIC 创建 stub 。

但是对于 EJB3,如果我要连接到 WebSphere,我必须包含瘦客户端 JAR,而且我必须使用 WAS 工具预先生成 stub 。对于 JBoss,我必须使用 jboss-client.jar。

最佳答案

不,这是不可能的。这已在 EJB 3.2 规范的第 10 节中明确说明:

This chapter describes the interoperability support for accessing an enterprise bean through the EJB 2.1 remote client view from clients distributed over a network, and the distributed interoperability requirements for invocations on enterprise beans from remote clients that are Java Platform, Enterprise Edition (Java EE) components. Distributed Interoperability is not defined for the EJB 3.x remote client view.

另请注意第 10.5.5 节:

System value classes are serializable value classes implementing the javax.ejb.Handle, javax.ejb.HomeHandle, javax.ejb.EJBMetaData, java.util.Enumeration,java.util.Collection, and java.util.Iterator interfaces. These value classes are provided by the EJB container vendor. They must be provided in the form of a JAR file by the container hosting the referenced bean. For interoperability scenarios, if a referencing component would use such system value classes at runtime, the Deployer must ensure that these system value classes provided by the container hosting the referenced bean are available to the referencing component. This may be done, for example, by including these system value classes in the classpath of the referencing container, or by deploying the system value classes with the referencing component’s application by providing them to the deployment tool.

对于 WebSphere Application Server,EJB 瘦客户端包含这些系统值类以及使用 CosNaming 的 IBM JNDI 实现。理论上,如果您不需要系统值类并且您的客户端 JVM 有自己的 ORB 并实现了 CosNaming,则不需要此瘦客户端。

关于java - 创建供应商中立的 EJB3 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21901470/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com