T - The format Requests/Responses are serialized as.public abstract class AbstractHandler<T> extends Object implements Handler<T>
Handlers to extend to inherit functionality common across
serialization strategies.Handler.HandlerResponse<T>| Modifier and Type | Field and Description |
|---|---|
protected Service |
service |
HANDLER_SERIALIZATION_METRICS_NAME, HTTP_BAD_REQUEST, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED| Constructor and Description |
|---|
AbstractHandler(Service service) |
| Modifier and Type | Method and Description |
|---|---|
Handler.HandlerResponse<T> |
apply(T serializedRequest)
Compute a response for the given request, handling errors generated by that computation.
|
Handler.HandlerResponse<T> |
badRequestErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse with an HTTP status code of
400. |
Handler.HandlerResponse<T> |
convertToErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse.
|
void |
setRpcMetadata(Service.RpcMetadataResponse metadata)
Sets some general server information to return to the client in all responses.
|
Handler.HandlerResponse<T> |
unauthenticatedErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse with an HTTP status code of
401. |
Handler.HandlerResponse<T> |
unauthorizedErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse with an HTTP stauts code of
403. |
protected final Service service
public AbstractHandler(Service service)
public Handler.HandlerResponse<T> apply(T serializedRequest)
apply in interface Handler<T>serializedRequest - The caller's request.Service.Response with additional context about that response.public Handler.HandlerResponse<T> convertToErrorResponse(Exception e)
e - The exception to convert.public Handler.HandlerResponse<T> badRequestErrorResponse(Exception e)
400.public Handler.HandlerResponse<T> unauthenticatedErrorResponse(Exception e)
401.public Handler.HandlerResponse<T> unauthorizedErrorResponse(Exception e)
403.public void setRpcMetadata(Service.RpcMetadataResponse metadata)
HandlersetRpcMetadata in interface Handler<T>metadata - Server-wide informationCopyright © 2012-2025 Apache Software Foundation. All Rights Reserved.