Package org.apache.synapse.transport.passthru

## Class SourceHandler

- java.lang.Object
- - org.apache.synapse.transport.passthru.SourceHandler

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

      public class SourceHandler
      extends Object
      implements org.apache.http.nio.NHttpServerEventHandler

  This is the class where transport interacts with the client. This class receives events for a particular connection. These events give information about the message and its various states.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `MESSAGE_SIZE_VALIDATION` |
    `static String` | `PROPERTY_FILE` |
    `static String` | `VALID_MAX_MESSAGE_SIZE` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SourceHandler​(SourceConfiguration sourceConfiguration)` |
    `SourceHandler​(SourceConfiguration sourceConfiguration, List<StreamInterceptor> streamInterceptors)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `closed​(org.apache.http.nio.NHttpServerConnection conn)` |
    `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 ex)` |
    `OutputStream` | `getOutputStream​(String method, SourceRequest request)` | Create synapse.response-source-buffer for GET and HEAD Http methods
    `SourceRequest` | `getSourceRequest​(org.apache.http.nio.NHttpServerConnection conn)` | Create SourceRequest from NHttpServerConnection conn
    `void` | `informReaderError​(org.apache.http.nio.NHttpServerConnection conn)` |
    `void` | `informWriterError​(org.apache.http.nio.NHttpServerConnection conn)` |
    `void` | `inputReady​(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentDecoder decoder)` |
    `void` | `logIOException​(org.apache.http.nio.NHttpServerConnection conn, IOException e)` |
    `void` | `outputReady​(org.apache.http.nio.NHttpServerConnection conn, org.apache.http.nio.ContentEncoder encoder)` |
    `void` | `requestReceived​(org.apache.http.nio.NHttpServerConnection conn)` |
    `void` | `responseReady​(org.apache.http.nio.NHttpServerConnection conn)` |
    `void` | `setCorrelationId​(org.apache.http.nio.NHttpServerConnection conn)` |
    `void` | `stop()` | Shutting down the thread pools.
    `void` | `timeout​(org.apache.http.nio.NHttpServerConnection conn)` |

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

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

- - ### Field Detail

    - #### PROPERTY_FILE

          public static final String PROPERTY_FILE

      See Also:
        Constant Field Values

    - #### MESSAGE_SIZE_VALIDATION

          public static final String MESSAGE_SIZE_VALIDATION

      See Also:
        Constant Field Values

    - #### VALID_MAX_MESSAGE_SIZE

          public static final String VALID_MAX_MESSAGE_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SourceHandler

          public SourceHandler​(SourceConfiguration sourceConfiguration)

    - #### SourceHandler

          public SourceHandler​(SourceConfiguration sourceConfiguration,
                               List<StreamInterceptor> streamInterceptors)

  - ### Method Detail

    - #### connected

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

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

    - #### requestReceived

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

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

    - #### setCorrelationId

          public void setCorrelationId​(org.apache.http.nio.NHttpServerConnection conn)

    - #### inputReady

          public void inputReady​(org.apache.http.nio.NHttpServerConnection conn,
                                 org.apache.http.nio.ContentDecoder decoder)

      Specified by:
        `inputReady` 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`

    - #### outputReady

          public void outputReady​(org.apache.http.nio.NHttpServerConnection conn,
                                  org.apache.http.nio.ContentEncoder encoder)

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

    - #### logIOException

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

    - #### timeout

          public void timeout​(org.apache.http.nio.NHttpServerConnection conn)

      Specified by:
        `timeout` 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`

    - #### endOfInput

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

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

    - #### exception

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

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

    - #### informReaderError

          public void informReaderError​(org.apache.http.nio.NHttpServerConnection conn)

    - #### informWriterError

          public void informWriterError​(org.apache.http.nio.NHttpServerConnection conn)

    - #### 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

    - #### stop

          public void stop()

      Shutting down the thread pools.

    - #### getOutputStream

          public OutputStream getOutputStream​(String method,
                                              SourceRequest request)

      Create synapse.response-source-buffer for GET and HEAD Http methods
      Parameters:
        `method` - Http Method
        `request` - Source Request
      Returns:
        OutputStream

    - #### getSourceRequest

          public SourceRequest getSourceRequest​(org.apache.http.nio.NHttpServerConnection conn)
                                         throws IOException,
                                                org.apache.http.HttpException

      Create SourceRequest from NHttpServerConnection conn
      Parameters:
        `conn` - the connection being processed
      Returns:
        SourceRequest
      Throws:
        `IOException`
        `org.apache.http.HttpException`