org.jboss.cache.marshall
Interface Marshaller

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

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

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 ReplicableCommand, 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 ReplicableCommands, 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
 Object objectFromObjectStream(ObjectInputStream in)
          Unmarshalls an object from an ObjectInputStream
 Object objectFromStream(InputStream is)
          Unmarshalls an object from an InputStream
 ByteBuffer objectToBuffer(Object o)
          A specialized form of RpcDispatcher.Marshaller2.objectToBuffer(Object) that returns an instance of ByteBuffer instead of Buffer.
 void objectToObjectStream(Object obj, ObjectOutputStream out)
          Marshalls an object to a given ObjectOutputStream
 void objectToObjectStream(Object obj, ObjectOutputStream out, Fqn region)
          Overloaded form of objectToObjectStream(Object,java.io.ObjectOutputStream) which adds a hint to the Fqn region
 RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer)
          Returns a RegionalizedMethodCall from a byte buffer.
 RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in)
          Returns a RegionalizedMethodCall from an object input stream.
 
Methods inherited from interface org.jgroups.blocks.RpcDispatcher.Marshaller2
objectFromByteBuffer
 
Methods inherited from interface org.jgroups.blocks.RpcDispatcher.Marshaller
objectFromByteBuffer, objectToByteBuffer
 

Method Detail

objectToObjectStream

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

Parameters:
obj - object to marshall
out - stream to marshall to
Throws:
Exception

objectFromObjectStream

Object objectFromObjectStream(ObjectInputStream in)
                              throws Exception
Unmarshalls an object from an ObjectInputStream

Parameters:
in - stream to unmarshall from
Throws:
Exception

objectFromStream

Object objectFromStream(InputStream is)
                        throws Exception
Unmarshalls an object from an InputStream

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

objectToObjectStream

void objectToObjectStream(Object obj,
                          ObjectOutputStream out,
                          Fqn region)
                          throws 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:
Exception

regionalizedMethodCallFromByteBuffer

RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer)
                                                            throws Exception
Returns a RegionalizedMethodCall from a byte buffer. Only use if you know that the byte buffer contains a MethodCall and that you are using region-based marshalling, otherwise use RpcDispatcher.Marshaller.objectFromByteBuffer(byte[])

Parameters:
buffer - byte buffer
Returns:
a RegionalizedMethodCall
Throws:
Exception - if there are issues
Since:
2.1.1

regionalizedMethodCallFromObjectStream

RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in)
                                                              throws Exception
Returns a RegionalizedMethodCall from an object input stream. Only use if you know that the byte buffer contains a MethodCall and that you are using region-based marshalling, otherwise use objectFromObjectStream(java.io.ObjectInputStream)

Parameters:
in - object inout stream
Returns:
a RegionalizedMethodCall
Throws:
Exception - if there are issues
Since:
2.1.1

objectToBuffer

ByteBuffer objectToBuffer(Object o)
                          throws Exception
A specialized form of RpcDispatcher.Marshaller2.objectToBuffer(Object) that returns an instance of ByteBuffer instead of Buffer.

Specified by:
objectToBuffer in interface org.jgroups.blocks.RpcDispatcher.Marshaller2
Parameters:
o - object to marshall
Returns:
a ByteBuffer
Throws:
Exception


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.