Package io.grpc

Interface ServerInterceptor


  • public interface ServerInterceptor
    Interface for intercepting incoming calls before they are dispatched by ServerCallHandler.

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

    • Enforcing valid authentication credentials
    • Logging and monitoring call behavior
    • Delegating calls to other servers

    From gRPC's perspective, interceptors don't generally exist and are more of a convenience. Convenience APIs will use ServerInterceptors to convert the interceptor into a ServerCallHandler. Thus interceptors are an extension of the application and run on the same threads and receive callbacks using the same executor.

    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.

    This interface is thread-safe.