Package org.infinispan.commons.marshall
Class ProtoStreamMarshaller
- java.lang.Object
-
- org.infinispan.commons.marshall.AbstractMarshaller
-
- org.infinispan.commons.marshall.ProtoStreamMarshaller
-
- All Implemented Interfaces:
Marshaller
- Direct Known Subclasses:
ProtoStreamMarshaller
public class ProtoStreamMarshaller extends AbstractMarshaller
Provides the starting point for implementing aMarshallerthat uses Protobuf encoding.- Since:
- 6.0
- Author:
- anistor@redhat.com
-
-
Field Summary
-
Fields inherited from class org.infinispan.commons.marshall.AbstractMarshaller
marshallableTypeHints
-
-
Constructor Summary
Constructors Constructor Description ProtoStreamMarshaller()ProtoStreamMarshaller(org.infinispan.protostream.SerializationContext serializationContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.infinispan.protostream.SerializationContextgetSerializationContext()booleanisMarshallable(java.lang.Object o)A method that checks whether the given object is marshallable as per the rules of this marshaller.MediaTypemediaType()java.lang.ObjectobjectFromByteBuffer(byte[] buf, int offset, int length)Unmarshalls an object from a specific portion of a byte array.protected ByteBufferobjectToBuffer(java.lang.Object o, int estimatedSize)This is a convenience method for converting an object into aByteBufferwhich takes an estimated size as parameter.voidregister(org.infinispan.protostream.SerializationContextInitializer initializer)-
Methods inherited from class org.infinispan.commons.marshall.AbstractMarshaller
getBufferSizePredictor, objectFromByteBuffer, objectFromInputStream, objectToBuffer, objectToByteBuffer, objectToByteBuffer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.commons.marshall.Marshaller
initialize, start, stop
-
-
-
-
Method Detail
-
register
public void register(org.infinispan.protostream.SerializationContextInitializer initializer)
-
getSerializationContext
public org.infinispan.protostream.SerializationContext getSerializationContext()
- Returns:
- the SerializationContext instance to use
-
objectFromByteBuffer
public java.lang.Object objectFromByteBuffer(byte[] buf, int offset, int length) throws java.io.IOException, java.lang.ClassNotFoundExceptionDescription copied from interface:MarshallerUnmarshalls an object from a specific portion of a byte array.- Parameters:
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- Returns:
- an object
- Throws:
java.io.IOException- if unmarshalling cannot complete due to some I/O errorjava.lang.ClassNotFoundException- if the class of the object trying to unmarshall is unknown
-
isMarshallable
public boolean isMarshallable(java.lang.Object o)
Description copied from interface:MarshallerA method that checks whether the given object is marshallable as per the rules of this marshaller.- Parameters:
o- object to verify whether it's marshallable or not- Returns:
- true if the object is marshallable, otherwise false
-
objectToBuffer
protected ByteBuffer objectToBuffer(java.lang.Object o, int estimatedSize) throws java.io.IOException, java.lang.InterruptedException
Description copied from class:AbstractMarshallerThis is a convenience method for converting an object into aByteBufferwhich takes an estimated size as parameter. AByteBufferallows direct access to the byte array with minimal array copying- Specified by:
objectToBufferin classAbstractMarshaller- Parameters:
o- object to marshallestimatedSize- an estimate of how large the resulting byte array may be- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
-