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 2011/11/14 11:38:30 UTC
svn commit: r1201660 - in /directory/apacheds/branches/apacheds-txns:
core-annotations/src/main/java/org/apache/directory/server/core/factory/
core/src/main/java/org/apache/directory/server/core/
Author: elecharny
Date: Mon Nov 14 10:38:30 2011
New Revision: 1201660
URL: http://svn.apache.org/viewvc?rev=1201660&view=rev
Log:
Moved the interceptors initialization so that it's not called in the DefaultDirectoryService constructor.
Modified:
directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Modified: directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1201660&r1=1201659&r2=1201660&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Mon Nov 14 10:38:30 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/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=1201660&r1=1201659&r2=1201660&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java Mon Nov 14 10:38:30 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/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1201660&r1=1201659&r2=1201660&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Mon Nov 14 10:38:30 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();
+ }
}