org.apache.ldap.server.interceptor
Class InterceptorChain

java.lang.Object
  extended byorg.apache.ldap.server.interceptor.InterceptorChain
All Implemented Interfaces:
Interceptor

public class InterceptorChain
extends java.lang.Object
implements Interceptor

Manages the chain of Interceptors. InterceptorChain is also an Interceptor, and thus you can create hiararchical interceptor structure to break down complex interceptors.

JndiProvider.invoke(Invocation) redirects Invocations to process(NextInterceptor, Invocation) and the chain starts.

Version:
$Rev: 159467 $, $Date: 2005-03-30 02:38:30 -0500 (Wed, 30 Mar 2005) $
Author:
Apache Directory Project

Field Summary
static java.lang.String NEXT_INTERCEPTOR
          The name of default interceptor that passes its control to the next interceptor in parent chain.
 
Constructor Summary
InterceptorChain()
          Create a new interceptor chain.
 
Method Summary
 void addAfter(java.lang.String baseName, java.lang.String name, Interceptor interceptor)
          Adds the specified interceptor with the specified name just after the interceptor whose name is baseName in this chain.
 void addBefore(java.lang.String baseName, java.lang.String name, Interceptor interceptor)
          Adds the specified interceptor with the specified name just before the interceptor whose name is baseName in this chain.
 void addFirst(java.lang.String name, Interceptor interceptor)
          Adds the specified interceptor with the specified name at the beginning of this chain.
 void addLast(java.lang.String name, Interceptor interceptor)
          Adds the specified interceptor with the specified name at the end of this chain.
 void clear()
          Removes all interceptors added to this chain.
 void destroy()
          Deinitializes all interceptors this chain contains.
 Interceptor get(java.lang.String name)
          Returns the interceptor with the specified name.
 java.util.List getAll()
          Returns the list of interceptors this chain in the order of evaluation.
 java.util.List getAllReversed()
          Returns the list of interceptors this chain in the reversed order of evaluation.
 void init(InterceptorContext ctx)
          Initializes all interceptors this chain contains.
static InterceptorChain newDefaultChain()
          Returns a new chain of default interceptors required to run core.
 void process(NextInterceptor nextInterceptor, Invocation invocation)
          Start invocation chain with the specified invocation.
 void remove(java.lang.String name)
          Removes the interceptor with the specified name from this chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEXT_INTERCEPTOR

public static final java.lang.String NEXT_INTERCEPTOR
The name of default interceptor that passes its control to the next interceptor in parent chain.

See Also:
Constant Field Values
Constructor Detail

InterceptorChain

public InterceptorChain()
Create a new interceptor chain.

Method Detail

newDefaultChain

public static InterceptorChain newDefaultChain()
Returns a new chain of default interceptors required to run core.


init

public void init(InterceptorContext ctx)
          throws javax.naming.NamingException
Initializes all interceptors this chain contains.

Specified by:
init in interface Interceptor
Parameters:
ctx - the configuration properties for this interceptor
Throws:
javax.naming.NamingException - if failed to initialize this interceptor

destroy

public void destroy()
Deinitializes all interceptors this chain contains.

Specified by:
destroy in interface Interceptor

get

public Interceptor get(java.lang.String name)
Returns the interceptor with the specified name.

Returns:
null if there is no interceptor with the specified name.

addFirst

public void addFirst(java.lang.String name,
                     Interceptor interceptor)
Adds the specified interceptor with the specified name at the beginning of this chain.


addLast

public void addLast(java.lang.String name,
                    Interceptor interceptor)
Adds the specified interceptor with the specified name at the end of this chain.


addBefore

public void addBefore(java.lang.String baseName,
                      java.lang.String name,
                      Interceptor interceptor)
Adds the specified interceptor with the specified name just before the interceptor whose name is baseName in this chain.


addAfter

public void addAfter(java.lang.String baseName,
                     java.lang.String name,
                     Interceptor interceptor)
Adds the specified interceptor with the specified name just after the interceptor whose name is baseName in this chain.


remove

public void remove(java.lang.String name)
Removes the interceptor with the specified name from this chain.


clear

public void clear()
Removes all interceptors added to this chain.


process

public void process(NextInterceptor nextInterceptor,
                    Invocation invocation)
             throws javax.naming.NamingException
Start invocation chain with the specified invocation.

Specified by:
process in interface Interceptor
Parameters:
nextInterceptor - the next interceptor in the interceptor chain
invocation - the invocation to process
Throws:
javax.naming.NamingException - if invocation failed

getAll

public java.util.List getAll()
Returns the list of interceptors this chain in the order of evaluation.


getAllReversed

public java.util.List getAllReversed()
Returns the list of interceptors this chain in the reversed order of evaluation.