Author: cziegeler
Date: Wed Jun 24 08:58:24 2009
New Revision: 787948
URL: http://svn.apache.org/viewvc?rev=787948&view=rev
Log:
SLING-904 : Implemented a quick and dirty retry if bundle can't be started for
the first time.
Modified:
sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java
Modified:
sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java?rev=787948&r1=787947&r2=787948&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java
(original)
+++
sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java
Wed Jun 24 08:58:24 2009
@@ -132,6 +132,12 @@
*/
public InstallResultCode installOrUpdate(String uri, Map<String, Object>
attributes,
InstallableData installableData) throws BundleException,
IOException {
+ int retryCount = 0;
+ if ( attributes.get("RETRY_COUNT") != null ) {
+ retryCount = (Integer)attributes.get("RETRY_COUNT");
+ }
+ retryCount++;
+ attributes.put("RETRY_COUNT", retryCount);
// Check that we have bundle data and manifest
InputStream data = installableData.adaptTo(InputStream.class);
@@ -166,7 +172,7 @@
// If the bundle (or one with the same symbolic name) is
// already installed, ignore the new one if it's a lower
// version
- if (b != null ) {
+ if (b != null && retryCount == 1) {
final Version installedVersion = new
Version((String)(b.getHeaders().get(Constants.BUNDLE_VERSION)));
final Version newBundleVersion = new
Version(m.getMainAttributes().getValue(Constants.BUNDLE_VERSION));
if
(newBundleVersion.compareTo(installedVersion) <= 0) {
@@ -179,10 +185,15 @@
if (b != null) {
// Existing bundle -> stop, update, restart
- log.debug("Calling Bundle.stop() and updating {}",
uri);
- b.stop();
- b.update(data);
- b.start();
+ if ( retryCount == 1 ) {
+ log.debug("Calling Bundle.stop() and updating
{}", uri);
+ b.stop();
+ b.update(data);
+ b.start();
+ } else {
+ log.debug("Calling Bundle.start {}", uri);
+ b.start();
+ }
updated = true;
needsRefresh = true;
} else {
@@ -308,9 +319,8 @@
activeBundles.size());
refreshPackagesSynchronously(null);
- } else {
- startBundles();
}
+ startBundles();
}
/**