Class AbstractHandler<T>

java.lang.Object
org.apache.calcite.avatica.remote.AbstractHandler<T>
Type Parameters:
T - The format Requests/Responses are serialized as.
All Implemented Interfaces:
Handler<T>
Direct Known Subclasses:
JsonHandler, ProtobufHandler

public abstract class AbstractHandler<T> extends Object implements Handler<T>
Abstract base class for Handlers to extend to inherit functionality common across serialization strategies.
  • Field Details

    • service

      protected final Service service
  • Constructor Details

    • AbstractHandler

      public AbstractHandler(Service service)
  • Method Details

    • apply

      public Handler.HandlerResponse<T> apply(T serializedRequest)
      Compute a response for the given request, handling errors generated by that computation.
      Specified by:
      apply in interface Handler<T>
      Parameters:
      serializedRequest - The caller's request.
      Returns:
      A Service.Response with additional context about that response.
    • convertToErrorResponse

      public Handler.HandlerResponse<T> convertToErrorResponse(Exception e)
      Attempts to convert an Exception to an ErrorResponse. If there is an issue in serialization, a RuntimeException is thrown instead (wrapping the original exception if necessary).
      Parameters:
      e - The exception to convert.
      Returns:
      A HandlerResponse instance.
    • unauthenticatedErrorResponse

      public Handler.HandlerResponse<T> unauthenticatedErrorResponse(Exception e)
      Attempts to convert an Exception to an ErrorResponse with an HTTP status code of 401.
    • unauthorizedErrorResponse

      public Handler.HandlerResponse<T> unauthorizedErrorResponse(Exception e)
      Attempts to convert an Exception to an ErrorResponse with an HTTP stauts code of 403.
    • setRpcMetadata

      public void setRpcMetadata(Service.RpcMetadataResponse metadata)
      Description copied from interface: Handler
      Sets some general server information to return to the client in all responses.
      Specified by:
      setRpcMetadata in interface Handler<T>
      Parameters:
      metadata - Server-wide information