directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1101926 - /directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
Date Wed, 11 May 2011 15:43:49 GMT
Author: elecharny
Date: Wed May 11 15:43:49 2011
New Revision: 1101926

URL: http://svn.apache.org/viewvc?rev=1101926&view=rev
Log:
Made Felix started in a Daemon Thread, so that it will be shut down properly when we quit
the main method.

Modified:
    directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java

Modified: directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java?rev=1101926&r1=1101925&r2=1101926&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
(original)
+++ directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
Wed May 11 15:43:49 2011
@@ -500,15 +500,37 @@ public class StandaloneLdapCodecService 
         // instantiate and start up felix
         felix = new Felix( config );
         
-        try
-        {
-            felix.start();
-        }
-        catch ( BundleException e )
+        Thread felixThread = new Thread(new Runnable() {
+            public void run()
+            {
+                try
+                {
+                    felix.start();
+                    this.notify();
+                }
+                catch ( BundleException e )
+                {
+                    String message = "Failed to start embedded felix instance: " + e.getMessage();
+                    LOG.error( message, e );
+                    throw new RuntimeException( message, e );
+                }
+            }
+        }, "FelixThread");
+        
+        felixThread.setDaemon( true );
+        felixThread.start();
+        
+        while ( felix.getState() != Felix.ACTIVE )
         {
-            String message = "Failed to start embedded felix instance: " + e.getMessage();
-            LOG.error( message, e );
-            throw new RuntimeException( message, e );
+            try
+            {
+                // Yuuukkkk...
+                Thread.sleep( 10 );
+            }
+            catch( InterruptedException ie )
+            {
+                // done
+            }
         }
     }
     



Mime
View raw message