Hi Frédéric Brégier,
On Dec 11, 2007 12:09 AM, Frédéric Brégier <[EMAIL PROTECTED]> wrote:
> Hi Trustin,
> Don't be sorry ! I completely understand the time this mailing
> list takes for you, and I really appreciate all the advices you give !!!
> I hope that you still have some night for you and your family...
Thanks for your understanding. I really appreciate it. :)
> Now back on the question :
> I understand better now the way it does with your answear.
> In my case, I probably can continue with only DemuxingIoHandler
> implements the global stuff since it is the same on every message
> (or almost, since I free some data specific to each message).
>
> I am not sure (I'm not such an expert) that splitting MessageHandler
> or making catch-all handler is better than now.
> For now, it was just a matter to know how to do it correctly,
> and your answear is just fine. Perhaps a short note in the API
> would be enough to be clear between those two ways.
I've made more change to MessageHandler and DemuxingIoHandler to fix
the API design issue you raised. Please take a look at the following
change log. The code will explain everything:
http://svn.apache.org/viewvc?view=rev&revision=603158
> Now next question (one answear sometimes brings another question)
> is that are you sure DemuxingIoHandler should throw an exception
> on messageSent when there is no messageHandler for it ?
> I look at the code in MINA, and it seems so.
> In my code, I have one particular message that the server will never
> receive but always anwear (written), so there is no messageHandler for it.
> As I overload the messageSent() function in my deumxingIoHandler,
> it never raised the exception since, if I am understanding clearly,
> mine overloading will never try to find the appropriate messageHandler
> (no call to handler.messageSent()).
You could simply register MessageHandler.NOOP to that type of message,
no? If you want to ignore all messageSent events, then you can even
do the following:
handler.addSentMessageHandler(MessageHandler.NOOP);
Especially with the change I've just made, I think all the concerns
you raised have been resolved. Please let me know if there's any case
that I missed out.
> If I am correct, in my case, it is therefore necessary to keep both ways
> as possible in MINA.
> Except perhaps I break the logic of Min by doing this ?
The possibility of overriding
DemuxingIoHandler.messageReceived/messageSent/exceptionCaught/findReceivedMessageHandler/findSentMessageHandler/findExceptionHandler
means that anyone who extends DemuxingIoHandler can break the existing
logic of DemuxingIoHandler. We could make all these methods final and
provide a kind of hook methods whose access modifier is 'protected'.
Assuming my recent change has resolved all the issues you raised, we
could do that. WDYT?
> Should I register those written only MessageHandler even if I never received
> one of them ?
> Perhaps it is related more to your question on splitting MessageHandler ?
> I don't like to make the API growing more and more, but you probably know
> better
> than me what it is better ot not in this case.
Yes, you have to register MessageHandler.NOOP at least to avoid an
exception. I think it's mandatory to prevent any mistake that a user
might forget to register a required handler.
> Perhaps my way (overloading DemuxingIoHandler, just an hypothesis)
> could be related to the other problem of 0 value for messages in statistics ?
No. It's not related. Let me respond in the other thread.
Cheers,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6