directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r202106 - in /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server: configuration/ jndi/
Date Tue, 28 Jun 2005 00:54:11 GMT
Author: trustin
Date: Mon Jun 27 17:54:09 2005
New Revision: 202106

URL: http://svn.apache.org/viewcvs?rev=202106&view=rev
Log:
Fix for DIREVE-172:
* Added Configuration.instanceId property so that user can speficy the id of ContextFactoryService
instance.
* Added ContextFactoryConfiguration.getInstanceId() so that user can find out which instance
it is working with.
* Added ContextFactoryService.getInstance() methods and ContextFactoryService.getAllInstances().

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/Configuration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ShutdownConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/SyncConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/Configuration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/Configuration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/Configuration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/Configuration.java
Mon Jun 27 17:54:09 2005
@@ -36,6 +36,12 @@
      * A JNDI environment key that configuration instance is put on. 
      */
     public static final String JNDI_KEY = Configuration.class.getName();
+    
+    /**
+     * The default ID of {@link ContextFactoryService} that is used
+     * when no instance ID is specified. 
+     */
+    public static final String DEFAULT_INSTANCE_ID = "default";
 
     /**
      * Gets {@link Configuration} instance from the specified JNDI environment
@@ -53,6 +59,32 @@
         }
         
         return ( Configuration ) value;
+    }
+    
+    private String instanceId = DEFAULT_INSTANCE_ID;
+    
+    /**
+     * Creates a new instance.
+     */
+    protected Configuration()
+    {
+    }
+    
+    /**
+     * Returns the ID of {@link ContextFactoryService} instance to configure.
+     */
+    public String getInstanceId()
+    {
+        return instanceId;
+    }
+    
+    /**
+     * Sets the ID of {@link ContextFactoryService} instance to configure.
+     */
+    protected void setInstanceId( String instanceId )
+    {
+        instanceId = instanceId.trim();
+        this.instanceId = instanceId;
     }
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/MutableStartupConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -22,6 +22,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.ldap.server.jndi.ContextFactoryService;
+
 /**
  * A mutable version of {@link StartupConfiguration}.
  *
@@ -37,6 +39,20 @@
      */
     public MutableStartupConfiguration()
     {
+    }
+    
+    /**
+     * Creates a new instance that operates on the {@link ContextFactoryService}
+     * with the specified ID.
+     */
+    public MutableStartupConfiguration( String instanceId )
+    {
+        super( instanceId );
+    }
+
+    public void setInstanceId( String instanceId )
+    {
+        super.setInstanceId( instanceId );
     }
 
     public void setAuthenticatorConfigurations( Set authenticators )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ShutdownConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ShutdownConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ShutdownConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/ShutdownConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -18,6 +18,8 @@
  */
 package org.apache.ldap.server.configuration;
 
+import org.apache.ldap.server.jndi.ContextFactoryService;
+
 /**
  * A {@link Configuration} that shuts down ApacheDS.
  *
@@ -33,5 +35,14 @@
      */
     public ShutdownConfiguration()
     {
+    }
+
+    /**
+     * Creates a new instance that operates on the {@link ContextFactoryService}
+     * with the specified ID.
+     */
+    public ShutdownConfiguration( String instanceId )
+    {
+        setInstanceId( instanceId );
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -32,6 +32,7 @@
 import org.apache.ldap.server.authn.SimpleAuthenticator;
 import org.apache.ldap.server.authz.AuthorizationService;
 import org.apache.ldap.server.exception.ExceptionService;
+import org.apache.ldap.server.jndi.ContextFactoryService;
 import org.apache.ldap.server.normalization.NormalizationService;
 import org.apache.ldap.server.operational.OperationalAttributeService;
 import org.apache.ldap.server.schema.SchemaService;
@@ -62,11 +63,26 @@
     private Set contextPartitionConfigurations = new HashSet(); // Set<ContextPartitionConfiguration>
     private List testEntries = new ArrayList(); // List<Attributes>
     
-    protected StartupConfiguration()
+    /**
+     * Creates a new instance with default settings.
+     */
+    public StartupConfiguration()
     {
         setDefaultAuthenticatorConfigurations();
         setDefaultBootstrapSchemas();
         setDefaultInterceptorConfigurations();
+    }
+
+    /**
+     * Creates a new instance with default settings that operates on the
+     * {@link ContextFactoryService} with the specified ID.
+     */
+    public StartupConfiguration( String instanceId )
+    {
+        setDefaultAuthenticatorConfigurations();
+        setDefaultBootstrapSchemas();
+        setDefaultInterceptorConfigurations();
+        setInstanceId( instanceId );
     }
 
     private void setDefaultAuthenticatorConfigurations()

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/SyncConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/SyncConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/SyncConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/SyncConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -36,4 +36,13 @@
     public SyncConfiguration()
     {
     }
+    
+    /**
+     * Creates a new instance that operates on the {@link ContextFactoryService}
+     * with the specified ID.
+     */
+    public SyncConfiguration( String instanceId )
+    {
+        setInstanceId( instanceId );
+    }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -34,6 +34,10 @@
  */
 public interface ContextFactoryConfiguration
 {
+    /**
+     * Returns the instance ID of the {@link ContextFactoryService}.
+     */
+    String getInstanceId();
     
     /**
      * Returns the listener that listens to service events.

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryService.java
Mon Jun 27 17:54:09 2005
@@ -16,11 +16,16 @@
  */
 package org.apache.ldap.server.jndi;
 
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
 
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.apache.ldap.server.configuration.Configuration;
 import org.apache.ldap.server.partition.ContextPartition;
 
 /**
@@ -31,11 +36,39 @@
  */
 public abstract class ContextFactoryService
 {
-    private static final ContextFactoryService instance = new DefaultContextFactoryService();
+    private static final Map instances = new HashMap();
 
+    /**
+     * Returns the default instance.  This method is identical with calling
+     * <tt>getInstance( Configuration.DEFAULT_INSTANCE_ID )</tt>.
+     */
     public static ContextFactoryService getInstance()
     {
-        return instance;
+        return getInstance( Configuration.DEFAULT_INSTANCE_ID );
+    }
+    
+    /**
+     * Returns {@link ContextFactoryService} with the specified instance ID.
+     */
+    public synchronized static ContextFactoryService getInstance( String instanceId )
+    {
+        instanceId = instanceId.trim();
+        ContextFactoryService service = ( ContextFactoryService ) instances.get( instanceId
);
+        if( service == null )
+        {
+            service = new DefaultContextFactoryService( instanceId );
+            instances.put( instanceId, service );
+        }
+        
+        return service;
+    }
+    
+    /**
+     * Returns all instances of instantiated {@link ContextFactoryService}.
+     */
+    public synchronized static Set getAllInstances()
+    {
+        return new HashSet( instances.values() );
     }
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryConfiguration.java
Mon Jun 27 17:54:09 2005
@@ -41,6 +41,11 @@
     {
         this.parent = parent;
     }
+    
+    public String getInstanceId()
+    {
+        return parent.getInstanceId();
+    }
 
     public ContextFactoryServiceListener getServiceListener()
     {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java?rev=202106&r1=202105&r2=202106&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
Mon Jun 27 17:54:09 2005
@@ -56,6 +56,8 @@
  */
 class DefaultContextFactoryService extends ContextFactoryService
 {
+    private final String instanceId;
+
     private final ContextFactoryConfiguration configuration = new DefaultContextFactoryConfiguration(
this );
 
     private ContextFactoryServiceListener serviceListener;
@@ -89,8 +91,15 @@
     /**
      * Creates a new instance.
      */
-    public DefaultContextFactoryService()
+    public DefaultContextFactoryService( String instanceId )
     {
+        if( instanceId == null )
+        {
+            throw new NullPointerException( "instanceId" );
+        }
+        
+        this.instanceId = instanceId;
+        
         // Register shutdown hook.
         Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
             public void run()
@@ -236,6 +245,11 @@
             startupConfiguration = null;
             serviceListener.afterShutdown( this );
         }
+    }
+    
+    public String getInstanceId()
+    {
+        return instanceId;
     }
     
     public ContextFactoryConfiguration getConfiguration()



Mime
View raw message