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 2009/11/22 23:22:57 UTC
svn commit: r883158 -
/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Author: elecharny
Date: Sun Nov 22 22:22:56 2009
New Revision: 883158
URL: http://svn.apache.org/viewvc?rev=883158&view=rev
Log:
o Injected the SchemaManager into the SC and N, just in case they need an access to the registries
o Modified the classloader to inject an OID to the created objects, if needed.
Modified:
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java?rev=883158&r1=883157&r2=883158&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java Sun Nov 22 22:22:56 2009
@@ -20,6 +20,7 @@
package org.apache.directory.shared.schema.loader.ldif;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
@@ -283,9 +284,6 @@
// Create the syntaxChecker instance
syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
- // Inject the SchemaManager
- syntaxChecker.setSchemaManager( schemaManager );
-
// Update the common fields
syntaxChecker.setBytecode( byteCodeStr );
syntaxChecker.setFqcn( className );
@@ -407,18 +405,29 @@
byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
}
- // Create the comparator instance
- comparator = ( LdapComparator<?> ) clazz.newInstance();
+ // Create the comparator instance. Either we have a no argument constructor,
+ // or we have one which takes an OID. Lets try the one with an OID argument first
+ try
+ {
+ Constructor<?> constructor = clazz.getConstructor( new Class[]{String.class} );
+ comparator = ( LdapComparator<?> )constructor.newInstance( new Object[]{ oid } );
+ }
+ catch ( NoSuchMethodException nsme )
+ {
+ // Ok, let's try with the constructor without argument
+ Constructor<?> constructor = clazz.getConstructor();
+ comparator = ( LdapComparator<?> )clazz.newInstance();
+ }
- // Inject the SchemaManager
- comparator.setSchemaManager( schemaManager );
-
// Update the loadable fields
comparator.setBytecode( byteCodeStr );
comparator.setFqcn( className );
+ // Inject the SchemaManager for the comparator who need it
+ comparator.setSchemaManager( schemaManager );
+
// Inject the new OID, as the loaded comparator might have its own
- comparator.setOid( oid );
+ //comparator.setOid( oid );
return comparator;
}
@@ -539,9 +548,6 @@
// Create the normalizer instance
normalizer = ( Normalizer ) clazz.newInstance();
- // Inject the SchemaManager
- normalizer.setSchemaManager( schemaManager );
-
// Update the common fields
normalizer.setBytecode( byteCodeStr );
normalizer.setFqcn( className );