Class ClientHandler
java.lang.Object
org.apache.synapse.transport.nhttp.ClientHandler
- All Implemented Interfaces:
org.apache.http.nio.NHttpClientEventHandler
The client connection handler. An instance of this class is used by each IOReactor, to
process every connection. Hence this class should not store any data related to a single
connection - as this is being shared.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientHandler(ConnectionPool connpool, ClientConnFactory connFactory, ProxyConfig proxyConfig, org.apache.axis2.context.ConfigurationContext cfgCtx, org.apache.http.params.HttpParams params, NhttpMetricsCollector metrics) Create an instance of this client connection handler using the Axis2 configuration context and Http protocol parameters given -
Method Summary
Modifier and TypeMethodDescriptionvoidclosed(org.apache.http.nio.NHttpClientConnection conn) Handle connection close eventsvoidInvoked when the destination is connectedvoidendOfInput(org.apache.http.nio.NHttpClientConnection conn) voidHandle IO errors while reading or writing to underlying channelsvoidexception(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.HttpException e) Handle Http protocol violations encountered while reading from underlying channelsvoidintintvoidinputReady(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.nio.ContentDecoder decoder) Process ready input (i.e.protected voidmarkRequestCompletedWithError(Axis2HttpRequest axis2Request, int errorCode, String errorMessage, Exception exceptionToRaise) Mark request to send failed with errorvoidoutputReady(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.nio.ContentEncoder encoder) Process ready output (i.e.voidrequestReady(org.apache.http.nio.NHttpClientConnection conn) voidresetConnectionPool(Set<RequestDescriptor> hostList) Shutdown the connections of the given host:port list.voidresponseReceived(org.apache.http.nio.NHttpClientConnection conn) Process a response received for the request sent outvoidsetConnFactory(ClientConnFactory connFactory) Set the given Client Connection Factory.voidstop()voidsubmitRequest(org.apache.http.nio.NHttpClientConnection conn, Axis2HttpRequest axis2Req) Submit a new request over an already established connection, which has been 'kept alive'voidtimeout(org.apache.http.nio.NHttpClientConnection conn) Handle connection timeouts by shutting down the connections.
-
Field Details
-
ATTACHMENT_KEY
- See Also:
-
TUNNEL_HANDLER
- See Also:
-
OUTGOING_MESSAGE_CONTEXT
- See Also:
-
AXIS2_HTTP_REQUEST
- See Also:
-
CLIENT_CONNECTION_DEBUG
- See Also:
-
CONNECTION_CREATION_TIME
- See Also:
-
REQUEST_SOURCE_BUFFER
- See Also:
-
RESPONSE_SINK_BUFFER
- See Also:
-
-
Constructor Details
-
ClientHandler
public ClientHandler(ConnectionPool connpool, ClientConnFactory connFactory, ProxyConfig proxyConfig, org.apache.axis2.context.ConfigurationContext cfgCtx, org.apache.http.params.HttpParams params, NhttpMetricsCollector metrics) throws org.apache.axis2.AxisFault Create an instance of this client connection handler using the Axis2 configuration context and Http protocol parameters given- Parameters:
cfgCtx- the Axis2 configuration contextparams- the Http protocol parameters to adhere tometrics- statistics collection metrics- Throws:
org.apache.axis2.AxisFault
-
-
Method Details
-
requestReady
public void requestReady(org.apache.http.nio.NHttpClientConnection conn) throws IOException, org.apache.http.HttpException - Specified by:
requestReadyin interfaceorg.apache.http.nio.NHttpClientEventHandler- Throws:
IOExceptionorg.apache.http.HttpException
-
submitRequest
public void submitRequest(org.apache.http.nio.NHttpClientConnection conn, Axis2HttpRequest axis2Req) throws org.apache.http.ConnectionClosedException Submit a new request over an already established connection, which has been 'kept alive'- Parameters:
conn- the connection to use to send the request, which has been kept openaxis2Req- the new request- Throws:
org.apache.http.ConnectionClosedException- if the connection is closed by the other party
-
connected
Invoked when the destination is connected- Specified by:
connectedin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- the connection being processedattachment- the attachment set previously
-
closed
public void closed(org.apache.http.nio.NHttpClientConnection conn) Handle connection close events- Specified by:
closedin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- HTTP connection to be closed
-
timeout
public void timeout(org.apache.http.nio.NHttpClientConnection conn) Handle connection timeouts by shutting down the connections. These are established that have reached the SO_TIMEOUT of the socket- Specified by:
timeoutin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- the connection being processed
-
exception
public void exception(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.HttpException e) Handle Http protocol violations encountered while reading from underlying channels- Parameters:
conn- the connection being processede- the exception encountered
-
exception
Handle IO errors while reading or writing to underlying channels- Specified by:
exceptionin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- the connection being processedex- the exception encountered
-
endOfInput
- Specified by:
endOfInputin interfaceorg.apache.http.nio.NHttpClientEventHandler- Throws:
IOException
-
markRequestCompletedWithError
protected void markRequestCompletedWithError(Axis2HttpRequest axis2Request, int errorCode, String errorMessage, Exception exceptionToRaise) Mark request to send failed with error- Parameters:
axis2Request- the Axis2HttpRequest to be marked as completed with an errorerrorCode- the error code to raiseerrorMessage- the text for an error message to be returned to the MR on failureexceptionToRaise- an Exception to be returned to the MR on failure
-
inputReady
public void inputReady(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.nio.ContentDecoder decoder) Process ready input (i.e. response from remote server)- Specified by:
inputReadyin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- connection being processeddecoder- the content decoder in use
-
outputReady
public void outputReady(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.nio.ContentEncoder encoder) Process ready output (i.e. write request to remote server)- Specified by:
outputReadyin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- the connection being processedencoder- the encoder in use
-
responseReceived
public void responseReceived(org.apache.http.nio.NHttpClientConnection conn) Process a response received for the request sent out- Specified by:
responseReceivedin interfaceorg.apache.http.nio.NHttpClientEventHandler- Parameters:
conn- the connection being processed
-
execute
-
getActiveCount
public int getActiveCount() -
getQueueSize
public int getQueueSize() -
stop
public void stop() -
setConnFactory
Set the given Client Connection Factory.- Parameters:
connFactory- ClientConnectionFactory instance
-
resetConnectionPool
Shutdown the connections of the given host:port list. This will allow to create new connection at the next request happens.- Parameters:
hostList- Set of String which contains entries in hots:port format
-