org.apache.mina.protocol
Interface ProtocolHandler

All Known Implementing Classes:
DemuxingProtocolHandler, 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: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
Author:
The Apache Directory Project (dev@directory.apache.org)
See Also:
ProtocolHandlerAdapter

Method Summary
 void exceptionCaught(ProtocolSession session, Throwable cause)
          Invoked when any exception is thrown by user ProtocolHandler implementation or by MINA.
 void messageReceived(ProtocolSession session, Object message)
          Invoked when protocol message is received.
 void messageSent(ProtocolSession session, 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

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

Throws:
Exception

sessionOpened

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

Throws:
Exception

sessionClosed

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

Throws:
Exception

sessionIdle

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

Throws:
Exception

exceptionCaught

void exceptionCaught(ProtocolSession session,
                     Throwable cause)
                     throws 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:
Exception

messageReceived

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

Throws:
Exception

messageSent

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

Throws:
Exception


Copyright © 2004-2005 . All Rights Reserved.