[FELIX-2787] Do not perform management activities while framework is starting/stopping

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1302323 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
index d77b128..b132ca8 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
@@ -274,7 +274,8 @@
             try
             {
                 // Don't access the disk when the framework is still in a startup phase.
-                if (FileInstall.getStartLevel().getStartLevel() >= activeLevel)
+                if (FileInstall.getStartLevel().getStartLevel() >= activeLevel
+                        && context.getBundle(0).getState() == Bundle.ACTIVE)
                 {
                     Set/*<File>*/ files = scanner.scan(false);
                     // Check that there is a result.  If not, this means that the directory can not be listed,
@@ -1353,4 +1354,22 @@
         }
         return result;
     }
+
+    protected void checkRemovedListener()
+    {
+        List/*<ArtifactListener>*/ listeners = FileInstall.getListeners();
+        for (Iterator it = currentManagedArtifacts.values().iterator(); it.hasNext(); )
+        {
+            Artifact artifact = (Artifact) it.next();
+            File file = artifact.getPath();
+            ArtifactListener listener = findListener(file, listeners);
+            // If no listener can handle this artifact, we need to defer the
+            // processing for this artifact until one is found
+            if (listener == null)
+            {
+                processingFailures.add(file);
+                artifact.setListener(null);
+            }
+        }
+    }
 }