incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r485669 - /incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
Date Mon, 11 Dec 2006 14:05:36 GMT
Author: rickmcguire
Date: Mon Dec 11 06:05:35 2006
New Revision: 485669

URL: http://svn.apache.org/viewvc?view=rev&rev=485669
Log:
YOKO-240 RMI support not marshalling value arrays correctly.


Modified:
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java?view=diff&rev=485669&r1=485668&r2=485669
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
(original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ArrayDescriptor.java
Mon Dec 11 06:05:35 2006
@@ -13,7 +13,7 @@
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
-*/ 
+*/
 
 package org.apache.yoko.rmi.impl;
 
@@ -31,8 +31,10 @@
     protected Class basicType;
 
     protected Class elementType;
-
+    // repository ID for the array class
     String _repid = null;
+    // repository ID for the contained elements
+    String _elementRepid = null;
 
     public String getRepositoryID() {
         if (_repid != null)
@@ -53,6 +55,26 @@
         return _repid;
     }
 
+
+    public String getElementRepositoryID() {
+        if (_elementRepid != null) {
+            return _elementRepid;
+        }
+
+        if (elementType.isPrimitive() || elementType == Object.class) {
+            // use the descriptor type past the array type marker
+            _elementRepid = "RMI:" + getJavaClass().getName().substring(1) + ":0000000000000000";
+        } else {
+            TypeDescriptor desc = getTypeRepository()
+                    .getDescriptor(elementType);
+            _elementRepid = desc.getRepositoryIDForArray();
+        }
+
+        // System.out.println ("Element REPID "+getJavaClass()+" >> "+_elementRepid);
+
+        return _elementRepid;
+    }
+
     protected ArrayDescriptor(Class type, Class elemType, TypeRepository rep) {
         super(type, rep);
         this.elementType = elemType;
@@ -139,14 +161,14 @@
     public Object read(org.omg.CORBA.portable.InputStream in) {
         org.omg.CORBA_2_3.portable.InputStream _in = (org.omg.CORBA_2_3.portable.InputStream)
in;
 
-        return _in.read_value();
+        return _in.read_value(getRepositoryID());
     }
 
     /** Write an instance of this value to a CDR stream */
     public void write(org.omg.CORBA.portable.OutputStream out, Object value) {
         org.omg.CORBA_2_3.portable.OutputStream _out = (org.omg.CORBA_2_3.portable.OutputStream)
out;
 
-        _out.write_value((java.io.Serializable) value);
+        _out.write_value((java.io.Serializable)value, getRepositoryID());
     }
 
     org.omg.CORBA.ValueMember[] getValueMembers() {
@@ -359,14 +381,12 @@
             java.io.Serializable value) {
         // System.out.println ("ValueArrayDescriptor::writeValue
         // "+getRepositoryID ());
-
-        org.omg.CORBA_2_3.portable.OutputStream _out = (org.omg.CORBA_2_3.portable.OutputStream)
out;
-
         Object[] arr = (Object[]) value;
         out.write_long(arr.length);
         java.io.Serializable[] sarr = (java.io.Serializable[]) arr;
+        org.omg.CORBA_2_3.portable.OutputStream _out = (org.omg.CORBA_2_3.portable.OutputStream)
out;
         for (int i = 0; i < sarr.length; i++) {
-            _out.write_value(sarr[i]);
+            _out.write_value(sarr[i], getElementRepositoryID());
         }
     }
 
@@ -392,7 +412,6 @@
             }
 
             return (java.io.Serializable) arr;
-
         } catch (java.io.IOException ex) {
             throw new MARSHAL(ex.getMessage());
         }



Mime
View raw message