Class ServerHandler
java.lang.Object
org.apache.synapse.transport.nhttp.ServerHandler
- All Implemented Interfaces:
org.apache.http.nio.NHttpServerEventHandler
The server 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
ConstructorsConstructorDescriptionServerHandler(org.apache.axis2.context.ConfigurationContext cfgCtx, Scheme scheme, ListenerContext listenerContext, NhttpMetricsCollector metrics) -
Method Summary
Modifier and TypeMethodDescriptionvoidclosed(org.apache.http.nio.NHttpServerConnection conn) voidcommitResponse(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response) Commit the response to the connection.voidcommitResponseHideExceptions(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response) Commit the response to the connection.voidconnected(org.apache.http.nio.NHttpServerConnection conn) voidendOfInput(org.apache.http.nio.NHttpServerConnection conn) voidexception(org.apache.http.nio.NHttpServerConnection conn, IOException e) Handle IO errors while reading or writing to underlying channelsvoidHandle errors while reading or writing to underlying channelsintintorg.apache.axis2.transport.base.MetricsCollectorintvoidinputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentDecoder decoder) Process ready input by writing it into the PipevoidvoidoutputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentEncoder encoder) Process ready output by writing into the channelvoidrequestReceived(org.apache.http.nio.NHttpServerConnection conn) Process a new incoming requestvoidresponseReady(org.apache.http.nio.NHttpServerConnection conn) voidstop()voidtimeout(org.apache.http.nio.NHttpServerConnection conn) Handle connection timeouts by shutting down the connections
-
Field Details
-
REQUEST_SINK_BUFFER
- See Also:
-
RESPONSE_SOURCE_BUFFER
- See Also:
-
CONNECTION_CREATION_TIME
- See Also:
-
SERVER_CONNECTION_DEBUG
- See Also:
-
HTTP_REQUEST
Used to obtain http request from context- See Also:
-
-
Constructor Details
-
ServerHandler
public ServerHandler(org.apache.axis2.context.ConfigurationContext cfgCtx, Scheme scheme, ListenerContext listenerContext, NhttpMetricsCollector metrics)
-
-
Method Details
-
requestReceived
public void requestReceived(org.apache.http.nio.NHttpServerConnection conn) Process a new incoming request- Specified by:
requestReceivedin interfaceorg.apache.http.nio.NHttpServerEventHandler- Parameters:
conn- the connection
-
inputReady
public void inputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentDecoder decoder) Process ready input by writing it into the Pipe- Specified by:
inputReadyin interfaceorg.apache.http.nio.NHttpServerEventHandler- Parameters:
conn- the connection being processeddecoder- the content decoder in use
-
outputReady
public void outputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentEncoder encoder) Process ready output by writing into the channel- Specified by:
outputReadyin interfaceorg.apache.http.nio.NHttpServerEventHandler- Parameters:
conn- the connection being processedencoder- the content encoder in use
-
commitResponseHideExceptions
public void commitResponseHideExceptions(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response) Commit the response to the connection. Processes the response through the configured HttpProcessor and submits it to be sent out. This method hides any exceptions and is targetted for non critical (i.e. browser requests etc) requests, which are not core messages- Parameters:
conn- the connection being processedresponse- the response to commit over the connection
-
commitResponse
public void commitResponse(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response) throws IOException, org.apache.http.HttpException Commit the response to the connection. Processes the response through the configured HttpProcessor and submits it to be sent out. Re-Throws exceptions, after closing connections- Parameters:
conn- the connection being processedresponse- the response to commit over the connection- Throws:
IOException- if an IO error occurs while sending the responseorg.apache.http.HttpException- if a HTTP protocol violation occurs while sending the response
-
timeout
public void timeout(org.apache.http.nio.NHttpServerConnection conn) Handle connection timeouts by shutting down the connections- Specified by:
timeoutin interfaceorg.apache.http.nio.NHttpServerEventHandler- Parameters:
conn- the connection being processed
-
endOfInput
- Specified by:
endOfInputin interfaceorg.apache.http.nio.NHttpServerEventHandler- Throws:
IOException
-
connected
public void connected(org.apache.http.nio.NHttpServerConnection conn) - Specified by:
connectedin interfaceorg.apache.http.nio.NHttpServerEventHandler
-
responseReady
public void responseReady(org.apache.http.nio.NHttpServerConnection conn) - Specified by:
responseReadyin interfaceorg.apache.http.nio.NHttpServerEventHandler
-
closed
public void closed(org.apache.http.nio.NHttpServerConnection conn) - Specified by:
closedin interfaceorg.apache.http.nio.NHttpServerEventHandler
-
markActiveConnectionsToBeClosed
public void markActiveConnectionsToBeClosed() -
exception
Handle errors while reading or writing to underlying channels- Specified by:
exceptionin interfaceorg.apache.http.nio.NHttpServerEventHandler- Parameters:
conn- the connection being processede- the exception encountered
-
exception
Handle IO errors while reading or writing to underlying channels- Parameters:
conn- the connection being processede- the exception encountered
-
getActiveConnectionsSize
public int getActiveConnectionsSize() -
getActiveCount
public int getActiveCount() -
getQueueSize
public int getQueueSize() -
getMetrics
public org.apache.axis2.transport.base.MetricsCollector getMetrics() -
stop
public void stop()
-