public final class JsonServerConnection extends Object implements RequestReceiver
RequestReceiver.RequestContext, RequestReceiver.TransportContext| Constructor and Description |
|---|
JsonServerConnection(ApiProvider provider,
List<RequestProcessor> processorChain)
Creates a handler which translates JSON-RPC 2.0 requests to
ApiProvider method calls. |
| Modifier and Type | Method and Description |
|---|---|
void |
requestReceived(InputStream request,
RequestReceiver.TransportContext transport)
Notifies the request receiver that a new request is received.
|
public JsonServerConnection(ApiProvider provider, List<RequestProcessor> processorChain)
ApiProvider method calls.provider - all ApiProvider method calls will be delegated
to this provider; must not be nullprocessorChain - chain of processors which will be invoked on each
JSON request; the input of each processor is the
output of the previous processor in the chain; the
input to the first processor is the original JSON
request; processors are executed before the
request gets translated into an ApiProvider
call; must not be nullpublic void requestReceived(InputStream request, RequestReceiver.TransportContext transport) throws IOException
RequestReceiverNotifies the request receiver that a new request is received.
There is no guarantee that the request is completely handled when this
method exits. The implementation is free to handle the request
asynchronously. Only after the RequestReceiver.TransportContext.send(java.io.InputStream, int, boolean) with
true value for the isFinal parameter is invoked, it is
certain that the request is completely processed and all responses have
been sent.
requestReceived in interface RequestReceiverrequest - request frame; must not be nulltransport - transport handle which can be used to send responses;
this handle is strongly correlated with the request;
use it to send responses only for this particular
request; must not be nullIOException - propagate an error coming from the transport module
(e.g. thrown by the request stream or by the
transport handle)Copyright © 2022. All rights reserved.