geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1152937 - in /geronimo/yoko/trunk: yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ yoko-core/src/main/java/org/apache/yoko/orb/OB/ yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/
Date Mon, 01 Aug 2011 21:25:05 GMT
Author: djencks
Date: Mon Aug  1 21:25:04 2011
New Revision: 1152937

URL: http://svn.apache.org/viewvc?rev=1152937&view=rev
Log:
YOKO-434 nasty try-it-twice attempt to determine if the source class had a write object method
by seeing what deserializes correctly

Modified:
    geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
    geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
    geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
    geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java

Modified: geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java?rev=1152937&r1=1152936&r2=1152937&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
(original)
+++ geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/InputStream.java
Mon Aug  1 21:25:04 2011
@@ -17,6 +17,7 @@
 
 package org.apache.yoko.orb.CORBA;
 
+import java.io.IOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -63,6 +64,9 @@ final public class InputStream extends o
 
 	private String codebase_;
 
+    //mark support
+    private int mark_pos;
+
     // ------------------------------------------------------------------
     // Private and protected members
     // ------------------------------------------------------------------
@@ -2126,5 +2130,21 @@ final public class InputStream extends o
             valueReader_.checkChunk();
         }
     }
+
+    @Override
+    public void mark(int i) {
+        mark_pos = buf_.pos();
+    }
+
+    @Override
+    public boolean markSupported() {
+        return true;
+    }
+
+    @Override
+    public void reset() throws IOException {
+        buf_.pos(mark_pos);
+        mark_pos = 0;
+    }
 }
 

Modified: geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java?rev=1152937&r1=1152936&r2=1152937&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java (original)
+++ geronimo/yoko/trunk/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java Mon
Aug  1 21:25:04 2011
@@ -202,7 +202,7 @@ final public class ValueReader {
     //
     // Create a value using a factory
     //
-    private class FactoryCreationStrategy extends CreationStrategy {
+    static class FactoryCreationStrategy extends CreationStrategy {
         private String id_;
 
         private ORBInstance orbInstance_;
@@ -296,8 +296,8 @@ final public class ValueReader {
             Assert._OB_assert(h.tag >= 0x7fffff00 && h.tag != -1);
 
             if (h.isRMIValue ()) {
-                Serializable result = readRMIValue (h, null, h.ids[0]);
-                addInstance (h.headerPos, result);
+                Serializable result = reader_.readRMIValue(h, null, h.ids[0]);
+                reader_.addInstance(h.headerPos, result);
                 return result;
             }
             //

Modified: geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java?rev=1152937&r1=1152936&r2=1152937&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
(original)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/CorbaObjectReader.java
Mon Aug  1 21:25:04 2011
@@ -19,6 +19,8 @@
 package org.apache.yoko.rmi.impl;
 
 
+import java.io.IOException;
+
 public class CorbaObjectReader extends ObjectReader {
     final org.omg.CORBA_2_3.portable.InputStream in;
 
@@ -202,4 +204,18 @@ public class CorbaObjectReader extends O
         return in.available();
     }
 
+    @Override
+    public void mark(int i) {
+        in.mark(i);
+    }
+
+    @Override
+    public boolean markSupported() {
+        return in.markSupported();
+    }
+
+    @Override
+    public void reset() throws IOException {
+        in.reset();
+    }
 }

Modified: geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java?rev=1152937&r1=1152936&r2=1152937&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
(original)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
Mon Aug  1 21:25:04 2011
@@ -818,13 +818,49 @@ public class ValueDescriptor extends Typ
 
         // System.out.println ("readValue "+getJavaClass());
 
-        if (_write_object_method != null) {
+        //Determine if source object had a writeObject method.
+        //If the source object had a writeObject method, the next two bytes will be stream
format version and
+        //whether the write object method called defaultWriteObject.
+
+        //If the source object did not have a writeObject method, the next 4-byte-aligned
bit will be the start of a header
+        //for the first field.
+        //What if there are no fields?
+
+        //The only obvious way to do this is to, if the reader supports mark, try the way
suggested by the target class
+        // and if that doesn't work try the other possibility.
+
+        if (reader.markSupported()) {
+            reader.mark(7);
+        }
+        boolean hasWriteObjectMethod = _write_object_method != null;
+
+        try {
+            tryReadObject(reader, value, hasWriteObjectMethod);
+        } catch (org.omg.CORBA.MARSHAL e) {
+            if (reader.markSupported()) {
+                reader.reset();
+                tryReadObject(reader, value, !hasWriteObjectMethod);
+            } else {
+                throw e;
+            }
+        } catch (org.omg.CORBA.portable.UnknownException e) {
+            if (reader.markSupported()) {
+                reader.reset();
+                tryReadObject(reader, value, !hasWriteObjectMethod);
+            } else {
+                throw e;
+            }
+        }
+
+    }
+
+    private void tryReadObject(ObjectReader reader, Serializable value, boolean hasWriteObjectMethod)
throws IOException {
+        if (hasWriteObjectMethod) {
 
             // read custom marshalling value header
             byte streamFormatVersion = reader.readByte();
             boolean writeDefaultStateCalled = reader.readBoolean();
         }
-
         if (_read_object_method != null) {
 
             // System.out.println ("readValue "+getJavaClass()+" calling
@@ -847,7 +883,6 @@ public class ValueDescriptor extends Typ
         } else {
             defaultReadValue(reader, value);
         }
-
     }
 
     protected long computeHashCode() {



Mime
View raw message