|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.core.polling.AbstractPollingIoProcessor<NioSession>
org.apache.mina.transport.socket.nio.NioProcessor
public final class NioProcessor
TODO Add documentation
| Nested Class Summary | |
|---|---|
protected static class |
NioProcessor.IoSessionIterator<NioSession>
An encapsulating iterator around the Selector.selectedKeys() or
the Selector.keys() iterator; |
| Field Summary |
|---|
| Fields inherited from class org.apache.mina.core.polling.AbstractPollingIoProcessor |
|---|
wakeupCalled |
| Constructor Summary | |
|---|---|
NioProcessor(java.util.concurrent.Executor executor)
Creates a new instance of NioProcessor. |
|
| Method Summary | |
|---|---|
protected java.util.Iterator<NioSession> |
allSessions()
Get an Iterator for the list of IoSession polled by this
IoProcessor |
protected void |
destroy(NioSession session)
Destroy the underlying client socket handle |
protected void |
doDispose()
Dispose the resources used by this IoProcessor for polling the
client connections. |
protected SessionState |
getState(NioSession session)
Get the state of a session (preparing, open, closed) |
protected void |
init(NioSession session)
Initialize the polling of a session. |
protected boolean |
isBrokenConnection()
Check that the select() has not exited immediately just because of a broken connection. |
protected boolean |
isInterestedInRead(NioSession session)
is this session registered for reading |
protected boolean |
isInterestedInWrite(NioSession session)
is this session registered for writing |
protected boolean |
isReadable(NioSession session)
Is the session ready for reading |
protected boolean |
isSelectorEmpty()
Say if the list of IoSession polled by this IoProcessor
is empty |
protected boolean |
isWritable(NioSession session)
Is the session ready for writing |
protected int |
read(NioSession session,
IoBuffer buf)
Reads a sequence of bytes from a IoSession into the given
IoBuffer. |
protected void |
registerNewSelector()
In the case we are using the java select() method, this method is used to trash the buggy selector and create a new one, registering all the sockets on it. |
protected int |
select()
poll those sessions forever |
protected int |
select(long timeout)
poll those sessions for the given timeout |
protected java.util.Iterator<NioSession> |
selectedSessions()
Get an Iterator for the list of IoSession found selected
by the last call of {@link AbstractPollingIoProcessor#select(int) |
protected void |
setInterestedInRead(NioSession session,
boolean isInterested)
register a session for reading |
protected void |
setInterestedInWrite(NioSession session,
boolean isInterested)
register a session for writing |
protected int |
transferFile(NioSession session,
FileRegion region,
int length)
Write a part of a file to a IoSession, if the underlying API
isn't supporting system calls like sendfile(), you can throw a
UnsupportedOperationException so the file will be send using
usual AbstractPollingIoProcessor.write(AbstractIoSession, IoBuffer, int) call. |
protected void |
wakeup()
Interrupt the {@link AbstractPollingIoProcessor#select(int) call. |
protected int |
write(NioSession session,
IoBuffer buf,
int length)
Write a sequence of bytes to a IoSession, means to be called when
a session was found ready for writing. |
| Methods inherited from class org.apache.mina.core.polling.AbstractPollingIoProcessor |
|---|
add, dispose, flush, isDisposed, isDisposing, remove, updateTrafficControl, updateTrafficMask |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NioProcessor(java.util.concurrent.Executor executor)
executor - | Method Detail |
|---|
protected void doDispose()
throws java.lang.Exception
AbstractPollingIoProcessorIoProcessor for polling the
client connections. The implementing class doDispose method will be called.
doDispose in class AbstractPollingIoProcessor<NioSession>java.lang.Exception - if some low level IO error occurs
protected int select(long timeout)
throws java.lang.Exception
AbstractPollingIoProcessor
select in class AbstractPollingIoProcessor<NioSession>timeout - milliseconds before the call timeout if no event appear
java.lang.Exception - if some low level IO error occurs
protected int select()
throws java.lang.Exception
AbstractPollingIoProcessor
select in class AbstractPollingIoProcessor<NioSession>java.lang.Exception - if some low level IO error occursprotected boolean isSelectorEmpty()
AbstractPollingIoProcessorIoSession polled by this IoProcessor
is empty
isSelectorEmpty in class AbstractPollingIoProcessor<NioSession>IoProcessorprotected void wakeup()
AbstractPollingIoProcessor
wakeup in class AbstractPollingIoProcessor<NioSession>protected java.util.Iterator<NioSession> allSessions()
AbstractPollingIoProcessorIterator for the list of IoSession polled by this
IoProcessor
allSessions in class AbstractPollingIoProcessor<NioSession>Iterator of IoSessionprotected java.util.Iterator<NioSession> selectedSessions()
AbstractPollingIoProcessorIterator for the list of IoSession found selected
by the last call of {@link AbstractPollingIoProcessor#select(int)
selectedSessions in class AbstractPollingIoProcessor<NioSession>Iterator of IoSession read for I/Os operation
protected void init(NioSession session)
throws java.lang.Exception
AbstractPollingIoProcessor
init in class AbstractPollingIoProcessor<NioSession>session - the IoSession to add to the polling
java.lang.Exception - any exception thrown by the underlying system calls
protected void destroy(NioSession session)
throws java.lang.Exception
AbstractPollingIoProcessor
destroy in class AbstractPollingIoProcessor<NioSession>session - the IoSession
java.lang.Exception - any exception thrown by the underlying system calls
protected void registerNewSelector()
throws java.io.IOException
registerNewSelector in class AbstractPollingIoProcessor<NioSession>java.io.IOException - If we got an exception
protected boolean isBrokenConnection()
throws java.io.IOException
isBrokenConnection in class AbstractPollingIoProcessor<NioSession>java.io.IOException - If we got an exceptionprotected SessionState getState(NioSession session)
getState in class AbstractPollingIoProcessor<NioSession>session - the IoSession to inspect
protected boolean isReadable(NioSession session)
AbstractPollingIoProcessor
isReadable in class AbstractPollingIoProcessor<NioSession>session - the session queried
protected boolean isWritable(NioSession session)
AbstractPollingIoProcessor
isWritable in class AbstractPollingIoProcessor<NioSession>session - the session queried
protected boolean isInterestedInRead(NioSession session)
AbstractPollingIoProcessor
isInterestedInRead in class AbstractPollingIoProcessor<NioSession>session - the session queried
protected boolean isInterestedInWrite(NioSession session)
AbstractPollingIoProcessor
isInterestedInWrite in class AbstractPollingIoProcessor<NioSession>session - the session queried
protected void setInterestedInRead(NioSession session,
boolean isInterested)
throws java.lang.Exception
setInterestedInRead in class AbstractPollingIoProcessor<NioSession>session - the session registeredisInterested - true for registering, false for removing
java.lang.Exception
protected void setInterestedInWrite(NioSession session,
boolean isInterested)
throws java.lang.Exception
setInterestedInWrite in class AbstractPollingIoProcessor<NioSession>session - the session registeredisInterested - true for registering, false for removing
java.lang.Exception
protected int read(NioSession session,
IoBuffer buf)
throws java.lang.Exception
AbstractPollingIoProcessorIoSession into the given
IoBuffer. Is called when the session was found ready for reading.
read in class AbstractPollingIoProcessor<NioSession>session - the session to readbuf - the buffer to fill
java.lang.Exception - any exception thrown by the underlying system calls
protected int write(NioSession session,
IoBuffer buf,
int length)
throws java.lang.Exception
AbstractPollingIoProcessorIoSession, means to be called when
a session was found ready for writing.
write in class AbstractPollingIoProcessor<NioSession>session - the session to writebuf - the buffer to writelength - the number of bytes to write can be superior to the number of
bytes remaining in the buffer
java.lang.Exception - any exception thrown by the underlying system calls
protected int transferFile(NioSession session,
FileRegion region,
int length)
throws java.lang.Exception
AbstractPollingIoProcessorIoSession, if the underlying API
isn't supporting system calls like sendfile(), you can throw a
UnsupportedOperationException so the file will be send using
usual AbstractPollingIoProcessor.write(AbstractIoSession, IoBuffer, int) call.
transferFile in class AbstractPollingIoProcessor<NioSession>session - the session to writeregion - the file region to writelength - the length of the portion to send
java.lang.Exception - any exception thrown by the underlying system calls
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||