org.apache.mina.protocol
Interface ProtocolHandler

All Known Implementing Classes:
ProtocolHandlerAdapter

public interface ProtocolHandler

Handles all protocol events fired by MINA. There are 6 event handler methods, and they are all invoked by MINA automatically.

Please refer to ReverseProtocolHandler example.

Version:
$Rev: 326586 $, $Date: 2005-10-19 17:50:29 +0200 (Wed, 19 Oct 2005) $
Author:
The Apache Directory Project (dev@directory.apache.org)
See Also:
ProtocolHandlerAdapter

Method Summary
 void exceptionCaught(ProtocolSession session, java.lang.Throwable cause)
          Invoked when any exception is thrown by user ProtocolHandler implementation or by MINA.
 void messageReceived(ProtocolSession session, java.lang.Object message)
          Invoked when protocol message is received.
 void messageSent(ProtocolSession session, java.lang.Object message)
          Invoked when protocol message that user requested by ProtocolSession.write(Object) is sent out actually.
 void sessionClosed(ProtocolSession session)
          Invoked when the connection is closed.
 void sessionCreated(ProtocolSession session)
          Invoked when the session is created.
 void sessionIdle(ProtocolSession session, IdleStatus status)
          Invoked when the connection is idle.
 void sessionOpened(ProtocolSession session)
          Invoked when the connection is opened.
 

Method Detail

sessionCreated

public void sessionCreated(ProtocolSession session)
                    throws java.lang.Exception
Invoked when the session is created. Initialize default socket parameters and user-defined attributes here.

Throws:
java.lang.Exception

sessionOpened

public void sessionOpened(ProtocolSession session)
                   throws java.lang.Exception
Invoked when the connection is opened. This method is not invoked if the transport type is UDP.

Throws:
java.lang.Exception

sessionClosed

public void sessionClosed(ProtocolSession session)
                   throws java.lang.Exception
Invoked when the connection is closed. This method is not invoked if the transport type is UDP.

Throws:
java.lang.Exception

sessionIdle

public void sessionIdle(ProtocolSession session,
                        IdleStatus status)
                 throws java.lang.Exception
Invoked when the connection is idle. Refer to IdleStatus. This method is not invoked if the transport type is UDP.

Throws:
java.lang.Exception

exceptionCaught

public void exceptionCaught(ProtocolSession session,
                            java.lang.Throwable cause)
                     throws java.lang.Exception
Invoked when any exception is thrown by user ProtocolHandler implementation or by MINA. If cause is instanceof IOException, MINA will close the connection automatically.

Throws:
java.lang.Exception

messageReceived

public void messageReceived(ProtocolSession session,
                            java.lang.Object message)
                     throws java.lang.Exception
Invoked when protocol message is received. Implement your protocol flow here.

Throws:
java.lang.Exception

messageSent

public void messageSent(ProtocolSession session,
                        java.lang.Object message)
                 throws java.lang.Exception
Invoked when protocol message that user requested by ProtocolSession.write(Object) is sent out actually.

Throws:
java.lang.Exception