Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.mina.common.IoHandlerAdapter
org.apache.mina.handler.StreamIoHandler
public abstract class StreamIoHandler
extends IoHandlerAdapter
IoHandler
that adapts asynchronous MINA events to stream I/O.
Please extend this class and implement
processStreamIo(IoSession,InputStream,OutputStream)
to
execute your stream I/O logic; please note that you must forward
the process request to other thread or thread pool.
Constructor Summary | |
Method Summary | |
void |
|
int |
|
int |
|
void |
|
protected abstract void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.apache.mina.common.IoHandlerAdapter | |
exceptionCaught , messageReceived , messageSent , sessionClosed , sessionCreated , sessionIdle , sessionOpened |
public void exceptionCaught(IoSession session, Throwable cause)
Forwards caught exceptions to input stream.
- Specified by:
- exceptionCaught in interface IoHandler
- Overrides:
- exceptionCaught in interface IoHandlerAdapter
public int getReadTimeout()
Returns read timeout in seconds. The default value is 0 (disabled).
public int getWriteTimeout()
Returns write timeout in seconds. The default value is 0 (disabled).
public void messageReceived(IoSession session, Object buf)
Forwards read data to input stream.
- Specified by:
- messageReceived in interface IoHandler
- Overrides:
- messageReceived in interface IoHandlerAdapter
protected abstract void processStreamIo(IoSession session, InputStream in, OutputStream out)
Implement this method to execute your stream I/O logic; please note that you must forward the process request to other thread or thread pool.
public void sessionClosed(IoSession session) throws Exception
Closes streams
- Specified by:
- sessionClosed in interface IoHandler
- Overrides:
- sessionClosed in interface IoHandlerAdapter
public void sessionIdle(IoSession session, IdleStatus status)
Handles read timeout.
- Specified by:
- sessionIdle in interface IoHandler
- Overrides:
- sessionIdle in interface IoHandlerAdapter
public void sessionOpened(IoSession session)
Initializes streams and timeout settings.
- Specified by:
- sessionOpened in interface IoHandler
- Overrides:
- sessionOpened in interface IoHandlerAdapter
public void setReadTimeout(int readTimeout)
Sets read timeout in seconds. The default value is 0 (disabled).
public void setWriteTimeout(int writeTimeout)
Sets write timeout in seconds. The default value is 0 (disabled).