public abstract class JsonBulkRequestHandler extends ARequestHandler
| Modifier and Type | Field and Description |
|---|---|
protected static DataFactory |
FACTORY
Record/Any factory.
|
protected static JsonHttpUtils |
HTTP_UTILS
Utilities for JSON-Request/Response handling.
|
| Constructor and Description |
|---|
JsonBulkRequestHandler() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
end(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
Called after processing and finishing is done.
|
abstract java.lang.Object |
finish(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
Called after the complete input bulk has been processed successfully.
|
protected int |
getErrorStatus(java.lang.String method,
java.lang.String requestUri,
java.lang.Throwable ex)
Gets the HTTP error status code depending on the method, request URI and throwable.
|
protected java.lang.String |
getRequestHost() |
protected int |
getSuccessStatus(java.lang.String method,
java.lang.String requestUri,
java.lang.Object resultObject)
Gets the ACCEPTED (202) HTTP status code.
|
void |
handle(HttpExchange exchange)
Handles a HttpExchange containing a HttpRequest.
|
protected boolean |
isValidMethod(java.lang.String method,
java.lang.String requestUri)
Checks if the given HTTP method is allowed for the request URI.
|
abstract void |
process(java.lang.String method,
java.lang.String requestUri,
Record inputRecord,
HttpExchange exchange)
process input record and return result record.
|
abstract void |
start(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
Called before processing.
|
protected boolean |
writeErrorResult(HttpExchange exchange,
java.lang.Throwable error)
Writes the error result.
|
protected void |
writeResultObject(java.io.OutputStream responseStream,
java.lang.Object resultObject)
write result object.
|
protected boolean |
writeSuccessResult(HttpExchange exchange,
java.lang.Object resultObject)
Writes a success status code.
|
activate, getDynamicUriParts, getRootContextPath, getStaticUriParts, getUriPattern, matches, urlDecodeprotected static final DataFactory FACTORY
protected static final JsonHttpUtils HTTP_UTILS
public abstract void process(java.lang.String method,
java.lang.String requestUri,
Record inputRecord,
HttpExchange exchange)
throws java.lang.Exception
method - the HTTP method of this request.requestUri - the request URIinputRecord - input Record, may be nullexchange - http exchange object, contains e.g. the http header fieldsjava.lang.Exception - any failure during processing.public abstract java.lang.Object finish(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
throws java.lang.Exception
method - the request method.requestUri - the request URI.exchange - http exchange object, contains e.g. the http header fieldsjava.lang.Exception - any failure during finishing.public abstract void start(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
throws java.lang.Exception
method - the request method.requestUri - the request URI.exchange - http exchange object, contains e.g. the http header fieldsjava.lang.Exception - any failure during processing.public abstract void end(java.lang.String method,
java.lang.String requestUri,
HttpExchange exchange)
throws java.lang.Exception
method - the request method.requestUri - the request URI.exchange - http exchange object, contains e.g. the http header fieldsjava.lang.Exceptionpublic void handle(HttpExchange exchange)
exchange - the HttpExchange objectprotected boolean isValidMethod(java.lang.String method,
java.lang.String requestUri)
method - the HTTP method.requestUri - the Request URI.protected boolean writeSuccessResult(HttpExchange exchange, java.lang.Object resultObject) throws java.io.IOException
exchange - the HttpExchangeresultObject - result object, may be null.java.io.IOExceptionprotected int getSuccessStatus(java.lang.String method,
java.lang.String requestUri,
java.lang.Object resultObject)
method - ignoredrequestUri - ignoredresultObject - result object, may be null.protected void writeResultObject(java.io.OutputStream responseStream,
java.lang.Object resultObject)
throws java.io.IOException
Record results. Subclasses that produce
different result types must override this method.responseStream - response streamresultObject - result object.java.io.IOException - error writing resultprotected boolean writeErrorResult(HttpExchange exchange, java.lang.Throwable error) throws java.io.IOException
exchange - the HttpExchange object.error - the error to be writtenjava.io.IOException - could not write the error to the response stream.protected int getErrorStatus(java.lang.String method,
java.lang.String requestUri,
java.lang.Throwable ex)
HTTP_UTILS#getErrorStatus(Throwable)protected java.lang.String getRequestHost()