You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/06/24 05:08:39 UTC

svn commit: r201550 [3/5] - in /directory/apacheds/trunk/core: ./ src/main/aspects/ src/main/java/org/apache/ldap/server/ src/main/java/org/apache/ldap/server/authn/ src/main/java/org/apache/ldap/server/authz/ src/main/java/org/apache/ldap/server/confi...

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java Thu Jun 23 20:08:31 2005
@@ -19,22 +19,28 @@
 
 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.ConfigurationException;
+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 org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.server.configuration.InterceptorConfiguration;
-import org.apache.ldap.server.invocation.Invocation;
+import org.apache.ldap.server.configuration.MutableInterceptorConfiguration;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
 
 
 /**
- * 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.
+ * Manages the chain of {@link Interceptor}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -43,12 +49,11 @@
 {
     private final Interceptor FINAL_INTERCEPTOR = new Interceptor()
     {
-        private InterceptorContext ctx;
+        private ContextPartitionNexus nexus;
 
-
-        public void init( InterceptorContext context )
+        public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg )
         {
-            ctx = context;
+            this.nexus = factoryCfg.getPartitionNexus();
         }
 
 
@@ -58,258 +63,270 @@
         }
 
 
-        public void process( NextInterceptor nextInterceptor, Invocation call ) throws NamingException
+        public Attributes getRootDSE( NextInterceptor next ) throws NamingException
         {
-            if ( parent == null )
-            {
-                // execute the actual backend operation only when this chain is root.
+            return nexus.getRootDSE();
+        }
 
-                call.execute( ctx.getRootNexus() );
-            }
+
+        public Name getMatchedName( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
+        {
+            return ( Name ) nexus.getMatchedName( dn, normalized ).clone();
         }
-    };
 
-    private InterceptorChain parent;
 
-    private final Map name2entry = new HashMap();
+        public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
+        {
+            return ( Name ) nexus.getSuffix( dn, normalized ).clone();
+        }
 
-    private final Map interceptor2entry = new IdentityHashMap();
 
-    private final Entry tail = new Entry( null, null, "end", FINAL_INTERCEPTOR );
+        public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
+        {
+            return nexus.listSuffixes( normalized );
+        }
 
-    private Entry head = tail;
 
+        public void delete( NextInterceptor next, Name name ) throws NamingException
+        {
+            nexus.delete( name );
+        }
 
-    /**
-     * Create a new interceptor chain.
-     */
-    public InterceptorChain()
-    {
-        this( new ArrayList() );
-    }
-    
-    /**
-     * Creates a new interceptor chain 
-     * @param configurations
-     */
-    public InterceptorChain( List configurations )
-    {
-        Iterator it = configurations.iterator();
-        while( it.hasNext() )
+
+        public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
         {
-            InterceptorConfiguration cfg = ( InterceptorConfiguration ) it.next();
-            this.addLast( cfg.getName(), cfg.getInterceptor() );
+            nexus.add( upName, normName, entry );
         }
-    }
 
 
-    /**
-     * Initializes all interceptors this chain contains.
-     */
-    public synchronized void init( InterceptorContext ctx ) throws NamingException
-    {
-        ListIterator it = getAll().listIterator();
+        public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
+        {
+            nexus.modify( name, modOp, mods );
+        }
 
-        Interceptor interceptor = null;
 
-        try
+        public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
         {
-            while ( it.hasNext() )
-            {
-                interceptor = ( Interceptor ) it.next();
-                interceptor.init( ctx );
-            }
+            nexus.modify( name, mods );
         }
-        catch ( Throwable t )
+
+
+        public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
         {
-            while ( it.hasPrevious() )
-            {
-                Interceptor i = ( Interceptor ) it.previous();
+            return nexus.list( base );
+        }
 
-                try
-                {
-                    i.destroy();
-                }
-                catch ( Throwable t2 )
-                {
-                    t2.printStackTrace();
-                }
-            }
 
-            if ( t instanceof NamingException )
-            {
-                throw ( NamingException ) t;
-            }
-            else
-            {
-                throw new InterceptorException( interceptor, null, "Failed to initialize interceptor chain.", t );
-            }
+        public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
+        {
+            return nexus.search( base, env, filter, searchCtls );
         }
-    }
 
 
-    /**
-     * Deinitializes all interceptors this chain contains.
-     */
-    public synchronized void destroy()
-    {
-        ListIterator it = getAllReversed().listIterator();
+        public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
+        {
+            return ( Attributes ) nexus.lookup( name ).clone();
+        }
 
-        while ( it.hasNext() )
+
+        public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
         {
-            Interceptor interceptor = ( Interceptor ) it.next();
+            return ( Attributes ) nexus.lookup( dn, attrIds ).clone();
+        }
 
-            try
-            {
-                interceptor.destroy();
-            }
-            catch ( Throwable t )
-            {
-                t.printStackTrace();
-            }
+
+        public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
+        {
+            return nexus.hasEntry( name );
         }
-    }
 
 
-    /**
-     * Returns the 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 );
+        public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
+        {
+            return nexus.isSuffix( name );
+        }
 
-        if ( e == null )
+
+        public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
         {
-            return null;
+            nexus.modifyRn( name, newRn, deleteOldRn );
         }
 
-        return e.interceptor;
-    }
 
+        public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
+        {
+            nexus.move( oriChildName, newParentName );
+        }
+
+
+        public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+        {
+            nexus.move( oriChildName, newParentName, newRn, deleteOldRn );
+        }
+    };
+
+    private final Map name2entry = new HashMap();
+
+    private final Entry tail;
+
+    private Entry head;
+
+    private ContextFactoryConfiguration factoryCfg;
 
     /**
-     * Adds the specified interceptor with the specified name at the beginning of this chain.
+     * Create a new interceptor chain.
      */
-    public synchronized void addFirst( String name,
-                                       Interceptor interceptor )
+    public InterceptorChain()
     {
-        checkAddable( name, interceptor );
-        register( name, interceptor, head );
+        MutableInterceptorConfiguration tailCfg = new MutableInterceptorConfiguration();
+        tailCfg.setName( "tail" );
+        tailCfg.setInterceptor( FINAL_INTERCEPTOR );
+        tail = new Entry( null, null, tailCfg );
+        head = tail;
     }
 
 
     /**
-     * Adds the specified interceptor with the specified name at the end of this chain.
+     * Initializes and registers all interceptors according to the specified
+     * {@link ContextFactoryConfiguration}.
      */
-    public synchronized void addLast( String name,
-                                      Interceptor interceptor )
+    public synchronized void init( ContextFactoryConfiguration factoryCfg ) throws NamingException
     {
-        checkAddable( name, interceptor );
-        register( name, interceptor, tail );
+        this.factoryCfg = factoryCfg;
+
+        // Initialize tail first.
+        FINAL_INTERCEPTOR.init( factoryCfg, null );
+        
+        // And register and initialize all interceptors
+        ListIterator i = factoryCfg.getStartupConfiguration().getInterceptorConfigurations().listIterator();
+        Interceptor interceptor = null;
+        try
+        {
+            while( i.hasNext() )
+            {
+                InterceptorConfiguration cfg = ( InterceptorConfiguration ) i.next();
+                register( cfg );
+            }
+        }
+        catch ( Throwable t )
+        {
+            // destroy if failed to initialize all interceptors.
+            destroy();
+
+            if ( t instanceof NamingException )
+            {
+                throw ( NamingException ) t;
+            }
+            else
+            {
+                throw new InterceptorException( interceptor, "Failed to initialize interceptor chain.", t );
+            }
+        }
     }
 
 
     /**
-     * Adds the specified interceptor with the specified name just before the interceptor whose name is
-     * <code>baseName</code> in this chain.
+     * Deinitializes and deregisters all interceptors this chain contains.
      */
-    public synchronized void addBefore( String baseName, String name, Interceptor interceptor )
+    public synchronized void destroy()
     {
-        Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, interceptor );
-        register( name, interceptor, baseEntry );
+        List entries = new ArrayList();
+        Entry e = tail;
+        do
+        {
+            entries.add( e );
+            e = e.prevEntry;
+        }
+        while ( e != null );
+
+        Iterator i = entries.iterator();
+        while ( i.hasNext() )
+        {
+            e = ( Entry ) i.next();
+            if( e != tail )
+            {
+                try
+                {
+                    deregister( e.configuration );
+                }
+                catch ( Throwable t )
+                {
+                    t.printStackTrace();
+                }
+            }
+        }
     }
 
 
     /**
-     * Adds the specified interceptor with the specified name just after the interceptor whose name is
-     * <code>baseName</code> in this chain.
+     * Adds and initializes an interceptor with the specified configuration.
      */
-    public synchronized void addAfter( String baseName, String name, Interceptor interceptor )
+    private void register( InterceptorConfiguration cfg ) throws NamingException
     {
-        Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, interceptor );
-        register( name, interceptor, baseEntry );
+        checkAddable( cfg );
+        register0( cfg, tail );
     }
 
 
     /**
-     * Removes the interceptor with the specified name from this chain.
+     * Removes and deinitializes the interceptor with the specified configuration.
      */
-    public synchronized void remove( String name )
+    private void deregister( InterceptorConfiguration cfg ) throws ConfigurationException
     {
+        String name = cfg.getName();
         Entry entry = checkOldName( name );
-
         Entry prevEntry = entry.prevEntry;
-
         Entry nextEntry = entry.nextEntry;
 
+        if( nextEntry == null )
+        {
+            // Don't deregister tail
+            return;
+        }
+
         if ( prevEntry == null )
         {
             nextEntry.prevEntry = null;
-
             head = entry;
         }
         else
         {
             prevEntry.nextEntry = nextEntry;
-
             nextEntry.prevEntry = prevEntry;
         }
 
         name2entry.remove( name );
-
-        Interceptor interceptor = entry.interceptor;
-
-        interceptor2entry.remove( interceptor );
-
-        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() )
-        {
-            this.remove( ( String ) it.next() );
-        }
+        entry.configuration.getInterceptor().destroy();
     }
 
 
-    private void register( String name, Interceptor interceptor, Entry nextEntry )
+    private void register0( InterceptorConfiguration cfg, Entry nextEntry ) throws NamingException
     {
+        String name = cfg.getName();
+        Interceptor interceptor = cfg.getInterceptor();
+        interceptor.init( factoryCfg, cfg );
+        
         Entry newEntry;
         if( nextEntry == head )
         {
-            newEntry = new Entry( null, head, name, interceptor );
+            newEntry = new Entry( null, head, cfg );
             head.prevEntry = newEntry;
             head = newEntry;
         }
         else if( head == tail )
         {
-            newEntry = new Entry( null, tail, name, interceptor );
+            newEntry = new Entry( null, tail, cfg );
             tail.prevEntry = newEntry;
             head = newEntry;
         }
         else
         {
-            newEntry = new Entry( nextEntry.prevEntry, nextEntry, name, interceptor );
+            newEntry = new Entry( nextEntry.prevEntry, nextEntry, cfg );
             nextEntry.prevEntry.nextEntry = newEntry;
             nextEntry.prevEntry = newEntry;
         }
         
         name2entry.put( name, newEntry );
-        interceptor2entry.put( newEntry.interceptor, newEntry );
     }
 
 
@@ -318,13 +335,13 @@
      *
      * @return An interceptor entry with the specified name.
      */
-    private Entry checkOldName( String baseName )
+    private Entry checkOldName( String baseName ) throws ConfigurationException
     {
         Entry e = ( Entry ) name2entry.get( baseName );
 
         if ( e == null )
         {
-            throw new IllegalArgumentException( "Unknown interceptor name:" + baseName );
+            throw new ConfigurationException( "Unknown interceptor name:" + baseName );
         }
 
         return e;
@@ -334,35 +351,42 @@
     /**
      * Checks the specified interceptor name is already taken and throws an exception if already taken.
      */
-    private void checkAddable( String name, Interceptor interceptor )
+    private void checkAddable( InterceptorConfiguration cfg ) throws ConfigurationException
     {
-        if ( name2entry.containsKey( name ) )
+        if ( name2entry.containsKey( cfg.getName() ) )
         {
-            throw new IllegalArgumentException( "Other interceptor is using name '" + name + "'" );
+            throw new ConfigurationException( "Other interceptor is using name '" + cfg.getName() + "'" );
         }
+    }
+
 
-        if ( interceptor instanceof InterceptorChain )
+    public Attributes getRootDSE() throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
         {
-            if ( ( ( InterceptorChain ) interceptor ).parent != null )
-            {
-                throw new IllegalArgumentException( "This interceptor chain has its parent already." );
-            }
+            return head.getRootDSE( next );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
         }
     }
 
 
-    /**
-     * Start invocation chain with the specified invocation.
-     *
-     * @throws NamingException if invocation failed
-     */
-    public void process( Invocation invocation ) throws NamingException
+    public Name getMatchedName( Name name, boolean normalized ) throws NamingException
     {
-        Entry head = this.head;
-
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
         try
         {
-            head.interceptor.process( head.nextInterceptor, invocation );
+            return head.getMatchedName( next, name, normalized );
         }
         catch ( NamingException ne )
         {
@@ -370,95 +394,585 @@
         }
         catch ( Throwable e )
         {
-            throw new InterceptorException( head.interceptor, invocation, "Unexpected exception.", e );
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
         }
     }
 
 
-    /**
-     * Returns the list of interceptors this chain in the order of evaluation.
-     */
-    public List getAll()
+    public Name getSuffix( Name name, boolean normalized ) throws NamingException
     {
-        List list = new ArrayList();
-
-        Entry e = head;
-
-        do
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
         {
-            list.add( e.interceptor );
-
-            e = e.nextEntry;
+            return head.getSuffix( next, name, normalized );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
         }
-        while ( e != null );
-
-        return list;
     }
 
 
-    /**
-     * Returns the list of interceptors this chain in the reversed order of evaluation.
-     */
-    public List getAllReversed()
+    public Iterator listSuffixes( boolean normalized ) throws NamingException
     {
-        List list = new ArrayList();
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.listSuffixes( next, normalized );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
 
-        Entry e = tail;
 
-        do
+    public void delete( Name name ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
         {
-            list.add( e.interceptor );
-
-            e = e.prevEntry;
+            head.delete( next, name );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
         }
+    }
 
-        while ( e != null );
 
-        return list;
+    public void add( String upName, Name normName, Attributes entry ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.add( next, upName, normName, entry );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
     }
 
 
-    /**
-     * Represents an internal entry of this chain.
-     */
-    private class Entry
+    public void modify( Name name, int modOp, Attributes mods ) throws NamingException
     {
-        private Entry prevEntry;
-
-        private Entry nextEntry;
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.modify( next, name, modOp, mods );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
+    }
 
-        private final Interceptor interceptor;
 
-        private final NextInterceptor nextInterceptor;
+    public void modify( Name name, ModificationItem[] mods ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.modify( next, name, mods );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
+    }
 
 
-        private Entry( Entry prevEntry, Entry nextEntry,
-                       String name, Interceptor interceptor )
+    public NamingEnumeration list( Name base ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
         {
-            if ( interceptor == null )
-            {
-                throw new NullPointerException( "interceptor" );
-            }
-            if ( name == null )
+            return head.list( next, base );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.search( next, base, env, filter, searchCtls );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public Attributes lookup( Name name ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.lookup( next, name );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.lookup( next, dn, attrIds );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public boolean hasEntry( Name name ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.hasEntry( next, name );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public boolean isSuffix( Name name ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            return head.isSuffix( next, name );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+            throw new InternalError(); // Should be unreachable
+        }
+    }
+
+
+    public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.modifyRn( next, name, newRn, deleteOldRn );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
+    }
+
+
+    public void move( Name oriChildName, Name newParentName ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.move( next, oriChildName, newParentName );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
+    }
+
+
+    public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+    {
+        Interceptor head = this.head.configuration.getInterceptor();
+        NextInterceptor next = this.head.nextInterceptor;
+        try
+        {
+            head.move( next, oriChildName, newParentName, newRn, deleteOldRn );
+        }
+        catch ( NamingException ne )
+        {
+            throw ne;
+        }
+        catch ( Throwable e )
+        {
+            throwInterceptorException( head, e );
+        }
+    }
+
+
+    /**
+     * Represents an internal entry of this chain.
+     */
+    private class Entry
+    {
+        private Entry prevEntry;
+
+        private Entry nextEntry;
+
+        private final InterceptorConfiguration configuration;
+
+        private final NextInterceptor nextInterceptor;
+
+
+        private Entry( Entry prevEntry, Entry nextEntry,
+                       InterceptorConfiguration configuration )
+        {
+            if ( configuration == null )
             {
-                throw new NullPointerException( "name" );
+                throw new NullPointerException( "configuration" );
             }
 
             this.prevEntry = prevEntry;
 
             this.nextEntry = nextEntry;
 
-            this.interceptor = interceptor;
+            this.configuration = configuration;
 
             this.nextInterceptor = new NextInterceptor()
             {
-                public void process( Invocation call ) throws NamingException
+                public Attributes getRootDSE() throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.getRootDSE( Entry.this.nextEntry.nextInterceptor );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public Name getMatchedName( Name dn, boolean normalized ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.getMatchedName( Entry.this.nextEntry.nextInterceptor, dn, normalized );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public Name getSuffix( Name dn, boolean normalized ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.getSuffix( Entry.this.nextEntry.nextInterceptor, dn, normalized );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public Iterator listSuffixes( boolean normalized ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.listSuffixes( Entry.this.nextEntry.nextInterceptor, normalized );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public void delete( Name name ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.delete( Entry.this.nextEntry.nextInterceptor, name );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public void add( String upName, Name normName, Attributes entry ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.add( Entry.this.nextEntry.nextInterceptor, upName, normName, entry );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public void modify( Name name, int modOp, Attributes mods ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, modOp, mods );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public void modify( Name name, ModificationItem[] mods ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, mods );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public NamingEnumeration list( Name base ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.list( Entry.this.nextEntry.nextInterceptor, base );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.search( Entry.this.nextEntry.nextInterceptor, base, env, filter, searchCtls );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public Attributes lookup( Name name ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, name );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, dn, attrIds );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public boolean hasEntry( Name name ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        return interceptor.hasEntry( Entry.this.nextEntry.nextInterceptor, name );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public boolean isSuffix( Name name ) throws NamingException
                 {
-                    Interceptor interceptor = Entry.this.nextEntry.interceptor;
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
 
                     try
                     {
-                        interceptor.process( Entry.this.nextEntry.nextInterceptor, call );
+                        return interceptor.isSuffix( Entry.this.nextEntry.nextInterceptor, name );
                     }
                     catch ( NamingException ne )
                     {
@@ -466,10 +980,71 @@
                     }
                     catch ( Throwable e )
                     {
-                        throw new InterceptorException( interceptor, call, "Unexpected exception.", e );
+                        throwInterceptorException( interceptor, e );
+                        throw new InternalError(); // Should be unreachable
+                    }
+                }
+
+                public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.modifyRn( Entry.this.nextEntry.nextInterceptor, name, newRn, deleteOldRn );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public void move( Name oriChildName, Name newParentName ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
+                    }
+                }
+
+                public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+                {
+                    Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
+
+                    try
+                    {
+                        interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName, newRn, deleteOldRn );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        throw ne;
+                    }
+                    catch ( Throwable e )
+                    {
+                        throwInterceptorException( interceptor, e );
                     }
                 }
             };
         }
+    }
+
+
+    private static void throwInterceptorException( Interceptor interceptor, Throwable e ) throws InterceptorException
+    {
+        throw new InterceptorException( interceptor, "Unexpected exception.", e );
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorException.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorException.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorException.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorException.java Thu Jun 23 20:08:31 2005
@@ -17,28 +17,21 @@
 package org.apache.ldap.server.interceptor;
 
 
-import org.apache.ldap.common.exception.LdapException;
-import org.apache.ldap.common.exception.LdapNamingException;
-import org.apache.ldap.common.message.ResultCodeEnum;
-import org.apache.ldap.server.invocation.Invocation;
+import javax.naming.NamingException;
 
 
 /**
- * A {@link LdapNamingException} that wraps uncaught runtime exceptions thrown from {@link Interceptor}s.
+ * A {@link NamingException} that wraps uncaught runtime exceptions thrown
+ * from {@link Interceptor}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class InterceptorException extends LdapNamingException
+public class InterceptorException extends NamingException
 {
     private static final long serialVersionUID = 3258690996517746233L;
 
     /**
-     * The Invocation the Interceptor failed on
-     */
-    private final Invocation invocation;
-
-    /**
      * The Interceptor causing the failure
      */
     private final Interceptor interceptor;
@@ -48,14 +41,9 @@
      * Creates an InterceptorException without a message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @param invocation  the Invocation the Interceptor failed on
      */
-    public InterceptorException( Interceptor interceptor, Invocation invocation )
+    public InterceptorException( Interceptor interceptor )
     {
-        super( ResultCodeEnum.OTHER );
-
-        this.invocation = invocation;
-
         this.interceptor = interceptor;
     }
 
@@ -64,15 +52,11 @@
      * Creates an InterceptorException with a custom message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @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 )
+    public InterceptorException( Interceptor interceptor, String explanation )
     {
-        super( explanation, ResultCodeEnum.OTHER );
-
-        this.invocation = invocation;
-
+        super( explanation );
         this.interceptor = interceptor;
     }
 
@@ -81,13 +65,11 @@
      * 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
      */
-    public InterceptorException( Interceptor interceptor, Invocation invocation, Throwable rootCause )
+    public InterceptorException( Interceptor interceptor, Throwable rootCause )
     {
-        this( interceptor, invocation );
-
+        this( interceptor );
         super.setRootCause( rootCause );
     }
 
@@ -96,31 +78,18 @@
      * Creates an InterceptorException without a message.
      *
      * @param interceptor the Interceptor causing the failure
-     * @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
      */
-    public InterceptorException( Interceptor interceptor, Invocation invocation, String explanation,
+    public InterceptorException( Interceptor interceptor, String explanation,
                                  Throwable rootCause )
     {
-        this( interceptor, invocation, explanation );
-
+        this( interceptor, explanation );
         super.setRootCause( rootCause );
     }
 
 
     /**
-     * Gets the invovation object this exception is associated with.
-     *
-     * @return the invovation object this exception is associated with
-     */
-    public Invocation getInvocation()
-    {
-        return invocation;
-    }
-
-
-    /**
      * Gets the interceptor this exception is associated with.
      *
      * @return the interceptor this exception is associated with
@@ -128,21 +97,5 @@
     public Interceptor getInterceptor()
     {
         return interceptor;
-    }
-
-
-    /**
-     * Will return the resultCode of the root cause if the root cause implements LdapException.
-     *
-     * @see org.apache.ldap.common.exception.LdapException#getResultCode()
-     */
-    public ResultCodeEnum getResultCode()
-    {
-        if ( getRootCause() != null && ( getRootCause() instanceof LdapException ) )
-        {
-            return ( ( LdapException ) getRootCause() ).getResultCode();
-        }
-
-        return super.getResultCode();
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java Thu Jun 23 20:08:31 2005
@@ -17,27 +17,97 @@
 package org.apache.ldap.server.interceptor;
 
 
-import org.apache.ldap.server.invocation.Invocation;
+import java.util.Iterator;
+import java.util.Map;
 
+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 org.apache.ldap.common.filter.ExprNode;
 
 
 /**
- * Represents the next {@link org.apache.ldap.server.interceptor.Interceptor} in the interceptor chain.
+ * Represents the next {@link Interceptor} in the interceptor chain.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
- * @see org.apache.ldap.server.interceptor.Interceptor
- * @see org.apache.ldap.server.interceptor.InterceptorChain
+ * @see Interceptor
+ * @see InterceptorChain
  */
 public interface NextInterceptor
 {
     /**
-     * Passes the control of current invocation to the next {@link org.apache.ldap.server.interceptor.Interceptor} in
-     * the {@link org.apache.ldap.server.interceptor.InterceptorChain}.
-     *
-     * @param incovation
-     * @throws NamingException
+     * Calls the next interceptor's {@link Interceptor#getRootDSE(NextInterceptor)}.
+     */
+    Attributes getRootDSE() throws NamingException; 
+    /**
+     * Calls the next interceptor's {@link Interceptor#getMatchedName(NextInterceptor, Name, boolean)}.
+     */
+    Name getMatchedName( Name name, boolean normalized ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#getSuffix(NextInterceptor, Name, boolean)}.
+     */
+    Name getSuffix( Name name, boolean normalized ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#listSuffixes(NextInterceptor, boolean)}.
+     */
+    Iterator listSuffixes( boolean normalized ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#delete(NextInterceptor, Name)}.
+     */
+    void delete( Name name ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#add(NextInterceptor, String, Name, Attributes)}.
+     */
+    void add( String userProvidedName, Name normalizedName, Attributes entry ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#modify(NextInterceptor, Name, int, Attributes)}.
+     */
+    void modify( Name name, int modOp, Attributes attributes ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#modify(NextInterceptor, Name, ModificationItem[])}.
+     */
+    void modify( Name name, ModificationItem[] items ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#list(NextInterceptor, Name)}.
+     */
+    NamingEnumeration list( Name baseName ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#search(NextInterceptor, Name, Map, ExprNode, SearchControls)}.
+     */
+    NamingEnumeration search( Name baseName, Map environment, ExprNode filter,
+                              SearchControls searchControls ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#lookup(NextInterceptor, Name)}.
+     */
+    Attributes lookup( Name name ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#lookup(NextInterceptor, Name, String[])}.
+     */
+    Attributes lookup( Name name, String [] attrIds ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#hasEntry(NextInterceptor, Name)}.
+     */
+    boolean hasEntry( Name name ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#isSuffix(NextInterceptor, Name)}.
+     */
+    boolean isSuffix( Name name ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#modifyRn(NextInterceptor, Name, String, boolean)}.
+     */
+    void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#move(NextInterceptor, Name, Name)}.
+     */
+    void move( Name oldName, Name newParentName ) throws NamingException;
+    /**
+     * Calls the next interceptor's {@link Interceptor#move(NextInterceptor, Name, Name, String, boolean)}.
      */
-    void process( Invocation incovation ) throws NamingException;
+    void move( Name oldName, Name newParentName, String newRn,
+               boolean deleteOldRn ) throws NamingException;
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/Invocation.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/Invocation.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/Invocation.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/Invocation.java Thu Jun 23 20:08:31 2005
@@ -17,99 +17,94 @@
 package org.apache.ldap.server.invocation;
 
 
-import java.io.Serializable;
-import java.util.Stack;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
-import javax.naming.NamingException;
+import javax.naming.Context;
 
-import org.apache.ldap.server.BackingStore;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
 
 
 /**
- * Represents a method invocation on {@link BackingStore}s.
- * <p/>
- * This class is abstract, and developers should extend this class to
- * represent the actual method invocations.
+ * Represents a call from JNDI {@link Context} to {@link ContextPartitionNexus}.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public abstract class Invocation implements Serializable
+public class Invocation
 {
-
-    protected transient Object returnValue;
-
-    protected transient Stack contextStack;
-
+    private final Context caller;
+    private final String name;
+    private final List parameters;
     
     /**
-     * Creates a new instance.  This constructor does nothing.
-     */
-    protected Invocation()
-    {
-    }
-
-
-    /**
-     * Returns the returnValue object for this invocation.
-     */
-    public Object getReturnValue()
-    {
-        return returnValue;
+     * Creates a new instance that represents an invocation without parameters.
+     * 
+     * @parem caller the JNDI {@link Context} that made this invocation
+     * @param name the name of the called method
+     */
+    public Invocation( Context caller, String name )
+    {
+        this( caller, name, null );
     }
 
-
     /**
-     * Sets the returnValue object for this invocation.
-     */
-    public void setReturnValue( Object returnValue )
-    {
-        this.returnValue = returnValue;
+     * Creates a new instance.
+     * 
+     * @parem caller the JNDI {@link Context} that made this invocation
+     * @param name the name of the called method
+     * @param parameters the array of parameters passed to the called method
+     */
+    public Invocation( Context caller, String name, Object[] parameters )
+    {
+        if( caller == null )
+        {
+            throw new NullPointerException( "caller" );
+        }
+        if( name == null )
+        {
+            throw new NullPointerException( "name" );
+        }
+        
+        if( parameters == null )
+        {
+            parameters = new Object[ 0 ];
+        }
+        
+        this.caller = caller;
+        this.name = name;
+        
+        List paramList = new ArrayList();
+        for( int i = 0; i < parameters.length; i++ )
+        {
+            paramList.add( parameters[ i ] );
+        }
+        
+        this.parameters = Collections.unmodifiableList( paramList );
     }
-
-
+    
     /**
-     * Gets the context stack in which this invocation occurs.  The
-     * context stack is a stack of LdapContexts.
-     *
-     * @return a stack of LdapContexts in which the invocation occurs
+     * Returns the JNDI {@link Context} which made this invocation.
      */
-    public Stack getContextStack()
+    public Context getCaller()
     {
-        return contextStack;
+        return caller;
     }
-
-
+    
     /**
-     * Sets the context stack in which this invocation occurs.  The context stack
-     * is a stack of LdapContexts.
-     *
-     * @param contextStack a stack of LdapContexts in which the invocation occurs
+     * Returns the name of the called method.
      */
-    public void setContextStack( Stack contextStack )
+    public String getName()
     {
-        this.contextStack = contextStack;
+        return name;
     }
-
-
+    
     /**
-     * Executes this invocation on the specified <code>store</code>. The default
-     * implementation calls an abstract method {@link #doExecute(BackingStore)}
-     * and sets the <code>returnValue</code> property of this invocation to its return value.
-     *
-     * @throws NamingException if the operation failed
+     * Returns the list of parameters parameters passed to the called method.
      */
-    public void execute( BackingStore store ) throws NamingException
+    public List getParameters()
     {
-        setReturnValue( doExecute( store ) );
+        return parameters;
     }
-
-
-    /**
-     * Implement this method to invoke the appropriate operation on the specified
-     * <code>store</code>.  Returned value will be set as the <code>returnValue</code> proeprty of this invocation.
-     *
-     * @throws NamingException if the operation failed
-     */
-    protected abstract Object doExecute( BackingStore store ) throws NamingException;
 }

Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/InvocationStack.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java Thu Jun 23 20:08:31 2005
@@ -19,21 +19,22 @@
 
 import java.util.Hashtable;
 
+import javax.naming.ConfigurationException;
 import javax.naming.Context;
+import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.naming.spi.InitialContextFactory;
 
 import org.apache.ldap.server.configuration.Configuration;
-import org.apache.ldap.server.configuration.ConfigurationException;
 import org.apache.ldap.server.configuration.ShutdownConfiguration;
 import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.ldap.server.configuration.SyncConfiguration;
 
 
 /**
- * A server-side provider implementation of a InitialContextFactory.  Can be
- * utilized via JNDI API in the standard fashion:
- *
+ * A server-side JNDI provider implementation of {@link InitialContextFactory}.
+ * This class can be utilized via JNDI API in the standard fashion:
+ * <p>
  * <code>
  * Hashtable env = new Hashtable();
  * env.put( Context.PROVIDER_URL, "ou=system" );
@@ -41,25 +42,36 @@
  * Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
  * InitialContext initialContext = new InitialContext( env );
  * </code>
- *
+ * <p>
+ * Unfortunately, {@link InitialContext} creates a new instance of
+ * {@link InitialContextFactory} implementation everytime it is instantiated,
+ * so this factory maintains only a static, singleton instance of
+ * {@link ContextFactoryService}, which provides actual implementation.
+ * Please note that you'll also have to maintain any stateful information
+ * as using singleton pattern if you're going to extend this factory.
+ * <p>
+ * This class implements {@link ContextFactoryServiceListener}.  This means that
+ * you can listen to the changes occurs to {@link ContextFactoryService}, and
+ * react to it (e.g. executing additional business logic).
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  * 
  * @see javax.naming.spi.InitialContextFactory
  */
-public abstract class AbstractContextFactory implements InitialContextFactory
+public abstract class AbstractContextFactory implements InitialContextFactory, ContextFactoryServiceListener
 {
     // ------------------------------------------------------------------------
     // Members
     // ------------------------------------------------------------------------
 
-    /** The singleton JndiProvider instance */
-    private static final ContextFactoryConfiguration provider = new DefaultContextFactoryConfiguration();
+    /** The singleton service instance */
+    private static final ContextFactoryService service = new DefaultContextFactoryService();
 
     /**
-     * Default constructor that sets the provider of this ServerContextFactory.
+     * Creates a new instance.
      */
-    public AbstractContextFactory()
+    protected AbstractContextFactory()
     {
     }
     
@@ -76,22 +88,22 @@
         // Execute configuration
         if( cfg instanceof ShutdownConfiguration )
         {
-            provider.shutdown();
+            ( ( DefaultContextFactoryService ) service ).shutdown();
         }
         else if( cfg instanceof SyncConfiguration )
         {
-            provider.sync();
+            service.sync();
         }
         else if( cfg instanceof StartupConfiguration )
         {
-            ( ( DefaultContextFactoryConfiguration ) provider ).startup( this, env );
+            service.startup( this, env );
         }
-        else if( provider == null )
+        else if( service == null )
         {
             throw new NamingException( "Unknown configuration: " + cfg );
         }
         
-        return provider.getJndiContext( principal, credential, authentication, providerUrl );
+        return service.getConfiguration().getJndiContext( principal, credential, authentication, providerUrl );
     }
 
     private String extractProviderUrl( Hashtable env )
@@ -122,7 +134,7 @@
         return authentication;
     }
 
-    private byte[] extractCredential( Hashtable env )
+    private byte[] extractCredential( Hashtable env ) throws ConfigurationException
     {
         byte[] credential;
         Object value = env.remove( Context.SECURITY_CREDENTIALS );
@@ -159,11 +171,4 @@
         }
         return principal;
     }
-    
-    protected abstract void beforeStartup( ContextFactoryConfiguration ctx ) throws NamingException;
-    protected abstract void afterStartup( ContextFactoryConfiguration ctx ) throws NamingException;
-    protected abstract void beforeShutdown( ContextFactoryConfiguration ctx ) throws NamingException;
-    protected abstract void afterShutdown( ContextFactoryConfiguration ctx ) throws NamingException;
-    protected abstract void beforeSync( ContextFactoryConfiguration ctx ) throws NamingException;
-    protected abstract void afterSync( ContextFactoryConfiguration ctx ) throws NamingException;
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java Thu Jun 23 20:08:31 2005
@@ -21,60 +21,71 @@
 import javax.naming.Context;
 import javax.naming.NamingException;
 
-import org.apache.ldap.server.RootNexus;
-import org.apache.ldap.server.SystemPartition;
 import org.apache.ldap.server.configuration.StartupConfiguration;
-import org.apache.ldap.server.invocation.Invocation;
+import org.apache.ldap.server.interceptor.InterceptorChain;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
 import org.apache.ldap.server.schema.GlobalRegistries;
 
-/** FIXME Rename to ContextFactoryContext */
+/**
+ * Represents the global configuration of currently running
+ * {@link ContextFactoryService}.  You can access all properties of
+ * {@link ContextFactoryService} and get JNDI {@link Context}s it provides
+ * via this interface.
+ */
 public interface ContextFactoryConfiguration
 {
+    
     /**
-     * Returns the initial context environment of this context factory.
+     * Returns the listener that listens to service events.
      */
-    Hashtable getEnvironment();
+    ContextFactoryServiceListener getServiceListener();
     
     /**
-     * Returns the startup configuration of this context factory.
+     * Returns the initial context environment of the {@link ContextFactoryService}.
      */
-    StartupConfiguration getConfiguration();
+    Hashtable getEnvironment();
     
     /**
-     * Returns the system partition used by this context factory.
+     * Returns the startup configuration of the {@link ContextFactoryService}.
      */
-    SystemPartition getSystemPartition();
-
+    StartupConfiguration getStartupConfiguration();
+    
     /**
-     * Returns the registries for system schema objects
+     * Returns the registries for system schema objects of the {@link ContextFactoryService}.
      */
     GlobalRegistries getGlobalRegistries();
 
     /**
-     * Returns the root nexus of this context factory.
+     * Returns the {@link ContextPartitionNexus} of the {@link ContextFactoryService}.
      */
-    RootNexus getRootNexus();
+    ContextPartitionNexus getPartitionNexus();
     
     /**
-     * Returns <tt>true</tt> if this context is started for the first time
-     * and bootstrap entries have been created.
+     * Returns the interceptor chain of the {@link ContextFactoryService}.
      */
-    boolean isFirstStart();
+    InterceptorChain getInterceptorChain();
     
     /**
-     * Returns <tt>true</tt> if this context is started.
+     * Returns <tt>true</tt> if this service is started
+     * and bootstrap entries have been created for the first time.
      */
-    boolean isStarted();
+    boolean isFirstStart();
     
-    Context getJndiContext( String rootDN ) throws NamingException;
-    Context getJndiContext( String principal, byte[] credential, String authentication, String rootDN ) throws NamingException;
-
     /**
-     * Invokes {@link Invocation} to this context.
+     * Returns an anonymous JNDI {@link Context} with the specified <tt>baseName</tt>
+     * @throws NamingException if failed to create a context
      */
-    Object invoke( Invocation call ) throws NamingException;
-    
-    void sync() throws NamingException;
+    Context getJndiContext( String baseName ) throws NamingException;
     
-    void shutdown() throws NamingException;
+    /**
+     * Returns a JNDI {@link Context} with the specified authentication information
+     * (<tt>principal</tt>, <tt>credential</tt>, and <tt>authentication</tt>) and
+     * <tt>baseName</tt>.
+     * 
+     * @param principal {@link Context#SECURITY_PRINCIPAL} value
+     * @param credential {@link Context#SECURITY_CREDENTIALS} value
+     * @param authentication {@link Context#SECURITY_AUTHENTICATION} value
+     * @throws NamingException if failed to create a context
+     */
+    Context getJndiContext( String principal, byte[] credential, String authentication, String baseName ) throws NamingException;
 }

Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryServiceListener.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java Thu Jun 23 20:08:31 2005
@@ -21,20 +21,12 @@
 
 
 /**
- * A server-side provider implementation of a InitialContextFactory.  Can be
- * utilized via JNDI API in the standard fashion:
- *
- * <code>
- * Hashtable env = new Hashtable();
- * env.put( Context.PROVIDER_URL, "ou=system" );
- * env.put(
- * Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
- * InitialContext initialContext = new InitialContext( env );
- * </code>
+ * A simplistic implementation of {@link AbstractContextFactory}.
+ * This class simply extends {@link AbstractContextFactory} and leaves all
+ * abstract event listener methods as empty.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
- * @see javax.naming.spi.InitialContextFactory
  */
 public class CoreContextFactory extends AbstractContextFactory implements InitialContextFactory
 {
@@ -45,27 +37,45 @@
     {
     }
 
-    protected void beforeStartup( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void beforeStartup( ContextFactoryService service ) throws NamingException
     {
     }
 
-    protected void afterStartup( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void afterStartup( ContextFactoryService service ) throws NamingException
     {
     }
     
-    protected void beforeShutdown( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void beforeShutdown( ContextFactoryService service ) throws NamingException
     {
     }
     
-    protected void afterShutdown( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void afterShutdown( ContextFactoryService service ) throws NamingException
     {
     }
     
-    protected void beforeSync( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void beforeSync( ContextFactoryService service ) throws NamingException
     {
     }
 
-    protected void afterSync( ContextFactoryConfiguration ctx ) throws NamingException
+    /**
+     * Does nothing by default.
+     */
+    public void afterSync( ContextFactoryService service ) throws NamingException
     {
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DeadContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DeadContext.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DeadContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DeadContext.java Thu Jun 23 20:08:31 2005
@@ -17,10 +17,14 @@
 package org.apache.ldap.server.jndi;
 
 
-import org.apache.ldap.common.exception.LdapServiceUnavailableException;
-import org.apache.ldap.common.message.ResultCodeEnum;
+import java.util.Hashtable;
 
-import javax.naming.*;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
@@ -29,19 +33,22 @@
 import javax.naming.ldap.ExtendedRequest;
 import javax.naming.ldap.ExtendedResponse;
 import javax.naming.ldap.LdapContext;
-import java.util.Hashtable;
+
+import org.apache.ldap.common.exception.LdapServiceUnavailableException;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.server.configuration.SyncConfiguration;
 
 
 /**
  * A do nothing placeholder context whose methods throw ConfigurationExceptions.
- * The provider returns these context when the shutdown environment property key
- * is set.  By returning a non-null Context we prevent an unnecessary exception
- * being thrown by InitialConext and any one of its subclasses.
+ * JNDI provider returns this context when your specify {@link SyncConfiguration}
+ * in JNDI environment.  By returning a non-null Context we prevent an unnecessary
+ * exception being thrown by {@link InitialContext} and any one of its subclasses.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
+ * @version $Rev$, $Date$
  */
-public class DeadContext implements LdapContext
+class DeadContext implements LdapContext
 {
     private final String EXCEPTION_MSG = "Context operation unavailable when " +
             "invoked after Eve provider has been shutdown";

Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/JavaLdapSupport.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/JavaLdapSupport.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/JavaLdapSupport.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/JavaLdapSupport.java Thu Jun 23 20:08:31 2005
@@ -17,9 +17,14 @@
 package org.apache.ldap.server.jndi;
 
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
-import java.io.*;
 
 
 /**
@@ -31,7 +36,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class JavaLdapSupport
+class JavaLdapSupport
 {
     // ------------------------------------------------------------------------
     // Attribute Id Constants Used By The Java LDAP BootstrapSchema

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java Thu Jun 23 20:08:31 2005
@@ -17,16 +17,19 @@
 package org.apache.ldap.server.jndi;
 
 
-import org.apache.ldap.common.exception.LdapNoPermissionException;
-import org.apache.ldap.common.filter.PresenceNode;
-import org.apache.ldap.common.message.LockableAttributesImpl;
-import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.common.util.NamespaceTools;
-import org.apache.ldap.server.PartitionNexus;
-import org.apache.ldap.server.authn.AuthenticationService;
-import org.apache.ldap.server.authn.LdapPrincipal;
+import java.io.Serializable;
+import java.util.Hashtable;
 
-import javax.naming.*;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
@@ -34,8 +37,15 @@
 import javax.naming.ldap.Control;
 import javax.naming.spi.DirStateFactory;
 import javax.naming.spi.DirectoryManager;
-import java.io.Serializable;
-import java.util.Hashtable;
+
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.util.NamespaceTools;
+import org.apache.ldap.server.authn.AuthenticationService;
+import org.apache.ldap.server.authn.LdapPrincipal;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
 
 
 /**
@@ -50,7 +60,7 @@
     public static final String DELETE_OLD_RDN_PROP = "java.naming.ldap.deleteRDN";
 
     /** The interceptor proxy to the backend nexus */
-    private final PartitionNexus nexusProxy;
+    private final ContextPartitionNexus nexusProxy;
 
     /** The cloned environment used by this Context */
     private final Hashtable env;
@@ -75,19 +85,20 @@
      * referenced name actually exists within the system.  This constructor
      * is used for all InitialContext requests.
      * 
-     * @param nexusProxy the intercepting proxy to the nexus.
+     * @param service the parent service that manages this context
      * @param env the environment properties used by this context.
      * @throws NamingException if the environment parameters are not set 
      * correctly.
      */
-    protected ServerContext( PartitionNexus nexusProxy, Hashtable env ) throws NamingException
+    protected ServerContext( ContextFactoryService service, Hashtable env ) throws NamingException
     {
-        String url;
-
         // set references to cloned env and the proxy
-        this.nexusProxy = nexusProxy;
-
-        this.env = ( Hashtable ) env.clone();
+        this.nexusProxy = new ContextPartitionNexusProxy( this, service );
+        
+        ContextFactoryConfiguration cfg = service.getConfiguration();
+        
+        this.env = ( Hashtable ) cfg.getEnvironment().clone();
+        this.env.putAll( env );
 
         /* --------------------------------------------------------------------
          * check for the provider URL property and make sure it exists
@@ -96,18 +107,16 @@
         if ( ! env.containsKey( Context.PROVIDER_URL ) )
         {
             String msg = "Expected property " + Context.PROVIDER_URL;
-
             msg += " but could not find it in env!";
 
             throw new ConfigurationException( msg );
         }
 
-        url = ( String ) env.get( Context.PROVIDER_URL );
+        String url = ( String ) env.get( Context.PROVIDER_URL );
 
         if ( url == null )
         {
             String msg = "Expected value for property " + Context.PROVIDER_URL;
-
             msg += " but it was set to null in env!";
 
             throw new ConfigurationException( msg );
@@ -132,7 +141,7 @@
      * @param env the environment properties used by this context
      * @param dn the distinguished name of this context
      */
-    protected ServerContext( LdapPrincipal principal, PartitionNexus nexusProxy, Hashtable env, Name dn )
+    protected ServerContext( LdapPrincipal principal, ContextPartitionNexus nexusProxy, Hashtable env, Name dn )
     {
         this.dn = ( LdapName ) dn.clone();
 
@@ -183,7 +192,7 @@
      * 
      * @return the proxy to the backend nexus.
      */
-    protected PartitionNexus getNexusProxy()
+    protected ContextPartitionNexus getNexusProxy()
     {
        return nexusProxy ;
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java Thu Jun 23 20:08:31 2005
@@ -17,22 +17,37 @@
 package org.apache.ldap.server.jndi;
 
 
-import org.apache.ldap.common.filter.*;
-import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.common.util.NamespaceTools;
-import org.apache.ldap.server.PartitionNexus;
-import org.apache.ldap.server.authn.LdapPrincipal;
-
-import javax.naming.*;
-import javax.naming.directory.*;
-import javax.naming.ldap.Control;
-import javax.naming.spi.DirStateFactory;
-import javax.naming.spi.DirectoryManager;
 import java.io.IOException;
 import java.io.Serializable;
 import java.text.ParseException;
 import java.util.Hashtable;
 
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.ldap.Control;
+import javax.naming.spi.DirStateFactory;
+import javax.naming.spi.DirectoryManager;
+
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.FilterParser;
+import org.apache.ldap.common.filter.FilterParserImpl;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.util.NamespaceTools;
+import org.apache.ldap.server.authn.LdapPrincipal;
+import org.apache.ldap.server.partition.ContextPartitionNexus;
+
 
 /**
  * The DirContext implementation for the Server Side JNDI LDAP provider.
@@ -52,13 +67,13 @@
      * Creates a new ServerDirContext by reading the PROVIDER_URL to resolve the
      * distinguished name for this context.
      *
-     * @param nexusProxy the proxy to the backend nexus
+     * @param service the parent service that manages this context
      * @param env the environment used for this context
      * @throws NamingException if something goes wrong
      */
-    public ServerDirContext( PartitionNexus nexusProxy, Hashtable env ) throws NamingException
+    public ServerDirContext( ContextFactoryService service, Hashtable env ) throws NamingException
     {
-        super( nexusProxy, env );
+        super( service, env );
     }
 
 
@@ -71,7 +86,7 @@
      * @param env the environment properties used by this context
      * @param dn the distinguished name of this context
      */
-    protected ServerDirContext( LdapPrincipal principal, PartitionNexus nexusProxy, Hashtable env, Name dn )
+    protected ServerDirContext( LdapPrincipal principal, ContextPartitionNexus nexusProxy, Hashtable env, Name dn )
     {
         super( principal, nexusProxy, env, dn );
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirObjectFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirObjectFactory.java?rev=201550&r1=201549&r2=201550&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirObjectFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerDirObjectFactory.java Thu Jun 23 20:08:31 2005
@@ -31,7 +31,7 @@
  * looks up the most specific object factory based on this additional
  * information.  This makes a huge difference when the number of ObjectFactory
  * instances is large.
- * <br/>
+ * <p/>
  * Eventually, it is highly feasible for generated schemas, to also include
  * state and object factories for various objectClasses, or domain objects.
  * This means the number of factories will increase.  By associating object and