org.clazzes.remoting.marshal
Interface Marshaler

All Known Implementing Classes:
CompactMarshaler, JAVAMarshaler, MarshalerSupport

public interface Marshaler

A marshaller, which handles the serialization and deserialization of objects.

Author:
wglas

Method Summary
 void close()
          Close the underlying transport and prepare the marshaler for calling setup(OutputStream, InputStream, ClassLoader) again.
 java.lang.Object readObject()
          Read the next object from the input stream.
 void reset()
          Reset the state of the serializer.
 void setup(java.io.OutputStream os, java.io.InputStream is, java.lang.ClassLoader inputClassLoader)
          Set up the marshaler for operation.
 void writeObject(java.lang.Object obj)
          Write an object to the underlying transport.
 

Method Detail

setup

void setup(java.io.OutputStream os,
           java.io.InputStream is,
           java.lang.ClassLoader inputClassLoader)
           throws java.io.IOException
Set up the marshaler for operation. Implementations must guarantee, that both, the input and the output stream are closed, when an excpetion is thrown.

Parameters:
os - The output stream to write to.
is - The input stream to read from.
inputClassLoader - The ClassLoader to use for deserialized instances.
Throws:
java.io.IOException - Upon errors setting up the streams.

readObject

java.lang.Object readObject()
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
Read the next object from the input stream. It is the responsibility of the caller, that this method is only called from a single thread at a time. The implementation need not be synchronized.

Returns:
The next object on the input stream.
Throws:
java.lang.ClassNotFoundException - If the underlying class loader was unable to find the class of a serialized object.
java.io.IOException - Upon transport errors.

writeObject

void writeObject(java.lang.Object obj)
                 throws java.io.IOException
Write an object to the underlying transport. This method must be implemented in a synchronized manner in order to allow writing objects from two concurrent threads.

Parameters:
obj - The object to write.
Throws:
java.io.IOException - Upon transport errors.

reset

void reset()
           throws java.io.IOException
Reset the state of the serializer. This incurs the cleanup of the object cache, which ensures, that the same instance of a class is serialized as reference rather than being serialized a second time.

Throws:
java.io.IOException - Upon transport errors.

close

void close()
Close the underlying transport and prepare the marshaler for calling setup(OutputStream, InputStream, ClassLoader) again. This method should be implemented in a fashion that is tolerant for an incomplete setup of the marshaler. It should even be possible to call close() twice on a single marshaler object.



Copyright © 2010. All Rights Reserved.