directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu" <akaras...@apache.org>
Subject Re: Skipping interceptors
Date Thu, 26 Apr 2007 12:20:18 GMT
NP good luck.

On 4/26/07, Martin Alderson <Martin.Alderson@salfordsoftware.co.uk> wrote:
>
> Thanks Alex.
>
> I knew about the overloads in PartitionNexusProxy but for some reason
> had dismissed them (I think I was thinking down the wrong path when I
> first encountered them).  I ended up making the code more complex than
> it needed to be!  The important remaining bit of my code is the
> getBypassAndPreviousInterceptors for getting a list of interceptors to
> bypass to make the new invocation carry on the same as the current would
> do.
>
> Thanks again,
>
> Martin
>
>
> >>> "Alex Karasulu" <akarasulu@apache.org> 25/04/2007 19:32 >>>
> yep you got it .... just use bypass instructions.  All methods into
> the
> interceptor chain have overload for taking a list of interceptors to
> bypass
> during IC processing.
>
> Alex
>
> On 4/25/07, Martin Alderson <Martin.Alderson@salfordsoftware.co.uk>
> wrote:
> >
> >
> > Ah, I think I've got it.
> >
> > For anyone interested (not yet tested!):
> >
> > /////
> >     private DirectoryServiceConfiguration factoryCfg; // from init()
> >     private InterceptorConfiguration cfg; // from init()
> >
> > //....
> >
> >     private Collection getBypassAndPreviousInterceptors
> > (Collection<String> interceptors) {
> >         Invocation invocation =
> InvocationStack.getInstance().peek();
> >
> >         boolean found = false;
> >
> >         List interceptorConfigurations =
> > factoryCfg.getStartupConfiguration().getInterceptorConfigurations();
> >         for (Iterator i = interceptorConfigurations.iterator();
> > i.hasNext(); ) {
> >             InterceptorConfiguration configuration =
> > (InterceptorConfiguration) i.next();
> >             String name = configuration.getName();
> >             if (!found || invocation.isBypassed(name)) {
> >                 // Previous interceptor or interceptor to bypass.
> >                 interceptors.add(name);
> >             }
> >             if (configuration.equals(cfg)) {
> >                 found = true;
> >             }
> >         }
> >
> >         return interceptors;
> >     }
> >
> >     /**
> >      * @return A new Invocation that starts where this interceptor
> left
> > off.
> >      */
> >     private Invocation newContinuationInvocation (Collection
> > bypassInterceptors) {
> >         Invocation invocation =
> InvocationStack.getInstance().peek();
> >         Collection bypass =
> > getBypassAndPreviousInterceptors(bypassInterceptors);
> >         return new Invocation(invocation.getProxy(),
> > invocation.getCaller(), invocation.getName(),
> > invocation.getParameters().toArray(), bypass);
> >     }
> > /////
> >
> > Now I can just do something like:
> >
> >     public boolean hasEntry (NextInterceptor next, LdapDN name)
> throws
> > NamingException {
> >         if (condition) {
> >             Collection<String> c = new HashSet<String>();
> >             c.add( "eventService" );  // Interceptor to skip.
> >             InvocationStack stack = InvocationStack.getInstance();
> >             stack.push(newContinuationInvocation(c));
> >             try {
> >                 return factoryCfg.getInterceptorChain().hasEntry(
> name
> > );
> >             } finally {
> >                 stack.pop();
> >             }
> >         } else {
> >             return next.hasEntry(name);
> >         }
> >     }
> >
> >
> > Martin
> >
> >
>

Mime
View raw message