directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Re: [mina] IoFilters: DIRMINA-121 / 122
Date Mon, 14 Nov 2005 21:26:21 GMT
Irving, Dave wrote:

>Hi Niklas,
>
>Thanks for your reply. I just wanted to make sure we were on the same
>wavelength before I started thrashing out code :o)
>
>I ** was ** thinking earlier that the only way we'd be able to get the
>required propagation (cleanly) would be to have a new "next handler" per
>chain traversal - so Im glad I didn't miss anything silly :o)
>Makes much more sense now.
>
>I think there's just one more thing to discuss / clear up about the
>approach.
>At first I was wondering why you wanted to pass the handler through at
>all (IoSession already has a "getHandler" method).
>However, this seemed to hint at the reason:
>
>  
>
>>The tail filter in a chain will always get the IoHandler from the
>>    
>>
>NextFilter and call it. 
>  
>
>>When combining IoFilterChains A and B, B is the IoHandler of A while
>>    
>>
>the real 
>  
>
>>IoHandler is the IoHandler of B.
>>    
>>
>
>Is the reason to enable a chain to masquerade as a handler, and have
>transparent chain "chaining" ?).
>  
>
Yes that's the reason. But I'm not sure exactly what happens when the
last filter of a filter chain has been executed and control should be
transferred to a new chain. The thing is that the code starting the
filtering through a chain also has to know what should happen after the
chain has completed and create/use the appropriate handler.

One possiblity would be to create chains of chains by wrapping them two
by two. Let's pretend we have this special IoFilterChain implementation
which takes two IoFilterChains (X, Y) and filters through them in order.
We can use this implementation to combine an arbitrary number of chains,
(((A, B), C), D). Oh, how I love recursion! :)

>If so, Im wondering if maybe there is a simpler way to "chain
>chains"....? (E.g, if we're jumping through hoops to chain them, maybe
>the "special" head and tail filters don't really belong in the chain
>(per se) at all...?
>  
>
The head and tail should not be needed anymore. The
Upstream/DownstreamNextFilters will know what to do when there are no
more filters.

>That way, you'd just have something like
>IoFilterChain#chain(IoFilterChain next). Any special meaning to the tail
>operations would be at a higher level. 
>(Again, clear in my head - but that doesn't mean anything :o)
>  
>
That doesn't make sense in my head! :) Though I am a bit sleepy at the
moment. Please elaborate.

/Niklas


Mime
View raw message