From abffc76da2289c94d15a69bace8b344075ffaa83 Mon Sep 17 00:00:00 2001 From: Eric Gribkoff Date: Thu, 27 Oct 2016 23:03:39 -0700 Subject: [PATCH] addressing reviewer comments --- .../proto/BenchmarkServiceGrpc.java | 4 +- .../benchmarks/proto/WorkerServiceGrpc.java | 4 +- .../src/java_plugin/cpp/java_generator.cpp | 10 +- compiler/src/test/golden/TestService.java.txt | 4 +- .../main/java/io/grpc/ServiceDescriptor.java | 30 +-- .../grpc/io/grpc/grpclb/LoadBalancerGrpc.java | 4 +- .../integration/MetricsServiceGrpc.java | 4 +- .../integration/ReconnectServiceGrpc.java | 4 +- .../testing/integration/TestServiceGrpc.java | 4 +- .../integration/UnimplementedServiceGrpc.java | 4 +- .../v1alpha/ServerReflectionGrpc.java | 216 ----------------- .../testing/ReflectableServiceGrpc.java | 224 ------------------ ....java => ProtoFileDescriptorSupplier.java} | 7 +- .../grpc/io/grpc/health/v1/HealthGrpc.java | 4 +- 14 files changed, 42 insertions(+), 481 deletions(-) delete mode 100644 protobuf/src/generated/main/grpc/io/grpc/reflection/v1alpha/ServerReflectionGrpc.java delete mode 100644 protobuf/src/generated/test/grpc/io/grpc/reflection/testing/ReflectableServiceGrpc.java rename protobuf/src/main/java/io/grpc/protobuf/{reflection/ProtoFileDescriptorWrapper.java => ProtoFileDescriptorSupplier.java} (89%) diff --git a/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java b/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java index 3cb9149e93..877ebe7294 100644 --- a/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java +++ b/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.benchmarks.proto.Services.getDescriptor(); @@ -274,7 +274,7 @@ public class BenchmarkServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new BenchmarkServiceDescriptorWrapper(), + new BenchmarkServiceDescriptorSupplier(), METHOD_UNARY_CALL, METHOD_STREAMING_CALL); } diff --git a/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java b/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java index e686cd3a04..c168f678fc 100644 --- a/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java +++ b/benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.benchmarks.proto.Services.getDescriptor(); @@ -392,7 +392,7 @@ public class WorkerServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new WorkerServiceDescriptorWrapper(), + new WorkerServiceDescriptorSupplier(), METHOD_RUN_SERVER, METHOD_RUN_CLIENT, METHOD_CORE_COUNT, diff --git a/compiler/src/java_plugin/cpp/java_generator.cpp b/compiler/src/java_plugin/cpp/java_generator.cpp index d209f6847d..d40088be24 100644 --- a/compiler/src/java_plugin/cpp/java_generator.cpp +++ b/compiler/src/java_plugin/cpp/java_generator.cpp @@ -889,11 +889,11 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service, 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()); p->Print( *vars, - "public static final class $proto_descriptor_wrapper$ implements $ProtoFileDescriptorWrapper$ {\n"); + "private static final class $proto_descriptor_supplier$ implements $ProtoFileDescriptorSupplier$ {\n"); p->Indent(); p->Print(*vars, "@$Override$\n"); p->Print( @@ -923,7 +923,7 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service, p->Indent(); p->Print( *vars, - "new $proto_descriptor_wrapper$()"); + "new $proto_descriptor_supplier$()"); p->Outdent(); p->Outdent(); } else { @@ -1180,8 +1180,8 @@ void GenerateService(const ServiceDescriptor* service, "io.grpc.ServerServiceDefinition"; vars["ServiceDescriptor"] = "io.grpc.ServiceDescriptor"; - vars["ProtoFileDescriptorWrapper"] = - "io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper"; + vars["ProtoFileDescriptorSupplier"] = + "io.grpc.protobuf.ProtoFileDescriptorSupplier"; vars["AbstractStub"] = "io.grpc.stub.AbstractStub"; vars["MethodDescriptor"] = "io.grpc.MethodDescriptor"; vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils"; diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt index 31650c1f23..966842eeeb 100644 --- a/compiler/src/test/golden/TestService.java.txt +++ b/compiler/src/test/golden/TestService.java.txt @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.testing.integration.Test.getDescriptor(); @@ -437,7 +437,7 @@ public class TestServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new TestServiceDescriptorWrapper(), + new TestServiceDescriptorSupplier(), METHOD_UNARY_CALL, METHOD_STREAMING_OUTPUT_CALL, METHOD_STREAMING_INPUT_CALL, diff --git a/core/src/main/java/io/grpc/ServiceDescriptor.java b/core/src/main/java/io/grpc/ServiceDescriptor.java index a378bd799f..b67a6ae586 100644 --- a/core/src/main/java/io/grpc/ServiceDescriptor.java +++ b/core/src/main/java/io/grpc/ServiceDescriptor.java @@ -47,26 +47,27 @@ public final class ServiceDescriptor { private final String name; private final Collection> methods; - private Object attachedObject = null; + private final Object marshallerDescriptor; public ServiceDescriptor(String name, MethodDescriptor... methods) { - this(name, Arrays.asList(methods)); + this(name, null, Arrays.asList(methods)); } public ServiceDescriptor(String name, Collection> methods) { - this.name = Preconditions.checkNotNull(name, "name"); - this.methods = Collections.unmodifiableList(new ArrayList>(methods)); + this(name, null, methods); } - public ServiceDescriptor(String name, Object attachedObject, MethodDescriptor... methods) { - this(name, methods); - this.attachedObject = attachedObject; + public ServiceDescriptor(String name, Object marshallerDescriptor, + MethodDescriptor... methods) { + this(name, marshallerDescriptor, Arrays.asList(methods)); } - public ServiceDescriptor(String name, Object attachedObject, + /** Creates a new ServiceDescriptor. */ + public ServiceDescriptor(String name, Object marshallerDescriptor, Collection> methods) { - this(name, methods); - this.attachedObject = attachedObject; + this.name = Preconditions.checkNotNull(name, "name"); + this.marshallerDescriptor = marshallerDescriptor; + this.methods = Collections.unmodifiableList(new ArrayList>(methods)); } /** 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 - * attaching a object that allows retrieving the underlying proto object. + * Returns a marshaller-specific object that provides additional information about the service. + * For example, when using Protobuf this should generally be a + * {@link io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper}, when present. */ @Nullable - public Object getAttachedObject() { - return attachedObject; + public Object getMarshallerDescriptor() { + return marshallerDescriptor; } } \ No newline at end of file diff --git a/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java b/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java index 793e337db3..375de7afe7 100644 --- a/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java +++ b/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.grpclb.LoadBalancerProto.getDescriptor(); @@ -205,7 +205,7 @@ public class LoadBalancerGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new LoadBalancerDescriptorWrapper(), + new LoadBalancerDescriptorSupplier(), METHOD_BALANCE_LOAD); } diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java index 476ed40aa0..2d2eb5e26c 100644 --- a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.testing.integration.Metrics.getDescriptor(); @@ -283,7 +283,7 @@ public class MetricsServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new MetricsServiceDescriptorWrapper(), + new MetricsServiceDescriptorSupplier(), METHOD_GET_ALL_GAUGES, METHOD_GET_GAUGE); } diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java index 5e395b4f0d..3e22376b3f 100644 --- a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.testing.integration.Test.getDescriptor(); @@ -281,7 +281,7 @@ public class ReconnectServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new ReconnectServiceDescriptorWrapper(), + new ReconnectServiceDescriptorSupplier(), METHOD_START, METHOD_STOP); } diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java index 09ced170e2..382b146de1 100644 --- a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.testing.integration.Test.getDescriptor(); @@ -568,7 +568,7 @@ public class TestServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new TestServiceDescriptorWrapper(), + new TestServiceDescriptorSupplier(), METHOD_EMPTY_CALL, METHOD_UNARY_CALL, METHOD_STREAMING_OUTPUT_CALL, diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java index 3bde78e291..65941bf2ee 100644 --- a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.testing.integration.Test.getDescriptor(); @@ -247,7 +247,7 @@ public class UnimplementedServiceGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new UnimplementedServiceDescriptorWrapper(), + new UnimplementedServiceDescriptorSupplier(), METHOD_UNIMPLEMENTED_CALL); } diff --git a/protobuf/src/generated/main/grpc/io/grpc/reflection/v1alpha/ServerReflectionGrpc.java b/protobuf/src/generated/main/grpc/io/grpc/reflection/v1alpha/ServerReflectionGrpc.java deleted file mode 100644 index b5663a7fb6..0000000000 --- a/protobuf/src/generated/main/grpc/io/grpc/reflection/v1alpha/ServerReflectionGrpc.java +++ /dev/null @@ -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 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 { - - /** - *
-     * The reflection service is structured as a bidirectional stream, ensuring
-     * all related requests go to a single server.
-     * 
- */ - public io.grpc.stub.StreamObserver serverReflectionInfo( - io.grpc.stub.StreamObserver 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 { - 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); - } - - /** - *
-     * The reflection service is structured as a bidirectional stream, ensuring
-     * all related requests go to a single server.
-     * 
- */ - public io.grpc.stub.StreamObserver serverReflectionInfo( - io.grpc.stub.StreamObserver responseObserver) { - return asyncBidiStreamingCall( - getChannel().newCall(METHOD_SERVER_REFLECTION_INFO, getCallOptions()), responseObserver); - } - } - - /** - */ - public static final class ServerReflectionBlockingStub extends io.grpc.stub.AbstractStub { - 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 { - 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 implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - 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 responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_SERVER_REFLECTION_INFO: - return (io.grpc.stub.StreamObserver) serviceImpl.serverReflectionInfo( - (io.grpc.stub.StreamObserver) 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; - } -} diff --git a/protobuf/src/generated/test/grpc/io/grpc/reflection/testing/ReflectableServiceGrpc.java b/protobuf/src/generated/test/grpc/io/grpc/reflection/testing/ReflectableServiceGrpc.java deleted file mode 100644 index 99398bae39..0000000000 --- a/protobuf/src/generated/test/grpc/io/grpc/reflection/testing/ReflectableServiceGrpc.java +++ /dev/null @@ -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 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 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 { - 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 responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_METHOD, getCallOptions()), request, responseObserver); - } - } - - /** - */ - public static final class ReflectableServiceBlockingStub extends io.grpc.stub.AbstractStub { - 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 { - 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 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 implements - io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - 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 responseObserver) { - switch (methodId) { - case METHODID_METHOD: - serviceImpl.method((io.grpc.reflection.testing.Request) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver 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; - } -} diff --git a/protobuf/src/main/java/io/grpc/protobuf/reflection/ProtoFileDescriptorWrapper.java b/protobuf/src/main/java/io/grpc/protobuf/ProtoFileDescriptorSupplier.java similarity index 89% rename from protobuf/src/main/java/io/grpc/protobuf/reflection/ProtoFileDescriptorWrapper.java rename to protobuf/src/main/java/io/grpc/protobuf/ProtoFileDescriptorSupplier.java index 0b129b4b07..9338b0ea07 100644 --- a/protobuf/src/main/java/io/grpc/protobuf/reflection/ProtoFileDescriptorWrapper.java +++ b/protobuf/src/main/java/io/grpc/protobuf/ProtoFileDescriptorSupplier.java @@ -29,14 +29,13 @@ * 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; /** - * The generated code implements this interface to provide access to the underlying proto - * file descriptor. + * Provides access to the underlying proto file descriptor. */ -public interface ProtoFileDescriptorWrapper { +public interface ProtoFileDescriptorSupplier { FileDescriptor getFileDescriptor(); } diff --git a/services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java b/services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java index 56b0796e3e..620db75712 100644 --- a/services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java +++ b/services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java @@ -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 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { return io.grpc.health.v1.HealthProto.getDescriptor(); @@ -215,7 +215,7 @@ public class HealthGrpc { public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() { if (serviceDescriptor == null) { serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME, - new HealthDescriptorWrapper(), + new HealthDescriptorSupplier(), METHOD_CHECK); }