blob: 57691bf84a37ead0e4a0d4aa846d2539131e2a63 [file] [log] [blame]
nmittlerf8314582015-01-27 10:25:39 -08001package io.grpc.testing.integration;
zhangkun835e607852015-01-22 12:31:56 -08002
Kun Zhang2ee4d022015-06-04 16:39:25 -07003import static io.grpc.stub.ClientCalls.asyncUnaryCall;
4import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
5import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -07006import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
Kun Zhang2ee4d022015-06-04 16:39:25 -07007import static io.grpc.stub.ClientCalls.blockingUnaryCall;
8import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
Kun Zhang686dcff2015-07-16 12:34:37 -07009import static io.grpc.stub.ClientCalls.futureUnaryCall;
Kun Zhang042b2782015-08-17 15:43:40 -070010import static io.grpc.MethodDescriptor.generateFullMethodName;
Kun Zhang867c76d2015-07-13 17:15:34 -070011import static io.grpc.stub.ServerCalls.asyncUnaryCall;
12import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
13import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070014import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
Lukasz Strzalkowski2fbf1422016-04-08 02:28:32 +020015import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
16import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
zhangkun835e607852015-01-22 12:31:56 -080017
Carl Mastrangelo72f1e882016-02-29 18:05:33 -080018@javax.annotation.Generated(
Lukasz Strzalkowski363e0f62016-04-11 19:34:15 +020019 value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
Carl Mastrangelo72f1e882016-02-29 18:05:33 -080020 comments = "Source: test.proto")
zhangkun835e607852015-01-22 12:31:56 -080021public class TestServiceGrpc {
22
Eric Andersonbe0d7e92015-09-10 09:47:17 -070023 private TestServiceGrpc() {}
24
David P. Baker66b984c2015-08-21 13:00:26 -040025 public static final String SERVICE_NAME = "grpc.testing.TestService";
26
Kun Zhang73acc732015-06-26 16:32:05 -070027 // Static method descriptors that strictly reflect the proto.
Kun Zhang5bb0ea92015-08-31 09:56:44 -070028 @io.grpc.ExperimentalApi
Kun Zhang73acc732015-06-26 16:32:05 -070029 public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.SimpleRequest,
nmittlerf8314582015-01-27 10:25:39 -080030 io.grpc.testing.integration.Test.SimpleResponse> METHOD_UNARY_CALL =
Kun Zhang73acc732015-06-26 16:32:05 -070031 io.grpc.MethodDescriptor.create(
32 io.grpc.MethodDescriptor.MethodType.UNARY,
Kun Zhang042b2782015-08-17 15:43:40 -070033 generateFullMethodName(
34 "grpc.testing.TestService", "UnaryCall"),
Eric Anderson47a7ccf2015-09-03 16:56:36 -070035 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.getDefaultInstance()),
36 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.getDefaultInstance()));
Kun Zhang5bb0ea92015-08-31 09:56:44 -070037 @io.grpc.ExperimentalApi
Kun Zhang73acc732015-06-26 16:32:05 -070038 public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
nmittlerf8314582015-01-27 10:25:39 -080039 io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL =
Kun Zhang73acc732015-06-26 16:32:05 -070040 io.grpc.MethodDescriptor.create(
41 io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING,
Kun Zhang042b2782015-08-17 15:43:40 -070042 generateFullMethodName(
43 "grpc.testing.TestService", "StreamingOutputCall"),
Eric Anderson47a7ccf2015-09-03 16:56:36 -070044 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
45 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
Kun Zhang5bb0ea92015-08-31 09:56:44 -070046 @io.grpc.ExperimentalApi
Kun Zhang73acc732015-06-26 16:32:05 -070047 public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
nmittlerf8314582015-01-27 10:25:39 -080048 io.grpc.testing.integration.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL =
Kun Zhang73acc732015-06-26 16:32:05 -070049 io.grpc.MethodDescriptor.create(
50 io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING,
Kun Zhang042b2782015-08-17 15:43:40 -070051 generateFullMethodName(
52 "grpc.testing.TestService", "StreamingInputCall"),
Eric Anderson47a7ccf2015-09-03 16:56:36 -070053 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.getDefaultInstance()),
54 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.getDefaultInstance()));
Kun Zhang5bb0ea92015-08-31 09:56:44 -070055 @io.grpc.ExperimentalApi
Kun Zhang73acc732015-06-26 16:32:05 -070056 public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070057 io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_FULL_BIDI_CALL =
Kun Zhang73acc732015-06-26 16:32:05 -070058 io.grpc.MethodDescriptor.create(
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070059 io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING,
Kun Zhang042b2782015-08-17 15:43:40 -070060 generateFullMethodName(
61 "grpc.testing.TestService", "FullBidiCall"),
Eric Anderson47a7ccf2015-09-03 16:56:36 -070062 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
63 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
Kun Zhang5bb0ea92015-08-31 09:56:44 -070064 @io.grpc.ExperimentalApi
Kun Zhang73acc732015-06-26 16:32:05 -070065 public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070066 io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_HALF_BIDI_CALL =
Kun Zhang73acc732015-06-26 16:32:05 -070067 io.grpc.MethodDescriptor.create(
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070068 io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING,
Kun Zhang042b2782015-08-17 15:43:40 -070069 generateFullMethodName(
70 "grpc.testing.TestService", "HalfBidiCall"),
Eric Anderson47a7ccf2015-09-03 16:56:36 -070071 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
72 io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
zhangkun835e607852015-01-22 12:31:56 -080073
nmittlerf8314582015-01-27 10:25:39 -080074 public static TestServiceStub newStub(io.grpc.Channel channel) {
Kun Zhangeb929672015-07-17 17:02:58 -070075 return new TestServiceStub(channel);
zhangkun835e607852015-01-22 12:31:56 -080076 }
77
78 public static TestServiceBlockingStub newBlockingStub(
nmittlerf8314582015-01-27 10:25:39 -080079 io.grpc.Channel channel) {
Kun Zhangeb929672015-07-17 17:02:58 -070080 return new TestServiceBlockingStub(channel);
zhangkun835e607852015-01-22 12:31:56 -080081 }
82
83 public static TestServiceFutureStub newFutureStub(
nmittlerf8314582015-01-27 10:25:39 -080084 io.grpc.Channel channel) {
Kun Zhangeb929672015-07-17 17:02:58 -070085 return new TestServiceFutureStub(channel);
zhangkun835e607852015-01-22 12:31:56 -080086 }
87
88 public static interface TestService {
89
nmittlerf8314582015-01-27 10:25:39 -080090 public void unaryCall(io.grpc.testing.integration.Test.SimpleRequest request,
91 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse> responseObserver);
zhangkun835e607852015-01-22 12:31:56 -080092
nmittlerf8314582015-01-27 10:25:39 -080093 public void streamingOutputCall(io.grpc.testing.integration.Test.StreamingOutputCallRequest request,
94 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver);
zhangkun835e607852015-01-22 12:31:56 -080095
nmittlerf8314582015-01-27 10:25:39 -080096 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallRequest> streamingInputCall(
97 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse> responseObserver);
zhangkun835e607852015-01-22 12:31:56 -080098
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -070099 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullBidiCall(
nmittlerf8314582015-01-27 10:25:39 -0800100 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800101
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -0700102 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfBidiCall(
nmittlerf8314582015-01-27 10:25:39 -0800103 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800104 }
105
Eric Anderson9bc5d932016-04-19 09:36:24 -0700106 @io.grpc.ExperimentalApi
Lukasz Strzalkowski2fbf1422016-04-08 02:28:32 +0200107 public static abstract class AbstractTestService implements TestService, io.grpc.BindableService {
108
109 @java.lang.Override
110 public void unaryCall(io.grpc.testing.integration.Test.SimpleRequest request,
111 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse> responseObserver) {
112 asyncUnimplementedUnaryCall(METHOD_UNARY_CALL, responseObserver);
113 }
114
115 @java.lang.Override
116 public void streamingOutputCall(io.grpc.testing.integration.Test.StreamingOutputCallRequest request,
117 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
118 asyncUnimplementedUnaryCall(METHOD_STREAMING_OUTPUT_CALL, responseObserver);
119 }
120
121 @java.lang.Override
122 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallRequest> streamingInputCall(
123 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse> responseObserver) {
124 return asyncUnimplementedStreamingCall(METHOD_STREAMING_INPUT_CALL, responseObserver);
125 }
126
127 @java.lang.Override
128 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullBidiCall(
129 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
130 return asyncUnimplementedStreamingCall(METHOD_FULL_BIDI_CALL, responseObserver);
131 }
132
133 @java.lang.Override
134 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfBidiCall(
135 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
136 return asyncUnimplementedStreamingCall(METHOD_HALF_BIDI_CALL, responseObserver);
137 }
138
139 @java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
140 return TestServiceGrpc.bindService(this);
141 }
142 }
143
zhangkun835e607852015-01-22 12:31:56 -0800144 public static interface TestServiceBlockingClient {
145
nmittlerf8314582015-01-27 10:25:39 -0800146 public io.grpc.testing.integration.Test.SimpleResponse unaryCall(io.grpc.testing.integration.Test.SimpleRequest request);
zhangkun835e607852015-01-22 12:31:56 -0800147
nmittlerf8314582015-01-27 10:25:39 -0800148 public java.util.Iterator<io.grpc.testing.integration.Test.StreamingOutputCallResponse> streamingOutputCall(
149 io.grpc.testing.integration.Test.StreamingOutputCallRequest request);
zhangkun835e607852015-01-22 12:31:56 -0800150 }
151
152 public static interface TestServiceFutureClient {
153
nmittlerf8314582015-01-27 10:25:39 -0800154 public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall(
155 io.grpc.testing.integration.Test.SimpleRequest request);
zhangkun835e607852015-01-22 12:31:56 -0800156 }
157
Kun Zhangeb929672015-07-17 17:02:58 -0700158 public static class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub>
zhangkun835e607852015-01-22 12:31:56 -0800159 implements TestService {
Kun Zhangeb929672015-07-17 17:02:58 -0700160 private TestServiceStub(io.grpc.Channel channel) {
161 super(channel);
zhangkun835e607852015-01-22 12:31:56 -0800162 }
163
Kun Zhangd3c5b002015-06-25 20:24:01 -0700164 private TestServiceStub(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700165 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700166 super(channel, callOptions);
Kun Zhangd3c5b002015-06-25 20:24:01 -0700167 }
168
zhangkun835e607852015-01-22 12:31:56 -0800169 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800170 protected TestServiceStub build(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700171 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700172 return new TestServiceStub(channel, callOptions);
zhangkun835e607852015-01-22 12:31:56 -0800173 }
174
175 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800176 public void unaryCall(io.grpc.testing.integration.Test.SimpleRequest request,
177 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse> responseObserver) {
zhangkun835e607852015-01-22 12:31:56 -0800178 asyncUnaryCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700179 getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request, responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800180 }
181
182 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800183 public void streamingOutputCall(io.grpc.testing.integration.Test.StreamingOutputCallRequest request,
184 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
zhangkun835e607852015-01-22 12:31:56 -0800185 asyncServerStreamingCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700186 getChannel().newCall(METHOD_STREAMING_OUTPUT_CALL, getCallOptions()), request, responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800187 }
188
189 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800190 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallRequest> streamingInputCall(
191 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse> responseObserver) {
zhangkun835e607852015-01-22 12:31:56 -0800192 return asyncClientStreamingCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700193 getChannel().newCall(METHOD_STREAMING_INPUT_CALL, getCallOptions()), responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800194 }
195
196 @java.lang.Override
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -0700197 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> fullBidiCall(
nmittlerf8314582015-01-27 10:25:39 -0800198 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -0700199 return asyncBidiStreamingCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700200 getChannel().newCall(METHOD_FULL_BIDI_CALL, getCallOptions()), responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800201 }
202
203 @java.lang.Override
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -0700204 public io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallRequest> halfBidiCall(
nmittlerf8314582015-01-27 10:25:39 -0800205 io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse> responseObserver) {
Carl Mastrangelo67fc45d2015-08-05 13:56:50 -0700206 return asyncBidiStreamingCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700207 getChannel().newCall(METHOD_HALF_BIDI_CALL, getCallOptions()), responseObserver);
zhangkun835e607852015-01-22 12:31:56 -0800208 }
209 }
210
Kun Zhangeb929672015-07-17 17:02:58 -0700211 public static class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub>
zhangkun835e607852015-01-22 12:31:56 -0800212 implements TestServiceBlockingClient {
Kun Zhangeb929672015-07-17 17:02:58 -0700213 private TestServiceBlockingStub(io.grpc.Channel channel) {
214 super(channel);
zhangkun835e607852015-01-22 12:31:56 -0800215 }
216
Kun Zhangd3c5b002015-06-25 20:24:01 -0700217 private TestServiceBlockingStub(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700218 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700219 super(channel, callOptions);
Kun Zhangd3c5b002015-06-25 20:24:01 -0700220 }
221
zhangkun835e607852015-01-22 12:31:56 -0800222 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800223 protected TestServiceBlockingStub build(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700224 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700225 return new TestServiceBlockingStub(channel, callOptions);
zhangkun835e607852015-01-22 12:31:56 -0800226 }
227
228 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800229 public io.grpc.testing.integration.Test.SimpleResponse unaryCall(io.grpc.testing.integration.Test.SimpleRequest request) {
zhangkun835e607852015-01-22 12:31:56 -0800230 return blockingUnaryCall(
Eric Anderson4168f672015-08-04 16:37:00 -0700231 getChannel(), METHOD_UNARY_CALL, getCallOptions(), request);
zhangkun835e607852015-01-22 12:31:56 -0800232 }
233
234 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800235 public java.util.Iterator<io.grpc.testing.integration.Test.StreamingOutputCallResponse> streamingOutputCall(
236 io.grpc.testing.integration.Test.StreamingOutputCallRequest request) {
zhangkun835e607852015-01-22 12:31:56 -0800237 return blockingServerStreamingCall(
Eric Anderson4168f672015-08-04 16:37:00 -0700238 getChannel(), METHOD_STREAMING_OUTPUT_CALL, getCallOptions(), request);
zhangkun835e607852015-01-22 12:31:56 -0800239 }
240 }
241
Kun Zhangeb929672015-07-17 17:02:58 -0700242 public static class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub>
zhangkun835e607852015-01-22 12:31:56 -0800243 implements TestServiceFutureClient {
Kun Zhangeb929672015-07-17 17:02:58 -0700244 private TestServiceFutureStub(io.grpc.Channel channel) {
245 super(channel);
zhangkun835e607852015-01-22 12:31:56 -0800246 }
247
Kun Zhangd3c5b002015-06-25 20:24:01 -0700248 private TestServiceFutureStub(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700249 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700250 super(channel, callOptions);
Kun Zhangd3c5b002015-06-25 20:24:01 -0700251 }
252
zhangkun835e607852015-01-22 12:31:56 -0800253 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800254 protected TestServiceFutureStub build(io.grpc.Channel channel,
Kun Zhangd3c5b002015-06-25 20:24:01 -0700255 io.grpc.CallOptions callOptions) {
Kun Zhangeb929672015-07-17 17:02:58 -0700256 return new TestServiceFutureStub(channel, callOptions);
zhangkun835e607852015-01-22 12:31:56 -0800257 }
258
259 @java.lang.Override
nmittlerf8314582015-01-27 10:25:39 -0800260 public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.integration.Test.SimpleResponse> unaryCall(
261 io.grpc.testing.integration.Test.SimpleRequest request) {
Kun Zhang686dcff2015-07-16 12:34:37 -0700262 return futureUnaryCall(
Eric Anderson23e63182015-09-10 08:36:08 -0700263 getChannel().newCall(METHOD_UNARY_CALL, getCallOptions()), request);
zhangkun835e607852015-01-22 12:31:56 -0800264 }
265 }
266
Eric Andersond52429d2015-11-13 16:50:08 -0800267 private static final int METHODID_UNARY_CALL = 0;
268 private static final int METHODID_STREAMING_OUTPUT_CALL = 1;
269 private static final int METHODID_STREAMING_INPUT_CALL = 2;
270 private static final int METHODID_FULL_BIDI_CALL = 3;
271 private static final int METHODID_HALF_BIDI_CALL = 4;
272
273 private static class MethodHandlers<Req, Resp> implements
274 io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
275 io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
276 io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
277 io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
278 private final TestService serviceImpl;
279 private final int methodId;
280
281 public MethodHandlers(TestService serviceImpl, int methodId) {
282 this.serviceImpl = serviceImpl;
283 this.methodId = methodId;
284 }
285
Carl Mastrangeloffe0dce2016-03-04 14:15:02 -0800286 @java.lang.Override
Eric Andersond52429d2015-11-13 16:50:08 -0800287 @java.lang.SuppressWarnings("unchecked")
288 public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
289 switch (methodId) {
290 case METHODID_UNARY_CALL:
291 serviceImpl.unaryCall((io.grpc.testing.integration.Test.SimpleRequest) request,
292 (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.SimpleResponse>) responseObserver);
293 break;
294 case METHODID_STREAMING_OUTPUT_CALL:
295 serviceImpl.streamingOutputCall((io.grpc.testing.integration.Test.StreamingOutputCallRequest) request,
296 (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver);
297 break;
298 default:
299 throw new AssertionError();
300 }
301 }
302
Carl Mastrangeloffe0dce2016-03-04 14:15:02 -0800303 @java.lang.Override
Eric Andersond52429d2015-11-13 16:50:08 -0800304 @java.lang.SuppressWarnings("unchecked")
305 public io.grpc.stub.StreamObserver<Req> invoke(
306 io.grpc.stub.StreamObserver<Resp> responseObserver) {
307 switch (methodId) {
308 case METHODID_STREAMING_INPUT_CALL:
309 return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall(
310 (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingInputCallResponse>) responseObserver);
311 case METHODID_FULL_BIDI_CALL:
312 return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall(
313 (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver);
314 case METHODID_HALF_BIDI_CALL:
315 return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall(
316 (io.grpc.stub.StreamObserver<io.grpc.testing.integration.Test.StreamingOutputCallResponse>) responseObserver);
317 default:
318 throw new AssertionError();
319 }
320 }
321 }
322
nmittlerf8314582015-01-27 10:25:39 -0800323 public static io.grpc.ServerServiceDefinition bindService(
zhangkun835e607852015-01-22 12:31:56 -0800324 final TestService serviceImpl) {
David P. Baker66b984c2015-08-21 13:00:26 -0400325 return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME)
Eric Andersond52429d2015-11-13 16:50:08 -0800326 .addMethod(
327 METHOD_UNARY_CALL,
328 asyncUnaryCall(
329 new MethodHandlers<
Eric Andersona6621da2015-09-10 17:37:21 -0700330 io.grpc.testing.integration.Test.SimpleRequest,
Eric Andersond52429d2015-11-13 16:50:08 -0800331 io.grpc.testing.integration.Test.SimpleResponse>(
332 serviceImpl, METHODID_UNARY_CALL)))
333 .addMethod(
334 METHOD_STREAMING_OUTPUT_CALL,
335 asyncServerStreamingCall(
336 new MethodHandlers<
Eric Andersona6621da2015-09-10 17:37:21 -0700337 io.grpc.testing.integration.Test.StreamingOutputCallRequest,
Eric Andersond52429d2015-11-13 16:50:08 -0800338 io.grpc.testing.integration.Test.StreamingOutputCallResponse>(
339 serviceImpl, METHODID_STREAMING_OUTPUT_CALL)))
340 .addMethod(
341 METHOD_STREAMING_INPUT_CALL,
342 asyncClientStreamingCall(
343 new MethodHandlers<
Eric Andersona6621da2015-09-10 17:37:21 -0700344 io.grpc.testing.integration.Test.StreamingInputCallRequest,
Eric Andersond52429d2015-11-13 16:50:08 -0800345 io.grpc.testing.integration.Test.StreamingInputCallResponse>(
346 serviceImpl, METHODID_STREAMING_INPUT_CALL)))
347 .addMethod(
348 METHOD_FULL_BIDI_CALL,
349 asyncBidiStreamingCall(
350 new MethodHandlers<
Eric Andersona6621da2015-09-10 17:37:21 -0700351 io.grpc.testing.integration.Test.StreamingOutputCallRequest,
Eric Andersond52429d2015-11-13 16:50:08 -0800352 io.grpc.testing.integration.Test.StreamingOutputCallResponse>(
353 serviceImpl, METHODID_FULL_BIDI_CALL)))
354 .addMethod(
355 METHOD_HALF_BIDI_CALL,
356 asyncBidiStreamingCall(
357 new MethodHandlers<
Eric Andersona6621da2015-09-10 17:37:21 -0700358 io.grpc.testing.integration.Test.StreamingOutputCallRequest,
Eric Andersond52429d2015-11-13 16:50:08 -0800359 io.grpc.testing.integration.Test.StreamingOutputCallResponse>(
360 serviceImpl, METHODID_HALF_BIDI_CALL)))
361 .build();
zhangkun835e607852015-01-22 12:31:56 -0800362 }
363}