Class 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.

    Author:
    Apache MINA Project
    • Constructor Detail

      • StreamIoHandler

        protected StreamIoHandler()
    • 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.
        Parameters:
        session - The current session
        in - The input stream
        out - The output stream
      • 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).
        Parameters:
        readTimeout - The Read timeout
      • 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).
        Parameters:
        writeTimeout - The Write timeout
      • sessionClosed

        public void sessionClosed​(IoSession session)
                           throws java.lang.Exception
        Closes streams
        Specified by:
        sessionClosed in interface IoHandler
        Overrides:
        sessionClosed in class IoHandlerAdapter
        Parameters:
        session - The session being closed
        Throws:
        java.lang.Exception - If we get an exception while processing the close event
      • messageReceived

        public void messageReceived​(IoSession session,
                                    java.lang.Object buf)
        Forwards read data to input stream.
        Specified by:
        messageReceived in interface IoHandler
        Overrides:
        messageReceived in class IoHandlerAdapter
        Parameters:
        session - The session that is receiving a message
        buf - The received message
      • exceptionCaught

        public void exceptionCaught​(IoSession session,
                                    java.lang.Throwable cause)
        Forwards caught exceptions to input stream.
        Specified by:
        exceptionCaught in interface IoHandler
        Overrides:
        exceptionCaught in class IoHandlerAdapter
        Parameters:
        session - The session for which we have got an exception
        cause - The exception that has been caught