Package org.apache.mina.handler
Class StreamIoHandler
- java.lang.Object
-
- org.apache.mina.common.IoHandlerAdapter
-
- org.apache.mina.handler.StreamIoHandler
-
- All Implemented Interfaces:
IoHandler
public abstract class StreamIoHandler extends IoHandlerAdapter
AIoHandler
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
Constructors Modifier Constructor Description protected
StreamIoHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
exceptionCaught(IoSession session, java.lang.Throwable cause)
Forwards caught exceptions to input stream.int
getReadTimeout()
Returns read timeout in seconds.int
getWriteTimeout()
Returns write timeout in seconds.void
messageReceived(IoSession session, java.lang.Object buf)
Forwards read data to input stream.protected abstract void
processStreamIo(IoSession session, java.io.InputStream in, java.io.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.void
sessionClosed(IoSession session)
Closes streamsvoid
sessionIdle(IoSession session, IdleStatus status)
Handles read timeout.void
sessionOpened(IoSession session)
Initializes streams and timeout settings.void
setReadTimeout(int readTimeout)
Sets read timeout in seconds.void
setWriteTimeout(int writeTimeout)
Sets write timeout in seconds.-
Methods inherited from class org.apache.mina.common.IoHandlerAdapter
messageSent, sessionCreated
-
-
-
-
Method Detail
-
processStreamIo
protected abstract void processStreamIo(IoSession session, java.io.InputStream in, java.io.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.
-
getReadTimeout
public int getReadTimeout()
Returns read timeout in seconds. The default value is 0 (disabled).
-
setReadTimeout
public void setReadTimeout(int readTimeout)
Sets read timeout in seconds. The default value is 0 (disabled).
-
getWriteTimeout
public int getWriteTimeout()
Returns write timeout in seconds. The default value is 0 (disabled).
-
setWriteTimeout
public void setWriteTimeout(int writeTimeout)
Sets write timeout in seconds. The default value is 0 (disabled).
-
sessionOpened
public void sessionOpened(IoSession session)
Initializes streams and timeout settings.- Specified by:
sessionOpened
in interfaceIoHandler
- Overrides:
sessionOpened
in classIoHandlerAdapter
-
sessionClosed
public void sessionClosed(IoSession session) throws java.lang.Exception
Closes streams- Specified by:
sessionClosed
in interfaceIoHandler
- Overrides:
sessionClosed
in classIoHandlerAdapter
- Throws:
java.lang.Exception
-
messageReceived
public void messageReceived(IoSession session, java.lang.Object buf)
Forwards read data to input stream.- Specified by:
messageReceived
in interfaceIoHandler
- Overrides:
messageReceived
in classIoHandlerAdapter
-
exceptionCaught
public void exceptionCaught(IoSession session, java.lang.Throwable cause)
Forwards caught exceptions to input stream.- Specified by:
exceptionCaught
in interfaceIoHandler
- Overrides:
exceptionCaught
in classIoHandlerAdapter
-
sessionIdle
public void sessionIdle(IoSession session, IdleStatus status)
Handles read timeout.- Specified by:
sessionIdle
in interfaceIoHandler
- Overrides:
sessionIdle
in classIoHandlerAdapter
-
-