org.infinispan.marshall
Class VersionAwareMarshaller

java.lang.Object
  extended by org.infinispan.marshall.AbstractMarshaller
      extended by org.infinispan.marshall.VersionAwareMarshaller
All Implemented Interfaces:
Marshaller

public class VersionAwareMarshaller
extends AbstractMarshaller

A delegate to various other marshallers like MarshallerImpl. 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.

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Galder ZamarreƱo

Constructor Summary
VersionAwareMarshaller()
           
 
Method Summary
 void finishObjectInput(ObjectInput oi)
          Finish using the given ObjectInput.
 void finishObjectOutput(ObjectOutput oo)
          Finish using the given ObjectOutput.
protected  int getCustomMarshallerVersionInt()
           
 void init(ClassLoader loader, RemoteCommandFactory remoteCommandFactory)
           
 Object objectFromByteBuffer(byte[] buf)
           
 Object objectFromByteBuffer(byte[] bytes, int offset, int len)
           
 Object objectFromObjectStream(ObjectInput in)
          Unmarshalls an object from an ObjectInput
 ByteBuffer objectToBuffer(Object obj)
          A method that returns an instance of ByteBuffer, which allows direct access to the byte array with minimal array copying
 byte[] objectToByteBuffer(Object obj)
           
 void objectToObjectStream(Object obj, ObjectOutput out)
          Marshalls an object to a given ObjectOutput
 ObjectInput startObjectInput(InputStream is)
          Create and open a new ObjectInput for the given input stream.
 ObjectOutput startObjectOutput(OutputStream os)
          Create and open a new ObjectOutput for the given output stream.
 
Methods inherited from class org.infinispan.marshall.AbstractMarshaller
objectFromInputStream
 
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

init

public void init(ClassLoader loader,
                 RemoteCommandFactory remoteCommandFactory)

getCustomMarshallerVersionInt

protected int getCustomMarshallerVersionInt()

objectToBuffer

public ByteBuffer objectToBuffer(Object obj)
                          throws IOException
Description copied from interface: Marshaller
A method that returns an instance of ByteBuffer, which allows direct access to the byte array with minimal array copying

Parameters:
obj - object to marshall
Returns:
a ByteBuffer
Throws:
IOException

objectFromByteBuffer

public Object objectFromByteBuffer(byte[] bytes,
                                   int offset,
                                   int len)
                            throws IOException,
                                   ClassNotFoundException
Throws:
IOException
ClassNotFoundException

startObjectOutput

public ObjectOutput startObjectOutput(OutputStream os)
                               throws IOException
Description copied from interface: Marshaller
Create and open a new ObjectOutput for the given output stream. This method should be used for opening data outpus when multiple objectToObjectStream() calls will be made before the stream is closed

Parameters:
os - output stream
Returns:
ObjectOutput to write to
Throws:
IOException

finishObjectOutput

public void finishObjectOutput(ObjectOutput oo)
Description copied from interface: Marshaller
Finish using the given ObjectOutput. After opening a ObjectOutput and calling objectToObjectStream() mutliple times, use this method to flush the data and close if necessary

Parameters:
oo - data output that finished using

objectToObjectStream

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

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

startObjectInput

public ObjectInput startObjectInput(InputStream is)
                             throws IOException
Description copied from interface: Marshaller
Create and open a new ObjectInput for the given input stream. This method should be used for opening data inputs when multiple objectFromObjectStream() calls will be made before the stream is closed.

Parameters:
is - input stream
Returns:
ObjectInput to read from
Throws:
IOException

finishObjectInput

public void finishObjectInput(ObjectInput oi)
Description copied from interface: Marshaller
Finish using the given ObjectInput. After opening a ObjectInput and calling objectFromObjectStream() mutliple times, use this method to flush the data and close if necessary

Parameters:
oi - data input that finished using

objectFromObjectStream

public Object objectFromObjectStream(ObjectInput in)
                              throws IOException,
                                     ClassNotFoundException
Description copied from interface: Marshaller
Unmarshalls an object from an ObjectInput

Parameters:
in - stream to unmarshall from
Throws:
IOException
ClassNotFoundException

objectToByteBuffer

public byte[] objectToByteBuffer(Object obj)
                          throws IOException
Throws:
IOException

objectFromByteBuffer

public Object objectFromByteBuffer(byte[] buf)
                            throws IOException,
                                   ClassNotFoundException
Throws:
IOException
ClassNotFoundException


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