net.sf.fikin.classmarshaling
Class MarshaledObjectOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ObjectOutputStream
          extended by net.sf.fikin.classmarshaling.MarshaledObjectOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.io.ObjectOutput, java.io.ObjectStreamConstants

public class MarshaledObjectOutputStream
extends java.io.ObjectOutputStream

An ObjectOutputStream which is serializing the object and its classes in two parallel output stream.

It uses a ClassSelector to choose which classes to serialize and which not.

Used by MarshaledObject.MarshaledObject(Object, ClassSelector). created on Aug 2, 2005

Since:
Version:
$Revision: 1.1 $
Author:
fiykov

Nested Class Summary
 
Nested classes/interfaces inherited from class java.io.ObjectOutputStream
java.io.ObjectOutputStream.PutField
 
Field Summary
 
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
 
Constructor Summary
MarshaledObjectOutputStream(java.io.OutputStream objOut, java.io.OutputStream annOut, ClassSelector selector)
          Instantiate the output stream using one stream for the object itself and another stream for selected class bytecodes.
 
Method Summary
protected  void annotateClass(java.lang.Class cl)
          an overloaded ObjectOutputStream.annotateClass(Class), serializing the class bytecode to the given to the constructor stream
 void flush()
          flush the streams call this before trying to obtain bytes from the output byte streams passed to the constructor this method can be called only once!
protected  void marshallClass(java.lang.Class cl)
          marshal class's bytecode It does that only once per gven class
 
Methods inherited from class java.io.ObjectOutputStream
annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarshaledObjectOutputStream

public MarshaledObjectOutputStream(java.io.OutputStream objOut,
                                   java.io.OutputStream annOut,
                                   ClassSelector selector)
                            throws java.io.IOException
Instantiate the output stream using one stream for the object itself and another stream for selected class bytecodes.

Parameters:
objOut - is the stream for the serialized object
annOut - is the stream for the serialized classes (a map)
selector - used to select which class metadata to be marshaled together with the object
Throws:
java.io.IOException - during stream writing
Method Detail

flush

public void flush()
           throws java.io.IOException
flush the streams

call this before trying to obtain bytes from the output byte streams passed to the constructor this method can be called only once!

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in interface java.io.ObjectOutput
Overrides:
flush in class java.io.ObjectOutputStream
Throws:
java.io.IOException - in case of internal error

annotateClass

protected void annotateClass(java.lang.Class cl)
                      throws java.io.IOException
an overloaded ObjectOutputStream.annotateClass(Class), serializing the class bytecode to the given to the constructor stream

Overrides:
annotateClass in class java.io.ObjectOutputStream
Parameters:
cl - to serialize
Throws:
java.io.IOException

marshallClass

protected void marshallClass(java.lang.Class cl)
marshal class's bytecode

It does that only once per gven class

Parameters:
cl - to serialize


Copyright © 2007 Nikolay Fiykov. All Rights Reserved.