假设部署了两个EAR的单个应用服务器实例。第一个EAR使用远程EJB接口从第二个EAR调用EJB。
传言说,即使调用是使用远程接口实现的,应用服务器也知道所有东西都在同一个JVM中,并在内部使用具有本地接口机制的远程接口,即它不通过RMI调用方法,不打开任何套接字,也不序列化/反序列化对象。
这是真的吗?如果任何人对WebLogic10.3.2和OC4j 10.1.3的行为有关于这个问题的反馈,我们将不胜感激。
发布于 2010-04-27 21:29:38
不,这不是真的。如果ORB实现了本地对象优化(有时是“并置对象”),那么它将不会打开任何套接字,但它将执行序列化/反序列化,这通常比编组更快。创建额外的对象副本是为了避免违反编程模型。
生成的存根支持此优化。下面是一个示例接口:
public interface a extends Remote {
public ArrayList test(ArrayList in1, ArrayList in2) throws RemoteException;
}以下是rmic -iiop -keep a的结果:
public ArrayList test(ArrayList arg0, ArrayList arg1) throws java.rmi.RemoteException {
if (!Util.isLocal(this)) {
/* ... trim remote code ... */
} else {
ServantObject so = _servant_preinvoke("test",a.class);
if (so == null) {
return test(arg0, arg1);
}
try {
Object[] copies = Util.copyObjects(new Object[]{arg0,arg1},_orb());
ArrayList arg0Copy = (ArrayList) copies[0];
ArrayList arg1Copy = (ArrayList) copies[1];
ArrayList result = ((a)so.servant).test(arg0Copy, arg1Copy);
return (ArrayList)Util.copyObject(result,_orb());
} catch (Throwable ex) {
Throwable exCopy = (Throwable)Util.copyObject(ex,_orb());
throw Util.wrapException(exCopy);
} finally {
_servant_postinvoke(so);
}
}
}当存根连接到本地对象时,它会调用ObjectImpl._servant_preinvoke在同一个JVM中定位一个服务程序(在本例中是一个EJB包装器)。然后,它复制输入参数(模拟编组),调用方法,并复制结果对象(再次模拟编组)。
我不是WebLogic专家。也就是说,本文档暗示WebLogic执行并置对象优化:
http://download.oracle.com/docs/cd/E13222_01/wls/docs61/cluster/object.html#1007328
https://stackoverflow.com/questions/2721285
复制相似问题