directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r155862 - in incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server: ContextPartitionConfig.java jndi/EnvKeys.java jndi/PartitionConfigBuilder.java jndi/ServerContextFactory.java
Date Wed, 02 Mar 2005 03:29:43 GMT
Author: akarasulu
Date: Tue Mar  1 19:29:42 2005
New Revision: 155862

URL: http://svn.apache.org/viewcvs?view=rev&rev=155862
Log:
changes ...

 o applying Endi's changes from the partition.patch file present here
   http://issues.apache.org/jira/secure/attachment/19058/partition.patch
 o adds extra optional options to the partition configuration and env props
   NOTE - Endi please update the environment property documentation

This feature enables different context partition implementations to be used
with the server.  More info about the feature is available here even though
this is only half the JIRA:

http://issues.apache.org/jira/browse/DIREVE-141


Modified:
    incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java
    incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
    incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java
    incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java

Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java
URL: http://svn.apache.org/viewcvs/incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java?view=diff&r1=155861&r2=155862
==============================================================================
--- incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java
(original)
+++ incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java
Tue Mar  1 19:29:42 2005
@@ -32,6 +32,8 @@
     private String id;
     private String[] indices;
     private Attributes attributes;
+    private String partitionClass;
+    private String properties;
 
 
     public String getSuffix()
@@ -79,5 +81,25 @@
     public void setAttributes( Attributes attributes )
     {
         this.attributes = attributes;
+    }
+
+    public String getPartitionClass()
+    {
+        return partitionClass;
+    }
+
+    public void setPartitionClass(String partitionClass)
+    {
+        this.partitionClass = partitionClass;
+    }
+
+    public String getProperties()
+    {
+        return properties;
+    }
+
+    public void setProperties(String properties)
+    {
+        this.properties = properties;
     }
 }

Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
URL: http://svn.apache.org/viewcvs/incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java?view=diff&r1=155861&r2=155862
==============================================================================
--- incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
(original)
+++ incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
Tue Mar  1 19:29:42 2005
@@ -68,6 +68,10 @@
     public static final String PARTITIONS = "server.db.partitions";
     /** the envprop key base to the suffix of a partition */
     public static final String SUFFIX = "server.db.partition.suffix.";
+    /** the envprop key base to the implementation of a partition */
+    public static final String PARTITION_CLASS = "server.db.partition.class.";
+    /** the envprop key base to the properties of a partition */
+    public static final String PROPERTIES = "server.db.partition.properties.";
     /** the envprop key base to the space separated list of indices for a partition */
     public static final String INDICES = "server.db.partition.indices.";
     /** the envprop key base to the Attributes for the context nexus entry */

Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java?view=diff&r1=155861&r2=155862
==============================================================================
--- incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java
(original)
+++ incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java
Tue Mar  1 19:29:42 2005
@@ -76,6 +76,32 @@
         config.setSuffix( suffix );
 
         // --------------------------------------------------------------------
+        // set partition class
+        // --------------------------------------------------------------------
+
+        buf.setLength( 0 );
+        buf.append( EnvKeys.PARTITION_CLASS ).append( id );
+        String partitionClass = ( String ) env.get(  buf.toString() );
+
+        if ( partitionClass != null )
+        {
+            config.setPartitionClass( partitionClass );
+        }
+
+        // --------------------------------------------------------------------
+        // set partition properties
+        // --------------------------------------------------------------------
+
+        buf.setLength( 0 );
+        buf.append( EnvKeys.PROPERTIES ).append( id );
+        String properties = ( String ) env.get(  buf.toString() );
+
+        if ( properties != null )
+        {
+            config.setProperties( properties );
+        }
+
+        // --------------------------------------------------------------------
         // extract index list and set the list of indices in config
         // --------------------------------------------------------------------
 

Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?view=diff&r1=155861&r2=155862
==============================================================================
--- incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
(original)
+++ incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Tue Mar  1 19:29:42 2005
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
+import java.lang.reflect.Constructor;
 
 import javax.naming.Context;
 import javax.naming.Name;
@@ -46,10 +47,7 @@
 import org.apache.ldap.common.util.DateUtils;
 import org.apache.ldap.common.util.PropertiesUtils;
 import org.apache.ldap.common.util.StringTools;
-import org.apache.ldap.server.ApplicationPartition;
-import org.apache.ldap.server.ContextPartitionConfig;
-import org.apache.ldap.server.RootNexus;
-import org.apache.ldap.server.SystemPartition;
+import org.apache.ldap.server.*;
 import org.apache.ldap.server.db.Database;
 import org.apache.ldap.server.db.DefaultSearchEngine;
 import org.apache.ldap.server.db.ExpressionEnumerator;
@@ -681,8 +679,39 @@
 
             AttributeType[] indexTypes = ( AttributeType[] ) attributeTypeList
                     .toArray( new AttributeType[attributeTypeList.size()] );
-            ApplicationPartition partition = new ApplicationPartition( upSuffix, normSuffix,
db, eng, indexTypes );
-            nexus.register( partition );
+
+            String partitionClass = configs[ii].getPartitionClass();
+            String properties = configs[ii].getProperties();
+            ContextPartition partition = null;
+
+            if ( partitionClass == null )
+            {
+                // If custom partition is not defined, use the ApplicationPartion.
+                partition = new ApplicationPartition( upSuffix,
+                        normSuffix, db, eng, indexTypes );
+
+            }
+            else
+            {
+                // If custom partition is defined, instantiate it.
+                try
+                {
+                    Class clazz = Class.forName( partitionClass );
+                    Constructor constructor = clazz.getConstructor(
+                            new Class[] { Name.class, Name.class, String.class } );
+                    partition = ( ContextPartition ) constructor.newInstance(
+                            new Object[] { upSuffix, normSuffix, properties } );
+                }
+                catch ( Exception e )
+                {
+                    e.printStackTrace();
+                }
+            }
+
+            if ( partition != null ) 
+            { 
+                nexus.register( partition );
+            }
 
             // ----------------------------------------------------------------
             // add the nexus context entry



Mime
View raw message