Interface MessageSerializer<M>
-
- All Known Subinterfaces:
MessageTextSerializer<M>
- All Known Implementing Classes:
AbstractGraphSONMessageSerializerV1d0
,AbstractGraphSONMessageSerializerV2d0
,AbstractMessageSerializer
,GraphBinaryMessageSerializerV1
,GraphSONMessageSerializerGremlinV1d0
,GraphSONMessageSerializerGremlinV2d0
,GraphSONMessageSerializerV1d0
,GraphSONMessageSerializerV2d0
,GraphSONMessageSerializerV3d0
,GraphSONUntypedMessageSerializerV1d0
,GraphSONUntypedMessageSerializerV2d0
,TextPlainMessageSerializer
public interface MessageSerializer<M>
Serializes data to and from Gremlin Server. Typically, the object being serialized or deserialized will be an item from anIterator
as returned from theScriptEngine
or an incomingRequestMessage
.MessageSerializer
instances are instantiated to a cache viaServiceLoader
and indexed based on the mime types they support. If a mime type is supported more than once, the firstMessageSerializer
instance loaded for that mime type is assigned. If a mime type is not found the server default is chosen. The default may change from version to version so it is best to not rely on it when developing applications and to always be explicit in specifying the type you wish to bind to.- Author:
- Stephen Mallette (http://stephen.genoprime.com)
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
logger
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
configure(Map<String,Object> config, Map<String,Graph> graphs)
Configure the serializer with mapper settings as required.RequestMessage
deserializeRequest(io.netty.buffer.ByteBuf msg)
Deserialize a NettyByteBuf
into aRequestMessage
.ResponseMessage
deserializeResponse(io.netty.buffer.ByteBuf msg)
Deserialize a NettyByteBuf
into aResponseMessage
.M
getMapper()
Gets the "mapper" that performs the underlying serialization work.String[]
mimeTypesSupported()
The list of mime types that the serializer supports.io.netty.buffer.ByteBuf
serializeRequestAsBinary(RequestMessage requestMessage, io.netty.buffer.ByteBufAllocator allocator)
Serialize aResponseMessage
to a NettyByteBuf
.io.netty.buffer.ByteBuf
serializeResponseAsBinary(ResponseMessage responseMessage, io.netty.buffer.ByteBufAllocator allocator)
Serialize aResponseMessage
to a NettyByteBuf
.
-
-
-
Method Detail
-
getMapper
M getMapper()
Gets the "mapper" that performs the underlying serialization work.
-
serializeResponseAsBinary
io.netty.buffer.ByteBuf serializeResponseAsBinary(ResponseMessage responseMessage, io.netty.buffer.ByteBufAllocator allocator) throws SerializationException
Serialize aResponseMessage
to a NettyByteBuf
.- Parameters:
responseMessage
- The response message to serialize to bytes.allocator
- The Netty allocator for theByteBuf
to return back.- Throws:
SerializationException
-
serializeRequestAsBinary
io.netty.buffer.ByteBuf serializeRequestAsBinary(RequestMessage requestMessage, io.netty.buffer.ByteBufAllocator allocator) throws SerializationException
Serialize aResponseMessage
to a NettyByteBuf
.- Parameters:
requestMessage
- The request message to serialize to bytes.allocator
- The Netty allocator for theByteBuf
to return back.- Throws:
SerializationException
-
deserializeRequest
RequestMessage deserializeRequest(io.netty.buffer.ByteBuf msg) throws SerializationException
Deserialize a NettyByteBuf
into aRequestMessage
.- Throws:
SerializationException
-
deserializeResponse
ResponseMessage deserializeResponse(io.netty.buffer.ByteBuf msg) throws SerializationException
Deserialize a NettyByteBuf
into aResponseMessage
.- Throws:
SerializationException
-
mimeTypesSupported
String[] mimeTypesSupported()
The list of mime types that the serializer supports.
-
configure
default void configure(Map<String,Object> config, Map<String,Graph> graphs)
Configure the serializer with mapper settings as required. The default implementation does not perform any function and it is up to the interface implementation to determine how the configuration will be executed and what its requirements are. An implementation may choose to use the list of available graphs to help initialize a serializer. The implementation should account for the possibility of a null value being provided for that parameter.
-
-