directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r981867 - in /directory/apacheds/branches/apacheds-dnfactory-experiment/core/src: main/java/org/apache/directory/server/core/ test/java/org/apache/directory/server/core/subtree/
Date Tue, 03 Aug 2010 13:31:21 GMT
Author: kayyagari
Date: Tue Aug  3 13:31:21 2010
New Revision: 981867

URL: http://svn.apache.org/viewvc?rev=981867&view=rev
Log:
o added a setter in DNFactory for schema manager
o update init method of DirectoryService to set the schema manager of DNFactory
o fixed the failing test

Modified:
    directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DNFactory.java
    directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java

Modified: directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DNFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DNFactory.java?rev=981867&r1=981866&r2=981867&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DNFactory.java
(original)
+++ directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DNFactory.java
Tue Aug  3 13:31:21 2010
@@ -45,6 +45,8 @@ public class DNFactory
 
     private static final Logger LOG = LoggerFactory.getLogger( DNFactory.class );
 
+    private static SchemaManager schemaManager;
+    
     // stat counters
     private static int hitCount = 0;
     private static int missCount = 0;
@@ -74,37 +76,40 @@ public class DNFactory
             return DN.EMPTY_DN;
         }
 
-        DN cachedDN = DN_CACHE.get( dn );
-
-        if ( cachedDN == null )
-        {
-            LOG.debug( "DN {} not found in the cache, creating", dn );
-
-            cachedDN = new DN( dn, schemaManager );
-
-            DN_CACHE.put( dn, cachedDN );
-            missCount++;
-        }
-        else
+        synchronized ( dn )
         {
-            if ( !cachedDN.isNormalized() && ( schemaManager != null ) )
+            DN cachedDN = DN_CACHE.get( dn );
+            
+            if ( cachedDN == null )
             {
-                cachedDN.normalize( schemaManager.getNormalizerMapping() );
+                LOG.debug( "DN {} not found in the cache, creating", dn );
+                
+                cachedDN = new DN( dn, schemaManager );
+                
+                DN_CACHE.put( dn, cachedDN );
+                missCount++;
             }
-
-            hitCount++;
-        }
-
-        LOG.debug( "DN {} found in the cache", dn );
+            else
+            {
+                if ( !cachedDN.isNormalized() && ( schemaManager != null ) )
+                {
+                    cachedDN.normalize( schemaManager.getNormalizerMapping() );
+                }
+                
+                hitCount++;
+            }
+            
+            LOG.debug( "DN {} found in the cache", dn );
 //        System.out.println( "DN cache hit - " + hitCount + ", miss - " + missCount + "
and is normalized = "
 //            + cachedDN.isNormalized() );
-        return cachedDN;
+            return cachedDN;
+        }
     }
 
 
     public static DN create( String... upRdns ) throws LdapInvalidDnException
     {
-        return create( null, upRdns );
+        return create( schemaManager, upRdns );
     }
 
 
@@ -124,7 +129,7 @@ public class DNFactory
 
     public static DN create( DN dn ) throws LdapInvalidDnException
     {
-        return create( dn.getName(), null );
+        return create( dn.getName(), schemaManager );
     }
 
 
@@ -136,7 +141,13 @@ public class DNFactory
 
     public static DN create( String dn ) throws LdapInvalidDnException
     {
-        return create( dn, null );
+        return create( dn, schemaManager );
     }
 
+
+    public static void setSchemaManager( SchemaManager schemaManager )
+    {
+        DNFactory.schemaManager = schemaManager;
+    }
+    
 }

Modified: directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=981867&r1=981866&r2=981867&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Tue Aug  3 13:31:21 2010
@@ -1413,6 +1413,8 @@ public class DefaultDirectoryService imp
             LOG.debug( "---> Initializing the DefaultDirectoryService " );
         }
 
+        DNFactory.setSchemaManager( schemaManager );
+        
         // triggers partition to load schema fully from schema partition
         schemaService.initialize();
         schemaService.getSchemaPartition().initialize();

Modified: directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java?rev=981867&r1=981866&r2=981867&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
(original)
+++ directory/apacheds/branches/apacheds-dnfactory-experiment/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
Tue Aug  3 13:31:21 2010
@@ -91,7 +91,9 @@ public class SubtreeEvaluatorTest
         {
             fail( "Schema load failed : " + LdapExceptionUtils.printErrors( schemaManager.getErrors()
) );
         }
-
+        
+        DNFactory.setSchemaManager( schemaManager );
+        
         ncn = new ConcreteNameComponentNormalizer( schemaManager );
 
         visitor = new FilterNormalizingVisitor( ncn, schemaManager );



Mime
View raw message