org.apache.mina.handler.multiton

Class SingleSessionIoHandlerAdapter

Implemented Interfaces:
SingleSessionIoHandler

public class SingleSessionIoHandlerAdapter
extends java.lang.Object
implements SingleSessionIoHandler

Adapter class for implementors of the SingleSessionIoHandler interface. The session to which the handler is assigned is accessible through the getSession() method.

Constructor Summary

SingleSessionIoHandlerAdapter(IoSession session)
Creates a new instance that is assigned to the passed in session.

Method Summary

void
exceptionCaught(Throwable th)
Invoked when any exception is thrown by user IoHandler implementation or by MINA.
protected IoSession
getSession()
Retrieves the session to which this handler is assigned.
void
messageReceived(Object message)
Invoked when protocol message is received.
void
messageSent(Object message)
Invoked when protocol message that user requested by IoSession.write(Object) is sent out actually.
void
sessionClosed()
Invoked when the connection is closed.
void
sessionCreated()
Invoked when the session is created.
void
sessionIdle(IdleStatus status)
Invoked when the connection is idle.
void
sessionOpened()
Invoked when the connection is opened.

Constructor Details

SingleSessionIoHandlerAdapter

public SingleSessionIoHandlerAdapter(IoSession session)
Creates a new instance that is assigned to the passed in session.
Parameters:
session - the session to which the handler is assigned

Method Details

exceptionCaught

public void exceptionCaught(Throwable th)
            throws Exception
Invoked when any exception is thrown by user IoHandler implementation or by MINA. If cause is instanceof IOException, MINA will close the connection automatically.
Specified by:
exceptionCaught in interface SingleSessionIoHandler
Parameters:

getSession

protected IoSession getSession()
Retrieves the session to which this handler is assigned.
Returns:
the session

messageReceived

public void messageReceived(Object message)
            throws Exception
Invoked when protocol message is received. Implement your protocol flow here.
Specified by:
messageReceived in interface SingleSessionIoHandler
Parameters:
message - the received message

messageSent

public void messageSent(Object message)
            throws Exception
Specified by:
messageSent in interface SingleSessionIoHandler
Parameters:
message - the sent message

sessionClosed

public void sessionClosed()
            throws Exception
Invoked when the connection is closed. This method is not invoked if the transport type is UDP.
Specified by:
sessionClosed in interface SingleSessionIoHandler

sessionCreated

public void sessionCreated()
            throws Exception
Invoked when the session is created. Initialize default socket parameters and user-defined attributes here.
Specified by:
sessionCreated in interface SingleSessionIoHandler

sessionIdle

public void sessionIdle(IdleStatus status)
            throws Exception
Invoked when the connection is idle. Refer to IdleStatus. This method is not invoked if the transport type is UDP.
Specified by:
sessionIdle in interface SingleSessionIoHandler
Parameters:
status - the type of idleness

sessionOpened

public void sessionOpened()
            throws Exception
Invoked when the connection is opened. This method is not invoked if the transport type is UDP.
Specified by:
sessionOpened in interface SingleSessionIoHandler