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/22 12:38:01 UTC

svn commit: r191792 [1/3] - in /directory/apacheds/branches/db_refactor/core: ./ src/main/aspects/ src/main/java/org/apache/ldap/server/authn/ src/main/java/org/apache/ldap/server/authz/ src/main/java/org/apache/ldap/server/exception/ src/main/java/org...

Author: trustin
Date: Wed Jun 22 03:37:56 2005
New Revision: 191792

URL: http://svn.apache.org/viewcvs?rev=191792&view=rev
Log:
* Removed InterceptorContext; now configures with ContextFactoryConfiguration and InterceptorConfiguration.
* Redesigned Interceptor to have the same methods at ContextPartitionNexus; this will help users program interceptors at most cases.
* Added InvocationStack class to extract invocation stack management code from Invocation.
* Invocation became minimal due to changes to Interceptor above.

Added:
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/InvocationStack.java   (with props)
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/BTreeSearchResult.java
      - copied, changed from r191637, directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/PartitionStoreSearchResult.java
Removed:
    directory/apacheds/branches/db_refactor/core/build.ajproperties
    directory/apacheds/branches/db_refactor/core/src/main/aspects/
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Add.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Delete.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/EntryInvocation.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/GetMatchedDN.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/GetSuffix.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/HasEntry.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/IsSuffix.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/List.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/ListSuffixes.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Lookup.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/LookupWithAttrIds.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Modify.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/ModifyMany.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/ModifyRN.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Move.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/MoveAndModifyRN.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Search.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/SubtreeInvocation.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/PartitionStoreSearchResult.java
Modified:
    directory/apacheds/branches/db_refactor/core/maven.xml
    directory/apacheds/branches/db_refactor/core/project.properties
    directory/apacheds/branches/db_refactor/core/project.xml
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorException.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/invocation/Invocation.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/ContextPartitionNexusProxy.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/jndi/ServerLdapContext.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/normalization/NormalizationService.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/ContextPartitionNexus.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/DefaultContextPartitionNexus.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/BTreeSearchResultEnumeration.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/IndexRecord.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmTable.java
    directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
    directory/apacheds/branches/db_refactor/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java

Modified: directory/apacheds/branches/db_refactor/core/maven.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/maven.xml?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/maven.xml (original)
+++ directory/apacheds/branches/db_refactor/core/maven.xml Wed Jun 22 03:37:56 2005
@@ -18,8 +18,4 @@
   <preGoal name="java:compile">
     <attainGoal name="directory:schema"/>
   </preGoal> 
- 
-  <postGoal name="java:compile">
-    <attainGoal name="aspectj:compile"/>
-  </postGoal>
 </project>

Modified: directory/apacheds/branches/db_refactor/core/project.properties
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/project.properties?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/project.properties (original)
+++ directory/apacheds/branches/db_refactor/core/project.properties Wed Jun 22 03:37:56 2005
@@ -9,13 +9,6 @@
 
 #maven.javadoc.private=true
 
-# AspectJ Properties
-# =======================
-
-#maven.aspectj.verbose=true
-#maven.aspectj.incremental=true
-maven.aspectj.time=true
-
 
 # schema class generation
 # =======================

Modified: directory/apacheds/branches/db_refactor/core/project.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/project.xml?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/project.xml (original)
+++ directory/apacheds/branches/db_refactor/core/project.xml Wed Jun 22 03:37:56 2005
@@ -76,15 +76,6 @@
       <version>0.9.1-SNAPSHOT</version>
     </dependency>
     <dependency>
-      <groupId>aspectj</groupId>
-      <artifactId>aspectjrt</artifactId>
-      <version>1.2</version>
-      <properties>
-        <gump.project>aspectj</gump.project>
-        <gump.id>aspectjrt</gump.id>
-      </properties>
-    </dependency>
-    <dependency>
       <groupId>${pom.groupId}</groupId>
       <artifactId>apacheds-shared</artifactId>
       <version>${pom.currentVersion}</version>
@@ -125,7 +116,6 @@
   </dependencies>
 
   <build>
-    <aspectSourceDirectory>${basedir}/src/main/aspects</aspectSourceDirectory>
   </build>
 
   <reports>

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java Wed Jun 22 03:37:56 2005
@@ -20,6 +20,8 @@
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
 
 
@@ -30,9 +32,8 @@
  */
 public abstract class AbstractAuthenticator implements Authenticator
 {
-
-    /** authenticator config */
-    private AuthenticatorContext ctx;
+    private ContextFactoryConfiguration factoryCfg;
+    private AuthenticatorConfiguration cfg;
 
     /** authenticator type */
     private String authenticatorType;
@@ -49,12 +50,14 @@
     }
 
 
-    /**
-     * Returns a reference to the AuthenticatorContext in which this authenticator is running.
-     */
-    public AuthenticatorContext getContext()
+    public ContextFactoryConfiguration getFactoryConfiguration()
     {
-        return ctx;
+        return factoryCfg;
+    }
+    
+    public AuthenticatorConfiguration getConfiguration()
+    {
+        return cfg;
     }
 
 
@@ -71,9 +74,10 @@
      * Called by the server to indicate to an authenticator that the authenticator
      * is being placed into service.
      */
-    public final void init( AuthenticatorContext ctx ) throws NamingException
+    public final void init( ContextFactoryConfiguration factoryCfg, AuthenticatorConfiguration cfg ) throws NamingException
     {
-        this.ctx = ctx;
+        this.factoryCfg = factoryCfg;
+        this.cfg = cfg;
         doInit();
     }
 
@@ -84,6 +88,9 @@
      */
     protected abstract void doInit();
 
+    public void destroy()
+    {
+    }
 
     /**
      * Perform the authentication operation and return the authorization id if successfull.

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java Wed Jun 22 03:37:56 2005
@@ -43,7 +43,7 @@
      */
     public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException
     {
-        if ( getContext().getRootConfiguration().isAllowAnonymousAccess() )
+        if ( getFactoryConfiguration().getConfiguration().isAllowAnonymousAccess() )
         {
             return LdapPrincipal.ANONYMOUS ;
         }

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java Wed Jun 22 03:37:56 2005
@@ -24,19 +24,25 @@
 import java.util.Map;
 
 import javax.naming.Context;
+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.exception.LdapAuthenticationException;
 import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException;
+import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.StringTools;
 import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
+import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.interceptor.Interceptor;
-import org.apache.ldap.server.interceptor.InterceptorContext;
 import org.apache.ldap.server.interceptor.NextInterceptor;
-import org.apache.ldap.server.invocation.Invocation;
+import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
-import org.apache.ldap.server.jndi.ServerLdapContext;
 
 
 /**
@@ -58,6 +64,7 @@
     /** authenticators **/
     public Map authenticators = new HashMap();
 
+    private ContextFactoryConfiguration factoryCfg;
 
     /**
      * Creates an authentication service interceptor.
@@ -66,25 +73,21 @@
     {
     }
 
-    public void init( InterceptorContext ctx ) throws NamingException
+    public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
     {
+        this.factoryCfg = factoryCfg;
+
         // Register all authenticators
-        Iterator i = ctx.getConfiguration().getAuthenticatorConfigurations().iterator();
+        Iterator i = factoryCfg.getConfiguration().getAuthenticatorConfigurations().iterator();
         while( i.hasNext() )
         {
-            try {
-                AuthenticatorConfiguration cfg = ( AuthenticatorConfiguration ) i.next();
-                
-                // Create context
-                AuthenticatorContext authenticatorContext =
-                    new GenericAuthenticatorContext( ctx.getConfiguration(), cfg, ctx.getRootNexus() );
-    
-                cfg.getAuthenticator().init( authenticatorContext );
-                
-                this.register( cfg.getAuthenticator() );
+            try
+            {
+                this.register( ( AuthenticatorConfiguration ) i.next() );
             }
             catch ( Exception e )
             {
+                destroy();
                 throw ( NamingException ) new NamingException(
                         "Failed to register authenticator." ).initCause( e );
             }
@@ -93,6 +96,16 @@
     
     public void destroy()
     {
+        Iterator i = new ArrayList( authenticators.values() ).iterator();
+        while( i.hasNext() )
+        {
+            Iterator j = new ArrayList( ( Collection ) i.next() ).iterator();
+            while( j.hasNext() )
+            {
+                unregister( ( Authenticator ) j.next() );
+            }
+        }
+        
         authenticators.clear();
     }
 
@@ -100,22 +113,19 @@
      * Registers an AuthenticationService with the AuthenticationService.  Called by each
      * AuthenticationService implementation after it has started to register for
      * authentication operation calls.
-     *
-     * @param authenticator AuthenticationService component to register with this
-     * AuthenticatorService.
      */
-    public void register( Authenticator authenticator )
+    private void register( AuthenticatorConfiguration cfg ) throws NamingException
     {
-        Collection authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
+        cfg.getAuthenticator().init( factoryCfg, cfg );
 
+        Collection authenticatorList = getAuthenticators( cfg.getAuthenticator().getAuthenticatorType() );
         if ( authenticatorList == null )
         {
             authenticatorList = new ArrayList();
-
-            authenticators.put( authenticator.getAuthenticatorType(), authenticatorList );
+            authenticators.put( cfg.getAuthenticator().getAuthenticatorType(), authenticatorList );
         }
 
-        authenticatorList.add( authenticator );
+        authenticatorList.add( cfg.getAuthenticator() );
     }
 
     /**
@@ -127,7 +137,7 @@
      * @param authenticator AuthenticationService component to unregister with this
      * AuthenticationService.
      */
-    public void unregister( org.apache.ldap.server.authn.Authenticator authenticator )
+    private void unregister( Authenticator authenticator )
     {
         Collection authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
 
@@ -137,6 +147,15 @@
         }
 
         authenticatorList.remove( authenticator );
+        
+        try
+        {
+            authenticator.destroy();
+        }
+        catch( Throwable t )
+        {
+            t.printStackTrace();
+        }
     }
 
     /**
@@ -145,16 +164,137 @@
      * @param type the authentication type
      * @return the authenticators with the specified type
      */
-    public Collection getAuthenticators( String type )
+    private Collection getAuthenticators( String type )
     {
         return ( Collection ) authenticators.get( type );
     }
     
-    public void process( NextInterceptor nextProcessor, Invocation call ) throws NamingException
+
+    public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
+    {
+        authenticate();
+        next.add( upName, normName, entry );
+    }
+
+
+    public void delete( NextInterceptor next, Name name ) throws NamingException
+    {
+        authenticate();
+        next.delete( name );
+    }
+
+
+    public Name getMatchedDn( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
+    {
+        authenticate();
+        return next.getMatchedDn( dn, normalized );
+    }
+
+
+    public Attributes getRootDSE( NextInterceptor next ) throws NamingException
+    {
+        authenticate();
+        return next.getRootDSE();
+    }
+
+
+    public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
+    {
+        authenticate();
+        return next.getSuffix( dn, normalized );
+    }
+
+
+    public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
+    {
+        authenticate();
+        return next.hasEntry( name );
+    }
+
+
+    public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
+    {
+        authenticate();
+        return next.isSuffix( name );
+    }
+
+
+    public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
+    {
+        authenticate();
+        return next.list( base );
+    }
+
+
+    public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
+    {
+        authenticate();
+        return next.listSuffixes( normalized );
+    }
+
+
+    public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
+    {
+        authenticate();
+        return next.lookup( dn, attrIds );
+    }
+
+
+    public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
+    {
+        authenticate();
+        return next.lookup( name );
+    }
+
+
+    public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
+    {
+        authenticate();
+        next.modify( name, modOp, mods );
+    }
+
+
+    public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
+    {
+        authenticate();
+        next.modify( name, mods );
+    }
+
+
+    public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
+    {
+        authenticate();
+        next.modifyRn( name, newRn, deleteOldRn );
+    }
+
+
+    public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+    {
+        authenticate();
+        next.move( oriChildName, newParentName, newRn, deleteOldRn );
+    }
+
+
+    public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
+    {
+        authenticate();
+        next.move( oriChildName, newParentName );
+    }
+
+
+    public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
+    {
+        authenticate();
+        return next.search( base, env, filter, searchCtls );
+    }
+
+
+    private void authenticate() throws NamingException
     {
         // check if we are already authenticated and if so we return making
         // sure first that the credentials are not exposed within context
-        ServerContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
+        ServerContext ctx =
+            ( ServerContext ) InvocationStack.getInstance().peek().getTarget();
 
         if ( ctx.getPrincipal() != null )
         {
@@ -162,9 +302,6 @@
             {
                 ctx.removeFromEnvironment( CREDS );
             }
-
-            nextProcessor.process(call);
-
             return;
         }
 
@@ -232,9 +369,6 @@
                 // remove creds so there is no security risk
 
                 ctx.removeFromEnvironment( CREDS );
-
-                nextProcessor.process(call);
-
                 return;
             }
             catch ( LdapAuthenticationException e )

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java Wed Jun 22 03:37:56 2005
@@ -19,6 +19,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
 
 
@@ -38,12 +40,15 @@
 {
     public String getAuthenticatorType();
     
-    public AuthenticatorContext getContext();
-
     /**
      * Called by the authenticator container to indicate that the authenticator is being placed into service.
      */
-    public void init( AuthenticatorContext ctx ) throws NamingException;
+    public void init( ContextFactoryConfiguration factoryCfg, AuthenticatorConfiguration cfg ) throws NamingException;
+    
+    /**
+     * Called by the authenticator container to indicate that the authenticator is being removed from service.
+     */
+    public void destroy();
 
     /**
      * Perform the authentication operation and return the authorization id if successfull.

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java Wed Jun 22 03:37:56 2005
@@ -18,8 +18,7 @@
 
 
 import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
-import org.apache.ldap.server.configuration.StartupConfiguration;
-import org.apache.ldap.server.partition.ContextPartitionNexus;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 
 
 /**
@@ -35,15 +34,10 @@
     /**
      * Returns root configuration.
      */
-    public StartupConfiguration getRootConfiguration();
+    public ContextFactoryConfiguration getFactoryConfiguration();
 
     /**
      * Returns configuration of the {@link Authenticator}.
      */
     public AuthenticatorConfiguration getConfiguration();
-
-    /**
-     * Returns {@link ContextPartitionNexus}.
-     */
-    public ContextPartitionNexus getPartitionNexus();
 }

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java Wed Jun 22 03:37:56 2005
@@ -18,8 +18,7 @@
 
 
 import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
-import org.apache.ldap.server.configuration.StartupConfiguration;
-import org.apache.ldap.server.partition.ContextPartitionNexus;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 
 
 /**
@@ -30,36 +29,27 @@
  */
 public class GenericAuthenticatorContext implements AuthenticatorContext
 {
-    private StartupConfiguration rootConfiguration;
+    private ContextFactoryConfiguration factoryConfiguration;
     private AuthenticatorConfiguration configuration;
-    /** the root nexus to all database partitions */
-    private ContextPartitionNexus partitionNexus;
 
     /**
      * Create a new AuthenticatorContext.
      */
     public GenericAuthenticatorContext(
-            StartupConfiguration rootConfiguration,
-            AuthenticatorConfiguration configuration,
-            ContextPartitionNexus partitionNexus )
+            ContextFactoryConfiguration factoryConfiguration,
+            AuthenticatorConfiguration configuration )
     {
-        this.rootConfiguration = rootConfiguration;
+        this.factoryConfiguration = factoryConfiguration;
         this.configuration = configuration;
-        this.partitionNexus = partitionNexus;
     }
     
-    public StartupConfiguration getRootConfiguration()
+    public ContextFactoryConfiguration getFactoryConfiguration()
     {
-        return rootConfiguration;
+        return factoryConfiguration;
     }
     
     public AuthenticatorConfiguration getConfiguration()
     {
         return configuration;
-    }
-
-    public ContextPartitionNexus getPartitionNexus()
-    {
-        return partitionNexus;
     }
 }

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java Wed Jun 22 03:37:56 2005
@@ -93,9 +93,8 @@
 
         LdapName principalDn = new LdapName( principal );
 
-        ContextPartitionNexus rootNexus = getContext().getPartitionNexus();
-
-        Attributes userEntry = rootNexus.lookup( principalDn );
+        ContextPartitionNexus nexus = getFactoryConfiguration().getPartitionNexus();
+        Attributes userEntry = nexus.lookup( principalDn );
 
         if ( userEntry == null )
         {

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java Wed Jun 22 03:37:56 2005
@@ -17,33 +17,27 @@
 package org.apache.ldap.server.authz;
 
 
+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 javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.name.DnParser;
+import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.enumeration.ResultFilteringEnumeration;
 import org.apache.ldap.server.enumeration.SearchResultFilter;
 import org.apache.ldap.server.interceptor.BaseInterceptor;
-import org.apache.ldap.server.interceptor.InterceptorContext;
 import org.apache.ldap.server.interceptor.NextInterceptor;
-import org.apache.ldap.server.invocation.Delete;
-import org.apache.ldap.server.invocation.HasEntry;
-import org.apache.ldap.server.invocation.Invocation;
-import org.apache.ldap.server.invocation.List;
-import org.apache.ldap.server.invocation.Lookup;
-import org.apache.ldap.server.invocation.LookupWithAttrIds;
-import org.apache.ldap.server.invocation.Modify;
-import org.apache.ldap.server.invocation.ModifyMany;
-import org.apache.ldap.server.invocation.ModifyRN;
-import org.apache.ldap.server.invocation.Move;
-import org.apache.ldap.server.invocation.MoveAndModifyRN;
-import org.apache.ldap.server.invocation.Search;
+import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
 import org.apache.ldap.server.partition.ContextPartition;
 import org.apache.ldap.server.partition.ContextPartitionNexus;
@@ -91,9 +85,9 @@
     }
 
 
-    public void init( InterceptorContext ctx ) throws NamingException
+    public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
     {
-        AttributeTypeRegistry atr = ctx.getGlobalRegistries().getAttributeTypeRegistry();
+        AttributeTypeRegistry atr = factoryCfg.getGlobalRegistries().getAttributeTypeRegistry();
         dnParser = new DnParser( new ConcreteNameComponentNormalizer( atr ) );
     }
 
@@ -103,19 +97,13 @@
     }
 
 
-    public void process( NextInterceptor nextInterceptor, Invocation call ) throws NamingException
-    {
-        super.process( nextInterceptor, call );
-    }
-
     // Note:
     //    Lookup, search and list operations need to be handled using a filter
     // and so we need access to the filter service.
 
-    protected void process( NextInterceptor nextInterceptor, Delete call ) throws NamingException
+    public void delete( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
-        Name name = call.getName();
-        Name principalDn = getPrincipal( call ).getDn();
+        Name principalDn = getPrincipal().getDn();
 
         if ( name.toString().equals( "" ) )
         {
@@ -149,7 +137,7 @@
             throw new LdapNoPermissionException( msg );
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.delete( name );
     }
 
 
@@ -159,9 +147,9 @@
      * the provider for optimization purposes so there is no reason for us to
      * start to constrain it.
      */
-    protected void process( NextInterceptor nextInterceptor, HasEntry call ) throws NamingException
+    public boolean hasEntry( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
-        super.process( nextInterceptor, call );
+        return super.hasEntry( nextInterceptor, name );
     }
 
 
@@ -176,10 +164,10 @@
      * users to self access these resources.  As far as we're concerned no one but
      * the admin needs access.
      */
-    protected void process( NextInterceptor nextInterceptor, Modify call ) throws NamingException
+    public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs ) throws NamingException
     {
-        protectModifyAlterations( call, call.getName() );
-        nextInterceptor.process( call );
+        protectModifyAlterations( name );
+        nextInterceptor.modify( name, modOp, attrs );
     }
 
 
@@ -189,16 +177,16 @@
      * self access these resources.  As far as we're concerned no one but the admin
      * needs access.
      */
-    protected void process( NextInterceptor nextInterceptor, ModifyMany call ) throws NamingException
+    public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
     {
-        protectModifyAlterations( call, call.getName() );
-        nextInterceptor.process( call );
+        protectModifyAlterations( name );
+        nextInterceptor.modify( name, items );
     }
 
 
-    private void protectModifyAlterations( Invocation call, Name dn ) throws LdapNoPermissionException
+    private void protectModifyAlterations( Name dn ) throws LdapNoPermissionException
     {
-        Name principalDn = getPrincipal( call ).getDn();
+        Name principalDn = getPrincipal().getDn();
 
         if ( dn.toString().equals( "" ) )
         {
@@ -246,30 +234,32 @@
     // ------------------------------------------------------------------------
 
 
-    protected void process( NextInterceptor nextInterceptor, ModifyRN call ) throws NamingException
+    public void modifyRn( NextInterceptor nextInterceptor, Name name, String newRn, boolean deleteOldRn ) throws NamingException
     {
-        protectDnAlterations( call, call.getName() );
-        nextInterceptor.process( call );
+        protectDnAlterations( name );
+        nextInterceptor.modifyRn( name, newRn, deleteOldRn );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Move call ) throws NamingException
+    public void move( NextInterceptor nextInterceptor, Name oriChildName, Name newParentName ) throws NamingException
     {
-        protectDnAlterations( call, call.getName() );
-        nextInterceptor.process( call );
+        protectDnAlterations( oriChildName );
+        nextInterceptor.move( oriChildName, newParentName );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) throws NamingException
+    public void move( NextInterceptor nextInterceptor,
+            Name oriChildName, Name newParentName, String newRn,
+            boolean deleteOldRn ) throws NamingException
     {
-        protectDnAlterations( call, call.getName() );
-        nextInterceptor.process( call );
+        protectDnAlterations( oriChildName );
+        nextInterceptor.move( oriChildName, newParentName, newRn, deleteOldRn );
     }
 
 
-    private void protectDnAlterations( Invocation call, Name dn ) throws LdapNoPermissionException
+    private void protectDnAlterations( Name dn ) throws LdapNoPermissionException
     {
-        Name principalDn = getPrincipal( call ).getDn();
+        Name principalDn = getPrincipal().getDn();
 
         if ( dn.toString().equals( "" ) )
         {
@@ -305,42 +295,36 @@
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Lookup call ) throws NamingException
+    public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
-        super.process( nextInterceptor, call );
-
-        Attributes attributes = ( Attributes ) call.getReturnValue();
+        Attributes attributes = nextInterceptor.lookup( name );
         if ( attributes == null )
         {
-            return;
+            return null;
         }
 
-        Attributes retval = ( Attributes ) attributes.clone();
-        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
-        protectLookUp( ctx, call.getName() );
-        call.setReturnValue( retval );
+        protectLookUp( name );
+        return attributes;
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
+    public Attributes lookup( NextInterceptor nextInterceptor, Name name, String[] attrIds ) throws NamingException
     {
-        super.process( nextInterceptor, call );
-
-        Attributes attributes = ( Attributes ) call.getReturnValue();
+        Attributes attributes = nextInterceptor.lookup( name, attrIds );
         if ( attributes == null )
         {
-            return;
+            return null;
         }
 
-        Attributes retval = ( Attributes ) attributes.clone();
-        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
-        protectLookUp( ctx, call.getName() );
-        call.setReturnValue( retval );
+        protectLookUp( name );
+        return attributes;
     }
 
 
-    private void protectLookUp( LdapContext ctx, Name dn ) throws NamingException
+    private void protectLookUp( Name dn ) throws NamingException
     {
+        LdapContext ctx =
+            ( LdapContext ) InvocationStack.getInstance().peek().getTarget();
         Name principalDn = ( ( ServerContext ) ctx ).getPrincipal().getDn();
 
         if ( !principalDn.equals( ADMIN_DN ) )
@@ -390,21 +374,19 @@
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
-    {
-        super.process( nextInterceptor, call );
-
-        SearchControls searchControls = call.getControls();
-        if ( searchControls.getReturningAttributes() != null )
-        {
-            return;
-        }
-
-        NamingEnumeration e;
-        ResultFilteringEnumeration retval;
-        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
-        e = ( NamingEnumeration ) call.getReturnValue();
-        retval = new ResultFilteringEnumeration( e, searchControls, ctx,
+    public NamingEnumeration search( NextInterceptor nextInterceptor,
+            Name base, Map env, ExprNode filter,
+            SearchControls searchCtls ) throws NamingException
+    {
+        NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
+        //if ( searchCtls.getReturningAttributes() != null )
+        //{
+        //    return null;
+        //}
+        
+        LdapContext ctx =
+            ( LdapContext ) InvocationStack.getInstance().peek().getTarget();
+        return new ResultFilteringEnumeration( e, searchCtls, ctx,
                 new SearchResultFilter()
                 {
                     public boolean accept( LdapContext ctx, SearchResult result,
@@ -414,20 +396,16 @@
                         return AuthorizationService.this.isSearchable( ctx, result );
                     }
                 } );
-
-        call.setReturnValue( retval );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
+    public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException
     {
-        super.process( nextInterceptor, call );
-
-        NamingEnumeration e;
-        ResultFilteringEnumeration retval;
-        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
-        e = ( NamingEnumeration ) call.getReturnValue();
-        retval = new ResultFilteringEnumeration( e, null, ctx,
+        NamingEnumeration e = nextInterceptor.list( base );
+        LdapContext ctx =
+            ( LdapContext ) InvocationStack.getInstance().peek().getTarget();
+        
+        return new ResultFilteringEnumeration( e, null, ctx,
             new SearchResultFilter()
             {
                 public boolean accept( LdapContext ctx, SearchResult result,
@@ -437,8 +415,6 @@
                     return AuthorizationService.this.isSearchable( ctx, result );
                 }
             } );
-
-        call.setReturnValue( retval );
     }
 
 

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java Wed Jun 22 03:37:56 2005
@@ -17,32 +17,27 @@
 package org.apache.ldap.server.exception;
 
 
+import java.util.Map;
+
 import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
 
 import org.apache.ldap.common.exception.LdapContextNotEmptyException;
 import org.apache.ldap.common.exception.LdapNameAlreadyBoundException;
 import org.apache.ldap.common.exception.LdapNameNotFoundException;
 import org.apache.ldap.common.exception.LdapNamingException;
+import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.interceptor.BaseInterceptor;
-import org.apache.ldap.server.interceptor.InterceptorContext;
 import org.apache.ldap.server.interceptor.NextInterceptor;
-import org.apache.ldap.server.invocation.Add;
-import org.apache.ldap.server.invocation.Delete;
-import org.apache.ldap.server.invocation.List;
-import org.apache.ldap.server.invocation.Lookup;
-import org.apache.ldap.server.invocation.LookupWithAttrIds;
-import org.apache.ldap.server.invocation.Modify;
-import org.apache.ldap.server.invocation.ModifyMany;
-import org.apache.ldap.server.invocation.ModifyRN;
-import org.apache.ldap.server.invocation.Move;
-import org.apache.ldap.server.invocation.MoveAndModifyRN;
-import org.apache.ldap.server.invocation.Search;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.partition.ContextPartition;
 import org.apache.ldap.server.partition.ContextPartitionNexus;
 
@@ -72,9 +67,9 @@
     }
 
 
-    public void init( InterceptorContext ctx )
+    public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg )
     {
-        this.nexus = ctx.getRootNexus();
+        this.nexus = factoryCfg.getPartitionNexus();
     }
 
 
@@ -87,11 +82,9 @@
      * In the pre-invocation state this interceptor method checks to see if the entry to be added already exists.  If it
      * does an exception is raised.
      */
-    protected void process( NextInterceptor nextInterceptor, Add call ) throws NamingException
+    public void add( NextInterceptor nextInterceptor, String upName, Name normName, Attributes entry ) throws NamingException
     {
         // check if the entry already exists
-        Name normName = call.getName();
-        String upName = call.getUserProvidedName();
         if ( nexus.hasEntry( normName ) )
         {
             NamingException ne = new LdapNameAlreadyBoundException();
@@ -118,7 +111,7 @@
             throw e;
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.add( upName, normName, entry );
     }
 
 
@@ -126,10 +119,8 @@
      * Checks to make sure the entry being deleted exists, and has no children, otherwise throws the appropriate
      * LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, Delete call ) throws NamingException
+    public void delete( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
-        Name name = call.getName();
-        
         // check if entry to delete exists
         String msg = "Attempt to delete non-existant entry: ";
         assertHasEntry( msg, name );
@@ -150,88 +141,85 @@
             throw e;
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.delete( name );
     }
 
 
     /**
      * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
+    public NamingEnumeration list( NextInterceptor nextInterceptor, Name baseName ) throws NamingException
     {
         // check if entry to search exists
         String msg = "Attempt to search under non-existant entry: ";
-        assertHasEntry( msg, call.getBaseName() );
+        assertHasEntry( msg, baseName );
 
-        nextInterceptor.process( call );
+        return nextInterceptor.list( baseName );
     }
 
 
     /**
      * Checks to make sure the entry being looked up exists other wise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, Lookup call ) throws NamingException
+    public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
         String msg = "Attempt to lookup non-existant entry: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, name );
 
-        nextInterceptor.process( call );
+        return nextInterceptor.lookup( name );
     }
 
 
     /**
      * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
+    public Attributes lookup( NextInterceptor nextInterceptor, Name name, String[] attrIds ) throws NamingException
     {
         // check if entry to lookup exists
         String msg = "Attempt to lookup non-existant entry: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, name );
 
-        nextInterceptor.process( call );
+        return nextInterceptor.lookup( name, attrIds );
     }
 
 
     /**
      * Checks to see the entry being modified exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, Modify call ) throws NamingException
+    public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs ) throws NamingException
     {
         // check if entry to modify exists
         String msg = "Attempt to modify non-existant entry: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, name );
 
-        nextInterceptor.process( call );
+        nextInterceptor.modify( name, modOp, attrs );
     }
 
 
     /**
      * Checks to see the entry being modified exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, ModifyMany call ) throws NamingException
+    public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
     {
         // check if entry to modify exists
         String msg = "Attempt to modify non-existant entry: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, name );
 
-        nextInterceptor.process( call );
+        nextInterceptor.modify( name, items );
     }
 
 
     /**
      * Checks to see the entry being renamed exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, ModifyRN call ) throws NamingException
+    public void modifyRn( NextInterceptor nextInterceptor, Name dn, String newRn, boolean deleteOldRn ) throws NamingException
     {
-        Name dn = call.getName();
-        String newRdn = call.getNewRelativeName();
-        
         // check if entry to rename exists
         String msg = "Attempt to rename non-existant entry: ";
         assertHasEntry( msg, dn );
 
         // check to see if target entry exists
-        Name target = dn.getSuffix( 1 ).add( newRdn );
+        Name target = dn.getSuffix( 1 ).add( newRn );
         if ( nexus.hasEntry( target ) )
         {
             LdapNameAlreadyBoundException e = null;
@@ -241,7 +229,7 @@
             throw e;
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.modifyRn( dn, newRn, deleteOldRn );
     }
 
 
@@ -249,19 +237,19 @@
      * Checks to see the entry being moved exists, and so does its parent, otherwise throws the appropriate
      * LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, Move call ) throws NamingException
+    public void move( NextInterceptor nextInterceptor, Name oriChildName, Name newParentName ) throws NamingException
     {
         // check if child to move exists
         String msg = "Attempt to move to non-existant parent: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, oriChildName );
 
         // check if parent to move to exists
         msg = "Attempt to move to non-existant parent: ";
-        assertHasEntry( msg, call.getNewParentName() );
+        assertHasEntry( msg, newParentName );
 
         // check to see if target entry exists
-        String rdn = call.getName().get( call.getName().size() - 1 );
-        Name target = ( Name ) call.getNewParentName().clone();
+        String rdn = oriChildName.get( oriChildName.size() - 1 );
+        Name target = ( Name ) newParentName.clone();
         target.add( rdn );
         if ( nexus.hasEntry( target ) )
         {
@@ -272,7 +260,7 @@
             throw e;
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.move( oriChildName, newParentName );
     }
 
 
@@ -280,19 +268,21 @@
      * Checks to see the entry being moved exists, and so does its parent, otherwise throws the appropriate
      * LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) throws NamingException
+    public void move( NextInterceptor nextInterceptor,
+            Name oriChildName, Name newParentName, String newRn,
+            boolean deleteOldRn ) throws NamingException
     {
         // check if child to move exists
         String msg = "Attempt to move to non-existant parent: ";
-        assertHasEntry( msg, call.getName() );
+        assertHasEntry( msg, oriChildName );
 
         // check if parent to move to exists
         msg = "Attempt to move to non-existant parent: ";
-        assertHasEntry( msg, call.getNewParentName() );
+        assertHasEntry( msg, newParentName );
 
         // check to see if target entry exists
-        Name target = ( Name ) call.getNewParentName().clone();
-        target.add( call.getNewRelativeName() );
+        Name target = ( Name ) newParentName.clone();
+        target.add( newRn );
         if ( nexus.hasEntry( target ) )
         {
             LdapNameAlreadyBoundException e = null;
@@ -302,34 +292,33 @@
             throw e;
         }
 
-        nextInterceptor.process( call );
+        nextInterceptor.move( oriChildName, newParentName, newRn, deleteOldRn );
     }
 
 
     /**
      * Checks to see the entry being searched exists, otherwise throws the appropriate LdapException.
      */
-    protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
+    public NamingEnumeration search( NextInterceptor nextInterceptor, 
+            Name base, Map env, ExprNode filter,
+            SearchControls searchCtls ) throws NamingException
     {
         String msg = "Attempt to search under non-existant entry: ";
 
-        Name base = call.getBaseName();
         if ( base.size() == 0 )
         {
-            nextInterceptor.process( call );
-            return;
+            return nextInterceptor.search( base, env, filter, searchCtls );
         }
 
         Attribute attr = nexus.getRootDSE().get( "subschemaSubentry" );
         if ( ( ( String ) attr.get() ).equalsIgnoreCase( base.toString() ) )
         {
-            nextInterceptor.process( call );
-            return;
+            return nextInterceptor.search( base, env, filter, searchCtls );
         }
 
         assertHasEntry( msg, base );
 
-        nextInterceptor.process( call );
+        return nextInterceptor.search( base, env, filter, searchCtls );
     }
 
 

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java Wed Jun 22 03:37:56 2005
@@ -17,26 +17,23 @@
 package org.apache.ldap.server.interceptor;
 
 
+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 javax.naming.ldap.LdapContext;
 
+import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.server.authn.LdapPrincipal;
-import org.apache.ldap.server.invocation.Add;
-import org.apache.ldap.server.invocation.Delete;
-import org.apache.ldap.server.invocation.GetMatchedDN;
-import org.apache.ldap.server.invocation.GetSuffix;
-import org.apache.ldap.server.invocation.HasEntry;
+import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.invocation.Invocation;
-import org.apache.ldap.server.invocation.IsSuffix;
-import org.apache.ldap.server.invocation.List;
-import org.apache.ldap.server.invocation.ListSuffixes;
-import org.apache.ldap.server.invocation.Lookup;
-import org.apache.ldap.server.invocation.LookupWithAttrIds;
-import org.apache.ldap.server.invocation.Modify;
-import org.apache.ldap.server.invocation.ModifyMany;
-import org.apache.ldap.server.invocation.ModifyRN;
-import org.apache.ldap.server.invocation.Move;
-import org.apache.ldap.server.invocation.MoveAndModifyRN;
-import org.apache.ldap.server.invocation.Search;
+import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.jndi.ServerContext;
 
 
@@ -73,11 +70,16 @@
      *
      * @return the principal making the call
      */
-    public static LdapPrincipal getPrincipal( Invocation call )
+    public static LdapPrincipal getPrincipal()
     {
-        ServerContext ctx = ( ServerContext ) call.getContextStack().peek();
+        ServerContext ctx = ( ServerContext ) getContext();
         return ctx.getPrincipal();
     }
+    
+    public static LdapContext getContext()
+    {
+        return ( LdapContext ) InvocationStack.getInstance().peek().getTarget();
+    }
 
 
     protected BaseInterceptor()
@@ -85,185 +87,118 @@
     }
 
 
-    // ------------------------------------------------------------------------
-    // Interceptor's Invoke Method
-    // ------------------------------------------------------------------------
+    public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
+    {
+    }
 
-    /**
-     * Uses a switch on the invocation method type to call the respective member
-     * analog method that does the work of the Interceptor for that Invocation method.
-     */
-    public void process( NextInterceptor nextInterceptor, Invocation call )
-            throws NamingException
+
+    public void destroy()
     {
-        if ( call instanceof Add )
-        {
-            process( nextInterceptor, ( Add ) call );
-        }
-        else if ( call instanceof Delete )
-        {
-            process( nextInterceptor, ( Delete ) call );
-        }
-        else if ( call instanceof GetMatchedDN )
-        {
-            process( nextInterceptor, ( GetMatchedDN ) call );
-        }
-        else if ( call instanceof GetSuffix )
-        {
-            process( nextInterceptor, ( GetSuffix ) call );
-        }
-        else if ( call instanceof HasEntry )
-        {
-            process( nextInterceptor, ( HasEntry ) call );
-        }
-        else if ( call instanceof IsSuffix )
-        {
-            process( nextInterceptor, ( IsSuffix ) call );
-        }
-        else if ( call instanceof List )
-        {
-            process( nextInterceptor, ( List ) call );
-        }
-        else if ( call instanceof ListSuffixes )
-        {
-            process( nextInterceptor, ( ListSuffixes ) call );
-        }
-        else if ( call instanceof Lookup )
-        {
-            process( nextInterceptor, ( Lookup ) call );
-        }
-        else if ( call instanceof LookupWithAttrIds )
-        {
-            process( nextInterceptor, ( LookupWithAttrIds ) call );
-        }
-        else if ( call instanceof Modify )
-        {
-            process( nextInterceptor, ( Modify ) call );
-        }
-        else if ( call instanceof ModifyMany )
-        {
-            process( nextInterceptor, ( ModifyMany ) call );
-        }
-        else if ( call instanceof ModifyRN )
-        {
-            process( nextInterceptor, ( ModifyRN ) call );
-        }
-        else if ( call instanceof Move )
-        {
-            process( nextInterceptor, ( Move ) call );
-        }
-        else if ( call instanceof MoveAndModifyRN )
-        {
-            process( nextInterceptor, ( MoveAndModifyRN ) call );
-        }
-        else if ( call instanceof Search )
-        {
-            process( nextInterceptor, ( Search ) call );
-        }
-        else
-        {
-            throw new IllegalArgumentException( "Unknown call type: " + call.getClass() );
-        }
     }
 
 
     // ------------------------------------------------------------------------
-    // Invocation Analogs
+    // Interceptor's Invoke Method
     // ------------------------------------------------------------------------
 
+    public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
+    {
+        next.add( upName, normName, entry );
+    }
+
 
-    protected void process( NextInterceptor nextInterceptor, Add call ) throws NamingException
+    public void delete( NextInterceptor next, Name name ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.delete( name );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Delete call ) throws NamingException
+    public Name getMatchedDn( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.getMatchedDn( dn, normalized );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, GetMatchedDN call ) throws NamingException
+    public Attributes getRootDSE( NextInterceptor next ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.getRootDSE();
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, GetSuffix call ) throws NamingException
+    public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.getSuffix( dn, normalized );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, HasEntry call ) throws NamingException
+    public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.hasEntry( name );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, IsSuffix call ) throws NamingException
+    public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.isSuffix( name );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, List call ) throws NamingException
+    public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.list( base );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, ListSuffixes call ) throws NamingException
+    public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.listSuffixes( normalized );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Lookup call ) throws NamingException
+    public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.lookup( dn, attrIds );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) throws NamingException
+    public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.lookup( name );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Modify call ) throws NamingException
+    public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.modify( name, modOp, mods );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, ModifyMany call ) throws NamingException
+    public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.modify( name, mods );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, ModifyRN call ) throws NamingException
+    public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.modifyRn( name, newRn, deleteOldRn );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Move call ) throws NamingException
+    public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.move( oriChildName, newParentName, newRn, deleteOldRn );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) throws NamingException
+    public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
     {
-        nextInterceptor.process( call );
+        next.move( oriChildName, newParentName );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
+    public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
     {
-        nextInterceptor.process( call );
+        return next.search( base, env, filter, searchCtls );
     }
 }

Modified: directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java?rev=191792&r1=191791&r2=191792&view=diff
==============================================================================
--- directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java (original)
+++ directory/apacheds/branches/db_refactor/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java Wed Jun 22 03:37:56 2005
@@ -17,10 +17,21 @@
 package org.apache.ldap.server.interceptor;
 
 
+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;
+import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.ldap.server.invocation.Invocation;
+import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
 import org.apache.ldap.server.partition.ContextPartition;
 
 
@@ -99,7 +110,7 @@
      * @param context the configuration properties for this interceptor
      * @throws NamingException if failed to initialize this interceptor
      */
-    void init( InterceptorContext context ) throws NamingException;
+    void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException;
 
 
     /**
@@ -108,15 +119,23 @@
      */
     void destroy();
 
-
-    /**
-     * Filters a particular invocation.  You can pass control to
-     * <code>nextInterceptor</code> by calling {@link NextInterceptor#process(
-     * org.apache.ldap.server.invocation.Invocation)}
-     *
-     * @param nextInterceptor the next interceptor in the interceptor chain
-     * @param invocation      the invocation to process
-     * @throws NamingException on failures while handling the invocation
-     */
-    void process( NextInterceptor nextInterceptor, Invocation invocation ) throws NamingException;
+    Attributes getRootDSE( NextInterceptor next ) throws NamingException; 
+    Name getMatchedDn( NextInterceptor next, Name dn, boolean normalized ) throws NamingException;
+    Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException;
+    Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException;
+    void delete( NextInterceptor next, Name name ) throws NamingException;
+    void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException;
+    void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException;
+    void modify( NextInterceptor next, Name name, ModificationItem [] mods ) throws NamingException;
+    NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException;
+    NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter,
+                              SearchControls searchCtls ) throws NamingException;
+    Attributes lookup( NextInterceptor next, Name name ) throws NamingException;
+    Attributes lookup( NextInterceptor next, Name dn, String [] attrIds ) throws NamingException;
+    boolean hasEntry( NextInterceptor next, Name name ) throws NamingException;
+    boolean isSuffix( NextInterceptor next, Name name ) throws NamingException;
+    void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException;
+    void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException;
+    void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn,
+               boolean deleteOldRn ) throws NamingException;
 }