In order to follow this how-to you'll need the following on your computer:
Prior to the Kickstarter, the Sling application was assembled into an uber JAR using the Provisioning Model. The JAR file was fairly large in size and weighed in at ~70MB. If the Sling application required a new bundle, the uber JAR would have to be rebuilt. The Kickstarter was designed to solve this problem as well as streamline the application packaging process.
The Kickstarter provides a method to start Sling using a new application packaging/assembly approach known as the Feature Model. By default, the Kickstarter is configured with a minimum set of feature definitions to produce a lightweight Sling application. If additional customization is required, simply define additional features based on your requirements. Any additional features will then be pulled from a Maven repository.
The Kickstarter uses the Feature Model Launcher to start a Sling instance. It sets up a control port to manage the instance and provides default values to start Sling. The Feature Launcher then downloads the necessary dependencies and installs them into the OSGi container.
Let's try this out!
Visit the Apache Sling Downloads page and download the Kickstart Project bundle.
Then, create a working directory for the Kickstarter and copy the bundle to this location. You can name this directory anything you like.
$ mkdir kickstarter $ cd kickstarter $ cp /some/download/path/org.apache.sling.kickstart-0.0.2.jar .
Run the Kickstarter to start Sling.
$ java -jar org.apache.sling.kickstart-0.0.2.jar
Next, open a browser and visit http://localhost:8080/.
Click the Login link and log in with admin/admin.
Open a new terminal window and navigate to the same Kickstarter working directory that was used to start Sling.
Now, run the Kickstarter JAR again with the
status command to view the current status of your Sling instance.
$ java -jar org.apache.sling.kickstart-0.0.2.jar status
If your Sling instance is running, you should see output similar to this:
/127.0.0.1:52516>status /127.0.0.1:52516<OK Sent 'status' to /127.0.0.1:52481: OK Terminate VM, status: 0
If your sling instance is not running, you should see:
No Apache Sling running at /127.0.0.1:52244 Terminate VM, status: 3
Run the Kickstarter JAR again and specify the
$ java -jar org.apache.sling.kickstart-0.0.2.jar stop
Alternatively, you can stop Sling by hitting
Did we succeed in making you more curious about the world of Feature Models? If you stay with us, you'll learn how to customize Sling by creating your own Feature Models.
If you still want to learn a bit more about the Kickstarter, stay on this page and keep reading.
The generalized command for the Kickstarter is as follows:
$ java -jar <jarfile> [options] [command]
It supports three commands:
status as well as a number of options. For a full list of available options, run the Kickstarter with the
|Short Option||Long Option||Description|
|-a||--address=<address>|| Address to bind to (default |
|-af||--additionalFeature=<additionalFeature>||Define additional feature files. Use multiple options for multiple features.|
|-c||--slingHome=<slingHome>|| Sling context directory (default |
|-D||--define=<key=value>|| Sets property key to value. This is different than the |
|-f||--logFile=<logFile>|| Log file or "-" for stdout (default |
|-i||--launcherHome=<launcherHome>|| Launcher home directory (default |
|-j||--control=<controlAddress>|| Host and port to use for control connection. Format |
|-l||--logLevel=<logLevel>||Initial log level (0..4, FATAL, ERROR, WARN, INFO, DEBUG).|
|-n||--noShutdownHook||Don't install the shutdown hook.|
|-p||--port=<port>|| Port to listen to (default |
|-r||--context=<contextPath>|| Root servlet context path for the HTTP service (default |
|-s||--mainFeature=<mainFeatureFile>||Main feature file (file path or URL). This will replace the default file used by Sling.|
|-v||--verbose||Start the launcher with additional information.|
The real power of the Kickstarter can be seen when you specify your own Feature Model. As an example, let's re-run the Kickstarter and specify an external Feature Model.
We'll start by moving into our
kickstarter workspace. Then, we'll Stop Sling if it's still running. Next, remove the old
launcher directories so that we can start a clean Sling instance. Extract the Sling 12 Feature Model file from the Kickstarter JAR. Lastly, start Sling using the Feature Model JSON file.
$ cd kickstarter $ java -jar org.apache.sling.kickstart-0.0.2.jar stop $ rm -rf conf launcher $ jar -xf org.apache.sling.kickstart-0.0.2.jar feature-sling12.json $ java -jar org.apache.sling.kickstart-0.0.2.jar --mainFeature=feature-sling12.json
If you're curious, take a peak at the Feature Model for Sling 12 by opening
feature-sling12.json in your favorite editor.