public class RequestHandler extends Object implements org.apache.http.nio.protocol.HttpAsyncRequestHandler<ResponseProducer>
inspectRequest
method if it exist,
analyzes the script response (and if appropriate delegates further processing to the script),
otherwise resolves the remote Target (if any),
and finally creates either a RequestForScriptConsumer
or a RequestForTargetConsumer
to actually consume the request.
NOTE: This is a singleton (not one per transaction as is the case for the Producers and Consumers).Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
Logger |
Constructor and Description |
---|
RequestHandler(org.apache.http.nio.protocol.HttpAsyncRequester executor,
org.apache.http.impl.nio.pool.BasicNIOConnPool connPool,
org.apache.commons.pool2.ObjectPool<ByteBuffer> bufferPool,
Path staticFilesPath,
Map<String,TargetDescriptor> patternTargetMapping,
NavigableMap<String,ScriptObjectMirror> scripts,
ConcurrentMap<String,org.apache.http.HttpHost> dynamicHostMap)
Primary constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
handle(ResponseProducer producer,
org.apache.http.nio.protocol.HttpAsyncExchange responseTrigger,
org.apache.http.protocol.HttpContext context)
Our
processRequest method always returns an instance of HttpAsyncRequestConsumer<ResponseProducer> and the ResponseProducer part of that is passed as the first parameter to this method. |
org.apache.http.nio.protocol.HttpAsyncRequestConsumer<ResponseProducer> |
processRequest(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context)
Main entry point of a client request into this server.
|
public RequestHandler(org.apache.http.nio.protocol.HttpAsyncRequester executor, org.apache.http.impl.nio.pool.BasicNIOConnPool connPool, org.apache.commons.pool2.ObjectPool<ByteBuffer> bufferPool, Path staticFilesPath, Map<String,TargetDescriptor> patternTargetMapping, NavigableMap<String,ScriptObjectMirror> scripts, ConcurrentMap<String,org.apache.http.HttpHost> dynamicHostMap)
executor
- HttpAsyncRequester
which will perform the actual request to the remote Target and receive it's response.connPool
- The client connection pool that will be used by the executor
patternTargetMapping
- The mapping of relative uri paths to configured Targets.scripts
- Mapping of all JavaScript endpoints. This map *may* be dynamically updated, or it may be null to reflect that JavaScript endpoints are not configured.dynamicHostMap
- If non-null, we will allow JavaScript endpoints to proxy to remote Target's not specified in the configuration file.public org.apache.http.nio.protocol.HttpAsyncRequestConsumer<ResponseProducer> processRequest(org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)
HttpAsyncRequestConsumer<ResponseProducer>
is returned to make that happen.
Otherwise the request (which may have been modified by the endpoint) is asynchronously sent off to a matching remote Target via RequestForTargetConsumer
.processRequest
in interface org.apache.http.nio.protocol.HttpAsyncRequestHandler<ResponseProducer>
public void handle(ResponseProducer producer, org.apache.http.nio.protocol.HttpAsyncExchange responseTrigger, org.apache.http.protocol.HttpContext context) throws org.apache.http.HttpException, IOException
processRequest
method always returns an instance of HttpAsyncRequestConsumer<ResponseProducer>
and the ResponseProducer
part of that is passed as the first parameter to this method.
This method simply arms the HttpAsyncExchange
response trigger with our asynchronous Producer
.handle
in interface org.apache.http.nio.protocol.HttpAsyncRequestHandler<ResponseProducer>
org.apache.http.HttpException
IOException
Copyright © 2015–2024 Frank Stock. All rights reserved.