Repository: karaf Updated Branches: refs/heads/master a45dc3bca -> 2f237e064
[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/2f237e06 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/2f237e06 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/2f237e06 Branch: refs/heads/master Commit: 2f237e06411884728e4500c2b7fc44585d5b6910 Parents: a45dc3b Author: Jean-Baptiste Onofré <[email protected]> Authored: Sat Jul 19 18:08:59 2014 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Sat Jul 19 18:08:59 2014 +0200 ---------------------------------------------------------------------- .../bundle/core/internal/BundleWatcherImpl.java | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/2f237e06/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 5181bc3..bd740cc 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 @@ -32,16 +32,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.karaf.bundle.core.BundleInfo; import org.apache.karaf.bundle.core.BundleService; import org.apache.karaf.bundle.core.BundleWatcher; import org.apache.karaf.util.maven.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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -129,9 +124,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); } } } @@ -158,9 +157,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 {
