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/17 02:38:53 UTC

svn commit: r487927 - in /directory/branches/trunks/schema/apacheds: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/c...

Author: akarasulu
Date: Sat Dec 16 17:38:48 2006
New Revision: 487927

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

 o most significantly we added a common SchemaLoader interface
 o made BootstrapSchemaLoader implement this interface
 o fixed issues while refactoring 
 o added new methods to Registries to deal with schema objects
 o Registries will now load their own schemas using their assigned schema loader


Added:
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java
Removed:
    directory/branches/trunks/schema/apacheds/schema-extras/src/main/java/org/apache/directory/server/core/
    directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/core/
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/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.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/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSchemaLoaderTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
    directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
    directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
    directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/schema/bootstrap/ExtraSchemaLoadTest.java
    directory/branches/trunks/schema/apacheds/schema-registries/pom.xml
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java
    directory/branches/trunks/schema/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.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=487927&r1=487926&r2=487927
==============================================================================
--- 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 Sat Dec 16 17:38:48 2006
@@ -133,7 +133,7 @@
     private AttributesFactory attributesFactory = new AttributesFactory();
     
     /** Registries of objects used to load the schema partition. */
-    private Registries registries = new DefaultRegistries();
+    private Registries registries;
 
     /** The store to load schema entities into. */
     private JdbmStore store = new JdbmStore();
@@ -551,6 +551,7 @@
         getLog().info( "" );
         
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        registries = new DefaultRegistries( loader );
         try
         {
             loader.load( schemas.values(), registries );

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=487927&r1=487926&r2=487927
==============================================================================
--- 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 Sat Dec 16 17:38:48 2006
@@ -47,9 +47,9 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
 import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -749,11 +749,11 @@
         // --------------------------------------------------------------------
 
         // setup temporary loader and temp registry 
-        registries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        registries = new DefaultRegistries( loader );
         
         // load essential bootstrap schemas 
-        Set<BootstrapSchema> bootstrapSchemas = new HashSet<BootstrapSchema>();
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
         bootstrapSchemas.add( new ApachemetaSchema() );
         bootstrapSchemas.add( new ApacheSchema() );
         bootstrapSchemas.add( new CoreSchema() );

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=487927&r1=487926&r2=487927
==============================================================================
--- 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 Sat Dec 16 17:38:48 2006
@@ -52,7 +52,7 @@
     private Partition partition;
     private OidRegistry oidRegistry;
     private AttributeTypeRegistry attrRegistry;
-    
+
     
     public PartitionSchemaLoader( Partition partition, Registries bootstrapRegiistries )
     {
@@ -60,6 +60,12 @@
         this.partition = partition;
         this.oidRegistry = bootstrapRegiistries.getOidRegistry();
         this.attrRegistry = bootstrapRegiistries.getAttributeTypeRegistry();
+    }
+    
+    
+    public void loadEnabled( Registries registries ) throws NamingException
+    {
+        
     }
     
     

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=487927&r1=487926&r2=487927
==============================================================================
--- 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 Sat Dec 16 17:38:48 2006
@@ -42,7 +42,6 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.schema.bootstrap.Schema;
@@ -87,11 +86,11 @@
         // --------------------------------------------------------------------
 
         // setup temporary loader and temp registry 
-        registries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        registries = new DefaultRegistries( loader );
         
         // load essential bootstrap schemas 
-        Set<BootstrapSchema> bootstrapSchemas = new HashSet<BootstrapSchema>();
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
         bootstrapSchemas.add( new ApachemetaSchema() );
         bootstrapSchemas.add( new ApacheSchema() );
         bootstrapSchemas.add( new CoreSchema() );

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java Sat Dec 16 17:38:48 2006
@@ -65,10 +65,10 @@
     {
         super( name );
 
-        registries = new DefaultRegistries();
-
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        registries = new DefaultRegistries( loader );
+
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new SystemSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new CoreSchema() );

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java Sat Dec 16 17:38:48 2006
@@ -44,17 +44,16 @@
 
 /**
  * Tests methods in SchemaService.
- * 
  */
 public class SchemaServiceTest extends TestCase
 {
-    DefaultRegistries registries = new DefaultRegistries();
+    DefaultRegistries registries;
 
 
     public void setUp() throws Exception
     {
-        registries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        registries = new DefaultRegistries( loader );
         loader.load( new SystemSchema(), registries );
         loader.load( new ApacheSchema(), registries );
         loader.load( new CoreSchema(), registries );

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSchemaLoaderTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSchemaLoaderTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSchemaLoaderTest.java Sat Dec 16 17:38:48 2006
@@ -31,9 +31,9 @@
 import junit.framework.TestCase;
 
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -47,13 +47,14 @@
  */
 public class BootstrapSchemaLoaderTest extends TestCase
 {
+    BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
     DefaultRegistries registries;
 
 
     protected void setUp() throws Exception
     {
         super.setUp();
-        registries = new DefaultRegistries();
+        registries = new DefaultRegistries( loader );
     }
 
 
@@ -66,8 +67,7 @@
 
     public void testLoadAll() throws NamingException
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new CoreSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new SystemSchema() );
@@ -92,7 +92,6 @@
     public void testSystemSchemaLoad() throws NamingException
     {
         SystemSchema systemSchema = new SystemSchema();
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         loader.load( systemSchema, registries );
 
         AttributeType type;
@@ -110,9 +109,7 @@
     public void testApacheSchemaLoad() throws NamingException
     {
         testSystemSchemaLoad();
-
         ApacheSchema apacheSchema = new ApacheSchema();
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         loader.load( apacheSchema, registries );
 
         AttributeType type;
@@ -129,9 +126,7 @@
 
     public void testEveDepsSchemaLoad() throws NamingException
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new ApacheSchema() );
         schemas.add( new SystemSchema() );
 
@@ -151,9 +146,7 @@
     public void testCoreSchemaLoad() throws NamingException
     {
         testSystemSchemaLoad();
-
         CoreSchema coreSchema = new CoreSchema();
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         loader.load( coreSchema, registries );
 
         AttributeType type;
@@ -170,9 +163,7 @@
 
     public void testCoreDepsSchemaLoad() throws NamingException
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new CoreSchema() );
         schemas.add( new SystemSchema() );
 

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java Sat Dec 16 17:38:48 2006
@@ -62,9 +62,9 @@
      */
     private void init() throws NamingException
     {
-        DefaultRegistries bsRegistries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        DefaultRegistries bsRegistries = new DefaultRegistries( loader );
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new SystemSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new CoreSchema() );

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java Sat Dec 16 17:38:48 2006
@@ -57,9 +57,9 @@
      */
     private void init() throws NamingException
     {
-        DefaultRegistries bsRegistries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        DefaultRegistries bsRegistries = new DefaultRegistries( loader );
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new SystemSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new CoreSchema() );

Modified: directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java Sat Dec 16 17:38:48 2006
@@ -56,10 +56,10 @@
 
     private void init() throws NamingException
     {
-        DefaultRegistries bsRegistries = new DefaultRegistries();
-        registries = bsRegistries;
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        DefaultRegistries bsRegistries = new DefaultRegistries( loader );
+        registries = bsRegistries;
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new SystemSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new CoreSchema() );

Modified: directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java Sat Dec 16 17:38:48 2006
@@ -24,6 +24,7 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Properties;
 import java.util.Stack;
 
 import javax.naming.NamingException;
@@ -42,6 +43,7 @@
 import org.apache.directory.server.schema.registries.NormalizerRegistry;
 import org.apache.directory.server.schema.registries.ObjectClassRegistry;
 import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.schema.registries.SchemaLoader;
 import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
 import org.apache.directory.server.schema.registries.SyntaxRegistry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -64,7 +66,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class BootstrapSchemaLoader
+public class BootstrapSchemaLoader implements SchemaLoader
 {
     private static final Logger log = LoggerFactory.getLogger( BootstrapSchemaLoader.class );
 
@@ -101,7 +103,7 @@
      * @param registries the registries to fill with producer created objects
      * @throws NamingException if there are any failures during this process
      */
-    public final void load( Collection<BootstrapSchema> bootstrapSchemas, Registries registries ) throws NamingException
+    public final void load( Collection<Schema> bootstrapSchemas, Registries registries ) throws NamingException
     {
         BootstrapSchema[] schemas = new BootstrapSchema[bootstrapSchemas.size()];
         schemas = ( BootstrapSchema[] ) bootstrapSchemas.toArray( schemas );
@@ -371,5 +373,76 @@
             ne.setRootCause( e );
             throw ne;
         }
+    }
+
+
+    public Schema getSchema( String schemaName ) throws NamingException
+    {
+        return getSchema( schemaName, null );
+    }
+    
+    
+    public Schema getSchema( String schemaName, Properties schemaProperties ) throws NamingException
+    {
+        String baseName = schemaName;
+        schemaName = schemaName.toLowerCase();
+        StringBuffer buf = new StringBuffer();
+
+        
+        if ( schemaProperties == null || schemaProperties.getProperty( "package" ) == null )
+        {
+            // first see if we can load a schema object using the default bootstrap package
+            Properties props = new Properties();
+            props.put( "package", "org.apache.directory.server.schema.bootstrap" );
+            
+            try
+            {
+                Schema schema = getSchema( baseName, props );
+                return schema;
+            }
+            catch( NamingException e )
+            {
+                throw new NamingException( "Can't find the bootstrap schema class in the default " +
+                        "\n bootstrap schema package.  I need a package name property with key \"package\"." );
+            }
+        }
+        
+        buf.append( schemaProperties.getProperty( "package" ) );
+        buf.append( '.' );
+        buf.append( Character.toUpperCase( schemaName.charAt( 0 ) ) );
+        buf.append( schemaName.substring( 1 ) );
+        schemaName = buf.toString();
+        
+        Schema schema = null;
+        try
+        {
+            schema = ( Schema ) Class.forName( schemaName ).newInstance();
+        }
+        catch ( InstantiationException e )
+        {
+            NamingException ne = new NamingException( "Failed to instantiate schema object: " + schemaName );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( IllegalAccessException e )
+        {
+            NamingException ne = 
+                new NamingException( "Failed to access default constructor of schema object: " + schemaName );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( ClassNotFoundException e )
+        {
+            NamingException ne = new NamingException( "Schema class not found: " + schemaName );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        
+        return schema;
+    }
+
+
+    public void load( Schema schema, Registries registries ) throws NamingException
+    {
     }
 }

Modified: directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/schema/bootstrap/ExtraSchemaLoadTest.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/schema/bootstrap/ExtraSchemaLoadTest.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/schema/bootstrap/ExtraSchemaLoadTest.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-extras/src/test/java/org/apache/directory/server/schema/bootstrap/ExtraSchemaLoadTest.java Sat Dec 16 17:38:48 2006
@@ -31,7 +31,6 @@
 import junit.framework.TestCase;
 
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
@@ -53,7 +52,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        registries = new DefaultRegistries();
+        registries = new DefaultRegistries( new BootstrapSchemaLoader() );
     }
 
 
@@ -67,7 +66,7 @@
     public void testLoadAll() throws NamingException
     {
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new CoreSchema() );
         schemas.add( new ApacheSchema() );
         schemas.add( new ApachednsSchema() );
@@ -153,7 +152,7 @@
     {
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
 
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new ApacheSchema() );
         schemas.add( new SystemSchema() );
 
@@ -213,7 +212,7 @@
     {
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
 
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new CoreSchema() );
         schemas.add( new JavaSchema() );
         schemas.add( new SystemSchema() );
@@ -235,7 +234,7 @@
     {
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
 
-        Set<BootstrapSchema> schemas = new HashSet<BootstrapSchema>();
+        Set<Schema> schemas = new HashSet<Schema>();
         schemas.add( new ApacheSchema() );
         schemas.add( new CoreSchema() );
         schemas.add( new JavaSchema() );

Modified: directory/branches/trunks/schema/apacheds/schema-registries/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/pom.xml?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/pom.xml (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/pom.xml Sat Dec 16 17:38:48 2006
@@ -18,6 +18,11 @@
       <artifactId>nlog4j</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>apacheds-core-shared</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
   </dependencies>
 </project>
 

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultRegistries.java Sat Dec 16 17:38:48 2006
@@ -21,11 +21,15 @@
 
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 import javax.naming.NamingException;
 
+import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
@@ -52,10 +56,13 @@
     private DefaultOidRegistry oidRegistry;
     private DefaultSyntaxCheckerRegistry syntaxCheckerRegistry;
     private DefaultSyntaxRegistry syntaxRegistry;
+    private Map<String,Schema> byName = new HashMap<String, Schema>();
+    private final SchemaLoader schemaLoader;
 
 
-    public DefaultRegistries()
+    public DefaultRegistries( SchemaLoader schemaLoader )
     {
+        this.schemaLoader = schemaLoader;
         oidRegistry = new DefaultOidRegistry();
         normalizerRegistry = new DefaultNormalizerRegistry();
         comparatorRegistry = new DefaultComparatorRegistry();
@@ -456,5 +463,40 @@
         }
 
         return isSuccess;
+    }
+
+    
+    /**
+     * Alterations to the returned map of schema names to schema objects does not 
+     * change the map returned from this method.  The returned map is however mutable.
+     */
+    public Map<String, Schema> getLoadedSchemas()
+    {
+        return new HashMap<String,Schema>( byName );
+    }
+
+
+    public void load( String schemaName ) throws NamingException
+    {
+        load( schemaName, new Properties() );
+    }
+
+
+    public void load( String schemaName, Properties schemaProperties ) throws NamingException
+    {
+        Schema schema = schemaLoader.getSchema( schemaName, schemaProperties );
+        if ( schema.isDisabled() )
+        {
+            throw new NamingException( "Disabled schemas cannot be loaded into registries." );
+        }
+        
+        byName.put( schema.getSchemaName(), schema );
+        schemaLoader.load( schema, this );
+    }
+
+
+    public SchemaLoader setSchemaLoader()
+    {
+        return schemaLoader;
     }
 }

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/Registries.java Sat Dec 16 17:38:48 2006
@@ -21,6 +21,12 @@
 
 
 import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.schema.bootstrap.Schema;
 
 
 /**
@@ -31,9 +37,17 @@
  */
 public interface Registries
 {
+    Map<String,Schema> getLoadedSchemas();
+    
+    void load( String schemaName ) throws NamingException;
+    
+    void load( String schemaName, Properties props ) throws NamingException;
+    
+    SchemaLoader setSchemaLoader();
+    
     AttributeTypeRegistry getAttributeTypeRegistry();
 
-
+    
     ComparatorRegistry getComparatorRegistry();
 
 

Added: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java?view=auto&rev=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java (added)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java Sat Dec 16 17:38:48 2006
@@ -0,0 +1,78 @@
+/*
+ *  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.schema.registries;
+
+
+import java.util.Collection;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.schema.bootstrap.Schema;
+
+
+/**
+ * Loads schemas into registres.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface SchemaLoader
+{
+    /**
+     * Gets a schema object based on it's name.
+     * 
+     * @param schemaName the name of the schema to load
+     * @return the Schema object associated with the name
+     * @throws NamingException if any problems while trying to find the associated Schema
+     */
+    Schema getSchema( String schemaName ) throws NamingException;
+    
+    /**
+     * Gets a schema object based on it's name and some properties.
+     * 
+     * @param schemaName the name of the schema to load
+     * @param schemaProperties the properties associated with that schema to facilitate locating/loading it
+     * @return the Schema object associated with the name
+     * @throws NamingException if any problems while trying to find the associated Schema
+     */
+    Schema getSchema( String schemaName, Properties schemaProperties ) throws NamingException;
+    
+    /**
+     * Loads a collection of schemas.  A best effort should be made to load the dependended 
+     * schemas that these schemas may rely on even if they are not included in the collection.
+     * 
+     * @param schemas the collection of schemas to load
+     * @param registries the registries to populate with these schemas
+     * @throws NamingException if any kind of problems are encountered during the load
+     */
+    void load( Collection<Schema> schemas, Registries registries ) throws NamingException;
+    
+    /**
+     * Loads a single schema at least.  A best effort should be made to load the dependended 
+     * schemas that this schema may rely on.  Hence this method may load more schemas by 
+     * leveraging the dependency information associated with a Schema.
+     * 
+     * @param schema the schema to load
+     * @param registries the registries to populate with these schemas
+     * @throws NamingException if any kind of problems are encountered during the load
+     */
+    void load( Schema schema, Registries registries ) throws NamingException;
+}

Modified: directory/branches/trunks/schema/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java?view=diff&rev=487927&r1=487926&r2=487927
==============================================================================
--- directory/branches/trunks/schema/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java (original)
+++ directory/branches/trunks/schema/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java Sat Dec 16 17:38:48 2006
@@ -47,6 +47,7 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmMasterTable;
 //import org.apache.directory.server.core.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.tools.ToolCommandListener;
@@ -75,7 +76,7 @@
     public static final String EXCLUDEDATTRIBUTES_PARAMETER = "excluded-attributes";
     public static final String INCLUDEOPERATIONAL_PARAMETER = "include-operational";
 
-    private DefaultRegistries bootstrapRegistries = new DefaultRegistries();
+    private DefaultRegistries bootstrapRegistries = new DefaultRegistries( new BootstrapSchemaLoader() );
     //private BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
     private Set<String> exclusions = new HashSet<String>();
     private boolean includeOperational = false;