sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1239159 - /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java
Date Wed, 01 Feb 2012 15:03:21 GMT
Author: cziegeler
Date: Wed Feb  1 15:03:20 2012
New Revision: 1239159

URL: http://svn.apache.org/viewvc?rev=1239159&view=rev
Log:
SLING-2376 : New Startup Features

Modified:
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java?rev=1239159&r1=1239158&r2=1239159&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/StartupManager.java
Wed Feb  1 15:03:20 2012
@@ -30,7 +30,6 @@ import org.apache.felix.framework.Logger
 import org.apache.sling.launchpad.api.LaunchpadContentProvider;
 import org.apache.sling.launchpad.api.StartupMode;
 import org.apache.sling.launchpad.base.shared.SharedConstants;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
 /**
@@ -45,7 +44,7 @@ public class StartupManager {
     private static final String DATA_FILE = "launchpad-timestamp.txt";
 
     /** The old data file. */
-    private static final String OLD_DATA_FILE = "bootstrapinstaller.ser";
+    private static final String OLD_DATA_FILE = "bundle0" + File.separatorChar + "bootstrapinstaller.ser";
 
     /**
      * The {@link Logger} use for logging messages during installation and
@@ -64,12 +63,11 @@ public class StartupManager {
     private final boolean incrementalStartupEnabled;
 
     StartupManager(final Map<String, String> properties,
-                   final Logger logger,
-                   final BundleContext bundleContext) {
+                   final Logger logger) {
         this.logger = logger;
         this.startupDir = DirectoryUtil.getStartupDir(properties);
         this.confDir = DirectoryUtil.getConfigDir(properties);
-        this.mode = detectMode(bundleContext);
+        this.mode = detectMode(properties.get(Constants.FRAMEWORK_STORAGE));
         this.logger.log(Logger.LOG_INFO, "Starting in mode " + this.mode);
 
         this.targetStartLevel = Long.valueOf(properties.get(Constants.FRAMEWORK_BEGINNING_STARTLEVEL));
@@ -109,7 +107,7 @@ public class StartupManager {
     /**
      * Detect the startup mode by comparing time stamps
      */
-    private StartupMode detectMode(final BundleContext bundleContext) {
+    private StartupMode detectMode(final String osgiStorageDir) {
         final File dataFile = new File(this.confDir, DATA_FILE);
         if (dataFile.exists()) {
 
@@ -144,13 +142,18 @@ public class StartupManager {
                     try { fis.close(); } catch (IOException ignore) {}
                 }
             }
-        }
-        // check for old data file
-        final File oldFile = bundleContext.getDataFile(OLD_DATA_FILE);
-        if ( oldFile.exists() ) {
-            // this is an upgrade - remove old file
-            oldFile.delete();
-            return StartupMode.UPDATE;
+        } else {
+            // check for old data file
+            // this is a little bit hacky as we have to directly look into
+            // the Apache Felix bundle cache. However, as we know that older
+            // versions did use Felix this is fine.
+            final File felixDir = new File(osgiStorageDir);
+            final File oldFile = new File(felixDir, OLD_DATA_FILE);
+            if ( oldFile.exists() ) {
+                // this is an update - remove old file
+                oldFile.delete();
+                return StartupMode.UPDATE;
+            }
         }
         // not installed yet - fallback
         return StartupMode.INSTALL;



Mime
View raw message