summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-28 09:50:34 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-28 09:51:44 +0200
commitcecb501245bb7d93b2e4c55acb783958b158f637 (patch)
tree062df29385005c2a040beb6f326a149d73dd9bc6
parentcb5e96d0106ed968640c11f7a0162d7ce25d4eaf (diff)
Support very simple serving.
– Not asynchronous at this point. – Not well-tested.
-rw-r--r--src/main/java/com/orbekk/protobuf/Rpc.java202
-rw-r--r--src/main/java/com/orbekk/protobuf/Rpc.proto9
-rw-r--r--src/main/java/com/orbekk/protobuf/SimpleProtobufClient.java3
-rw-r--r--src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java79
-rw-r--r--src/main/java/com/orbekk/protobuf/Test.java1035
-rw-r--r--src/main/java/com/orbekk/protobuf/Test.proto15
6 files changed, 1304 insertions, 39 deletions
diff --git a/src/main/java/com/orbekk/protobuf/Rpc.java b/src/main/java/com/orbekk/protobuf/Rpc.java
index 2748329..c74e48a 100644
--- a/src/main/java/com/orbekk/protobuf/Rpc.java
+++ b/src/main/java/com/orbekk/protobuf/Rpc.java
@@ -542,9 +542,13 @@ public final class Rpc {
boolean hasResponseProto();
com.google.protobuf.ByteString getResponseProto();
- // optional int32 error = 2 [default = 0];
+ // optional .com.orbekk.protobuf.Response.Error error = 2;
boolean hasError();
- int getError();
+ com.orbekk.protobuf.Rpc.Response.Error getError();
+
+ // optional int32 app_error = 4;
+ boolean hasAppError();
+ int getAppError();
// optional string error_message = 3;
boolean hasErrorMessage();
@@ -578,6 +582,81 @@ public final class Rpc {
return com.orbekk.protobuf.Rpc.internal_static_com_orbekk_protobuf_Response_fieldAccessorTable;
}
+ public enum Error
+ implements com.google.protobuf.ProtocolMessageEnum {
+ UNKNOWN_SERVICE(0, 0),
+ UNKNOWN_METHOD(1, 1),
+ CANCELED(2, 2),
+ APP_ERROR(3, 3),
+ ;
+
+ public static final int UNKNOWN_SERVICE_VALUE = 0;
+ public static final int UNKNOWN_METHOD_VALUE = 1;
+ public static final int CANCELED_VALUE = 2;
+ public static final int APP_ERROR_VALUE = 3;
+
+
+ public final int getNumber() { return value; }
+
+ public static Error valueOf(int value) {
+ switch (value) {
+ case 0: return UNKNOWN_SERVICE;
+ case 1: return UNKNOWN_METHOD;
+ case 2: return CANCELED;
+ case 3: return APP_ERROR;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap<Error>
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static com.google.protobuf.Internal.EnumLiteMap<Error>
+ internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap<Error>() {
+ public Error findValueByNumber(int number) {
+ return Error.valueOf(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(index);
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Rpc.Response.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final Error[] VALUES = {
+ UNKNOWN_SERVICE, UNKNOWN_METHOD, CANCELED, APP_ERROR,
+ };
+
+ public static Error valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int index;
+ private final int value;
+
+ private Error(int index, int value) {
+ this.index = index;
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:com.orbekk.protobuf.Response.Error)
+ }
+
private int bitField0_;
// optional bytes response_proto = 1;
public static final int RESPONSE_PROTO_FIELD_NUMBER = 1;
@@ -589,21 +668,31 @@ public final class Rpc {
return responseProto_;
}
- // optional int32 error = 2 [default = 0];
+ // optional .com.orbekk.protobuf.Response.Error error = 2;
public static final int ERROR_FIELD_NUMBER = 2;
- private int error_;
+ private com.orbekk.protobuf.Rpc.Response.Error error_;
public boolean hasError() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
- public int getError() {
+ public com.orbekk.protobuf.Rpc.Response.Error getError() {
return error_;
}
+ // optional int32 app_error = 4;
+ public static final int APP_ERROR_FIELD_NUMBER = 4;
+ private int appError_;
+ public boolean hasAppError() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public int getAppError() {
+ return appError_;
+ }
+
// optional string error_message = 3;
public static final int ERROR_MESSAGE_FIELD_NUMBER = 3;
private Object errorMessage_;
public boolean hasErrorMessage() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ return ((bitField0_ & 0x00000008) == 0x00000008);
}
public String getErrorMessage() {
Object ref = errorMessage_;
@@ -633,7 +722,8 @@ public final class Rpc {
private void initFields() {
responseProto_ = com.google.protobuf.ByteString.EMPTY;
- error_ = 0;
+ error_ = com.orbekk.protobuf.Rpc.Response.Error.UNKNOWN_SERVICE;
+ appError_ = 0;
errorMessage_ = "";
}
private byte memoizedIsInitialized = -1;
@@ -652,11 +742,14 @@ public final class Rpc {
output.writeBytes(1, responseProto_);
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
- output.writeInt32(2, error_);
+ output.writeEnum(2, error_.getNumber());
}
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeBytes(3, getErrorMessageBytes());
}
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeInt32(4, appError_);
+ }
getUnknownFields().writeTo(output);
}
@@ -672,12 +765,16 @@ public final class Rpc {
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(2, error_);
+ .computeEnumSize(2, error_.getNumber());
}
- if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, getErrorMessageBytes());
}
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(4, appError_);
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -802,10 +899,12 @@ public final class Rpc {
super.clear();
responseProto_ = com.google.protobuf.ByteString.EMPTY;
bitField0_ = (bitField0_ & ~0x00000001);
- error_ = 0;
+ error_ = com.orbekk.protobuf.Rpc.Response.Error.UNKNOWN_SERVICE;
bitField0_ = (bitField0_ & ~0x00000002);
- errorMessage_ = "";
+ appError_ = 0;
bitField0_ = (bitField0_ & ~0x00000004);
+ errorMessage_ = "";
+ bitField0_ = (bitField0_ & ~0x00000008);
return this;
}
@@ -855,6 +954,10 @@ public final class Rpc {
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000004;
}
+ result.appError_ = appError_;
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000008;
+ }
result.errorMessage_ = errorMessage_;
result.bitField0_ = to_bitField0_;
onBuilt();
@@ -878,6 +981,9 @@ public final class Rpc {
if (other.hasError()) {
setError(other.getError());
}
+ if (other.hasAppError()) {
+ setAppError(other.getAppError());
+ }
if (other.hasErrorMessage()) {
setErrorMessage(other.getErrorMessage());
}
@@ -918,15 +1024,26 @@ public final class Rpc {
break;
}
case 16: {
- bitField0_ |= 0x00000002;
- error_ = input.readInt32();
+ int rawValue = input.readEnum();
+ com.orbekk.protobuf.Rpc.Response.Error value = com.orbekk.protobuf.Rpc.Response.Error.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(2, rawValue);
+ } else {
+ bitField0_ |= 0x00000002;
+ error_ = value;
+ }
break;
}
case 26: {
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000008;
errorMessage_ = input.readBytes();
break;
}
+ case 32: {
+ bitField0_ |= 0x00000004;
+ appError_ = input.readInt32();
+ break;
+ }
}
}
}
@@ -957,15 +1074,18 @@ public final class Rpc {
return this;
}
- // optional int32 error = 2 [default = 0];
- private int error_ ;
+ // optional .com.orbekk.protobuf.Response.Error error = 2;
+ private com.orbekk.protobuf.Rpc.Response.Error error_ = com.orbekk.protobuf.Rpc.Response.Error.UNKNOWN_SERVICE;
public boolean hasError() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
- public int getError() {
+ public com.orbekk.protobuf.Rpc.Response.Error getError() {
return error_;
}
- public Builder setError(int value) {
+ public Builder setError(com.orbekk.protobuf.Rpc.Response.Error value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
bitField0_ |= 0x00000002;
error_ = value;
onChanged();
@@ -973,7 +1093,28 @@ public final class Rpc {
}
public Builder clearError() {
bitField0_ = (bitField0_ & ~0x00000002);
- error_ = 0;
+ error_ = com.orbekk.protobuf.Rpc.Response.Error.UNKNOWN_SERVICE;
+ onChanged();
+ return this;
+ }
+
+ // optional int32 app_error = 4;
+ private int appError_ ;
+ public boolean hasAppError() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public int getAppError() {
+ return appError_;
+ }
+ public Builder setAppError(int value) {
+ bitField0_ |= 0x00000004;
+ appError_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearAppError() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ appError_ = 0;
onChanged();
return this;
}
@@ -981,7 +1122,7 @@ public final class Rpc {
// optional string error_message = 3;
private Object errorMessage_ = "";
public boolean hasErrorMessage() {
- return ((bitField0_ & 0x00000004) == 0x00000004);
+ return ((bitField0_ & 0x00000008) == 0x00000008);
}
public String getErrorMessage() {
Object ref = errorMessage_;
@@ -997,19 +1138,19 @@ public final class Rpc {
if (value == null) {
throw new NullPointerException();
}
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000008;
errorMessage_ = value;
onChanged();
return this;
}
public Builder clearErrorMessage() {
- bitField0_ = (bitField0_ & ~0x00000004);
+ bitField0_ = (bitField0_ & ~0x00000008);
errorMessage_ = getDefaultInstance().getErrorMessage();
onChanged();
return this;
}
void setErrorMessage(com.google.protobuf.ByteString value) {
- bitField0_ |= 0x00000004;
+ bitField0_ |= 0x00000008;
errorMessage_ = value;
onChanged();
}
@@ -1047,9 +1188,12 @@ public final class Rpc {
"\n+src/main/java/com/orbekk/protobuf/Rpc." +
"proto\022\023com.orbekk.protobuf\"P\n\007Request\022\031\n" +
"\021full_service_name\030\001 \001(\t\022\023\n\013method_name\030" +
- "\002 \001(\t\022\025\n\rrequest_proto\030\003 \001(\014\"K\n\010Response" +
- "\022\026\n\016response_proto\030\001 \001(\014\022\020\n\005error\030\002 \001(\005:" +
- "\0010\022\025\n\rerror_message\030\003 \001(\t"
+ "\002 \001(\t\022\025\n\rrequest_proto\030\003 \001(\014\"\317\001\n\010Respons" +
+ "e\022\026\n\016response_proto\030\001 \001(\014\0222\n\005error\030\002 \001(\016" +
+ "2#.com.orbekk.protobuf.Response.Error\022\021\n" +
+ "\tapp_error\030\004 \001(\005\022\025\n\rerror_message\030\003 \001(\t\"" +
+ "M\n\005Error\022\023\n\017UNKNOWN_SERVICE\020\000\022\022\n\016UNKNOWN" +
+ "_METHOD\020\001\022\014\n\010CANCELED\020\002\022\r\n\tAPP_ERROR\020\003"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -1069,7 +1213,7 @@ public final class Rpc {
internal_static_com_orbekk_protobuf_Response_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_com_orbekk_protobuf_Response_descriptor,
- new java.lang.String[] { "ResponseProto", "Error", "ErrorMessage", },
+ new java.lang.String[] { "ResponseProto", "Error", "AppError", "ErrorMessage", },
com.orbekk.protobuf.Rpc.Response.class,
com.orbekk.protobuf.Rpc.Response.Builder.class);
return null;
diff --git a/src/main/java/com/orbekk/protobuf/Rpc.proto b/src/main/java/com/orbekk/protobuf/Rpc.proto
index 49e60ea..f733140 100644
--- a/src/main/java/com/orbekk/protobuf/Rpc.proto
+++ b/src/main/java/com/orbekk/protobuf/Rpc.proto
@@ -10,6 +10,13 @@ message Request {
// Next tag: 4
message Response {
optional bytes response_proto = 1;
- optional int32 error = 2 [default = 0];
+ enum Error {
+ UNKNOWN_SERVICE = 0;
+ UNKNOWN_METHOD = 1;
+ CANCELED = 2;
+ APP_ERROR = 3;
+ };
+ optional Error error = 2;
+ optional int32 app_error = 4;
optional string error_message = 3;
}
diff --git a/src/main/java/com/orbekk/protobuf/SimpleProtobufClient.java b/src/main/java/com/orbekk/protobuf/SimpleProtobufClient.java
index eabb516..ffaedb0 100644
--- a/src/main/java/com/orbekk/protobuf/SimpleProtobufClient.java
+++ b/src/main/java/com/orbekk/protobuf/SimpleProtobufClient.java
@@ -9,7 +9,8 @@ public class SimpleProtobufClient {
try {
Socket socket = new Socket("localhost", 10000);
Rpc.Request r1 = Rpc.Request.newBuilder()
- .setFullServiceName("Service1")
+ .setFullServiceName("com.orbekk.protobuf.TestService")
+ .setMethodName("Run")
.build();
Rpc.Request r2 = Rpc.Request.newBuilder()
.setFullServiceName("Service2")
diff --git a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java
index 57afae9..0a20883 100644
--- a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java
+++ b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java
@@ -2,16 +2,26 @@ package com.orbekk.protobuf;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.io.OutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
+import com.google.protobuf.Message;
+import com.google.protobuf.Service;
+import com.google.protobuf.RpcController;
+import com.google.protobuf.RpcCallback;
+import com.google.protobuf.Descriptors;
+import java.util.Map;
+import java.util.HashMap;
public class SimpleProtobufServer extends Thread {
private static Logger logger = Logger.getLogger(
SimpleProtobufServer.class.getName());
- ServerSocket serverSocket;
+ private ServerSocket serverSocket;
+ private Map<String, Service> registeredServices =
+ new HashMap<String, Service>();
public static SimpleProtobufServer create(int port) {
try {
@@ -30,16 +40,52 @@ public class SimpleProtobufServer extends Thread {
this.serverSocket = serverSocket;
}
+ public synchronized void registerService(Service service) {
+ String serviceName = service.getDescriptorForType().getFullName();
+ if (registeredServices.containsKey(serviceName)) {
+ logger.warning("Already registered service with this name.");
+ }
+ logger.info("Registering service: " + serviceName);
+ registeredServices.put(serviceName, service);
+ }
+
+ public void handleRequest(Rpc.Request request, OutputStream out)
+ throws IOException {
+ Service service = registeredServices.get(request.getFullServiceName());
+ final Rpc.Response.Builder response = Rpc.Response.newBuilder();
+ if (service == null) {
+ response.setError(Rpc.Response.Error.UNKNOWN_SERVICE);
+ response.build().writeDelimitedTo(out);
+ return;
+ }
+ Descriptors.MethodDescriptor method = service.getDescriptorForType()
+ .findMethodByName(request.getMethodName());
+ if (method == null) {
+ response.setError(Rpc.Response.Error.UNKNOWN_METHOD);
+ response.build().writeDelimitedTo(out);
+ return;
+ }
+ RpcCallback<Message> doneCallback = new RpcCallback<Message>() {
+ @Override public void run(Message responseMessage) {
+ response.setResponseProto(responseMessage.toByteString());
+ }
+ };
+ Message requestMessage = service.getRequestPrototype(method)
+ .toBuilder()
+ .mergeFrom(request.getRequestProto())
+ .build();
+ service.callMethod(method, null, requestMessage, doneCallback);
+ }
+
private void handleConnection(final Socket connection) {
new Thread(new Runnable() {
@Override public void run() {
try {
- Rpc.Request r1 = Rpc.Request.parseDelimitedFrom(
- connection.getInputStream());
- Rpc.Request r2 = Rpc.Request.parseDelimitedFrom(
- connection.getInputStream());
- System.out.println(r1);
- System.out.println(r2);
+ while (true) {
+ Rpc.Request r1 = Rpc.Request.parseDelimitedFrom(
+ connection.getInputStream());
+ handleRequest(r1, connection.getOutputStream());
+ }
} catch (IOException e) {
logger.info("Closed connection: " + connection);
} finally {
@@ -66,6 +112,23 @@ public class SimpleProtobufServer extends Thread {
}
public static void main(String[] args) {
- SimpleProtobufServer.create(10000).start();
+ SimpleProtobufServer server = SimpleProtobufServer.create(10000);
+ Test.TestService testService = new Test.TestService() {
+ @Override public void run(RpcController controller,
+ Test.TestRequest request,
+ RpcCallback<Test.TestResponse> done) {
+ System.out.println("Hello from TestService!");
+ done.run(Test.TestResponse.newBuilder()
+ .setId("Hello from server.")
+ .build());
+ }
+ };
+ server.registerService(testService);
+ server.start();
+ try {
+ server.join();
+ } catch (InterruptedException e) {
+ System.out.println("Stopped.");
+ }
}
}
diff --git a/src/main/java/com/orbekk/protobuf/Test.java b/src/main/java/com/orbekk/protobuf/Test.java
new file mode 100644
index 0000000..8b17a74
--- /dev/null
+++ b/src/main/java/com/orbekk/protobuf/Test.java
@@ -0,0 +1,1035 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: src/main/java/com/orbekk/protobuf/Test.proto
+
+package com.orbekk.protobuf;
+
+public final class Test {
+ private Test() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface TestRequestOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional string id = 1;
+ boolean hasId();
+ String getId();
+ }
+ public static final class TestRequest extends
+ com.google.protobuf.GeneratedMessage
+ implements TestRequestOrBuilder {
+ // Use TestRequest.newBuilder() to construct.
+ private TestRequest(Builder builder) {
+ super(builder);
+ }
+ private TestRequest(boolean noInit) {}
+
+ private static final TestRequest defaultInstance;
+ public static TestRequest getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public TestRequest getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestRequest_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // optional string id = 1;
+ public static final int ID_FIELD_NUMBER = 1;
+ private Object id_;
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ Object ref = id_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ id_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getIdBytes() {
+ Object ref = id_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ id_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private void initFields() {
+ id_ = "";
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getIdBytes());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getIdBytes());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestRequest parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.orbekk.protobuf.Test.TestRequest prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.protobuf.Test.TestRequestOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestRequest_fieldAccessorTable;
+ }
+
+ // Construct using com.orbekk.protobuf.Test.TestRequest.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ id_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.orbekk.protobuf.Test.TestRequest.getDescriptor();
+ }
+
+ public com.orbekk.protobuf.Test.TestRequest getDefaultInstanceForType() {
+ return com.orbekk.protobuf.Test.TestRequest.getDefaultInstance();
+ }
+
+ public com.orbekk.protobuf.Test.TestRequest build() {
+ com.orbekk.protobuf.Test.TestRequest result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.orbekk.protobuf.Test.TestRequest buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.orbekk.protobuf.Test.TestRequest result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.orbekk.protobuf.Test.TestRequest buildPartial() {
+ com.orbekk.protobuf.Test.TestRequest result = new com.orbekk.protobuf.Test.TestRequest(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.id_ = id_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.orbekk.protobuf.Test.TestRequest) {
+ return mergeFrom((com.orbekk.protobuf.Test.TestRequest)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.orbekk.protobuf.Test.TestRequest other) {
+ if (other == com.orbekk.protobuf.Test.TestRequest.getDefaultInstance()) return this;
+ if (other.hasId()) {
+ setId(other.getId());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ id_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // optional string id = 1;
+ private Object id_ = "";
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ Object ref = id_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ id_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setId(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearId() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ id_ = getDefaultInstance().getId();
+ onChanged();
+ return this;
+ }
+ void setId(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.orbekk.protobuf.TestRequest)
+ }
+
+ static {
+ defaultInstance = new TestRequest(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.orbekk.protobuf.TestRequest)
+ }
+
+ public interface TestResponseOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional string id = 1;
+ boolean hasId();
+ String getId();
+ }
+ public static final class TestResponse extends
+ com.google.protobuf.GeneratedMessage
+ implements TestResponseOrBuilder {
+ // Use TestResponse.newBuilder() to construct.
+ private TestResponse(Builder builder) {
+ super(builder);
+ }
+ private TestResponse(boolean noInit) {}
+
+ private static final TestResponse defaultInstance;
+ public static TestResponse getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public TestResponse getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestResponse_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestResponse_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // optional string id = 1;
+ public static final int ID_FIELD_NUMBER = 1;
+ private Object id_;
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ Object ref = id_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ id_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getIdBytes() {
+ Object ref = id_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ id_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private void initFields() {
+ id_ = "";
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getIdBytes());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getIdBytes());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.protobuf.Test.TestResponse parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.orbekk.protobuf.Test.TestResponse prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.protobuf.Test.TestResponseOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestResponse_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.protobuf.Test.internal_static_com_orbekk_protobuf_TestResponse_fieldAccessorTable;
+ }
+
+ // Construct using com.orbekk.protobuf.Test.TestResponse.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ id_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.orbekk.protobuf.Test.TestResponse.getDescriptor();
+ }
+
+ public com.orbekk.protobuf.Test.TestResponse getDefaultInstanceForType() {
+ return com.orbekk.protobuf.Test.TestResponse.getDefaultInstance();
+ }
+
+ public com.orbekk.protobuf.Test.TestResponse build() {
+ com.orbekk.protobuf.Test.TestResponse result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.orbekk.protobuf.Test.TestResponse buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.orbekk.protobuf.Test.TestResponse result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.orbekk.protobuf.Test.TestResponse buildPartial() {
+ com.orbekk.protobuf.Test.TestResponse result = new com.orbekk.protobuf.Test.TestResponse(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.id_ = id_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.orbekk.protobuf.Test.TestResponse) {
+ return mergeFrom((com.orbekk.protobuf.Test.TestResponse)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.orbekk.protobuf.Test.TestResponse other) {
+ if (other == com.orbekk.protobuf.Test.TestResponse.getDefaultInstance()) return this;
+ if (other.hasId()) {
+ setId(other.getId());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ id_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // optional string id = 1;
+ private Object id_ = "";
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ Object ref = id_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ id_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setId(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearId() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ id_ = getDefaultInstance().getId();
+ onChanged();
+ return this;
+ }
+ void setId(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.orbekk.protobuf.TestResponse)
+ }
+
+ static {
+ defaultInstance = new TestResponse(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.orbekk.protobuf.TestResponse)
+ }
+
+ public static abstract class TestService
+ implements com.google.protobuf.Service {
+ protected TestService() {}
+
+ public interface Interface {
+ public abstract void run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request,
+ com.google.protobuf.RpcCallback<com.orbekk.protobuf.Test.TestResponse> done);
+
+ }
+
+ public static com.google.protobuf.Service newReflectiveService(
+ final Interface impl) {
+ return new TestService() {
+ @java.lang.Override
+ public void run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request,
+ com.google.protobuf.RpcCallback<com.orbekk.protobuf.Test.TestResponse> done) {
+ impl.run(controller, request, done);
+ }
+
+ };
+ }
+
+ public static com.google.protobuf.BlockingService
+ newReflectiveBlockingService(final BlockingInterface impl) {
+ return new com.google.protobuf.BlockingService() {
+ public final com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public final com.google.protobuf.Message callBlockingMethod(
+ com.google.protobuf.Descriptors.MethodDescriptor method,
+ com.google.protobuf.RpcController controller,
+ com.google.protobuf.Message request)
+ throws com.google.protobuf.ServiceException {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.callBlockingMethod() given method descriptor for " +
+ "wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return impl.run(controller, (com.orbekk.protobuf.Test.TestRequest)request);
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getRequestPrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getRequestPrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.protobuf.Test.TestRequest.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getResponsePrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getResponsePrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.protobuf.Test.TestResponse.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ };
+ }
+
+ public abstract void run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request,
+ com.google.protobuf.RpcCallback<com.orbekk.protobuf.Test.TestResponse> done);
+
+ public static final
+ com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptor() {
+ return com.orbekk.protobuf.Test.getDescriptor().getServices().get(0);
+ }
+ public final com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public final void callMethod(
+ com.google.protobuf.Descriptors.MethodDescriptor method,
+ com.google.protobuf.RpcController controller,
+ com.google.protobuf.Message request,
+ com.google.protobuf.RpcCallback<
+ com.google.protobuf.Message> done) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.callMethod() given method descriptor for wrong " +
+ "service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ this.run(controller, (com.orbekk.protobuf.Test.TestRequest)request,
+ com.google.protobuf.RpcUtil.<com.orbekk.protobuf.Test.TestResponse>specializeCallback(
+ done));
+ return;
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getRequestPrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getRequestPrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.protobuf.Test.TestRequest.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getResponsePrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getResponsePrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.protobuf.Test.TestResponse.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public static Stub newStub(
+ com.google.protobuf.RpcChannel channel) {
+ return new Stub(channel);
+ }
+
+ public static final class Stub extends com.orbekk.protobuf.Test.TestService implements Interface {
+ private Stub(com.google.protobuf.RpcChannel channel) {
+ this.channel = channel;
+ }
+
+ private final com.google.protobuf.RpcChannel channel;
+
+ public com.google.protobuf.RpcChannel getChannel() {
+ return channel;
+ }
+
+ public void run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request,
+ com.google.protobuf.RpcCallback<com.orbekk.protobuf.Test.TestResponse> done) {
+ channel.callMethod(
+ getDescriptor().getMethods().get(0),
+ controller,
+ request,
+ com.orbekk.protobuf.Test.TestResponse.getDefaultInstance(),
+ com.google.protobuf.RpcUtil.generalizeCallback(
+ done,
+ com.orbekk.protobuf.Test.TestResponse.class,
+ com.orbekk.protobuf.Test.TestResponse.getDefaultInstance()));
+ }
+ }
+
+ public static BlockingInterface newBlockingStub(
+ com.google.protobuf.BlockingRpcChannel channel) {
+ return new BlockingStub(channel);
+ }
+
+ public interface BlockingInterface {
+ public com.orbekk.protobuf.Test.TestResponse run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request)
+ throws com.google.protobuf.ServiceException;
+ }
+
+ private static final class BlockingStub implements BlockingInterface {
+ private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {
+ this.channel = channel;
+ }
+
+ private final com.google.protobuf.BlockingRpcChannel channel;
+
+ public com.orbekk.protobuf.Test.TestResponse run(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.protobuf.Test.TestRequest request)
+ throws com.google.protobuf.ServiceException {
+ return (com.orbekk.protobuf.Test.TestResponse) channel.callBlockingMethod(
+ getDescriptor().getMethods().get(0),
+ controller,
+ request,
+ com.orbekk.protobuf.Test.TestResponse.getDefaultInstance());
+ }
+
+ }
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_orbekk_protobuf_TestRequest_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_orbekk_protobuf_TestRequest_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_orbekk_protobuf_TestResponse_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_orbekk_protobuf_TestResponse_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n,src/main/java/com/orbekk/protobuf/Test" +
+ ".proto\022\023com.orbekk.protobuf\"\031\n\013TestReque" +
+ "st\022\n\n\002id\030\001 \001(\t\"\032\n\014TestResponse\022\n\n\002id\030\001 \001" +
+ "(\t2Y\n\013TestService\022J\n\003Run\022 .com.orbekk.pr" +
+ "otobuf.TestRequest\032!.com.orbekk.protobuf" +
+ ".TestResponseB\003\210\001\001"
+ };
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(
+ com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_com_orbekk_protobuf_TestRequest_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_com_orbekk_protobuf_TestRequest_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_orbekk_protobuf_TestRequest_descriptor,
+ new java.lang.String[] { "Id", },
+ com.orbekk.protobuf.Test.TestRequest.class,
+ com.orbekk.protobuf.Test.TestRequest.Builder.class);
+ internal_static_com_orbekk_protobuf_TestResponse_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_com_orbekk_protobuf_TestResponse_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_orbekk_protobuf_TestResponse_descriptor,
+ new java.lang.String[] { "Id", },
+ com.orbekk.protobuf.Test.TestResponse.class,
+ com.orbekk.protobuf.Test.TestResponse.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/src/main/java/com/orbekk/protobuf/Test.proto b/src/main/java/com/orbekk/protobuf/Test.proto
new file mode 100644
index 0000000..3abb507
--- /dev/null
+++ b/src/main/java/com/orbekk/protobuf/Test.proto
@@ -0,0 +1,15 @@
+package com.orbekk.protobuf;
+
+option java_generic_services = true;
+
+message TestRequest {
+ optional string id = 1;
+}
+
+message TestResponse {
+ optional string id = 1;
+}
+
+service TestService {
+ rpc Run (TestRequest) returns (TestResponse);
+}