You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/08/26 23:17:25 UTC
svn commit: r1162261 -
/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Author: rickhall
Date: Fri Aug 26 21:17:25 2011
New Revision: 1162261
URL: http://svn.apache.org/viewvc?rev=1162261&view=rev
Log:
Handle refreshing extension bundles and the system bundle better. (FELIX-2467)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1162261&r1=1162260&r2=1162261&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Fri Aug 26 21:17:25 2011
@@ -3997,70 +3997,65 @@ public class Felix extends BundleImpl im
{
for (Bundle b : bundles)
{
- if (systemBundle == b)
+ if ((systemBundle == b) || ((BundleImpl) b).isExtension())
{
- Bundle[] allBundles = getBundles();
- for (int j = 0; !restart && j < allBundles.length; j++)
- {
- if (((BundleImpl) allBundles[j]).isExtension() &&
- (allBundles[j].getState() == Bundle.INSTALLED))
- {
- restart = true;
- break;
- }
- }
+ restart = true;
+ break;
}
-
- // Remove any targeted bundles from the uninstalled bundles
- // array, since they will be removed from the system after
- // the refresh.
- // TODO: FRAMEWORK - Is this correct?
- forgetUninstalledBundle((BundleImpl) b);
}
- // Now we actually need to refresh the affected bundles.
- // At this point the collection contains every bundle that has
- // been updated and/or removed as well as all bundles that import
- // packages from these bundles.
+ // If we need to restart the framework, then no reason to
+ // do a refresh.
+ if (!restart)
+ {
+ // Now we actually need to refresh the affected bundles.
+ // At this point the collection contains every bundle that has
+ // been updated and/or removed as well as all bundles that import
+ // packages from these bundles.
+
+ // Create refresh helpers for each bundle.
+ List<RefreshHelper> helpers = new ArrayList<RefreshHelper>(bundles.size());
+ for (Bundle b : bundles)
+ {
+ // Remove any targeted bundles from the uninstalled bundles
+ // array, since they will be removed from the system after
+ // the refresh.
+ // TODO: FRAMEWORK - Is this correct?
+ forgetUninstalledBundle((BundleImpl) b);
- // Create refresh helpers for each bundle.
- List<RefreshHelper> helpers = new ArrayList<RefreshHelper>(bundles.size());
- for (Bundle b : bundles)
- {
- helpers.add(new RefreshHelper(b));
- }
+ // Create refresh helper for bundle.
+ helpers.add(new RefreshHelper(b));
+ }
- // Stop, purge or remove, and reinitialize all bundles first.
- // TODO: FRAMEWORK - this will stop the system bundle if
- // somebody called refresh 0. Is this what we want?
- for (RefreshHelper helper : helpers)
- {
- if (helper != null)
+ // Stop, purge or remove, and reinitialize all bundles first.
+ for (RefreshHelper helper : helpers)
{
- helper.stop();
- helper.refreshOrRemove();
+ if (helper != null)
+ {
+ helper.stop();
+ helper.refreshOrRemove();
+ }
}
- }
- // Then restart all bundles that were previously running.
- for (RefreshHelper helper : helpers)
- {
- if (helper != null)
+ // Then restart all bundles that were previously running.
+ for (RefreshHelper helper : helpers)
{
- helper.restart();
+ if (helper != null)
+ {
+ helper.restart();
+ }
}
}
- }
-
- if (restart)
- {
- try
- {
- update();
- }
- catch (BundleException ex)
+ else
{
- m_logger.log(Logger.LOG_ERROR, "Framework restart error.", ex);
+ try
+ {
+ update();
+ }
+ catch (BundleException ex)
+ {
+ m_logger.log(Logger.LOG_ERROR, "Framework restart error.", ex);
+ }
}
}
}