Author: gnodet Date: Wed Dec 16 12:16:23 2009 New Revision: 891210 URL: http://svn.apache.org/viewvc?rev=891210&view=rev Log: FELIX-1851: FileInstall watched bundles are restarted twice upon update
Modified: felix/trunk/fileinstall/pom.xml felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java Modified: felix/trunk/fileinstall/pom.xml URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/pom.xml?rev=891210&r1=891209&r2=891210&view=diff ============================================================================== --- felix/trunk/fileinstall/pom.xml (original) +++ felix/trunk/fileinstall/pom.xml Wed Dec 16 12:16:23 2009 @@ -35,12 +35,12 @@ <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> - <version>4.0.0</version> + <version>4.1.0</version> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> - <version>4.0.0</version> + <version>4.1.0</version> </dependency> </dependencies> <build> Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java?rev=891210&r1=891209&r2=891210&view=diff ============================================================================== --- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java (original) +++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java Wed Dec 16 12:16:23 2009 @@ -390,8 +390,6 @@ if (uninstalledBundles.size() > 0 || updatedBundles.size() > 0) { // Refresh if any bundle got uninstalled or updated. - // This can lead to restart of recently updated bundles, but - // don't worry about that at this point of time. refresh(); } @@ -893,6 +891,7 @@ if (Util.loadChecksum(b, context) != checksum) { log(Logger.LOG_WARNING, "A bundle with the same symbolic name (" + sn + ") and version (" + vStr + ") is already installed. Updating this bundle instead.", null); + stopTransient(b); Util.storeChecksum(b, checksum, context); b.update(is); } @@ -980,6 +979,7 @@ + ". The bundle has been uninstalled", null); return null; } + stopTransient(bundle); Util.storeChecksum(bundle, artifact.getChecksum(), context); InputStream in = (transformed != null) ? transformed.openStream() : new FileInputStream(path); try @@ -1005,6 +1005,7 @@ + ". The bundle has been uninstalled", null); return null; } + stopTransient(bundle); Util.storeChecksum(bundle, artifact.getChecksum(), context); InputStream in = new FileInputStream(transformed != null ? transformed : path); try @@ -1025,6 +1026,15 @@ return bundle; } + private void stopTransient(Bundle bundle) throws BundleException { + // Stop the bundle transiently so that it will be restarted when startAllBundles() is called + // but this avoids the need to restart the bundle twice (once for the update and another one + // when refreshing packages). + if (startBundles) { + bundle.stop(Bundle.STOP_TRANSIENT); + } + } + private void startAllBundles() { List bundles = new ArrayList();