You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Michael Bauroth <mi...@falcom.de> on 2006/08/14 07:47:18 UTC

Extending from DemuxingIoHandler

Hi,

I want to implement some special behaviour in an own IoHandler derived 
from DemuxingIoHandler. Unfortunately the findHandler methods are 
implemented as private methods, so that I must implement the whole stuff 
again :(
Would it be possible, that Mina gives us the opportunity to simple 
override the messageReceived method while using the original findHandler 
methods as protected? In an object oriented context it should make more 
sense than implementing a copy of this methods in the derived classes again.
WDYT?

Best Regards
Michael

Re: Extending from DemuxingIoHandler

Posted by Trustin Lee <tr...@gmail.com>.
On 8/22/06, Michael Bauroth <mi...@falcom.de> wrote:
> Hi,
>
> since there are a few weeks gone since my question, I don't remember the
> complete idea behind at the moment. :)
> For the rest I wrote a workaround, but may be a modified
> DemuxingIoHandler would be the better option to avoid additional
> exception throws. Don't know ... WDYT?

So you want to override findHandler(Class) method and provide default
MessageHandler, right?  That's reasonable.  I've just made
findHandler(Class) to be protected:

http://issues.apache.org/jira/browse/DIRMINA-330

Thanks for a good idea!

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: Extending from DemuxingIoHandler

Posted by Michael Bauroth <mi...@falcom.de>.
Hi,

since there are a few weeks gone since my question, I don't remember the 
complete idea behind at the moment. :)
For the rest I wrote a workaround, but may be a modified 
DemuxingIoHandler would be the better option to avoid additional 
exception throws. Don't know ... WDYT?

I have implemented a nested 2-stage protocol with many different codecs, 
messages and message handlers. In some cases it can be, that incoming 
messages aren't identified as a special message but instead only as a 
simple key-value-pair or anything else. For such "unknown" messages I 
haven't registered a separate handler in my TcpSessionHandler, but want 
to try handle it also ...

My current solution looks like this:

public void messageReceived( IoSession pSession, Object pMsg )
throws Exception
{
   try
   {
     super.messageReceived( pSession, pMsg );
   }
   catch ( UnknownMessageTypeException e )
   {
     if ( mDefaultHandler != null )
     {
       mDefaultHandler.messageReceived( pSession, pMsg );
     }
     else
     {
       mLogger.error( "Unknown message type received: ", e );
     }
   }
}

Best Regards
Michael



Trustin Lee wrote:

> Could you tell me 'the special behavior' you are going to implement?
> 
> Thanks in advance,
> Trustin
> 
> On 8/14/06, Michael Bauroth <mi...@falcom.de> wrote:
> 
>>
>> Hi,
>>
>> I want to implement some special behaviour in an own IoHandler derived
>> from DemuxingIoHandler. Unfortunately the findHandler methods are
>> implemented as private methods, so that I must implement the whole stuff
>> again :(
>> Would it be possible, that Mina gives us the opportunity to simple
>> override the messageReceived method while using the original findHandler
>> methods as protected? In an object oriented context it should make more
>> sense than implementing a copy of this methods in the derived classes
>> again.
>> WDYT?
>>
>> Best Regards
>> Michael
>>
> 
> 
> 


Re: Extending from DemuxingIoHandler

Posted by Trustin Lee <tr...@gmail.com>.
Could you tell me 'the special behavior' you are going to implement?

Thanks in advance,
Trustin

On 8/14/06, Michael Bauroth <mi...@falcom.de> wrote:
>
> Hi,
>
> I want to implement some special behaviour in an own IoHandler derived
> from DemuxingIoHandler. Unfortunately the findHandler methods are
> implemented as private methods, so that I must implement the whole stuff
> again :(
> Would it be possible, that Mina gives us the opportunity to simple
> override the messageReceived method while using the original findHandler
> methods as protected? In an object oriented context it should make more
> sense than implementing a copy of this methods in the derived classes
> again.
> WDYT?
>
> Best Regards
> Michael
>



-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: Extending from DemuxingIoHandler

Posted by peter royal <pr...@apache.org>.
On Aug 14, 2006, at 1:47 AM, Michael Bauroth wrote:
> I want to implement some special behaviour in an own IoHandler  
> derived from DemuxingIoHandler. Unfortunately the findHandler  
> methods are implemented as private methods, so that I must  
> implement the whole stuff again :(
> Would it be possible, that Mina gives us the opportunity to simple  
> override the messageReceived method while using the original  
> findHandler methods as protected? In an object oriented context it  
> should make more sense than implementing a copy of this methods in  
> the derived classes again.
> WDYT?

Sounds reasonable. Want to post a patch in JIRA with how you'd like  
it changed? Thanks!
-pete


-- 
proyal@apache.org - http://fotap.org/~osi