You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/12/29 09:15:25 UTC

svn commit: r490951 - in /directory/branches/trunks/schema: apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/ apacheds/core-unit/src/test/j...

Author: akarasulu
Date: Fri Dec 29 00:15:23 2006
New Revision: 490951

URL: http://svn.apache.org/viewvc?view=rev&rev=490951
Log:
changes ...

 o started bootstraping the schema partition in the init process
 o wrote code to pull out and load global registries with schema content from
   the schema partition
 o minimal schema manager implemented for maintaining registries
 o corrected several syntax checkers, normalizers and comparators to load
   using reflection
 o comparators and normalizers seem to be loading now


Added:
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaModifyHandler.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
Modified:
    directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
    directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
    directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
    directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java
    directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationITest.java
    directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java
    directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DirectoryServiceConfiguration.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
    directory/branches/trunks/schema/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
    directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java
    directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemNormalizerProducer.java
    directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisComparatorProducer.java
    directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisNormalizerProducer.java
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnComparator.java
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnNormalizer.java
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java
    directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/CachingNormalizer.java
    directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NormalizingComparator.java
    directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AcceptAllSyntaxChecker.java
    directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BinarySyntaxChecker.java

Modified: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Fri Dec 29 00:15:23 2006
@@ -44,6 +44,7 @@
 import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStoreConfiguration;
+import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
@@ -562,6 +563,8 @@
             e.printStackTrace();
             throw new MojoFailureException( "Failed to load bootstrap registries with schemas: " + e.getMessage() );
         }
+        
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
     }
     
 

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java Fri Dec 29 00:15:23 2006
@@ -155,7 +155,7 @@
             configuration.setPartitionConfigurations( Collections.singleton( partConfig ) );
             
             doDelete( configuration.getWorkingDirectory() );
-            setSysRoot( username, password, configuration );
+            setContextRoots( username, password, configuration );
             
             Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
             env.put( Context.SECURITY_PRINCIPAL, username );

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java Fri Dec 29 00:15:23 2006
@@ -80,6 +80,9 @@
     /** the context root for the system partition */
     protected LdapContext sysRoot;
 
+    /** the context root for the schema partition */
+    protected LdapContext schemaRoot;
+
     /** flag whether to delete database files for each test or not */
     protected boolean doDelete = true;
 
@@ -153,7 +156,7 @@
         
     	List entries = reader.parseLdif( LDIF );
         
-        Entry entry = (Entry)entries.get(0);
+        Entry entry = ( Entry ) entries.get(0);
 
         testEntries.add( entry );
 
@@ -203,7 +206,7 @@
         configuration.setTestEntries( testEntries );
         configuration.setShutdownHookEnabled( false );
         doDelete( configuration.getWorkingDirectory() );
-        setSysRoot( username, password, configuration );
+        setContextRoots( username, password, configuration );
     }
 
 
@@ -236,13 +239,13 @@
      * @return the sysRoot context which is also set
      * @throws NamingException if there is a failure of any kind
      */
-    protected LdapContext setSysRoot( String user, String passwd, Configuration cfg ) throws NamingException
+    protected void setContextRoots( String user, String passwd, Configuration cfg ) throws NamingException
     {
         Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.SECURITY_PRINCIPAL, user );
         env.put( Context.SECURITY_CREDENTIALS, passwd );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
-        return setSysRoot( env );
+        setContextRoots( env );
     }
 
 
@@ -255,7 +258,7 @@
      * @return the sysRoot context which is also set
      * @throws NamingException if there is a failure of any kind
      */
-    protected LdapContext setSysRoot( Hashtable env ) throws NamingException
+    protected void setContextRoots( Hashtable env ) throws NamingException
     {
         Hashtable envFinal = new Hashtable( env );
         if ( !envFinal.containsKey( Context.PROVIDER_URL ) )
@@ -274,7 +277,9 @@
         new InitialLdapContext( adminEnv, null );
 
         // OK, now let's get an appropriate context.
-        return sysRoot = new InitialLdapContext( envFinal, null );
+        sysRoot = new InitialLdapContext( envFinal, null );
+        envFinal.put( Context.PROVIDER_URL, "ou=schema" );
+        schemaRoot = new InitialLdapContext( envFinal, null );
     }
 
 
@@ -303,7 +308,7 @@
     {
         super.tearDown();
 
-        Hashtable env = new Hashtable();
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
 
         env.put( Context.PROVIDER_URL, "ou=system" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java Fri Dec 29 00:15:23 2006
@@ -25,9 +25,12 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
@@ -60,22 +63,6 @@
     public void setUp() throws Exception
     {
         // -------------------------------------------------------------------
-        // Alter the system configuration to include the NisSchema
-        // -------------------------------------------------------------------
-
-        if ( true )
-        {
-            throw new RuntimeException( "Fix this startup code that tries to initialize the server to use the nis " +
-                    "\nschema; so it looks like we still need some way to tell the config how to use different" +
-                    "\nschemas without having to initialize bootstrap schema objects." );
-        }
-        
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
-        //schemas.addAll( configuration.getBootstrapSchemas() );
-        schemas.add( new NisSchema() );
-        //configuration.setBootstrapSchemas( schemas );
-        
-        // -------------------------------------------------------------------
         // Alter the partition configuration to index gidNumber
         // -------------------------------------------------------------------
 
@@ -98,6 +85,15 @@
         }
         
         super.setUp();
+
+        // -------------------------------------------------------------------
+        // Enable the nis schema
+        // -------------------------------------------------------------------
+
+        Attribute disabled = new BasicAttribute( "m-disabled" );
+        ModificationItem[] mods = new ModificationItem[] { 
+            new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
+        schemaRoot.modifyAttributes( "cn=nis", mods );
         
         // -------------------------------------------------------------------
         // Add a bunch of nis groups

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationITest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationITest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationITest.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationITest.java Fri Dec 29 00:15:23 2006
@@ -185,7 +185,7 @@
         configuration.setAllowAnonymousAccess( false );
         try
         {
-            setSysRoot( env );
+            setContextRoots( env );
             fail( "should not get here due to exception" );
         }
         catch ( LdapNoPermissionException e )
@@ -198,8 +198,8 @@
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         configuration.setAllowAnonymousAccess( true );
 
-        InitialLdapContext ctx = ( InitialLdapContext ) setSysRoot( env );
-        assertNotNull( ctx );
+        setContextRoots( env );
+        assertNotNull( sysRoot );
 
         // now go in as anonymous user and we should be wh
         env.put( Context.PROVIDER_URL, "ou=system" );
@@ -242,7 +242,7 @@
 
         try
         {
-            setSysRoot( env );
+            setContextRoots( env );
             fail( "should not get here due to exception" );
         }
         catch ( ConfigurationException e )
@@ -271,7 +271,7 @@
 
         try
         {
-            setSysRoot( env );
+            setContextRoots( env );
             fail( "should not get here due to exception" );
         }
         catch ( ConfigurationException e )

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java Fri Dec 29 00:15:23 2006
@@ -47,7 +47,7 @@
      */
     public void testShutdownNonNullContext() throws Exception
     {
-        setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
+        setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
         doDelete( configuration.getWorkingDirectory() );
     }
@@ -60,11 +60,11 @@
      */
     public void testShutdownRestart() throws Exception
     {
-        setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
+        setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
 
         // restart the system now
-        setSysRoot( "uid=admin,ou=system", "secret", configuration );
+        setContextRoots( "uid=admin,ou=system", "secret", configuration );
 
         // (tearDown is overriden)
         super.tearDown();

Modified: directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java (original)
+++ directory/branches/trunks/schema/apacheds/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java Fri Dec 29 00:15:23 2006
@@ -42,7 +42,7 @@
      */
     public void testSyncNoException() throws Exception
     {
-        sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
+        setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
         assertNotNull( sysRoot );
     }
 
@@ -55,7 +55,7 @@
      */
     public void testPostSyncLookup() throws Exception
     {
-        sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
+        setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
 
         Attributes users = sysRoot.getAttributes( "ou=users" );
 

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Fri Dec 29 00:15:23 2006
@@ -45,6 +45,9 @@
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.core.schema.PartitionSchemaLoader;
+import org.apache.directory.server.core.schema.SchemaManager;
+import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
@@ -86,6 +89,8 @@
     private final DirectoryServiceConfiguration configuration = new DefaultDirectoryServiceConfiguration( this );
 
     private DirectoryServiceListener serviceListener;
+    
+    private SchemaManager schemaManager;
 
     /** the initial context environment that fired up the backend subsystem */
     private Hashtable<String, Object> environment;
@@ -769,6 +774,8 @@
             throw e;
         }
         
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+        
         // --------------------------------------------------------------------
         // If not present extract schema partition from jar
         // --------------------------------------------------------------------
@@ -790,27 +797,31 @@
         // Initialize schema partition
         // --------------------------------------------------------------------
         
-        MutablePartitionConfiguration pc = new MutablePartitionConfiguration();
-        pc.setName( "schema" );
-        pc.setCacheSize( 1000 );
-        pc.setIndexedAttributes( extractor.getDbFileListing().getIndexedAttributes() );
-        pc.setOptimizerEnabled( true );
-        pc.setSuffix( "ou=schema" );
+        MutablePartitionConfiguration schemaPartitionConfig = new MutablePartitionConfiguration();
+        schemaPartitionConfig.setName( "schema" );
+        schemaPartitionConfig.setCacheSize( 1000 );
+        schemaPartitionConfig.setIndexedAttributes( extractor.getDbFileListing().getIndexedAttributes() );
+        schemaPartitionConfig.setOptimizerEnabled( true );
+        schemaPartitionConfig.setSuffix( "ou=schema" );
         
         Attributes entry = new LockableAttributesImpl();
         entry.put( "objectClass", "top" );
         entry.get( "objectClass" ).add( "organizationalUnit" );
         entry.put( "ou", "schema" );
-        pc.setContextEntry( entry );
+        schemaPartitionConfig.setContextEntry( entry );
         JdbmPartition schemaPartition = new JdbmPartition();
-        schemaPartition.init( configuration, pc );
+        schemaPartition.init( configuration, schemaPartitionConfig );
+        schemaPartitionConfig.setContextPartition( schemaPartition );
 
         // --------------------------------------------------------------------
         // Initialize schema subsystem and reset registries
         // --------------------------------------------------------------------
         
-        // To be done
-        
+        PartitionSchemaLoader schemaLoader = new PartitionSchemaLoader( schemaPartition, registries );
+        Registries globalRegistries = new DefaultRegistries( schemaLoader );
+        schemaLoader.loadEnabled( globalRegistries );
+        registries = globalRegistries;
+        SerializableComparator.setRegistry( globalRegistries.getComparatorRegistry() );
         
         Set<String> binaries = new HashSet<String>();
         if ( this.environment.containsKey( BINARY_KEY ) )
@@ -848,6 +859,8 @@
                 }
             }
         }
+        
+        schemaManager = new SchemaManager( globalRegistries, schemaLoader );
 
         // now get all the attributeTypes that are binary from the registry
         AttributeTypeRegistry registry = registries.getAttributeTypeRegistry();
@@ -877,6 +890,7 @@
 
         partitionNexus = new DefaultPartitionNexus( new LockableAttributesImpl() );
         partitionNexus.init( configuration, null );
+        partitionNexus.addContextPartition( schemaPartitionConfig );
 
         interceptorChain = new InterceptorChain();
         interceptorChain.init( configuration );
@@ -885,5 +899,11 @@
         {
             log.debug( "<--- DefaultDirectoryService initialized" );
         }
+    }
+
+
+    public SchemaManager getSchemaManager()
+    {
+        return schemaManager;
     }
 }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java Fri Dec 29 00:15:23 2006
@@ -28,6 +28,7 @@
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.SchemaManager;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
@@ -113,5 +114,11 @@
         String authentication, String baseName ) throws NamingException
     {
         return parent.getJndiContext( principalDn, principal, credential, authentication, baseName );
+    }
+
+
+    public SchemaManager getSchemaManager()
+    {
+        return parent.getSchemaManager();
     }
 }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DirectoryServiceConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DirectoryServiceConfiguration.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DirectoryServiceConfiguration.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DirectoryServiceConfiguration.java Fri Dec 29 00:15:23 2006
@@ -27,6 +27,7 @@
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.SchemaManager;
 import org.apache.directory.server.schema.registries.Registries;
 
 
@@ -87,6 +88,10 @@
      */
     InterceptorChain getInterceptorChain();
 
+    /**
+     * Returns the schema manager for the {@link DirectoryService}.
+     */
+    SchemaManager getSchemaManager();
 
     /**
      * Returns <tt>true</tt> if this service is started

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Fri Dec 29 00:15:23 2006
@@ -527,7 +527,11 @@
             throw new ConfigurationException( "Duplicate partition suffix: " + key );
         }
 
-        partition.init( factoryCfg, config );
+        if ( ! partition.isInitialized() )
+        {
+            partition.init( factoryCfg, config );
+        }
+        
         partitions.put( partition.getSuffix().toString(), partition );
 
         Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );

Added: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaModifyHandler.java?view=auto&rev=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaModifyHandler.java (added)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaModifyHandler.java Fri Dec 29 00:15:23 2006
@@ -0,0 +1,174 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.ServerUtils;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+
+/**
+ * Handles events where entries of objectClass metaSchema are modified.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MetaSchemaModifyHandler
+{
+    private final PartitionSchemaLoader loader;
+    private final Registries globalRegistries;
+    private final AttributeType disabledAT;
+    
+
+    public MetaSchemaModifyHandler( Registries globalRegistries, PartitionSchemaLoader loader ) 
+        throws NamingException
+    {
+        this.globalRegistries = globalRegistries;
+        this.disabledAT = globalRegistries.getAttributeTypeRegistry()
+            .lookup( MetaSchemaConstants.M_DISABLED_AT );
+        this.loader = loader;
+    }
+
+    
+    void handleMetaSchemaModification( LdapDN name, int modOp, Attributes mods, Attributes entry )
+        throws NamingException
+    {
+        Attribute disabledInMods = ServerUtils.getAttribute( disabledAT, mods );
+        if ( disabledInMods != null )
+        {
+            handleMetaSchemaDisable( name, modOp, disabledInMods, ServerUtils.getAttribute( disabledAT, entry ) );
+        }
+    }
+
+
+    private void handleMetaSchemaDisable( LdapDN name, int modOp, Attribute disabledInMods, Attribute disabledInEntry )
+        throws NamingException
+    {
+        switch ( modOp )
+        {
+            /*
+             * If the user is adding a new m-disabled attribute to an enabled schema, 
+             * we check that the value is "TRUE" and disable that schema if so.
+             */
+            case ( DirContext.ADD_ATTRIBUTE  ):
+                if ( disabledInEntry == null )
+                {
+                    if ( "TRUE".equalsIgnoreCase( ( String ) disabledInMods.get() ) )
+                    {
+                        disableSchema( getSchemaName( name ) );
+                    }
+                }
+                break;
+
+            /*
+             * If the user is removing the m-disabled attribute we check if the schema is currently 
+             * disabled.  If so we enable the schema.
+             */
+            case ( DirContext.REMOVE_ATTRIBUTE  ):
+                if ( "TRUE".equalsIgnoreCase( ( String ) disabledInEntry.get() ) )
+                {
+                    enableSchema( getSchemaName( name ) );
+                }
+                break;
+
+            /*
+             * If the user is replacing the m-disabled attribute we check if the schema is 
+             * currently disabled and enable it if the new state has it as enabled.  If the
+             * schema is not disabled we disable it if the mods set m-disabled to true.
+             */
+            case ( DirContext.REPLACE_ATTRIBUTE  ):
+                boolean isCurrentlyDisabled = "TRUE".equalsIgnoreCase( ( String ) disabledInEntry.get() );
+                boolean isNewStateDisabled = "TRUE".equalsIgnoreCase( ( String ) disabledInMods.get() );
+
+                if ( isCurrentlyDisabled && !isNewStateDisabled )
+                {
+                    enableSchema( getSchemaName( name ) );
+                    break;
+                }
+
+                if ( !isCurrentlyDisabled && isNewStateDisabled )
+                {
+                    disableSchema( getSchemaName( name ) );
+                    break;
+                }
+            default:
+                throw new IllegalArgumentException( "Unknown modify operation type: " + modOp );
+        }
+    }
+
+    
+    private final String getSchemaName( LdapDN schema ) throws NamingException
+    {
+        return ( String ) schema.getRdn().getValue();
+    }
+    
+
+    private void disableSchema( String schemaName )
+    {
+        throw new NotImplementedException();
+    }
+
+
+    /**
+     * TODO - for now we're just going to add the schema to the global 
+     * registries ... we may need to add it to more than that though later.
+     */
+    private void enableSchema( String schemaName ) throws NamingException
+    {
+        if ( globalRegistries.getLoadedSchemas().containsKey( schemaName ) )
+        {
+            // TODO log warning: schemaName + " was already loaded"
+            return;
+        }
+        
+        Schema schema = loader.getSchema( schemaName );
+        loader.load( schema, globalRegistries );
+    }
+
+
+    public void handleMetaSchemaModification( LdapDN name, ModificationItem[] mods, Attributes entry ) 
+        throws NamingException
+    {
+        OidRegistry registry = globalRegistries.getOidRegistry();
+        Attribute disabledInEntry = ServerUtils.getAttribute( disabledAT, entry );
+        
+        for ( int ii = 0; ii < mods.length; ii++ )
+        {
+            String id = registry.getOid( mods[ii].getAttribute().getID() );
+            if ( id.equals( disabledAT.getOid() ) )
+            {
+                handleMetaSchemaDisable( name, mods[ii].getModificationOp(), 
+                    mods[ii].getAttribute(), disabledInEntry );
+            }
+        }
+    }
+}

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java Fri Dec 29 00:15:23 2006
@@ -32,11 +32,11 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.core.partition.Partition;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.AbstractSchemaLoader;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -52,7 +52,6 @@
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
 import org.apache.directory.server.schema.registries.SyntaxRegistry;
-import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -78,7 +77,7 @@
     private AttributeTypeRegistry attrRegistry;
 
     
-    public PartitionSchemaLoader( Partition partition, Registries bootstrapRegiistries )
+    public PartitionSchemaLoader( Partition partition, Registries bootstrapRegiistries ) throws NamingException
     {
         this.factory = new SchemaEntityFactory( bootstrapRegiistries );
         this.partition = partition;
@@ -95,23 +94,21 @@
      */
     public void loadEnabled( Registries registries ) throws NamingException
     {
-        
+        Map<String, Schema> schemas = getSchemas();
+        Set<Schema> schemaSet = new HashSet<Schema>();
+
+        for ( Schema schema: schemas.values() )
+        {
+            if ( ! schema.isDisabled() )
+            {
+                schemaSet.add( schema );
+            }
+        }
+
+        loadWithDependencies( schemaSet, registries );
     }
     
     
-    /**
-     * Returns the set of schemas that have been disabled or enabled.
-     * 
-     * @param disabled if set to to true disabled schemas are returned, otherwise enabled schemas are returned 
-     * @return enabled or disabled schemas 
-     * @throws NamingException if there is a problem accessing the backing store
-     */
-    public Map<String,Schema> getSchemas( boolean disabled ) throws NamingException
-    {
-        throw new NotImplementedException();
-    }
-
-    
     public Map<String,Schema> getSchemas() throws NamingException
     {
         Map<String,Schema> schemas = new HashMap<String,Schema>();
@@ -181,7 +178,7 @@
         list = notLoaded.values().iterator();
         while ( list.hasNext() )
         {
-            Schema schema = ( BootstrapSchema ) list.next();
+            Schema schema = ( Schema ) list.next();
             loadDepsFirst( new Stack<String>(), notLoaded, schema, registries, null );
             list = notLoaded.values().iterator();
         }
@@ -259,7 +256,10 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            ObjectClass oc = factory.getObjectClass( result.getAttributes() );
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            ObjectClass oc = factory.getObjectClass( attrs );
             registry.register( schema.getSchemaName(), oc );
         }
     }
@@ -279,7 +279,10 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            AttributeType at = factory.getAttributeType( result.getAttributes() );
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            AttributeType at = factory.getAttributeType( attrs );
             registry.register( schema.getSchemaName(), at );
         }
     }
@@ -299,7 +302,10 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            MatchingRule mrule = factory.getMatchingRule( result.getAttributes() );
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            MatchingRule mrule = factory.getMatchingRule( attrs );
             registry.register( schema.getSchemaName(), mrule );
 
         }
@@ -320,7 +326,10 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            Syntax syntax = factory.getSyntax( result.getAttributes() );
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            Syntax syntax = factory.getSyntax( attrs );
             registry.register( schema.getSchemaName(), syntax );
         }
     }
@@ -340,7 +349,10 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            SyntaxChecker sc = factory.getSyntaxChecker( result.getAttributes() );
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            SyntaxChecker sc = factory.getSyntaxChecker( attrs );
             registry.register( schema.getSchemaName(), sc.getSyntaxOid(), sc );
         }
     }
@@ -360,8 +372,11 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            Normalizer normalizer = factory.getNormalizer( result.getAttributes() );
-            String oid = ( String ) result.getAttributes().get( "m-oid" ).get();
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            Normalizer normalizer = factory.getNormalizer( attrs );
+            String oid = ( String ) attrs.get( "m-oid" ).get();
             registry.register( schema.getSchemaName(), oid, normalizer );
         }
     }
@@ -381,8 +396,11 @@
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
-            Comparator comparator = factory.getComparator( result.getAttributes() );
-            String oid = ( String ) result.getAttributes().get( "m-oid" ).get();
+            LdapDN resultDN = new LdapDN( result.getName() );
+            resultDN.normalize( attrRegistry.getNormalizerMapping() );
+            Attributes attrs = partition.lookup( resultDN );
+            Comparator comparator = factory.getComparator( attrs );
+            String oid = ( String ) attrs.get( "m-oid" ).get();
             registry.register( schema.getSchemaName(), oid, comparator );
         }
     }

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java Fri Dec 29 00:15:23 2006
@@ -33,6 +33,7 @@
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
+import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.*;
@@ -49,18 +50,24 @@
 {
     /** Used for looking up the setRegistries(Registries) method */
     private final static Class[] parameterTypes = new Class[] { Registries.class };
+    /** Used for looking up the setSyntaxOid(String) method */
+    private final static Class[] setOidParameterTypes = new Class[] { String.class };
     private static final String[] EMPTY = new String[0];
     
     /** Used for dependency injection of Registries via setter into schema objects */
     private final Registries registries;
     /** A special ClassLoader that loads a class from the bytecode attribute */
     private final AttributeClassLoader classLoader;
+    private final AttributeType oidAT;
+    private AttributeType byteCodeAT;
     
     
-    public SchemaEntityFactory( Registries registries )
+    public SchemaEntityFactory( Registries registries ) throws NamingException
     {
         this.registries = registries;
         this.classLoader = new AttributeClassLoader();
+        this.oidAT = registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.byteCodeAT = registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_BYTECODE_AT );
     }
 
     
@@ -135,7 +142,8 @@
         SyntaxChecker syntaxChecker = null;
         Class clazz = null;
 
-        if ( entry.get( MetaSchemaConstants.M_BYTECODE_AT ) == null )
+        Attribute byteCodeAttr = ServerUtils.getAttribute( byteCodeAT, entry );
+        if ( byteCodeAttr == null )
         {
             try
             {
@@ -196,6 +204,8 @@
 
         // try now before returning to check if we can inject a Registries object
         injectRegistries( syntaxChecker );
+        String syntaxOid = ( String ) ServerUtils.getAttribute( oidAT, entry ).get();
+        injectOid( syntaxOid, syntaxChecker );
         return syntaxChecker;
     }
     
@@ -410,29 +420,84 @@
         }
         catch ( NoSuchMethodException e )
         {
+            // this is ok since not every object may have setRegistries()
+        }
+        catch ( IllegalArgumentException e )
+        {
             NamingException ne = new NamingException( "SyntaxChecker class "+ className 
                 + " could not have the Registries dependency injected." );
             ne.setRootCause( e );
             throw ne;
         }
-        catch ( IllegalArgumentException e )
+        catch ( IllegalAccessException e )
         {
             NamingException ne = new NamingException( "SyntaxChecker class "+ className 
                 + " could not have the Registries dependency injected." );
             ne.setRootCause( e );
             throw ne;
         }
-        catch ( IllegalAccessException e )
+        catch ( InvocationTargetException e )
         {
             NamingException ne = new NamingException( "SyntaxChecker class "+ className 
                 + " could not have the Registries dependency injected." );
             ne.setRootCause( e );
             throw ne;
         }
+    }
+
+
+    /**
+     * Uses reflection to see if a setSyntaxOid( String ) method exists 
+     * on the object's class.  If so then the oid dependency is injected into the 
+     * new SyntaxChecker.
+     * 
+     * @param obj a schema object to have a oid dependency injected.
+     */
+    private void injectOid( String syntaxOid, SyntaxChecker checker ) throws NamingException
+    {
+        String className = checker.getClass().getName();
+        
+        try
+        {
+            Method method = checker.getClass().getMethod( "setSyntaxOid", setOidParameterTypes );
+            
+            if ( method == null )
+            {
+                return;
+            }
+            
+            Object[] args = new Object[] { syntaxOid};
+            method.invoke( checker, args );
+        }
+        catch ( SecurityException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the oid dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( NoSuchMethodException e )
+        {
+            // this is ok since not every object may have setSyntaxOid()
+        }
+        catch ( IllegalArgumentException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the oid dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( IllegalAccessException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the oid dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
         catch ( InvocationTargetException e )
         {
             NamingException ne = new NamingException( "SyntaxChecker class "+ className 
-                + " could not have the Registries dependency injected." );
+                + " could not have the oid dependency injected." );
             ne.setRootCause( e );
             throw ne;
         }

Added: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java?view=auto&rev=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java (added)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java Fri Dec 29 00:15:23 2006
@@ -0,0 +1,110 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.ModificationItem;
+
+import org.apache.directory.server.constants.SystemSchemaConstants;
+import org.apache.directory.server.core.ServerUtils;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+
+
+/**
+ * Central point of control for schemas enforced by the server.  The 
+ * following duties are presently performed by this class:
+ * 
+ * <ul>
+ *   <li>Provide central point of access for all registries: global and SAA specific registries</li>
+ *   <li>Manage enabling and disabling schemas</li>
+ *   <li>Responding to specific schema object changes</li>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaManager
+{
+    private final PartitionSchemaLoader loader;
+    private final MetaSchemaModifyHandler metaSchemaModifyHandler;
+    private final Registries globalRegistries;
+    private final AttributeType objectClassAT;
+    
+
+    public SchemaManager( Registries globalRegistries, PartitionSchemaLoader loader ) throws NamingException
+    {
+        this.loader = loader;
+        this.globalRegistries = globalRegistries;
+        
+        this.objectClassAT = this.globalRegistries.getAttributeTypeRegistry()
+            .lookup( SystemSchemaConstants.OBJECT_CLASS_AT );
+        this.metaSchemaModifyHandler = new MetaSchemaModifyHandler( this.globalRegistries, this.loader );
+    }
+    
+    
+    public Registries getGlobalRegistries()
+    {
+        throw new NotImplementedException();
+    }
+    
+    
+    public Registries getRegistries( LdapDN dn ) throws NamingException
+    {
+        throw new NotImplementedException();
+    }
+
+
+
+    public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry ) throws NamingException
+    {
+        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        
+        // We are changing a metaSchema entry
+        if ( AttributeUtils.containsValue( oc, "metaSchema", objectClassAT ) )
+        {
+            metaSchemaModifyHandler.handleMetaSchemaModification( name, modOp, mods, entry );
+            return;
+        }
+
+        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+    }
+
+
+    public void modify( LdapDN name, ModificationItem[] mods, Attributes entry ) throws NamingException
+    {
+        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        
+        // We are changing a metaSchema entry
+        if ( AttributeUtils.containsValue( oc, "metaSchema", objectClassAT ) )
+        {
+            metaSchemaModifyHandler.handleMetaSchemaModification( name, mods, entry );
+            return;
+        }
+
+        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+    }
+}

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Fri Dec 29 00:15:23 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.server.core.schema;
 
-
+ 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -125,6 +125,10 @@
      */
     private String startUpTimeStamp;
 
+    private SchemaManager schemaManager;
+    
+    // the base DN (normalized) of the schema partition
+    private LdapDN schemaBaseDN;
 
     /**
      * Creates a schema service interceptor.
@@ -152,6 +156,11 @@
         filters.add( topFilter );
         binaries = ( Set ) factoryCfg.getEnvironment().get( BINARY_KEY );
 
+        schemaBaseDN = new LdapDN( "ou=schema" );
+        schemaBaseDN.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        
+        schemaManager = factoryCfg.getSchemaManager();
+        
         // stuff for dealing with subentries (garbage for now)
         String subschemaSubentry = ( String ) nexus.getRootDSE().get( "subschemaSubentry" ).get();
         subschemaSubentryDn = new LdapDN( subschemaSubentry );
@@ -777,8 +786,13 @@
             }
         }
 
+        if ( name.startsWith( schemaBaseDN ) )
+        {
+            schemaManager.modify( name, modOp, mods, entry );
+        }
         next.modify( name, modOp, mods );
     }
+    
 
     public void modify( NextInterceptor next, LdapDN name, ModificationItem[] mods ) throws NamingException
     {
@@ -1010,6 +1024,10 @@
         
         assertNumberOfAttributeValuesValid( tmpEntry );
 
+        if ( name.startsWith( schemaBaseDN ) )
+        {
+            schemaManager.modify( name, mods, entry );
+        }
         next.modify( name, mods );
     }
 

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java Fri Dec 29 00:15:23 2006
@@ -40,6 +40,7 @@
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
@@ -96,7 +97,7 @@
         bootstrapSchemas.add( new CoreSchema() );
         bootstrapSchemas.add( new SystemSchema() );
         loader.loadWithDependencies( bootstrapSchemas, registries );
-
+        
         // run referential integrity tests
         java.util.List errors = registries.checkRefInteg();
         if ( !errors.isEmpty() )
@@ -105,7 +106,8 @@
             e.setRootCause( ( Throwable ) errors.get( 0 ) );
             throw e;
         }
-        
+
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
         configuration = new TestConfiguration( registries, startupConfiguration );
         
         // --------------------------------------------------------------------
@@ -344,6 +346,10 @@
         {
             return false;
         }
-        
+
+        public SchemaManager getSchemaManager()
+        {
+            return null;
+        }
     }
 }

Modified: directory/branches/trunks/schema/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java (original)
+++ directory/branches/trunks/schema/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java Fri Dec 29 00:15:23 2006
@@ -18,7 +18,7 @@
  *  
  */
 package org.apache.directory.mitosis.store.derby;
-
+ 
 
 import java.io.File;
 import java.io.IOException;
@@ -45,6 +45,7 @@
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.SchemaManager;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
@@ -432,6 +433,12 @@
 
 
         public DirectoryServiceListener getServiceListener()
+        {
+            return null;
+        }
+
+
+        public SchemaManager getSchemaManager()
         {
             return null;
         }

Modified: directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemComparatorProducer.java Fri Dec 29 00:15:23 2006
@@ -48,7 +48,25 @@
         super( ProducerTypeEnum.COMPARATOR_PRODUCER );
     }
 
+    
+    public static class DeepTrimToLowerCachingNormalizingComparator extends NormalizingComparator
+    {
+        public DeepTrimToLowerCachingNormalizingComparator()        
+        {
+            super( new CachingNormalizer( new DeepTrimToLowerNormalizer() ), new ComparableComparator() );
+        }
+    }
+
+    
+    public static class DeepTrimCachingNormalizingComparator extends NormalizingComparator
+    {
+        public DeepTrimCachingNormalizingComparator()        
+        {
+            super( new CachingNormalizer( new DeepTrimNormalizer() ), new ComparableComparator() );
+        }
+    }
 
+    
     public void produce( Registries registries, ProducerCallback cb ) throws NamingException
     {
         Comparator comparator;
@@ -73,24 +91,21 @@
          ( 2.5.13.2 NAME 'caseIgnoreMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.2", comparator );
 
         /*
          ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.3", comparator );
 
         /*
          ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.4", comparator );
 
         /*
@@ -118,8 +133,7 @@
          ( 2.5.13.11 NAME 'caseIgnoreListMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.11", comparator );
 
         /*
@@ -182,8 +196,7 @@
          ( 2.5.13.23 NAME 'uniqueMemberMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.23", comparator );
 
         /*
@@ -235,16 +248,14 @@
          ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", comparator );
 
         /*
          ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", comparator );
 
         /*
@@ -274,16 +285,13 @@
 
          */
 
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.5", comparator );
 
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.7", comparator );
 
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "2.5.13.12", comparator );
 
         /*
@@ -294,9 +302,7 @@
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
          */
 
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimToLowerCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.3", comparator );
-
     }
 }

Modified: directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemNormalizerProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemNormalizerProducer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemNormalizerProducer.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/SystemNormalizerProducer.java Fri Dec 29 00:15:23 2006
@@ -20,6 +20,9 @@
 package org.apache.directory.server.schema.bootstrap;
 
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.DnNormalizer;
@@ -47,6 +50,100 @@
         super( ProducerTypeEnum.NORMALIZER_PRODUCER );
     }
 
+    
+    public static class CachingDeepTrimToLowerNormalizer extends CachingNormalizer
+    {
+        private static final long serialVersionUID = 1L;
+
+        public CachingDeepTrimToLowerNormalizer()
+        {
+            super( new DeepTrimToLowerNormalizer() );
+        }
+    }
+    
+    
+    public static class CachingDeepTrimNormalizer extends CachingNormalizer
+    {
+        private static final long serialVersionUID = 1L;
+
+        public CachingDeepTrimNormalizer()
+        {
+            super( new DeepTrimNormalizer() );
+        }
+    }
+    
+    
+    public static class CachingDnNormalizer extends CachingNormalizer
+    {
+        private static final long serialVersionUID = 1L;
+
+        /** Used for looking up the setRegistries(Registries) method */
+        private final static Class[] parameterTypes = new Class[] { Registries.class };
+
+        
+        public CachingDnNormalizer()
+        {
+            super( new DnNormalizer() );
+        }
+
+        
+        public void setRegistries( Registries registries ) throws NamingException
+        {
+            injectRegistries( super.normalizer, registries );
+        }
+        
+        
+        private void injectRegistries( Object obj, Registries registries ) throws NamingException
+        {
+            String className = obj.getClass().getName();
+            
+            try
+            {
+                Method method = obj.getClass().getMethod( "setRegistries", parameterTypes );
+                
+                if ( method == null )
+                {
+                    return;
+                }
+                
+                Object[] args = new Object[] { registries };
+                method.invoke( obj, args );
+            }
+            catch ( SecurityException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                    + " could not have the Registries dependency injected." );
+                ne.setRootCause( e );
+                throw ne;
+            }
+            catch ( NoSuchMethodException e )
+            {
+                // this is ok since not every object may have setRegistries()
+            }
+            catch ( IllegalArgumentException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                    + " could not have the Registries dependency injected." );
+                ne.setRootCause( e );
+                throw ne;
+            }
+            catch ( IllegalAccessException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                    + " could not have the Registries dependency injected." );
+                ne.setRootCause( e );
+                throw ne;
+            }
+            catch ( InvocationTargetException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                    + " could not have the Registries dependency injected." );
+                ne.setRootCause( e );
+                throw ne;
+            }
+        }
+    }
+    
 
     public void produce( Registries registries, ProducerCallback cb ) throws NamingException
     {
@@ -59,42 +156,43 @@
          ( 2.5.13.1 NAME 'distinguishedNameMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
          */
-        normalizer = new CachingNormalizer( new DnNormalizer( registries.getAttributeTypeRegistry() ) );
+        normalizer = new CachingDnNormalizer();
+        ( ( CachingDnNormalizer ) normalizer ).setRegistries( registries );
         cb.schemaObjectProduced( this, "2.5.13.1", normalizer );
 
         /*
          ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", normalizer );
 
         /*
          ( 2.5.13.11 NAME 'caseIgnoreListMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.11", normalizer );
 
         /*
          ( 2.5.13.2 NAME 'caseIgnoreMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.2", normalizer );
 
         /*
          ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.3", normalizer );
 
         /*
          ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.4", normalizer );
 
         /*
@@ -185,28 +283,28 @@
          ( 2.5.13.23 NAME 'uniqueMemberMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.23", normalizer );
 
         /*
          ( 2.5.13.24 NAME 'protocolInformationMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.24", normalizer );
 
         /*
          ( 2.5.13.27 NAME 'generalizedTimeMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.27", normalizer );
 
         /*
          ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.28", normalizer );
 
         /*
@@ -237,7 +335,7 @@
          ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", normalizer );
 
         /*
@@ -266,13 +364,13 @@
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
          */
 
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.5", normalizer );
 
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.7", normalizer );
 
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "2.5.13.12", normalizer );
 
         /*
@@ -283,7 +381,7 @@
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
          */
 
-        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        normalizer = new CachingDeepTrimToLowerNormalizer();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.3", normalizer );
     }
 }

Modified: directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisComparatorProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisComparatorProducer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisComparatorProducer.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisComparatorProducer.java Fri Dec 29 00:15:23 2006
@@ -50,7 +50,16 @@
         super( ProducerTypeEnum.COMPARATOR_PRODUCER );
     }
 
+    
+    public static class DeepTrimCachingNormalizingComparator extends NormalizingComparator
+    {
+        public DeepTrimCachingNormalizingComparator()        
+        {
+            super( new CachingNormalizer( new DeepTrimNormalizer() ), new ComparableComparator() );
+        }
+    }
 
+    
     // ------------------------------------------------------------------------
     // BootstrapProducer Methods
     // ------------------------------------------------------------------------
@@ -67,8 +76,7 @@
          ( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        comparator = new NormalizingComparator( new CachingNormalizer( new DeepTrimNormalizer() ),
-            new ComparableComparator() );
+        comparator = new DeepTrimCachingNormalizingComparator();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.4203.1.2.1", comparator );
     }
 }

Modified: directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisNormalizerProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisNormalizerProducer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisNormalizerProducer.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/schema/bootstrap/NisNormalizerProducer.java Fri Dec 29 00:15:23 2006
@@ -47,7 +47,18 @@
         super( ProducerTypeEnum.NORMALIZER_PRODUCER );
     }
 
-
+    
+    public static class CachingDeepTrimNormalizer extends CachingNormalizer
+    {
+        private static final long serialVersionUID = 1L;
+        
+        public CachingDeepTrimNormalizer()
+        {
+            super( new DeepTrimNormalizer() );
+        }
+    }
+    
+        
     // ------------------------------------------------------------------------
     // BootstrapProducer Methods
     // ------------------------------------------------------------------------
@@ -64,7 +75,7 @@
          ( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
          */
-        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        normalizer = new CachingDeepTrimNormalizer();
         cb.schemaObjectProduced( this, "1.3.6.1.4.1.4203.1.2.1", normalizer );
 
     }

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnComparator.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnComparator.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnComparator.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnComparator.java Fri Dec 29 00:15:23 2006
@@ -26,6 +26,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -38,12 +39,23 @@
 public class DnComparator implements Comparator
 {
     // @TODO you'll need this to fix the way normalization is done
-    private final AttributeTypeRegistry attrRegistry;
+    private AttributeTypeRegistry attrRegistry;
     
     
     public DnComparator( AttributeTypeRegistry attrRegistry )
     {
         this.attrRegistry = attrRegistry;
+    }
+    
+    
+    public DnComparator()
+    {
+    }
+
+    
+    public void setRegistries( Registries registries )
+    {
+        attrRegistry = registries.getAttributeTypeRegistry();
     }
     
     

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnNormalizer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnNormalizer.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/DnNormalizer.java Fri Dec 29 00:15:23 2006
@@ -24,6 +24,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 
@@ -39,12 +40,23 @@
     private static final long serialVersionUID = 1L;
 
     // @TODO use this later for seting up normalization
-    private final AttributeTypeRegistry attrRegistry;
+    private AttributeTypeRegistry attrRegistry;
     
     
     public DnNormalizer( AttributeTypeRegistry attrRegistry )
     {
         this.attrRegistry = attrRegistry;
+    }
+    
+    
+    public DnNormalizer()
+    {
+    }
+ 
+    
+    public void setRegistries( Registries registries )
+    {
+        this.attrRegistry = registries.getAttributeTypeRegistry();
     }
     
 

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultComparatorRegistry.java Fri Dec 29 00:15:23 2006
@@ -61,7 +61,6 @@
     {
         this.oidToSchema = new HashMap<String,String>();
         this.comparators = new HashMap<String, Comparator>();
-        SerializableComparator.setRegistry( this );
     }
 
 

Modified: directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/CachingNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/CachingNormalizer.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/CachingNormalizer.java (original)
+++ directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/CachingNormalizer.java Fri Dec 29 00:15:23 2006
@@ -33,6 +33,8 @@
  */
 public class CachingNormalizer implements Normalizer
 {
+    private static final long serialVersionUID = 1L;
+
     /** Cache maximum size default */
     public static final int CACHE_MAX = 250;
 
@@ -40,7 +42,7 @@
     private final SynchronizedLRUMap cache;
 
     /** The underlying decorated Normalizer */
-    private final Normalizer normalizer;
+    protected final Normalizer normalizer;
 
 
     // ------------------------------------------------------------------------
@@ -51,10 +53,9 @@
      * Creates a CachingNormalizer that decorates another normalizer using a
      * default cache size.
      * 
-     * @param normalizer
-     *            the underlying Normalizer being decorated
+     * @param normalizer the underlying Normalizer being decorated
      */
-    public CachingNormalizer(Normalizer normalizer)
+    public CachingNormalizer( Normalizer normalizer )
     {
         this( normalizer, CACHE_MAX );
     }
@@ -64,12 +65,10 @@
      * Creates a CachingNormalizer that decorates another normalizer using a
      * specified cache size.
      * 
-     * @param normalizer
-     *            the underlying Normalizer being decorated
-     * @param cacheSz
-     *            the maximum size of the name cache
+     * @param normalizer the underlying Normalizer being decorated
+     * @param cacheSz the maximum size of the name cache
      */
-    public CachingNormalizer(Normalizer normalizer, int cacheSz)
+    public CachingNormalizer( Normalizer normalizer, int cacheSz )
     {
         this.normalizer = normalizer;
         cache = new SynchronizedLRUMap( cacheSz );

Modified: directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NormalizingComparator.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NormalizingComparator.java (original)
+++ directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NormalizingComparator.java Fri Dec 29 00:15:23 2006
@@ -48,12 +48,10 @@
     /**
      * A comparator which normalizes a value first before comparing them.
      * 
-     * @param normalizer
-     *            the Normalizer to normalize values with before comparing
-     * @param comparator
-     *            the underlying comparator to use for comparisons
+     * @param normalizer the Normalizer to normalize values with before comparing
+     * @param comparator the underlying comparator to use for comparisons
      */
-    public NormalizingComparator(Normalizer normalizer, Comparator comparator)
+    public NormalizingComparator( Normalizer normalizer, Comparator comparator )
     {
         this.normalizer = normalizer;
         this.comparator = comparator;

Modified: directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AcceptAllSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AcceptAllSyntaxChecker.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AcceptAllSyntaxChecker.java (original)
+++ directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AcceptAllSyntaxChecker.java Fri Dec 29 00:15:23 2006
@@ -33,21 +33,31 @@
 public class AcceptAllSyntaxChecker implements SyntaxChecker
 {
     /** the OID of the Syntax this checker is associated with */
-    private final String oid;
+    private String oid;
 
 
     /**
      * Creates a SyntaxChecker which accepts all values.
      * 
-     * @param oid
-     *            the oid of the Syntax this checker is associated with
+     * @param oid the oid of the Syntax this checker is associated with
      */
-    public AcceptAllSyntaxChecker(String oid)
+    public AcceptAllSyntaxChecker( String oid )
     {
         this.oid = oid;
     }
 
+    
+    public AcceptAllSyntaxChecker()
+    {
+    }
 
+    
+    public void setSyntaxOid( String oid )
+    {
+        this.oid = oid;
+    }
+    
+    
     /**
      * @see SyntaxChecker#getSyntaxOid()
      */

Modified: directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BinarySyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BinarySyntaxChecker.java?view=diff&rev=490951&r1=490950&r2=490951
==============================================================================
--- directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BinarySyntaxChecker.java (original)
+++ directory/branches/trunks/schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BinarySyntaxChecker.java Fri Dec 29 00:15:23 2006
@@ -51,11 +51,10 @@
 
 
     /**
-     * Private default constructor to prevent unnecessary instantiation.
+     * Bogus this should be public and not private.
      */
-    private BinarySyntaxChecker()
+    public BinarySyntaxChecker()
     {
-        // so people are not creating this unnecesarily
     }