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 04:05:25 UTC
svn commit: r487933 - in /directory/branches/trunks/schema/apacheds:
bootstrap-partition/
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/apac...
Author: akarasulu
Date: Sat Dec 16 19:05:24 2006
New Revision: 487933
URL: http://svn.apache.org/viewvc?view=rev&rev=487933
Log:
changes ...
o renamed a load method in SchemaLoader interface to show that it loads with
dependency resolution
o added extra overloaded method for loading with dependencies when loading a
single schema as opposed to a collection of them
o updates to rest of the code
o added protection code to make sure we do not reload a schema that has already
been loaded into the registries
Modified:
directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml
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/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/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java
directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java
Modified: directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml?view=diff&rev=487933&r1=487932&r2=487933
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml Sat Dec 16 19:05:24 2006
@@ -69,6 +69,7 @@
<indexedAttribute>ou</indexedAttribute>
<indexedAttribute>cn</indexedAttribute>
<indexedAttribute>m-oid</indexedAttribute>
+ <indexedAttribute>m-disabled</indexedAttribute>
</indexedAttributes>
<bootstrapSchemaClasses>
<bootstrapSchemaClass>org.apache.directory.server.schema.bootstrap.ApachednsSchema</bootstrapSchemaClass>
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -554,7 +554,7 @@
registries = new DefaultRegistries( loader );
try
{
- loader.load( schemas.values(), registries );
+ loader.loadWithDependencies( schemas.values(), registries );
}
catch ( NamingException e )
{
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -758,7 +758,7 @@
bootstrapSchemas.add( new ApacheSchema() );
bootstrapSchemas.add( new CoreSchema() );
bootstrapSchemas.add( new SystemSchema() );
- loader.load( bootstrapSchemas, registries );
+ loader.loadWithDependencies( bootstrapSchemas, registries );
// run referential integrity tests
java.util.List errors = registries.checkRefInteg();
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -41,6 +41,7 @@
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
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.filter.ExprNode;
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -81,7 +82,20 @@
}
- Map<String,Schema> getSchemas() throws NamingException
+ /**
+ * 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>();
NamingEnumeration list = listSchemas();
@@ -96,7 +110,7 @@
}
- Set<String> getSchemaNames() throws NamingException
+ public Set<String> getSchemaNames() throws NamingException
{
Set<String> schemaNames = new HashSet<String>();
NamingEnumeration list = listSchemas();
@@ -135,7 +149,7 @@
}
- public final void load( Collection<Schema> schemas, Registries registries ) throws NamingException
+ public final void loadWithDependencies( Collection<Schema> schemas, Registries registries ) throws NamingException
{
HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();
Iterator<Schema> list = schemas.iterator();
@@ -157,10 +171,24 @@
public final void load( Schema schema, Registries registries ) throws NamingException
{
+ if ( registries.getLoadedSchemas().containsKey( schema.getSchemaName() ) )
+ {
+ return;
+ }
+
// TODO Auto-generated method stub: NOT FINISHED YET!!!!!!!!!!!!!
// load the schema entities here ....
notifyListenerOrRegistries( schema, registries );
+ }
+
+
+ public void loadWithDependencies( Schema schema, Registries registries ) throws NamingException
+ {
+ HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();
+ notLoaded.put( schema.getSchemaName(), schema );
+ Properties props = new Properties();
+ loadDepsFirst( new Stack<String>(), notLoaded, schema, registries, props );
}
}
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -95,7 +95,7 @@
bootstrapSchemas.add( new ApacheSchema() );
bootstrapSchemas.add( new CoreSchema() );
bootstrapSchemas.add( new SystemSchema() );
- loader.load( bootstrapSchemas, registries );
+ loader.loadWithDependencies( bootstrapSchemas, registries );
// run referential integrity tests
java.util.List errors = registries.checkRefInteg();
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -72,7 +72,7 @@
schemas.add( new SystemSchema() );
schemas.add( new ApacheSchema() );
schemas.add( new CoreSchema() );
- loader.load( schemas, ( DefaultRegistries ) registries );
+ loader.loadWithDependencies( schemas, ( DefaultRegistries ) registries );
java.util.List errors = registries.checkRefInteg();
if ( !errors.isEmpty() )
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -72,7 +72,7 @@
schemas.add( new ApacheSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
// from core.schema
@@ -130,7 +130,7 @@
schemas.add( new ApacheSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
type = registries.getAttributeTypeRegistry().lookup( "apacheNdn" );
assertNotNull( type );
@@ -167,7 +167,7 @@
schemas.add( new CoreSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
type = registries.getAttributeTypeRegistry().lookup( "knowledgeInformation" );
assertNotNull( type );
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -68,7 +68,7 @@
schemas.add( new SystemSchema() );
schemas.add( new ApacheSchema() );
schemas.add( new CoreSchema() );
- loader.load( schemas, bsRegistries );
+ loader.loadWithDependencies( schemas, bsRegistries );
registries = bsRegistries;
}
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -63,7 +63,7 @@
schemas.add( new SystemSchema() );
schemas.add( new ApacheSchema() );
schemas.add( new CoreSchema() );
- loader.load( schemas, bsRegistries );
+ loader.loadWithDependencies( schemas, bsRegistries );
registries = bsRegistries;
}
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -63,7 +63,7 @@
schemas.add( new SystemSchema() );
schemas.add( new ApacheSchema() );
schemas.add( new CoreSchema() );
- loader.load( schemas, bsRegistries );
+ loader.loadWithDependencies( schemas, bsRegistries );
}
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -24,6 +24,7 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import java.util.Stack;
@@ -95,7 +96,22 @@
registries = new ThreadLocal<Registries>();
}
+
+ public final void loadWithDependencies( Schema schema, Registries registries ) throws NamingException
+ {
+ if ( ! ( schema instanceof BootstrapSchema ) )
+ {
+ throw new NamingException( "Expecting schema to be of sub-type BootstrapSchema" );
+ }
+
+ Map<String, Schema> notLoaded = new HashMap<String, Schema>();
+ notLoaded.put( schema.getSchemaName(), schema );
+ Properties props = new Properties();
+ props.put( "package", ( ( BootstrapSchema ) schema ).getPackageName() );
+ loadDepsFirst( new Stack<String>(), notLoaded, schema, registries, props );
+ }
+
/**
* Loads a set of schemas by loading and running all producers for each
* dependent schema first.
@@ -104,7 +120,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<Schema> bootstrapSchemas, Registries registries ) throws NamingException
+ public final void loadWithDependencies( Collection<Schema> bootstrapSchemas, Registries registries ) throws NamingException
{
BootstrapSchema[] schemas = new BootstrapSchema[bootstrapSchemas.size()];
schemas = ( BootstrapSchema[] ) bootstrapSchemas.toArray( schemas );
@@ -138,7 +154,7 @@
/**
- * Loads a schema by loading and running all producers for te schema.
+ * Loads a schema by loading and running all producers for the schema.
*
* @param schema the schema to load
* @param registries the registries to fill with producer created objects
@@ -146,6 +162,11 @@
*/
public final void load( Schema schema, Registries registries ) throws NamingException
{
+ if ( registries.getLoadedSchemas().containsKey( schema.getSchemaName() ) )
+ {
+ return;
+ }
+
if ( ! ( schema instanceof BootstrapSchema ) )
{
throw new NamingException( "Expecting schema to be of sub-type BootstrapSchema" );
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=487933&r1=487932&r2=487933
==============================================================================
--- 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 19:05:24 2006
@@ -83,7 +83,7 @@
schemas.add( new SambaSchema() );
schemas.add( new Krb5kdcSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
// from autofs.schema
@@ -156,7 +156,7 @@
schemas.add( new ApacheSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
type = registries.getAttributeTypeRegistry().lookup( "apacheNdn" );
assertNotNull( type );
@@ -217,7 +217,7 @@
schemas.add( new JavaSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
type = registries.getAttributeTypeRegistry().lookup( "javaFactory" );
assertNotNull( type );
@@ -240,7 +240,7 @@
schemas.add( new JavaSchema() );
schemas.add( new SystemSchema() );
- loader.load( schemas, registries );
+ loader.loadWithDependencies( schemas, registries );
AttributeType type;
type = registries.getAttributeTypeRegistry().lookup( "apacheAlias" );
assertNotNull( type );
Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java?view=diff&rev=487933&r1=487932&r2=487933
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java Sat Dec 16 19:05:24 2006
@@ -80,6 +80,11 @@
protected final void loadDepsFirst( Stack<String> beenthere, Map<String,Schema> notLoaded, Schema schema,
Registries registries, Properties props ) throws NamingException
{
+ if ( registries.getLoadedSchemas().containsKey( schema.getSchemaName() ) )
+ {
+ return;
+ }
+
beenthere.push( schema.getSchemaName() );
String[] deps = schema.getDependencies();
Modified: 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=diff&rev=487933&r1=487932&r2=487933
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SchemaLoader.java Sat Dec 16 19:05:24 2006
@@ -71,12 +71,19 @@
* @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;
+ void loadWithDependencies( 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.
+ * Loads a single schema at least and possibly it's dependencies.
+ *
+ * @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 loadWithDependencies( Schema schemas, Registries registries ) throws NamingException;
+
+ /**
+ * Loads a single schema. Do not try to resolve dependencies while implementing this method.
*
* @param schema the schema to load
* @param registries the registries to populate with these schemas