dain 2005/03/17 18:56:31
Modified: modules/core/src/java/org/openejb/client EJBRequest.java
EJBResponse.java
Log:
Added special handling code for corba objects - should be removed later
Revision Changes Path
1.5 +32 -1
openejb/modules/core/src/java/org/openejb/client/EJBRequest.java
Index: EJBRequest.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/client/EJBRequest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EJBRequest.java 9 Mar 2005 06:17:16 -0000 1.4
+++ EJBRequest.java 17 Mar 2005 23:56:31 -0000 1.5
@@ -49,6 +49,17 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Method;
+import java.rmi.Remote;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Stub;
+
+import org.omg.CORBA.ORB;
+import org.openejb.corba.util.Util;
+
/**
*
@@ -384,6 +395,21 @@
throw new IOException("Unkown primitive type: " + type);
}
} else {
+ if (obj instanceof PortableRemoteObject && obj instanceof
Remote) {
+ Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
+ if (tie == null) {
+ throw new IOException("Unable to serialize
PortableRemoteObject; object has not been exported: " + obj);
+ }
+ ORB orb = null;
+ try {
+ Context initialContext = new InitialContext();
+ orb = (ORB) initialContext.lookup("java:comp/ORB");
+ } catch (NamingException e) {
+ throw new IOException("Unable to connect
PortableRemoteObject stub to an ORB, no ORB bound to java:comp/ORB");
+ }
+ tie.orb(orb);
+ obj = PortableRemoteObject.toStub((Remote) obj);
+ }
out.write(L);
out.writeObject(type);
out.writeObject(obj);
@@ -456,6 +482,11 @@
case L:
clazz = (Class) in.readObject();
obj = in.readObject();
+// if (obj instanceof Stub) {
+// Stub stub = (Stub)obj;
+// ORB orb = Util.getORB();
+// stub.connect(orb);
+// }
break;
default:
throw new IOException("Unkown data type: " + type);
1.2 +18 -1
openejb/modules/core/src/java/org/openejb/client/EJBResponse.java
Index: EJBResponse.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/client/EJBResponse.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EJBResponse.java 1 Mar 2004 07:14:43 -0000 1.1
+++ EJBResponse.java 17 Mar 2005 23:56:31 -0000 1.2
@@ -47,6 +47,12 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.CORBA.Stub;
+
+import org.omg.CORBA.ORB;
/**
*
@@ -136,6 +142,17 @@
// so we can take an active part in reading it in
// as we do with the other reponse objects
result = in.readObject();
+ if (result instanceof Stub) {
+ Stub stub = (Stub)result;
+ ORB orb = null;
+ try {
+ Context initialContext = new InitialContext();
+ orb = (ORB) initialContext.lookup("java:comp/ORB");
+ } catch (NamingException e) {
+ throw new IOException("Unable to connect
PortableRemoteObject stub to an ORB, no ORB bound to java:comp/ORB");
+ }
+ stub.connect(orb);
+ }
}
/**