mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Q about the SessionCreated event
Date Tue, 04 Nov 2008 19:28:07 GMT
Hi,

I have a question regarding the way this event is handled in MINA. When 
you connect to a remote server, the client will call the 
NioSocketConnector, which will create a connection, then a Processor 
will be spawn, its add() method will be called, the session will be 
initialized (the chain is injected into it), and at the end, we will 
fire the CreateSessionEvent :

            // DefaultIoFilterChain.CONNECT_FUTURE is cleared inside here
            // in AbstractIoFilterChain.fireSessionOpened().
            ((AbstractIoService) 
session.getService()).getListeners().fireSessionCreated(session);

This will in return notify the waiting ConnectFuture object which is 
used by the client, when the event has been processed by the Tail filter.

So far, so good. Now, my question : why do we notify the future in the 
tail filter, instead of doing so when we come back from the filter ? I 
understand that we have to traverse the full chain in order to be sure 
that no exception is thrown, but I don't get why we can't simply wait 
for the return to notify.

What we have is :
fireEvent -> filter1.handle() -> filter2.handle() -> ... -> 
TailFilter.handle() -> notify(future)

why not :
try {
  fireEvent -> filter1.handle() -> filter2.handle() -> ... -> 
TailFilter.handle() (do nothing)
  notify(future)
} catch( error ) {
  handle exception
}

The problem I have with the first approach is that you _have_ to deal 
with this TailFilter, even if you don't need it, which means that the 
Handler must be distinct from a filter, _or_ that the last filter (if we 
consider that an handler should be a filter) _have to_ call the 
TailFilter handler for this event ?

Seems to me pretty complicated, by maybe it's just me...
wdyt ?

-- 
--
cordialement, regards,
Emmanuel L├ęcharny
www.iktek.com
directory.apache.org



Mime
View raw message