directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r159017 - in directory/apacheds/trunk/core: ./ src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/ src/test/org/apache/ldap/server/jndi/invocation/interceptor/
Date Fri, 25 Mar 2005 14:07:45 GMT
Author: trustin
Date: Fri Mar 25 06:07:43 2005
New Revision: 159017

URL: http://svn.apache.org/viewcvs?view=rev&rev=159017
Log:
InterceptorChain is now able to emulate 'around' pointcut.

Modified:
    directory/apacheds/trunk/core/build.ajproperties
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java

Modified: directory/apacheds/trunk/core/build.ajproperties
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/build.ajproperties?view=diff&r1=159016&r2=159017
==============================================================================
--- directory/apacheds/trunk/core/build.ajproperties (original)
+++ directory/apacheds/trunk/core/build.ajproperties Fri Mar 25 06:07:43 2005
@@ -1,4 +1,4 @@
-src.includes = src/main/java/,\
-               src/test/,\
-               target/schema/,\
-               src/main/aspects/
+src.includes = src/main/java/,\
+               target/schema/,\
+               src/main/aspects/,\
+               src/test/

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java?view=diff&r1=159016&r2=159017
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java
Fri Mar 25 06:07:43 2005
@@ -17,6 +17,14 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
 
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+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.exception.LdapNoPermissionException;
 import org.apache.ldap.common.name.DnParser;
 import org.apache.ldap.server.BackingStore;
@@ -24,18 +32,20 @@
 import org.apache.ldap.server.db.ResultFilteringEnumeration;
 import org.apache.ldap.server.db.SearchResultFilter;
 import org.apache.ldap.server.jndi.ServerContext;
-import org.apache.ldap.server.jndi.invocation.*;
+import org.apache.ldap.server.jndi.invocation.Delete;
+import org.apache.ldap.server.jndi.invocation.HasEntry;
+import org.apache.ldap.server.jndi.invocation.Invocation;
+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.schema.AttributeTypeRegistry;
 import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer;
-
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
 
 
 /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java?view=diff&r1=159016&r2=159017
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java
Fri Mar 25 06:07:43 2005
@@ -17,11 +17,18 @@
 package org.apache.ldap.server.jndi.invocation.interceptor;
 
 
-import org.apache.ldap.server.jndi.Authenticator;
-import org.apache.ldap.server.jndi.invocation.Invocation;
+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 java.util.*;
+
+import org.apache.ldap.server.jndi.Authenticator;
+import org.apache.ldap.server.jndi.invocation.Invocation;
 
 
 /**
@@ -39,16 +46,10 @@
 public class InterceptorChain implements Interceptor
 {
     /**
-     * 'Preprocess chain' passes the invocation to the next interceptor
-     * of the parent chain after processing children.
-     */
-    public static final ChainType PREPROCESS = new ChainType();
-
-    /**
-     * 'Postprocess chain' passes the invocation to the next interceptor
-     * of the parent chain before processing children.
+     * The name of default interceptor that passes its control to the
+     * next interceptor in parent chain.
      */
-    public static final ChainType POSTPROCESS = new ChainType();
+    public static final String NEXT_INTERCEPTOR = "nextInterceptor";
 
 
     /**
@@ -56,24 +57,35 @@
      */
     public static InterceptorChain newDefaultChain()
     {
-        return newDefaultChain( PREPROCESS );
+        InterceptorChain chain = new InterceptorChain();
+        chain.addBefore( NEXT_INTERCEPTOR, "authenticator", new Authenticator() );
+        chain.addBefore( NEXT_INTERCEPTOR, "authorizer", new Authorizer() );
+        chain.addBefore( NEXT_INTERCEPTOR, "validator", new Validator() );
+        chain.addBefore( NEXT_INTERCEPTOR, "schemaManager", new SchemaManager() );
+        chain.addBefore( NEXT_INTERCEPTOR, "operationalAttributeInterceptor", new OperationalAttributeInterceptor()
);
+        return chain;
     }
 
-
-    /**
-     * Returns a new chain of default interceptors required to run core.
-     */
-    public static InterceptorChain newDefaultChain( ChainType type )
+    private final Interceptor NEXT_INTERCEPTOR0 = new Interceptor()
     {
-        InterceptorChain chain = new InterceptorChain( type );
-        chain.addLast( "authenticator", new Authenticator() );
-        chain.addLast( "authorizer", new Authorizer() );
-        chain.addLast( "validator", new Validator() );
-        chain.addLast( "schemaManager", new SchemaManager() );
-        chain.addLast( "operationalAttributeInterceptor", new OperationalAttributeInterceptor()
);
-        return chain;
-    }
+        public void init( InterceptorContext context ) throws NamingException
+        {
+        }
 
+        public void destroy()
+        {
+        }
+
+        public void process( NextInterceptor nextInterceptor, Invocation invocation ) throws
NamingException
+        {
+            if( parent != null )
+            {
+                Entry e = ( Entry ) parent.interceptor2entry.get( InterceptorChain.this );
+                e.nextInterceptor.process( invocation );
+            }
+            nextInterceptor.process( invocation );
+        }
+    };
 
     private final Interceptor FINAL_INTERCEPTOR = new Interceptor()
     {
@@ -106,40 +118,25 @@
 
     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 Entry head = new Entry( null, null, NEXT_INTERCEPTOR, NEXT_INTERCEPTOR0 );
 
-    private final Entry tail = head;
+    private final Entry tail = new Entry( null, null, "end", FINAL_INTERCEPTOR );
 
 
     /**
-     * Create a new interceptor chain whose type is {@link #PREPROCESS}.
+     * Create a new interceptor chain.
      */
     public InterceptorChain()
     {
-        this( PREPROCESS );
+        head.nextEntry = tail;
+        tail.prevEntry = head;
+        register( NEXT_INTERCEPTOR, head );
     }
 
-
-    /**
-     * Creates a new interceptor chain with the specified chain type.
-     */
-    public InterceptorChain( ChainType type )
-    {
-        if ( type == null )
-        {
-            throw new NullPointerException( "type" );
-        }
-
-        this.type = type;
-    }
-
-
     /**
      * Initializes all interceptors this chain contains.
      */
@@ -290,11 +287,13 @@
         Entry newEntry = new Entry( prevEntry, baseEntry, name, interceptor );
         if ( prevEntry == null )
         {
+            baseEntry.prevEntry = newEntry;
             head = newEntry;
+            
         }
         else
         {
-            prevEntry.nextEntry.prevEntry = newEntry;
+            baseEntry.prevEntry = newEntry;
             prevEntry.nextEntry = newEntry;
         }
 
@@ -427,23 +426,7 @@
         Entry head = this.head;
         try
         {
-            if ( type == PREPROCESS )
-            {
-                head.interceptor.process( head.nextInterceptor, invocation );
-                if ( nextInterceptor != null )
-                {
-                    nextInterceptor.process( invocation );
-                }
-            }
-            else // POSTPROCESS
-            {
-                if ( nextInterceptor != null )
-                {
-                    nextInterceptor.process( invocation );
-                }
-                head.interceptor.process( head.nextInterceptor, invocation );
-            }
-
+            head.interceptor.process( head.nextInterceptor, invocation );
         }
         catch ( NamingException ne )
         {
@@ -546,16 +529,6 @@
                     }
                 }
             };
-        }
-    }
-
-    /**
-     * Represents how {@link InterceptorChain} interacts with {@link NextInterceptor}.
-     */
-    public static class ChainType
-    {
-        private ChainType()
-        {
         }
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java?view=diff&r1=159016&r2=159017
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/invocation/interceptor/NextInterceptor.java
Fri Mar 25 06:07:43 2005
@@ -35,8 +35,8 @@
     /**
      * Passes the control of current invocation to the next {@link Interceptor} in the {@link
InterceptorChain}.
      *
-     * @param call
+     * @param incovation
      * @throws NamingException
      */
-    void process( Invocation call ) throws NamingException;
+    void process( Invocation incovation ) throws NamingException;
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java?view=diff&r1=159016&r2=159017
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/invocation/interceptor/ConfigurationTest.java
Fri Mar 25 06:07:43 2005
@@ -33,7 +33,7 @@
     {
         rootChain.addLast( "A", interceptorA );
         rootChain.addLast( "child", childChain );
-        childChain.addLast( "B", interceptorB );
+        childChain.addBefore( InterceptorChain.NEXT_INTERCEPTOR, "B", interceptorB );
         rootChain.addLast( "default", InterceptorChain.newDefaultChain() );
 
         extras.put( EnvKeys.INTERCEPTORS, rootChain );



Mime
View raw message