org.apache.synapse.transport.nhttp

## Class ServerHandler

- java.lang.Object
- - org.apache.synapse.transport.nhttp.ServerHandler

- All Implemented Interfaces:
    org.apache.http.nio.NHttpServerEventHandler

      public class ServerHandler
      extends Object
      implements 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
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONNECTION_CREATION_TIME`
    `static String` | `HTTP_REQUEST` Used to obtain http request from context
    `static String` | `REQUEST_SINK_BUFFER`
    `static String` | `RESPONSE_SOURCE_BUFFER`
    `static String` | `SERVER_CONNECTION_DEBUG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServerHandler(org.apache.axis2.context.ConfigurationContext cfgCtx, Scheme scheme, ListenerContext listenerContext, NhttpMetricsCollector metrics)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closed(org.apache.http.nio.NHttpServerConnection conn)`
    `void` | `commitResponse(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response)` Commit the response to the connection.
    `void` | `commitResponseHideExceptions(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.HttpResponse response)` Commit the response to the connection.
    `void` | `connected(org.apache.http.nio.NHttpServerConnection conn)`
    `void` | `endOfInput(org.apache.http.nio.NHttpServerConnection conn)`
    `void` | `exception(org.apache.http.nio.NHttpServerConnection conn, Exception e)` Handle errors while reading or writing to underlying channels
    `void` | `exception(org.apache.http.nio.NHttpServerConnection conn, IOException e)` Handle IO errors while reading or writing to underlying channels
    `int` | `getActiveConnectionsSize()`
    `int` | `getActiveCount()`
    `org.apache.axis2.transport.base.MetricsCollector` | `getMetrics()`
    `int` | `getQueueSize()`
    `void` | `inputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentDecoder decoder)` Process ready input by writing it into the Pipe
    `void` | `markActiveConnectionsToBeClosed()`
    `void` | `outputReady(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentEncoder encoder)` Process ready output by writing into the channel
    `void` | `requestReceived(org.apache.http.nio.NHttpServerConnection conn)` Process a new incoming request
    `void` | `responseReady(org.apache.http.nio.NHttpServerConnection conn)`
    `void` | `stop()`
    `void` | `timeout(org.apache.http.nio.NHttpServerConnection conn)` Handle connection timeouts by shutting down the connections

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REQUEST_SINK_BUFFER

          public static final String REQUEST_SINK_BUFFER

      See Also:
        Constant Field Values

    - #### RESPONSE_SOURCE_BUFFER

          public static final String RESPONSE_SOURCE_BUFFER

      See Also:
        Constant Field Values

    - #### CONNECTION_CREATION_TIME

          public static final String CONNECTION_CREATION_TIME

      See Also:
        Constant Field Values

    - #### SERVER_CONNECTION_DEBUG

          public static final String SERVER_CONNECTION_DEBUG

      See Also:
        Constant Field Values

    - #### HTTP_REQUEST

          public static final String HTTP_REQUEST

      Used to obtain http request from context
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ServerHandler

          public ServerHandler(org.apache.axis2.context.ConfigurationContext cfgCtx,
                               Scheme scheme,
                               ListenerContext listenerContext,
                               NhttpMetricsCollector metrics)

  - ### Method Detail

    - #### requestReceived

          public void requestReceived(org.apache.http.nio.NHttpServerConnection conn)

      Process a new incoming request
      Specified by:
        `requestReceived` in interface `org.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:
        `inputReady` in interface `org.apache.http.nio.NHttpServerEventHandler`
      Parameters:
        `conn` - the connection being processed
        `decoder` - 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:
        `outputReady` in interface `org.apache.http.nio.NHttpServerEventHandler`
      Parameters:
        `conn` - the connection being processed
        `encoder` - 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 processed
        `response` - 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 processed
        `response` - the response to commit over the connection
      Throws:
        `IOException` - if an IO error occurs while sending the response
        `org.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:
        `timeout` in interface `org.apache.http.nio.NHttpServerEventHandler`
      Parameters:
        `conn` - the connection being processed

    - #### endOfInput

          public void endOfInput(org.apache.http.nio.NHttpServerConnection conn)
                          throws IOException

      Specified by:
        `endOfInput` in interface `org.apache.http.nio.NHttpServerEventHandler`
      Throws:
        `IOException`

    - #### connected

          public void connected(org.apache.http.nio.NHttpServerConnection conn)

      Specified by:
        `connected` in interface `org.apache.http.nio.NHttpServerEventHandler`

    - #### responseReady

          public void responseReady(org.apache.http.nio.NHttpServerConnection conn)

      Specified by:
        `responseReady` in interface `org.apache.http.nio.NHttpServerEventHandler`

    - #### closed

          public void closed(org.apache.http.nio.NHttpServerConnection conn)

      Specified by:
        `closed` in interface `org.apache.http.nio.NHttpServerEventHandler`

    - #### markActiveConnectionsToBeClosed

          public void markActiveConnectionsToBeClosed()

    - #### exception

          public void exception(org.apache.http.nio.NHttpServerConnection conn,
                                Exception e)

      Handle errors while reading or writing to underlying channels
      Specified by:
        `exception` in interface `org.apache.http.nio.NHttpServerEventHandler`
      Parameters:
        `conn` - the connection being processed
        `e` - the exception encountered

    - #### exception

          public void exception(org.apache.http.nio.NHttpServerConnection conn,
                                IOException e)

      Handle IO errors while reading or writing to underlying channels
      Parameters:
        `conn` - the connection being processed
        `e` - 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()

Copyright © 2005–2023 Apache Software Foundation. All rights reserved.