我收到消息
<Warning> <EJB> <BEA-010202> <Call-by-reference is not enabled for the EJB 'myEjb'.
The server will have better performance if it is enabled. To enable call-by-reference, set the enable-call-by-reference element to True in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB.>
和
<Warning> <EJB> <BEA-012035> <The Remote interface method: 'public abstract java.util.Collection my.sessionfassade.ejb.myFassade.myMethod(java.lang.String,java.lang.String,java.util.Collection) throws my.Exception' in EJB 'myEjb' contains a parameter of type: 'java.util.Collection' which is not Serializable. Though the EJB 'myEjb' has call-by-reference set to false, this parameter is not Serializable and hence will be passed by reference. A parameter can be passed using call-by-value only if the parameter type is Serializable.>
为什么默认情况下不启用此功能,因为如果标志设置为 True,远程调用仍然可能并按值完成?将其设置为 True 时是否有任何负面影响?
最佳答案
call-by-reference = true 不符合 EJB 规范。
远程 EJB 的目标是提供位置透明性。换句话说,如果目标 EJB 在另一个 JVM 中,那么显然数据必须以某种方式复制到该 JVM,因此为了一致性,对同一 JVM 中的 EJB 的调用也会被复制。例如,如果未复制对同一 JVM 中的 EJB 的调用,则调用者/被调用者将不知道他们是否需要防御性地复制 ArrayList。通过始终复制,消除了这种歧义,但以牺牲性能为代价。
如果您可以完全信任同一 JVM 中的所有客户端和 EJB,并且您建立了必要时复制数据的约定,那么您可以启用 call-by-reference = true。
关于performance - enable-call-by-reference 的效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6251797/