directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 43385 - incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus
Date Sun, 05 Sep 2004 09:15:32 GMT
Author: niclas
Date: Sun Sep  5 02:15:31 2004
New Revision: 43385

Added:
   incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusComponent.java
      - copied, changed from rev 43384, incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusModule.java
Removed:
   incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusModule.java
Log:
Better name for the component, and ripped out the superclass' content.

Copied: incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusComponent.java
(from rev 43384, incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusModule.java)
==============================================================================
--- incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusModule.java
(original)
+++ incubator/directory/sandbox/trunk/store/nexus-metro/src/java/org/apache/ldap/metro/store/nexus/NexusComponent.java
Sun Sep  5 02:15:31 2004
@@ -23,344 +23,45 @@
  * -- any LDAPd project for copyright and distribution information.      --
  *
  */
-package org.apache.ldap.store.nexus;
-
-import java.util.Collections ;
-import java.util.HashMap ;
-import java.util.Hashtable ;
-import java.util.Iterator ;
-
-import javax.naming.Name ;
-import javax.naming.NameNotFoundException ;
-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.Control ;
-import javax.naming.ldap.LdapContext ;
+package org.apache.ldap.metro.store.nexus;
 
 import org.apache.avalon.framework.service.Serviceable ;
 import org.apache.avalon.framework.service.ServiceManager ;
 import org.apache.avalon.framework.service.ServiceException ;
 
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.NotImplementedException ;
-
-import org.apache.ldap.store.api.BackendNexus ;
 import org.apache.ldap.store.api.AtomicBackend ;
 
+import org.apache.ldap.store.nexus.NexusModule;
 
 /**
- * BackendNexus implementing LDAPd Module.
+ * Metro component for the Nexus implementation.
  *
  * @avalon.component name="backend-nexus" lifestyle="singleton"
- * @avalon.service type="org.apache.ldap.server.nexus.BackendNexus" 
+ * @avalon.service type="org.apache.ldap.store.api.BackendNexus" 
  * version="1.0"
  * 
  * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
  * @author $Author: akarasulu $
  * @version $Revision: 1.8 $
  */
-public class NexusComponent extends org.apache.ldap.store.nexus.NexusModule
-    implements BackendNexus, Serviceable
+public class NexusComponent extends NexusModule
+    implements Serviceable
 {
-    /** Handle on the singleton instance of this class within the entire JVM. */
-    private static NexusModule s_singleton = null ;
-    
-    /** the system backend */
-    private AtomicBackend m_system ;
-    /** the backends keyed by normalized suffix strings */
-    private HashMap m_backends = new HashMap() ;
-    
-    
+
     /**
      * Default constructor that checks to make sure that there is only one
      * instance of this class within the entire JVM.
      */
-    public NexusModule()
-    {
-        if ( null != s_singleton )
-        {
-            throw new IllegalStateException() ;
-        }
-        
-        s_singleton = this ;
-    }
-    
-
-    // ------------------------------------------------------------------------
-    // BackendNexus Interface Method Implementations
-    // ------------------------------------------------------------------------
-    
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#getLdapContext()
-     */
-    public LdapContext getLdapContext() 
-    {
-        throw new NotImplementedException() ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#getMatchedDn(javax.naming.Name, 
-     * boolean)
-     */
-    public Name getMatchedDn( Name a_dn, boolean a_normalized )
-        throws NamingException 
-    {
-        throw new NotImplementedException() ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#getSuffix(javax.naming.Name, 
-     * boolean)
-     */
-    public Name getSuffix( Name a_dn, boolean a_normalized )
-        throws NamingException
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        return l_backend.getSuffix( a_normalized ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#listSuffixes(boolean)
-     */
-    public Iterator listSuffixes( boolean a_normalized ) 
-        throws NamingException 
-    {
-        return Collections.unmodifiableSet( m_backends.keySet() ).iterator() ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#getRootDSE()
-     */
-    public Attributes getRootDSE() 
-    {
-        throw new NotImplementedException() ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#register(
-     * org.apache.ldap.server.backend.AtomicBackend)
-     */
-    public void register( AtomicBackend a_backend ) 
-    {
-        m_backends.put( a_backend.getSuffix( true ).toString(), a_backend ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.BackendNexus#unregister(
-     * org.apache.ldap.server.backend.AtomicBackend)
-     */
-    public void unregister( AtomicBackend a_backend ) 
-    {
-        m_backends.remove( a_backend.getSuffix( true ).toString() ) ;
-    }
-
-
-    // ------------------------------------------------------------------------
-    // Backend Interface Method Implementations
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#delete(javax.naming.Name)
-     */
-    public void delete( Name a_dn ) throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        l_backend.delete( a_dn ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#add(javax.naming.Name, 
-     * javax.naming.directory.Attributes)
-     */
-    public void add( String a_updn, Name a_dn, Attributes an_entry ) 
-        throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        l_backend.add( a_updn, a_dn, an_entry ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#modify(javax.naming.Name, int, 
-     * javax.naming.directory.Attributes)
-     */
-    public void modify( Name a_dn, int a_modOp, Attributes a_mods )
-        throws NamingException 
+    public NexusComponent()
     {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        l_backend.modify( a_dn, a_modOp, a_mods ) ;
     }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#modify(javax.naming.Name, 
-     * javax.naming.directory.ModificationItem[])
-     */
-    public void modify( Name a_dn, ModificationItem[] a_mods )
-        throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        l_backend.modify( a_dn, a_mods ) ;
-    }
-
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#list(javax.naming.Name)
-     */
-    public NamingEnumeration list( Name a_base ) throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_base ) ;
-        return l_backend.list( a_base ) ;
-    }
-    
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#search(javax.naming.Name, 
-     * java.util.Hashtable, org.apache.ldap.common.filter.ExprNode, 
-     * javax.naming.ldap.Control[], javax.naming.directory.SearchControls)
-     */
-    public NamingEnumeration search( Name a_base, Hashtable a_env, 
-        ExprNode a_filter, Control [] a_reqCtls, SearchControls a_searchCtls ) 
-        throws NamingException
-    {
-        AtomicBackend l_backend = getBackend( a_base ) ;
-        return l_backend.search( a_base, a_env, a_filter, 
-                a_reqCtls, a_searchCtls ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#lookup(javax.naming.Name, 
-     * java.lang.String)
-     */
-    public Attributes lookup( Name a_dn, String [] a_attrIds ) 
-        throws NamingException 
-    {
-        throw new NotImplementedException() ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#lookup(javax.naming.Name)
-     */
-    public Attributes lookup( Name a_dn )  throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        return l_backend.lookup( a_dn ) ;
-    }
-
-
-    /**
-     * @see org.apache.ldap.server.backend.Backend#hasEntry(javax.naming.Name)
-     */
-    public boolean hasEntry( Name a_dn ) throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        return l_backend.hasEntry( a_dn ) ;
-    }
-
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#isSuffix(javax.naming.Name)
-     */
-    public boolean isSuffix( Name a_dn ) throws NamingException 
-    {
-        return m_backends.containsKey( a_dn.toString() ) ;
-    }
-
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#modifyRdn(javax.naming.Name, 
-     * java.lang.String, boolean)
-     */
-    public void modifyRdn( Name a_dn, String a_newRdn, boolean a_deleteOldRdn )
-        throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_dn ) ;
-        l_backend.modifyRdn( a_dn, a_newRdn, a_deleteOldRdn ) ;
-    }
-    
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#move(javax.naming.Name, 
-     * javax.naming.Name)
-     */
-    public void move( Name a_oldChildDn, Name a_newParentDn )
-        throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_oldChildDn ) ;
-        l_backend.move( a_oldChildDn, a_newParentDn ) ;
-    }
-    
-    
-    /**
-     * @see org.apache.ldap.server.backend.Backend#move(javax.naming.Name, 
-     * javax.naming.Name, java.lang.String, boolean)
-     */
-    public void move( Name a_oldChildDn, Name a_newParentDn, String a_newRdn,
-        boolean a_deleteOldRdn ) throws NamingException 
-    {
-        AtomicBackend l_backend = getBackend( a_oldChildDn ) ;
-        l_backend.move( a_oldChildDn, a_newParentDn, a_newRdn, a_deleteOldRdn );
-    }
-    
-
-    // ------------------------------------------------------------------------
-    // Private Methods
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Gets the backend partition associated with a dn.
-     * 
-     * @param a_dn the name to resolve to a backend
-     * @return the backend partition associated with the dn
-     * @throws NamingException if the name cannot be resolved to a backend
-     */
-    private AtomicBackend getBackend( Name a_dn ) throws NamingException
-    {
-        Name l_dn = ( Name ) a_dn.clone() ;
-        AtomicBackend l_backend = null ;
-        
-        while ( l_dn.size() > 0 )
-        {
-            if ( m_backends.containsKey( l_dn.toString() ) )
-            {
-                return ( AtomicBackend ) m_backends.get( l_dn.toString() ) ;
-            }
-            
-            l_dn.remove( 0 ) ;
-        }
-        
-        throw new NameNotFoundException() ;
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Life-Cycle Stage Methods
-    // ------------------------------------------------------------------------
-    
     
     /**
      * The nexus is dependent on the SystemBackend and so must get a handle on
      * it during the Serviceable life-cycle stage.
      * 
      * @avalon.dependency 
-     *      type="org.apache.ldap.server.backend.AtomicBackend"
+     *      type="org.apache.ldap.store.api.AtomicBackend"
      *      key="system-backend" version="1.0"
      * 
      * @see org.apache.avalon.framework.service.Serviceable#service( 
@@ -369,7 +70,7 @@
     public void service( ServiceManager a_manager )
         throws ServiceException
     {
-        m_system = ( AtomicBackend ) a_manager.lookup( "system-backend" ) ;
-        register( m_system ) ;
+        AtomicBackend system = ( AtomicBackend ) a_manager.lookup( "system-backend" ) ;
+        setSystem( system ) ;
     }
 }

Mime
View raw message