org.apache.mina.io.handler
Class StreamIoHandler

java.lang.Object
  extended by org.apache.mina.io.IoHandlerAdapter
      extended by org.apache.mina.io.handler.StreamIoHandler
All Implemented Interfaces:
IoHandler

public abstract class StreamIoHandler
extends IoHandlerAdapter

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.

Version:
$Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
Author:
The Apache Directory Project (dev@directory.apache.org), Trustin Lee (trustin@apache.org)

Constructor Summary
protected StreamIoHandler()
           
 
Method Summary
 void dataRead(IoSession session, ByteBuffer buf)
          Forwards read data to input stream.
 void exceptionCaught(IoSession session, Throwable cause)
          Forwards caught exceptions to input stream.
 int getReadTimeout()
          Returns read timeout in seconds.
 int getWriteTimeout()
          Returns write timeout in seconds.
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.
 void sessionClosed(IoSession session)
          Closes input stream.
 void 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.io.IoHandlerAdapter
dataWritten, sessionCreated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamIoHandler

protected StreamIoHandler()
Method Detail

processStreamIo

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.


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 interface IoHandler
Overrides:
sessionOpened in class IoHandlerAdapter

sessionClosed

public void sessionClosed(IoSession session)
Closes input stream.

Specified by:
sessionClosed in interface IoHandler
Overrides:
sessionClosed in class IoHandlerAdapter

dataRead

public void dataRead(IoSession session,
                     ByteBuffer buf)
Forwards read data to input stream.

Specified by:
dataRead in interface IoHandler
Overrides:
dataRead in class IoHandlerAdapter

exceptionCaught

public void exceptionCaught(IoSession session,
                            Throwable cause)
Forwards caught exceptions to input stream.

Specified by:
exceptionCaught in interface IoHandler
Overrides:
exceptionCaught in class IoHandlerAdapter

sessionIdle

public void sessionIdle(IoSession session,
                        IdleStatus status)
Handles read timeout.

Specified by:
sessionIdle in interface IoHandler
Overrides:
sessionIdle in class IoHandlerAdapter


Copyright © 2004-2005 . All Rights Reserved.