Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Excerpt
hiddentrue

How we could get the Sling Launcher to be updated through management interfaces such as the Felix Web Console or the Felix Shell. (IMPLEMENTED)

Status: DRAFTIMPLEMENTED
Created: 10. Januar January 2009
Author: fmeschbe
Updated: 13. January 2009, fmeschbe, Prototype implementation

Table of Contents
minLevel2

...

The main class or servlet provide the launcher with two Runnable instances: stopNotifier and updateNotifier. The stopNotifier a Notifiable instances. The Notifiable.stopped() is called if the framework has been stopped. The updateNotifier Notifiable.updated(File) is called if the framework has been stopped for it to be restarted, where the file argument may be the new launcher JAR to use.

The stopNotifier Runnable Notifiable.stopped method enables the main class or servlet to react to the situation that the framework has gone and take appropriate actions. The updateNotifier Runable Notifiable.updated(File) method enables the main class or servlet to drop the framework and classloader and restart the framework in a new class loader with a potentiall potentially new launcher JAR.

5 Prototype

I will be creating have prepared a prototype implementation in my whiteboard

6 Alternative Approach

of this concept in my white board at http://svn.apache.org/repos/asf/incubator/sling/whiteboard/fmeschbe/launchpad.

The launchpad/base module creates two artifacts: The primary artifact is included with the final application. The secondary artifact is the actual launcher JAR file.

...

The primary artifact contains three elements:

  • Notifier Notifiable interface with two methods stopped – called when the framework has been stopped – and updated – called when the framework has been updated and needs to be restarted. This interface is to be implemented by the main class or servlet.
  • Loader creates the URLClassLoader with the launcher JAR and instantiates the launcher class. This class is implemented as a utility class with a two methods loadLauncher and cleanupVM:

...

  • Launcher interface which is implemented by classes in the secondary artifact. This interface has a method to support the standaline Java Application case (setCommandLine). To support the Web Application, the launcher class is expected to implement the javax.servlet.Servlet interface. The Launcher interface is defined as follows:
Code Block

// set sling home for the framework
public void setSlingHome(String slingHome);

// set the Notifiable to be informed on stop/update
public void setNotifiable(Notifiable notifiable);

// sets command line arguments, mainly used by the main class
public void setCommandLine(String[] args);

// starts the framework
public void start();

// stops the framework
// this method only returns when the framework has actually been stopped.
// this method may be used by the main class or servlet to initiate a
// shutdown of the framework
public void stop();

...

The secondary artifact is just what is the launchpad/base artifact today. The extension is just the support for the new API defined in the primary artifact. This secondary artifact is included as the launcher JAR in the final application.

6.3 Building the prototype

To build an test drive the prototype do the following:

1. Checkout the prototype:

No Format

$ svn checkout http://svn.apache.org/repos/asf/incubator/sling/whiteboard/fmeschbe/launchpad prototype

2. Build and locally install the base artifact

No Format

$ cd prototype/base
$ mvn clean install

This install three artifacts: the primary artifact later used as the launcher JAR and two secondary artifacts with classifier shared and sources. The shared artifact is used by the app and webapp modules to get the Loader class and the Notifiable and Launcher interfaces.

3. Build the standalone application

No Format

$ cd ../app
$ mvn -PwithBase,withBundles,withShell clean install

The module has three profiles, which are not enabled by default:

  • withBase – Include the launcher JAR with the build
  • withBundles – Include the Sling Bundles with the build
  • withShell – Add the Apache Felix Shell and Shell Remote bundles

You may omit the withShell profile, but generally want to include the withBase and withBundles artifacts. These profiles will also later be enabled by default.

The standalone application can of course directly be used by launching it with

No Format

$ java -jar target/org.apache.sling.launchpad.app-5-incubator-SNAPSHOT.jar

4. Build the Web Application

The web application depends on the standalone application to share the list of bundles included. The web application is easily built by

No Format

$ cd ../webapp
$ mvn clean install

This creates the web application.

Note: The web application also contains support for SLING-711. This results in modified behaviour for the definition for the defualt sling.home value. Previously the system property sling.home was considered if no sling.home servlet init-param or context init-param was available with a final fallback to "sling". Now the system property is ignored altogether and the default value is derived from the servlet context path as sling/<path> where <path> is the servlet context path with all slashes replaced by underscores and the root context being a single underscore. For example: If Sling is running in the context /sling the defualt sling.home is sling/_sling.