FELIX-1833 Make the ComponentActorThread a Runnable handled to a standard
Thread as target and better cleanup of the BundleComponentActivator

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@831396 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/Activator.java b/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
index 767f5d0..5638db5 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
@@ -92,7 +92,9 @@
 
         // create and start the component actor
         m_componentActor = new ComponentActorThread();
-        m_componentActor.start();
+        Thread t = new Thread(m_componentActor, "SCR Component Actor");
+        t.setDaemon( true );
+        t.start();
 
         // register for bundle updates
         context.addBundleListener( this );
@@ -136,21 +138,11 @@
         // dispose component registry
         m_componentRegistry.dispose();
 
-        // terminate the actor thread and wait for it for a limited time
+        // terminate the actor thread
         if ( m_componentActor != null )
         {
-            // terminate asynchrounous updates
             m_componentActor.terminate();
-
-            // wait for all updates to terminate
-            try
-            {
-                m_componentActor.join( 5000 );
-            }
-            catch ( InterruptedException ie )
-            {
-                // don't really care
-            }
+            m_componentActor = null;
         }
     }
 
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
index f10f65a..1b1a3fe 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
@@ -332,6 +332,13 @@
         log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] STOPPED", new Object[]
             { new Long( m_context.getBundle().getBundleId() ) }, null, null );
 
+        if (m_logService != null) {
+            m_logService.close();
+            m_logService = null;
+        }
+
+        m_componentActor = null;
+        m_componentRegistry = null;
         m_context = null;
     }
 
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
index bb88edc..2080563 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -28,7 +28,7 @@
  * The <code>ComponentActorThread</code> is the thread used to act upon registered
  * components of the service component runtime.
  */
-class ComponentActorThread extends Thread
+class ComponentActorThread implements Runnable
 {
 
     // sentinel task to terminate this thread
@@ -51,7 +51,6 @@
 
     ComponentActorThread()
     {
-        super( "SCR Component Actor" );
         tasks = new LinkedList();
     }
 
@@ -65,7 +64,7 @@
     {
         for ( ;; )
         {
-            Runnable task;
+            final Runnable task;
             synchronized ( tasks )
             {
                 while ( tasks.isEmpty() )