directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r756875 - /directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java
Date Sat, 21 Mar 2009 04:29:17 GMT
Author: kayyagari
Date: Sat Mar 21 04:29:16 2009
New Revision: 756875

URL: http://svn.apache.org/viewvc?rev=756875&view=rev
Log:
o fixed an issue with stopping embedded server
o made the action methods to run in a separate thread

Modified:
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java?rev=756875&r1=756874&r2=756875&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplRunnerUI.java
Sat Mar 21 04:29:16 2009
@@ -28,6 +28,7 @@
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.DefaultDirectoryService;
@@ -62,6 +63,8 @@
     
     private DirectoryService dirService;
     
+    private LdapService ldapService;
+    
     private static final Logger LOG = LoggerFactory.getLogger( SyncreplRunnerUI.class );
     
     // UI components
@@ -90,18 +93,26 @@
     
     public void start()
     {
-        if ( ! workDir.exists() )
+        try
         {
-            workDir.mkdirs();
+            if ( ! workDir.exists() )
+            {
+                workDir.mkdirs();
+            }
+            
+            dirService = startEmbeddedServer( workDir );
+            
+            agent.init( dirService );
+            agent.connect();
+            agent.bind();
+            agent.prepareSyncSearchRequest();
+            agent.startSync();
+        }
+        catch( Exception e )
+        {
+            LOG.error( "Failed to start the embedded server & syncrepl consumer", e );
+            throw new RuntimeException( e );
         }
-
-        dirService = startEmbeddedServer( workDir );
-        
-        agent.init( dirService );
-        agent.connect();
-        agent.bind();
-        agent.prepareSyncSearchRequest();
-        agent.startSync();
     }
 
     public void stop()
@@ -110,6 +121,7 @@
         {
             agent.disconnet();
             dirService.shutdown();
+            ldapService.stop();
         }
         catch( Exception e )
         {
@@ -144,7 +156,7 @@
             dirService.setShutdownHookEnabled( false );
             dirService.setWorkingDirectory( workDir );
             int consumerPort = AvailablePortFinder.getNextAvailable( 1024 );
-            LdapService ldapService = new LdapService();
+            ldapService = new LdapService();
             ldapService.setTcpTransport( new TcpTransport( consumerPort ) );
             ldapService.setDirectoryService( dirService );
 
@@ -177,6 +189,7 @@
     {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
+        frame.setTitle( "Syncrepl consumer UI" );
         
         btnStart = new JButton( "Start" );
         btnStart.setMnemonic( 'S' );
@@ -220,13 +233,26 @@
         {
             btnStart.setEnabled( false );
             btnCleanStart.setEnabled( false );
-            start();
+            SwingUtilities.invokeLater( new Runnable()
+            {
+                public void run()
+                {
+                    start();
+                }
+            } );
             btnStop.setEnabled( true );
         }
         else if( src == btnStop )
         {
             btnStop.setEnabled( false );
-            stop();
+            SwingUtilities.invokeLater( new Runnable()
+            {
+                public void run()
+                {
+                    stop();
+                }
+            } );
+
             btnStart.setEnabled( true );
             btnCleanStart.setEnabled( true );
         }
@@ -235,7 +261,13 @@
             btnCleanStart.setEnabled( false );
             btnStart.setEnabled( false );
 
-            cleanStart();
+            SwingUtilities.invokeLater( new Runnable()
+            {
+                public void run()
+                {
+                    cleanStart();
+                }
+            } );
             btnStop.setEnabled( true );
         }
     }



Mime
View raw message