You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/11/09 23:45:09 UTC

svn commit: r473116 - in /directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core: ./ schema/ schema/bootstrap/

Author: elecharny
Date: Thu Nov  9 14:45:08 2006
New Revision: 473116

URL: http://svn.apache.org/viewvc?view=rev&rev=473116
Log:
Applied Norvals patch, after some code refactoring to respect coding convention
and Java 5 switching

Added:
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/ApacheSchemaAdditions.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/InetorgpersonSchemaAdditions.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/NisSchemaAdditions.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SchemaAdditions.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemSchemaAdditions.java
Modified:
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/FileSystemSchemaLoader.java
    directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaFromFileConverter.java

Modified: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?view=diff&rev=473116&r1=473115&r2=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Thu Nov  9 14:45:08 2006
@@ -1,76 +1,50 @@
-/*
- *  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;
 
-
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
+import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.authz.AuthorizationService;
-import org.apache.directory.server.core.configuration.Configuration;
-import org.apache.directory.server.core.configuration.ConfigurationException;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
-import org.apache.directory.server.core.configuration.SchemaLoader;
-import org.apache.directory.server.core.interceptor.InterceptorChain;
-import org.apache.directory.server.core.jndi.AbstractContextFactory;
 import org.apache.directory.server.core.jndi.DeadContext;
 import org.apache.directory.server.core.jndi.PropertyKeys;
 import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.jndi.AbstractContextFactory;
+import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.core.schema.AttributeTypeRegistry;
-import org.apache.directory.server.core.schema.bootstrap.BootstrapRegistries;
-import org.apache.directory.server.core.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.core.schema.global.GlobalRegistries;
-import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
+import org.apache.directory.server.core.schema.bootstrap.BootstrapRegistries;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.configuration.ConfigurationException;
+import org.apache.directory.server.core.configuration.SchemaLoader;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
-import org.apache.directory.shared.ldap.ldif.Entry;
-import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
-import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
-
+import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import java.util.*;
 
 /**
- * Default implementation of {@link DirectoryService}.
- * 
+ * Default implementation of {@link org.apache.directory.server.core.DirectoryService}.
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 class DefaultDirectoryService extends DirectoryService
 {
-    private static final Logger log = LoggerFactory.getLogger( DefaultDirectoryService.class );
+    private static final Logger log = LoggerFactory.getLogger( org.apache.directory.server.core.DefaultDirectoryService.class );
     private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
 
     private final String instanceId;
@@ -128,7 +102,7 @@
     }
 
 
-    public synchronized Context getJndiContext( LdapDN principalDn, String principal, byte[] credential, 
+    public synchronized Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,
         String authentication, String rootDN ) throws NamingException
     {
         checkSecuritySettings( principal, credential, authentication );
@@ -163,7 +137,7 @@
             rootDN = "";
         }
         environment.put( Context.PROVIDER_URL, rootDN );
-        
+
         if ( principalDn != null )
         {
             environment.put( PropertyKeys.PARSED_BIND_DN, principalDn );
@@ -196,7 +170,7 @@
                     catch ( NamingException e )
                     {
                         log.warn( "Failed to shut down the directory service: "
-                            + DefaultDirectoryService.this.instanceId, e );
+                            + org.apache.directory.server.core.DefaultDirectoryService.this.instanceId, e );
                     }
                 }
             }, "ApacheDS Shutdown Hook (" + instanceId + ')' ) );
@@ -421,7 +395,7 @@
     private boolean createBootstrapEntries() throws NamingException
     {
         boolean firstStart = false;
-        
+
         // -------------------------------------------------------------------
         // create admin entry
         // -------------------------------------------------------------------
@@ -458,10 +432,10 @@
         // create system users area
         // -------------------------------------------------------------------
 
-        Map oidsMap = configuration.getGlobalRegistries().getAttributeTypeRegistry().getNormalizerMapping();
+        Map<String, OidNormalizer> oidsMap = configuration.getGlobalRegistries().getAttributeTypeRegistry().getNormalizerMapping();
         LdapDN userDn = new LdapDN( "ou=users,ou=system" );
         userDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( userDn ) )
         {
             firstStart = true;
@@ -485,7 +459,7 @@
 
         LdapDN groupDn = new LdapDN( "ou=groups,ou=system" );
         groupDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( groupDn ) )
         {
             firstStart = true;
@@ -510,7 +484,7 @@
         String upName = "cn=Administrators,ou=groups,ou=system";
         LdapDN normName = new LdapDN( "cn=administrators,ou=groups,ou=system" );
         normName.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( normName ) )
         {
             firstStart = true;
@@ -527,11 +501,8 @@
 
             partitionNexus.add(normName, attributes );
             AuthorizationService authzSrvc = ( AuthorizationService ) interceptorChain.get( "authorizationService" );
-            
-            if (authzSrvc != null) 
-            {
+            if (authzSrvc != null)
                 authzSrvc.cacheNewGroup( upName, normName, attributes );
-            }
         }
 
         // -------------------------------------------------------------------
@@ -540,7 +511,7 @@
 
         LdapDN configurationDn = new LdapDN( "ou=configuration,ou=system" );
         configurationDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( configurationDn ) )
         {
             firstStart = true;
@@ -564,8 +535,8 @@
 
         LdapDN partitionsDn = new LdapDN( "ou=partitions,ou=configuration,ou=system" );
         partitionsDn.normalize( oidsMap );
-        
-        if ( !partitionNexus.hasEntry( partitionsDn ) ) 
+
+        if ( !partitionNexus.hasEntry( partitionsDn ) )
         {
             firstStart = true;
 
@@ -588,7 +559,7 @@
 
         LdapDN servicesDn = new LdapDN( "ou=services,ou=configuration,ou=system" );
         servicesDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( servicesDn ) )
         {
             firstStart = true;
@@ -612,7 +583,7 @@
 
         LdapDN interceptorsDn = new LdapDN( "ou=interceptors,ou=configuration,ou=system" );
         interceptorsDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( interceptorsDn ) )
         {
             firstStart = true;
@@ -636,7 +607,7 @@
 
         LdapDN sysPrefRootDn = new LdapDN( "prefNodeName=sysPrefRoot,ou=system");
         sysPrefRootDn.normalize( oidsMap );
-        
+
         if ( !partitionNexus.hasEntry( sysPrefRootDn ) )
         {
             firstStart = true;
@@ -669,7 +640,7 @@
 
         LdapDN adminDn = new LdapDN( PartitionNexus.ADMIN_PRINCIPAL );
         adminDn.normalize( configuration.getGlobalRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
-        
+
         Attributes adminEntry = partitionNexus.lookup( adminDn );
         Object userPassword = adminEntry.get( "userPassword" ).get();
         if ( userPassword instanceof byte[] )
@@ -695,33 +666,33 @@
         String principal = AbstractContextFactory.getPrincipal( env );
         byte[] credential = AbstractContextFactory.getCredential( env );
         String authentication = AbstractContextFactory.getAuthentication( env );
-        
+
         LdapDN principalDn = ( LdapDN ) env.get( PropertyKeys.PARSED_BIND_DN );
-        ServerLdapContext ctx = ( ServerLdapContext ) 
+        ServerLdapContext ctx = ( ServerLdapContext )
             getJndiContext( principalDn, principal, credential, authentication, "" );
 
         Iterator i = startupConfiguration.getTestEntries().iterator();
         while ( i.hasNext() )
         {
-        	try
-        	{
-	        	Entry entry =  (Entry)( ( Entry ) i.next() ).clone();
-	            Attributes attributes = entry.getAttributes();
-	            String dn = entry.getDn();
-
-	            try
-	            {
-	                ctx.createSubcontext( dn, attributes );
-	            }
-	            catch ( Exception e )
-	            {
-	                log.warn( dn + " test entry already exists.", e );
-	            }
-        	}
-        	catch ( CloneNotSupportedException cnse )
-        	{
+            try
+            {
+                Entry entry =  (Entry)( ( Entry ) i.next() ).clone();
+                Attributes attributes = entry.getAttributes();
+                String dn = entry.getDn();
+
+                try
+                {
+                    ctx.createSubcontext( dn, attributes );
+                }
+                catch ( Exception e )
+                {
+                    log.warn( dn + " test entry already exists.", e );
+                }
+            }
+            catch ( CloneNotSupportedException cnse )
+            {
                 log.warn( "Cannot clone the entry ", cnse );
-        	}
+            }
         }
     }
 
@@ -743,19 +714,20 @@
         // --------------------------------------------------------------------
 
         BootstrapRegistries bootstrapRegistries = new BootstrapRegistries();
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        loader.load( startupConfiguration.getBootstrapSchemas(), bootstrapRegistries );
-        
-        if ( startupConfiguration.getSchemaLoaders() != null )
+//        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+//        loader.load( startupConfiguration.getBootstrapSchemas(), bootstrapRegistries );
+        if (startupConfiguration.getSchemaLoaders() != null)
         {
-            for ( SchemaLoader schemaLoader:startupConfiguration.getSchemaLoaders() )
+            for (Iterator it = startupConfiguration.getSchemaLoaders().iterator(); it.hasNext();)
             {
+                final SchemaLoader     schemaLoader;
+
+                schemaLoader = (SchemaLoader) it.next();
                 schemaLoader.loadSchemas(startupConfiguration, bootstrapRegistries);
             }
         }
 
         java.util.List errors = bootstrapRegistries.checkRefInteg();
-        
         if ( !errors.isEmpty() )
         {
             NamingException e = new NamingException();
@@ -766,7 +738,8 @@
         }
 
         globalRegistries = new GlobalRegistries( bootstrapRegistries );
-        Set binaries = new HashSet();
+        Set<String> binaries = new HashSet<String>();
+        
         if ( this.environment.containsKey( BINARY_KEY ) )
         {
             if ( log.isInfoEnabled() )
@@ -775,6 +748,7 @@
             }
 
             String binaryIds = ( String ) this.environment.get( BINARY_KEY );
+            
             if ( binaryIds == null )
             {
                 if ( log.isWarnEnabled() )
@@ -806,6 +780,7 @@
         // now get all the attributeTypes that are binary from the registry
         AttributeTypeRegistry registry = globalRegistries.getAttributeTypeRegistry();
         Iterator list = registry.list();
+        
         while ( list.hasNext() )
         {
             AttributeType type = ( AttributeType ) list.next();
@@ -816,6 +791,7 @@
 
                 // add the lowercased name for the names for the attributeType
                 String[] names = type.getNames();
+                
                 for ( int ii = 0; ii < names.length; ii++ )
                 {
                     binaries.add( StringTools.lowerCase( StringTools.trim( names[ii] ) ) );

Modified: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java?view=diff&rev=473116&r1=473115&r2=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java (original)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java Thu Nov  9 14:45:08 2006
@@ -26,6 +26,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
 
 
 /**
@@ -90,7 +91,7 @@
      * Gets an oid/name to normalizer mapping used to normalize distinguished 
      * names.
      */
-    Map getNormalizerMapping() throws NamingException; 
+    Map<String, OidNormalizer> getNormalizerMapping() throws NamingException; 
     
     /**
      * Quick lookup to see if an attribute has descendants.

Modified: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/FileSystemSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/FileSystemSchemaLoader.java?view=diff&rev=473116&r1=473115&r2=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/FileSystemSchemaLoader.java (original)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/FileSystemSchemaLoader.java Thu Nov  9 14:45:08 2006
@@ -1,12 +1,18 @@
 package org.apache.directory.server.core.schema;
 
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.io.File;
 import java.io.FilenameFilter;
 
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.configuration.SchemaLoader;
+import org.apache.directory.server.core.schema.bootstrap.BootstrapRegistries;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,7 +32,7 @@
 
     private final String        directoryName;
     private final String        fileNameRegex;
-    private final List          fileNames;
+    private final List<String>  fileNames;
 
 
     // ------------------------------------------------------------------------
@@ -36,7 +42,7 @@
     /** Calls <code>FileSystemSchemaLoader(null, (String)null)</code>. */
     public FileSystemSchemaLoader()
     {
-        this(null, (String)null);
+        this( null, (String)null );
     }
 
     /**
@@ -48,11 +54,11 @@
      * @param fileNameRegex     Regular expression which file names need to match, if null
      *      then <code>".*_openldap.schema"</code> will be used.
      */
-    public FileSystemSchemaLoader(final String directoryName, final String fileNameRegex)
+    public FileSystemSchemaLoader( String directoryName, String fileNameRegex )
     {
         this.directoryName = directoryName;
         this.fileNameRegex = fileNameRegex;
-        this.fileNames = null;
+        fileNames = null;
     }
 
     /**
@@ -62,7 +68,7 @@
      * @param fileNames         Names of files under directoryName to load, in order (a schema
      *      file must appear before any files that are dependant on it).
      */
-    public FileSystemSchemaLoader(final String   directoryName, final List fileNames)
+    public FileSystemSchemaLoader( String directoryName, List<String> fileNames )
     {
         this.directoryName = directoryName;
         this.fileNames = fileNames;
@@ -74,69 +80,103 @@
         return directoryName;
     }
 
-    public Collection loadSchemas(final StartupConfiguration startupConfiguration, final Registries registries)
+    public Collection<File> loadSchemas( final StartupConfiguration startupConfiguration, final BootstrapRegistries registries)
     {
-        final File          schemaDir;
-        final File[]        schemaFiles;
-        final List          files;
-        final Collection    schemas;
-
-        if (directoryName == null)
+        if ( directoryName == null )
+        {
             return null;
+        }
 
-        schemaDir = new File(directoryName);
-        if (!schemaDir.isDirectory())
+        File                schemaDir = new File( directoryName );;
+        File[]              schemaFiles;
+        List<File>          files;
+        Collection<File>    schemas;
+        final Pattern       pattern;
+
+        if ( !schemaDir.isDirectory() )
+        {
             return null;
+        }
 
-        if (fileNameRegex != null)
+        if ( fileNameRegex != null )
         {
-            schemaFiles = schemaDir.listFiles(new FilenameFilter() {
-                public boolean accept(final File dir, final String name)
+            pattern = Pattern.compile(fileNameRegex);
+            
+            schemaFiles = schemaDir.listFiles( new FilenameFilter() 
                 {
-                    return name.matches(fileNameRegex);
-                }
-            });
-            if (schemaFiles == null)
+                    public boolean accept( File dir, String name )
+                    {
+                        return pattern.matcher( name ).matches();
+                    }
+                } );
+            
+            if ( schemaFiles == null )
+            {
                 return null;
-            Arrays.sort(schemaFiles);
-            files = Arrays.asList(schemaFiles);
+            }
+            
+            Arrays.sort( schemaFiles );
+            files = Arrays.asList( schemaFiles );
         }
         else
         {
-            if ((fileNames == null) || fileNames.isEmpty())
+            pattern = Pattern.compile( "(.*)\\.schema" );
+            
+            if ( ( fileNames == null ) || fileNames.isEmpty() )
+            {
                 return null;
-            files = new ArrayList(fileNames.size());
-            for (Iterator it = fileNames.iterator(); it.hasNext();)
+            }
+            
+            files = new ArrayList<File>( fileNames.size() );
+            
+            for ( String fileName:fileNames )
             {
-                final String    fl = (String) it.next();
-
-                files.add(new File(schemaDir, fl));
+                files.add( new File( schemaDir, fileName ) );
             }
         }
 
-        if (log.isInfoEnabled())
-            log.info("about to read " + files.size() + " schema files");
-        schemas = new ArrayList(files.size());
-        for (Iterator it = files.iterator(); it.hasNext();)
+        if ( log.isInfoEnabled() )
         {
-            final File                      schemaFile = (File) it.next();
-            final String                    schemaName;
-            final SchemaFromFileConverter   schema;
-
-            schemaName = schemaFile.getName().replaceFirst("_[^_]*", "");
+            log.info("about to read {} schema files", files.size() );
+        }
+        
+        schemas = new ArrayList<File>( files.size() );
+        
+        for ( File schemaFile:files )
+        {
+            String                    schemaName;
+            SchemaFromFileConverter   schema;
+            Matcher                   matcher;
+
+            matcher = pattern.matcher( schemaFile.getName() );
+            
+            if (matcher.matches())
+            {
+                schemaName = matcher.group(1);
+            }
+            else
+            {
+                schemaName = schemaFile.getName();
+            }
+            
             try
             {
-                schema = new SchemaFromFileConverter(schemaName, schemaFile);
-                schema.convert(registries);
-                if (log.isInfoEnabled())
-                    log.info("read schema from '" + schemaFile + '\'');
-                schemas.add(schemas);
+                schema = new SchemaFromFileConverter( schemaName, schemaFile );
+                schema.convert( registries );
+                
+                if ( log.isInfoEnabled() )
+                {
+                    log.info( "read schema from '{}'", schemaFile );
+                }
+                
+                schemas.add( schemaFile );
             }
             catch (Exception e)
             {
-                log.error("failed reading schema from '" + schemaFile + '\'', e);
+                log.error( "failed reading schema from '{}'", schemaFile, e );
             }
         }
-        return (schemas.isEmpty() ? null : schemas);
+        
+        return ( schemas.isEmpty() ? null : schemas );
     }
 }

Modified: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaFromFileConverter.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaFromFileConverter.java?view=diff&rev=473116&r1=473115&r2=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaFromFileConverter.java (original)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaFromFileConverter.java Thu Nov  9 14:45:08 2006
@@ -1,9 +1,13 @@
 package org.apache.directory.server.core.schema;
 
+
 import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
 import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
 import org.apache.directory.server.core.tools.schema.OpenLdapSchemaParser;
-import org.apache.directory.shared.ldap.schema.SchemaUtils;
+import org.apache.directory.server.core.schema.bootstrap.*;
+import org.apache.directory.server.core.jndi.ServerDirStateFactory;
+import org.apache.directory.server.core.jndi.ServerDirObjectFactory;
+import org.apache.directory.shared.ldap.schema.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -12,10 +16,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
+import java.util.*;
+
 
 /**
  *   Wrapper that can parse an OpenLDAP format schema and help register the
@@ -24,36 +26,85 @@
  */
 public class SchemaFromFileConverter extends SchemaProducer
 {
-    private static final Logger log = LoggerFactory.getLogger(SchemaFromFileConverter.class);
+    private static final Logger log = LoggerFactory.getLogger( SchemaFromFileConverter.class );
+
+    private String schemaName;
+    private File schemaFile;
+    private InputStream schemaStream;
+    private BootstrapRegistries registries;
+
+    /** the callback that just calls register() */
+    private final ProducerCallback cb = new ProducerCallback()
+    {
+        public void schemaObjectProduced( BootstrapProducer producer, String registryKey, Object schemaObject )
+            throws NamingException
+        {
+            register( producer.getType(), registryKey, schemaObject );
+        }
+    };
 
-    private final String        schemaName;
-    private final File          schemaFile;
-    private final InputStream   schemaStream;
 
-    public SchemaFromFileConverter(final String schemaName, final File schemaFile)
+    public SchemaFromFileConverter( String schemaName, final File schemaFile )
     {
         this.schemaName = schemaName;
         this.schemaFile = schemaFile;
         schemaStream = null;
     }
 
-    public SchemaFromFileConverter(final String schemaName, final InputStream schemaStream)
+
+    public SchemaFromFileConverter( String schemaName, final InputStream schemaStream )
     {
         this.schemaName = schemaName;
         this.schemaFile = null;
         this.schemaStream = schemaStream;
     }
 
-    public void convert(final Registries registries) throws NamingException, IOException, ParseException
+
+    public synchronized void convert( BootstrapRegistries registries ) throws NamingException, IOException,
+        ParseException
     {
-        final OpenLdapSchemaParser      parser = new OpenLdapSchemaParser();
+        OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
+        StringBuffer clsName = new StringBuffer( schemaName );
+        String schemaAdditionsClassName;
 
-        if (schemaFile != null)
-            parser.parse(schemaFile);
+        if ( schemaFile != null )
+        {
+            parser.parse( schemaFile );
+        }
         else
-            parser.parse(schemaStream);
-        convertAttributeTypes(registries, parser.getAttributeTypes());
-        convertObjectClasses(registries, parser.getObjectClassTypes());
+        {
+            parser.parse( schemaStream );
+        }
+        
+        convertAttributeTypes( registries, parser.getAttributeTypes() );
+        convertObjectClasses( registries, parser.getObjectClassTypes() );
+        clsName.setCharAt( 0, Character.toUpperCase( clsName.charAt( 0 ) ) );
+        schemaAdditionsClassName = SchemaAdditions.class.getName().replaceFirst( "(SchemaAdditions)",
+            clsName.toString() + "$1" );
+        this.registries = registries;
+
+        try
+        {
+            Class schemaAdditionsClass;
+            SchemaAdditions schemaAdditions;
+
+            schemaAdditionsClass = Class.forName( schemaAdditionsClassName );
+            schemaAdditions = ( SchemaAdditions ) schemaAdditionsClass.newInstance();
+            
+            for ( BootstrapProducer producer: schemaAdditions.getProducers() )
+            {
+                producer.produce( registries, cb );
+            }
+        }
+        catch ( Exception e )
+        {
+            log.debug( "didn't find class '" + schemaAdditionsClassName + "' containing manual additions "
+                + "for schema '" + schemaName + '\'', e );
+        }
+        finally
+        {
+            this.registries = null;
+        }
     }
 
 
@@ -64,121 +115,240 @@
      * @param toRegistries  Registry to be populated.
      * @throws javax.naming.NamingException
      */
-    public void convertAttributeTypes(final Registries toRegistries, final Collection attributeTypeLiterals)
+    public void convertAttributeTypes( Registries toRegistries, Collection attributeTypeLiterals )
         throws NamingException
     {
-        final AttributeTypeRegistry attributeTypeRegistry;
-        final ArrayList             skipped = new ArrayList();
-        int                         good = 0;
+        AttributeTypeRegistry attributeTypeRegistry;
+        ArrayList<String> skipped = new ArrayList<String>();
+        int good = 0;
 
         attributeTypeRegistry = toRegistries.getAttributeTypeRegistry();
-        for (Iterator it = attributeTypeLiterals.iterator(); it.hasNext();)
+        for ( Iterator it = attributeTypeLiterals.iterator(); it.hasNext(); )
         {
-            final AttributeTypeLiteral          in = (AttributeTypeLiteral) it.next();
-            final String                        oid = in.getOid();
-            final String                        name;
-            final ConcreteSchemaAttributeType   out;
+            AttributeTypeLiteral in = ( AttributeTypeLiteral ) it.next();
+            String oid = in.getOid();
+            String name;
+            ConcreteSchemaAttributeType out;
 
             name = in.getNames()[0];
-            if (attributeTypeRegistry.hasAttributeType(oid))
+            
+            if ( attributeTypeRegistry.hasAttributeType( oid ) )
             {
-                skipped.add(name + " : " + oid);
+                skipped.add( name + " : " + oid );
                 continue;
             }
-            out = newAttributeType(oid, toRegistries);
-            out.setDescription(in.getDescription());
-            out.setEqualityId(in.getEquality());
-            out.setLength(in.getLength());
-            out.setNames(in.getNames());
-            out.setOrderingId(in.getOrdering());
-            out.setSubstrId(in.getSubstr());
-            out.setSuperiorId(in.getSuperior());
-            out.setSyntaxId(in.getSyntax());
-            out.setUsage(in.getUsage());
-
-            if (SchemaFromFileConverter.log.isDebugEnabled())
-                SchemaFromFileConverter.log.debug("converting attributeType[" + good + "]: " + oid
-                    + "=" + name);
+            
+            out = newAttributeType( oid, toRegistries );
+            out.setDescription( in.getDescription() );
+            out.setEqualityId( in.getEquality() );
+            out.setLength( in.getLength() );
+            out.setNames( in.getNames() );
+            out.setOrderingId( in.getOrdering() );
+            out.setSubstrId( in.getSubstr() );
+            out.setSuperiorId( in.getSuperior() );
+            out.setSyntaxId( in.getSyntax() );
+            out.setUsage( in.getUsage() );
+
+            if ( SchemaFromFileConverter.log.isDebugEnabled() )
+            {
+                SchemaFromFileConverter.log.debug( "converting attributeType[" + good + "]: " + oid + "=" + name );
+            }
+            
             good++;
-            attributeTypeRegistry.register(schemaName, out);
+            attributeTypeRegistry.register( schemaName, out );
         }
-        SchemaFromFileConverter.log.info("'" + schemaName + "': registered " + good + " attributeTypes (skipped "
-                + skipped.size() + ")");
-        if (! skipped.isEmpty())
+        
+        SchemaFromFileConverter.log.info( "'" + schemaName + "': registered " + good + " attributeTypes (skipped "
+            + skipped.size() + ")" );
+        
+        if ( !skipped.isEmpty() )
         {
-            int     i = 0;
+            int i = 0;
 
-            Collections.sort(skipped);
-            for (Iterator it = skipped.iterator(); it.hasNext(); i++)
+            Collections.sort( skipped );
+        
+            for ( String skip:skipped )
             {
-                final String    skip = (String)it.next();
-
-                SchemaFromFileConverter.log.error("skipped attributeType[" + i + "]: " + skip);
+                SchemaFromFileConverter.log.error( "skipped attributeType[" + i + "]: " + skip );
             }
         }
     }
 
-    private void convertObjectClasses(final Registries toRegistries, final Collection objectClassLiterals)
+
+    private void convertObjectClasses( Registries toRegistries, Collection objectClassLiterals )
     {
-        final ObjectClassRegistry   objectClassRegistry;
-        final ArrayList             skipped = new ArrayList();
-        int                         good = 0;
+        ObjectClassRegistry objectClassRegistry;
+        ArrayList<String> skipped = new ArrayList<String>();
+        int good = 0;
 
         objectClassRegistry = toRegistries.getObjectClassRegistry();
 
-        for (Iterator it = objectClassLiterals.iterator(); it.hasNext();)
+        for ( Iterator it = objectClassLiterals.iterator(); it.hasNext(); )
         {
-            final ObjectClassLiteral        in = (ObjectClassLiteral) it.next();
-            final String                    oid = in.getOid();
-            final String                    name;
-            final ConcreteSchemaObjectClass out;
+            ObjectClassLiteral in = ( ObjectClassLiteral ) it.next();
+            String oid = in.getOid();
+            String name;
+            ConcreteSchemaObjectClass out;
 
             name = in.getNames()[0];
-            if (objectClassRegistry.hasObjectClass(oid))
+            
+            if ( objectClassRegistry.hasObjectClass( oid ) )
             {
-                skipped.add(name + " : " + oid);
+                skipped.add( name + " : " + oid );
                 continue;
             }
-            if (SchemaFromFileConverter.log.isDebugEnabled())
-                SchemaFromFileConverter.log.debug("converting objectClass[" + good + "]: " + oid
-                    + "=" + name);
+            
+            if ( SchemaFromFileConverter.log.isDebugEnabled() )
+            {
+                SchemaFromFileConverter.log.debug( "converting objectClass[" + good + "]: " + oid + "=" + name );
+            }
+            
             good++;
-                // @note Code copied from ./plugin/src/main/java/org/apache/ldap/server/tools/schema/ObjectClasses.template
-            out = newObjectClass(oid, toRegistries);
-            out.setDescription(in.getDescription());
-            out.setNames(in.getNames());
-            out.setType(in.getClassType());
-            out.setMayListIds(in.getMay());
-            out.setMustListIds(in.getMust());
-            out.setSuperClassIds(in.getSuperiors());
-            out.setObsolete(in.isObsolete());
+            // @note Code copied from ./plugin/src/main/java/org/apache/ldap/server/tools/schema/ObjectClasses.template
+            out = newObjectClass( oid, toRegistries );
+            out.setDescription( in.getDescription() );
+            out.setNames( in.getNames() );
+            out.setType( in.getClassType() );
+            out.setMayListIds( in.getMay() );
+            out.setMustListIds( in.getMust() );
+            out.setSuperClassIds( in.getSuperiors() );
+            out.setObsolete( in.isObsolete() );
 
             try
             {
-                    // avoid case where external schema attempts to register
-                    //  OC with bad references
-                SchemaUtils.render(out);
-                objectClassRegistry.register(schemaName, out);
+                // avoid case where external schema attempts to register
+                //  OC with bad references
+                SchemaUtils.render( out );
+                objectClassRegistry.register( schemaName, out );
             }
-            catch (NamingException e)
+            catch ( NamingException e )
             {
-                log.error("failed validation objectClass: " + name + ": " + e);
-                skipped.add(name + " : " + oid + " [failed]");
+                log.error( "failed validation objectClass: " + name + ": " + e );
+                skipped.add( name + " : " + oid + " [failed]" );
             }
         }
-        log.info("'" + schemaName + "': registered " + good + " objectClasss (skipped "
-            + skipped.size() + ")");
-        if (! skipped.isEmpty())
+        
+        log.info( "'" + schemaName + "': registered " + good + " objectClasss (skipped " + skipped.size() + ")" );
+        
+        if ( !skipped.isEmpty() )
         {
-            int     i = 0;
+            int i = 0;
 
-            Collections.sort(skipped);
-            for (Iterator it = skipped.iterator(); it.hasNext(); i++)
+            Collections.sort( skipped );
+            
+            for ( String skip:skipped )
             {
-                final String    skip = (String)it.next();
-
-                SchemaFromFileConverter.log.error("skipped objectClass[" + i + "]: " + skip);
+                SchemaFromFileConverter.log.error( "skipped objectClass[" + i + "]: " + skip );
             }
+        }
+    }
+
+
+    /**
+     * Registers objects
+     *
+     * @param type the type of the producer which determines the type of object produced
+     * @param id the primary key identifying the created object in a registry
+     * @param schemaObject the object being registered
+     * @throws NamingException if there are problems when registering the object
+     * in any of the registries
+     */
+    private void register( ProducerTypeEnum type, String id, Object schemaObject ) throws NamingException
+    {
+        switch ( type.getValue() )
+        {
+            case ( ProducerTypeEnum.NORMALIZER_PRODUCER_VAL    ):
+                Normalizer normalizer = ( Normalizer ) schemaObject;
+                NormalizerRegistry normalizerRegistry;
+                normalizerRegistry = registries.getNormalizerRegistry();
+                normalizerRegistry.register( schemaName, id, normalizer );
+                break;
+                
+            case ( ProducerTypeEnum.COMPARATOR_PRODUCER_VAL    ):
+                Comparator comparator = ( Comparator ) schemaObject;
+                ComparatorRegistry comparatorRegistry;
+                comparatorRegistry = registries.getComparatorRegistry();
+                comparatorRegistry.register( schemaName, id, comparator );
+                break;
+                
+            case ( ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER_VAL    ):
+                SyntaxChecker syntaxChecker = ( SyntaxChecker ) schemaObject;
+                SyntaxCheckerRegistry syntaxCheckerRegistry;
+                syntaxCheckerRegistry = registries.getSyntaxCheckerRegistry();
+                syntaxCheckerRegistry.register( schemaName, id, syntaxChecker );
+                break;
+                
+            case ( ProducerTypeEnum.SYNTAX_PRODUCER_VAL    ):
+                Syntax syntax = ( Syntax ) schemaObject;
+                SyntaxRegistry syntaxRegistry = registries.getSyntaxRegistry();
+                syntaxRegistry.register( schemaName, syntax );
+                break;
+                
+            case ( ProducerTypeEnum.MATCHING_RULE_PRODUCER_VAL    ):
+                MatchingRule matchingRule = ( MatchingRule ) schemaObject;
+                MatchingRuleRegistry matchingRuleRegistry;
+                matchingRuleRegistry = registries.getMatchingRuleRegistry();
+                matchingRuleRegistry.register( schemaName, matchingRule );
+                break;
+                
+            case ( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER_VAL    ):
+                AttributeType attributeType = ( AttributeType ) schemaObject;
+                AttributeTypeRegistry attributeTypeRegistry;
+                attributeTypeRegistry = registries.getAttributeTypeRegistry();
+                attributeTypeRegistry.register( schemaName, attributeType );
+                break;
+                
+            case ( ProducerTypeEnum.OBJECT_CLASS_PRODUCER_VAL    ):
+                ObjectClass objectClass = ( ObjectClass ) schemaObject;
+                ObjectClassRegistry objectClassRegistry;
+                objectClassRegistry = registries.getObjectClassRegistry();
+                objectClassRegistry.register( schemaName, objectClass );
+                break;
+                
+            case ( ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER_VAL    ):
+                MatchingRuleUse matchingRuleUse = ( MatchingRuleUse ) schemaObject;
+                MatchingRuleUseRegistry matchingRuleUseRegistry;
+                matchingRuleUseRegistry = registries.getMatchingRuleUseRegistry();
+                matchingRuleUseRegistry.register( schemaName, matchingRuleUse );
+                break;
+                
+            case ( ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER_VAL    ):
+                DITContentRule ditContentRule = ( DITContentRule ) schemaObject;
+                DITContentRuleRegistry ditContentRuleRegistry;
+                ditContentRuleRegistry = registries.getDitContentRuleRegistry();
+                ditContentRuleRegistry.register( schemaName, ditContentRule );
+                break;
+                
+            case ( ProducerTypeEnum.NAME_FORM_PRODUCER_VAL    ):
+                NameForm nameForm = ( NameForm ) schemaObject;
+                NameFormRegistry nameFormRegistry;
+                nameFormRegistry = registries.getNameFormRegistry();
+                nameFormRegistry.register( schemaName, nameForm );
+                break;
+                
+            case ( ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER_VAL    ):
+                DITStructureRule ditStructureRule = ( DITStructureRule ) schemaObject;
+                DITStructureRuleRegistry ditStructureRuleRegistry;
+                ditStructureRuleRegistry = registries.getDitStructureRuleRegistry();
+                ditStructureRuleRegistry.register( schemaName, ditStructureRule );
+                break;
+                
+            case ( ProducerTypeEnum.STATE_FACTORY_PRODUCER_VAL    ):
+                ServerDirStateFactory stateFactory = ( ServerDirStateFactory ) schemaObject;
+                StateFactoryRegistry stateFactoryRegistry;
+                stateFactoryRegistry = registries.getStateFactoryRegistry();
+                stateFactoryRegistry.register( stateFactory );
+                break;
+                
+            case ( ProducerTypeEnum.OBJECT_FACTORY_PRODUCER_VAL    ):
+                ServerDirObjectFactory objectFactory = ( ServerDirObjectFactory ) schemaObject;
+                ObjectFactoryRegistry objectFactoryRegistry;
+                objectFactoryRegistry = registries.getObjectFactoryRegistry();
+                objectFactoryRegistry.register( objectFactory );
+                break;
+                
+            default:
+                throw new IllegalStateException( "ProducerTypeEnum is broke!" );
         }
     }
 }

Added: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/ApacheSchemaAdditions.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/ApacheSchemaAdditions.java?view=auto&rev=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/ApacheSchemaAdditions.java (added)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/ApacheSchemaAdditions.java Thu Nov  9 14:45:08 2006
@@ -0,0 +1,46 @@
+/*
+ *  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.bootstrap;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *   Manual additions associated with NN_system.schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437043 $
+ */
+public class ApacheSchemaAdditions extends SchemaAdditions
+{
+    private static final List<BootstrapProducer>   PRODUCERS = new ArrayList<BootstrapProducer>(5);
+
+    static
+    {
+        PRODUCERS.add(new ApacheComparatorProducer());
+        PRODUCERS.add(new ApacheMatchingRuleProducer());
+        PRODUCERS.add(new ApacheNormalizerProducer());
+    }
+
+    public List<BootstrapProducer> getProducers()
+    {
+        return ApacheSchemaAdditions.PRODUCERS;
+    }
+}

Added: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/InetorgpersonSchemaAdditions.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/InetorgpersonSchemaAdditions.java?view=auto&rev=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/InetorgpersonSchemaAdditions.java (added)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/InetorgpersonSchemaAdditions.java Thu Nov  9 14:45:08 2006
@@ -0,0 +1,46 @@
+/*
+ *  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.bootstrap;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *   Manual additions associated with NN_inetorgperson.schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437043 $
+ */
+public class InetorgpersonSchemaAdditions extends SchemaAdditions
+{
+    private static final List<BootstrapProducer>   PRODUCERS = new ArrayList<BootstrapProducer>(5);
+
+    static
+    {
+        PRODUCERS.add(new InetorgpersonComparatorProducer());
+        PRODUCERS.add(new InetorgpersonMatchingRuleProducer());
+        PRODUCERS.add(new InetorgpersonNormalizerProducer());
+    }
+
+    public List<BootstrapProducer> getProducers()
+    {
+        return InetorgpersonSchemaAdditions.PRODUCERS;
+    }
+}

Added: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/NisSchemaAdditions.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/NisSchemaAdditions.java?view=auto&rev=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/NisSchemaAdditions.java (added)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/NisSchemaAdditions.java Thu Nov  9 14:45:08 2006
@@ -0,0 +1,48 @@
+/*
+ *  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.bootstrap;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *   Manual additions associated with NN_nis.schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437043 $
+ */
+public class NisSchemaAdditions extends SchemaAdditions
+{
+    private static final List<BootstrapProducer>   PRODUCERS = new ArrayList<BootstrapProducer>(5);
+
+    static
+    {
+        PRODUCERS.add(new NisComparatorProducer());
+        PRODUCERS.add(new NisMatchingRuleProducer());
+        PRODUCERS.add(new NisNormalizerProducer());
+        PRODUCERS.add(new NisSyntaxCheckerProducer());
+        PRODUCERS.add(new NisSyntaxProducer());
+    }
+
+    public List<BootstrapProducer> getProducers()
+    {
+        return PRODUCERS;
+    }
+}

Added: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SchemaAdditions.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SchemaAdditions.java?view=auto&rev=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SchemaAdditions.java (added)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SchemaAdditions.java Thu Nov  9 14:45:08 2006
@@ -0,0 +1,40 @@
+/*
+ *  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.bootstrap;
+
+import java.util.List;
+
+/**
+ *   Can be optionally provided in addition to a .schema file, so that manually maintained artifacts
+ * (rather then just the attribute types and object classes in the .schema file) can be contributed.
+ * Instances of this class are searched for using reflection based on a schema's name, so for instance
+ * <code>NisSchemaAdditions</code> will be searched for when a schema file called "nis" is loaded.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class SchemaAdditions
+{
+    public SchemaAdditions()
+    {
+    }
+
+    public abstract List<BootstrapProducer> getProducers();
+}

Added: directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemSchemaAdditions.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemSchemaAdditions.java?view=auto&rev=473116
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemSchemaAdditions.java (added)
+++ directory/branches/apacheds-schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemSchemaAdditions.java Thu Nov  9 14:45:08 2006
@@ -0,0 +1,51 @@
+/*
+ *  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.bootstrap;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *   Manual additions associated with NN_system.schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437043 $
+ */
+public class SystemSchemaAdditions extends SchemaAdditions
+{
+    private static final List<BootstrapProducer>   PRODUCERS = new ArrayList<BootstrapProducer>(5);
+
+    static
+    {
+        PRODUCERS.add(new SystemComparatorProducer());
+        PRODUCERS.add(new SystemMatchingRuleProducer());
+        PRODUCERS.add(new SystemNormalizerProducer());
+        PRODUCERS.add(new SystemSyntaxCheckerProducer());
+        PRODUCERS.add(new SystemSyntaxProducer());
+    }
+
+    /**
+     * Get the list of producers for the System schema
+     */
+    public List<BootstrapProducer> getProducers()
+    {
+        return PRODUCERS;
+    }
+}