org.apache.http.impl.nio.reactor

## Class DefaultListeningIOReactor

- java.lang.Object
- - org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
  - - org.apache.http.impl.nio.reactor.DefaultListeningIOReactor

- All Implemented Interfaces:
    IOReactor, ListeningIOReactor

      @ThreadSafe
      public class DefaultListeningIOReactor
      extends AbstractMultiworkerIOReactor
      implements ListeningIOReactor

  Default implementation of `ListeningIOReactor`. This class extends `AbstractMultiworkerIOReactor` with capability to listen for incoming connections.
  Since:
    4.0

- - ### Field Summary

    - ### Fields inherited from class org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor

      `auditLog, config, exceptionHandler, interestOpsQueueing, params, selector, selectTimeout, status`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultListeningIOReactor()` Creates an instance of DefaultListeningIOReactor with default configuration.
    `DefaultListeningIOReactor(int workerCount, HttpParams params)` Deprecated. (4.2) use `DefaultListeningIOReactor(IOReactorConfig)`
    `DefaultListeningIOReactor(int workerCount, ThreadFactory threadFactory, HttpParams params)` Deprecated. (4.2) use `DefaultListeningIOReactor(IOReactorConfig, ThreadFactory)`
    `DefaultListeningIOReactor(IOReactorConfig config)` Creates an instance of DefaultListeningIOReactor with the given configuration.
    `DefaultListeningIOReactor(IOReactorConfig config, ThreadFactory threadFactory)` Creates an instance of DefaultListeningIOReactor with the given configuration.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `cancelRequests()` Triggered to cancel pending session requests.
    `Set<ListenerEndpoint>` | `getEndpoints()` Returns a set of endpoints for this I/O reactor.
    `ListenerEndpoint` | `listen(SocketAddress address)` Opens a new listener endpoint with the given socket address.
    `void` | `pause()` Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.
    `protected void` | `processEvents(int readyCount)` Triggered to process I/O events registered by the main `Selector`.
    `void` | `resume()` Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.

    - ### Methods inherited from class org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor

      `addChannel, addExceptionEvent, addExceptionEvent, awaitShutdown, doShutdown, execute, getAuditLog, getStatus, prepareSocket, registerChannel, setExceptionHandler, shutdown, shutdown`

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

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

    - ### Methods inherited from interface org.apache.http.nio.reactor.IOReactor

      `execute, getStatus, shutdown, shutdown`

- - ### Constructor Detail

    - #### DefaultListeningIOReactor

          public DefaultListeningIOReactor(IOReactorConfig config,
                                   ThreadFactory threadFactory)
                                    throws IOReactorException

      Creates an instance of DefaultListeningIOReactor with the given configuration.
      Parameters:
        `config` - I/O reactor configuration.
        `threadFactory` - the factory to create threads. Can be `null`.
      Throws:
        `IOReactorException` - in case if a non-recoverable I/O error.
      Since:
        4.2

    - #### DefaultListeningIOReactor

          public DefaultListeningIOReactor(IOReactorConfig config)
                                    throws IOReactorException

      Creates an instance of DefaultListeningIOReactor with the given configuration.
      Parameters:
        `config` - I/O reactor configuration. Can be `null`.
      Throws:
        `IOReactorException` - in case if a non-recoverable I/O error.
      Since:
        4.2

    - #### DefaultListeningIOReactor

          public DefaultListeningIOReactor()
                                    throws IOReactorException

      Creates an instance of DefaultListeningIOReactor with default configuration.
      Throws:
        `IOReactorException` - in case if a non-recoverable I/O error.
      Since:
        4.2

    - #### DefaultListeningIOReactor

          @Deprecated
          public DefaultListeningIOReactor(int workerCount,
                                              ThreadFactory threadFactory,
                                              HttpParams params)
                                    throws IOReactorException

      Deprecated. (4.2) use `DefaultListeningIOReactor(IOReactorConfig, ThreadFactory)`
      Throws:
        `IOReactorException`

    - #### DefaultListeningIOReactor

          @Deprecated
          public DefaultListeningIOReactor(int workerCount,
                                              HttpParams params)
                                    throws IOReactorException

      Deprecated. (4.2) use `DefaultListeningIOReactor(IOReactorConfig)`
      Throws:
        `IOReactorException`

  - ### Method Detail

    - #### cancelRequests

          protected void cancelRequests()
                                 throws IOReactorException

      Description copied from class: `AbstractMultiworkerIOReactor`
      Triggered to cancel pending session requests.

      Super-classes can implement this method to react to the event.

      Specified by:
        `cancelRequests` in class `AbstractMultiworkerIOReactor`
      Throws:
        `IOReactorException` - in case if a non-recoverable I/O error.

    - #### processEvents

          protected void processEvents(int readyCount)
                                throws IOReactorException

      Description copied from class: `AbstractMultiworkerIOReactor`
      Triggered to process I/O events registered by the main `Selector`.

      Super-classes can implement this method to react to the event.

      Specified by:
        `processEvents` in class `AbstractMultiworkerIOReactor`
      Parameters:
        `readyCount` - event count.
      Throws:
        `IOReactorException` - in case if a non-recoverable I/O error.

    - #### listen

          public ListenerEndpoint listen(SocketAddress address)

      Description copied from interface: `ListeningIOReactor`
      Opens a new listener endpoint with the given socket address. Once the endpoint is fully initialized it starts accepting incoming connections and propagates I/O activity notifications to the I/O event dispatcher.

      `ListenerEndpoint.waitFor()` can be used to wait for the listener to be come ready to accept incoming connections.

      `ListenerEndpoint.close()` can be used to shut down the listener even before it is fully initialized.

      Specified by:
        `listen` in interface `ListeningIOReactor`
      Parameters:
        `address` - the socket address to listen on.
      Returns:
        listener endpoint.

    - #### getEndpoints

          public Set<ListenerEndpoint> getEndpoints()

      Description copied from interface: `ListeningIOReactor`
      Returns a set of endpoints for this I/O reactor.
      Specified by:
        `getEndpoints` in interface `ListeningIOReactor`
      Returns:
        set of endpoints.

    - #### pause

          public void pause()
                     throws IOException

      Description copied from interface: `ListeningIOReactor`
      Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.
      Specified by:
        `pause` in interface `ListeningIOReactor`
      Throws:
        `IOException` - in case of an I/O error.

    - #### resume

          public void resume()
                      throws IOException

      Description copied from interface: `ListeningIOReactor`
      Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.
      Specified by:
        `resume` in interface `ListeningIOReactor`
      Throws:
        `IOException` - in case of an I/O error.

Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.