Class PersistenceMarshallerImpl

  • All Implemented Interfaces:
    org.infinispan.commons.marshall.Marshaller, org.infinispan.commons.marshall.StreamAwareMarshaller, PersistenceMarshaller

    public class PersistenceMarshallerImpl
    extends Object
    implements PersistenceMarshaller
    A Protostream based 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.

    Since:
    10.0
    Author:
    Ryan Emerson
    • Constructor Detail

      • PersistenceMarshallerImpl

        public PersistenceMarshallerImpl()
    • Method Detail

      • getSerializationContext

        public org.infinispan.protostream.ImmutableSerializationContext getSerializationContext()
      • start

        public void start()
        Specified by:
        start in interface org.infinispan.commons.marshall.Marshaller
      • getUserMarshaller

        public org.infinispan.commons.marshall.Marshaller getUserMarshaller()
        Specified by:
        getUserMarshaller in interface PersistenceMarshaller
        Returns:
        a custom marshaller configured by SerializationContext if one exists, otherwise the default ProtoStream based marshaller is returned.
      • register

        public void register​(org.infinispan.protostream.SerializationContextInitializer initializer)
        Description copied from interface: PersistenceMarshaller
        Registers the schemas and marshallers defined by the provided SerializationContextInitializer with the PersistenceMarshaller's SerializationContext.
        Specified by:
        register in interface PersistenceMarshaller
        Parameters:
        initializer - whose schemas and marshallers' will be registered with the PersistenceMarshaller SerializationContext
      • stop

        public void stop()
        Specified by:
        stop in interface org.infinispan.commons.marshall.Marshaller
      • mediaType

        public org.infinispan.commons.dataconversion.MediaType mediaType()
        Specified by:
        mediaType in interface org.infinispan.commons.marshall.Marshaller
        Specified by:
        mediaType in interface org.infinispan.commons.marshall.StreamAwareMarshaller
      • objectToBuffer

        public org.infinispan.commons.io.ByteBuffer objectToBuffer​(Object o)
        Specified by:
        objectToBuffer in interface org.infinispan.commons.marshall.Marshaller
      • objectToByteBuffer

        public byte[] objectToByteBuffer​(Object obj,
                                         int estimatedSize)
        Specified by:
        objectToByteBuffer in interface org.infinispan.commons.marshall.Marshaller
      • objectToByteBuffer

        public byte[] objectToByteBuffer​(Object obj)
        Specified by:
        objectToByteBuffer in interface org.infinispan.commons.marshall.Marshaller
      • objectFromByteBuffer

        public Object objectFromByteBuffer​(byte[] buf)
                                    throws IOException
        Specified by:
        objectFromByteBuffer in interface org.infinispan.commons.marshall.Marshaller
        Throws:
        IOException
      • objectFromByteBuffer

        public Object objectFromByteBuffer​(byte[] buf,
                                           int offset,
                                           int length)
                                    throws IOException
        Specified by:
        objectFromByteBuffer in interface org.infinispan.commons.marshall.Marshaller
        Throws:
        IOException
      • getBufferSizePredictor

        public org.infinispan.commons.marshall.BufferSizePredictor getBufferSizePredictor​(Object o)
        Specified by:
        getBufferSizePredictor in interface org.infinispan.commons.marshall.Marshaller
      • writeObject

        public void writeObject​(Object o,
                                OutputStream out)
                         throws IOException
        Specified by:
        writeObject in interface org.infinispan.commons.marshall.StreamAwareMarshaller
        Throws:
        IOException
      • isMarshallable

        public boolean isMarshallable​(Object o)
        Specified by:
        isMarshallable in interface org.infinispan.commons.marshall.Marshaller
        Specified by:
        isMarshallable in interface org.infinispan.commons.marshall.StreamAwareMarshaller
      • sizeEstimate

        public int sizeEstimate​(Object o)
        Specified by:
        sizeEstimate in interface org.infinispan.commons.marshall.StreamAwareMarshaller