Top Description Methods
io.grpc

public Interface ServerInterceptor

Annotations
@ThreadSafe
Imports
javax.annotation.concurrent.ThreadSafe

Interface for intercepting incoming calls before that are dispatched by ServerCallHandler.

Implementers use this mechanism to add cross-cutting behavior to server-side calls. Common example of such behavior include:

The interceptor may be called for multiple calls by one or more threads without completing the previous ones first. Refer to the ServerCall.Listener docs for more details regarding thread safety of the returned listener.

Method Summary

Modifier and TypeMethod and Description
public <ReqT, RespT> ServerCall.Listener<ReqT>

Returns:

listener for processing incoming messages for call, never null.
interceptCall
(ServerCall<ReqT, RespT>
object to receive response messages
call
,
Metadata
which can contain extra call metadata from ClientCall#start, e.g. authentication credentials.
headers
,
ServerCallHandler<ReqT, RespT>
next processor in the interceptor chain
next
)

Intercept ServerCall dispatch by the next ServerCallHandler.

Method Detail

interceptCallback to summary
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next)

Intercept ServerCall dispatch by the next ServerCallHandler. General semantics of ServerCallHandler#startCall apply and the returned io.grpc.ServerCall.Listener must not be null.

If the implementation throws an exception, call will be closed with an error. Implementations must not throw an exception if they started processing that may use call on another thread.

Parameters
call:ServerCall<ReqT, RespT>

object to receive response messages

headers:Metadata

which can contain extra call metadata from ClientCall#start, e.g. authentication credentials.

next:ServerCallHandler<ReqT, RespT>

next processor in the interceptor chain

Returns:ServerCall.Listener<ReqT>

listener for processing incoming messages for call, never null.