You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2011/08/09 14:56:17 UTC

svn commit: r1155341 - /sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java

Author: cziegeler
Date: Tue Aug  9 12:56:17 2011
New Revision: 1155341

URL: http://svn.apache.org/viewvc?rev=1155341&view=rev
Log:
SLING-2173 : Bundle Update: StartLevel service should be asked for bundle persistent state

Modified:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java?rev=1155341&r1=1155340&r2=1155341&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java (original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleUpdateTask.java Tue Aug  9 12:56:17 2011
@@ -25,6 +25,7 @@ import org.apache.sling.installer.core.i
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.service.startlevel.StartLevel;
 
 /** Update a bundle from a RegisteredResource. Creates
  *  a bundleStartTask to restart the bundle if it was
@@ -45,6 +46,20 @@ public class BundleUpdateTask extends Ab
     }
 
     /**
+     * Check if the bundle is active.
+     * This is true if the bundle has the active state or of the bundle
+     * is in the starting state and has the lazy activation policy.
+     * Or if the bundle is a fragment, it's considered active as well
+     */
+    protected boolean isBundleActive(final Bundle b) {
+        if ( BundleStartTask.isBundleActive(b) ) {
+            return true;
+        }
+        final StartLevel startLevelService = this.creator.getStartLevel();
+        return startLevelService.isBundlePersistentlyStarted(b);
+    }
+
+    /**
      * @see org.apache.sling.installer.api.tasks.InstallTask#execute(org.apache.sling.installer.api.tasks.InstallationContext)
      */
     public void execute(InstallationContext ctx) {
@@ -72,7 +87,7 @@ public class BundleUpdateTask extends Ab
     	try {
             // If the bundle is active before the update - restart it once updated, but
             // in sequence, not right now
-            final boolean reactivate = BundleStartTask.isBundleActive(b);
+            final boolean reactivate = this.isBundleActive(b);
             b.stop();
 
             b.update(getResource().getInputStream());