gpt4 book ai didi

java - EJB3通信机制

转载 作者:行者123 更新时间:2023-11-29 04:22:00 25 4
gpt4 key购买 nike

我是 Java EE 的新手,对 EJB 感到困惑。据我了解,@remote EJB 使用 RMI 和 JNDI 进行通信。在 EJB3.0 beans 需要通过 EJBHome 接口(interface)实现 Remote 接口(interface)之前——这样我就理解了 RMI 是如何使用的。但是现在我只需要打@remote注解,可以用ejb-jar.xml中的属性代替。

所以,问题是:如何在没有 Serializible 接口(interface)的情况下使用 JNDI 和在没有 Remote 接口(interface)的情况下使用 RMI?

如果我的一些假设是错误的,请纠正我。

最佳答案

  1. EJB3 仍然在底层使用 RMI,只是应用程序容器会自动为您生成和使用 RMI stub 和远程接口(interface),并将它们映射到您的 EJB3 类。

  2. 在某些情况下您仍然需要使用Serializible。参见 this :

Clustered Session Beans (SLSB & SFSB)

First of all, clustered EJB3 SLSBs or SFSBs do not need to implement Serializable. In fact, it's recommended that they don't. In the case of clustered SLSBs, no state replication occurs, so their instance variables do not even need to be Serializable. With clustered SFSBs though, the same serialization rules used for SFSB passivation apply to SFSB state replication. In other words, all non-transient instance variables that are not references to beans, sessions contexts or user transactions must be serializable, or null at replication time. For further information on the SFSB passivation (and by extension replication because in both cases the SFSB bean context needs to be serialized), please check section 4.2.1 of the EJB3 core specification.

Clustered Entity Beans

These only need to be marked Serializable if the clustered entity instances are to be passed by value as a detached object (e.g., through a remote interface). Otherwise, there's no need to mark them as Serializable.

关于java - EJB3通信机制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48527013/

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