geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gianny DAMOUR" <gianny_dam...@hotmail.com>
Subject Re: Proposal: Change the way interceptors are stacked
Date Mon, 24 Nov 2003 10:36:16 GMT
Jeremy Boynes wrote:
>Currently the interceptor stack is built from the front backwards using the 
>addInterceptor method on the container.
>
>I would like to propose we change to build the stack in the opposite order, 
>from the back forward.
Is it possible to have a bi-directional implementation?

The current Interceptor implementation uses a Decorator approach, where each 
Interceptor invokes itself the next one.

Another strategy is the one defined by the servlet specifications 2.3: the 
general idea is to add two new components, namely an "Interceptor Manager" 
and an "Ordered list of Interceptors".

In such an implementation the "Interceptor Manager", InterceptorManager, 
manages the "Ordered list of Interceptors", InterceptorChain,  and each 
Interceptor invokes InterceptorChain instead of invoking directly the next 
Interceptor.

At the end of the day, for a stack of two Interceptors, iter1 and iter2, the 
flow is:
InterceptorChain -> iter1 -> InterceptorChain -> iter2 -> InterceptorChain

I think that such an implementation is sometime more powerful: it allows to 
have rather simply the number of Interceptors, to add/remove at any given 
position an Interceptor. For instance, to add a new Interceptor right in the 
middle of two other ones, one could request to InterceptorManager to insert 
a "Latch Interceptor" as the head of the InterceptorChain. This "Latch 
Interceptor" simply blocks the incoming invocations the time required to 
insert the new Interceptor. When this is done, InterceptorManager removes 
the "Latch Interceptor" and releases the latch.

Cheers,
Gianny

_________________________________________________________________
Trouvez l'âme soeur sur MSN Rencontres http://g.msn.fr/FR1000/9551


Mime
View raw message