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" <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
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
>
>