Frédéric Brégier wrote:
Hi Emmanuel,
I don't get your point.
We have some code in ADS which extends the DemuxingIoHandler, and this
is a PITA to change, because of the final methods. Le me explain why...
Version 2 gets MessageHandlers methods,
so noone should change the three methods you point in DemuxingIoHandler
or one could break the internal logic of the Demx.
well, the logic is pretty simple : you receive a message, pick the
correct handler depending on the message, and call the handler.
Subclassing this and calling the super method does the trick as well,
assuming that you*know* what you are doing, of course :)
In our case, following the current logic, we would have to change all
the message handlers when doing this on the demuxing layer would be more
generic. The logic we want to have is the following :
1) we receive a message
2) we have to add some information in this message, whatever type of
message we are dealing with
3) now we call the underlying demuxing layer, calling the
super.messageReceived() method
4) the message is propagated to the associated handler.
With those final methods, the problem is that we have to modify the 15
message handlers we have to deal with this generic modification we want
to do on the messages.
The two methods messageSent messageReceived are forwarding to
(MessageHandler) handler.handleMessage, and execeptionCaught is forwarding to
(ExeceptionHandler) handler.exceptionCaught.
So if you remove those "final" words, How could the user know that in
DemuxingIoHandler
he/she shouldn't change the internal logic ?
I _hope_ that the users are smart enough to avoid messing in this area.
If we have users who are defining their own protocol handlers, then they
should be aware of what is doing the demuxingIoHandler. I don't really
see how badly they can break the internal logic of this class, btw,
without having solething which will be totally broken :)
That's was the reason of the post 9 month ago and the fix.
Yeah, I read the post again lately. The problem i sthat the initial
convo was issued in november 2007, with a last mail saying that some
'final' keywords will be added, in conjonction with some hooks. And 2
months later, a commit was done without the hooks. So far, we didn't
realized that it could have been a problem, as we were still using
1.1.7, but those missing hooks are now a big burden for us.
So we have 4 options now :
- removing the final keywords (painless, and fast)
- adding the hooks, plus the logic in our code (pretty complex)
- duplicating the DemuxingIoHandler class in ADS (yerk...)
- or implementing the logic we have in out extended class into the 15
handlers we have (double yerk ... :/ )
Look, I have nothing against protecting MINA's user from doing bad
things, but here, it seems to me a little bit overkilling...
Does it make sense ?
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org