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/09/28 16:51:44 UTC

Re: getMessageTypes in MessageEncoder

On 8/23/07, mat <fo...@gmail.com> wrote:
> I wonder what is the usage of getMessageTypes in MessageEncoder?

I think it's of no use actually.  Just specifying the type when
registering an encoder will be more flexible, like we did for
DemuxingIoHandler.  This issue will be taken care of here:

https://issues.apache.org/jira/browse/DIRMINA-439

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: getMessageTypes in MessageEncoder

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 11, 2007 10:59 PM, mat <fo...@gmail.com> wrote:
> Hi Trustin
>
> I read the source code(1.1.6)
> ProtocolEncoderImpl<http://mina.apache.org/report/1.1/xref/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.html>.
>
>
> 1)Set<Class<?>> messageTypes = encoder.getMessageTypes(); is used to get the
> message of concrete encoder class.
> 2)in encode method:
> Class<?> type = message.getClass();
> MessageEncoder<http://mina.apache.org/report/1.1/xref/org/apache/mina/filter/codec/demux/MessageEncoder.html>encoder
> = findEncoder(type); --How mina find out what encoder should be
> used, right?
>
> Therefore, if I have to register my concrete encoder class to TYPES and also
> implement
>  public Set<Class<?>> getMessageTypes() {
>   return TYPES;
>  }
>
> However in your previous answer, you said getMessageTypes in NO use? Which
> means in Mina2.0, it is NO use?

In MINA 2.0, you have to specify the type of the message that the
MessageEncoder will encode explicily as a parameter.  Therefore,
MessageEncoder.getMessageTypes() has been removed from MessageEncoder
interface.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: getMessageTypes in MessageEncoder

Posted by mat <fo...@gmail.com>.
Hi Trustin

I read the source code(1.1.6)
ProtocolEncoderImpl<http://mina.apache.org/report/1.1/xref/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.html>.


1)Set<Class<?>> messageTypes = encoder.getMessageTypes(); is used to get the
message of concrete encoder class.
2)in encode method:
Class<?> type = message.getClass();
MessageEncoder<http://mina.apache.org/report/1.1/xref/org/apache/mina/filter/codec/demux/MessageEncoder.html>encoder
= findEncoder(type); --How mina find out what encoder should be
used, right?

Therefore, if I have to register my concrete encoder class to TYPES and also
implement
 public Set<Class<?>> getMessageTypes() {
  return TYPES;
 }

However in your previous answer, you said getMessageTypes in NO use? Which
means in Mina2.0, it is NO use?

On Sep 28, 2007 10:51 PM, Trustin Lee <tr...@gmail.com> wrote:

> On 8/23/07, mat <fo...@gmail.com> wrote:
> > I wonder what is the usage of getMessageTypes in MessageEncoder?
>
> I think it's of no use actually.  Just specifying the type when
> registering an encoder will be more flexible, like we did for
> DemuxingIoHandler.  This issue will be taken care of here:
>
> https://issues.apache.org/jira/browse/DIRMINA-439
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>