Interface ServerCallHandler<RequestT, ResponseT>

All Known Implementing Classes:
ServerCalls.StreamingServerCallHandler, ServerCalls.UnaryServerCallHandler, ServerInterceptors.InterceptCallHandler

@ThreadSafe public interface ServerCallHandler<RequestT, ResponseT>
Interface to initiate processing of incoming remote calls. Advanced applications and generated code will implement this interface to allows Servers to invoke service methods.
  • Method Details

    • startCall

      Starts asynchronous processing of an incoming call.

      Callers of this method transfer their ownership of the non-thread-safe ServerCall and Metadata arguments to the ServerCallHandler implementation for processing. Ownership means that the implementation may invoke methods on call and headers while startCall(ServerCall, Metadata) runs and at any time after it returns normally. On the other hand, if startCall(ServerCall, Metadata) throws, ownership of call and headers reverts to the caller and the implementation loses the right to call methods on these objects (from some other thread, say).

      Ownership also includes the responsibility to eventually close call. In particular, if startCall(ServerCall, Metadata) throws an exception, the caller must handle it by closing call with an error. Since call can only be closed once, an implementation can report errors either to ServerCall.close(Status, Metadata) for itself or by throwing an exception, but not both.

      Returns a non-null listener for the incoming call. Callers of this method must arrange for events associated with call to be delivered there.

      Parameters:
      call - object for responding to the remote client.
      headers - request headers received from the client but open to modification by an owner
      Returns:
      listener for processing incoming request messages for call