directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r486450 - 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/schema/ core/src/main/schema/
Date Wed, 13 Dec 2006 01:48:02 GMT
Author: akarasulu
Date: Tue Dec 12 17:47:59 2006
New Revision: 486450

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

 o moved some classes from plugin into the core like the attribute classloader
 o added disabled attribute to metaschema
 o added configuration section for disabling some schemas that are loaded so
   they are not installed on startup


Added:
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeClassLoader.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
Removed:
    directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java
    directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java
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/schema/DnNormalizer.java
    directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema

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=486450&r1=486449&r2=486450
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml Tue Dec 12 17:47:59
2006
@@ -38,6 +38,16 @@
 	    <groupId>org.apache.directory.server</groupId>
   	    <artifactId>apacheds-bootstrap-plugin</artifactId>
             <configuration>
+              <disabledSchemas>
+                <disabledSchema>nis</disabledSchema>
+                <disabledSchema>krb5kdc</disabledSchema>
+                <disabledSchema>samba</disabledSchema>
+                <disabledSchema>autofs</disabledSchema>
+                <disabledSchema>apachedns</disabledSchema>
+                <disabledSchema>corba</disabledSchema>
+                <disabledSchema>dhcp</disabledSchema>
+                <disabledSchema>mozilla</disabledSchema>
+              </disabledSchemas>
               <indexedAttributes>
                 <indexedAttribute>objectClass</indexedAttribute>
                 <indexedAttribute>ou</indexedAttribute>

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=486450&r1=486449&r2=486450
==============================================================================
--- 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
Tue Dec 12 17:47:59 2006
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.bootstrap.plugin;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -29,6 +30,8 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
@@ -52,16 +55,19 @@
 import org.apache.directory.server.core.schema.bootstrap.SystemSchema;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
 
 
 /**
@@ -75,6 +81,8 @@
  */
 public class BootstrapPlugin extends AbstractMojo
 {
+    private static final String M_DISABLED_AT = "m-disabled";
+
     /**
      * The target directory into which the plugin generates schema partion files.
      * 
@@ -91,6 +99,13 @@
     private String[] bootstrapSchemaClasses;
     
     /**
+     * The set of disabled schema names.
+     * 
+     * @parameter 
+     */
+    private String[] disabledSchemas;
+    
+    /**
      * The names of Attributes to index.
      * 
      * @parameter 
@@ -114,6 +129,21 @@
      */
     public void execute() throws MojoExecutionException, MojoFailureException
     {
+        // delete output directory if it exists
+        File schemaDirectory = new File( outputDirectory, "schema" );
+        if ( schemaDirectory.exists() )
+        {
+            try
+            {
+                FileUtils.forceDelete( schemaDirectory );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoFailureException( "Failed to delete old schema partition folder
" 
+                    + schemaDirectory.getAbsolutePath() + ": " + e.getMessage() );
+            }
+        }
+        
         initializeSchemas();
         initializePartition();
         
@@ -138,8 +168,29 @@
             addMatchingRules();
             addAttributeTypes();
             addObjectClasses();
-            
-            listEntries();
+
+            // by default we disable these schemas
+            if ( disabledSchemas != null && disabledSchemas.length > 0 )
+            {
+                getLog().info( "------------------------------------------------------------------------"
);
+                getLog().info( "Disabling schemas:" );
+                getLog().info( "------------------------------------------------------------------------"
);
+                getLog().info( "" );
+
+                for ( String disabledSchema: disabledSchemas )
+                {
+                    disableSchema( disabledSchema );
+                    getLog().info( "\t\t o " + disabledSchema );
+                }
+                
+                getLog().info( "" );
+                getLog().info( "------------------------------------------------------------------------"
);
+            }
+
+            if ( getLog().isDebugEnabled() )
+            {
+                listEntries();
+            }
         }
         catch ( NamingException e )
         {
@@ -161,16 +212,17 @@
     private void addAttributeTypes() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding attributeTypes" );
+        getLog().info( " Adding attributeTypes:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
         Iterator<AttributeType> ii = attributeTypeRegistry.iterator();
         while ( ii.hasNext() )
         {
             AttributeType at = ii.next();
-            getLog().info( "Adding attributeType with oid = " + at.getOid() );
             String schemaName = attributeTypeRegistry.getSchemaName( at.getOid() );
+            getLog().info( "\t\t o [" + schemaName + "] - " + getNameOrNumericoid( at ) );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=attributeTypes" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -180,22 +232,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addObjectClasses() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding objectClasses" );
+        getLog().info( " Adding objectClasses:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         ObjectClassRegistry objectClassRegistry = registries.getObjectClassRegistry();
         Iterator<ObjectClass> ii = objectClassRegistry.iterator();
         while ( ii.hasNext() )
         {
             ObjectClass oc = ii.next();
-            getLog().info( "Adding objectClass with oid = " + oc.getOid() );
             String schemaName = objectClassRegistry.getSchemaName( oc.getOid() );
+            getLog().info( "\t\t o [" + schemaName + "] - " + getNameOrNumericoid( oc ) );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=objectClasses" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -205,22 +259,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addMatchingRules() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding matchingRules" );
+        getLog().info( " Adding matchingRules:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         MatchingRuleRegistry matchingRuleRegistry = registries.getMatchingRuleRegistry();
         Iterator<MatchingRule> ii = matchingRuleRegistry.iterator();
         while ( ii.hasNext() )
         {
             MatchingRule mr = ii.next();
-            getLog().info( "Adding matchingRule with oid = " + mr.getOid() );
             String schemaName = matchingRuleRegistry.getSchemaName( mr.getOid() );
+            getLog().info( "\t\t o [" + schemaName + "] - " + getNameOrNumericoid( mr ) );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=matchingRules" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -230,22 +286,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addComparators() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding comparators" );
+        getLog().info( " Adding comparators:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         ComparatorRegistry comparatorRegistry = registries.getComparatorRegistry();
         Iterator<String> ii = comparatorRegistry.oidIterator();
         while ( ii.hasNext() )
         {
             String oid = ii.next();
-            getLog().info( "Adding comparator with oid = " + oid );
             String schemaName = comparatorRegistry.getSchemaName( oid );
+            getLog().info( "\t\t o [" + schemaName + "] - " + oid );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=comparators" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -255,22 +313,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addNormalizers() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding normalizers" );
+        getLog().info( " Adding normalizers:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         NormalizerRegistry normalizerRegistry = registries.getNormalizerRegistry();
         Iterator<String> ii = normalizerRegistry.oidIterator();
         while ( ii.hasNext() )
         {
             String oid = ii.next();
-            getLog().info( "Adding normalizer with oid = " + oid );
             String schemaName = normalizerRegistry.getSchemaName( oid );
+            getLog().info( "\t\t o [" + schemaName + "] - " + oid );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=normalizers" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -280,22 +340,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addSyntaxes() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding syntaxes " );
+        getLog().info( " Adding syntaxes:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         SyntaxRegistry syntaxRegistry = registries.getSyntaxRegistry();
         Iterator<Syntax> ii = syntaxRegistry.iterator();
         while ( ii.hasNext() )
         {
             Syntax syntax = ii.next();
-            getLog().info( "Adding syntax with oid = " + syntax.getOid() );
             String schemaName = syntaxRegistry.getSchemaName( syntax.getOid() );
+            getLog().info( "\t\t o [" + schemaName + "] - " + getNameOrNumericoid( syntax
) );
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=syntaxes" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -305,22 +367,24 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
 
 
     private void addSyntaxCheckers() throws NamingException
     {
         getLog().info( "------------------------------------------------------------------------"
);
-        getLog().info( " Adding syntaxCheckers " );
+        getLog().info( " Adding syntaxCheckers:" );
         getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         SyntaxCheckerRegistry syntaxCheckerRegistry = registries.getSyntaxCheckerRegistry();
         Iterator<SyntaxChecker> ii = syntaxCheckerRegistry.iterator();
         while ( ii.hasNext() )
         {
             SyntaxChecker syntaxChecker = ii.next();
-            getLog().info( "Adding syntax checker with oid = " + syntaxChecker.getSyntaxOid()
);
             String schemaName = syntaxCheckerRegistry.getSchemaName( syntaxChecker.getSyntaxOid()
);
+            getLog().info( "\t\t o [" + schemaName + "] - " + syntaxChecker.getSyntaxOid()
);
             LdapDN dn = checkCreateSchema( schemaName );
             dn.add( "ou=syntaxCheckers" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
@@ -330,6 +394,7 @@
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             partition.add( dn, entry );
         }
+        getLog().info( "" );
     }
     
     
@@ -405,6 +470,8 @@
         
         getLog().info( "------------------------------------------------------------------------"
);
         getLog().info( "Found bootstrap schemas: " );
+        getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
 
         // start loading other schemas from the plugin's configuration section
         for ( String schemaClassName: bootstrapSchemaClasses )
@@ -433,7 +500,7 @@
             
             getLog().info( "\t" + schemaClassName );
         }
-        getLog().info( "------------------------------------------------------------------------"
);
+        getLog().info( "" );
         
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         try
@@ -497,5 +564,28 @@
         entry.put( "cn", schemaName );
         partition.add( dn, entry );
         return dn;
+    }
+    
+    
+    private void disableSchema( String schemaName ) throws NamingException
+    {
+        LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
+        dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, 
+            new LockableAttributeImpl( M_DISABLED_AT, "TRUE" ) );
+        ModificationItem[] mods = new ModificationItem[] { mod };
+        partition.modify( dn, mods );
+    }
+
+
+    private final String getNameOrNumericoid( SchemaObject object )
+    {
+        // first try to use userfriendly name if we can
+        if ( object.getName() != null )
+        {
+            return object.getName();
+        }
+        
+        return object.getOid();
     }
 }

Added: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeClassLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeClassLoader.java?view=auto&rev=486450
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeClassLoader.java
(added)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeClassLoader.java
Tue Dec 12 17:47:59 2006
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+
+package org.apache.directory.server.core.schema;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+
+/**
+ * A class loader that loads classes from an attribute within an entry.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$ $Date$
+ */
+public class AttributeClassLoader extends ClassLoader
+{
+    public Attribute attribute;
+    
+
+    public AttributeClassLoader()
+    {
+        super( AttributeClassLoader.class.getClassLoader() );
+    }
+    
+    
+    public void setAttribute( Attribute attribute )
+    {
+        this.attribute = attribute;
+    }
+
+    
+    @SuppressWarnings("unchecked")
+    public Class findClass( String name ) throws ClassNotFoundException
+    {
+        byte[] classBytes = null;
+        
+        try
+        {
+            classBytes = ( byte[] ) attribute.get();
+        }
+        catch ( NamingException e )
+        {
+            throw new ClassNotFoundException( "Failed to access attribute bytes.", e );
+        }
+        
+        return defineClass( name, classBytes, 0, classBytes.length );
+    }
+}

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java?view=diff&rev=486450&r1=486449&r2=486450
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
Tue Dec 12 17:47:59 2006
@@ -35,6 +35,8 @@
  */
 public class DnNormalizer implements Normalizer
 {
+    private static final long serialVersionUID = 1L;
+
     // @TODO use this later for seting up normalization
     private final AttributeTypeRegistry attrRegistry;
     

Added: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java?view=auto&rev=486450
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
(added)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
Tue Dec 12 17:47:59 2006
@@ -0,0 +1,203 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.core.schema.Registries;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+
+
+/**
+ * Showing how it's done ...
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SchemaEntityFactory
+{
+    /** Used for looking up the setRegistries(Registries) method */
+    private final static Class[] parameterTypes = new Class[] { Registries.class };
+    
+    /** Used for dependency injection of Registries via setter into schema objects */
+    private final Registries registries;
+    /** A special ClassLoader that loads a class from the bytecode attribute */
+    private final AttributeClassLoader classLoader;
+    
+    
+    public SchemaEntityFactory( Registries registries )
+    {
+        this.registries = registries;
+        this.classLoader = new AttributeClassLoader();
+    }
+    
+
+    /**
+     * Example of how to retrieve and load a syntaxChecker class from the DIT.
+     * 
+     * @param entry the entry to load the syntaxChecker from
+     * @return the loaded SyntaxChecker
+     * @throws NamingException if anything fails during loading
+     */
+    public SyntaxChecker getSyntaxChecker( Attributes entry ) throws NamingException
+    {
+        if ( entry == null )
+        {
+            throw new NullPointerException( "entry cannot be null" );
+        }
+        
+        if ( entry.get( "m-fqcn" ) == null )
+        {
+            throw new NullPointerException( "entry must have a valid m-fqcn attribute" );
+        }
+        
+        String className = ( String ) entry.get( "m-fqcn" ).get();
+        SyntaxChecker syntaxChecker = null;
+        Class clazz = null;
+
+        if ( entry.get( "m-bytecode" ) == null )
+        {
+            try
+            {
+                clazz = Class.forName( className );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ " was not found" );
+                ne.setRootCause( e );
+                throw ne;
+            }
+        }       
+        else
+        {
+            try
+            {
+                clazz = classLoader.loadClass( className );
+            }
+            catch ( ClassCastException e )
+            {
+                NamingException ne = new NamingException( "Class "+ className + " does not
implement SyntaxChecker" );
+                ne.setRootCause( e );
+                throw ne;
+            }
+            catch ( ClassNotFoundException e )
+            {
+                NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ " was not found" );
+                ne.setRootCause( e );
+                throw ne;
+            }
+        }
+        
+        
+        try
+        {
+            syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
+        }
+        catch ( ClassCastException e )
+        {
+            NamingException ne = new NamingException( "Class "+ className + " does not implement
SyntaxChecker" );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( InstantiationException e )
+        {
+            NamingException ne = new NamingException( "Failed to instantiate syntaxChecker
class "+ className 
+                + ".\nCheck that a default constructor exists for the class." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( IllegalAccessException e )
+        {
+            NamingException ne = new NamingException( "Failed to instantiate syntaxChecker
class "+ className 
+                + ".\nCheck that a **PUBLIC** accessible default constructor exists for the
class." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+
+        // try now before returning to check if we can inject a Registries object
+        injectRegistries( syntaxChecker );
+        return syntaxChecker;
+    }
+    
+    
+    /**
+     * Uses reflection to see if a setRegistries( Registries ) method exists on the
+     * object's class.  If so then the registries are dependency injected into the 
+     * new schema object.
+     * 
+     * @param obj a schema object to have a Registries dependency injected.
+     */
+    private void injectRegistries( Object obj ) throws NamingException
+    {
+        String className = obj.getClass().getName();
+        
+        try
+        {
+            Method method = obj.getClass().getMethod( "setRegistries", parameterTypes );
+            
+            if ( method == null )
+            {
+                return;
+            }
+            
+            Object[] args = new Object[] { this.registries };
+            method.invoke( obj, args );
+        }
+        catch ( SecurityException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the Registries dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( NoSuchMethodException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the Registries dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( IllegalArgumentException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the Registries dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( IllegalAccessException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the Registries dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+        catch ( InvocationTargetException e )
+        {
+            NamingException ne = new NamingException( "SyntaxChecker class "+ className 
+                + " could not have the Registries dependency injected." );
+            ne.setRootCause( e );
+            throw ne;
+        }
+    }
+}

Modified: directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema?view=diff&rev=486450&r1=486449&r2=486450
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema Tue Dec
12 17:47:59 2006
@@ -320,6 +320,7 @@
     SUP metaTop
     STRUCTURAL
     MUST cn
+    MAY m-disabled
 )
 
 # --- metaNormalizer objectclass ----------------------------------------------
@@ -611,6 +612,13 @@
     DESC 'Extensions for MatchingRule'
     EQUALITY caseIgnoreMatch
     SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+)
+
+# --- m-disabled AttributeType -----------------------------------
+attributetype ( 1.3.6.1.4.1.18060.0.4.0.2.37 NAME 'm-disabled'
+    DESC 'Used as a marker for schemas to enable or disable them.'
+    EQUALITY booleanMatch
+    SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
 )
 
 



Mime
View raw message