directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1412556 - in /directory/apacheds/trunk/service/src: main/java/org/apache/directory/server/UberjarMain.java test/java/org/apache/directory/server/UberJarMainTest.java
Date Thu, 22 Nov 2012 14:17:28 GMT
Author: elecharny
Date: Thu Nov 22 14:17:27 2012
New Revision: 1412556

URL: http://svn.apache.org/viewvc?rev=1412556&view=rev
Log:
Modified the UberjarMain so that we can stop the server when the UberjarMain test is finished.
This is necessary if we want to be able to release the handle on the master.db file.

Modified:
    directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java
    directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java

Modified: directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java?rev=1412556&r1=1412555&r2=1412556&view=diff
==============================================================================
--- directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java
(original)
+++ directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java
Thu Nov 22 14:17:27 2012
@@ -35,6 +35,9 @@ public class UberjarMain
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( UberjarMain.class );
 
+    /** The ApacheDS service */
+    ApacheDsService service;
+
 
     /**
      * Takes a single argument, the path to the installation home, which contains 
@@ -46,16 +49,48 @@ public class UberjarMain
     {
         if ( ( args != null ) && ( args.length == 1 ) )
         {
-            // Creating ApacheDS service
-            ApacheDsService service = new ApacheDsService();
+            UberjarMain uberjarMain = new UberjarMain();
+            
+            uberjarMain.start( args );
+        }
+        else
+        {
+            // TODO default to the current directory.
+            throw new IllegalArgumentException(
+                "Program must be launched with 1 arguement, the path to the instance directory."
);
+        }
+    }
+    
+    
+    public void start( String[] args )
+    {
+        // Creating ApacheDS service
+        service = new ApacheDsService();
 
-            // Creating instance layouts from the argument
-            InstanceLayout instanceLayout = new InstanceLayout( args[0] );
+        // Creating instance layouts from the argument
+        InstanceLayout instanceLayout = new InstanceLayout( args[0] );
 
-            // Initializing the service
+        // Initializing the service
+        try
+        {
+            service.start( instanceLayout );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+            LOG.error( "Failed to start the service.", e );
+            System.exit( 1 );
+        }
+    }
+    
+    
+    public void stop()
+    {
+        if ( service != null )
+        {
             try
             {
-                service.start( instanceLayout );
+                service.stop();
             }
             catch ( Exception e )
             {
@@ -64,11 +99,5 @@ public class UberjarMain
                 System.exit( 1 );
             }
         }
-        else
-        {
-            // TODO default to the current directory.
-            throw new IllegalArgumentException(
-                "Program must be launched with 1 arguement, the path to the instance directory."
);
-        }
     }
 }

Modified: directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java?rev=1412556&r1=1412555&r2=1412556&view=diff
==============================================================================
--- directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
(original)
+++ directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
Thu Nov 22 14:17:27 2012
@@ -94,7 +94,9 @@ public class UberJarMainTest
         instanceDirectory.mkdir();
 
         // Launching the server
-        UberjarMain.main( new String[]
+        UberjarMain uberjarMain = new UberjarMain();
+        
+        uberjarMain.start( new String[]
             { instanceDirectory.toString() } );
 
         // Creating a separate thread for the connection verification
@@ -119,6 +121,7 @@ public class UberJarMainTest
 
                     // Looking for the Root DSE entry
                     Entry rootDseEntry = connection.lookup( Dn.ROOT_DSE );
+                    
                     if ( rootDseEntry == null )
                     {
                         // This isn't good
@@ -132,7 +135,7 @@ public class UberJarMainTest
                 }
             };
         };
-
+        
         // Starting the connection verification thread
         // and waiting for the termination of it
         connectionVerificationThread.start();



Mime
View raw message