Package org.apache.mina.handler
Class StreamIoHandler
java.lang.Object
org.apache.mina.common.IoHandlerAdapter
org.apache.mina.handler.StreamIoHandler
- All Implemented Interfaces:
IoHandler
A
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexceptionCaught(IoSession session, Throwable cause) Forwards caught exceptions to input stream.intReturns read timeout in seconds.intReturns write timeout in seconds.voidmessageReceived(IoSession session, Object buf) Forwards read data to input stream.protected abstract voidprocessStreamIo(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.voidsessionClosed(IoSession session) Closes streamsvoidsessionIdle(IoSession session, IdleStatus status) Handles read timeout.voidsessionOpened(IoSession session) Initializes streams and timeout settings.voidsetReadTimeout(int readTimeout) Sets read timeout in seconds.voidsetWriteTimeout(int writeTimeout) Sets write timeout in seconds.Methods inherited from class org.apache.mina.common.IoHandlerAdapter
messageSent, sessionCreated
-
Constructor Details
-
StreamIoHandler
protected StreamIoHandler()
-
-
Method Details
-
processStreamIo
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
Initializes streams and timeout settings.- Specified by:
sessionOpenedin interfaceIoHandler- Overrides:
sessionOpenedin classIoHandlerAdapter
-
sessionClosed
Closes streams- Specified by:
sessionClosedin interfaceIoHandler- Overrides:
sessionClosedin classIoHandlerAdapter- Throws:
Exception
-
messageReceived
Forwards read data to input stream.- Specified by:
messageReceivedin interfaceIoHandler- Overrides:
messageReceivedin classIoHandlerAdapter
-
exceptionCaught
Forwards caught exceptions to input stream.- Specified by:
exceptionCaughtin interfaceIoHandler- Overrides:
exceptionCaughtin classIoHandlerAdapter
-
sessionIdle
Handles read timeout.- Specified by:
sessionIdlein interfaceIoHandler- Overrides:
sessionIdlein classIoHandlerAdapter
-