org.jboss.cache.marshall
Class VersionAwareMarshaller

java.lang.Object
  extended by org.jboss.cache.marshall.AbstractMarshaller
      extended by org.jboss.cache.marshall.VersionAwareMarshaller
All Implemented Interfaces:
Marshaller, org.jgroups.blocks.RpcDispatcher.Marshaller, org.jgroups.blocks.RpcDispatcher.Marshaller2

public class VersionAwareMarshaller
extends AbstractMarshaller

A delegate to various other marshallers like CacheMarshaller200. This delegating marshaller adds versioning information to the stream when marshalling objects and is able to pick the appropriate marshaller to delegate to based on the versioning information when unmarshalling objects.

Author:
Manik Surtani (manik AT jboss DOT org), Galder Zamarreno

Field Summary
 
Fields inherited from class org.jboss.cache.marshall.AbstractMarshaller
configuration, defaultClassLoader, defaultInactive, regionManager, trace, useRefs, useRegionBasedMarshalling
 
Constructor Summary
VersionAwareMarshaller()
           
 
Method Summary
protected  int getCustomMarshallerVersionInt()
           
 void initReplicationVersions()
           
 Object objectFromByteBuffer(byte[] bytes, int offset, int len)
           
 Object objectFromObjectStream(ObjectInputStream in)
          Unmarshalls an object from an ObjectInputStream
 Object objectFromStream(InputStream is)
          Unmarshalls an object from an InputStream
 ByteBuffer objectToBuffer(Object obj)
          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 Marshaller.objectToObjectStream(Object,java.io.ObjectOutputStream) which adds a hint to the Fqn region
 RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buf)
          Returns a RegionalizedMethodCall from a byte buffer.
 
Methods inherited from class org.jboss.cache.marshall.AbstractMarshaller
extractFqn, init, initLogger, objectFromByteBuffer, objectToByteBuffer, regionalizedMethodCallFromObjectStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionAwareMarshaller

public VersionAwareMarshaller()
Method Detail

initReplicationVersions

public void initReplicationVersions()

getCustomMarshallerVersionInt

protected int getCustomMarshallerVersionInt()

objectToBuffer

public ByteBuffer objectToBuffer(Object obj)
                          throws Exception
Description copied from interface: Marshaller
A specialized form of RpcDispatcher.Marshaller2.objectToBuffer(Object) that returns an instance of ByteBuffer instead of Buffer.

Specified by:
objectToBuffer in interface Marshaller
Specified by:
objectToBuffer in interface org.jgroups.blocks.RpcDispatcher.Marshaller2
Overrides:
objectToBuffer in class AbstractMarshaller
Parameters:
obj - object to marshall
Returns:
a ByteBuffer
Throws:
Exception

objectFromByteBuffer

public Object objectFromByteBuffer(byte[] bytes,
                                   int offset,
                                   int len)
                            throws Exception
Specified by:
objectFromByteBuffer in interface org.jgroups.blocks.RpcDispatcher.Marshaller2
Overrides:
objectFromByteBuffer in class AbstractMarshaller
Throws:
Exception

regionalizedMethodCallFromByteBuffer

public RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buf)
                                                            throws Exception
Description copied from interface: Marshaller
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[])

Specified by:
regionalizedMethodCallFromByteBuffer in interface Marshaller
Overrides:
regionalizedMethodCallFromByteBuffer in class AbstractMarshaller
Parameters:
buf - byte buffer
Returns:
a RegionalizedMethodCall
Throws:
Exception - if there are issues

objectFromStream

public Object objectFromStream(InputStream is)
                        throws Exception
Description copied from interface: Marshaller
Unmarshalls an object from an InputStream

Specified by:
objectFromStream in interface Marshaller
Overrides:
objectFromStream in class AbstractMarshaller
Parameters:
is - stream to unmarshall from
Returns:
Object from stream passed in.
Throws:
Exception

objectToObjectStream

public void objectToObjectStream(Object obj,
                                 ObjectOutputStream out,
                                 Fqn region)
                          throws Exception
Description copied from interface: Marshaller
Overloaded form of Marshaller.objectToObjectStream(Object,java.io.ObjectOutputStream) which adds a hint to the Fqn region

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

objectToObjectStream

public void objectToObjectStream(Object obj,
                                 ObjectOutputStream out)
                          throws Exception
Description copied from interface: Marshaller
Marshalls an object to a given ObjectOutputStream

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

objectFromObjectStream

public Object objectFromObjectStream(ObjectInputStream in)
                              throws Exception
Description copied from interface: Marshaller
Unmarshalls an object from an ObjectInputStream

Parameters:
in - stream to unmarshall from
Throws:
Exception


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