directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1201653 - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/ core/src/main/java/org/apache/directory/server/core/
Date Mon, 14 Nov 2011 10:03:46 GMT
Author: elecharny
Date: Mon Nov 14 10:03:45 2011
New Revision: 1201653

URL: http://svn.apache.org/viewvc?rev=1201653&view=rev
Log:
Moved the interceptors initialization so that it's not called in the DefaultDirectoryService
constructor.

Modified:
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1201653&r1=1201652&r2=1201653&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
(original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
Mon Nov 14 10:03:45 2011
@@ -81,13 +81,15 @@ public class DSAnnotationProcessor
         service.setAllowAnonymousAccess( dsBuilder.allowAnonAccess() );
         service.getChangeLog().setEnabled( dsBuilder.enableChangeLog() );
 
-        List<Interceptor> interceptorList = service.getInterceptors();
-        
+        dsf.init( dsBuilder.name() );
+
         for ( Class<?> interceptorClass : dsBuilder.additionalInterceptors() )
         {
-            interceptorList.add( ( Interceptor ) interceptorClass.newInstance() );
+            service.addLast( ( Interceptor ) interceptorClass.newInstance() );
         }
 
+        List<Interceptor> interceptorList = service.getInterceptors();
+
         if ( dsBuilder.authenticators().length != 0 )
         {
             AuthenticationInterceptor authenticationInterceptor = null;
@@ -127,8 +129,6 @@ public class DSAnnotationProcessor
 
         service.setInterceptors( interceptorList );
 
-        dsf.init( dsBuilder.name() );
-
         // Process the Partition, if any.
         for ( CreatePartition createPartition : dsBuilder.partitions() )
         {

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=1201653&r1=1201652&r2=1201653&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
(original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
Mon Nov 14 10:03:45 2011
@@ -69,6 +69,7 @@ public class DefaultDirectoryServiceFact
             // we we can set some properties like accesscontrol, anon access
             // before starting up the service
             directoryService = new DefaultDirectoryService();
+            
             // no need to register a shutdown hook during tests because this 
             // starts a lot of threads and slows down test execution
             directoryService.setShutdownHookEnabled( false );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1201653&r1=1201652&r2=1201653&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Mon Nov 14 10:03:45 2011
@@ -353,7 +353,6 @@ public class DefaultDirectoryService imp
      */
     public DefaultDirectoryService() throws Exception
     {
-        setDefaultInterceptorConfigurations();
         changeLog = new DefaultChangeLog();
         journal = new DefaultJournal();
         syncPeriodMillis = DEFAULT_SYNC_PERIOD;
@@ -957,8 +956,10 @@ public class DefaultDirectoryService imp
     // ------------------------------------------------------------------------
     // BackendSubsystem Interface Method Implementations
     // ------------------------------------------------------------------------
-
-
+    /**
+     * Define a default list of interceptors that has to be used if no other 
+     * configuration is defined.
+     */
     private void setDefaultInterceptorConfigurations()
     {
         // Set default interceptor chains
@@ -1792,6 +1793,12 @@ public class DefaultDirectoryService imp
         {
             LOG.debug( "---> Initializing the DefaultDirectoryService " );
         }
+        
+        // If no interceptor list is defined, setup a default list
+        if ( interceptors == null )
+        {
+            setDefaultInterceptorConfigurations();
+        }
 
         cacheService = new CacheService();
         cacheService.initialize( this );
@@ -2061,6 +2068,35 @@ public class DefaultDirectoryService imp
      */
     public void addAfter( String interceptorName, Interceptor interceptor )
     {
+        try
+        {
+            int position = 0;
+            writeLock.lock();
+
+            // Find the position
+            for ( Interceptor inter : interceptors )
+            {
+                if ( interceptorName.equals( inter.getName() ) )
+                {
+                    break;
+                }
+                
+                position++;
+            }
+            
+            if ( position == interceptors.size() )
+            {
+                interceptors.add( interceptor );
+            }
+            else
+            {
+                interceptors.add( position, interceptor );
+            }
+        }
+        finally
+        {
+            writeLock.unlock();
+        }
     }
 
 



Mime
View raw message