public class

BaseIOReactor

extends AbstractIOReactor
java.lang.Object
   ↳ org.apache.http.impl.nio.reactor.AbstractIOReactor
     ↳ org.apache.http.impl.nio.reactor.BaseIOReactor

Class Overview

Default implementation of AbstractIOReactor that serves as a base for more advanced IOReactor implementations. This class adds support for the I/O event dispatching using IOEventDispatch, management of buffering sessions, and session timeout handling.

Summary

Public Constructors
BaseIOReactor(long selectTimeout)
Creates new BaseIOReactor instance.
BaseIOReactor(long selectTimeout, boolean interestOpsQueueing)
Creates new BaseIOReactor instance.
Public Methods
void execute(IOEventDispatch eventDispatch)
Activates the I/O reactor.
void setExceptionHandler(IOReactorExceptionHandler exceptionHandler)
Sets exception handler for this I/O reactor.
Protected Methods
void acceptable(SelectionKey key)
This I/O reactor implementation does not react to the OP_ACCEPT event.
void connectable(SelectionKey key)
This I/O reactor implementation does not react to the OP_CONNECT event.
IOSession getSession(SelectionKey key)
Obtains IOSession instance associated with the given selection key.
void handleRuntimeException(RuntimeException ex)
Handles the given RuntimeException.
void readable(SelectionKey key)
Processes OP_READ event on the given selection key.
void sessionClosed(IOSession session)
Processes closed I/O session.
void sessionCreated(SelectionKey key, IOSession session)
Processes newly created I/O session.
void timeoutCheck(SelectionKey key, long now)
Performs timeout check for the I/O session associated with the given selection key.
void validate(Set<SelectionKey> keys)
Verifies whether any of the sessions associated with the given selection keys timed out by invoking the timeoutCheck(SelectionKey, long) method.
void writable(SelectionKey key)
Processes OP_WRITE event on the given selection key.
[Expand]
Inherited Methods
From class org.apache.http.impl.nio.reactor.AbstractIOReactor
From class java.lang.Object
From interface org.apache.http.nio.reactor.IOReactor

Public Constructors

public BaseIOReactor (long selectTimeout)

Creates new BaseIOReactor instance.

Parameters
selectTimeout the select timeout.
Throws
IOReactorException in case if a non-recoverable I/O error.

public BaseIOReactor (long selectTimeout, boolean interestOpsQueueing)

Creates new BaseIOReactor instance.

Parameters
selectTimeout the select timeout.
interestOpsQueueing Ops queueing flag.
Throws
IOReactorException in case if a non-recoverable I/O error.

Public Methods

public void execute (IOEventDispatch eventDispatch)

Activates the I/O reactor. The I/O reactor will start reacting to I/O events and dispatch I/O event notifications to the given IOEventDispatch.

Throws
InterruptedIOException if the dispatch thread is interrupted.
IOReactorException in case if a non-recoverable I/O error.

public void setExceptionHandler (IOReactorExceptionHandler exceptionHandler)

Sets exception handler for this I/O reactor.

Parameters
exceptionHandler the exception handler.

Protected Methods

protected void acceptable (SelectionKey key)

This I/O reactor implementation does not react to the OP_ACCEPT event.

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

Parameters
key the selection key.

protected void connectable (SelectionKey key)

This I/O reactor implementation does not react to the OP_CONNECT event.

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

Parameters
key the selection key.

protected IOSession getSession (SelectionKey key)

Obtains IOSession instance associated with the given selection key.

Parameters
key the selection key.
Returns
  • I/O session.

protected void handleRuntimeException (RuntimeException ex)

Handles the given RuntimeException. This method delegates handling of the exception to the IOReactorExceptionHandler, if available.

Parameters
ex the runtime exception.

protected void readable (SelectionKey key)

Processes OP_READ event on the given selection key. This method dispatches the event notification to the inputReady(IOSession) method.

Parameters
key the selection key.

protected void sessionClosed (IOSession session)

Processes closed I/O session. This method dispatches the event notification to the disconnected(IOSession) method.

Parameters
session closed I/O session.

protected void sessionCreated (SelectionKey key, IOSession session)

Processes newly created I/O session. This method dispatches the event notification to the connected(IOSession) method.

Parameters
key the selection key.
session new I/O session.

protected void timeoutCheck (SelectionKey key, long now)

Performs timeout check for the I/O session associated with the given selection key.

Parameters
key the selection key.
now current time as long value.

protected void validate (Set<SelectionKey> keys)

Verifies whether any of the sessions associated with the given selection keys timed out by invoking the timeoutCheck(SelectionKey, long) method.

This method will also invoke the inputReady(IOSession) method on all sessions that have buffered input data.

Parameters
keys all selection keys registered with the selector.

protected void writable (SelectionKey key)

Processes OP_WRITE event on the given selection key. This method dispatches the event notification to the outputReady(IOSession) method.

Parameters
key the selection key.