sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1239127 - in /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl: Sling.java StartupManager.java
Date Wed, 01 Feb 2012 13:38:01 GMT
Author: cziegeler
Date: Wed Feb  1 13:38:01 2012
New Revision: 1239127

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

Modified:
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
    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/Sling.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java?rev=1239127&r1=1239126&r2=1239127&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
Wed Feb  1 13:38:01 2012
@@ -220,10 +220,10 @@ public class Sling {
 
         // create the framework and start it
         try {
-            // initiate startup handler
-            final StartupManager startupManager = new StartupManager(props, logger);
 
             Framework tmpFramework = createFramework(notifiable, logger, props);
+            // initiate startup handler
+            final StartupManager startupManager = new StartupManager(props, logger, tmpFramework.getBundleContext());
 
             init(tmpFramework);
 

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=1239127&r1=1239126&r2=1239127&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 13:38:01 2012
@@ -30,6 +30,7 @@ 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;
 
 /**
@@ -43,6 +44,9 @@ public class StartupManager {
     /** The data file which works as a marker to detect the first startup. */
     private static final String DATA_FILE = "launchpad-timestamp.txt";
 
+    /** The old data file. */
+    private static final String OLD_DATA_FILE = "bootstrapinstaller.ser";
+
     /**
      * The {@link Logger} use for logging messages during installation and
      * startup.
@@ -60,11 +64,12 @@ public class StartupManager {
     private final boolean incrementalStartupEnabled;
 
     StartupManager(final Map<String, String> properties,
-                   final Logger logger) {
+                   final Logger logger,
+                   final BundleContext bundleContext) {
         this.logger = logger;
         this.startupDir = DirectoryUtil.getStartupDir(properties);
         this.confDir = DirectoryUtil.getConfigDir(properties);
-        this.mode = detectMode();
+        this.mode = detectMode(bundleContext);
         this.logger.log(Logger.LOG_INFO, "Starting in mode " + this.mode);
 
         this.targetStartLevel = Long.valueOf(properties.get(Constants.FRAMEWORK_BEGINNING_STARTLEVEL));
@@ -104,7 +109,7 @@ public class StartupManager {
     /**
      * Detect the startup mode by comparing time stamps
      */
-    private StartupMode detectMode() {
+    private StartupMode detectMode(final BundleContext bundleContext) {
         final File dataFile = new File(this.confDir, DATA_FILE);
         if (dataFile.exists()) {
 
@@ -140,6 +145,13 @@ public class StartupManager {
                 }
             }
         }
+        // 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;
+        }
         // not installed yet - fallback
         return StartupMode.INSTALL;
     }



Mime
View raw message