You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Trustin Lee <tr...@gmail.com> on 2007/04/03 06:27:32 UTC
Applying Java 5 Generics to o.a.mina.handler.demux.MessageHandler
Hi folks,
I'm reviewing MINA 1.1.0-SNAPSHOT. While fixing some compiler
warning, I found that o.a.mina.handler.demux.MessageHandler can use
Java 5 Generics because the implementor will expect that a certain
type of message will be received to the implementation. So I added a
type parameter to the MessageHandler and modified the public method
declaration of the DemuxingIoHandler as the following:
----------------
public <E> MessageHandler<? super E> addMessageHandler( Class<E>
type, MessageHandler<? super E> handler )
public <E> MessageHandler<? super E> removeMessageHandler( Class<E> type )
public <E> MessageHandler<? super E> getMessageHandler( Class<E> type )
----------------
and, here's the modified MessageHandler:
----------------
public interface MessageHandler<E>
{
......
void messageReceived( IoSession session, E message ) throws Exception;
}
----------------
What do you think? Would this change be useful, or should I revert back?
Thanks,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6
Re: Applying Java 5 Generics to o.a.mina.handler.demux.MessageHandler
Posted by Trustin Lee <tr...@gmail.com>.
I forgot to mention that we can do the same for MessageEncoder
(o.a.mina.filter.codec.demux).
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6