incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r792562 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl: OsgiControllerImpl.java tasks/SynchronousRefreshPackagesTask.java
Date Thu, 09 Jul 2009 14:37:11 GMT
Author: bdelacretaz
Date: Thu Jul  9 14:37:10 2009
New Revision: 792562

URL: http://svn.apache.org/viewvc?rev=792562&view=rev
Log:
SLING-1039 - OsgiControllerImpl created too many BundleStartTasks

Modified:
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792562&r1=792561&r2=792562&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
Thu Jul  9 14:37:10 2009
@@ -31,9 +31,7 @@
 import org.apache.sling.osgi.installer.OsgiControllerServices;
 import org.apache.sling.osgi.installer.ResourceOverrideRules;
 import org.apache.sling.osgi.installer.impl.tasks.BundleInstallRemoveTask;
-import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask;
 import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallRemoveTask;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -152,20 +150,9 @@
     	}
     	
         synchronized (tasks) {
-        	// Add start bundle tasks for all active bundles
-        	// so that they are restarted once we're done
-        	for(Bundle b : bundleContext.getBundles()) {
-        		if(b.getState() == Bundle.ACTIVE) {
-        			final OsgiControllerTask t = new BundleStartTask(b.getBundleId()); 
-        			tasks.add(t);
-                	if(getLogService() != null) {
-                        getLogService().log(LogService.LOG_DEBUG, "Added " + t); 
-                	}
-        		}
-        	}
-
         	if(getLogService() != null) {
-                getLogService().log(LogService.LOG_INFO, "Executing " + tasks.size() + "
queued tasks");
+                getLogService().log(LogService.LOG_INFO, "Executing " + tasks.size() 
+                		+ " queued tasks (more might be created during execution cycle)");
         	}
             final long start = System.currentTimeMillis();
             

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java?rev=792562&r1=792561&r2=792562&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
Thu Jul  9 14:37:10 2009
@@ -21,6 +21,7 @@
 import org.apache.sling.osgi.installer.OsgiControllerServices;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.service.log.LogService;
@@ -67,6 +68,20 @@
         final long timeout = System.currentTimeMillis() + MAX_REFRESH_PACKAGES_WAIT_SECONDS
* 1000L;
         ocs = ctx.getOsgiControllerServices();
 
+        // Refreshing packages might cause some bundles to be stopped,
+        // make sure all currently active ones are restarted after
+        // this task executes
+    	for(Bundle b : ctx.getBundleContext().getBundles()) {
+    		if(b.getState() == Bundle.ACTIVE) {
+    			final OsgiControllerTask t = new BundleStartTask(b.getBundleId());
+    			ctx.addTaskToCurrentCycle(t);
+            	if(ctx.getOsgiControllerServices().getLogService() != null) {
+            		ctx.getOsgiControllerServices().getLogService().log(LogService.LOG_DEBUG, 
+            				"Added " + t + " to restart bundle if needed after refreshing packages");

+            	}
+    		}
+    	}
+
         // It seems like (at least with Felix 1.0.4) we won't get a FrameworkEvent.PACKAGES_REFRESHED
         // if one happened very recently and there's nothing to refresh
         ctx.getPackageAdmin().refreshPackages(null);



Mime
View raw message