directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r516535 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
Date Fri, 09 Mar 2007 20:12:35 GMT
Author: elecharny
Date: Fri Mar  9 12:12:34 2007
New Revision: 516535

URL: http://svn.apache.org/viewvc?view=rev&rev=516535
Log:
Switched to Java 1.5 generics
Added some logs
Simplified the initialization using a new constructor for MutableAuthenticatorConfiguration


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java?view=diff&rev=516535&r1=516534&r2=516535
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
Fri Mar  9 12:12:34 2007
@@ -40,11 +40,14 @@
 import org.apache.directory.server.core.exception.ExceptionService;
 import org.apache.directory.server.core.normalization.NormalizationService;
 import org.apache.directory.server.core.operational.OperationalAttributeService;
+import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.referral.ReferralService;
 import org.apache.directory.server.core.schema.SchemaService;
 import org.apache.directory.server.core.subtree.SubentryService;
 import org.apache.directory.server.core.trigger.TriggerService;
 import org.apache.directory.shared.ldap.ldif.Entry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -55,6 +58,11 @@
  */
 public class StartupConfiguration extends Configuration
 {
+    private static final Logger log = LoggerFactory.getLogger( StartupConfiguration.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     private static final long serialVersionUID = 4826762196566871677L;
 
     public static final int MAX_THREADS_DEFAULT = 4;
@@ -103,19 +111,11 @@
     {
         Set<AuthenticatorConfiguration> set = new HashSet<AuthenticatorConfiguration>();
 
-        MutableAuthenticatorConfiguration authCfg;
-
         // Anonymous
-        authCfg = new MutableAuthenticatorConfiguration();
-        authCfg.setName( "Anonymous" );
-        authCfg.setAuthenticator( new AnonymousAuthenticator() );
-        set.add( authCfg );
+        set.add( new MutableAuthenticatorConfiguration( "Anonymous", new AnonymousAuthenticator()
) );
 
         // Simple
-        authCfg = new MutableAuthenticatorConfiguration();
-        authCfg.setName( "Simple" );
-        authCfg.setAuthenticator( new SimpleAuthenticator() );
-        set.add( authCfg );
+        set.add( new MutableAuthenticatorConfiguration( "Simple", new SimpleAuthenticator()
) );
 
         setAuthenticatorConfigurations( set );
     }
@@ -203,26 +203,30 @@
     /**
      * Sets {@link AuthenticatorConfiguration}s to use for authenticating clients.
      */
-    protected void setAuthenticatorConfigurations( Set authenticatorConfigurations )
+    protected void setAuthenticatorConfigurations( Set<AuthenticatorConfiguration>
authenticatorConfigurations )
     {
-        Set newSet = ConfigurationUtil.getTypeSafeSet( authenticatorConfigurations, AuthenticatorConfiguration.class
);
+        Set<String> names = new HashSet<String>();
 
-        Set names = new HashSet();
-        Iterator i = newSet.iterator();
-        while ( i.hasNext() )
+        // Loop through all the configurations to check if we do not have duplicated authenticators.
+        for ( AuthenticatorConfiguration cfg:authenticatorConfigurations )
         {
-            AuthenticatorConfiguration cfg = ( AuthenticatorConfiguration ) i.next();
             cfg.validate();
 
             String name = cfg.getName();
+
             if ( names.contains( name ) )
             {
+                // TODO Not sure that it worth to throw an excpetion here. We could simply
ditch the
+                // duplicated authenticator, trace a warning and that's it. 
+                log.error( "The authenticator nammed '{}' has already been registred.", name
);
                 throw new ConfigurationException( "Duplicate authenticator name: " + name
);
             }
+            
             names.add( name );
         }
 
-        this.authenticatorConfigurations = newSet;
+        // The set has been checked, so we can now register it
+        this.authenticatorConfigurations = authenticatorConfigurations;
     }
 
 



Mime
View raw message