|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@ThreadSafe public interface Marshaller
A marshaller is a class that is able to marshall and unmarshall objects efficiently.
This interface is used to marshallReplicableCommand
s, their parameters and their
response values, as well as any other arbitraty Object <--> byte[] conversions, such as those used in client/server
communications.
The interface is also used by the CacheStore
framework to efficiently serialize data
to be persisted, as well as the StateTransferManager
when serializing the cache
for transferring state en-masse.
A single instance of any implementation is shared by multiple threads, so implementations need to be threadsafe,
and preferably immutable.
Method Summary | |
---|---|
boolean |
isMarshallable(Object o)
A method that checks whether the given object is marshallable as per the rules of this marshaller. |
Object |
objectFromByteBuffer(byte[] buf)
Unmarshalls an object from a byte array. |
Object |
objectFromByteBuffer(byte[] buf,
int offset,
int length)
Unmarshalls an object from a specific portion of a byte array. |
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)
Marshalls an object to a byte array. |
byte[] |
objectToByteBuffer(Object obj,
int estimatedSize)
Marshalls an object to a byte array. |
Method Detail |
---|
byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException, InterruptedException
obj
- object to convert to a byte array. Must not be null.estimatedSize
- an estimate of how large the resulting byte array may be
IOException
- if marshalling cannot complete due to some I/O error
InterruptedException
- if the marshalling was interrupted. Clients should take this as a sign that
the marshaller is no longer available, maybe due to shutdown, and so no more unmarshalling should be attempted.byte[] objectToByteBuffer(Object obj) throws IOException, InterruptedException
obj
- object to convert to a byte array. Must not be null.
IOException
- if marshalling cannot complete due to some I/O error
InterruptedException
- if the marshalling process was interrupted. Clients should take this as a sign that
the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.Object objectFromByteBuffer(byte[] buf) throws IOException, ClassNotFoundException
buf
- byte array containing the binary representation of an object. Must not be null.
IOException
- if unmarshalling cannot complete due to some I/O error
ClassNotFoundException
- if the class of the object trying to unmarshall is unknownObject objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException
buf
- byte array containing the binary representation of an object. Must not be null.offset
- point in buffer to start readinglength
- number of bytes to consider
IOException
- if unmarshalling cannot complete due to some I/O error
ClassNotFoundException
- if the class of the object trying to unmarshall is unknownByteBuffer objectToBuffer(Object o) throws IOException, InterruptedException
ByteBuffer
, which allows direct access to the byte
array with minimal array copying
o
- object to marshall
IOException
- if marshalling cannot complete due to some I/O error
InterruptedException
- if the marshalling process was interrupted. Clients should take this as a sign that
the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.boolean isMarshallable(Object o)
o
- object to verify whether it's marshallable or not
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |