public final class ServerInterceptors extends Object
ServerInterceptor
s.Modifier and Type | Method and Description |
---|---|
static ServerServiceDefinition |
intercept(BindableService bindableService,
List<? extends ServerInterceptor> interceptors) |
static ServerServiceDefinition |
intercept(BindableService bindableService,
ServerInterceptor... interceptors) |
static ServerServiceDefinition |
intercept(ServerServiceDefinition serviceDef,
List<? extends ServerInterceptor> interceptors)
Create a new
ServerServiceDefinition whose ServerCallHandler s will call
interceptors before calling the pre-existing ServerCallHandler . |
static ServerServiceDefinition |
intercept(ServerServiceDefinition serviceDef,
ServerInterceptor... interceptors)
Create a new
ServerServiceDefinition whose ServerCallHandler s will call
interceptors before calling the pre-existing ServerCallHandler . |
static ServerServiceDefinition |
interceptForward(BindableService bindableService,
List<? extends ServerInterceptor> interceptors) |
static ServerServiceDefinition |
interceptForward(BindableService bindableService,
ServerInterceptor... interceptors) |
static ServerServiceDefinition |
interceptForward(ServerServiceDefinition serviceDef,
List<? extends ServerInterceptor> interceptors)
Create a new
ServerServiceDefinition whose ServerCallHandler s will call
interceptors before calling the pre-existing ServerCallHandler . |
static ServerServiceDefinition |
interceptForward(ServerServiceDefinition serviceDef,
ServerInterceptor... interceptors)
Create a new
ServerServiceDefinition whose ServerCallHandler s will call
interceptors before calling the pre-existing ServerCallHandler . |
static ServerServiceDefinition |
useInputStreamMessages(ServerServiceDefinition serviceDef)
Create a new
ServerServiceDefinition whose MethodDescriptor serializes to
and from InputStream for all methods. |
static <T> ServerServiceDefinition |
useMarshalledMessages(ServerServiceDefinition serviceDef,
MethodDescriptor.Marshaller<T> marshaller)
Create a new
ServerServiceDefinition whose MethodDescriptor serializes to
and from T for all methods. |
public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors)
ServerServiceDefinition
whose ServerCallHandler
s will call
interceptors
before calling the pre-existing ServerCallHandler
. The first
interceptor will have its ServerInterceptor.interceptCall(io.grpc.ServerCall<ReqT, RespT>, io.grpc.Metadata, io.grpc.ServerCallHandler<ReqT, RespT>)
called first.serviceDef
- the service definition for which to intercept all its methods.interceptors
- array of interceptors to apply to the service.serviceDef
with the interceptors applied.public static ServerServiceDefinition interceptForward(BindableService bindableService, ServerInterceptor... interceptors)
public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, List<? extends ServerInterceptor> interceptors)
ServerServiceDefinition
whose ServerCallHandler
s will call
interceptors
before calling the pre-existing ServerCallHandler
. The first
interceptor will have its ServerInterceptor.interceptCall(io.grpc.ServerCall<ReqT, RespT>, io.grpc.Metadata, io.grpc.ServerCallHandler<ReqT, RespT>)
called first.serviceDef
- the service definition for which to intercept all its methods.interceptors
- list of interceptors to apply to the service.serviceDef
with the interceptors applied.public static ServerServiceDefinition interceptForward(BindableService bindableService, List<? extends ServerInterceptor> interceptors)
public static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors)
ServerServiceDefinition
whose ServerCallHandler
s will call
interceptors
before calling the pre-existing ServerCallHandler
. The last
interceptor will have its ServerInterceptor.interceptCall(io.grpc.ServerCall<ReqT, RespT>, io.grpc.Metadata, io.grpc.ServerCallHandler<ReqT, RespT>)
called first.serviceDef
- the service definition for which to intercept all its methods.interceptors
- array of interceptors to apply to the service.serviceDef
with the interceptors applied.public static ServerServiceDefinition intercept(BindableService bindableService, ServerInterceptor... interceptors)
public static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef, List<? extends ServerInterceptor> interceptors)
ServerServiceDefinition
whose ServerCallHandler
s will call
interceptors
before calling the pre-existing ServerCallHandler
. The last
interceptor will have its ServerInterceptor.interceptCall(io.grpc.ServerCall<ReqT, RespT>, io.grpc.Metadata, io.grpc.ServerCallHandler<ReqT, RespT>)
called first.serviceDef
- the service definition for which to intercept all its methods.interceptors
- list of interceptors to apply to the service.serviceDef
with the interceptors applied.public static ServerServiceDefinition intercept(BindableService bindableService, List<? extends ServerInterceptor> interceptors)
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1712") public static ServerServiceDefinition useInputStreamMessages(ServerServiceDefinition serviceDef)
ServerServiceDefinition
whose MethodDescriptor
serializes to
and from InputStream for all methods. The InputStream is guaranteed return true for
markSupported(). The ServerCallHandler
created will automatically
convert back to the original types for request and response before calling the existing
ServerCallHandler
. Calling this method combined with the intercept methods will
allow the developer to choose whether to intercept messages of InputStream, or the modeled
types of their application.serviceDef
- the service definition to convert messages to InputStreamserviceDef
with the InputStream conversion applied.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1712") public static <T> ServerServiceDefinition useMarshalledMessages(ServerServiceDefinition serviceDef, MethodDescriptor.Marshaller<T> marshaller)
ServerServiceDefinition
whose MethodDescriptor
serializes to
and from T for all methods. The ServerCallHandler
created will automatically
convert back to the original types for request and response before calling the existing
ServerCallHandler
. Calling this method combined with the intercept methods will
allow the developer to choose whether to intercept messages of T, or the modeled types
of their application. This can also be chained to allow for interceptors to handle messages
as multiple different T types within the chain if the added cost of serialization is not
a concern.serviceDef
- the service definition to convert messages to TserviceDef
with the T conversion applied.