|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.nio.reactor.AbstractIOReactor
org.apache.http.impl.nio.reactor.BaseIOReactor
public class BaseIOReactor
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.
Constructor Summary | |
---|---|
BaseIOReactor(long selectTimeout)
Creates new BaseIOReactor instance. |
|
BaseIOReactor(long selectTimeout,
boolean interestOpsQueueing)
Creates new BaseIOReactor instance. |
Method Summary | |
---|---|
protected void |
acceptable(java.nio.channels.SelectionKey key)
This I/O reactor implementation does not react to the SelectionKey.OP_ACCEPT event. |
protected void |
connectable(java.nio.channels.SelectionKey key)
This I/O reactor implementation does not react to the SelectionKey.OP_CONNECT event. |
void |
execute(IOEventDispatch eventDispatch)
Activates the I/O reactor. |
protected IOSession |
getSession(java.nio.channels.SelectionKey key)
Obtains IOSession instance associated with the given selection
key. |
protected void |
handleRuntimeException(java.lang.RuntimeException ex)
Handles the given RuntimeException . |
protected void |
readable(java.nio.channels.SelectionKey key)
Processes SelectionKey.OP_READ event on the given selection key. |
protected void |
sessionClosed(IOSession session)
Processes closed I/O session. |
protected void |
sessionCreated(java.nio.channels.SelectionKey key,
IOSession session)
Processes newly created I/O session. |
void |
setExceptionHandler(IOReactorExceptionHandler exceptionHandler)
Sets exception handler for this I/O reactor. |
protected void |
timeoutCheck(java.nio.channels.SelectionKey key,
long now)
Performs timeout check for the I/O session associated with the given selection key. |
protected void |
validate(java.util.Set<java.nio.channels.SelectionKey> keys)
Verifies whether any of the sessions associated with the given selection keys timed out by invoking the timeoutCheck(SelectionKey, long)
method. |
protected void |
writable(java.nio.channels.SelectionKey key)
Processes SelectionKey.OP_WRITE event on the given selection key. |
Methods inherited from class org.apache.http.impl.nio.reactor.AbstractIOReactor |
---|
addChannel, awaitShutdown, closeActiveChannels, closeNewChannels, closeSessions, execute, getInterestOpsQueueing, getStatus, gracefulShutdown, hardShutdown, processEvent, queueClosedSession, shutdown, shutdown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseIOReactor(long selectTimeout) throws IOReactorException
selectTimeout
- the select timeout.
IOReactorException
- in case if a non-recoverable I/O error.public BaseIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException
selectTimeout
- the select timeout.interestOpsQueueing
- Ops queueing flag.
IOReactorException
- in case if a non-recoverable I/O error.Method Detail |
---|
public void execute(IOEventDispatch eventDispatch) throws java.io.InterruptedIOException, IOReactorException
IOEventDispatch
.
eventDispatch
- the I/O event dispatch.
java.io.InterruptedIOException
- if the dispatch thread is interrupted.
IOReactorException
- in case if a non-recoverable I/O error.public void setExceptionHandler(IOReactorExceptionHandler exceptionHandler)
exceptionHandler
- the exception handler.protected void handleRuntimeException(java.lang.RuntimeException ex)
RuntimeException
. This method delegates
handling of the exception to the IOReactorExceptionHandler
,
if available.
ex
- the runtime exception.protected void acceptable(java.nio.channels.SelectionKey key)
SelectionKey.OP_ACCEPT
event.
Super-classes can override this method to react to the event.
acceptable
in class AbstractIOReactor
key
- the selection key.protected void connectable(java.nio.channels.SelectionKey key)
SelectionKey.OP_CONNECT
event.
Super-classes can override this method to react to the event.
connectable
in class AbstractIOReactor
key
- the selection key.protected void readable(java.nio.channels.SelectionKey key)
SelectionKey.OP_READ
event on the given selection key.
This method dispatches the event notification to the
IOEventDispatch.inputReady(IOSession)
method.
readable
in class AbstractIOReactor
key
- the selection key.protected void writable(java.nio.channels.SelectionKey key)
SelectionKey.OP_WRITE
event on the given selection key.
This method dispatches the event notification to the
IOEventDispatch.outputReady(IOSession)
method.
writable
in class AbstractIOReactor
key
- the selection key.protected void validate(java.util.Set<java.nio.channels.SelectionKey> keys)
timeoutCheck(SelectionKey, long)
method.
This method will also invoke the
IOEventDispatch.inputReady(IOSession)
method on all sessions
that have buffered input data.
validate
in class AbstractIOReactor
keys
- all selection keys registered with the selector.protected void timeoutCheck(java.nio.channels.SelectionKey key, long now)
timeoutCheck
in class AbstractIOReactor
key
- the selection key.now
- current time as long value.protected void sessionCreated(java.nio.channels.SelectionKey key, IOSession session)
IOEventDispatch.connected(IOSession)
method.
sessionCreated
in class AbstractIOReactor
key
- the selection key.session
- new I/O session.protected IOSession getSession(java.nio.channels.SelectionKey key)
AbstractIOReactor
IOSession
instance associated with the given selection
key.
getSession
in class AbstractIOReactor
key
- the selection key.
protected void sessionClosed(IOSession session)
IOEventDispatch.disconnected(IOSession)
method.
sessionClosed
in class AbstractIOReactor
session
- closed I/O session.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |