org.apache.calcite.avatica.remote

## Class JsonHandler

- java.lang.Object
- - org.apache.calcite.avatica.remote.AbstractHandler<String>
  - - org.apache.calcite.avatica.remote.JsonHandler

All Implemented Interfaces:
  Handler<String>

    public class JsonHandler
    extends AbstractHandler<String>

Implementation of `Handler` that decodes JSON requests, sends them to a `Service`, and encodes the responses into JSON.

See Also:
  `JsonService`

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.calcite.avatica.remote.Handler

`Handler.HandlerResponse<T>`

### Field Summary

Fields
`protected static com.fasterxml.jackson.databind.ObjectMapper` `MAPPER`
`(package private) MetricsSystem` `metrics`
`(package private) Timer` `serializationTimer`

### Fields inherited from class org.apache.calcite.avatica.remote.AbstractHandler

`service`

### Fields inherited from interface org.apache.calcite.avatica.remote.Handler

`HANDLER_SERIALIZATION_METRICS_NAME, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK`

### Constructor Summary

Constructors
Constructor and Description
`JsonHandler(Service service, MetricsSystem metrics)`

### Method Summary

Methods
`Handler.HandlerResponse<String>` `apply(String jsonRequest)` Compute a response for the given request, handling errors generated by that computation.
`(package private) Service.Request` `decode(String request)`
`(package private) String` `encode(Service.Response response)` Serializes the provided object as JSON.

### Methods inherited from class org.apache.calcite.avatica.remote.AbstractHandler

`convertToErrorResponse, setRpcMetadata, unwrapException`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MAPPER

    protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER

#### metrics

    final MetricsSystem metrics

#### serializationTimer

    final Timer serializationTimer

### Constructor Detail

#### JsonHandler

    public JsonHandler(Service service,
               MetricsSystem metrics)

### Method Detail

#### apply

    public Handler.HandlerResponse<String> apply(String jsonRequest)

Description copied from class: `AbstractHandler`
Compute a response for the given request, handling errors generated by that computation.

Specified by:
  `apply` in interface `Handler<String>`
Overrides:
  `apply` in class `AbstractHandler<String>`
Parameters:
  `jsonRequest` - The caller's request.
Returns:
  A `Service.Response` with additional context about that response.

#### decode

    Service.Request decode(String request)
                     throws IOException

Specified by:
  `decode` in class `AbstractHandler<String>`
Throws:
  `IOException`

#### encode

    String encode(Service.Response response)
            throws IOException

Serializes the provided object as JSON.

Specified by:
  `encode` in class `AbstractHandler<String>`
Parameters:
  `response` - The object to serialize.
Returns:
  A JSON string.
Throws:
  `IOException`