org.infinispan.marshall
Class MarshallerImpl

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

public class MarshallerImpl
extends AbstractMarshaller

Abstract marshaller

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

Field Summary
protected  ClassLoader defaultClassLoader
           
protected  Log log
           
protected static int MAGICNUMBER_ARRAY
           
protected static int MAGICNUMBER_ARRAY_LIST
           
protected static int MAGICNUMBER_BOOLEAN
           
protected static int MAGICNUMBER_BYTE
           
protected static int MAGICNUMBER_CACHESTORE_BUCKET
           
protected static int MAGICNUMBER_CHAR
           
protected static int MAGICNUMBER_COMMAND
           
protected static int MAGICNUMBER_DOUBLE
           
protected static int MAGICNUMBER_EXCEPTION_RESPONSE
           
protected static int MAGICNUMBER_EXTENDED_RESPONSE
           
protected static int MAGICNUMBER_FASTCOPY_HASHMAP
           
protected static int MAGICNUMBER_FLOAT
           
protected static int MAGICNUMBER_GTX
           
protected static int MAGICNUMBER_HASH_MAP
           
protected static int MAGICNUMBER_HASH_SET
           
protected static int MAGICNUMBER_ICE_IMMORTAL
           
protected static int MAGICNUMBER_ICE_MORTAL
           
protected static int MAGICNUMBER_ICE_TRANSIENT
           
protected static int MAGICNUMBER_ICE_TRANSIENT_MORTAL
           
protected static int MAGICNUMBER_ICV_IMMORTAL
           
protected static int MAGICNUMBER_ICV_MORTAL
           
protected static int MAGICNUMBER_ICV_TRANSIENT
           
protected static int MAGICNUMBER_ICV_TRANSIENT_MORTAL
           
protected static int MAGICNUMBER_IMMUTABLE_MAPCOPY
           
protected static int MAGICNUMBER_INTEGER
           
protected static int MAGICNUMBER_JG_ADDRESS
           
protected static int MAGICNUMBER_LINKED_LIST
           
protected static int MAGICNUMBER_LONG
           
protected static int MAGICNUMBER_MARSHALLEDVALUE
           
protected static int MAGICNUMBER_NULL
           
protected static int MAGICNUMBER_OBJECT
           
protected static int MAGICNUMBER_REF
           
protected static int MAGICNUMBER_REQUEST_IGNORED_RESPONSE
           
protected static int MAGICNUMBER_SERIALIZABLE
           
protected static int MAGICNUMBER_SHORT
           
protected static int MAGICNUMBER_SINGLETON_LIST
           
protected static int MAGICNUMBER_STRING
           
protected static int MAGICNUMBER_SUCCESSFUL_RESPONSE
           
protected static int MAGICNUMBER_TRANSACTION_LOG
           
protected static int MAGICNUMBER_TREE_MAP
           
protected static int MAGICNUMBER_TREE_SET
           
protected static int MAGICNUMBER_UNSUCCESSFUL_RESPONSE
           
protected  boolean trace
           
protected  boolean useRefs
           
 
Constructor Summary
MarshallerImpl()
           
 
Method Summary
 void finishObjectInput(ObjectInput oi)
          Finish using the given ObjectInput.
 void finishObjectOutput(ObjectOutput oo)
          Finish using the given ObjectOutput.
 void init(ClassLoader defaultClassLoader, RemoteCommandFactory remoteCommandFactory)
           
protected  void initLogger()
           
protected  boolean isKnownType(Class c)
           
protected  void marshallArray(Object o, ObjectOutput out, Map<Object,Integer> refMap)
           
protected  void marshallObject(Object o, ObjectOutput out, Map<Object,Integer> refMap)
           
protected  void marshallString(String s, ObjectOutput out)
           
 Object objectFromByteBuffer(byte[] bytes)
           
 Object objectFromByteBuffer(byte[] buf, int offset, int length)
           
 Object objectFromObjectStream(ObjectInput in)
          Unmarshalls an object from an ObjectInput
 ByteBuffer objectToBuffer(Object o)
          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 o, ObjectOutput out)
          Marshalls an object to a given ObjectOutput
protected  int readReference(ObjectInput in)
          This version of readReference is written to solve JBCACHE-1211, where references are encoded as ints rather than shorts.
 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.
protected  Object unmarshallArray(ObjectInput in, UnmarshalledReferences refs)
           
protected  Object unmarshallObject(ObjectInput in, ClassLoader loader, UnmarshalledReferences refMap, boolean overrideContextClassloaderOnThread)
           
protected  Object unmarshallObject(ObjectInput in, UnmarshalledReferences refMap)
           
protected  String unmarshallString(ObjectInput in)
           
protected  void writeReference(ObjectOutput out, int reference)
          This version of writeReference is written to solve JBCACHE-1211, where references are encoded as ints rather than shorts.
 
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
 

Field Detail

MAGICNUMBER_GTX

protected static final int MAGICNUMBER_GTX
See Also:
Constant Field Values

MAGICNUMBER_JG_ADDRESS

protected static final int MAGICNUMBER_JG_ADDRESS
See Also:
Constant Field Values

MAGICNUMBER_ARRAY_LIST

protected static final int MAGICNUMBER_ARRAY_LIST
See Also:
Constant Field Values

MAGICNUMBER_INTEGER

protected static final int MAGICNUMBER_INTEGER
See Also:
Constant Field Values

MAGICNUMBER_LONG

protected static final int MAGICNUMBER_LONG
See Also:
Constant Field Values

MAGICNUMBER_BOOLEAN

protected static final int MAGICNUMBER_BOOLEAN
See Also:
Constant Field Values

MAGICNUMBER_STRING

protected static final int MAGICNUMBER_STRING
See Also:
Constant Field Values

MAGICNUMBER_LINKED_LIST

protected static final int MAGICNUMBER_LINKED_LIST
See Also:
Constant Field Values

MAGICNUMBER_HASH_MAP

protected static final int MAGICNUMBER_HASH_MAP
See Also:
Constant Field Values

MAGICNUMBER_TREE_MAP

protected static final int MAGICNUMBER_TREE_MAP
See Also:
Constant Field Values

MAGICNUMBER_HASH_SET

protected static final int MAGICNUMBER_HASH_SET
See Also:
Constant Field Values

MAGICNUMBER_TREE_SET

protected static final int MAGICNUMBER_TREE_SET
See Also:
Constant Field Values

MAGICNUMBER_SHORT

protected static final int MAGICNUMBER_SHORT
See Also:
Constant Field Values

MAGICNUMBER_IMMUTABLE_MAPCOPY

protected static final int MAGICNUMBER_IMMUTABLE_MAPCOPY
See Also:
Constant Field Values

MAGICNUMBER_MARSHALLEDVALUE

protected static final int MAGICNUMBER_MARSHALLEDVALUE
See Also:
Constant Field Values

MAGICNUMBER_FASTCOPY_HASHMAP

protected static final int MAGICNUMBER_FASTCOPY_HASHMAP
See Also:
Constant Field Values

MAGICNUMBER_ARRAY

protected static final int MAGICNUMBER_ARRAY
See Also:
Constant Field Values

MAGICNUMBER_BYTE

protected static final int MAGICNUMBER_BYTE
See Also:
Constant Field Values

MAGICNUMBER_CHAR

protected static final int MAGICNUMBER_CHAR
See Also:
Constant Field Values

MAGICNUMBER_FLOAT

protected static final int MAGICNUMBER_FLOAT
See Also:
Constant Field Values

MAGICNUMBER_DOUBLE

protected static final int MAGICNUMBER_DOUBLE
See Also:
Constant Field Values

MAGICNUMBER_OBJECT

protected static final int MAGICNUMBER_OBJECT
See Also:
Constant Field Values

MAGICNUMBER_SINGLETON_LIST

protected static final int MAGICNUMBER_SINGLETON_LIST
See Also:
Constant Field Values

MAGICNUMBER_COMMAND

protected static final int MAGICNUMBER_COMMAND
See Also:
Constant Field Values

MAGICNUMBER_TRANSACTION_LOG

protected static final int MAGICNUMBER_TRANSACTION_LOG
See Also:
Constant Field Values

MAGICNUMBER_ICE_IMMORTAL

protected static final int MAGICNUMBER_ICE_IMMORTAL
See Also:
Constant Field Values

MAGICNUMBER_ICE_MORTAL

protected static final int MAGICNUMBER_ICE_MORTAL
See Also:
Constant Field Values

MAGICNUMBER_ICE_TRANSIENT

protected static final int MAGICNUMBER_ICE_TRANSIENT
See Also:
Constant Field Values

MAGICNUMBER_ICE_TRANSIENT_MORTAL

protected static final int MAGICNUMBER_ICE_TRANSIENT_MORTAL
See Also:
Constant Field Values

MAGICNUMBER_ICV_IMMORTAL

protected static final int MAGICNUMBER_ICV_IMMORTAL
See Also:
Constant Field Values

MAGICNUMBER_ICV_MORTAL

protected static final int MAGICNUMBER_ICV_MORTAL
See Also:
Constant Field Values

MAGICNUMBER_ICV_TRANSIENT

protected static final int MAGICNUMBER_ICV_TRANSIENT
See Also:
Constant Field Values

MAGICNUMBER_ICV_TRANSIENT_MORTAL

protected static final int MAGICNUMBER_ICV_TRANSIENT_MORTAL
See Also:
Constant Field Values

MAGICNUMBER_REQUEST_IGNORED_RESPONSE

protected static final int MAGICNUMBER_REQUEST_IGNORED_RESPONSE
See Also:
Constant Field Values

MAGICNUMBER_EXTENDED_RESPONSE

protected static final int MAGICNUMBER_EXTENDED_RESPONSE
See Also:
Constant Field Values

MAGICNUMBER_EXCEPTION_RESPONSE

protected static final int MAGICNUMBER_EXCEPTION_RESPONSE
See Also:
Constant Field Values

MAGICNUMBER_SUCCESSFUL_RESPONSE

protected static final int MAGICNUMBER_SUCCESSFUL_RESPONSE
See Also:
Constant Field Values

MAGICNUMBER_UNSUCCESSFUL_RESPONSE

protected static final int MAGICNUMBER_UNSUCCESSFUL_RESPONSE
See Also:
Constant Field Values

MAGICNUMBER_CACHESTORE_BUCKET

protected static final int MAGICNUMBER_CACHESTORE_BUCKET
See Also:
Constant Field Values

MAGICNUMBER_NULL

protected static final int MAGICNUMBER_NULL
See Also:
Constant Field Values

MAGICNUMBER_SERIALIZABLE

protected static final int MAGICNUMBER_SERIALIZABLE
See Also:
Constant Field Values

MAGICNUMBER_REF

protected static final int MAGICNUMBER_REF
See Also:
Constant Field Values

log

protected Log log

trace

protected boolean trace

defaultClassLoader

protected ClassLoader defaultClassLoader

useRefs

protected boolean useRefs
Constructor Detail

MarshallerImpl

public MarshallerImpl()
Method Detail

init

public void init(ClassLoader defaultClassLoader,
                 RemoteCommandFactory remoteCommandFactory)

initLogger

protected void initLogger()

objectToByteBuffer

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

marshallObject

protected void marshallObject(Object o,
                              ObjectOutput out,
                              Map<Object,Integer> refMap)
                       throws IOException
Throws:
IOException

marshallString

protected void marshallString(String s,
                              ObjectOutput out)
                       throws IOException
Throws:
IOException

unmarshallObject

protected Object unmarshallObject(ObjectInput in,
                                  ClassLoader loader,
                                  UnmarshalledReferences refMap,
                                  boolean overrideContextClassloaderOnThread)
                           throws IOException,
                                  ClassNotFoundException
Throws:
IOException
ClassNotFoundException

unmarshallObject

protected Object unmarshallObject(ObjectInput in,
                                  UnmarshalledReferences refMap)
                           throws IOException,
                                  ClassNotFoundException
Throws:
IOException
ClassNotFoundException

unmarshallString

protected String unmarshallString(ObjectInput in)
                           throws IOException,
                                  ClassNotFoundException
Throws:
IOException
ClassNotFoundException

writeReference

protected void writeReference(ObjectOutput out,
                              int reference)
                       throws IOException
This version of writeReference is written to solve JBCACHE-1211, where references are encoded as ints rather than shorts.

Parameters:
out - stream to write to
reference - reference to write
Throws:
IOException - propagated from OOS
See Also:
JBCACHE-1211

readReference

protected int readReference(ObjectInput in)
                     throws IOException
This version of readReference is written to solve JBCACHE-1211, where references are encoded as ints rather than shorts.

Parameters:
in - stream to read from
Returns:
reference
Throws:
IOException - propagated from OUS
See Also:
JBCACHE-1211

unmarshallArray

protected Object unmarshallArray(ObjectInput in,
                                 UnmarshalledReferences refs)
                          throws IOException,
                                 ClassNotFoundException
Throws:
IOException
ClassNotFoundException

marshallArray

protected void marshallArray(Object o,
                             ObjectOutput out,
                             Map<Object,Integer> refMap)
                      throws IOException
Throws:
IOException

isKnownType

protected boolean isKnownType(Class c)

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 o,
                                 ObjectOutput out)
                          throws IOException
Description copied from interface: Marshaller
Marshalls an object to a given ObjectOutput

Parameters:
o - 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

objectToBuffer

public ByteBuffer objectToBuffer(Object o)
                          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:
o - object to marshall
Returns:
a ByteBuffer
Throws:
IOException

objectFromByteBuffer

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

objectFromByteBuffer

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


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