public class PersistenceMarshallerImpl extends Object implements PersistenceMarshaller
PersistenceMarshaller implementation that is responsible
for marshalling/unmarshalling objects which are to be persisted.
Known internal objects that are required by stores and loaders, such as EmbeddedMetadata,
are registered with this marshaller's SerializationContext so that they can be natively marshalled by the
underlying Protostream marshaller. If no entry exists in the SerializationContext for a given object, then
the marshalling of said object is delegated to a user marshaller if configured
(SerializationConfiguration.MARSHALLER) and the generated bytes are wrapped
in a MarshallableUserObject object and marshalled by ProtoStream.
| Constructor and Description |
|---|
PersistenceMarshallerImpl() |
| Modifier and Type | Method and Description |
|---|---|
BufferSizePredictor |
getBufferSizePredictor(Object o)
Returns a marshalled payload size predictor for a particular type.
|
org.infinispan.protostream.ImmutableSerializationContext |
getSerializationContext() |
Marshaller |
getUserMarshaller() |
boolean |
isMarshallable(Object o)
A method that checks whether the given object is marshallable as per the rules of this marshaller.
|
MediaType |
mediaType() |
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.
|
Object |
readObject(InputStream in)
Unmarshall an object from the
InputStream |
void |
register(org.infinispan.protostream.SerializationContextInitializer initializer)
Registers the schemas and marshallers defined by the provided
SerializationContextInitializer with the
PersistenceMarshaller's SerializationContext. |
int |
sizeEstimate(Object o)
An method that provides an estimate of the buffer size that will be required once the object has been marshalled.
|
void |
start()
Perform any initialization required before the marshaller is used.
|
void |
stop()
Stop the marshaller.
|
void |
writeObject(Object o,
OutputStream out)
Marshall an object to the
OutputStream |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitializepublic org.infinispan.protostream.ImmutableSerializationContext getSerializationContext()
public void start()
Marshallerstart in interface Marshallerpublic Marshaller getUserMarshaller()
getUserMarshaller in interface PersistenceMarshallerSerializationContext if one exists, otherwise the default
ProtoStream based marshaller is returned.public void register(org.infinispan.protostream.SerializationContextInitializer initializer)
PersistenceMarshallerSerializationContextInitializer with the
PersistenceMarshaller's SerializationContext.register in interface PersistenceMarshallerinitializer - whose schemas and marshallers' will be registered with the PersistenceMarshaller SerializationContextpublic void stop()
Marshallerstop in interface Marshallerpublic MediaType mediaType()
mediaType in interface MarshallermediaType in interface StreamAwareMarshallerMediaType associated with the content produced by the marshallerpublic ByteBuffer objectToBuffer(Object o)
MarshallerByteBuffer, which allows direct access to the byte
array with minimal array copyingobjectToBuffer in interface Marshallero - object to marshallpublic byte[] objectToByteBuffer(Object obj, int estimatedSize)
MarshallerobjectToByteBuffer in interface Marshallerobj - object to convert to a byte array. Must not be null.estimatedSize - an estimate of how large the resulting byte array may bepublic byte[] objectToByteBuffer(Object obj)
MarshallerobjectToByteBuffer in interface Marshallerobj - object to convert to a byte array. Must not be null.public Object objectFromByteBuffer(byte[] buf) throws IOException
MarshallerobjectFromByteBuffer in interface Marshallerbuf - byte array containing the binary representation of an object. Must not be null.IOException - if unmarshalling cannot complete due to some I/O errorpublic Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException
MarshallerobjectFromByteBuffer in interface Marshallerbuf - byte array containing the binary representation of an object. Must not be null.offset - point in buffer to start readinglength - number of bytes to considerIOException - if unmarshalling cannot complete due to some I/O errorpublic BufferSizePredictor getBufferSizePredictor(Object o)
MarshallergetBufferSizePredictor in interface Marshallero - Object for which serialized predictor will be returnedBufferSizePredictorpublic void writeObject(Object o, OutputStream out) throws IOException
StreamAwareMarshallerOutputStreamwriteObject in interface StreamAwareMarshallero - the object to write to the OutputStreamout - the OutputStream to write the object toIOException - if the object cannot be marshalled to the OutputStream due to some I/O errorpublic Object readObject(InputStream in) throws ClassNotFoundException, IOException
StreamAwareMarshallerInputStreamreadObject in interface StreamAwareMarshallerin - the InputStream to unmarshall an object fromClassNotFoundException - if the class of the object trying to unmarshall is not foundIOException - if unmarshalling cannot complete due to some I/O errorpublic boolean isMarshallable(Object o)
MarshallerisMarshallable in interface MarshallerisMarshallable in interface StreamAwareMarshallero - object to verify whether it's marshallable or notpublic int sizeEstimate(Object o)
StreamAwareMarshallersizeEstimate in interface StreamAwareMarshallero - instance that will be stored in the buffer.Copyright © 2022 JBoss by Red Hat. All rights reserved.