Top Description Inners Fields Constructors Methods
io.grpc

public Class ClientInterceptors

extends Object
Class Inheritance
Imports
com.google.common.base.Preconditions, io.grpc.MethodDescriptor.Marshaller, java.io.InputStream, java.util.ArrayList, .Arrays, .Collections, .List

Utility methods for working with ClientInterceptors.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>

A io.grpc.ForwardingClientCall that delivers exceptions from its start logic to the call listener.

private static class

Field Summary

Modifier and TypeField and Description
private static final ClientCall<Object, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Channel

Returns:

a new channel instance with the interceptors applied.
intercept
(Channel
the underlying channel to intercept.
channel
,
ClientInterceptor...
array of interceptors to bind to channel.
interceptors
)

Create a new Channel that will call interceptors before starting a call on the given channel.

public static Channel

Returns:

a new channel instance with the interceptors applied.
intercept
(Channel
the underlying channel to intercept.
channel
,
List<? extends ClientInterceptor>
a list of interceptors to bind to channel.
interceptors
)

Create a new Channel that will call interceptors before starting a call on the given channel.

public static Channel

Returns:

a new channel instance with the interceptors applied.
interceptForward
(Channel
the underlying channel to intercept.
channel
,
ClientInterceptor...
array of interceptors to bind to channel.
interceptors
)

Create a new Channel that will call interceptors before starting a call on the given channel.

public static Channel

Returns:

a new channel instance with the interceptors applied.
interceptForward
(Channel
the underlying channel to intercept.
channel
,
List<? extends ClientInterceptor>
a list of interceptors to bind to channel.
interceptors
)

Create a new Channel that will call interceptors before starting a call on the given channel.

pack-priv static <WReqT, WRespT> ClientInterceptor
wrapClientInterceptor(final ClientInterceptor interceptor, final MethodDescriptor.Marshaller<WReqT> reqMarshaller, final MethodDescriptor.Marshaller<WRespT> respMarshaller)

Creates a new ClientInterceptor that transforms requests into WReqT and responses into WRespT before passing them into the interceptor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NOOP_CALLback to summary
private static final ClientCall<Object, Object> NOOP_CALL

Constructor Detail

ClientInterceptorsback to summary
private ClientInterceptors()

Method Detail

interceptback to summary
public static Channel intercept(Channel channel, ClientInterceptor... interceptors)

Create a new Channel that will call interceptors before starting a call on the given channel. The last interceptor will have its ClientInterceptor#interceptCall called first.

Parameters
channel:Channel

the underlying channel to intercept.

interceptors:ClientInterceptor[]

array of interceptors to bind to channel.

Returns:Channel

a new channel instance with the interceptors applied.

interceptback to summary
public static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors)

Create a new Channel that will call interceptors before starting a call on the given channel. The last interceptor will have its ClientInterceptor#interceptCall called first.

Parameters
channel:Channel

the underlying channel to intercept.

interceptors:List<? extends ClientInterceptor>

a list of interceptors to bind to channel.

Returns:Channel

a new channel instance with the interceptors applied.

interceptForwardback to summary
public static Channel interceptForward(Channel channel, ClientInterceptor... interceptors)

Create a new Channel that will call interceptors before starting a call on the given channel. The first interceptor will have its ClientInterceptor#interceptCall called first.

Parameters
channel:Channel

the underlying channel to intercept.

interceptors:ClientInterceptor[]

array of interceptors to bind to channel.

Returns:Channel

a new channel instance with the interceptors applied.

interceptForwardback to summary
public static Channel interceptForward(Channel channel, List<? extends ClientInterceptor> interceptors)

Create a new Channel that will call interceptors before starting a call on the given channel. The first interceptor will have its ClientInterceptor#interceptCall called first.

Parameters
channel:Channel

the underlying channel to intercept.

interceptors:List<? extends ClientInterceptor>

a list of interceptors to bind to channel.

Returns:Channel

a new channel instance with the interceptors applied.

wrapClientInterceptorback to summary
pack-priv static <WReqT, WRespT> ClientInterceptor wrapClientInterceptor(final ClientInterceptor interceptor, final MethodDescriptor.Marshaller<WReqT> reqMarshaller, final MethodDescriptor.Marshaller<WRespT> respMarshaller)

Creates a new ClientInterceptor that transforms requests into WReqT and responses into WRespT before passing them into the interceptor.

io.grpc back to summary

public abstract Class ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>

extends ForwardingClientCall<ReqT, RespT>
Class Inheritance

A io.grpc.ForwardingClientCall that delivers exceptions from its start logic to the call listener.

ClientCall#start(ClientCall.Listener, Metadata) should not throw any exception other than those caused by misuse, e.g., IllegalStateException. CheckedForwardingClientCall provides checkedStart() in which throwing exceptions is allowed.

Field Summary

Modifier and TypeField and Description
private ClientCall<ReqT, RespT>

Constructor Summary

AccessConstructor and Description
protected
CheckedForwardingClientCall(ClientCall<ReqT, RespT> delegate)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
checkedStart(ClientCall.Listener<RespT> responseListener, Metadata headers)

Subclasses implement the start logic here that would normally belong to start().

protected final ClientCall<ReqT, RespT>
delegate()

Implements abstract io.grpc.ForwardingClientCall.delegate.

Returns the delegated ClientCall.
public final void
start(ClientCall.Listener<RespT>
receives response messages
responseListener
,
Metadata
which can contain extra call metadata, e.g. authentication credentials.
headers
)

Overrides io.grpc.ForwardingClientCall.start.

Start a call, using responseListener for processing response messages.
Inherited from io.grpc.ForwardingClientCall:
sendMessage

Field Detail

delegateback to summary
private ClientCall<ReqT, RespT> delegate

Constructor Detail

CheckedForwardingClientCallback to summary
protected CheckedForwardingClientCall(ClientCall<ReqT, RespT> delegate)

Method Detail

checkedStartback to summary
protected abstract void checkedStart(ClientCall.Listener<RespT> responseListener, Metadata headers) throws Exception

Subclasses implement the start logic here that would normally belong to start().

Implementation should call this.delegate().start() in the normal path. Exceptions may safely be thrown prior to calling this.delegate().start(). Such exceptions will be handled by CheckedForwardingClientCall and be delivered to responseListener. Exceptions must not be thrown after calling this.delegate().start(), as this can result in ClientCall.Listener#onClose being called multiple times.

delegateback to summary
protected final ClientCall<ReqT, RespT> delegate()

Implements abstract io.grpc.ForwardingClientCall.delegate.

Doc from io.grpc.ForwardingClientCall.delegate.

Returns the delegated ClientCall.

Annotations
@Override
startback to summary
public final void start(ClientCall.Listener<RespT> responseListener, Metadata headers)

Overrides io.grpc.ForwardingClientCall.start.

Doc from io.grpc.ClientCall.start.

Start a call, using responseListener for processing response messages.

It must be called prior to any other method on this class, except for cancel which may be called at any time.

Since Metadata is not thread-safe, the caller must not access (read or write) headers after this point.

Parameters
responseListener:ClientCall.Listener<RespT>

receives response messages

headers:Metadata

which can contain extra call metadata, e.g. authentication credentials.

Annotations
@Override
@SuppressWarnings:unchecked
io.grpc back to summary

private Class ClientInterceptors.InterceptorChannel

extends Channel
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Channel
private final ClientInterceptor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
authority()

Implements abstract io.grpc.Channel.authority.

The authority of the destination this channel connects to.
public <ReqT, RespT> ClientCall<ReqT, RespT>
newCall(MethodDescriptor<ReqT, RespT>
describes the name and parameter types of the operation to call.
method
,
CallOptions
runtime options to be applied to this call.
callOptions
)

Implements abstract io.grpc.Channel.newCall.

Create a ClientCall to the remote operation specified by the given MethodDescriptor.

Field Detail

channelback to summary
private final Channel channel
interceptorback to summary
private final ClientInterceptor interceptor

Constructor Detail

InterceptorChannelback to summary
private InterceptorChannel(Channel channel, ClientInterceptor interceptor)

Method Detail

authorityback to summary
public String authority()

Implements abstract io.grpc.Channel.authority.

Doc from io.grpc.Channel.authority.

The authority of the destination this channel connects to. Typically this is in the format host:port.

Annotations
@Override
newCallback to summary
public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions)

Implements abstract io.grpc.Channel.newCall.

Doc from io.grpc.Channel.newCall.

Create a ClientCall to the remote operation specified by the given MethodDescriptor. The returned ClientCall does not trigger any remote behavior until ClientCall#start(ClientCall.Listener, Metadata) is invoked.

Parameters
method:MethodDescriptor<ReqT, RespT>

describes the name and parameter types of the operation to call.

callOptions:CallOptions

runtime options to be applied to this call.

Returns:ClientCall<ReqT, RespT>

a ClientCall bound to the specified method.

Annotations
@Override