incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r487647 - in /incubator/yoko/trunk/core: pom.xml src/main/java/org/apache/yoko/orb/CORBA/InputStream.java src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java
Date Fri, 15 Dec 2006 20:21:13 GMT
Author: rickmcguire
Date: Fri Dec 15 12:21:12 2006
New Revision: 487647

URL: http://svn.apache.org/viewvc?view=rev&rev=487647
Log:
YOKO-254 Core InputStream class not implementing IDL generated Stub classes


Modified:
    incubator/yoko/trunk/core/pom.xml
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java

Modified: incubator/yoko/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/pom.xml?view=diff&rev=487647&r1=487646&r2=487647
==============================================================================
--- incubator/yoko/trunk/core/pom.xml (original)
+++ incubator/yoko/trunk/core/pom.xml Fri Dec 15 12:21:12 2006
@@ -36,6 +36,10 @@
       <artifactId>yoko-spec-corba</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.yoko</groupId>
+      <artifactId>yoko-rmi-spec</artifactId>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java?view=diff&rev=487647&r1=487646&r2=487647
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java Fri
Dec 15 12:21:12 2006
@@ -16,6 +16,8 @@
 
 package org.apache.yoko.orb.CORBA;
 
+import javax.rmi.CORBA.Util;
+
 import org.omg.SendingContext.CodeBase;
 
 final public class InputStream extends org.omg.CORBA_2_3.portable.InputStream {
@@ -1680,23 +1682,90 @@
         org.omg.CORBA.Object obj = read_Object();
 
         if (obj != null) {
+            // OK, we have two possibilities here.  The usual possibility is we're asked
to load 
+            // an object using a specified Stub class.  We just create an instance of the
stub class, 
+            // attach the object as a delegate, and we're done. 
+            // 
+            // The second possibility is a request for an instance of an interface.  This
will require
+            // us to locate a stub class using the defined Stub search orders.  After that,
the process 
+            // is largely the same. 
             org.omg.CORBA.portable.ObjectImpl impl = (org.omg.CORBA.portable.ObjectImpl)
obj;
-            java.lang.Object stubObject;
-            try {
-                stubObject = clz.newInstance();
-                org.omg.CORBA.portable.ObjectImpl stubImpl = (org.omg.CORBA.portable.ObjectImpl)
stubObject;
-                stubImpl._set_delegate(impl._get_delegate());
-                return stubImpl;
-            } catch (IllegalAccessException ex) {
-                throw new org.omg.CORBA.MARSHAL();
-            } catch (InstantiationException ex) {
-                throw new org.omg.CORBA.MARSHAL();
+            
+            if (org.omg.CORBA.portable.ObjectImpl.class.isAssignableFrom(clz)) {
+                java.lang.Object stubObject;
+                try {
+                    stubObject = clz.newInstance();
+                    org.omg.CORBA.portable.ObjectImpl stubImpl = (org.omg.CORBA.portable.ObjectImpl)
stubObject;
+                    stubImpl._set_delegate(impl._get_delegate());
+                    return stubImpl;
+                } catch (IllegalAccessException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to create stub for class " +
clz.getName());
+                } catch (InstantiationException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to create stub for class " +
clz.getName());
+                }
+            }
+            else {
+                try {
+                    Class stubClass = getIDLStubClass(((org.omg.CORBA_2_3.portable.ObjectImpl)impl)._get_codebase(),
clz); 
+                    
+                    java.lang.Object stubObject = stubClass.newInstance();
+                    org.omg.CORBA.portable.ObjectImpl stubImpl = (org.omg.CORBA.portable.ObjectImpl)stubObject;
+                    stubImpl._set_delegate(impl._get_delegate());
+                    return stubImpl;
+                } catch (IllegalAccessException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to create stub for class " +
clz.getName());
+                } catch (InstantiationException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to create stub for class " +
clz.getName());
+                } catch (ClassNotFoundException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to locate stub for class " +
clz.getName());
+                } catch (ClassCastException ex) {
+                    throw new org.omg.CORBA.MARSHAL("Unable to locate stub for class " +
clz.getName());
+                }
             }
         }
-
+        // null object, just return null. 
         return null;
     }
 
+
+    /**
+     * Convert a class type into a stub class name using the
+     * ISL stub name rules.
+     * 
+     * @param c      The class we need to stub.
+     * 
+     * @return The target stub class name. 
+     */
+    private String getIDLStubClassName(Class c) {
+
+        String cname = c.getName();
+
+        //String pkgname = null;
+        int idx = cname.lastIndexOf('.');
+
+        if (idx == -1) {
+            return "_" + cname + "Stub";
+        } else {
+            return cname.substring(0, idx + 1) + "_" + cname.substring(idx + 1) + "Stub";
+        }
+    }
+    
+    
+    /**
+     * Load a statically-created Stub class for a type, 
+     * attempting both the old and new stub class rules.
+     * 
+     * @param codebase The search codebase to use.
+     * @param type     The type we need a stub for.
+     * 
+     * @return A loaded stub class.
+     */
+    private Class getIDLStubClass(String codebase, Class type) throws ClassNotFoundException
{
+        String name = getIDLStubClassName(type); 
+        return Util.loadClass(name, codebase, type.getClassLoader()); 
+    }
+    
+
     public org.omg.CORBA.TypeCode read_TypeCode() {
         //
         // NOTE:
@@ -2029,3 +2098,4 @@
 		return codebase_;
 	}
 }
+

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java?view=diff&rev=487647&r1=487646&r2=487647
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/CORBA/OutputStream.java Fri
Dec 15 12:21:12 2006
@@ -1744,6 +1744,7 @@
 
                     case org.omg.CORBA.TCKind._tk_alias:
                         org.apache.yoko.orb.OB.Assert._OB_assert(false);
+                        break;
 
                     default:
                         for (int i = 0; i < len; i++)



Mime
View raw message