Package io.grpc
Class ClientInterceptors
- java.lang.Object
-
- io.grpc.ClientInterceptors
-
public class ClientInterceptors extends java.lang.Object
Utility methods for working withClientInterceptor
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClientInterceptors.CheckedForwardingClientCall<ReqT,RespT>
AForwardingClientCall
that delivers exceptions from its start logic to the call listener.private static class
ClientInterceptors.InterceptorChannel
-
Field Summary
Fields Modifier and Type Field Description private static ClientCall<java.lang.Object,java.lang.Object>
NOOP_CALL
-
Constructor Summary
Constructors Modifier Constructor Description private
ClientInterceptors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Channel
intercept(Channel channel, ClientInterceptor... interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel.static Channel
intercept(Channel channel, java.util.List<? extends ClientInterceptor> interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel.static Channel
interceptForward(Channel channel, ClientInterceptor... interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel.static Channel
interceptForward(Channel channel, java.util.List<? extends ClientInterceptor> interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel.(package private) static <WReqT,WRespT>
ClientInterceptorwrapClientInterceptor(ClientInterceptor interceptor, MethodDescriptor.Marshaller<WReqT> reqMarshaller, MethodDescriptor.Marshaller<WRespT> respMarshaller)
Creates a new ClientInterceptor that transforms requests intoWReqT
and responses intoWRespT
before passing them into theinterceptor
.
-
-
-
Field Detail
-
NOOP_CALL
private static final ClientCall<java.lang.Object,java.lang.Object> NOOP_CALL
-
-
Method Detail
-
interceptForward
public static Channel interceptForward(Channel channel, ClientInterceptor... interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel. The first interceptor will have itsClientInterceptor.interceptCall(io.grpc.MethodDescriptor<ReqT, RespT>, io.grpc.CallOptions, io.grpc.Channel)
called first.- Parameters:
channel
- the underlying channel to intercept.interceptors
- array of interceptors to bind tochannel
.- Returns:
- a new channel instance with the interceptors applied.
-
interceptForward
public static Channel interceptForward(Channel channel, java.util.List<? extends ClientInterceptor> interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel. The first interceptor will have itsClientInterceptor.interceptCall(io.grpc.MethodDescriptor<ReqT, RespT>, io.grpc.CallOptions, io.grpc.Channel)
called first.- Parameters:
channel
- the underlying channel to intercept.interceptors
- a list of interceptors to bind tochannel
.- Returns:
- a new channel instance with the interceptors applied.
-
intercept
public static Channel intercept(Channel channel, ClientInterceptor... interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel. The last interceptor will have itsClientInterceptor.interceptCall(io.grpc.MethodDescriptor<ReqT, RespT>, io.grpc.CallOptions, io.grpc.Channel)
called first.- Parameters:
channel
- the underlying channel to intercept.interceptors
- array of interceptors to bind tochannel
.- Returns:
- a new channel instance with the interceptors applied.
-
intercept
public static Channel intercept(Channel channel, java.util.List<? extends ClientInterceptor> interceptors)
Create a newChannel
that will callinterceptors
before starting a call on the given channel. The last interceptor will have itsClientInterceptor.interceptCall(io.grpc.MethodDescriptor<ReqT, RespT>, io.grpc.CallOptions, io.grpc.Channel)
called first.- Parameters:
channel
- the underlying channel to intercept.interceptors
- a list of interceptors to bind tochannel
.- Returns:
- a new channel instance with the interceptors applied.
-
wrapClientInterceptor
static <WReqT,WRespT> ClientInterceptor wrapClientInterceptor(ClientInterceptor interceptor, MethodDescriptor.Marshaller<WReqT> reqMarshaller, MethodDescriptor.Marshaller<WRespT> respMarshaller)
Creates a new ClientInterceptor that transforms requests intoWReqT
and responses intoWRespT
before passing them into theinterceptor
.
-
-