addressing reviewer comments

This commit is contained in:
Eric Gribkoff 2016-10-27 23:03:39 -07:00
parent aff1cac7da
commit abffc76da2
14 changed files with 42 additions and 481 deletions

View File

@ -262,7 +262,7 @@ public class BenchmarkServiceGrpc {
} }
} }
public static final class BenchmarkServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class BenchmarkServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.benchmarks.proto.Services.getDescriptor(); return io.grpc.benchmarks.proto.Services.getDescriptor();
@ -274,7 +274,7 @@ public class BenchmarkServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new BenchmarkServiceDescriptorWrapper(), new BenchmarkServiceDescriptorSupplier(),
METHOD_UNARY_CALL, METHOD_UNARY_CALL,
METHOD_STREAMING_CALL); METHOD_STREAMING_CALL);
} }

View File

@ -380,7 +380,7 @@ public class WorkerServiceGrpc {
} }
} }
public static final class WorkerServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class WorkerServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.benchmarks.proto.Services.getDescriptor(); return io.grpc.benchmarks.proto.Services.getDescriptor();
@ -392,7 +392,7 @@ public class WorkerServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new WorkerServiceDescriptorWrapper(), new WorkerServiceDescriptorSupplier(),
METHOD_RUN_SERVER, METHOD_RUN_SERVER,
METHOD_RUN_CLIENT, METHOD_RUN_CLIENT,
METHOD_CORE_COUNT, METHOD_CORE_COUNT,

View File

@ -889,11 +889,11 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
if (flavor == ProtoFlavor::NORMAL) { if (flavor == ProtoFlavor::NORMAL) {
(*vars)["proto_descriptor_wrapper"] = service->name() + "DescriptorWrapper"; (*vars)["proto_descriptor_supplier"] = service->name() + "DescriptorSupplier";
(*vars)["proto_class_name"] = google::protobuf::compiler::java::ClassName(service->file()); (*vars)["proto_class_name"] = google::protobuf::compiler::java::ClassName(service->file());
p->Print( p->Print(
*vars, *vars,
"public static final class $proto_descriptor_wrapper$ implements $ProtoFileDescriptorWrapper$ {\n"); "private static final class $proto_descriptor_supplier$ implements $ProtoFileDescriptorSupplier$ {\n");
p->Indent(); p->Indent();
p->Print(*vars, "@$Override$\n"); p->Print(*vars, "@$Override$\n");
p->Print( p->Print(
@ -923,7 +923,7 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
p->Indent(); p->Indent();
p->Print( p->Print(
*vars, *vars,
"new $proto_descriptor_wrapper$()"); "new $proto_descriptor_supplier$()");
p->Outdent(); p->Outdent();
p->Outdent(); p->Outdent();
} else { } else {
@ -1180,8 +1180,8 @@ void GenerateService(const ServiceDescriptor* service,
"io.grpc.ServerServiceDefinition"; "io.grpc.ServerServiceDefinition";
vars["ServiceDescriptor"] = vars["ServiceDescriptor"] =
"io.grpc.ServiceDescriptor"; "io.grpc.ServiceDescriptor";
vars["ProtoFileDescriptorWrapper"] = vars["ProtoFileDescriptorSupplier"] =
"io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper"; "io.grpc.protobuf.ProtoFileDescriptorSupplier";
vars["AbstractStub"] = "io.grpc.stub.AbstractStub"; vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
vars["MethodDescriptor"] = "io.grpc.MethodDescriptor"; vars["MethodDescriptor"] = "io.grpc.MethodDescriptor";
vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils"; vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils";

View File

@ -425,7 +425,7 @@ public class TestServiceGrpc {
} }
} }
public static final class TestServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class TestServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.testing.integration.Test.getDescriptor(); return io.grpc.testing.integration.Test.getDescriptor();
@ -437,7 +437,7 @@ public class TestServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new TestServiceDescriptorWrapper(), new TestServiceDescriptorSupplier(),
METHOD_UNARY_CALL, METHOD_UNARY_CALL,
METHOD_STREAMING_OUTPUT_CALL, METHOD_STREAMING_OUTPUT_CALL,
METHOD_STREAMING_INPUT_CALL, METHOD_STREAMING_INPUT_CALL,

View File

@ -47,26 +47,27 @@ public final class ServiceDescriptor {
private final String name; private final String name;
private final Collection<MethodDescriptor<?, ?>> methods; private final Collection<MethodDescriptor<?, ?>> methods;
private Object attachedObject = null; private final Object marshallerDescriptor;
public ServiceDescriptor(String name, MethodDescriptor<?, ?>... methods) { public ServiceDescriptor(String name, MethodDescriptor<?, ?>... methods) {
this(name, Arrays.asList(methods)); this(name, null, Arrays.asList(methods));
} }
public ServiceDescriptor(String name, Collection<MethodDescriptor<?, ?>> methods) { public ServiceDescriptor(String name, Collection<MethodDescriptor<?, ?>> methods) {
this.name = Preconditions.checkNotNull(name, "name"); this(name, null, methods);
this.methods = Collections.unmodifiableList(new ArrayList<MethodDescriptor<?, ?>>(methods));
} }
public ServiceDescriptor(String name, Object attachedObject, MethodDescriptor<?, ?>... methods) { public ServiceDescriptor(String name, Object marshallerDescriptor,
this(name, methods); MethodDescriptor<?, ?>... methods) {
this.attachedObject = attachedObject; this(name, marshallerDescriptor, Arrays.asList(methods));
} }
public ServiceDescriptor(String name, Object attachedObject, /** Creates a new ServiceDescriptor. */
public ServiceDescriptor(String name, Object marshallerDescriptor,
Collection<MethodDescriptor<?, ?>> methods) { Collection<MethodDescriptor<?, ?>> methods) {
this(name, methods); this.name = Preconditions.checkNotNull(name, "name");
this.attachedObject = attachedObject; this.marshallerDescriptor = marshallerDescriptor;
this.methods = Collections.unmodifiableList(new ArrayList<MethodDescriptor<?, ?>>(methods));
} }
/** Simple name of the service. It is not an absolute path. */ /** Simple name of the service. It is not an absolute path. */
@ -83,11 +84,12 @@ public final class ServiceDescriptor {
} }
/** /**
* The generated code may attach an object to a service descriptor, such as the proto codegen * Returns a marshaller-specific object that provides additional information about the service.
* attaching a object that allows retrieving the underlying proto object. * For example, when using Protobuf this should generally be a
* {@link io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper}, when present.
*/ */
@Nullable @Nullable
public Object getAttachedObject() { public Object getMarshallerDescriptor() {
return attachedObject; return marshallerDescriptor;
} }
} }

View File

@ -193,7 +193,7 @@ public class LoadBalancerGrpc {
} }
} }
public static final class LoadBalancerDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class LoadBalancerDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.grpclb.LoadBalancerProto.getDescriptor(); return io.grpc.grpclb.LoadBalancerProto.getDescriptor();
@ -205,7 +205,7 @@ public class LoadBalancerGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new LoadBalancerDescriptorWrapper(), new LoadBalancerDescriptorSupplier(),
METHOD_BALANCE_LOAD); METHOD_BALANCE_LOAD);
} }

View File

@ -271,7 +271,7 @@ public class MetricsServiceGrpc {
} }
} }
public static final class MetricsServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class MetricsServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.testing.integration.Metrics.getDescriptor(); return io.grpc.testing.integration.Metrics.getDescriptor();
@ -283,7 +283,7 @@ public class MetricsServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new MetricsServiceDescriptorWrapper(), new MetricsServiceDescriptorSupplier(),
METHOD_GET_ALL_GAUGES, METHOD_GET_ALL_GAUGES,
METHOD_GET_GAUGE); METHOD_GET_GAUGE);
} }

View File

@ -269,7 +269,7 @@ public class ReconnectServiceGrpc {
} }
} }
public static final class ReconnectServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class ReconnectServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.testing.integration.Test.getDescriptor(); return io.grpc.testing.integration.Test.getDescriptor();
@ -281,7 +281,7 @@ public class ReconnectServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new ReconnectServiceDescriptorWrapper(), new ReconnectServiceDescriptorSupplier(),
METHOD_START, METHOD_START,
METHOD_STOP); METHOD_STOP);
} }

View File

@ -556,7 +556,7 @@ public class TestServiceGrpc {
} }
} }
public static final class TestServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class TestServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.testing.integration.Test.getDescriptor(); return io.grpc.testing.integration.Test.getDescriptor();
@ -568,7 +568,7 @@ public class TestServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new TestServiceDescriptorWrapper(), new TestServiceDescriptorSupplier(),
METHOD_EMPTY_CALL, METHOD_EMPTY_CALL,
METHOD_UNARY_CALL, METHOD_UNARY_CALL,
METHOD_STREAMING_OUTPUT_CALL, METHOD_STREAMING_OUTPUT_CALL,

View File

@ -235,7 +235,7 @@ public class UnimplementedServiceGrpc {
} }
} }
public static final class UnimplementedServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class UnimplementedServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.testing.integration.Test.getDescriptor(); return io.grpc.testing.integration.Test.getDescriptor();
@ -247,7 +247,7 @@ public class UnimplementedServiceGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new UnimplementedServiceDescriptorWrapper(), new UnimplementedServiceDescriptorSupplier(),
METHOD_UNIMPLEMENTED_CALL); METHOD_UNIMPLEMENTED_CALL);
} }

View File

@ -1,216 +0,0 @@
package io.grpc.reflection.v1alpha;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.1.0-SNAPSHOT)",
comments = "Source: io/grpc/reflection/v1alpha/reflection.proto")
public class ServerReflectionGrpc {
private ServerReflectionGrpc() {}
public static final String SERVICE_NAME = "grpc.reflection.v1alpha.ServerReflection";
// Static method descriptors that strictly reflect the proto.
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static final io.grpc.MethodDescriptor<io.grpc.reflection.v1alpha.ServerReflectionRequest,
io.grpc.reflection.v1alpha.ServerReflectionResponse> METHOD_SERVER_REFLECTION_INFO =
io.grpc.MethodDescriptor.create(
io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING,
generateFullMethodName(
"grpc.reflection.v1alpha.ServerReflection", "ServerReflectionInfo"),
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.reflection.v1alpha.ServerReflectionRequest.getDefaultInstance()),
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.reflection.v1alpha.ServerReflectionResponse.getDefaultInstance()));
/**
* Creates a new async stub that supports all call types for the service
*/
public static ServerReflectionStub newStub(io.grpc.Channel channel) {
return new ServerReflectionStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static ServerReflectionBlockingStub newBlockingStub(
io.grpc.Channel channel) {
return new ServerReflectionBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service
*/
public static ServerReflectionFutureStub newFutureStub(
io.grpc.Channel channel) {
return new ServerReflectionFutureStub(channel);
}
/**
*/
public static abstract class ServerReflectionImplBase implements io.grpc.BindableService {
/**
* <pre>
* The reflection service is structured as a bidirectional stream, ensuring
* all related requests go to a single server.
* </pre>
*/
public io.grpc.stub.StreamObserver<io.grpc.reflection.v1alpha.ServerReflectionRequest> serverReflectionInfo(
io.grpc.stub.StreamObserver<io.grpc.reflection.v1alpha.ServerReflectionResponse> responseObserver) {
return asyncUnimplementedStreamingCall(METHOD_SERVER_REFLECTION_INFO, responseObserver);
}
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
METHOD_SERVER_REFLECTION_INFO,
asyncBidiStreamingCall(
new MethodHandlers<
io.grpc.reflection.v1alpha.ServerReflectionRequest,
io.grpc.reflection.v1alpha.ServerReflectionResponse>(
this, METHODID_SERVER_REFLECTION_INFO)))
.build();
}
}
/**
*/
public static final class ServerReflectionStub extends io.grpc.stub.AbstractStub<ServerReflectionStub> {
private ServerReflectionStub(io.grpc.Channel channel) {
super(channel);
}
private ServerReflectionStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServerReflectionStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ServerReflectionStub(channel, callOptions);
}
/**
* <pre>
* The reflection service is structured as a bidirectional stream, ensuring
* all related requests go to a single server.
* </pre>
*/
public io.grpc.stub.StreamObserver<io.grpc.reflection.v1alpha.ServerReflectionRequest> serverReflectionInfo(
io.grpc.stub.StreamObserver<io.grpc.reflection.v1alpha.ServerReflectionResponse> responseObserver) {
return asyncBidiStreamingCall(
getChannel().newCall(METHOD_SERVER_REFLECTION_INFO, getCallOptions()), responseObserver);
}
}
/**
*/
public static final class ServerReflectionBlockingStub extends io.grpc.stub.AbstractStub<ServerReflectionBlockingStub> {
private ServerReflectionBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private ServerReflectionBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServerReflectionBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ServerReflectionBlockingStub(channel, callOptions);
}
}
/**
*/
public static final class ServerReflectionFutureStub extends io.grpc.stub.AbstractStub<ServerReflectionFutureStub> {
private ServerReflectionFutureStub(io.grpc.Channel channel) {
super(channel);
}
private ServerReflectionFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServerReflectionFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ServerReflectionFutureStub(channel, callOptions);
}
}
private static final int METHODID_SERVER_REFLECTION_INFO = 0;
private static class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final ServerReflectionImplBase serviceImpl;
private final int methodId;
public MethodHandlers(ServerReflectionImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_SERVER_REFLECTION_INFO:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.serverReflectionInfo(
(io.grpc.stub.StreamObserver<io.grpc.reflection.v1alpha.ServerReflectionResponse>) responseObserver);
default:
throw new AssertionError();
}
}
}
public static final class ServerReflectionDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.reflection.v1alpha.ServerReflectionProto.getDescriptor();
}
}
private static io.grpc.ServiceDescriptor serviceDescriptor;
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new ServerReflectionDescriptorWrapper(),
METHOD_SERVER_REFLECTION_INFO);
}
return serviceDescriptor;
}
}

View File

@ -1,224 +0,0 @@
package io.grpc.reflection.testing;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.1.0-SNAPSHOT)",
comments = "Source: io/grpc/reflection/testing/reflection_test.proto")
public class ReflectableServiceGrpc {
private ReflectableServiceGrpc() {}
public static final String SERVICE_NAME = "grpc.reflection.testing.ReflectableService";
// Static method descriptors that strictly reflect the proto.
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static final io.grpc.MethodDescriptor<io.grpc.reflection.testing.Request,
io.grpc.reflection.testing.Reply> METHOD_METHOD =
io.grpc.MethodDescriptor.create(
io.grpc.MethodDescriptor.MethodType.UNARY,
generateFullMethodName(
"grpc.reflection.testing.ReflectableService", "Method"),
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.reflection.testing.Request.getDefaultInstance()),
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.reflection.testing.Reply.getDefaultInstance()));
/**
* Creates a new async stub that supports all call types for the service
*/
public static ReflectableServiceStub newStub(io.grpc.Channel channel) {
return new ReflectableServiceStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static ReflectableServiceBlockingStub newBlockingStub(
io.grpc.Channel channel) {
return new ReflectableServiceBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service
*/
public static ReflectableServiceFutureStub newFutureStub(
io.grpc.Channel channel) {
return new ReflectableServiceFutureStub(channel);
}
/**
*/
public static abstract class ReflectableServiceImplBase implements io.grpc.BindableService {
/**
*/
public void method(io.grpc.reflection.testing.Request request,
io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply> responseObserver) {
asyncUnimplementedUnaryCall(METHOD_METHOD, responseObserver);
}
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
METHOD_METHOD,
asyncUnaryCall(
new MethodHandlers<
io.grpc.reflection.testing.Request,
io.grpc.reflection.testing.Reply>(
this, METHODID_METHOD)))
.build();
}
}
/**
*/
public static final class ReflectableServiceStub extends io.grpc.stub.AbstractStub<ReflectableServiceStub> {
private ReflectableServiceStub(io.grpc.Channel channel) {
super(channel);
}
private ReflectableServiceStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ReflectableServiceStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ReflectableServiceStub(channel, callOptions);
}
/**
*/
public void method(io.grpc.reflection.testing.Request request,
io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply> responseObserver) {
asyncUnaryCall(
getChannel().newCall(METHOD_METHOD, getCallOptions()), request, responseObserver);
}
}
/**
*/
public static final class ReflectableServiceBlockingStub extends io.grpc.stub.AbstractStub<ReflectableServiceBlockingStub> {
private ReflectableServiceBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private ReflectableServiceBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ReflectableServiceBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ReflectableServiceBlockingStub(channel, callOptions);
}
/**
*/
public io.grpc.reflection.testing.Reply method(io.grpc.reflection.testing.Request request) {
return blockingUnaryCall(
getChannel(), METHOD_METHOD, getCallOptions(), request);
}
}
/**
*/
public static final class ReflectableServiceFutureStub extends io.grpc.stub.AbstractStub<ReflectableServiceFutureStub> {
private ReflectableServiceFutureStub(io.grpc.Channel channel) {
super(channel);
}
private ReflectableServiceFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ReflectableServiceFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new ReflectableServiceFutureStub(channel, callOptions);
}
/**
*/
public com.google.common.util.concurrent.ListenableFuture<io.grpc.reflection.testing.Reply> method(
io.grpc.reflection.testing.Request request) {
return futureUnaryCall(
getChannel().newCall(METHOD_METHOD, getCallOptions()), request);
}
}
private static final int METHODID_METHOD = 0;
private static class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final ReflectableServiceImplBase serviceImpl;
private final int methodId;
public MethodHandlers(ReflectableServiceImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_METHOD:
serviceImpl.method((io.grpc.reflection.testing.Request) request,
(io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
public static final class ReflectableServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.reflection.testing.ReflectionTestProto.getDescriptor();
}
}
private static io.grpc.ServiceDescriptor serviceDescriptor;
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new ReflectableServiceDescriptorWrapper(),
METHOD_METHOD);
}
return serviceDescriptor;
}
}

View File

@ -29,14 +29,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package io.grpc.protobuf.reflection; package io.grpc.protobuf;
import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.Descriptors.FileDescriptor;
/** /**
* The generated code implements this interface to provide access to the underlying proto * Provides access to the underlying proto file descriptor.
* file descriptor.
*/ */
public interface ProtoFileDescriptorWrapper { public interface ProtoFileDescriptorSupplier {
FileDescriptor getFileDescriptor(); FileDescriptor getFileDescriptor();
} }

View File

@ -203,7 +203,7 @@ public class HealthGrpc {
} }
} }
public static final class HealthDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper { private static final class HealthDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
@java.lang.Override @java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.health.v1.HealthProto.getDescriptor(); return io.grpc.health.v1.HealthProto.getDescriptor();
@ -215,7 +215,7 @@ public class HealthGrpc {
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
if (serviceDescriptor == null) { if (serviceDescriptor == null) {
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
new HealthDescriptorWrapper(), new HealthDescriptorSupplier(),
METHOD_CHECK); METHOD_CHECK);
} }