directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r893471 - in /directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ: DirectoryServiceFactory.java FrameworkDirectoryServiceFactory.java FrameworkRunner.java
Date Wed, 23 Dec 2009 11:05:41 GMT
Author: kayyagari
Date: Wed Dec 23 11:05:40 2009
New Revision: 893471

URL: http://svn.apache.org/viewvc?rev=893471&view=rev
Log:
o removed the duplicate code
o added a static final default DSFactory instance

Modified:
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java?rev=893471&r1=893470&r2=893471&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
Wed Dec 23 11:05:40 2009
@@ -55,106 +55,6 @@
  */
 public interface DirectoryServiceFactory
 {
-    /**
-     * The default factory returns stock instances of a directory
-     * service with smart defaults
-     */
-    DirectoryServiceFactory DEFAULT = new DirectoryServiceFactory()
-    {
-        private DirectoryService service;
-
-
-        public DirectoryService newInstance() throws Exception
-        {
-            String workingDirectory = System.getProperty( "workingDirectory" );
-
-            if ( workingDirectory == null )
-            {
-                String path = DirectoryServiceFactory.class.getResource( "" ).getPath();
-                int targetPos = path.indexOf( "target" );
-                workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work-" +
UUID.randomUUID().toString();
-            }
-
-            service = new DefaultDirectoryService();
-            service.setWorkingDirectory( new File( workingDirectory ) );
-
-            return service;
-        }
-
-
-        public void init() throws Exception
-        {
-            if ( service.isStarted() )
-            {
-                return;
-            }
-
-            SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-
-            // Init the LdifPartition
-            LdifPartition ldifPartition = new LdifPartition();
-
-            String workingDirectory = service.getWorkingDirectory().getPath();
-
-            ldifPartition.setWorkingDirectory( workingDirectory + "/schema" );
-
-            // Extract the schema on disk (a brand new one) and load the registries
-            File schemaRepository = new File( workingDirectory, "schema" );
-            SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
-            
-            long t0 = System.currentTimeMillis();
-            extractor.extractOrCopy();
-            long t1 = System.currentTimeMillis();
-            System.out.println( "Delta = " + ( t1 - t0 ) );
-
-            schemaPartition.setWrappedPartition( ldifPartition );
-
-            SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
-            SchemaManager schemaManager = new DefaultSchemaManager( loader );
-            service.setSchemaManager( schemaManager );
-
-            // We have to load the schema now, otherwise we won't be able
-            // to initialize the Partitions, as we won't be able to parse 
-            // and normalize their suffix DN
-            long t2 = System.currentTimeMillis();
-            boolean loaded = schemaManager.loadAllEnabled();
-            long t3 = System.currentTimeMillis();
-            System.out.println( "Delta load = " + ( t3 - t2 ) );
-            
-            schemaPartition.setSchemaManager( schemaManager );
-
-            List<Throwable> errors = schemaManager.getErrors();
-
-            if ( errors.size() != 0 )
-            {
-                throw new Exception( "Schema load failed : " + ExceptionUtils.printErrors(
errors ) );
-            }
-
-            service.getChangeLog().setEnabled( true );
-
-            // change the working directory to something that is unique
-            // on the system and somewhere either under target directory
-            // or somewhere in a temp area of the machine.
-
-            // Inject the System Partition
-            Partition systemPartition = new JdbmPartition();
-            systemPartition.setId( "system" );
-            ( ( JdbmPartition ) systemPartition ).setCacheSize( 500 );
-            systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setSchemaManager( schemaManager );
-            ( ( JdbmPartition ) systemPartition ).setPartitionDir( new File( workingDirectory,
"system" ) );
-
-            // Add objectClass attribute for the system partition
-            Set<Index<?, ServerEntry>> indexedAttrs = new HashSet<Index<?,
ServerEntry>>();
-            indexedAttrs.add( new JdbmIndex<Object, ServerEntry>( SchemaConstants.OBJECT_CLASS_AT
) );
-            ( ( JdbmPartition ) systemPartition ).setIndexedAttributes( indexedAttrs );
-
-            service.setSystemPartition( systemPartition );
-
-            service.startup();
-        }
-    };
-
 
     void init() throws Exception;
 

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java?rev=893471&r1=893470&r2=893471&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
Wed Dec 23 11:05:40 2009
@@ -30,6 +30,11 @@
 {
     private DirectoryService service;
 
+    /**
+     * The default factory returns stock instances of a directory
+     * service with smart defaults
+     */
+    public static final DirectoryServiceFactory DEFAULT = new FrameworkDirectoryServiceFactory();
 
     public DirectoryService newInstance() throws Exception
     {

Modified: directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=893471&r1=893470&r2=893471&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Wed Dec 23 11:05:40 2009
@@ -85,7 +85,7 @@
             }
             else if( getSuite() == null ) // for a class without a @Factory and running standalone
without a suite
             {
-                DirectoryServiceFactory dsf = DirectoryServiceFactory.DEFAULT;
+                DirectoryServiceFactory dsf = FrameworkDirectoryServiceFactory.DEFAULT;
                 dirService = dsf.newInstance();
                 dsf.init();
             }
@@ -97,7 +97,7 @@
                 if ( suitFactory == null )
                 {
                     // instantiate a default factory
-                    dsf = DirectoryServiceFactory.DEFAULT;
+                    dsf = FrameworkDirectoryServiceFactory.DEFAULT;
                 }
                 else
                 {



Mime
View raw message