org.apache.mina.filter.reqres

## Class RequestResponseFilter

- java.lang.Object
- - org.apache.mina.core.filterchain.IoFilterAdapter
  - - org.apache.mina.filter.util.WriteRequestFilter
    - - org.apache.mina.filter.reqres.RequestResponseFilter

- All Implemented Interfaces:
    IoFilter

      public class RequestResponseFilter
      extends WriteRequestFilter

  TODO Add documentation
  Author:
    Apache MINA Project

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter

      `IoFilter.NextFilter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestResponseFilter(ResponseInspectorFactory responseInspectorFactory, ScheduledExecutorService timeoutScheduler)`
    `RequestResponseFilter(ResponseInspector responseInspector, ScheduledExecutorService timeoutScheduler)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Map<Object,Request>` | `createRequestStore(IoSession session)` Returns a `Map` which stores `messageId`-`Request` pairs whose `Response`s are not received yet.
    `protected Set<Request>` | `createUnrespondedRequestStore(IoSession session)` Returns a `Set` which stores `Request` whose `Response`s are not received yet.
    `protected void` | `destroyRequestStore(Map<Object,Request> requestStore)` Releases any resources related with the `Map` created by `createRequestStore(IoSession)`.
    `protected void` | `destroyUnrespondedRequestStore(Set<Request> unrespondedRequestStore)` Releases any resources related with the `Set` created by `createUnrespondedRequestStore(IoSession)`.
    `protected Object` | `doFilterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)`
    `void` | `messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)` Filters `IoHandler.messageReceived(IoSession,Object)` event.
    `void` | `onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)` Invoked after this filter is removed from the specified `parent`.
    `void` | `onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)` Invoked before this filter is added to the specified `parent`.
    `void` | `sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)` Filters `IoHandler.sessionClosed(IoSession)` event.

    - ### Methods inherited from class org.apache.mina.filter.util.WriteRequestFilter

      `filterWrite, messageSent`

    - ### Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter

      `destroy, exceptionCaught, filterClose, init, onPostAdd, onPreRemove, sessionCreated, sessionIdle, sessionOpened, toString`

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

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

- - ### Constructor Detail

    - #### RequestResponseFilter

          public RequestResponseFilter(ResponseInspector responseInspector,
                               ScheduledExecutorService timeoutScheduler)

    - #### RequestResponseFilter

          public RequestResponseFilter(ResponseInspectorFactory responseInspectorFactory,
                               ScheduledExecutorService timeoutScheduler)

  - ### Method Detail

    - #### onPreAdd

          public void onPreAdd(IoFilterChain parent,
                      String name,
                      IoFilter.NextFilter nextFilter)
                        throws Exception

      Description copied from class: `IoFilterAdapter`
      Invoked before this filter is added to the specified `parent`. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked before `IoFilter.init()` is invoked.
      Specified by:
        `onPreAdd` in interface `IoFilter`
      Overrides:
        `onPreAdd` in class `IoFilterAdapter`
      Parameters:
        `parent` - the parent who called this method
        `name` - the name assigned to this filter
        `nextFilter` - the `IoFilter.NextFilter` for this filter. You can reuse this object until this filter is removed from the chain.
      Throws:
        `Exception`

    - #### onPostRemove

          public void onPostRemove(IoFilterChain parent,
                          String name,
                          IoFilter.NextFilter nextFilter)
                            throws Exception

      Description copied from class: `IoFilterAdapter`
      Invoked after this filter is removed from the specified `parent`. Please note that this method can be invoked more than once if this filter is removed from more than one parents. This method is always invoked before `IoFilter.destroy()` is invoked.
      Specified by:
        `onPostRemove` in interface `IoFilter`
      Overrides:
        `onPostRemove` in class `IoFilterAdapter`
      Parameters:
        `parent` - the parent who called this method
        `name` - the name assigned to this filter
        `nextFilter` - the `IoFilter.NextFilter` for this filter. You can reuse this object until this filter is removed from the chain.
      Throws:
        `Exception`

    - #### messageReceived

          public void messageReceived(IoFilter.NextFilter nextFilter,
                             IoSession session,
                             Object message)
                               throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoHandler.messageReceived(IoSession,Object)` event.
      Specified by:
        `messageReceived` in interface `IoFilter`
      Overrides:
        `messageReceived` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### doFilterWrite

          protected Object doFilterWrite(IoFilter.NextFilter nextFilter,
                             IoSession session,
                             WriteRequest writeRequest)
                                  throws Exception

      Specified by:
        `doFilterWrite` in class `WriteRequestFilter`
      Throws:
        `Exception`

    - #### sessionClosed

          public void sessionClosed(IoFilter.NextFilter nextFilter,
                           IoSession session)
                             throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoHandler.sessionClosed(IoSession)` event.
      Specified by:
        `sessionClosed` in interface `IoFilter`
      Overrides:
        `sessionClosed` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### createRequestStore

          protected Map<Object,Request> createRequestStore(IoSession session)

      Returns a `Map` which stores `messageId`-`Request` pairs whose `Response`s are not received yet. Please override this method if you need to use other `Map` implementation than the default one (`HashMap`).

    - #### createUnrespondedRequestStore

          protected Set<Request> createUnrespondedRequestStore(IoSession session)

      Returns a `Set` which stores `Request` whose `Response`s are not received yet. Please override this method if you need to use other `Set` implementation than the default one (`LinkedHashSet`). Please note that the `Iterator` of the returned `Set` have to iterate its elements in the insertion order to ensure that `RequestTimeoutException`s are thrown in the order which `Request`s were written. If you don't need to guarantee the order of thrown exceptions, any `Set` implementation can be used.

    - #### destroyRequestStore

          protected void destroyRequestStore(Map<Object,Request> requestStore)

      Releases any resources related with the `Map` created by `createRequestStore(IoSession)`. This method is useful if you override `createRequestStore(IoSession)`.
      Parameters:
        `requestStore` - what you returned in `createRequestStore(IoSession)`

    - #### destroyUnrespondedRequestStore

          protected void destroyUnrespondedRequestStore(Set<Request> unrespondedRequestStore)

      Releases any resources related with the `Set` created by `createUnrespondedRequestStore(IoSession)`. This method is useful if you override `createUnrespondedRequestStore(IoSession)`.
      Parameters:
        `unrespondedRequestStore` - what you returned in `createUnrespondedRequestStore(IoSession)`

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.