org.jboss.cache.marshall
Interface Marshaller

All Superinterfaces:
org.jgroups.blocks.RpcDispatcher.Marshaller
All Known Implementing Classes:
AbstractMarshaller, CacheMarshaller200, VersionAwareMarshaller

public interface Marshaller
extends org.jgroups.blocks.RpcDispatcher.Marshaller

A marshaller is a class that is able to marshall and unmarshall objects efficiently.

The reason why this is implemented specially in JBoss Cache rather than resorting to Java serialization or even the more efficient JBoss serialization is that a lot of efficiency can be gained when a majority of the serialization that occurs has to do with a small set of known types such as Fqn or MethodCall, and class type information can be replaced with simple magic numbers.

Unknown types (typically user data) falls back to JBoss serialization.

In addition, using a marshaller allows adding additional data to the byte stream, such as context class loader information on which class loader to use to deserialize the object stream, or versioning information to allow streams to interoperate between different versions of JBoss Cache (see VersionAwareMarshaller

This interface implements the JGroups building-block interface RpcDispatcher.Marshaller which is used to marshall MethodCalls, their parameters and their response values.

The interface is also used by the CacheLoader framework to efficiently serialize data to be persisted, as well as the StateTransferManager when serializing the cache for transferring state en-masse.

Since:
2.0.0
Author:
Manik Surtani

Method Summary
 java.lang.Object objectFromObjectStream(java.io.ObjectInputStream in)
          Unmarshalls an object from an ObjectInputStream
 java.lang.Object objectFromStream(java.io.InputStream is)
          Unmarshalls an object from an InputStream
 void objectToObjectStream(java.lang.Object obj, java.io.ObjectOutputStream out)
          Marshalls an object to a given ObjectOutputStream
 void objectToObjectStream(java.lang.Object obj, java.io.ObjectOutputStream out, Fqn region)
          Overloaded form of objectToObjectStream(Object,java.io.ObjectOutputStream) which adds a hint to the Fqn region
 
Methods inherited from interface org.jgroups.blocks.RpcDispatcher.Marshaller
objectFromByteBuffer, objectToByteBuffer
 

Method Detail

objectToObjectStream

void objectToObjectStream(java.lang.Object obj,
                          java.io.ObjectOutputStream out)
                          throws java.lang.Exception
Marshalls an object to a given ObjectOutputStream

Parameters:
obj - object to marshall
out - stream to marshall to
Throws:
java.lang.Exception

objectFromObjectStream

java.lang.Object objectFromObjectStream(java.io.ObjectInputStream in)
                                        throws java.lang.Exception
Unmarshalls an object from an ObjectInputStream

Parameters:
in - stream to unmarshall from
Throws:
java.lang.Exception

objectFromStream

java.lang.Object objectFromStream(java.io.InputStream is)
                                  throws java.lang.Exception
Unmarshalls an object from an InputStream

Parameters:
is - stream to unmarshall from
Returns:
Object from stream passed in.
Throws:
java.lang.Exception

objectToObjectStream

void objectToObjectStream(java.lang.Object obj,
                          java.io.ObjectOutputStream out,
                          Fqn region)
                          throws java.lang.Exception
Overloaded form of objectToObjectStream(Object,java.io.ObjectOutputStream) which adds a hint to the Fqn region

Parameters:
obj - object to marshall
region - fqn that this object pertains to
out - stream to marshall to
Throws:
java.lang.Exception