| java.lang.Object org.apache.mina.common.IoHandlerAdapter org.apache.mina.handler.demux.DemuxingIoHandler
DemuxingIoHandler | public class DemuxingIoHandler extends IoHandlerAdapter (Code) | | A
IoHandler that demuxes messageReceived events
to the appropriate
MessageHandler .
You can freely register and deregister
MessageHandler s using
DemuxingIoHandler.addReceivedMessageHandler(Class,MessageHandler) and
DemuxingIoHandler.removeReceivedMessageHandler(Class) .
When message is received through a call to
DemuxingIoHandler.messageReceived(IoSession,Object) the class of the
message object will be used to find a
MessageHandler for
that particular message type. If no
MessageHandler instance can be
found for the immediate class (i.e. message.getClass() ) the
interfaces implemented by the immediate class will be searched in depth-first
order. If no match can be found for any of the interfaces the search will be
repeated recursively for the superclass of the immediate class
(i.e. message.getClass().getSuperclass() ).
Consider the following type hierarchy (Cx are classes while
Ix are interfaces):
C3 - I7 - I9
| | /\
| I8 I3 I4
|
C2 - I5 - I6
|
C1 - I1 - I2 - I4
| |
| I3
Object
When message is of type C3 this hierarchy will be
searched in the following order:
C3, I7, I8, I9, I3, I4, C2, I5, I6, C1, I1, I2, I3, I4, Object .
For efficiency searches will be cached. Calls to
DemuxingIoHandler.addReceivedMessageHandler(Class,MessageHandler) and
DemuxingIoHandler.removeReceivedMessageHandler(Class) clear this cache.
author: The Apache MINA Project (dev@mina.apache.org) version: $Rev: 612349 $, $Date: 2008-01-15 21:39:03 -0700 (Tue, 15 Jan 2008) $ |
Method Summary | |
public ExceptionHandler<? super E> | addExceptionHandler(Class<E> type, ExceptionHandler<? super E> handler) Registers a
MessageHandler that receives the messages of
the specified type .
the old handler if there is already a registered handler forthe specified type. | public MessageHandler<? super E> | addReceivedMessageHandler(Class<E> type, MessageHandler<? super E> handler) Registers a
MessageHandler that handles the received messages of
the specified type .
the old handler if there is already a registered handler forthe specified type. | public MessageHandler<? super E> | addSentMessageHandler(Class<E> type, MessageHandler<? super E> handler) Registers a
MessageHandler that handles the sent messages of the
specified type .
the old handler if there is already a registered handler forthe specified type. | final public void | exceptionCaught(IoSession session, Throwable cause) | protected ExceptionHandler<Throwable> | findExceptionHandler(Class<? extends Throwable> type) | protected MessageHandler<Object> | findReceivedMessageHandler(Class> type) | protected MessageHandler<Object> | findSentMessageHandler(Class> type) | public Map<Class<?>, ExceptionHandler<?>> | getExceptionHandlerMap() Returns the
Map which contains all messageType-
MessageHandler pairs registered to this handler. | public MessageHandler<? super E> | getMessageHandler(Class<E> type) Returns the
MessageHandler which is registered to process
the specified type . | public Map<Class<?>, MessageHandler<?>> | getReceivedMessageHandlerMap() Returns the
Map which contains all messageType-
MessageHandler pairs registered to this handler for received messages. | public Map<Class<?>, MessageHandler<?>> | getSentMessageHandlerMap() Returns the
Map which contains all messageType-
MessageHandler pairs registered to this handler for sent messages. | final public void | messageReceived(IoSession session, Object message) Forwards the received events into the appropriate
MessageHandler which is registered by
DemuxingIoHandler.addReceivedMessageHandler(Class,MessageHandler) . | final public void | messageSent(IoSession session, Object message) | public ExceptionHandler<? super E> | removeExceptionHandler(Class<E> type) Deregisters a
MessageHandler that receives the messages of
the specified type .
the removed handler if successfully removed. | public MessageHandler<? super E> | removeReceivedMessageHandler(Class<E> type) Deregisters a
MessageHandler that handles the received messages
of the specified type .
the removed handler if successfully removed. | public MessageHandler<? super E> | removeSentMessageHandler(Class<E> type) Deregisters a
MessageHandler that handles the sent messages of
the specified type .
the removed handler if successfully removed. |
DemuxingIoHandler | public DemuxingIoHandler()(Code) | | Creates a new instance with no registered
MessageHandler s.
|
addExceptionHandler | public ExceptionHandler<? super E> addExceptionHandler(Class<E> type, ExceptionHandler<? super E> handler)(Code) | | Registers a
MessageHandler that receives the messages of
the specified type .
the old handler if there is already a registered handler forthe specified type. null otherwise. |
addReceivedMessageHandler | public MessageHandler<? super E> addReceivedMessageHandler(Class<E> type, MessageHandler<? super E> handler)(Code) | | Registers a
MessageHandler that handles the received messages of
the specified type .
the old handler if there is already a registered handler forthe specified type. null otherwise. |
addSentMessageHandler | public MessageHandler<? super E> addSentMessageHandler(Class<E> type, MessageHandler<? super E> handler)(Code) | | Registers a
MessageHandler that handles the sent messages of the
specified type .
the old handler if there is already a registered handler forthe specified type. null otherwise. |
removeExceptionHandler | public ExceptionHandler<? super E> removeExceptionHandler(Class<E> type)(Code) | | Deregisters a
MessageHandler that receives the messages of
the specified type .
the removed handler if successfully removed. null otherwise. |
removeReceivedMessageHandler | public MessageHandler<? super E> removeReceivedMessageHandler(Class<E> type)(Code) | | Deregisters a
MessageHandler that handles the received messages
of the specified type .
the removed handler if successfully removed. null otherwise. |
removeSentMessageHandler | public MessageHandler<? super E> removeSentMessageHandler(Class<E> type)(Code) | | Deregisters a
MessageHandler that handles the sent messages of
the specified type .
the removed handler if successfully removed. null otherwise. |
|
|