mirror of https://github.com/grpc/grpc-java.git
Prevent construction of container classes and reduce API
This commit is contained in:
parent
e969a900a0
commit
be0d7e911a
|
@ -58,7 +58,7 @@ import java.util.concurrent.Executor;
|
|||
* <p> Uses the new and simplified Google auth library:
|
||||
* https://github.com/google/google-auth-library-java
|
||||
*/
|
||||
public class ClientAuthInterceptor implements ClientInterceptor {
|
||||
public final class ClientAuthInterceptor implements ClientInterceptor {
|
||||
|
||||
private final Credentials credentials;
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class TestServiceGrpc {
|
||||
|
||||
private TestServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.TestService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class WorkerGrpc {
|
||||
|
||||
private WorkerGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.Worker";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -511,6 +511,9 @@ static void PrintService(const ServiceDescriptor* service,
|
|||
"@$Generated$(\"by gRPC proto compiler\")\n"
|
||||
"public class $service_class_name$ {\n\n");
|
||||
p->Indent();
|
||||
p->Print(
|
||||
*vars,
|
||||
"private $service_class_name$() {}\n\n");
|
||||
|
||||
p->Print(
|
||||
*vars,
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class TestServiceGrpc {
|
||||
|
||||
private TestServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.TestService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -18,6 +18,8 @@ import java.io.IOException;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class TestServiceGrpc {
|
||||
|
||||
private TestServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.TestService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class GreeterGrpc {
|
||||
|
||||
private GreeterGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "helloworld.Greeter";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class RouteGuideGrpc {
|
||||
|
||||
private RouteGuideGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "routeguide.RouteGuide";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class ReconnectServiceGrpc {
|
||||
|
||||
private ReconnectServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.ReconnectService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class TestServiceGrpc {
|
||||
|
||||
private TestServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.TestService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -16,6 +16,8 @@ import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class UnimplementedServiceGrpc {
|
||||
|
||||
private UnimplementedServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.UnimplementedService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
|
|
|
@ -55,6 +55,8 @@ import javax.annotation.Nullable;
|
|||
* that the runtime can vary behavior without requiring regeneration of the stub.
|
||||
*/
|
||||
public class ClientCalls {
|
||||
// Prevent instantiation
|
||||
private ClientCalls() {}
|
||||
|
||||
/**
|
||||
* Executes a unary call with a response {@link StreamObserver}.
|
||||
|
|
|
@ -35,6 +35,7 @@ import io.grpc.CallOptions;
|
|||
import io.grpc.Channel;
|
||||
import io.grpc.ClientCall;
|
||||
import io.grpc.ClientInterceptor;
|
||||
import io.grpc.ExperimentalApi;
|
||||
import io.grpc.ForwardingClientCall.SimpleForwardingClientCall;
|
||||
import io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener;
|
||||
import io.grpc.Metadata;
|
||||
|
@ -47,6 +48,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
* Utility functions for binding and receiving headers.
|
||||
*/
|
||||
public class MetadataUtils {
|
||||
// Prevent instantiation
|
||||
private MetadataUtils() {}
|
||||
|
||||
/**
|
||||
* Attaches a set of request headers to a stub.
|
||||
|
@ -55,11 +58,11 @@ public class MetadataUtils {
|
|||
* @param extraHeaders the headers to be passed by each call on the returned stub.
|
||||
* @return an implementation of the stub with {@code extraHeaders} bound to each call.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T extends AbstractStub> T attachHeaders(
|
||||
@ExperimentalApi
|
||||
public static <T extends AbstractStub<T>> T attachHeaders(
|
||||
T stub,
|
||||
final Metadata extraHeaders) {
|
||||
return (T) stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders));
|
||||
return stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,12 +97,12 @@ public class MetadataUtils {
|
|||
* @param trailersCapture to record the last received trailers
|
||||
* @return an implementation of the stub with {@code extraHeaders} bound to each call.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T extends AbstractStub> T captureMetadata(
|
||||
@ExperimentalApi
|
||||
public static <T extends AbstractStub<T>> T captureMetadata(
|
||||
T stub,
|
||||
AtomicReference<Metadata> headersCapture,
|
||||
AtomicReference<Metadata> trailersCapture) {
|
||||
return (T) stub.withInterceptors(
|
||||
return stub.withInterceptors(
|
||||
newCaptureMetadataInterceptor(headersCapture, trailersCapture));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue