public class ProtobufTranslationImpl extends Object implements ProtobufTranslation
ProtobufTranslationImpl that translates
protobuf requests to POJO requests.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ProtobufTranslationImpl.RequestTranslator
Encapsulate the logic of transforming a protobuf Request message into the Avatica POJO request.
|
(package private) static class |
ProtobufTranslationImpl.ResponseTranslator
Encapsulate the logic of transforming a protobuf Response message into the Avatica POJO
Response.
|
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOG |
private static Map<Class<?>,com.google.protobuf.ByteString> |
MESSAGE_CLASSES |
private static Map<String,ProtobufTranslationImpl.RequestTranslator> |
REQUEST_PARSERS |
private static Map<String,ProtobufTranslationImpl.ResponseTranslator> |
RESPONSE_PARSERS |
private ThreadLocal<UnsynchronizedBuffer> |
threadLocalBuffer |
| Constructor and Description |
|---|
ProtobufTranslationImpl() |
| Modifier and Type | Method and Description |
|---|---|
private static List<Class<?>> |
getAllMessageClasses() |
(package private) com.google.protobuf.ByteString |
getClassNameBytes(Class<?> clz) |
static ProtobufTranslationImpl.RequestTranslator |
getParserForRequest(String className)
Fetches the concrete message's Parser implementation.
|
static ProtobufTranslationImpl.ResponseTranslator |
getParserForResponse(String className)
Fetches the concrete message's Parser implementation.
|
Service.Request |
parseRequest(byte[] bytes)
Parses a serialized protocol buffer request into a
Service.Request. |
Service.Response |
parseResponse(byte[] bytes)
Parses a serialized protocol buffer response into a
Service.Response. |
(package private) void |
serializeMessage(OutputStream out,
com.google.protobuf.Message msg) |
byte[] |
serializeRequest(Service.Request request)
Serializes a
Service.Request as a protocol buffer. |
byte[] |
serializeResponse(Service.Response response)
Serializes a
Service.Response as a protocol buffer. |
private static com.google.protobuf.ByteString |
wrapClassName(Class<?> clz) |
private static final org.slf4j.Logger LOG
private static final Map<String,ProtobufTranslationImpl.RequestTranslator> REQUEST_PARSERS
private static final Map<String,ProtobufTranslationImpl.ResponseTranslator> RESPONSE_PARSERS
private final ThreadLocal<UnsynchronizedBuffer> threadLocalBuffer
private static com.google.protobuf.ByteString wrapClassName(Class<?> clz)
public static ProtobufTranslationImpl.RequestTranslator getParserForRequest(String className)
className - The protocol buffer class nameIllegalArgumentException - If the argument is null or if a Parser for the given
class name is not found.public static ProtobufTranslationImpl.ResponseTranslator getParserForResponse(String className)
className - The protocol buffer class nameIllegalArgumentException - If the argument is null or if a Parser for the given
class name is not found.public byte[] serializeResponse(Service.Response response) throws IOException
ProtobufTranslationService.Response as a protocol buffer.serializeResponse in interface ProtobufTranslationresponse - The response to serializeIOException - If there are errors during serializationpublic byte[] serializeRequest(Service.Request request) throws IOException
ProtobufTranslationService.Request as a protocol buffer.serializeRequest in interface ProtobufTranslationrequest - The request to serializeIOException - If there are errors during serializationvoid serializeMessage(OutputStream out, com.google.protobuf.Message msg) throws IOException
IOExceptioncom.google.protobuf.ByteString getClassNameBytes(Class<?> clz)
public Service.Request parseRequest(byte[] bytes) throws IOException
ProtobufTranslationService.Request.parseRequest in interface ProtobufTranslationbytes - Serialized protocol buffer request from clientIOException - If the protocol buffer cannot be deserializedpublic Service.Response parseResponse(byte[] bytes) throws IOException
ProtobufTranslationService.Response.parseResponse in interface ProtobufTranslationbytes - Serialized protocol buffer request from serverIOException - If the protocol buffer cannot be deserializedCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.