incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1156070 - in /sling/trunk: contrib/launchpad/testing/ launchpad/base/src/main/java/org/apache/sling/launchpad/app/ launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/ launchpad/base/src/main/java/org/apache/sling/launchpad/b...
Date Wed, 10 Aug 2011 08:46:48 GMT
Author: cziegeler
Date: Wed Aug 10 08:46:47 2011
New Revision: 1156070

URL: http://svn.apache.org/viewvc?rev=1156070&view=rev
Log:
SLING-2174 : Leverage Framework interface to better control framework startup

Modified:
    sling/trunk/contrib/launchpad/testing/pom.xml
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java
    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/webapp/SlingServletDelegate.java
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java
    sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/BootstrapInstallerTest.java
    sling/trunk/launchpad/builder/pom.xml
    sling/trunk/launchpad/integration-tests/pom.xml
    sling/trunk/launchpad/testing/pom.xml

Modified: sling/trunk/contrib/launchpad/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/pom.xml?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/contrib/launchpad/testing/pom.xml (original)
+++ sling/trunk/contrib/launchpad/testing/pom.xml Wed Aug 10 08:46:47 2011
@@ -421,7 +421,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.base</artifactId>
-            <version>2.2.1-SNAPSHOT</version>
+            <version>2.3.1-SNAPSHOT</version>
             <classifier>webapp</classifier>
             <type>war</type>
             <scope>runtime</scope>

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/app/ControlListener.java
Wed Aug 10 08:46:47 2011
@@ -105,7 +105,7 @@ class ControlListener implements Runnabl
         if (socketAddress != null) {
             Thread listener = new Thread(this);
             listener.setDaemon(true);
-            listener.setName("Sling Control Listener@" + socketAddress);
+            listener.setName("Apache Sling Control Listener@" + socketAddress);
             listener.start();
         } else {
             Main.info("No socket address to listen to", null);
@@ -139,7 +139,7 @@ class ControlListener implements Runnabl
         try {
             server = new ServerSocket();
             server.bind(socketAddress);
-            Main.info("Sling Control Server started", null);
+            Main.info("Apache Sling Control Server started", null);
         } catch (IOException ioe) {
             Main.error("Failed to start Sling Control Server", ioe);
             return;
@@ -157,7 +157,7 @@ class ControlListener implements Runnabl
                         slingMain.shutdown();
                         writeLine(s, RESPONSE_OK);
 
-                        Main.info("Sling shut down, exiting Java VM", null);
+                        Main.info("Apache Sling shut down, exiting Java VM", null);
                         System.exit(0);
 
                     } else if (COMMAND_STATUS.equals(command)) {
@@ -231,7 +231,7 @@ class ControlListener implements Runnabl
                     + result, null);
                 return 0; // LSB code for everything's fine
             } catch (ConnectException ce) {
-                Main.info("No Sling running at " + socketAddress, null);
+                Main.info("No Apache Sling running at " + socketAddress, null);
                 return 3; // LSB code for programm not running
             } catch (IOException ioe) {
                 Main.error("Failed sending '" + command + "' to "

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/BootstrapInstaller.java
Wed Aug 10 08:46:47 2011
@@ -34,7 +34,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.jar.JarInputStream;
+import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
 import org.apache.felix.framework.Logger;
@@ -42,12 +42,9 @@ import org.apache.sling.launchpad.api.La
 import org.apache.sling.launchpad.base.impl.bootstrapcommands.BootstrapCommandFile;
 import org.apache.sling.launchpad.base.shared.SharedConstants;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.osgi.service.startlevel.StartLevel;
@@ -61,7 +58,7 @@ import org.osgi.service.startlevel.Start
  * to 1 and started. Any bundle already installed is not installed again and
  * will also not be started here.
  */
-class BootstrapInstaller implements BundleActivator, FrameworkListener {
+class BootstrapInstaller {
 
     /**
      * The Bundle location scheme (protocol) used for bundles installed by this
@@ -146,33 +143,15 @@ class BootstrapInstaller implements Bund
      */
     private final LaunchpadContentProvider resourceProvider;
 
-    private BundleContext bundleContext;
+    /** The bundle context. */
+    private final BundleContext bundleContext;
 
-    /**
-     * The OSGi start level into which the framework is taken by the
-     * {@link #frameworkEvent(FrameworkEvent)} method when the framework has
-     * reached the originally specified start level.
-     * <p>
-     * If this value is smaller than 1 the framework is restarted. This is
-     * particularly the case if the {@link #start(BundleContext)} method causes
-     * the update of an installed framework extension bundle.
-     * <p>
-     * This value is preset by the
-     * {@link #BootstrapInstaller(Logger, LaunchpadContentProvider, Map)} constructor to
-     * the value set in the <code>org.osgi.framework.startlevel.beginning</code>
-     * property of the supplied map.
-     */
-    private int targetStartLevel;
-
-    BootstrapInstaller(Logger logger, LaunchpadContentProvider resourceProvider,
-            Map<String, String> props) {
+    BootstrapInstaller(final BundleContext bundleContext, Logger logger, LaunchpadContentProvider
resourceProvider) {
         this.logger = logger;
         this.resourceProvider = resourceProvider;
-        this.targetStartLevel = getStartLevel(props);
+        this.bundleContext = bundleContext;
     }
 
-    //---------- BundleActivator interface
-
     /**
      * https://issues.apache.org/jira/browse/SLING-922
      * Handles the initial detection and installation of bundles into
@@ -190,36 +169,30 @@ class BootstrapInstaller implements Bund
      *   So you could place your bundles in that structure and get them installed
      *   at the requested start level (0 being "default bundle start level").
      */
-    public void start(final BundleContext context) throws Exception {
+    boolean install() throws IOException {
 
-        // prepare for further startup after initial startup
-        // see the frameworkEvent method for details
-        this.bundleContext = context;
-        this.bundleContext.addFrameworkListener(this);
-
-        // get the startup location in sling home
-        String slingHome = context.getProperty(SharedConstants.SLING_HOME);
+        String slingHome = bundleContext.getProperty(SharedConstants.SLING_HOME);
         File slingStartupDir = getSlingStartupDir(slingHome);
 
         // execute bootstrap commands, if needed
         final BootstrapCommandFile cmd = new BootstrapCommandFile(logger, new File(slingHome,
BOOTSTRAP_CMD_FILENAME));
-        boolean requireRestart = cmd.execute(context);
+        boolean requireRestart = cmd.execute(bundleContext);
 
         boolean shouldInstall = false;
 
         // see if the loading of bundles from the package is forced
-        String fpblString = context.getProperty(SharedConstants.FORCE_PACKAGE_BUNDLE_LOADING);
+        String fpblString = bundleContext.getProperty(SharedConstants.FORCE_PACKAGE_BUNDLE_LOADING);
         if (Boolean.valueOf(fpblString)) {
             shouldInstall = true;
         } else {
-            shouldInstall = !isAlreadyInstalled(context, slingStartupDir);
+            shouldInstall = !isAlreadyInstalled(bundleContext, slingStartupDir);
         }
 
         if (shouldInstall) {
             // only run the war/jar copies when this war/jar is new/changed
 
             // see if the loading of bundles from the package is disabled
-            String dpblString = context.getProperty(SharedConstants.DISABLE_PACKAGE_BUNDLE_LOADING);
+            String dpblString = bundleContext.getProperty(SharedConstants.DISABLE_PACKAGE_BUNDLE_LOADING);
             Boolean disablePackageBundleLoading = Boolean.valueOf(dpblString);
 
             if (disablePackageBundleLoading) {
@@ -253,7 +226,7 @@ class BootstrapInstaller implements Bund
             }
 
             // get the set of all existing (installed) bundles by symbolic name
-            Bundle[] bundles = context.getBundles();
+            Bundle[] bundles = bundleContext.getBundles();
             Map<String, Bundle> bySymbolicName = new HashMap<String, Bundle>();
             for (int i = 0; i < bundles.length; i++) {
                 bySymbolicName.put(bundles[i].getSymbolicName(), bundles[i]);
@@ -263,13 +236,13 @@ class BootstrapInstaller implements Bund
             List<Bundle> installed = new LinkedList<Bundle>();
 
             // get all bundles from the startup location and install them
-            requireRestart |= installBundles(slingStartupDir, context, bySymbolicName, installed);
+            requireRestart |= installBundles(slingStartupDir, bundleContext, bySymbolicName,
installed);
 
             // start all the newly installed bundles (existing bundles are not started if
they are stopped)
             startBundles(installed);
 
             // mark everything installed
-            markInstalled(context, slingStartupDir);
+            markInstalled(bundleContext, slingStartupDir);
         }
 
         // due to the upgrade of a framework extension bundle, the framework
@@ -279,73 +252,9 @@ class BootstrapInstaller implements Bund
             logger.log(
                 Logger.LOG_INFO,
                 "Framework extension(s) have been updated, restarting framework after startup
has completed");
-
-            targetStartLevel = -1;
         }
-    }
-
-    /** Nothing to be done on stop */
-    public void stop(BundleContext context) {
-        this.bundleContext = null;
-    }
-
-    //---------- Framework Listener
-
-    /**
-     * Called whenever a framework event is taking place. This method only cares
-     * for the framework event emitted once the framework startup has completed.
-     * Once the framework startup has completed, this method takes further
-     * actions (besides unregistering as a framework listener):
-     * <ul>
-     * <li>If bundle installation in the {@link #start(BundleContext)} method
-     * included an update of a framework extension fragment bundle, the
-     * framework has to be restarted. This is effectuated by calling the
-     * <code>Bundle.update()</code> method on the system bundle.</li>
-     * <li>If a restart is not required, the StartLevel service is instructed to
-     * raise the framework start level to the value requested by the framework
-     * launcher.</li>
-     * </ul>
-     */
-    public void frameworkEvent(FrameworkEvent event) {
-        if (event.getType() == FrameworkEvent.STARTED) {
-
-            // don't care for further events
-            this.bundleContext.removeFrameworkListener(this);
-
-            if (targetStartLevel < 1) {
-
-                // restart
-                logger.log(Logger.LOG_INFO,
-                    "Restarting framework to resolve new framework extension(s)");
-                try {
-                    bundleContext.getBundle(0).update();
-                } catch (BundleException be) {
-                    logger.log(
-                        Logger.LOG_ERROR,
-                        "Failed restarting to resolve new framework extension(s)",
-                        be);
-                }
-
-            } else {
 
-                // raise start level to the desired target
-                ServiceReference sr = bundleContext.getServiceReference(StartLevel.class.getName());
-                if (sr != null) {
-                    StartLevel sl = (StartLevel) bundleContext.getService(sr);
-                    try {
-                        logger.log(Logger.LOG_INFO, "Setting start level to "
-                            + targetStartLevel);
-                        sl.setStartLevel(targetStartLevel);
-                    } finally {
-                        bundleContext.ungetService(sr);
-                    }
-                } else {
-                    logger.log(Logger.LOG_WARNING,
-                        "StartLevel service not available, will not set the start level");
-                }
-
-            }
-        }
+        return requireRestart;
     }
 
     //---------- Startup folder maintenance
@@ -706,34 +615,19 @@ class BootstrapInstaller implements Bund
      *            of this instance.
      */
     private Manifest getManifest(File jar) {
+        JarFile jarFile = null;
         try {
-            InputStream ins = new FileInputStream(jar);
-            return getManifest(ins);
-        } catch (FileNotFoundException e) {
-            logger.log(Logger.LOG_WARNING, "Could not get inputstream from file ("+jar+"):"+e);
-            //throw new IllegalArgumentException("Could not get inputstream from file ("+jar+"):"+e,
e);
-        }
-        return null;
-    }
-
-    /**
-     * Return the manifest from a jar if it is possible to get it,
-     * this will also handle closing out the stream
-     *
-     * @param ins the inputstream for the jar
-     * @return the manifest OR null if it cannot be obtained
-     */
-    Manifest getManifest(InputStream ins) {
-        try {
-            JarInputStream jis = new JarInputStream(ins);
-            return jis.getManifest();
-        } catch (IOException ioe) {
-            logger.log(Logger.LOG_ERROR, "Failed to read manifest from stream: "
-                    + ins, ioe);
+            jarFile = new JarFile(jar, false);
+            return jarFile.getManifest();
+        } catch (IOException e) {
+            logger.log(Logger.LOG_WARNING,
+                "Could not get inputstream from file (" + jar + "):" + e);
         } finally {
-            try {
-                ins.close();
-            } catch (IOException ignore) {
+            if (jarFile != null) {
+                try {
+                    jarFile.close();
+                } catch (IOException ignore) {
+                }
             }
         }
         return null;
@@ -749,7 +643,7 @@ class BootstrapInstaller implements Bund
      *
      * @param manifest The Manifest from which to extract the header.
      */
-    String getBundleSymbolicName(Manifest manifest) {
+    static String getBundleSymbolicName(Manifest manifest) {
         return manifest.getMainAttributes().getValue(
             Constants.BUNDLE_SYMBOLICNAME);
     }

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=1156070&r1=1156069&r2=1156070&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 Aug 10 08:46:47 2011
@@ -24,11 +24,9 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.management.ManagementFactory;
 import java.net.MalformedURLException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -43,17 +41,17 @@ import javax.management.AttributeList;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.felix.framework.Felix;
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.sling.launchpad.api.LaunchpadContentProvider;
 import org.apache.sling.launchpad.base.shared.Notifiable;
 import org.apache.sling.launchpad.base.shared.SharedConstants;
-import org.osgi.framework.BundleActivator;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.launch.Framework;
 import org.osgi.service.url.URLConstants;
 import org.osgi.service.url.URLStreamHandlerService;
 
@@ -89,10 +87,7 @@ import org.osgi.service.url.URLStreamHan
  * <code>${inner}</code>.
  * <p>
  */
-public class Sling implements BundleActivator {
-
-    /** Pseduo class version ID to keep the IDE quite. */
-    private static final long serialVersionUID = 1L;
+public class Sling {
 
     /**
      * The name of the configuration property defining the Sling home directory
@@ -161,6 +156,14 @@ public class Sling implements BundleActi
     public static final String PROP_SYSTEM_PACKAGES = "org.apache.sling.launcher.system.packages";
 
     /**
+     * Timeout to wait for the initialized framework to actually stop for it to
+     * be reinitialized. This is set to a second, which should be ample time to
+     * do this. If this time passes without the framework being stopped, an
+     * error is issued.
+     */
+    private static final long REINIT_TIMEOUT = 1000L;
+
+    /**
      * List of multiple Execution Environment names supported by various
      * Java Runtime versions.
      * @see #setExecutionEnvironment(Map)
@@ -181,14 +184,7 @@ public class Sling implements BundleActi
      * The <code>Felix</code> instance loaded on {@link #init()} and stopped
      * on {@link #destroy()}.
      */
-    private Felix felix;
-
-    /**
-     * The <code>BundleContext</code> of the OSGi framework system bundle.
-     * This is used for service registration and service access to get at the
-     * delegatee servlet.
-     */
-    private BundleContext bundleContext;
+    private Framework framework;
 
     /**
      * Initializes this servlet by loading the framework configuration
@@ -205,7 +201,7 @@ public class Sling implements BundleActi
         this.logger = logger;
         this.resourceProvider = resourceProvider;
 
-        this.logger.log(Logger.LOG_INFO, "Starting Sling");
+        this.logger.log(Logger.LOG_INFO, "Starting Apache Sling");
 
         // read the default parameters
         Map<String, String> props = this.loadConfigProperties(propOverwrite);
@@ -216,28 +212,24 @@ public class Sling implements BundleActi
         // ensure execution environment
         this.setExecutionEnvironment(props);
 
-        // prepare bootstrap installer and ensure the framework only goes into
-        // level 1 in the first place
-        final BootstrapInstaller bi = new BootstrapInstaller(logger,
-            resourceProvider, props);
-        props.put(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, "1");
-
-        // the custom activator list just contains this servlet
-        List<BundleActivator> activators = new ArrayList<BundleActivator>();
-        activators.add(this);
-        activators.add(bi);
-
         // create the framework and start it
-        Map<String, Object> felixProps = new HashMap<String, Object>(props);
-        felixProps.put(FelixConstants.LOG_LOGGER_PROP, logger);
-        felixProps.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activators);
         try {
-            Felix tmpFelix = new SlingFelix(notifiable, felixProps);
-            tmpFelix.init(); // call needed due to FELIX-910
-            tmpFelix.start();
+            Framework tmpFramework = createFramework(notifiable, logger, props);
+
+            init(tmpFramework);
+
+            if (new BootstrapInstaller(tmpFramework.getBundleContext(), logger,
+                resourceProvider).install()) {
+                stop(tmpFramework);
+                tmpFramework = createFramework(notifiable, logger, props);
+                init(tmpFramework);
+            }
+
+            // finally start
+            tmpFramework.start();
 
             // only assign field if start succeeds
-            this.felix = tmpFelix;
+            this.framework = tmpFramework;
         } catch (BundleException be) {
             throw be;
         } catch (Exception e) {
@@ -246,7 +238,7 @@ public class Sling implements BundleActi
         }
 
         // log sucess message
-        this.logger.log(Logger.LOG_INFO, "Sling started");
+        this.logger.log(Logger.LOG_INFO, "Apache Sling started");
     }
 
     /**
@@ -254,21 +246,21 @@ public class Sling implements BundleActi
      * delegatee servlet if one is set at all.
      */
     public final void destroy() {
-        if (felix != null) {
+        if (framework != null) {
             // get a private copy of the reference and remove the class ref
-            Felix myFelix;
+            Framework myFramework;
             synchronized (this) {
-                myFelix = felix;
-                felix = null;
+                myFramework = framework;
+                framework = null;
             }
 
             // shutdown the Felix container
-            if (myFelix != null) {
-                logger.log(Logger.LOG_INFO, "Shutting down Sling");
+            if (myFramework != null) {
+                logger.log(Logger.LOG_INFO, "Shutting down Apache Sling");
                 try {
 
-                    myFelix.stop();
-                    myFelix.waitForStop(0);
+                    myFramework.stop();
+                    myFramework.waitForStop(0);
 
                 } catch (BundleException be) {
 
@@ -286,7 +278,7 @@ public class Sling implements BundleActi
 
                 }
 
-                logger.log(Logger.LOG_INFO, "Sling stopped");
+                logger.log(Logger.LOG_INFO, "Apache Sling stopped");
             }
         }
     }
@@ -303,10 +295,9 @@ public class Sling implements BundleActi
      *
      * @param bundleContext The <code>BundleContext</code> of the system
      *            bundle of the OSGi framework.
-     * @throws Exception May be thrown if the {@link #doStartBundle()} throws.
+     * @throws BundleException May be thrown if the {@link #doStartBundle()} throws.
      */
-    public final void start(BundleContext bundleContext) throws Exception {
-        this.bundleContext = bundleContext;
+    private final void startup(BundleContext bundleContext) throws BundleException {
 
         // register the context URL handler
         Hashtable<String, Object> props = new Hashtable<String, Object>();
@@ -343,7 +334,11 @@ public class Sling implements BundleActi
         bundleContext.registerService(LaunchpadContentProvider.class.getName(), resourceProvider,
null);
 
         // execute optional bundle startup tasks of an extension
-        this.doStartBundle();
+        try {
+            this.doStartBundle();
+        } catch (Exception e) {
+            throw new BundleException(e.getMessage(), e);
+        }
     }
 
     /**
@@ -355,19 +350,47 @@ public class Sling implements BundleActi
      * @param bundleContext The <code>BundleContext</code> of the system
      *            bundle of the OSGi framework.
      */
-    public final void stop(BundleContext bundleContext) {
+    private final void shutdown() {
         // execute optional bundle stop tasks of an extension
         try {
             this.doStopBundle();
         } catch (Exception e) {
             this.logger.log(Logger.LOG_ERROR, "Unexpected exception caught", e);
         }
+    }
+
+    // ---------- Creating the framework instance
+
+    @SuppressWarnings("unchecked")
+    private Framework createFramework(final Notifiable notifiable,
+            final Logger logger, @SuppressWarnings("rawtypes") Map props)
+            throws Exception {
+        props.put(FelixConstants.LOG_LOGGER_PROP, logger);
+        return new SlingFelix(notifiable, props);
+    }
+
+    private void init(final Framework framework) throws BundleException {
+        // initialize the framework
+        framework.init();
 
-        // drop bundle context reference
-        this.bundleContext = null;
+        // do first startup setup
+        this.startup(framework.getBundleContext());
+    }
+
+    private void stop(final Framework framework) throws BundleException {
+        if ((framework.getState() & (Bundle.STARTING|Bundle.ACTIVE|Bundle.STOPPING))
!= 0) {
+            framework.stop();
+
+            try {
+                framework.waitForStop(REINIT_TIMEOUT);
+            } catch (InterruptedException ie) {
+                throw new BundleException(
+                    "Interrupted while waiting for the framework stop before reinitialization");
+            }
+        }
     }
 
-    // ---------- Configuration Loading ----------------------------------------
+    // ---------- Configuration Loading
 
     /**
      * Loads the configuration properties in the configuration property file
@@ -377,9 +400,9 @@ public class Sling implements BundleActi
      * located in the <tt>conf/</tt> directory of the Felix installation
      * directory and is called "<tt>config.properties</tt>". The
      * installation directory of Felix is assumed to be the parent directory of
-     * the <tt>felix.jar</tt> file as found on the system class path property.
+     * the <tt>framework.jar</tt> file as found on the system class path property.
      * The precise file from which to load configuration properties can be set
-     * by initializing the "<tt>felix.config.properties</tt>" system
+     * by initializing the "<tt>framework.config.properties</tt>" system
      * property to an arbitrary URL.
      *
      * @return A <tt>Properties</tt> instance or <tt>null</tt> if
there was
@@ -415,23 +438,23 @@ public class Sling implements BundleActi
         slingHome = slingHomeFile.getAbsolutePath();
 
         // overlay with ${sling.home}/sling.properties
-        this.logger.log(Logger.LOG_INFO, "Starting sling in " + slingHome);
+        this.logger.log(Logger.LOG_INFO, "Starting Apache Sling in " + slingHome);
         File propFile = new File(slingHome, CONFIG_PROPERTIES);
         this.load(staticProps, propFile);
 
         // migrate old properties to new properties
-        migrateProp(staticProps, "felix.cache.profiledir", Constants.FRAMEWORK_STORAGE);
+        migrateProp(staticProps, "framework.cache.profiledir", Constants.FRAMEWORK_STORAGE);
         migrateProp(staticProps, "sling.osgi-core-packages", "osgi-core-packages");
         migrateProp(staticProps, "sling.osgi-compendium-services", "osgi-compendium-services");
 
         // migrate initial start level property: Felix used to have
-        // felix.startlevel.framework, later moved to org.osgi.framework.startlevel
+        // framework.startlevel.framework, later moved to org.osgi.framework.startlevel
         // and finally now uses org.osgi.framework.startlevel.beginning as
         // speced in the latest R 4.2 draft (2009/03/10). We first check the
         // intermediate Felix property, then the initial property, thus allowing
         // the older (and more probable value) to win
         migrateProp(staticProps, "org.osgi.framework.startlevel", Constants.FRAMEWORK_BEGINNING_STARTLEVEL);
-        migrateProp(staticProps, "felix.startlevel.framework", Constants.FRAMEWORK_BEGINNING_STARTLEVEL);
+        migrateProp(staticProps, "framework.startlevel.framework", Constants.FRAMEWORK_BEGINNING_STARTLEVEL);
 
         // create a copy of the properties to perform variable substitution
         final Map<String, String> runtimeProps = new HashMap<String, String>();
@@ -758,7 +781,7 @@ public class Sling implements BundleActi
      * before it is being stopped.
      */
     protected final BundleContext getBundleContext() {
-        return this.bundleContext;
+        return this.framework.getBundleContext();
     }
 
     /**

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
Wed Aug 10 08:46:47 2011
@@ -16,7 +16,7 @@
  */
 package org.apache.sling.launchpad.base.webapp;
 
-import static org.apache.felix.framework.util.FelixConstants.*;
+import static org.apache.felix.framework.util.FelixConstants.LOG_LEVEL_PROP;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -192,7 +192,7 @@ public class SlingServletDelegate extend
 
         try {
 
-            log("Starting Sling in " + slingHome);
+            log("Starting Apache Sling in " + slingHome);
 
             // read the default parameters
             Map<String, String> props = loadConfigProperties(slingHome);
@@ -212,7 +212,7 @@ public class SlingServletDelegate extend
             // them destroyed in the finally clause.
             if (servletDestroyed) {
 
-                log("SlingServletDelegate destroyed while starting Sling, shutting Sling
down");
+                log("SlingServletDelegate destroyed while starting Apache Sling, shutting
Apache Sling down");
 
             } else {
 
@@ -224,20 +224,20 @@ public class SlingServletDelegate extend
                 tmpSling = null;
                 tmpDelegatee = null;
 
-                log("Sling successfully started in " + slingHome);
+                log("Apache Sling successfully started in " + slingHome);
             }
 
         } catch (BundleException be) {
 
-            throw new ServletException("Failed to start Sling in " + slingHome, be);
+            throw new ServletException("Failed to start Apache Sling in " + slingHome, be);
 
         } catch (ServletException se) {
 
-            throw new ServletException("Failed to start bridge servlet for Sling", se);
+            throw new ServletException("Failed to start bridge servlet for Apache Sling",
se);
 
         } catch (Throwable t) {
 
-            throw new ServletException("Uncaught Failure starting Sling", t);
+            throw new ServletException("Uncaught Failure starting Apache Sling", t);
 
         } finally {
 

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java
Wed Aug 10 08:46:47 2011
@@ -112,7 +112,7 @@ public class SlingServlet extends Generi
         if (slingHome != null) {
             startSling();
         } else {
-            log("Sling cannot be started yet, because sling.home is not defined yet");
+            log("Apache Sling cannot be started yet, because sling.home is not defined yet");
         }
 
         log("Servlet " + getServletName() + " initialized");
@@ -160,7 +160,7 @@ public class SlingServlet extends Generi
 
             ((HttpServletResponse) res).sendError(
                 HttpServletResponse.SC_SERVICE_UNAVAILABLE,
-                "Sling is currently starting up, please try again");
+                "Apache Sling is currently starting up, please try again");
         }
     }
 
@@ -200,7 +200,7 @@ public class SlingServlet extends Generi
          * removed and remove the shutdown hook (but don't care if that fails).
          */
 
-        log("Sling has been stopped");
+        log("Apache Sling has been stopped");
 
         // clear the reference to the framework
         sling = null;
@@ -234,7 +234,7 @@ public class SlingServlet extends Generi
 
         if (updateFile == null) {
 
-            log("Restarting Framework and Sling");
+            log("Restarting Framework and Apache Sling");
             startSling((URL) null);
 
         } else {
@@ -301,7 +301,7 @@ public class SlingServlet extends Generi
 
             startSling(launcherJar);
         } catch (MalformedURLException mue) {
-            log("Cannot load Sling Launcher JAR "
+            log("Cannot load Apache Sling Launcher JAR "
                 + SharedConstants.DEFAULT_SLING_LAUNCHER_JAR, mue);
         }
     }
@@ -313,10 +313,10 @@ public class SlingServlet extends Generi
     private void startSling(URL launcherJar) {
         synchronized (this) {
             if (sling != null) {
-                log("Sling already started, nothing to do");
+                log("Apache Sling already started, nothing to do");
                 return;
             } else if (startingSling != null) {
-                log("Sling being started by Thread " + startingSling);
+                log("Apache Sling being started by Thread " + startingSling);
                 return;
             }
 
@@ -439,7 +439,7 @@ public class SlingServlet extends Generi
 
             }
         }
-        
+
         slingHome = substVars(slingHome, null, null, null);
 
         log("Setting sling.home=" + slingHome + " (" + source + ")");
@@ -477,7 +477,7 @@ public class SlingServlet extends Generi
 
         // ensure message
         if (message == null) {
-            message = "Failed to start Sling in " + slingHome;
+            message = "Failed to start Apache Sling in " + slingHome;
         }
 
         // unwrap to get the real cause
@@ -494,7 +494,7 @@ public class SlingServlet extends Generi
             startingSling = null;
         }
     }
-    
+
     // ---------- Property file variable substition support --------------------
 
     /**

Modified: sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/BootstrapInstallerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/BootstrapInstallerTest.java?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/BootstrapInstallerTest.java
(original)
+++ sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/BootstrapInstallerTest.java
Wed Aug 10 08:46:47 2011
@@ -25,9 +25,6 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.HashMap;
-import java.util.jar.Manifest;
-
 import org.junit.Test;
 
 /**
@@ -186,46 +183,6 @@ public class BootstrapInstallerTest {
         assertFalse(BootstrapInstaller.isBlank(" asdf "));
     }
 
-    /**
-     * Test method for
-     * {@link org.apache.sling.launchpad.base.impl.BootstrapInstaller#getManifest(java.io.InputStream)}
-     * .
-     */
-    @Test
-    public void testGetManifestInputStream() {
-        BootstrapInstaller bsi = new BootstrapInstaller(null, null, new HashMap<String,
String>());
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(
-            "holaworld.jar");
-        Manifest m = bsi.getManifest(is);
-        assertNotNull(m);
-
-        is = Thread.currentThread().getContextClassLoader().getResourceAsStream(
-            "holaworld-nomanifest.jar");
-        m = bsi.getManifest(is);
-        assertNull(m);
-    }
-
-    /**
-     * Test method for
-     * {@link org.apache.sling.launchpad.base.impl.BootstrapInstaller#getBundleSymbolicName(java.util.jar.Manifest)}
-     * .
-     */
-    @Test
-    public void testGetBundleSymbolicName() {
-        BootstrapInstaller bsi = new BootstrapInstaller(null, null, new HashMap<String,
String>());
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(
-            "holaworld.jar");
-        Manifest m = bsi.getManifest(is);
-        String sname = bsi.getBundleSymbolicName(m);
-        assertNotNull(sname);
-
-        is = Thread.currentThread().getContextClassLoader().getResourceAsStream(
-            "holaworld-invalid.jar");
-        m = bsi.getManifest(is);
-        sname = bsi.getBundleSymbolicName(m);
-        assertNull(sname);
-    }
-
     // TODO eventually add in tests that create a context so we can test more
     // things in detail
 

Modified: sling/trunk/launchpad/builder/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/pom.xml?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/pom.xml (original)
+++ sling/trunk/launchpad/builder/pom.xml Wed Aug 10 08:46:47 2011
@@ -294,7 +294,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.base</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <classifier>webapp</classifier>
             <type>war</type>
             <scope>runtime</scope>
@@ -302,7 +302,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.base</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <classifier>app</classifier>
             <scope>provided</scope>
         </dependency>

Modified: sling/trunk/launchpad/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/pom.xml?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/pom.xml (original)
+++ sling/trunk/launchpad/integration-tests/pom.xml Wed Aug 10 08:46:47 2011
@@ -125,7 +125,7 @@
     <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.testing</artifactId>
-      <version>2.0.8</version>
+      <version>2.0.9-SNAPSHOT</version>
       <exclusions>
         <exclusion>
           <groupId>org.slf4j</groupId>

Modified: sling/trunk/launchpad/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/pom.xml?rev=1156070&r1=1156069&r2=1156070&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/pom.xml (original)
+++ sling/trunk/launchpad/testing/pom.xml Wed Aug 10 08:46:47 2011
@@ -164,12 +164,12 @@
                     <dependency>
                         <groupId>org.apache.sling</groupId>
                         <artifactId>org.apache.sling.launchpad.base</artifactId>
-                        <version>2.3.0</version>
+                        <version>2.3.1-SNAPSHOT</version>
                     </dependency>
                     <dependency>
                         <groupId>org.apache.sling</groupId>
                         <artifactId>org.apache.sling.launchpad.base</artifactId>
-                        <version>2.3.0</version>
+                        <version>2.3.1-SNAPSHOT</version>
                         <classifier>app</classifier>
                     </dependency>
                 </dependencies>
@@ -468,7 +468,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.base</artifactId>
-            <version>2.3.0</version>
+            <version>2.3.1-SNAPSHOT</version>
             <classifier>app</classifier>
         </dependency>
 
@@ -504,7 +504,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.testing</artifactId>
-            <version>2.0.9-SNAPSHOT</version>
+            <version>2.0.8</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>



Mime
View raw message