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/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<