incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r688973 - in /incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app: BootstrapInstaller.java DeploymentPackageInstaller.java
Date Tue, 26 Aug 2008 06:55:17 GMT
Author: cziegeler
Date: Mon Aug 25 23:55:16 2008
New Revision: 688973

URL: http://svn.apache.org/viewvc?rev=688973&view=rev
Log:
SLING-570 - Only install bundles on first startup.

Modified:
    incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/BootstrapInstaller.java
    incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/DeploymentPackageInstaller.java

Modified: incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/BootstrapInstaller.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/BootstrapInstaller.java?rev=688973&r1=688972&r2=688973&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/BootstrapInstaller.java
(original)
+++ incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/BootstrapInstaller.java
Mon Aug 25 23:55:16 2008
@@ -18,7 +18,13 @@
  */
 package org.apache.sling.launcher.app;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -77,6 +83,9 @@
      */
     private final ResourceProvider resourceProvider;
 
+    /** The data file which works as a marker to detect the first startup. */
+    private static final String DATA_FILE = "bootstrapinstaller.ser";
+
     BootstrapInstaller(Logger logger, ResourceProvider resourceProvider) {
         this.logger = logger;
         this.resourceProvider = resourceProvider;
@@ -86,30 +95,78 @@
      * Installs any Bundles missing in the current framework instance. The
      * Bundles are verified by the Bundle location string. All missing Bundles
      * are first installed and then started in the order of installation.
+     * Also install all deployment packages.
+     *
+     * This installation stuff is only performed during the first startup!
      */
     public void start(BundleContext context) throws Exception {
-
-        // register deployment package support
-        final DeploymentPackageInstaller dpi =
-            new DeploymentPackageInstaller(context, logger, resourceProvider);
-        context.addFrameworkListener(dpi);
-        context.addServiceListener(dpi, "("
-                + Constants.OBJECTCLASS + "=" + DeploymentPackageInstaller.DEPLOYMENT_ADMIN
+ ")");
-
-        // list all existing bundles
-        Bundle[] bundles = context.getBundles();
-        Map<String, Bundle> byLocation = new HashMap<String, Bundle>();
-        for (int i = 0; i < bundles.length; i++) {
-            byLocation.put(bundles[i].getLocation(), bundles[i]);
+        boolean alreadyInstalled = false;
+        final File dataFile = context.getDataFile(DATA_FILE);
+        if ( dataFile != null && dataFile.exists() ) {
+            try {
+                final FileInputStream fis = new FileInputStream(dataFile);
+                try {
+                    final ObjectInputStream ois = new ObjectInputStream(fis);
+                    try {
+                        alreadyInstalled = ois.readBoolean();
+                    } finally {
+                        try {
+                            ois.close();
+                        } catch (IOException ignore) {}
+                    }
+                } finally {
+                    try {
+                        fis.close();
+                    } catch (IOException ignore) {}
+                }
+            } catch (IOException ioe) {
+                logger.log(Logger.LOG_ERROR, "IOException during reading of installed flag.",
ioe);
+            }
         }
 
-        // install bundles
-        List<Bundle> installed = new LinkedList<Bundle>();
-        installBundles(context, byLocation, PATH_CORE_BUNDLES, installed);
-        installBundles(context, byLocation, PATH_BUNDLES, installed);
+        if ( !alreadyInstalled ) {
+            // register deployment package support
+            final DeploymentPackageInstaller dpi =
+                new DeploymentPackageInstaller(context, logger, resourceProvider);
+            context.addFrameworkListener(dpi);
+            context.addServiceListener(dpi, "("
+                    + Constants.OBJECTCLASS + "=" + DeploymentPackageInstaller.DEPLOYMENT_ADMIN
+ ")");
+
+            // list all existing bundles
+            Bundle[] bundles = context.getBundles();
+            Map<String, Bundle> byLocation = new HashMap<String, Bundle>();
+            for (int i = 0; i < bundles.length; i++) {
+                byLocation.put(bundles[i].getLocation(), bundles[i]);
+            }
 
-        // set start levels on the bundles and start them
-        startBundles(context, installed);
+            // install bundles
+            List<Bundle> installed = new LinkedList<Bundle>();
+            installBundles(context, byLocation, PATH_CORE_BUNDLES, installed);
+            installBundles(context, byLocation, PATH_BUNDLES, installed);
+
+            try {
+                final FileOutputStream fos = new FileOutputStream(dataFile);
+                try {
+                    final ObjectOutputStream oos = new ObjectOutputStream(fos);
+                    try {
+                        oos.writeBoolean(true);
+                    } finally {
+                        try {
+                            oos.close();
+                        } catch (IOException ignore) {}
+                    }
+                } finally {
+                    try {
+                        fos.close();
+                    } catch (IOException ignore) {}
+                }
+            } catch (IOException ioe) {
+                logger.log(Logger.LOG_ERROR, "IOException during writing of installed flag.",
ioe);
+            }
+
+            // set start levels on the bundles and start them
+            startBundles(context, installed);
+        }
     }
 
     /** Nothing to be done on stop */

Modified: incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/DeploymentPackageInstaller.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/DeploymentPackageInstaller.java?rev=688973&r1=688972&r2=688973&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/DeploymentPackageInstaller.java
(original)
+++ incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launcher/app/DeploymentPackageInstaller.java
Mon Aug 25 23:55:16 2008
@@ -103,6 +103,7 @@
     /**
      * Deploy the deployment packages.
      */
+    @SuppressWarnings("unchecked")
     private void deploy() {
         ArrayList<String> installedPcks = null;
         final File dataFile = this.bundleContext.getDataFile(DATA_FILE);



Mime
View raw message