Interface ClientInterceptor
-
- All Known Implementing Classes:
ClientAuthInterceptor
@ThreadSafe public interface ClientInterceptorInterface for intercepting outgoing calls before they are dispatched by aChannel.Implementers use this mechanism to add cross-cutting behavior to
Channeland stub implementations. Common examples of such behavior include:- Logging and monitoring call behavior
- Adding metadata for proxies to observe
- Request and response rewriting
Providing authentication credentials is better served by
CallCredentials. But aClientInterceptorcould set theCallCredentialswithin theCallOptions.The interceptor may be called for multiple
callsby one or more threads without completing the previous ones first. Refer to theClientCall.Listenerdocs for more details regarding thread safety of the returned listener.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <ReqT,RespT>
ClientCall<ReqT,RespT>interceptCall(MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, Channel next)
-
-
-
Method Detail
-
interceptCall
<ReqT,RespT> ClientCall<ReqT,RespT> interceptCall(MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, Channel next)
InterceptClientCallcreation by thenextChannel.Many variations of interception are possible. Complex implementations may return a wrapper around the result of
next.newCall(), whereas a simpler implementation may just modify the header metadata prior to returning the result ofnext.newCall().next.newCall()must not be called under a differentContextother than the currentContext. The outcome of such usage is undefined and may cause memory leak due to unbounded chain ofContexts.- Parameters:
method- the remote method to be called.callOptions- the runtime options to be applied to this call.next- the channel which is being intercepted.- Returns:
- the call object for the remote operation, never
null.
-
-