directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r537377 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
Date Sat, 12 May 2007 10:27:14 GMT
Author: elecharny
Date: Sat May 12 03:27:11 2007
New Revision: 537377

URL: http://svn.apache.org/viewvc?view=rev&rev=537377
Log:
Ussing two static entries for rooDSE :
- one which stores all the attributes
- one which stores all the non-operational attributes.

If a lookup() is done with an empty DN,
then we return one of the two possible static value, depending on the 
requested attributes (none or '+'). If the user specified
some attributes, the a real lookup() is done.

This increase the performance of the server a lot.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?view=diff&rev=537377&r1=537376&r2=537377
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
Sat May 12 03:27:11 2007
@@ -24,6 +24,7 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 import javax.naming.Context;
@@ -48,6 +49,8 @@
 import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration;
 import org.apache.directory.server.core.event.EventService;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
+import org.apache.directory.server.core.interceptor.context.GetRootDSEOperationContext;
+import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.OperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
@@ -91,6 +94,18 @@
     /** Bypass String to use when ALL interceptors should be skipped */
     public static final Collection BYPASS_ALL_COLLECTION = Collections.singleton( BYPASS_ALL
);
     
+    /** A static object to store the rootDSE entry with all the attributes */
+    private static Attributes ROOT_DSE_ALL;
+
+    /** A static object to store the rootDSE entry without operationnal attributes */
+    private static Attributes ROOT_DSE_NO_OPERATIONNAL;
+
+    /** A mutex to protect the rootDSE construction */
+    private static final Object ROOT_DSE_ALL_MUTEX = new Object();
+    
+    /** A mutex to protect the rootDSE construction */
+    private static final Object ROOT_DSE_NOOP_MUTEX = new Object();
+    
     private final Context caller;
     private final DirectoryService service;
     private final DirectoryServiceConfiguration configuration;
@@ -140,7 +155,7 @@
      * @param caller a JNDI {@link Context} object that will call this proxy
      * @param service a JNDI service
      */
-    public PartitionNexusProxy(Context caller, DirectoryService service)
+    public PartitionNexusProxy(Context caller, DirectoryService service) throws NamingException
     {
         this.caller = caller;
         this.service = service;
@@ -154,7 +169,7 @@
     }
 
 
-    public void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg
)
+    public void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg
) throws NamingException
     {
     }
 
@@ -463,6 +478,37 @@
 
     public Attributes lookup( OperationContext opContext ) throws NamingException
     {
+    	if ( opContext.getDn().size() == 0 )
+    	{
+    		List<String> attrs = ( (LookupOperationContext)opContext).getAttrsId();
+    		
+    		if ( ( attrs == null ) || ( attrs.size() == 0 ) )
+    		{
+    			synchronized( ROOT_DSE_NOOP_MUTEX )
+    			{
+    				if ( ROOT_DSE_NO_OPERATIONNAL == null )
+    				{
+    					ROOT_DSE_NO_OPERATIONNAL = lookup( opContext, ( Collection ) null );
+    				}
+    			}
+    			
+        		return ROOT_DSE_NO_OPERATIONNAL;
+    		}
+    		else if ( ( attrs.size() == 1 ) && ( attrs.contains( "+" ) ) )
+    		{
+    			synchronized( ROOT_DSE_ALL_MUTEX )
+    			{
+    				if ( ROOT_DSE_ALL == null )
+    				{
+    					ROOT_DSE_ALL = lookup( opContext, ( Collection ) null );
+    				}
+    			}
+    			
+    			return ROOT_DSE_ALL;
+    		}
+    			
+    	}
+    	
         return lookup( opContext, ( Collection ) null );
     }
 
@@ -636,6 +682,19 @@
 
     public Attributes getRootDSE( OperationContext opContext ) throws NamingException
     {
+    	if ( opContext.getDn().size() == 0 )
+    	{
+    		synchronized( ROOT_DSE_ALL_MUTEX )
+    		{
+    			if ( ROOT_DSE_ALL == null )
+    			{
+    				ROOT_DSE_ALL = getRootDSE( null, null );
+    			}
+    		}
+    		
+    		return ROOT_DSE_ALL;
+    	}
+    	
         return getRootDSE( null, null );
     }
 



Mime
View raw message