directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1082181 - /directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
Date Wed, 16 Mar 2011 16:14:19 GMT
Author: pamarcelot
Date: Wed Mar 16 16:14:19 2011
New Revision: 1082181

URL: http://svn.apache.org/viewvc?rev=1082181&view=rev
Log:
Fix for DIRSERVER-1598 (Code referenced in "Embedding ApacheDS as a Web Application" doesn't
compile with apacheds-all 1.5.8-SNAPSHOT).

Modified:
    directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java

Modified: directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
URL: http://svn.apache.org/viewvc/directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java?rev=1082181&r1=1082180&r2=1082181&view=diff
==============================================================================
--- directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
(original)
+++ directory/documentation/samples/trunk/apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java
Wed Mar 16 16:14:19 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package ${package};
+package org.example;
 
 
 import java.io.File;
@@ -30,21 +30,21 @@ import javax.servlet.ServletContextListe
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.InstanceLayout;
 import org.apache.directory.server.core.factory.JdbmPartitionFactory;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.ldif.LdifPartition;
 import org.apache.directory.server.core.schema.SchemaPartition;
-import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.schema.SchemaManager;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
-import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
-import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
-import org.apache.directory.server.core.factory.JdbmPartitionFactory;
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+
 
 /**
  * A Servlet context listener to start and stop ApacheDS.
@@ -72,7 +72,6 @@ public class StartStopListener implement
 
             ldapServer = new LdapServer();
             ldapServer.setDirectoryService( directoryService );
-            ldapServer.setAllowAnonymousAccess( true );
 
             // Set LDAP port to 10389
             TcpTransport ldapTransport = new TcpTransport( 10389 );
@@ -83,12 +82,13 @@ public class StartStopListener implement
             File workingDir = ( File ) servletContext.getAttribute( "javax.servlet.context.tempdir"
);
             workingDir = new File( workingDir, "server-work" );
             workingDir.mkdirs();
-            
-            directoryService.setWorkingDirectory( workingDir );
+
+            InstanceLayout instanceLayout = new InstanceLayout( workingDir );
+            directoryService.setInstanceLayout( instanceLayout );
 
             initSchema();
             initSystemPartition();
-            
+
             directoryService.startup();
             ldapServer.start();
 
@@ -117,8 +117,8 @@ public class StartStopListener implement
             throw new RuntimeException( e );
         }
     }
-    
-    
+
+
     /**
      * Inits the schema and schema partition.
      */
@@ -128,14 +128,14 @@ public class StartStopListener implement
 
         // Init the LdifPartition
         LdifPartition ldifPartition = new LdifPartition();
-        String workingDirectory = directoryService.getWorkingDirectory().getPath();
-        ldifPartition.setWorkingDirectory( workingDirectory + "/schema" );
+
+        File partitionsDirectory = directoryService.getInstanceLayout().getPartitionsDirectory();
+        File schemaPartitionDirectory = new File( partitionsDirectory, "schema" );
+        ldifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );
 
         // Extract the schema on disk (a brand new one) and load the registries
-        File serverWorkDirectory = new File( workingDirectory );
-        File schemaRepository = new File( serverWorkDirectory, "schema" );
-        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( serverWorkDirectory
);
-        if( ! schemaRepository.exists() )
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( partitionsDirectory
);
+        if ( !schemaPartitionDirectory.exists() )
         {
             // extract only if the schema directory is not present
             extractor.extractOrCopy();
@@ -147,7 +147,7 @@ public class StartStopListener implement
 
         schemaPartition.setWrappedPartition( ldifPartition );
 
-        SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        SchemaLoader loader = new LdifSchemaLoader( schemaPartitionDirectory );
         SchemaManager schemaManager = new DefaultSchemaManager( loader );
         directoryService.setSchemaManager( schemaManager );
 
@@ -167,7 +167,7 @@ public class StartStopListener implement
         }
     }
 
-    
+
     /**
      * Inits the system partition.
      * 
@@ -182,7 +182,7 @@ public class StartStopListener implement
 
         // Inject the System Partition
         Partition systemPartition = partitionFactory.createPartition( "system", ServerDNConstants.SYSTEM_DN,
500,
-            new File( directoryService.getWorkingDirectory(), "system" ) );
+            new File( directoryService.getInstanceLayout().getPartitionsDirectory(), "system"
) );
         systemPartition.setSchemaManager( directoryService.getSchemaManager() );
 
         partitionFactory.addIndex( systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100
);



Mime
View raw message