Remove Method and switch its users to MethodDescriptor.
Resolves #511.
- In generated code, make CONFIG private and METHOD_* fields public.
METHOD_* fields are MethodDescriptors now, users of the CONFIG field
should switch to using the METHOD_* fields.
- Move MethodType into MethodDescriptor (#529).
- Unify the fully qualified method name. It is fully qualified service
name + slash + short method name. It doesn't have the leading slash.
- HandlerRegistry switches the key from short method name to fully
qualified method name.
diff --git a/compiler/src/java_plugin/cpp/java_generator.cpp b/compiler/src/java_plugin/cpp/java_generator.cpp
index 5653db1..3d0da66 100644
--- a/compiler/src/java_plugin/cpp/java_generator.cpp
+++ b/compiler/src/java_plugin/cpp/java_generator.cpp
@@ -62,6 +62,7 @@
static void PrintMethodFields(
const ServiceDescriptor* service, map<string, string>* vars, Printer* p,
bool generate_nano) {
+ (*vars)["service_name"] = service->name();
for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* method = service->method(i);
(*vars)["method_name"] = method->name();
@@ -84,16 +85,19 @@
}
}
+ p->Print("// Static method descriptors that strictly reflect the proto.\n");
+
if (generate_nano) {
// TODO(zsurocking): we're creating two Parsers for each method right now.
// We could instead create static Parsers and reuse them if some methods
// share the same request or response messages.
p->Print(
*vars,
- "private static final $Method$<$input_type$,\n"
+ "public static final $MethodDescriptor$<$input_type$,\n"
" $output_type$> $method_field_name$ =\n"
- " $Method$.create(\n"
- " $MethodType$.$method_type$, \"$method_name$\",\n"
+ " $MethodDescriptor$.create(\n"
+ " $MethodType$.$method_type$,\n"
+ " \"$Package$$service_name$\", \"$method_name$\",\n"
" $NanoUtils$.<$input_type$>marshaller(\n"
" new io.grpc.protobuf.nano.Parser<$input_type$>() {\n"
" @Override\n"
@@ -113,12 +117,13 @@
} else {
p->Print(
*vars,
- "private static final $Method$<$input_type$,\n"
+ "public static final $MethodDescriptor$<$input_type$,\n"
" $output_type$> $method_field_name$ =\n"
- " $Method$.create(\n"
- " $MethodType$.$method_type$, \"$method_name$\",\n"
- " $ProtoUtils$.marshaller($input_type$.parser()),\n"
- " $ProtoUtils$.marshaller($output_type$.parser()));\n");
+ " $MethodDescriptor$.create(\n"
+ " $MethodType$.$method_type$,\n"
+ " \"$Package$$service_name$\", \"$method_name$\",\n"
+ " $ProtoUtils$.marshaller($input_type$.PARSER),\n"
+ " $ProtoUtils$.marshaller($output_type$.PARSER));\n");
}
}
p->Print("\n");
@@ -158,8 +163,7 @@
(*vars)["method_field_name"] = MethodPropertiesFieldName(method);
(*vars)["lower_method_name"] = LowerMethodName(method);
p->Print(*vars,
- "$lower_method_name$ = createMethodDescriptor(\n"
- " \"$Package$$service_name$\", $method_field_name$);\n");
+ "$lower_method_name$ = $method_field_name$;\n");
}
p->Outdent();
p->Print("}\n");
@@ -181,7 +185,7 @@
*vars,
"$lower_method_name$ = ($MethodDescriptor$<$input_type$,\n"
" $output_type$>) methodMap.get(\n"
- " CONFIG.$lower_method_name$.getName());\n");
+ " CONFIG.$lower_method_name$.getFullMethodName());\n");
}
p->Outdent();
p->Print("}\n\n");
@@ -517,7 +521,7 @@
(*vars)["invocation_class"] =
"io.grpc.stub.ServerCalls.UnaryRequestMethod";
}
- p->Print(*vars, ".addMethod(createMethodDefinition(\n");
+ p->Print(*vars, ".addMethod($ServerMethodDefinition$.create(\n");
p->Indent();
p->Indent();
p->Print(
@@ -609,9 +613,10 @@
p->Outdent();
p->Print("}\n\n");
+ p->Print("// The default service descriptor\n");
p->Print(
*vars,
- "public static final $service_name$ServiceDescriptor CONFIG =\n"
+ "private static final $service_name$ServiceDescriptor CONFIG =\n"
" new $service_name$ServiceDescriptor();\n\n");
PrintServiceDescriptor(service, vars, p);
PrintStub(service, vars, p, ASYNC_INTERFACE);
@@ -628,8 +633,6 @@
void PrintImports(Printer* p, bool generate_nano) {
p->Print(
"import static "
- "io.grpc.stub.ClientCalls.createMethodDescriptor;\n"
- "import static "
"io.grpc.stub.ClientCalls.asyncUnaryCall;\n"
"import static "
"io.grpc.stub.ClientCalls.asyncServerStreamingCall;\n"
@@ -644,8 +647,6 @@
"import static "
"io.grpc.stub.ClientCalls.unaryFutureCall;\n"
"import static "
- "io.grpc.stub.ServerCalls.createMethodDefinition;\n"
- "import static "
"io.grpc.stub.ServerCalls.asyncUnaryRequestCall;\n"
"import static "
"io.grpc.stub.ServerCalls.asyncStreamingRequestCall;\n\n");
@@ -664,11 +665,12 @@
vars["Override"] = "java.lang.Override";
vars["Channel"] = "io.grpc.Channel";
vars["CallOptions"] = "io.grpc.CallOptions";
- vars["MethodType"] = "io.grpc.MethodType";
+ vars["MethodType"] = "io.grpc.MethodDescriptor.MethodType";
+ vars["ServerMethodDefinition"] =
+ "io.grpc.ServerMethodDefinition";
vars["ServerServiceDefinition"] =
"io.grpc.ServerServiceDefinition";
vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
- vars["Method"] = "io.grpc.stub.Method";
vars["AbstractServiceDescriptor"] =
"io.grpc.stub.AbstractServiceDescriptor";
vars["ImmutableList"] = "com.google.common.collect.ImmutableList";
diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt
index 261a088..cb3baf6 100644
--- a/compiler/src/test/golden/TestService.java.txt
+++ b/compiler/src/test/golden/TestService.java.txt
@@ -1,6 +1,5 @@
package io.grpc.testing.integration;
-import static io.grpc.stub.ClientCalls.createMethodDescriptor;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
@@ -8,43 +7,52 @@
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall;
-import static io.grpc.stub.ServerCalls.createMethodDefinition;
import static io.grpc.stub.ServerCalls.asyncUnaryRequestCall;
import static io.grpc.stub.ServerCalls.asyncStreamingRequestCall;
@javax.annotation.Generated("by gRPC proto compiler")
public class TestServiceGrpc {
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.SimpleRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest,
io.grpc.testing.integration.Test.SimpleResponse> METHOD_UNARY_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.UNARY, "UnaryCall",
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.parser()));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.UNARY,
+ "grpc.testing.TestService", "UnaryCall",
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.PARSER),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.PARSER));
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.SERVER_STREAMING, "StreamingOutputCall",
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingInputCallRequest,
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING,
+ "grpc.testing.TestService", "StreamingOutputCall",
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.PARSER),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.PARSER));
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
io.grpc.testing.integration.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.CLIENT_STREAMING, "StreamingInputCall",
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.parser()));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING,
+ "grpc.testing.TestService", "StreamingInputCall",
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.PARSER),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.PARSER));
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_FULL_DUPLEX_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.DUPLEX_STREAMING, "FullDuplexCall",
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.DUPLEX_STREAMING,
+ "grpc.testing.TestService", "FullDuplexCall",
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.PARSER),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.PARSER));
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_HALF_DUPLEX_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.DUPLEX_STREAMING, "HalfDuplexCall",
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.DUPLEX_STREAMING,
+ "grpc.testing.TestService", "HalfDuplexCall",
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.PARSER),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.PARSER));
public static TestServiceStub newStub(io.grpc.Channel channel) {
return new TestServiceStub(channel, CONFIG);
@@ -60,7 +68,8 @@
return new TestServiceFutureStub(channel, CONFIG);
}
- public static final TestServiceServiceDescriptor CONFIG =
+ // The default service descriptor
+ private static final TestServiceServiceDescriptor CONFIG =
new TestServiceServiceDescriptor();
@javax.annotation.concurrent.Immutable
@@ -78,16 +87,11 @@
io.grpc.testing.integration.Test.StreamingOutputCallResponse> halfDuplexCall;
private TestServiceServiceDescriptor() {
- unaryCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_UNARY_CALL);
- streamingOutputCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_STREAMING_OUTPUT_CALL);
- streamingInputCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_STREAMING_INPUT_CALL);
- fullDuplexCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_FULL_DUPLEX_CALL);
- halfDuplexCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_HALF_DUPLEX_CALL);
+ unaryCall = METHOD_UNARY_CALL;
+ streamingOutputCall = METHOD_STREAMING_OUTPUT_CALL;
+ streamingInputCall = METHOD_STREAMING_INPUT_CALL;
+ fullDuplexCall = METHOD_FULL_DUPLEX_CALL;
+ halfDuplexCall = METHOD_HALF_DUPLEX_CALL;
}
@SuppressWarnings("unchecked")
@@ -95,19 +99,19 @@
java.util.Map<java.lang.String, io.grpc.MethodDescriptor<?, ?>> methodMap) {
unaryCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest,
io.grpc.testing.integration.Test.SimpleResponse>) methodMap.get(
- CONFIG.unaryCall.getName());
+ CONFIG.unaryCall.getFullMethodName());
streamingOutputCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.streamingOutputCall.getName());
+ CONFIG.streamingOutputCall.getFullMethodName());
streamingInputCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
io.grpc.testing.integration.Test.StreamingInputCallResponse>) methodMap.get(
- CONFIG.streamingInputCall.getName());
+ CONFIG.streamingInputCall.getFullMethodName());
fullDuplexCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.fullDuplexCall.getName());
+ CONFIG.fullDuplexCall.getFullMethodName());
halfDuplexCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.halfDuplexCall.getName());
+ CONFIG.halfDuplexCall.getFullMethodName());
}
@java.lang.Override
@@ -283,7 +287,7 @@
public static io.grpc.ServerServiceDefinition bindService(
final TestService serviceImpl) {
return io.grpc.ServerServiceDefinition.builder("grpc.testing.TestService")
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_UNARY_CALL,
asyncUnaryRequestCall(
new io.grpc.stub.ServerCalls.UnaryRequestMethod<
@@ -296,7 +300,7 @@
serviceImpl.unaryCall(request, responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_STREAMING_OUTPUT_CALL,
asyncUnaryRequestCall(
new io.grpc.stub.ServerCalls.UnaryRequestMethod<
@@ -309,7 +313,7 @@
serviceImpl.streamingOutputCall(request, responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_STREAMING_INPUT_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<
@@ -321,7 +325,7 @@
return serviceImpl.streamingInputCall(responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_FULL_DUPLEX_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<
@@ -333,7 +337,7 @@
return serviceImpl.fullDuplexCall(responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_HALF_DUPLEX_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<
diff --git a/compiler/src/test/golden/TestServiceNano.java.txt b/compiler/src/test/golden/TestServiceNano.java.txt
index 6431f21..a75422d 100644
--- a/compiler/src/test/golden/TestServiceNano.java.txt
+++ b/compiler/src/test/golden/TestServiceNano.java.txt
@@ -1,6 +1,5 @@
package io.grpc.testing.integration;
-import static io.grpc.stub.ClientCalls.createMethodDescriptor;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
@@ -8,7 +7,6 @@
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.unaryFutureCall;
-import static io.grpc.stub.ServerCalls.createMethodDefinition;
import static io.grpc.stub.ServerCalls.asyncUnaryRequestCall;
import static io.grpc.stub.ServerCalls.asyncStreamingRequestCall;
@@ -17,10 +15,12 @@
@javax.annotation.Generated("by gRPC proto compiler")
public class TestServiceGrpc {
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.SimpleRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest,
io.grpc.testing.integration.Test.SimpleResponse> METHOD_UNARY_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.UNARY, "UnaryCall",
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.UNARY,
+ "grpc.testing.TestService", "UnaryCall",
io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.Test.SimpleRequest>marshaller(
new io.grpc.protobuf.nano.Parser<io.grpc.testing.integration.Test.SimpleRequest>() {
@Override
@@ -35,10 +35,12 @@
return io.grpc.testing.integration.Test.SimpleResponse.parseFrom(input);
}
}));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.SERVER_STREAMING, "StreamingOutputCall",
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING,
+ "grpc.testing.TestService", "StreamingOutputCall",
io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.Test.StreamingOutputCallRequest>marshaller(
new io.grpc.protobuf.nano.Parser<io.grpc.testing.integration.Test.StreamingOutputCallRequest>() {
@Override
@@ -53,10 +55,12 @@
return io.grpc.testing.integration.Test.StreamingOutputCallResponse.parseFrom(input);
}
}));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingInputCallRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
io.grpc.testing.integration.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.CLIENT_STREAMING, "StreamingInputCall",
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING,
+ "grpc.testing.TestService", "StreamingInputCall",
io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.Test.StreamingInputCallRequest>marshaller(
new io.grpc.protobuf.nano.Parser<io.grpc.testing.integration.Test.StreamingInputCallRequest>() {
@Override
@@ -71,10 +75,12 @@
return io.grpc.testing.integration.Test.StreamingInputCallResponse.parseFrom(input);
}
}));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_FULL_DUPLEX_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.DUPLEX_STREAMING, "FullDuplexCall",
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.DUPLEX_STREAMING,
+ "grpc.testing.TestService", "FullDuplexCall",
io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.Test.StreamingOutputCallRequest>marshaller(
new io.grpc.protobuf.nano.Parser<io.grpc.testing.integration.Test.StreamingOutputCallRequest>() {
@Override
@@ -89,10 +95,12 @@
return io.grpc.testing.integration.Test.StreamingOutputCallResponse.parseFrom(input);
}
}));
- private static final io.grpc.stub.Method<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
+ // Static method descriptors that strictly reflect the proto.
+ public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_HALF_DUPLEX_CALL =
- io.grpc.stub.Method.create(
- io.grpc.MethodType.DUPLEX_STREAMING, "HalfDuplexCall",
+ io.grpc.MethodDescriptor.create(
+ io.grpc.MethodDescriptor.MethodType.DUPLEX_STREAMING,
+ "grpc.testing.TestService", "HalfDuplexCall",
io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.integration.Test.StreamingOutputCallRequest>marshaller(
new io.grpc.protobuf.nano.Parser<io.grpc.testing.integration.Test.StreamingOutputCallRequest>() {
@Override
@@ -122,7 +130,8 @@
return new TestServiceFutureStub(channel, CONFIG);
}
- public static final TestServiceServiceDescriptor CONFIG =
+ // The default service descriptor
+ private static final TestServiceServiceDescriptor CONFIG =
new TestServiceServiceDescriptor();
@javax.annotation.concurrent.Immutable
@@ -140,16 +149,11 @@
io.grpc.testing.integration.Test.StreamingOutputCallResponse> halfDuplexCall;
private TestServiceServiceDescriptor() {
- unaryCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_UNARY_CALL);
- streamingOutputCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_STREAMING_OUTPUT_CALL);
- streamingInputCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_STREAMING_INPUT_CALL);
- fullDuplexCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_FULL_DUPLEX_CALL);
- halfDuplexCall = createMethodDescriptor(
- "grpc.testing.TestService", METHOD_HALF_DUPLEX_CALL);
+ unaryCall = METHOD_UNARY_CALL;
+ streamingOutputCall = METHOD_STREAMING_OUTPUT_CALL;
+ streamingInputCall = METHOD_STREAMING_INPUT_CALL;
+ fullDuplexCall = METHOD_FULL_DUPLEX_CALL;
+ halfDuplexCall = METHOD_HALF_DUPLEX_CALL;
}
@SuppressWarnings("unchecked")
@@ -157,19 +161,19 @@
java.util.Map<java.lang.String, io.grpc.MethodDescriptor<?, ?>> methodMap) {
unaryCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest,
io.grpc.testing.integration.Test.SimpleResponse>) methodMap.get(
- CONFIG.unaryCall.getName());
+ CONFIG.unaryCall.getFullMethodName());
streamingOutputCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.streamingOutputCall.getName());
+ CONFIG.streamingOutputCall.getFullMethodName());
streamingInputCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
io.grpc.testing.integration.Test.StreamingInputCallResponse>) methodMap.get(
- CONFIG.streamingInputCall.getName());
+ CONFIG.streamingInputCall.getFullMethodName());
fullDuplexCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.fullDuplexCall.getName());
+ CONFIG.fullDuplexCall.getFullMethodName());
halfDuplexCall = (io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse>) methodMap.get(
- CONFIG.halfDuplexCall.getName());
+ CONFIG.halfDuplexCall.getFullMethodName());
}
@java.lang.Override
@@ -345,7 +349,7 @@
public static io.grpc.ServerServiceDefinition bindService(
final TestService serviceImpl) {
return io.grpc.ServerServiceDefinition.builder("grpc.testing.TestService")
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_UNARY_CALL,
asyncUnaryRequestCall(
new io.grpc.stub.ServerCalls.UnaryRequestMethod<
@@ -358,7 +362,7 @@
serviceImpl.unaryCall(request, responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_STREAMING_OUTPUT_CALL,
asyncUnaryRequestCall(
new io.grpc.stub.ServerCalls.UnaryRequestMethod<
@@ -371,7 +375,7 @@
serviceImpl.streamingOutputCall(request, responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_STREAMING_INPUT_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<
@@ -383,7 +387,7 @@
return serviceImpl.streamingInputCall(responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_FULL_DUPLEX_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<
@@ -395,7 +399,7 @@
return serviceImpl.fullDuplexCall(responseObserver);
}
})))
- .addMethod(createMethodDefinition(
+ .addMethod(io.grpc.ServerMethodDefinition.create(
METHOD_HALF_DUPLEX_CALL,
asyncStreamingRequestCall(
new io.grpc.stub.ServerCalls.StreamingRequestMethod<