You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/08/31 16:49:34 UTC

svn commit: r265055 - in /directory/sandbox/trunk/osgi-core/trunk/apacheds: project.xml src/main/java/org/apache/ldap/server/Activator.java

Author: erodriguez
Date: Wed Aug 31 07:49:28 2005
New Revision: 265055

URL: http://svn.apache.org/viewcvs?rev=265055&view=rev
Log:
Updates to apacheds core OSGi wrapper:
o  bumping up deps
o  initial use of apacheds-core configuration mechanism
o  initial use of SLF4J logging, library dependency to POM

Modified:
    directory/sandbox/trunk/osgi-core/trunk/apacheds/project.xml
    directory/sandbox/trunk/osgi-core/trunk/apacheds/src/main/java/org/apache/ldap/server/Activator.java

Modified: directory/sandbox/trunk/osgi-core/trunk/apacheds/project.xml
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/apacheds/project.xml?rev=265055&r1=265054&r2=265055&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/apacheds/project.xml (original)
+++ directory/sandbox/trunk/osgi-core/trunk/apacheds/project.xml Wed Aug 31 07:49:28 2005
@@ -7,8 +7,8 @@
   <name>Apache Backing Store</name>
   <currentVersion>0.1.1</currentVersion>
   <properties>
-    <osgi.export.package>org.apache.ldap.common.util,org.apache.ldap.common.message.spi,org.apache.ldap.common,org.apache.ldap.common.message,org.apache.ldap.common.exception,org.apache.ldap.common.filter</osgi.export.package>
-    <osgi.import.package>org.apache.ldap.common.berlib.asn1,org.osgi.framework,org.apache.asn1.codec,org.apache.asn1.codec.stateful</osgi.import.package>
+    <osgi.export.package>org.apache.ldap.common.util,org.apache.ldap.common.message.spi,org.apache.ldap.common,org.apache.ldap.common.message,org.apache.ldap.common.exception,org.apache.ldap.common.filter,org.apache.ldap.server.jndi,org.apache.ldap.server.configuration</osgi.export.package>
+    <osgi.import.package>org.osgi.framework</osgi.import.package>
   </properties>
   <inceptionYear>2005</inceptionYear>
   <package>org.apache.store</package>
@@ -16,6 +16,15 @@
   <description>Apache Backing Store</description>
   <dependencies>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <version>1.2.14</version>
+      <url>http://slf4j.org/nlog4j</url>
+      <properties>
+        <osgi.jar.bundle>true</osgi.jar.bundle>
+      </properties>
+    </dependency>
+    <dependency>
       <groupId>regexp</groupId>
       <artifactId>regexp</artifactId>
       <version>1.2</version>
@@ -42,7 +51,7 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-      <version>1.0</version>
+      <version>1.0.4</version>
       <url>http://jakarta.apache.org/commons/logging</url>
     </dependency>
     <dependency>
@@ -86,7 +95,7 @@
     <dependency>
       <groupId>directory-shared</groupId>
       <artifactId>ldap-common</artifactId>
-      <version>0.9-SNAPSHOT</version>
+      <version>0.9.2-SNAPSHOT</version>
       <properties>
         <osgi.jar.bundle>true</osgi.jar.bundle>
       </properties>
@@ -94,7 +103,7 @@
     <dependency>
       <groupId>directory</groupId>
       <artifactId>apacheds-core</artifactId>
-      <version>0.9-SNAPSHOT</version>
+      <version>0.9.2-SNAPSHOT</version>
       <properties>
         <osgi.jar.bundle>true</osgi.jar.bundle>
       </properties>
@@ -102,7 +111,7 @@
     <dependency>
       <groupId>directory</groupId>
       <artifactId>apacheds-shared</artifactId>
-      <version>0.9-SNAPSHOT</version>
+      <version>0.9.2-SNAPSHOT</version>
       <properties>
         <osgi.jar.bundle>true</osgi.jar.bundle>
       </properties>

Modified: directory/sandbox/trunk/osgi-core/trunk/apacheds/src/main/java/org/apache/ldap/server/Activator.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/apacheds/src/main/java/org/apache/ldap/server/Activator.java?rev=265055&r1=265054&r2=265055&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/apacheds/src/main/java/org/apache/ldap/server/Activator.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/apacheds/src/main/java/org/apache/ldap/server/Activator.java Wed Aug 31 07:49:28 2005
@@ -14,28 +14,40 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.ldap.server;
 
+import java.util.Collections;
 import java.util.Dictionary;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Set;
 
+import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.spi.InitialContextFactory;
 
+import org.apache.ldap.common.message.LockableAttributeImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.server.configuration.MutableContextPartitionConfiguration;
+import org.apache.ldap.server.configuration.MutableStartupConfiguration;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
 import org.apache.ldap.server.jndi.CoreContextFactory;
-import org.apache.ldap.server.jndi.EnvKeys;
+import org.apache.ldap.server.schema.bootstrap.ApacheSchema;
+import org.apache.ldap.server.schema.bootstrap.CoreSchema;
+import org.apache.ldap.server.schema.bootstrap.CosineSchema;
+import org.apache.ldap.server.schema.bootstrap.InetorgpersonSchema;
+import org.apache.ldap.server.schema.bootstrap.Krb5kdcSchema;
+import org.apache.ldap.server.schema.bootstrap.SystemSchema;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceRegistration;
 
-
 public class Activator implements BundleActivator
 {
-    private InitialContextFactory factory = null;
-    private ServiceRegistration registration = null;
-    
+    private InitialContextFactory factory;
+    private ServiceRegistration registration;
+
     /**
      * Implements BundleActivator.start().
      * Logs that this service is starting and starts this service.
@@ -44,28 +56,32 @@
     public void start( BundleContext context ) throws BundleException
     {
         System.out.println( "Starting Apache Backing Store." );
-        
-        // Get absolute path
-        // File dataFile = context.getDataFile( "store" );
-        
+
+        Hashtable env = new Hashtable( setUpPartition() );
+
+        env.put( "java.naming.factory.initial", CoreContextFactory.class.getName() );
+        env.put( "java.naming.security.authentication", "simple" );
+        env.put( "java.naming.provider.url", "dc=example,dc=com" );
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+
         factory = new CoreContextFactory();
-        
-        Hashtable env = new Hashtable();
-        loadEnvironment( env );
-        
+
         try
         {
             factory.getInitialContext( env );
-            Dictionary parameters = new Hashtable();
-            registration = context.registerService( InitialContextFactory.class.getName(), factory, parameters );
         }
-        catch (NamingException ne)
+        catch ( NamingException ne )
         {
             ne.printStackTrace();
             throw new BundleException( "Initial context load failed." );
         }
+
+        Dictionary parameters = new Hashtable();
+
+        registration = context.registerService( InitialContextFactory.class.getName(), factory, parameters );
     }
-    
+
     /**
      * Implements BundleActivator.stop().
      * Logs that this service has stopped.
@@ -74,48 +90,67 @@
     public void stop( BundleContext context ) throws BundleException
     {
         System.out.println( "Stopping Apache Backing Store." );
-        
-        Hashtable env = new Hashtable();
-        env.put( EnvKeys.SHUTDOWN, "true" );
-        
+
+        Hashtable env = new ShutdownConfiguration().toJndiEnvironment();
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
+        env.put( "java.naming.security.authentication", "simple" );
+        env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
+        env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        env.put( Context.SECURITY_CREDENTIALS, "secret" );
+
         try
         {
             factory.getInitialContext( env );
         }
-        catch (NamingException ne)
+        catch ( NamingException ne )
         {
             ne.printStackTrace();
             throw new BundleException( "Initial context shutdown failed." );
         }
-        
+
         factory = null;
-        
+
         registration.unregister();
         registration = null;
     }
-    
-    private void loadEnvironment( Hashtable env )
+
+    private Hashtable setUpPartition()
     {
-        env.put( "java.naming.provider.url", "dc=example,dc=com" );
-        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
-        env.put( "java.naming.security.authentication", "simple" );
-        env.put( "java.naming.security.credentials", "secret" );
-        env.put( "java.naming.factory.initial", "org.apache.ldap.server.jndi.CoreContextFactory" );
-        
-        env.put( "server.db.partitions", "apache example" );
-        
-        env.put( "server.db.partition.suffix.apache", "dc=apache,dc=org" );
-        env.put( "server.db.partition.indices.apache", "objectClass ou uid" );
-        env.put( "server.db.partition.attributes.apache.objectClass", "top domain extensibleObject" );
-        env.put( "server.db.partition.attributes.apache.dc", "apache" );
-        
-        env.put( "server.db.partition.suffix.example", "dc=example,dc=com" );
-        env.put( "server.db.partition.indices.example", "ou uid objectClass krb5PrincipalName" );
-        env.put( "server.db.partition.attributes.example.dc", "example" );
-        env.put( "server.db.partition.attributes.example.objectClass", "top domain example" );
-        
-        env.put( "server.wkdir", "./target/eve" );
-        env.put( "server.schemas", "org.apache.ldap.server.schema.bootstrap.SystemSchema org.apache.ldap.server.schema.bootstrap.ApacheSchema org.apache.ldap.server.schema.bootstrap.CoreSchema org.apache.ldap.server.schema.bootstrap.CosineSchema org.apache.ldap.server.schema.bootstrap.InetorgpersonSchema org.apache.ldap.server.schema.bootstrap.Krb5kdcSchema" );
+        MutableStartupConfiguration config = new MutableStartupConfiguration();
+
+        MutableContextPartitionConfiguration partConfig = new MutableContextPartitionConfiguration();
+        partConfig.setName( "example" );
+
+        HashSet indices = new HashSet();
+        indices.add( "dc" );
+        indices.add( "ou" );
+        indices.add( "objectClass" );
+        indices.add( "krb5PrincipalName" );
+        indices.add( "uid" );
+        partConfig.setIndexedAttributes( indices );
+
+        partConfig.setSuffix( "dc=example,dc=com" );
+
+        LockableAttributesImpl attrs = new LockableAttributesImpl();
+        LockableAttributeImpl attr = new LockableAttributeImpl( "objectClass" );
+        attr.add( "top" );
+        attr.add( "domain" );
+        attrs.put( attr );
+        attrs.put( "dc", "example" );
+        partConfig.setContextEntry( attrs );
+
+        Set schemas = new HashSet();
+        schemas.add( new CoreSchema() );
+        schemas.add( new CosineSchema() );
+        schemas.add( new ApacheSchema() );
+        schemas.add( new InetorgpersonSchema() );
+        schemas.add( new Krb5kdcSchema() );
+        schemas.add( new SystemSchema() );
+        config.setBootstrapSchemas( schemas );
+        config.setContextPartitionConfigurations( Collections.singleton( partConfig ) );
+
+        partConfig.setSuffix( "dc=example,dc=com" );
+
+        return config.toJndiEnvironment();
     }
 }
-