Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 857825bbb -> 92e7fabff


[KARAF-3123] Prevent bundle watcher to stop/start fragment bundles


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/92e7fabf
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/92e7fabf
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/92e7fabf

Branch: refs/heads/karaf-3.0.x
Commit: 92e7fabff4a3a5fd79ad248eb9ac2d6920e6c91f
Parents: 857825b
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Sat Jul 19 22:01:57 2014 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Sat Jul 19 22:01:57 2014 +0200

----------------------------------------------------------------------
 .../bundle/core/internal/BundleWatcherImpl.java | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/92e7fabf/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
----------------------------------------------------------------------
diff --git 
a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
 
b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
index 570426f..8e25955 100644
--- 
a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
+++ 
b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleWatcherImpl.java
@@ -34,15 +34,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.karaf.bundle.core.BundleService;
 import org.apache.karaf.bundle.core.BundleWatcher;
 import org.ops4j.pax.url.mvn.Parser;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.*;
 import org.osgi.framework.wiring.FrameworkWiring;
-import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,9 +117,13 @@ public class BundleWatcherImpl implements Runnable, 
BundleListener, BundleWatche
                 }
                 for (Bundle bundle : updated) {
                     try {
-                        bundle.start(Bundle.START_TRANSIENT);
+                        if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) 
!= null) {
+                            logger.info("[Watch] Bundle {} is a fragment, so 
it's not started", bundle.getSymbolicName());
+                        } else {
+                            bundle.start(Bundle.START_TRANSIENT);
+                        }
                     } catch (BundleException ex) {
-                        logger.warn("Error starting bundle", ex);
+                        logger.warn("[Watch] Error starting bundle", ex);
                     }
                 }
             }
@@ -148,9 +145,12 @@ public class BundleWatcherImpl implements Runnable, 
BundleListener, BundleWatche
         if (location != null && location.exists() && location.lastModified() > 
bundle.getLastModified()) {
             InputStream is = new FileInputStream(location);
             try {
-                logger.info("[Watch] Updating watched bundle: " + 
bundle.getSymbolicName() + " ("
-                            + bundle.getVersion() + ")");
-                bundle.stop(Bundle.STOP_TRANSIENT);
+                logger.info("[Watch] Updating watched bundle: {} ({})", 
bundle.getSymbolicName(), bundle.getVersion());
+                if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) {
+                    logger.info("[Watch] Bundle {} is a fragment, so it's not 
stopped", bundle.getSymbolicName());
+                } else {
+                    bundle.stop(Bundle.STOP_TRANSIENT);
+                }
                 bundle.update(is);
                 updated.add(bundle);
             } finally {

Reply via email to