Class PersistenceMarshallerImpl
- java.lang.Object
-
- org.infinispan.marshall.persistence.impl.PersistenceMarshallerImpl
-
- All Implemented Interfaces:
org.infinispan.commons.marshall.Marshaller,org.infinispan.commons.marshall.StreamAwareMarshaller,PersistenceMarshaller
public class PersistenceMarshallerImpl extends Object implements PersistenceMarshaller
A Protostream basedPersistenceMarshallerimplementation 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'sSerializationContextso that they can be natively marshalled by the underlying Protostream marshaller. If no entry exists in theSerializationContextfor 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 aMarshallableUserObjectobject and marshalled by ProtoStream.- Since:
- 10.0
- Author:
- Ryan Emerson
-
-
Constructor Summary
Constructors Constructor Description PersistenceMarshallerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.infinispan.commons.marshall.BufferSizePredictorgetBufferSizePredictor(Object o)org.infinispan.protostream.ImmutableSerializationContextgetSerializationContext()org.infinispan.commons.marshall.MarshallergetUserMarshaller()booleanisMarshallable(Object o)org.infinispan.commons.dataconversion.MediaTypemediaType()ObjectobjectFromByteBuffer(byte[] buf)ObjectobjectFromByteBuffer(byte[] buf, int offset, int length)org.infinispan.commons.io.ByteBufferobjectToBuffer(Object o)byte[]objectToByteBuffer(Object obj)byte[]objectToByteBuffer(Object obj, int estimatedSize)ObjectreadObject(InputStream in)voidregister(org.infinispan.protostream.SerializationContextInitializer initializer)Registers the schemas and marshallers defined by the providedSerializationContextInitializerwith thePersistenceMarshaller'sSerializationContext.intsizeEstimate(Object o)voidstart()voidstop()voidwriteObject(Object o, OutputStream out)
-
-
-
Method Detail
-
getSerializationContext
public org.infinispan.protostream.ImmutableSerializationContext getSerializationContext()
-
start
public void start()
- Specified by:
startin interfaceorg.infinispan.commons.marshall.Marshaller
-
getUserMarshaller
public org.infinispan.commons.marshall.Marshaller getUserMarshaller()
- Specified by:
getUserMarshallerin interfacePersistenceMarshaller- Returns:
- a custom marshaller configured by
SerializationContextif one exists, otherwise the default ProtoStream based marshaller is returned.
-
register
public void register(org.infinispan.protostream.SerializationContextInitializer initializer)
Description copied from interface:PersistenceMarshallerRegisters the schemas and marshallers defined by the providedSerializationContextInitializerwith thePersistenceMarshaller'sSerializationContext.- Specified by:
registerin interfacePersistenceMarshaller- Parameters:
initializer- whose schemas and marshallers' will be registered with thePersistenceMarshallerSerializationContext
-
stop
public void stop()
- Specified by:
stopin interfaceorg.infinispan.commons.marshall.Marshaller
-
mediaType
public org.infinispan.commons.dataconversion.MediaType mediaType()
- Specified by:
mediaTypein interfaceorg.infinispan.commons.marshall.Marshaller- Specified by:
mediaTypein interfaceorg.infinispan.commons.marshall.StreamAwareMarshaller
-
objectToBuffer
public org.infinispan.commons.io.ByteBuffer objectToBuffer(Object o)
- Specified by:
objectToBufferin interfaceorg.infinispan.commons.marshall.Marshaller
-
objectToByteBuffer
public byte[] objectToByteBuffer(Object obj, int estimatedSize)
- Specified by:
objectToByteBufferin interfaceorg.infinispan.commons.marshall.Marshaller
-
objectToByteBuffer
public byte[] objectToByteBuffer(Object obj)
- Specified by:
objectToByteBufferin interfaceorg.infinispan.commons.marshall.Marshaller
-
objectFromByteBuffer
public Object objectFromByteBuffer(byte[] buf) throws IOException
- Specified by:
objectFromByteBufferin interfaceorg.infinispan.commons.marshall.Marshaller- Throws:
IOException
-
objectFromByteBuffer
public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException
- Specified by:
objectFromByteBufferin interfaceorg.infinispan.commons.marshall.Marshaller- Throws:
IOException
-
getBufferSizePredictor
public org.infinispan.commons.marshall.BufferSizePredictor getBufferSizePredictor(Object o)
- Specified by:
getBufferSizePredictorin interfaceorg.infinispan.commons.marshall.Marshaller
-
writeObject
public void writeObject(Object o, OutputStream out) throws IOException
- Specified by:
writeObjectin interfaceorg.infinispan.commons.marshall.StreamAwareMarshaller- Throws:
IOException
-
readObject
public Object readObject(InputStream in) throws ClassNotFoundException, IOException
- Specified by:
readObjectin interfaceorg.infinispan.commons.marshall.StreamAwareMarshaller- Throws:
ClassNotFoundExceptionIOException
-
isMarshallable
public boolean isMarshallable(Object o)
- Specified by:
isMarshallablein interfaceorg.infinispan.commons.marshall.Marshaller- Specified by:
isMarshallablein interfaceorg.infinispan.commons.marshall.StreamAwareMarshaller
-
sizeEstimate
public int sizeEstimate(Object o)
- Specified by:
sizeEstimatein interfaceorg.infinispan.commons.marshall.StreamAwareMarshaller
-
-