directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r158735 [2/2] - in directory/apacheds/branches/interceptor_revamp/core/src: main/java/org/apache/ldap/server/jndi/invocation/ main/java/org/apache/ldap/server/jndi/invocation/interceptor/ test/org/apache/ldap/server/jndi/invocation/interceptor/
Date Wed, 23 Mar 2005 06:11:12 GMT
Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java Tue Mar 22 22:11:07 2005
@@ -16,30 +16,24 @@
  */
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import javax.naming.NamingException;
 
 import org.apache.ldap.server.jndi.Authenticator;
 import org.apache.ldap.server.jndi.invocation.Invocation;
 
+import javax.naming.NamingException;
+import java.util.*;
+
+
 /**
- * Manages the chain of {@link Interceptor}s.  <tt>InterceptorChain</tt> is
- * also an {@link Interceptor}, and thus you can create hiararchical interceptor
- * structure to break down complex interceptors.
- * <p>
+ * Manages the chain of {@link Interceptor}s.  <tt>InterceptorChain</tt>
+ * is also an {@link Interceptor}, and thus you can create hiararchical
+ * interceptor structure to break down complex interceptors.
+ * <p/>
  * {@link org.apache.ldap.server.jndi.JndiProvider#invoke(Invocation)}
- * redirects {@link Invocation}s to {@link #process(Invocation)} and
- * the chain starts.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @author Trustin Lee (trustin@apache.org)
+ * redirects {@link Invocation}s to {@link#process(Invocation)} and the
+ * chain starts.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class InterceptorChain implements Interceptor
@@ -55,7 +49,8 @@
      * of the parent chain before processing children.
      */
     public static final ChainType POSTPROCESS = new ChainType();
-    
+
+
     /**
      * Returns a new chain of default interceptors required to run core.
      */
@@ -63,7 +58,8 @@
     {
         return newDefaultChain( PREPROCESS );
     }
-    
+
+
     /**
      * Returns a new chain of default interceptors required to run core.
      */
@@ -77,25 +73,29 @@
         chain.addLast( "operationalAttributeInterceptor", new OperationalAttributeInterceptor() );
         return chain;
     }
-    
+
+
     private final Interceptor FINAL_INTERCEPTOR = new Interceptor()
     {
         private InterceptorContext ctx;
-        
-        public void init(InterceptorContext context) throws NamingException
+
+
+        public void init( InterceptorContext context )
         {
             ctx = context;
         }
 
+
         public void destroy()
         {
             // unused
         }
 
-        public void process(NextInterceptor nextInterceptor, Invocation call)
+
+        public void process( NextInterceptor nextInterceptor, Invocation call )
                 throws NamingException
         {
-            if( parent == null )
+            if ( parent == null )
             {
                 // execute the actual backend operation only when this chain
                 // is root.
@@ -105,12 +105,18 @@
     };
 
     private InterceptorChain parent;
+
     private final ChainType type;
+
     private final Map name2entry = new HashMap();
+
     private final Map interceptor2entry = new IdentityHashMap();
+
     private Entry head = new Entry( null, null, "end", FINAL_INTERCEPTOR );
+
     private final Entry tail = head;
 
+
     /**
      * Create a new interceptor chain whose type is {@link #PREPROCESS}.
      */
@@ -118,20 +124,22 @@
     {
         this( PREPROCESS );
     }
-    
+
+
     /**
      * Creates a new interceptor chain with the specified chain type.
      */
     public InterceptorChain( ChainType type )
     {
-        if( type == null )
+        if ( type == null )
         {
             throw new NullPointerException( "type" );
         }
 
         this.type = type;
     }
-    
+
+
     /**
      * Initializes all interceptors this chain contains.
      */
@@ -141,120 +149,119 @@
         Interceptor interceptor = null;
         try
         {
-            while( it.hasNext() )
+            while ( it.hasNext() )
             {
                 interceptor = ( Interceptor ) it.next();
                 String name = getName( interceptor );
-                InterceptorContext newCtx = new InterceptorContext(
-                        ctx.getEnvironment(), ctx.getSystemPartition(),
+                InterceptorContext newCtx = new InterceptorContext( ctx.getEnvironment(), ctx.getSystemPartition(),
                         ctx.getGlobalRegistries(), ctx.getRootNexus(),
-                        InterceptorConfigBuilder.build(
-                                ctx.getConfig(), ( name == null ) ? "" : name ) );
-                
+                        InterceptorConfigBuilder.build( ctx.getConfig(), ( name == null ) ? "" : name ) );
+
                 interceptor.init( newCtx );
             }
         }
-        catch( Throwable t )
+        catch ( Throwable t )
         {
-            while( it.hasPrevious() )
+            while ( it.hasPrevious() )
             {
                 Interceptor i = ( Interceptor ) it.previous();
                 try
                 {
                     i.destroy();
                 }
-                catch( Throwable t2 )
+                catch ( Throwable t2 )
                 {
                     t2.printStackTrace();
                 }
             }
-            
-            if( t instanceof NamingException )
+
+            if ( t instanceof NamingException )
             {
                 throw ( NamingException ) t;
             }
             else
             {
-                throw new InterceptorException( 
-                        interceptor, null,
+                throw new InterceptorException( interceptor, null,
                         "Failed to initialize interceptor chain.", t );
             }
         }
     }
-    
+
+
     /**
      * Deinitializes all interceptors this chain contains.
      */
     public synchronized void destroy()
     {
         ListIterator it = getAllReversed().listIterator();
-        while( it.hasNext() )
+        while ( it.hasNext() )
         {
             Interceptor interceptor = ( Interceptor ) it.next();
             try
             {
                 interceptor.destroy();
             }
-            catch( Throwable t )
+            catch ( Throwable t )
             {
                 t.printStackTrace();
             }
         }
     }
 
+
     /**
      * Returns the interceptor with the specified <code>name</code>.
-     * 
-     * @return <code>null</code> if there is no interceptor with the specified
-     *         <code>name</code>.
+     *
+     * @return <code>null</code> if there is no interceptor with the specified <code>name</code>.
      */
     public Interceptor get( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
-        if( e == null )
+        if ( e == null )
         {
             return null;
         }
         return e.interceptor;
     }
-    
+
+
     private String getName( Interceptor interceptor )
     {
         Entry e = ( Entry ) interceptor2entry.get( interceptor );
-        if( e == null )
+        if ( e == null )
         {
             return null;
         }
         return e.name;
     }
-    
+
+
     /**
-     * Adds the specified interceptor with the specified name at the beginning
-     * of this chain.
+     * Adds the specified interceptor with the specified name at the beginning of this chain.
      */
     public synchronized void addFirst( String name,
                                        Interceptor interceptor )
     {
         checkAddable( name, interceptor );
-        
+
         Entry newEntry = new Entry( null, head, name, interceptor );
         head.prevEntry = newEntry;
         head = newEntry;
 
-        register(name, newEntry);
+        register( name, newEntry );
     }
 
+
     /**
-     * Adds the specified interceptor with the specified name at the end
-     * of this chain.
+     * Adds the specified interceptor with the specified name at the end of this chain.
      */
     public synchronized void addLast( String name,
                                       Interceptor interceptor )
     {
         checkAddable( name, interceptor );
-        
+
         Entry newEntry = new Entry( tail.prevEntry, tail, name, interceptor );
-        if( tail.prevEntry != null )
+        if ( tail.prevEntry != null )
         {
             tail.prevEntry.nextEntry = newEntry;
         }
@@ -263,13 +270,14 @@
             head = newEntry;
         }
         tail.prevEntry = newEntry;
-        
-        register(name, newEntry);
+
+        register( name, newEntry );
     }
 
+
     /**
-     * Adds the specified interceptor with the specified name just before
-     * the interceptor whose name is <code>baseName</code> in this chain.
+     * Adds the specified interceptor with the specified name just before the interceptor whose name is
+     * <code>baseName</code> in this chain.
      */
     public synchronized void addBefore( String baseName,
                                         String name,
@@ -280,7 +288,7 @@
 
         Entry prevEntry = baseEntry.prevEntry;
         Entry newEntry = new Entry( prevEntry, baseEntry, name, interceptor );
-        if( prevEntry == null )
+        if ( prevEntry == null )
         {
             head = newEntry;
         }
@@ -289,13 +297,14 @@
             prevEntry.nextEntry.prevEntry = newEntry;
             prevEntry.nextEntry = newEntry;
         }
-        
-        register(name, newEntry);
+
+        register( name, newEntry );
     }
-    
+
+
     /**
-     * Adds the specified interceptor with the specified name just after
-     * the interceptor whose name is <code>baseName</code> in this chain.
+     * Adds the specified interceptor with the specified name just after the interceptor whose name is
+     * <code>baseName</code> in this chain.
      */
     public synchronized void addAfter( String baseName,
                                        String name,
@@ -306,16 +315,17 @@
 
         Entry nextEntry = baseEntry.nextEntry;
         Entry newEntry = new Entry( baseEntry, nextEntry, name, interceptor );
-        if( nextEntry == null )
+        if ( nextEntry == null )
         {
             throw new IllegalStateException();
         }
 
         nextEntry.prevEntry.nextEntry = newEntry;
         nextEntry.prevEntry = newEntry;
-        register(name, newEntry);
+        register( name, newEntry );
     }
-    
+
+
     /**
      * Removes the interceptor with the specified name from this chain.
      */
@@ -324,7 +334,7 @@
         Entry entry = checkOldName( name );
         Entry prevEntry = entry.prevEntry;
         Entry nextEntry = entry.nextEntry;
-        if( prevEntry == null )
+        if ( prevEntry == null )
         {
             nextEntry.prevEntry = null;
             head = entry;
@@ -338,76 +348,78 @@
         name2entry.remove( name );
         Interceptor interceptor = entry.interceptor;
         interceptor2entry.remove( interceptor );
-        if( interceptor instanceof InterceptorChain )
+        if ( interceptor instanceof InterceptorChain )
         {
             ( ( InterceptorChain ) interceptor ).parent = null;
         }
     }
 
+
     /**
      * Removes all interceptors added to this chain.
      */
     public synchronized void clear()
     {
         Iterator it = new ArrayList( name2entry.keySet() ).iterator();
-        while( it.hasNext() )
+        while ( it.hasNext() )
         {
             this.remove( ( String ) it.next() );
         }
     }
 
-    private void register(String name, Entry newEntry) {
+
+    private void register( String name, Entry newEntry )
+    {
         Interceptor interceptor = newEntry.interceptor;
         name2entry.put( name, newEntry );
         interceptor2entry.put( newEntry.interceptor, newEntry );
-        if( interceptor instanceof InterceptorChain )
+        if ( interceptor instanceof InterceptorChain )
         {
             ( ( InterceptorChain ) interceptor ).parent = this;
         }
     }
 
-	/**
-	 * Throws an exception when the specified interceptor name is not registered
-	 * in this chain.
-	 * 
-	 * @return An interceptor entry with the specified name.
-	 */
+
+    /**
+     * Throws an exception when the specified interceptor name is not registered in this chain.
+     *
+     * @return An interceptor entry with the specified name.
+     */
     private Entry checkOldName( String baseName )
     {
         Entry e = ( Entry ) name2entry.get( baseName );
-        if( e == null )
+        if ( e == null )
         {
             throw new IllegalArgumentException( "Unknown interceptor name:" +
-                                                baseName );
+                    baseName );
         }
         return e;
     }
 
-	/**
-	 * Checks the specified interceptor name is already taken and throws
-	 * an exception if already taken.
-	 */
+
+    /**
+     * Checks the specified interceptor name is already taken and throws an exception if already taken.
+     */
     private void checkAddable( String name, Interceptor interceptor )
     {
-        if( name2entry.containsKey( name ) )
+        if ( name2entry.containsKey( name ) )
         {
-            throw new IllegalArgumentException(
-                    "Other interceptor is using name '" + name + "'" );
+            throw new IllegalArgumentException( "Other interceptor is using name '" + name + "'" );
         }
-        
-        if( interceptor instanceof InterceptorChain )
+
+        if ( interceptor instanceof InterceptorChain )
         {
             if ( ( ( InterceptorChain ) interceptor ).parent != null )
             {
-                throw new IllegalArgumentException(
-                        "This interceptor chain has its parent already." );
+                throw new IllegalArgumentException( "This interceptor chain has its parent already." );
             }
         }
     }
-    
+
+
     /**
      * Start invocation chain with the specified invocation.
-     * 
+     *
      * @throws NamingException if invocation failed
      */
     public void process( NextInterceptor nextInterceptor, Invocation invocation ) throws NamingException
@@ -415,38 +427,38 @@
         Entry head = this.head;
         try
         {
-            if( type == PREPROCESS )
+            if ( type == PREPROCESS )
             {
                 head.interceptor.process( head.nextInterceptor, invocation );
-                if( nextInterceptor != null )
+                if ( nextInterceptor != null )
                 {
                     nextInterceptor.process( invocation );
                 }
             }
             else // POSTPROCESS
             {
-                if( nextInterceptor != null )
+                if ( nextInterceptor != null )
                 {
                     nextInterceptor.process( invocation );
                 }
                 head.interceptor.process( head.nextInterceptor, invocation );
             }
-            
+
         }
-        catch( NamingException ne )
+        catch ( NamingException ne )
         {
             throw ne;
         }
-        catch( Throwable e )
+        catch ( Throwable e )
         {
             throw new InterceptorException( head.interceptor, invocation,
-                                            "Unexpected exception.", e );
+                    "Unexpected exception.", e );
         }
     }
 
+
     /**
-     * Returns the list of interceptors this chain in the order of
-     * evaluation.
+     * Returns the list of interceptors this chain in the order of evaluation.
      */
     public List getAll()
     {
@@ -457,14 +469,14 @@
             list.add( e.interceptor );
             e = e.nextEntry;
         }
-        while( e != null );
+        while ( e != null );
 
         return list;
     }
 
+
     /**
-     * Returns the list of interceptors this chain in the reversed
-     * order of evaluation.
+     * Returns the list of interceptors this chain in the reversed order of evaluation.
      */
     public List getAllReversed()
     {
@@ -475,30 +487,36 @@
             list.add( e.interceptor );
             e = e.prevEntry;
         }
-        while( e != null );
+        while ( e != null );
 
         return list;
     }
 
-	/**
-	 * Represents an internal entry of this chain.
-	 */
+
+    /**
+     * Represents an internal entry of this chain.
+     */
     private class Entry
     {
         private Entry prevEntry;
+
         private Entry nextEntry;
+
         private final String name;
+
         private final Interceptor interceptor;
+
         private final NextInterceptor nextInterceptor;
 
+
         private Entry( Entry prevEntry, Entry nextEntry,
                        String name, Interceptor interceptor )
         {
-            if( interceptor == null )
+            if ( interceptor == null )
             {
                 throw new NullPointerException( "interceptor" );
             }
-            if( name == null )
+            if ( name == null )
             {
                 throw new NullPointerException( "name" );
             }
@@ -509,31 +527,30 @@
             this.interceptor = interceptor;
             this.nextInterceptor = new NextInterceptor()
             {
-                public void process(Invocation call)
-                        throws NamingException {
+                public void process( Invocation call )
+                        throws NamingException
+                {
                     Interceptor interceptor = Entry.this.nextEntry.interceptor;
                     try
                     {
-                        interceptor.process(
-                                Entry.this.nextEntry.nextInterceptor, call );
+                        interceptor.process( Entry.this.nextEntry.nextInterceptor, call );
                     }
-                    catch( NamingException ne )
+                    catch ( NamingException ne )
                     {
                         throw ne;
                     }
-                    catch( Throwable e )
+                    catch ( Throwable e )
                     {
                         throw new InterceptorException( interceptor, call,
-                                                             "Unexpected exception.", e );
+                                "Unexpected exception.", e );
                     }
                 }
             };
         }
     }
-    
+
     /**
-     * Represents how {@link InterceptorChain} interacts with
-     * {@link NextInterceptor}.
+     * Represents how {@link InterceptorChain} interacts with {@link NextInterceptor}.
      */
     public static class ChainType
     {

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorConfigBuilder.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorConfigBuilder.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorConfigBuilder.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorConfigBuilder.java Tue Mar 22 22:11:07 2005
@@ -1,38 +1,48 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-public class InterceptorConfigBuilder {
 
-    public static Map build(Map map, String prefix)
+/**
+ * @todo doc me
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+
+public class InterceptorConfigBuilder
+{
+
+    public static Map build( Map map, String prefix )
     {
         Map newMap = new HashMap();
         Iterator it = map.entrySet().iterator();
-        while( it.hasNext() )
+        while ( it.hasNext() )
         {
-            Map.Entry e = (Map.Entry) it.next();
+            Map.Entry e = ( Map.Entry ) it.next();
             String key = e.getKey().toString();
-            if( key.startsWith( prefix ) && key.length() > prefix.length() )
+            if ( key.startsWith( prefix ) && key.length() > prefix.length() )
             {
                 key = key.substring( prefix.length() );
-                if( key.indexOf( '#' ) < 0 )
+                if ( key.indexOf( '#' ) < 0 )
                 {
                     continue;
                 }
-                if( key.charAt(0) == '.' || key.charAt(0) == '#' )
+                if ( key.charAt( 0 ) == '.' || key.charAt( 0 ) == '#' )
                 {
                     key = key.substring( 1 );
                 }
-                
+
                 newMap.put( key, e.getValue() );
             }
         }
-        
+
         return newMap;
     }
-    
+
+
     private InterceptorConfigBuilder()
     {
     }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java Tue Mar 22 22:11:07 2005
@@ -1,28 +1,47 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
-import java.util.Map;
 
 import org.apache.ldap.server.RootNexus;
 import org.apache.ldap.server.SystemPartition;
 import org.apache.ldap.server.schema.GlobalRegistries;
 
-public class InterceptorContext {
+import java.util.Map;
+
 
-    /** the initial context environment that fired up the backend subsystem */
+/**
+ * @todo doc me
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InterceptorContext
+{
+
+    /**
+     * the initial context environment that fired up the backend subsystem
+     */
     private final Map environment;
-    
-    /** Configuration for the interceptor. */
+
+    /**
+     * Configuration for the interceptor.
+     */
     private final Map config;
 
-    /** the system partition used by the context factory */
+    /**
+     * the system partition used by the context factory
+     */
     private final SystemPartition systemPartition;
 
-    /** the registries for system schema objects */
+    /**
+     * the registries for system schema objects
+     */
     private final GlobalRegistries globalRegistries;
 
-    /** the root nexus */
+    /**
+     * the root nexus
+     */
     private final RootNexus rootNexus;
 
+
     public InterceptorContext( Map environment,
                                SystemPartition systemPartition,
                                GlobalRegistries globalRegistries,
@@ -36,26 +55,33 @@
         this.config = config;
     }
 
-    public Map getEnvironment() {
+
+    public Map getEnvironment()
+    {
         return environment;
     }
-    
-    public Map getConfig() {
+
+
+    public Map getConfig()
+    {
         return config;
     }
-    
 
-    public GlobalRegistries getGlobalRegistries() {
+
+    public GlobalRegistries getGlobalRegistries()
+    {
         return globalRegistries;
     }
-    
 
-    public RootNexus getRootNexus() {
+
+    public RootNexus getRootNexus()
+    {
         return rootNexus;
     }
-    
 
-    public SystemPartition getSystemPartition() {
+
+    public SystemPartition getSystemPartition()
+    {
         return systemPartition;
     }
 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorException.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorException.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorException.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorException.java Tue Mar 22 22:11:07 2005
@@ -24,21 +24,23 @@
 
 
 /**
- * A {@link LdapNamingException} that wraps uncaught runtime exceptions
- * thrown from {@link Interceptor}s.
+ * A {@link LdapNamingException} that wraps uncaught runtime exceptions thrown from {@link Interceptor}s.
  *
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @author Alex Karasulu (akarasulu@apache.org)
- * @author Trustin Lee (trustin@apache.org)
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class InterceptorException extends LdapNamingException
 {
     private static final long serialVersionUID = 3258690996517746233L;
 
-    /** The Invocation the Interceptor failed on */
+    /**
+     * The Invocation the Interceptor failed on
+     */
     private final Invocation invocation;
-    /** The Interceptor causing the failure */
+
+    /**
+     * The Interceptor causing the failure
+     */
     private final Interceptor interceptor;
 
 
@@ -46,7 +48,7 @@
      * Creates an InterceptorException without a message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @param invocation the Invocation the Interceptor failed on
+     * @param invocation  the Invocation the Interceptor failed on
      */
     public InterceptorException( Interceptor interceptor, Invocation invocation )
     {
@@ -60,11 +62,11 @@
      * Creates an InterceptorException with a custom message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @param invocation the Invocation the Interceptor failed on
+     * @param invocation  the Invocation the Interceptor failed on
      * @param explanation String explanation of why the Interceptor failed
      */
     public InterceptorException( Interceptor interceptor,
-                                      Invocation invocation, String explanation )
+                                 Invocation invocation, String explanation )
     {
         super( explanation, ResultCodeEnum.OTHER );
         this.invocation = invocation;
@@ -76,33 +78,35 @@
      * Creates an InterceptorException without a message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @param invocation the Invocation the Interceptor failed on
-     * @param rootCause the root cause of this exception
+     * @param invocation  the Invocation the Interceptor failed on
+     * @param rootCause   the root cause of this exception
      */
     public InterceptorException( Interceptor interceptor,
-                                      Invocation invocation, Throwable rootCause )
+                                 Invocation invocation, Throwable rootCause )
     {
         this( interceptor, invocation );
         super.setRootCause( rootCause );
     }
 
+
     /**
      * Creates an InterceptorException without a message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @param invocation the Invocation the Interceptor failed on
+     * @param invocation  the Invocation the Interceptor failed on
      * @param explanation String explanation of why the Interceptor failed
-     * @param rootCause the root cause of this exception
+     * @param rootCause   the root cause of this exception
      */
     public InterceptorException( Interceptor interceptor,
-                                      Invocation invocation,
-                                      String explanation,
-                                      Throwable rootCause )
+                                 Invocation invocation,
+                                 String explanation,
+                                 Throwable rootCause )
     {
         this( interceptor, invocation, explanation );
         super.setRootCause( rootCause );
     }
 
+
     /**
      * Gets the invovation object this exception is associated with.
      *
@@ -126,8 +130,7 @@
 
 
     /**
-     * Will return the resultCode of the root cause if the root cause
-     * implements LdapException.
+     * Will return the resultCode of the root cause if the root cause implements LdapException.
      *
      * @see org.apache.ldap.common.exception.LdapException#getResultCode()
      */

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java Tue Mar 22 22:11:07 2005
@@ -16,25 +16,25 @@
  */
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
-import javax.naming.NamingException;
 
 import org.apache.ldap.server.jndi.invocation.Invocation;
 
+import javax.naming.NamingException;
+
+
 /**
  * Represents the next {@link Interceptor} in the interceptor chain.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @author Trustin Lee (trustin@apache.org)
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
- * 
  * @see Interceptor
  * @see InterceptorChain
  */
-public interface NextInterceptor {
+public interface NextInterceptor
+{
     /**
-     * Passes the control of current invocation to the next
-     * {@link Interceptor} in the {@link InterceptorChain}.
-     * 
+     * Passes the control of current invocation to the next {@link Interceptor} in the {@link InterceptorChain}.
+     *
      * @param call
      * @throws NamingException
      */

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/OperationalAttributeInterceptor.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/OperationalAttributeInterceptor.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/OperationalAttributeInterceptor.java Tue Mar 22 22:11:07 2005
@@ -17,56 +17,41 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
 
-import java.util.HashSet;
-
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
-
 import org.apache.ldap.common.schema.AttributeType;
 import org.apache.ldap.common.schema.UsageEnum;
 import org.apache.ldap.common.util.DateUtils;
 import org.apache.ldap.server.RootNexus;
 import org.apache.ldap.server.db.ResultFilteringEnumeration;
 import org.apache.ldap.server.db.SearchResultFilter;
-import org.apache.ldap.server.jndi.invocation.Add;
-import org.apache.ldap.server.jndi.invocation.List;
-import org.apache.ldap.server.jndi.invocation.Lookup;
-import org.apache.ldap.server.jndi.invocation.LookupWithAttrIds;
-import org.apache.ldap.server.jndi.invocation.Modify;
-import org.apache.ldap.server.jndi.invocation.ModifyMany;
-import org.apache.ldap.server.jndi.invocation.ModifyRN;
-import org.apache.ldap.server.jndi.invocation.Move;
-import org.apache.ldap.server.jndi.invocation.MoveAndModifyRN;
-import org.apache.ldap.server.jndi.invocation.Search;
+import org.apache.ldap.server.jndi.invocation.*;
 import org.apache.ldap.server.schema.AttributeTypeRegistry;
 
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.*;
+import javax.naming.ldap.LdapContext;
+import java.util.HashSet;
+
 
 /**
- * An {@link Interceptor} that adds or modifies the default attributes of entries.
- * There are four default attributes for now;<code>'creatorsName'</code>,
- * <code>'createTimestamp'</code>, <code>'modifiersName'</code>, and
+ * An {@link Interceptor} that adds or modifies the default attributes
+ * of entries. There are four default attributes for now;<code>'creatorsName'
+ * </code>, <code>'createTimestamp'</code>, <code>'modifiersName'</code>, and
  * <code>'modifyTimestamp'</code>.
  *
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @author Alex Karasulu (akarasulu@apache.org)
- * @author Trustin Lee (trustin@apache.org)
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class OperationalAttributeInterceptor extends BaseInterceptor
 {
-    /** the database search result filter to register with filter service */
+    /**
+     * the database search result filter to register with filter service
+     */
     private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
     {
         public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls )
-            throws NamingException
+                throws NamingException
         {
             if ( controls.getReturningAttributes() == null )
             {
@@ -77,8 +62,11 @@
         }
     };
 
-    /** the root nexus of the system */
+    /**
+     * the root nexus of the system
+     */
     private RootNexus nexus;
+
     private AttributeTypeRegistry registry;
 
 
@@ -89,14 +77,19 @@
     {
     }
 
-    public void init( InterceptorContext ctx ) throws NamingException {
+
+    public void init( InterceptorContext ctx ) throws NamingException
+    {
         nexus = ctx.getRootNexus();
         registry = ctx.getGlobalRegistries().getAttributeTypeRegistry();
     }
 
-    public void destroy() {
+
+    public void destroy()
+    {
     }
 
+
     /**
      * Adds extra operational attributes to the entry before it is added.
      *
@@ -114,7 +107,7 @@
         attribute = new BasicAttribute( "createTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         entry.put( attribute );
-        
+
         nextInterceptor.process( call );
     }
 
@@ -210,18 +203,21 @@
     }
 
 
-    protected void process(NextInterceptor nextInterceptor, Lookup call) throws NamingException {
+    protected void process( NextInterceptor nextInterceptor, Lookup call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
+
         Attributes attributes = ( Attributes ) call.getResponse();
         Attributes retval = ( Attributes ) attributes.clone();
         filter( retval );
         call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, LookupWithAttrIds call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
+
         Attributes attributes = ( Attributes ) call.getResponse();
         if ( attributes == null )
         {
@@ -233,10 +229,12 @@
         call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, List call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
-        NamingEnumeration e ;
+
+        NamingEnumeration e;
         ResultFilteringEnumeration retval;
         LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
         e = ( NamingEnumeration ) call.getResponse();
@@ -244,16 +242,18 @@
         call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, Search call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
+
         SearchControls searchControls = call.getControls();
         if ( searchControls.getReturningAttributes() != null )
         {
             return;
         }
 
-        NamingEnumeration e ;
+        NamingEnumeration e;
         ResultFilteringEnumeration retval;
         LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
         e = ( NamingEnumeration ) call.getResponse();
@@ -261,9 +261,10 @@
         call.setResponse( retval );
     }
 
+
     /**
-     * Filters out the operational attributes within a search results
-     * attributes.  The attributes are directly modified.
+     * Filters out the operational attributes within a search results attributes.  The attributes are directly
+     * modified.
      *
      * @param attributes the resultant attributes to filter
      * @return true always
@@ -291,8 +292,9 @@
         return true;
     }
 
+
     private void filter( Name dn, Attributes entry, String[] ids )
-        throws NamingException
+            throws NamingException
     {
         // still need to protect against returning op attrs when ids is null
         if ( ids == null )
@@ -300,23 +302,23 @@
             OperationalAttributeInterceptor.this.filter( entry );
             return;
         }
-        
+
         if ( dn.size() == 0 )
         {
             HashSet idsSet = new HashSet( ids.length );
-            
+
             for ( int ii = 0; ii < ids.length; ii++ )
             {
                 idsSet.add( ids[ii].toLowerCase() );
             }
 
             NamingEnumeration list = entry.getIDs();
-            
+
             while ( list.hasMore() )
             {
                 String attrId = ( ( String ) list.nextElement() ).toLowerCase();
-                
-                if ( ! idsSet.contains( attrId ) )
+
+                if ( !idsSet.contains( attrId ) )
                 {
                     entry.remove( attrId );
                 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/SchemaManager.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/SchemaManager.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/SchemaManager.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/SchemaManager.java Tue Mar 22 22:11:07 2005
@@ -17,34 +17,13 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
-
 import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.filter.PresenceNode;
 import org.apache.ldap.common.filter.SimpleNode;
 import org.apache.ldap.common.message.LockableAttributeImpl;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.common.schema.AttributeType;
-import org.apache.ldap.common.schema.DITContentRule;
-import org.apache.ldap.common.schema.DITStructureRule;
-import org.apache.ldap.common.schema.MatchingRule;
-import org.apache.ldap.common.schema.MatchingRuleUse;
-import org.apache.ldap.common.schema.NameForm;
-import org.apache.ldap.common.schema.ObjectClass;
-import org.apache.ldap.common.schema.SchemaUtils;
-import org.apache.ldap.common.schema.Syntax;
+import org.apache.ldap.common.schema.*;
 import org.apache.ldap.common.util.SingletonEnumeration;
 import org.apache.ldap.server.RootNexus;
 import org.apache.ldap.server.db.ResultFilteringEnumeration;
@@ -57,35 +36,57 @@
 import org.apache.ldap.server.schema.AttributeTypeRegistry;
 import org.apache.ldap.server.schema.GlobalRegistries;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
 
 /**
  * An {@link Interceptor} that manages and enforces schemas.
- * TODO Better interceptor description required.
  *
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @author Alex Karasulu (akarasulu@apache.org)
- * @author Trustin Lee (trustin@apache.org)
+ * @todo Better interceptor description required.
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class SchemaManager extends BaseInterceptor
 {
     private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
 
-    /** the root nexus to all database partitions */
+    /**
+     * the root nexus to all database partitions
+     */
     private RootNexus nexus;
-    /** a binary attribute tranforming filter: String -> byte[] */
+
+    /**
+     * a binary attribute tranforming filter: String -> byte[]
+     */
     private BinaryAttributeFilter binaryAttributeFilter;
-    /** the global schema object registries */
+
+    /**
+     * the global schema object registries
+     */
     private GlobalRegistries globalRegistries;
+
     private AttributeTypeRegistry attributeRegistry;
-    /** subschemaSubentry attribute's value from Root DSE */
+
+    /**
+     * subschemaSubentry attribute's value from Root DSE
+     */
     private String subentryDn;
 
 
     /**
      * Creates a schema service interceptor.
      *
-     * @param nexus the root nexus to access all database partitions
+     * @param nexus            the root nexus to access all database partitions
      * @param globalRegistries the global schema object registries
      * @param filterService
      */
@@ -93,6 +94,7 @@
     {
     }
 
+
     public void init( InterceptorContext ctx ) throws NamingException
     {
         this.nexus = ctx.getRootNexus();
@@ -104,15 +106,18 @@
         String subschemaSubentry = ( String ) nexus.getRootDSE().get( "subschemaSubentry" ).get();
         subentryDn = new LdapName( subschemaSubentry ).toString().toLowerCase();
     }
-    
+
+
     public void destroy()
     {
     }
 
-    protected void process(NextInterceptor nextInterceptor, List call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
-        NamingEnumeration e ;
+
+        NamingEnumeration e;
         ResultFilteringEnumeration retval;
         LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
         e = ( NamingEnumeration ) call.getResponse();
@@ -120,10 +125,11 @@
         call.setResponse( retval );
     }
 
+
     protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
     {
         // check to make sure the DN searched for is a subentry
-        if ( ! subentryDn.equals( call.getBaseName().toString() ) )
+        if ( !subentryDn.equals( call.getBaseName().toString() ) )
         {
             nextInterceptor.process( call );
             return;
@@ -133,14 +139,14 @@
         SearchControls searchControls = call.getControls();
         ExprNode filter = call.getFilter();
         if ( searchControls.getSearchScope() == SearchControls.OBJECT_SCOPE &&
-             filter instanceof SimpleNode )
+                filter instanceof SimpleNode )
         {
             SimpleNode node = ( SimpleNode ) filter;
 
             if ( node.getAttribute().equalsIgnoreCase( "objectClass" ) &&
-                 node.getValue().equalsIgnoreCase( "subschema" ) &&
-                 node.getAssertionType() == SimpleNode.EQUALITY
-               )
+                    node.getValue().equalsIgnoreCase( "subschema" ) &&
+                    node.getAssertionType() == SimpleNode.EQUALITY
+            )
             {
                 // call.setBypass( true );
                 Attributes attrs = getSubschemaEntry( searchControls.getReturningAttributes() );
@@ -151,7 +157,7 @@
             }
         }
         else if ( searchControls.getSearchScope() == SearchControls.OBJECT_SCOPE &&
-                 filter instanceof PresenceNode )
+                filter instanceof PresenceNode )
         {
             PresenceNode node = ( PresenceNode ) filter;
 
@@ -166,17 +172,17 @@
             }
         }
 
-        if( !bypass )
+        if ( !bypass )
         {
             nextInterceptor.process( call );
         }
-        
+
         if ( searchControls.getReturningAttributes() != null )
         {
             return;
         }
 
-        NamingEnumeration e ;
+        NamingEnumeration e;
         ResultFilteringEnumeration retval;
         LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
         e = ( NamingEnumeration ) call.getResponse();
@@ -310,9 +316,11 @@
         return attrs;
     }
 
-    protected void process(NextInterceptor nextInterceptor, Lookup call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, Lookup call ) throws NamingException
+    {
         nextInterceptor.process( call );
-        
+
         ServerLdapContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
         Attributes attributes = ( Attributes ) call.getResponse();
         Attributes retval = ( Attributes ) attributes.clone();
@@ -320,7 +328,9 @@
         call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, LookupWithAttrIds call) throws NamingException {
+
+    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
+    {
         nextInterceptor.process( call );
 
         ServerLdapContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
@@ -335,15 +345,16 @@
         call.setResponse( retval );
     }
 
+
     private void doFilter( LdapContext ctx, Attributes entry )
-        throws NamingException
+            throws NamingException
     {
         // set of AttributeType objects that are to behave as binaries
         Set binaries;
         
         // construct the set for fast lookups while filtering
         String binaryIds = ( String ) ctx.getEnvironment().get( BINARY_KEY );
-        
+
         if ( binaryIds == null )
         {
             binaries = Collections.EMPTY_SET;
@@ -351,13 +362,13 @@
         else
         {
             String[] binaryArray = binaryIds.split( " " );
-            
+
             binaries = new HashSet( binaryArray.length );
-            
+
             for ( int ii = 0; ii < binaryArray.length; ii++ )
             {
                 AttributeType type = attributeRegistry.lookup( binaryArray[ii] );
-                
+
                 binaries.add( type );
             }
         }
@@ -367,37 +378,37 @@
          * human readable and those that are in the binaries set
          */
         NamingEnumeration list = entry.getIDs();
-        
+
         while ( list.hasMore() )
         {
             String id = ( String ) list.next();
-            
+
             AttributeType type = null;
-            
+
             boolean asBinary = false;
-            
+
             if ( attributeRegistry.hasAttributeType( id ) )
             {
                 type = attributeRegistry.lookup( id );
             }
-            
+
             if ( type != null )
             {
-                asBinary = ! type.getSyntax().isHumanReadible();
-                
+                asBinary = !type.getSyntax().isHumanReadible();
+
                 asBinary = asBinary || binaries.contains( type );
             }
-            
+
             if ( asBinary )
             {
                 Attribute attribute = entry.get( id );
-                
+
                 Attribute binary = new LockableAttributeImpl( id );
-                
+
                 for ( int ii = 0; ii < attribute.size(); ii++ )
                 {
                     Object value = attribute.get( ii );
-                    
+
                     if ( value instanceof String )
                     {
                         binary.add( ii, ( ( String ) value ).getBytes() );
@@ -407,29 +418,29 @@
                         binary.add( ii, value );
                     }
                 }
-                
+
                 entry.remove( id );
-                
+
                 entry.put( binary );
             }
         }
     }
 
+
     /**
-     * A special filter over entry attributes which replaces Attribute String
-     * values with their respective byte[] representations using schema
-     * information and the value held in the JNDI environment property:
+     * A special filter over entry attributes which replaces Attribute String values with their respective byte[]
+     * representations using schema information and the value held in the JNDI environment property:
      * <code>java.naming.ldap.attributes.binary</code>.
      *
-     * @see <a href=
-     * "http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap-gl.html#binary">
-     * java.naming.ldap.attributes.binary</a>
+     * @see <a href= "http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap-gl.html#binary">
+     *      java.naming.ldap.attributes.binary</a>
      */
     private class BinaryAttributeFilter implements SearchResultFilter
     {
-        public BinaryAttributeFilter( )
+        public BinaryAttributeFilter()
         {
         }
+
 
         public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls ) throws NamingException
         {

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Validator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Validator.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Validator.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Validator.java Tue Mar 22 22:11:07 2005
@@ -17,12 +17,6 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
 
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
 import org.apache.ldap.common.exception.LdapContextNotEmptyException;
 import org.apache.ldap.common.exception.LdapNameAlreadyBoundException;
 import org.apache.ldap.common.exception.LdapNameNotFoundException;
@@ -31,32 +25,29 @@
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.server.BackingStore;
 import org.apache.ldap.server.RootNexus;
-import org.apache.ldap.server.jndi.invocation.Add;
-import org.apache.ldap.server.jndi.invocation.Delete;
-import org.apache.ldap.server.jndi.invocation.List;
-import org.apache.ldap.server.jndi.invocation.Lookup;
-import org.apache.ldap.server.jndi.invocation.LookupWithAttrIds;
-import org.apache.ldap.server.jndi.invocation.Modify;
-import org.apache.ldap.server.jndi.invocation.ModifyMany;
-import org.apache.ldap.server.jndi.invocation.ModifyRN;
-import org.apache.ldap.server.jndi.invocation.Move;
-import org.apache.ldap.server.jndi.invocation.MoveAndModifyRN;
-import org.apache.ldap.server.jndi.invocation.Search;
+import org.apache.ldap.server.jndi.invocation.*;
+
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
 
 
 /**
- * An {@link Interceptor} that detects any operations that breaks
- * integrity of {@link BackingStore} and terminates the current
- * invocation chain by throwing a {@link NamingException}.
- * Those operations include when an entry already exists at a DN and is
- * added once again to the same DN.
+ * An {@link Interceptor} that detects any operations that breaks integrity
+ * of {@link BackingStore} and terminates the current invocation chain by
+ * throwing a {@link NamingException}. Those operations include when an entry
+ * already exists at a DN and is added once again to the same DN.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
 public class Validator extends BaseInterceptor
 {
-    /** the root nexus of the system */
+    /**
+     * the root nexus of the system
+     */
     private RootNexus nexus;
 
 
@@ -66,20 +57,22 @@
     public Validator()
     {
     }
-    
+
+
     public void init( InterceptorContext ctx )
     {
         this.nexus = ctx.getRootNexus();
     }
 
+
     public void destroy()
     {
     }
 
+
     /**
-     * In the pre-invocation state this interceptor method checks to see if
-     * the entry to be added already exists.  If it does an exception is
-     * raised.
+     * In the pre-invocation state this interceptor method checks to see if the entry to be added already exists.  If it
+     * does an exception is raised.
      *
      * @see BaseInterceptor#add(String, Name, Attributes)
      */
@@ -113,13 +106,14 @@
             e.setResolvedName( parentDn );
             throw e;
         }
-        
+
         nextInterceptor.process( call );
     }
 
+
     /**
-     * Checks to make sure the entry being deleted exists, and has no children,
-     * otherwise throws the appropriate LdapException.
+     * Checks to make sure the entry being deleted exists, and has no children, otherwise throws the appropriate
+     * LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, Delete call ) throws NamingException
     {
@@ -144,28 +138,26 @@
             e.setResolvedName( name );
             throw e;
         }
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the base being searched exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
     {
         // check if entry to search exists
         String msg = "Attempt to search under non-existant entry: ";
         assertHasEntry( msg, call.getBaseName() );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to make sure the entry being looked up exists other wise throws
-     * the appropriate LdapException.
+     * Checks to make sure the entry being looked up exists other wise throws the appropriate LdapException.
      *
      * @see org.apache.ldap.server.jndi.BaseInterceptor#lookup(javax.naming.Name)
      */
@@ -173,56 +165,52 @@
     {
         String msg = "Attempt to lookup non-existant entry: ";
         assertHasEntry( msg, call.getName() );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the base being searched exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
     {
         // check if entry to lookup exists
         String msg = "Attempt to lookup non-existant entry: ";
         assertHasEntry( msg, call.getName() );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being modified exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the entry being modified exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, Modify call ) throws NamingException
     {
         // check if entry to modify exists
         String msg = "Attempt to modify non-existant entry: ";
         assertHasEntry( msg, call.getName() );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being modified exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the entry being modified exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, ModifyMany call ) throws NamingException
     {
         // check if entry to modify exists
         String msg = "Attempt to modify non-existant entry: ";
         assertHasEntry( msg, call.getName() );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being renamed exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the entry being renamed exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, ModifyRN call ) throws NamingException
     {
@@ -239,18 +227,18 @@
         {
             LdapNameAlreadyBoundException e = null;
             e = new LdapNameAlreadyBoundException( "target entry " + target
-                + " already exists!" );
+                    + " already exists!" );
             e.setResolvedName( target );
             throw e;
         }
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being moved exists, and so does its parent,
-     * otherwise throws the appropriate LdapException.
+     * Checks to see the entry being moved exists, and so does its parent, otherwise throws the appropriate
+     * LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, Move call ) throws NamingException
     {
@@ -270,18 +258,18 @@
         {
             LdapNameAlreadyBoundException e = null;
             e = new LdapNameAlreadyBoundException( "target entry " + target
-                + " already exists!" );
+                    + " already exists!" );
             e.setResolvedName( target );
             throw e;
         }
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being moved exists, and so does its parent,
-     * otherwise throws the appropriate LdapException.
+     * Checks to see the entry being moved exists, and so does its parent, otherwise throws the appropriate
+     * LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) throws NamingException
     {
@@ -300,18 +288,17 @@
         {
             LdapNameAlreadyBoundException e = null;
             e = new LdapNameAlreadyBoundException( "target entry " + target
-                + " already exists!" );
+                    + " already exists!" );
             e.setResolvedName( target );
             throw e;
         }
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Checks to see the entry being searched exists, otherwise throws the
-     * appropriate LdapException.
+     * Checks to see the entry being searched exists, otherwise throws the appropriate LdapException.
      */
     protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
     {
@@ -323,33 +310,32 @@
             nextInterceptor.process( call );
             return;
         }
-        
+
         Attribute attr = nexus.getRootDSE().get( "subschemaSubentry" );
         if ( ( ( String ) attr.get() ).equalsIgnoreCase( base.toString() ) )
         {
             nextInterceptor.process( call );
             return;
-        }  
+        }
 
         assertHasEntry( msg, base );
-        
+
         nextInterceptor.process( call );
     }
 
 
     /**
-     * Asserts that an entry is present and as a side effect if it is not,
-     * creates a LdapNameNotFoundException, which is used to set the before
-     * exception on the invocation - eventually the exception is thrown.
+     * Asserts that an entry is present and as a side effect if it is not, creates a LdapNameNotFoundException, which is
+     * used to set the before exception on the invocation - eventually the exception is thrown.
      *
-     * @param msg the message to prefix to the distinguished name for explanation
-     * @param dn the distinguished name of the entry that is asserted
+     * @param msg        the message to prefix to the distinguished name for explanation
+     * @param dn         the distinguished name of the entry that is asserted
      * @param invocation the invocation object to alter if the entry does not exist
      * @throws NamingException if the entry does not exist
      */
     private void assertHasEntry( String msg, Name dn ) throws NamingException
     {
-        if ( ! nexus.hasEntry( dn ) )
+        if ( !nexus.hasEntry( dn ) )
         {
             LdapNameNotFoundException e = null;
 

Modified: directory/apacheds/branches/interceptor_revamp/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java?view=diff&r1=158734&r2=158735
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java Tue Mar 22 22:11:07 2005
@@ -1,30 +1,41 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.NamingException;
 
 import junit.framework.Assert;
-
 import org.apache.ldap.server.AbstractServerTest;
 import org.apache.ldap.server.jndi.EnvKeys;
 import org.apache.ldap.server.jndi.invocation.Invocation;
 
-public class ConfigurationTest extends AbstractServerTest {
-    
+import javax.naming.NamingException;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Test case for interceptor configurations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConfigurationTest extends AbstractServerTest
+{
+
     private TestInterceptorChain rootChain = new TestInterceptorChain();
+
     private TestInterceptorChain childChain = new TestInterceptorChain();
+
     private TestInterceptor interceptorA = new TestInterceptor();
+
     private TestInterceptor interceptorB = new TestInterceptor();
-    
+
+
     protected void setUp() throws Exception
     {
         rootChain.addLast( "A", interceptorA );
         rootChain.addLast( "child", childChain );
         childChain.addLast( "B", interceptorB );
         rootChain.addLast( "default", InterceptorChain.newDefaultChain() );
-        
+
         extras.put( EnvKeys.INTERCEPTORS, rootChain );
         extras.put( EnvKeys.INTERCEPTORS + "#root", "1" );
         extras.put( EnvKeys.INTERCEPTORS + ".A", "2" );
@@ -34,10 +45,11 @@
         extras.put( EnvKeys.INTERCEPTORS + ".child.B", "6" );
         extras.put( EnvKeys.INTERCEPTORS + ".child.B#B", "7" );
         extras.put( EnvKeys.INTERCEPTORS + ".child.B#B.B", "8" );
-        
+
         super.setUp();
     }
-    
+
+
     public void testRootChain() throws Exception
     {
         Map expected = new HashMap();
@@ -50,6 +62,7 @@
         Assert.assertEquals( expected, rootChain.config );
     }
 
+
     public void testChildChain() throws Exception
     {
         Map expected = new HashMap();
@@ -58,7 +71,8 @@
         expected.put( "B#B.B", "8" );
         Assert.assertEquals( expected, childChain.config );
     }
-    
+
+
     public void testA() throws Exception
     {
         Map expected = new HashMap();
@@ -67,6 +81,7 @@
         Assert.assertEquals( expected, interceptorA.config );
     }
 
+
     public void testB() throws Exception
     {
         Map expected = new HashMap();
@@ -74,32 +89,41 @@
         expected.put( "B.B", "8" );
         Assert.assertEquals( expected, interceptorB.config );
     }
-    
+
+
     private static class TestInterceptorChain extends InterceptorChain
     {
         private Map config;
-        
-        public synchronized void init(InterceptorContext ctx) throws NamingException {
+
+
+        public synchronized void init( InterceptorContext ctx ) throws NamingException
+        {
             config = ctx.getConfig();
-            super.init(ctx);
+            super.init( ctx );
         }
-        
+
     }
 
     private static class TestInterceptor implements Interceptor
     {
         private Map config;
 
-        public void init(InterceptorContext context) throws NamingException {
+
+        public void init( InterceptorContext context ) throws NamingException
+        {
             config = context.getConfig();
         }
 
-        public void destroy() {
+
+        public void destroy()
+        {
         }
 
-        public void process(NextInterceptor nextInterceptor, Invocation invocation) throws NamingException {
+
+        public void process( NextInterceptor nextInterceptor, Invocation invocation ) throws NamingException
+        {
             nextInterceptor.process( invocation );
         }
     }
-    
+
 }



Mime
View raw message