tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r526682 - /incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
Date Mon, 09 Apr 2007 09:17:52 GMT
Author: rickmcguire
Date: Mon Apr  9 02:17:52 2007
New Revision: 526682

URL: http://svn.apache.org/viewvc?view=rev&rev=526682
Log:
Fix handling of remote objects on inbound method parameters and cleanup obtaining 
an ORB reference. 

Modified:
    incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java

Modified: incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java?view=diff&rev=526682&r1=526681&r2=526682
==============================================================================
--- incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
(original)
+++ incubator/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
Mon Apr  9 02:17:52 2007
@@ -99,6 +99,7 @@
     }
 
     public static class Body implements java.io.Externalizable {
+        private transient ORB orb; 
         private transient Method methodInstance;
         private transient Class methodClass;
         private transient String methodName;
@@ -243,13 +244,7 @@
                         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");
-                        }
+                        ORB orb = getORB();
                         tie.orb(orb);
                         obj = PortableRemoteObject.toStub((Remote) obj);
                     }
@@ -263,6 +258,25 @@
         static final Class[] noArgsC = new Class[0];
         static final Object[] noArgsO = new Object[0];
 
+        /**
+         * Obtain an ORB instance for this request to activate remote 
+         * arguments and return results.
+         * 
+         * @return An ORB instance.
+         */
+        protected ORB getORB() throws IOException {
+            // first ORB request?  Check our various sources 
+            if (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");
+                }
+            }
+            return orb; 
+        }
+
         protected void readMethodParameters(ObjectInput in) throws IOException, ClassNotFoundException
{
             int length = in.read();
 
@@ -325,6 +339,11 @@
                     case L:
                         clazz = (Class) in.readObject();
                         obj = in.readObject();
+                        if (obj instanceof Stub) {
+                            Stub stub = (Stub)obj;
+                            ORB orb = getORB();
+                            stub.connect(orb);
+                        }
                         break;
                     default:
                         throw new IOException("Unkown data type: " + type);



Mime
View raw message