org.apache.ldap.server.interceptor
Interface Interceptor

All Known Implementing Classes:
AuthenticationService, BaseInterceptor, InterceptorChain

public interface Interceptor

Filters any directory operations. You can filter any Invocation performed on BackingStores just like Servlet filters do.

Interceptor Chaining

Interceptors should usually pass the control of current invocation to the next interceptor by calling NextInterceptor.process(Invocation). The flow control is returned when the next interceptor's process(NextInterceptor, Invocation) returns. You can therefore implement pre-, post-, around- invocation handler by how you place the statement.

Pre-invocation Filtering

 public void process( NextInterceptor nextInterceptor, Invocation invocation )
 {
     System.out.println( "Starting invocation." );
     nextInterceptor.process( invocation );
 }
 

Post-invocation Filtering

 public void process( NextInterceptor nextInterceptor, Invocation invocation )
 {
     nextInterceptor.process( invocation );
     System.out.println( "Invocation ended." );
 }
 

Around-invocation Filtering

 public void process( NextInterceptor nextInterceptor, Invocation invocation )
 {
     long startTime = System.currentTimeMillis();
     try
     {
         nextInterceptor.process( invocation );
     }
     finally
     {
         long endTime = System.currentTimeMillis();
         System.out.println( ( endTime - startTime ) + "ms elapsed." );
     }
 }
 

Interceptor Naming Convention

When you create an implementation of Interceptor, you have to follow the basic class naming convention to avoid others' confusion:

Plus, placing your interceptor implementations into relavent packages like interceptor or ones that reflect its purpose would be a good practice.

Overriding Default Interceptor Settings

See EnvKeys.INTERCEPTORS and InterceptorChain.newDefaultChain().

Version:
$Rev: 159316 $, $Date: 2005-03-28 17:20:10 -0500 (Mon, 28 Mar 2005) $
Author:
Apache Directory Project
See Also:
NextInterceptor

Method Summary
 void destroy()
          Deinitializes this interceptor.
 void init(InterceptorContext context)
          Intializes this interceptor.
 void process(NextInterceptor nextInterceptor, Invocation invocation)
          Filters a particular invocation.
 

Method Detail

init

public void init(InterceptorContext context)
          throws javax.naming.NamingException
Intializes this interceptor. This is invoked by directory service provider when this intercepter is loaded into interceptor chain.

Parameters:
context - the configuration properties for this interceptor
Throws:
javax.naming.NamingException - if failed to initialize this interceptor

destroy

public void destroy()
Deinitializes this interceptor. This is invoked by directory service provider when this intercepter is unloaded from interceptor chain.


process

public void process(NextInterceptor nextInterceptor,
                    Invocation invocation)
             throws javax.naming.NamingException
Filters a particular invocation. You can pass control to nextInterceptor by calling NextInterceptor.process( org.apache.ldap.server.invocation.Invocation)

Parameters:
nextInterceptor - the next interceptor in the interceptor chain
invocation - the invocation to process
Throws:
javax.naming.NamingException - on failures while handling the invocation


Copyright © 2002-2005 . All Rights Reserved.