Package org.apache.calcite.avatica.remote

## Class JsonHandler

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

All Implemented Interfaces:
  `Handler<java.lang.String>`

    public class JsonHandler
    extends AbstractHandler<java.lang.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) org.apache.calcite.avatica.metrics.MetricsSystem` `metrics`
`(package private) org.apache.calcite.avatica.metrics.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, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED`

### Constructor Summary

Constructors
`JsonHandler​(Service service, org.apache.calcite.avatica.metrics.MetricsSystem metrics)`

### Method Summary

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

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

`convertToErrorResponse, setRpcMetadata, unauthenticatedErrorResponse, unauthorizedErrorResponse, 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 org.apache.calcite.avatica.metrics.MetricsSystem metrics

#### serializationTimer

    final org.apache.calcite.avatica.metrics.Timer serializationTimer

### Constructor Detail

#### JsonHandler

    public JsonHandler​(Service service,
                       org.apache.calcite.avatica.metrics.MetricsSystem metrics)

### Method Detail

#### apply

    public Handler.HandlerResponse<java.lang.String> apply​(java.lang.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<java.lang.String>`
Overrides:
  `apply` in class `AbstractHandler<java.lang.String>`
Parameters:
  `jsonRequest` - The caller's request.
Returns:
  A `Service.Response` with additional context about that response.

#### decode

    Service.Request decode​(java.lang.String request)
                    throws java.io.IOException

Specified by:
  `decode` in class `AbstractHandler<java.lang.String>`
Throws:
  `java.io.IOException`

#### encode

    java.lang.String encode​(Service.Response response)
                     throws java.io.IOException

Serializes the provided object as JSON.

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