[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/marshal/serializable ...

Ron Sigal ron_sigal at yahoo.com
Wed May 9 04:31:01 EDT 2007


  User: rsigal  
  Date: 07/05/09 04:31:01

  Modified:    src/main/org/jboss/remoting/marshal/serializable   Tag:
                        remoting_2_2_0_GA SerializableMarshaller.java
                        SerializableUnMarshaller.java
  Log:
  JBREM-714: Added version parameter to read()/write().
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.11.10.3.4.1 +19 -3     JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableMarshaller.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SerializableMarshaller.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableMarshaller.java,v
  retrieving revision 1.11.10.3
  retrieving revision 1.11.10.3.4.1
  diff -u -b -r1.11.10.3 -r1.11.10.3.4.1
  --- SerializableMarshaller.java	4 Feb 2007 08:40:24 -0000	1.11.10.3
  +++ SerializableMarshaller.java	9 May 2007 08:31:01 -0000	1.11.10.3.4.1
  @@ -28,8 +28,10 @@
   import java.io.OutputStream;
   import java.util.Map;
   
  +import org.jboss.remoting.Version;
   import org.jboss.remoting.marshal.Marshaller;
   import org.jboss.remoting.marshal.PreferredStreamMarshaller;
  +import org.jboss.remoting.marshal.VersionedMarshaller;
   import org.jboss.remoting.serialization.SerializationManager;
   import org.jboss.remoting.serialization.SerializationStreamFactory;
   
  @@ -39,7 +41,7 @@
    *
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
    */
  -public class SerializableMarshaller implements PreferredStreamMarshaller
  +public class SerializableMarshaller implements PreferredStreamMarshaller, VersionedMarshaller
   {
      static final long serialVersionUID = -5553685435323600244L;
   
  @@ -100,8 +102,22 @@
       */
      public void write(Object dataObject, OutputStream output) throws IOException
      {
  +      int version = Version.getDefaultVersion();
  +      write(dataObject, output, version);
  +   }
  +
  +   /**
  +    * Take the data object and write to the output.  Has ben customized
  +    * for working with ObjectOutputStreams since requires extra messaging.
  +    *
  +    * @param dataObject Object to be writen to output
  +    * @param output     The data output to write the object data to.
  +    * @param version    Wire format version
  +    */
  +   public void write(Object dataObject, OutputStream output, int version) throws IOException
  +   {
         ObjectOutputStream oos = (ObjectOutputStream) getMarshallingStream(output, null);
  -      SerializationStreamFactory.getManagerInstance(getSerializationType()).sendObject(oos, dataObject);
  +      SerializationStreamFactory.getManagerInstance(getSerializationType()).sendObject(oos, dataObject, version);
      }
   
      public Marshaller cloneMarshaller()
  
  
  
  1.11.10.3.4.1 +29 -4     JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableUnMarshaller.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SerializableUnMarshaller.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableUnMarshaller.java,v
  retrieving revision 1.11.10.3
  retrieving revision 1.11.10.3.4.1
  diff -u -b -r1.11.10.3 -r1.11.10.3.4.1
  --- SerializableUnMarshaller.java	4 Feb 2007 08:47:31 -0000	1.11.10.3
  +++ SerializableUnMarshaller.java	9 May 2007 08:31:01 -0000	1.11.10.3.4.1
  @@ -28,8 +28,10 @@
   import java.io.ObjectInputStream;
   import java.util.Map;
   
  +import org.jboss.remoting.Version;
   import org.jboss.remoting.marshal.PreferredStreamUnMarshaller;
   import org.jboss.remoting.marshal.UnMarshaller;
  +import org.jboss.remoting.marshal.VersionedUnMarshaller;
   import org.jboss.remoting.serialization.SerializationManager;
   import org.jboss.remoting.serialization.SerializationStreamFactory;
   
  @@ -38,7 +40,7 @@
    *
    * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
    */
  -public class SerializableUnMarshaller implements PreferredStreamUnMarshaller
  +public class SerializableUnMarshaller implements PreferredStreamUnMarshaller, VersionedUnMarshaller
   {
      static final long serialVersionUID = -1554017376768780738L;
   
  @@ -91,8 +93,32 @@
       */
      public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
      {
  +      int version = Version.getDefaultVersion();
  +      return read(inputStream, metadata, version);
  +   }
  +
  +   /**
  +    * Reads the data from the input stream and converts to an Object.
  +    * <p/>
  +    * If the inputStream passed is an ObjectInputStream (which would prefer it not be), it will just
  +    * use it as given.  If the input stream is not an instance of ObjectInputStream, will wrap it with a
  +    * custom ObjectInputStream (ObjectInputStreamWithClassLoader) and use it.  The ObjectInputStreamWithClassLoader
  +    * will use the custom class loader set in order to ensure that any classes not found within the local classloader
  +    * can be loaded from the server and used within the client VM.  If the inpustream is of type ObjectInputStreamWithClassLoader,
  +    * then will just set the classloader to the custom classloader and proceed.<p>
  +    *
  +    * @param inputStream
  +    * @param metadata
  +    * @param version
  +    * @return
  +    * @throws IOException
  +    * @throws ClassNotFoundException
  +    */
  +   public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
  +   {
         ObjectInputStream ois = (ObjectInputStream) getMarshallingStream(inputStream, null);
  -      return SerializationStreamFactory.getManagerInstance(getSerializationType()).receiveObject(ois, customClassLoader);
  +      return SerializationStreamFactory.getManagerInstance(getSerializationType()).receiveObject(ois, customClassLoader, version);
  +
      }
   
      /**
  @@ -130,5 +156,4 @@
            return serializationType;
         }
      }
  -
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list