dain 2005/06/27 21:47:50
Modified: modules/core/src/java/org/openejb/corba/util
StubMethodInterceptor.java Util.java
Log:
Make sure to set the replacement strategy before calling write
Do isIdentical in the stub to avoid unnecessary round trip
Revision Changes Path
1.5 +18 -2
openejb/modules/core/src/java/org/openejb/corba/util/StubMethodInterceptor.java
Index: StubMethodInterceptor.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/StubMethodInterceptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StubMethodInterceptor.java 24 Jun 2005 07:54:14 -0000 1.4
+++ StubMethodInterceptor.java 28 Jun 2005 01:47:50 -0000 1.5
@@ -50,6 +50,7 @@
import java.util.HashMap;
import java.util.Map;
import javax.rmi.CORBA.Util;
+import javax.ejb.EJBObject;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
@@ -68,6 +69,15 @@
* @version $Revision$ $Date$
*/
public class StubMethodInterceptor implements MethodInterceptor {
+ private static final Method ISIDENTICAL;
+ static {
+ try {
+ ISIDENTICAL = EJBObject.class.getMethod("isIdentical", new
Class[]{EJBObject.class});
+ } catch (NoSuchMethodException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
private final Class type;
private final Map operations;
@@ -84,6 +94,12 @@
public Object intercept(Object proxy, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
ClientContextHolderStub stub = (ClientContextHolderStub) proxy;
+
+ // handle is identical in stub to avoid unnecessary round trip
+ if (method.equals(ISIDENTICAL)) {
+ org.omg.CORBA.Object otherObject = (org.omg.CORBA.Object)args[0];
+ return new Boolean(stub._is_equivalent(otherObject));
+ }
// get the operation name object
String operationName = (String) operations.get(method);
1.16 +16 -1
openejb/modules/core/src/java/org/openejb/corba/util/Util.java
Index: Util.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/Util.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Util.java 25 Jun 2005 20:13:30 -0000 1.15
+++ Util.java 28 Jun 2005 01:47:50 -0000 1.16
@@ -69,6 +69,7 @@
import org.omg.CORBA.ORB;
import org.omg.CORBA.UserException;
import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
import org.omg.GSSUP.GSSUPMechOID;
import org.omg.GSSUP.InitialContextToken;
import org.omg.GSSUP.InitialContextTokenHelper;
@@ -83,6 +84,8 @@
import org.openejb.corba.CorbaApplicationServer;
import org.openejb.server.ServerFederation;
import org.openejb.spi.ApplicationServer;
+import org.openejb.proxy.SerializationHanlder;
+import org.openejb.proxy.ReplacementStrategy;
/**
* Various utility functions.
@@ -442,6 +445,17 @@
ApplicationServer oldApplicationServer =
ServerFederation.getApplicationServer();
try {
ServerFederation.setApplicationServer(corbaApplicationServer);
+
SerializationHanlder.setStrategy(ReplacementStrategy.REPLACE);
+
+ // copy the result to force replacement
+ // corba does not call writeReplace on remote proxies
+ try {
+ object = SerializationHanlder.copyObj(object);
+ } catch (Exception e) {
+ log.debug("Exception in result copy", e);
+ throw new UnknownException(e);
+ }
+
if (type == Object.class || type == Serializable.class) {
javax.rmi.CORBA.Util.writeAny(out, object);
} else if
(org.omg.CORBA.Object.class.isAssignableFrom(type)) {
@@ -455,6 +469,7 @@
}
} finally {
ServerFederation.setApplicationServer(oldApplicationServer);
+ SerializationHanlder.setStrategy(null);
}
}
}