public class ProtobufTranslationImpl extends Object implements ProtobufTranslation
ProtobufTranslationImpl that translates
protobuf requests to POJO requests.| Modifier and Type | Field and Description |
|---|---|
private static Map<String,RequestTranslator> |
REQUEST_PARSERS |
private static Map<String,ResponseTranslator> |
RESPONSE_PARSERS |
| Constructor and Description |
|---|
ProtobufTranslationImpl() |
| Modifier and Type | Method and Description |
|---|---|
static RequestTranslator |
getParserForRequest(String className)
Fetches the concrete message's Parser implementation.
|
static 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 final Map<String,RequestTranslator> REQUEST_PARSERS
private static final Map<String,ResponseTranslator> RESPONSE_PARSERS
public static 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 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
IOExceptionpublic Service.Request parseRequest(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException
ProtobufTranslationService.Request.parseRequest in interface ProtobufTranslationbytes - Serialized protocol buffer request from clientcom.google.protobuf.InvalidProtocolBufferException - If the protocol buffer cannot be deserializedpublic Service.Response parseResponse(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException
ProtobufTranslationService.Response.parseResponse in interface ProtobufTranslationbytes - Serialized protocol buffer request from servercom.google.protobuf.InvalidProtocolBufferException - If the protocol buffer cannot be deserializedCopyright © 2012–2016 The Apache Software Foundation. All rights reserved.