incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r818658 [21/23] - in /websites/staging/sling/trunk/content: ./ tutorials-how-tos/
Date Tue, 22 May 2012 08:25:36 GMT
Modified: websites/staging/sling/trunk/content/the-sling-launchpad.html
==============================================================================
--- websites/staging/sling/trunk/content/the-sling-launchpad.html (original)
+++ websites/staging/sling/trunk/content/the-sling-launchpad.html Tue May 22 08:25:32 2012
@@ -82,268 +82,267 @@
         <a href="/">Home</a>
       </div>
       <h1>The Sling Launchpad</h1>
-      <p><a name="TheSlingLaunchpad-TheSlingLaunchpad"></a></p>
-<h1 id="the-sling-launchpad">The Sling Launchpad</h1>
-<p>{toc:minLevel=2|maxLevel=3}</p>
-<p>This tries to explain how exactly the Sling Launchpad works, what
-constitutes the Sling Launchpad and how you can use the Sling Launchpad to
-custom create you Sling launchers. For a view behind the scenes of the
-Sling Launchpad Base module (the actual launcher) you might want to refer
-to the <a href="embedding-sling.html">Embedding Sling</a>
- page.</p>
-<p><a name="TheSlingLaunchpad-SlingHome"></a></p>
+      <h1 id="the-sling-launchpad">The Sling Launchpad</h1>
+<div class="toc">
+<ul>
+<li><a href="#the-sling-launchpad">The Sling Launchpad</a><ul>
+<li><a href="#sling-home">Sling Home</a></li>
+<li><a href="#command-line-options">Command Line Options</a><ul>
+<li><a href="#control-port">Control Port</a></li>
+</ul>
+</li>
+<li><a href="#servlet-parameters">Servlet Parameters</a></li>
+<li><a href="#slingproperties">sling.properties</a></li>
+<li><a href="#components">Components</a><ul>
+<li><a href="#launchpad-base">Launchpad Base</a></li>
+<li><a href="#launchpad-bundles">Launchpad Bundles</a></li>
+<li><a href="#launchpad-app-and-launchpad-webapp">Launchpad App and Launchpad WebApp</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</div>
+<p>This tries to explain how exactly the Sling Launchpad works, what constitutes the Sling Launchpad and how you can use the Sling Launchpad to custom create you Sling launchers. For a view behind the scenes of the Sling Launchpad Base module (the actual launcher) you might want to refer to the <a href="/embedding-sling.html">Embedding Sling</a> page.</p>
 <h2 id="sling-home">Sling Home</h2>
-<p>Since Sling requires some space on the filesystem to store various files
-Sling has to know where this filesystem space is located.</p>
+<p>Since Sling requires some space on the filesystem to store various files Sling has to know where this filesystem space is located.</p>
 <p>The following is a list of uses for the Sling Home directory:</p>
 <ul>
-<li><em>sling.properties</em> -- The main configuration file used by Sling to
-launch the framework. It mainly contains OSGi framework configuration and
-initial configuration for some bundles. This file is read on each startup
-of <em>Launcher JAR</em>. That is, changes to this file require a restart of the
-<em>Launcher JAR</em>.</li>
-<li><em>org.apache.sling.launchpad.base.jar</em> --  This is the <em>Launcher JAR</em>
-file used by the Standalone Application or the Web Application to start the
-OSGi Framework. This file is initially placed when first starting Sling and
-may later be updated by updating the system bundle with a new <em>Launcher
-JAR</em>.</li>
-<li><em>felix</em> -- The directory into which the Apache Felix Framework places
-the bundles, which have been installed into the system. This does generally
-not need to be touched.</li>
-<li><em>config</em> -- The directory into which the Apache Felix Configuration
-Admin Service stores the configurationes. Do not change any files in this
-directory, since changes will not generally be picked up.</li>
-<li><em>jackrabbit</em> -- The directory in which the Apache Jackrabbit JCR
-repository is started. Amongst other things this also contains the
-Jackrabbit configuration file <em>repository.xml</em>. You may modify this file,
-but don't forget to restart the Embedded Jackrabbit Repository bundle after
-doing this.</li>
-<li><em>logs</em> -- Contains the log files generated by Sling. By default this
-contains the error.log and its rotated generations.</li>
+<li><code>sling.properties</code> -- The main configuration file used by Sling to launch the framework. It mainly contains OSGi framework configuration and initial configuration for some bundles. This file is read on each startup of <em>Launcher JAR</em>. That is, changes to this file require a restart of the <em>Launcher JAR</em>.</li>
+<li><code>org.apache.sling.launchpad.base.jar</code> --  This is the <em>Launcher JAR</em> file used by the Standalone Application or the Web Application to start the OSGi Framework. This file is initially placed when first starting Sling and may later be updated by updating the system bundle with a new <em>Launcher JAR</em>.</li>
+<li><code>felix</code> -- The directory into which the Apache Felix Framework places the bundles, which have been installed into the system. This does generally not need to be touched.</li>
+<li><code>config</code> -- The directory into which the Apache Felix Configuration Admin Service stores the configurationes. Do not change any files in this directory, since changes will not generally be picked up.</li>
+<li><code>jackrabbit</code> -- The directory in which the Apache Jackrabbit JCR repository is started. Amongst other things this also contains the Jackrabbit configuration file <code>repository.xml</code>. You may modify this file, but don't forget to restart the Embedded Jackrabbit Repository bundle after doing this.</li>
+<li><code>logs</code> -- Contains the log files generated by Sling. By default this contains the error.log and its rotated generations.</li>
 </ul>
-<p><a name="TheSlingLaunchpad-CommandLineOptions"></a></p>
 <h2 id="command-line-options">Command Line Options</h2>
-<p>The Java Standalone Application supports a number of command line options,
-which influence the operation of the launch process.</p>
+<p>The Java Standalone Application supports a number of command line options, which influence the operation of the launch process.</p>
 <table>
-<tr><th> Option </th><th> Argument </th><th> Description </th></tr>
-<tr><td> *start* </td><td> -- </td><td> Open a TCP/IP server socket when starting Sling. Uses
-option *-j* to define the local socket address. </td></tr>
-<tr><td> *status* </td><td> -- </td><td> Check whether a (remote) Sling application is running.
-Uses option *-j* to define the address of the Sling instance to check.
-Note, that the Sling application terminates after checking for the (remote)
-Sling status. </td></tr>
-<tr><td> *stop* </td><td> -- </td><td> Stop a (remote) Sling application is running. Uses option
-*-j* to define the address of the Sling instance to stop. Note, that the
-Sling application terminates after stopping the (remote) Sling instance. </td></tr>
-<tr><td> *-c* </td><td> slinghome </td><td> The directory in which Sling locates its initial
-configuration file *sling.properties* and where files of Sling itself
-such as the Apache Felix bundle archive or the JCR repository files are
-stored. This defaults to the *sling* folder in the current working
-directory. This is the value which is commonly refered to as
-*$\{sling.home}.*
-</tr>
-<tr><td> *-l* </td><td> loglevel </td><td> Sets the initial loglevel as an integer in the range
-0 to 4 or as one of the well known level strings *ERROR*, *WARN*,
-*INFO*, or *DEBUG*. This option overwrites the
-*org.apache.sling.osg.log.level* setting the *sling.properties* file.
-The default is *INFO*. </td></tr>
-<tr><td> *-f* </td><td> logfile </td><td>  The log file to use or *-* to log to standard out.
-This option overwrites the *org.apache.sling.osg.log.file* setting the
-*sling.properties* file. The default is
-*$\{sling.home}/logs/error.log*. </td></tr>
-<tr><td> *-a* </td><td> address </td><td> The interfact to bind to (use 0.0.0.0 for any). This
-option is not implemented yet. </td></tr>
-<tr><td> *-p* </td><td> port </td><td>  The port to listen (default 8080) to handle HTTP
-requests. This option overwrites the *org.osgi.service.http.port* setting
-the *sling.properties* file. </td></tr>
-<tr><td> *-j* </td><td> [ host ":" ](-host-":"-.html)
- port </td><td>  The socket address to listen on for control connections (*start*
-or to use as the remote endpoint for the control connection (*status* and
-*stop*. If this parameter has no arguments or is not specified, the
-address defaults to port 63000 on localhost/127.0.0.1. If only the port is
-specified localhost/127.0.0.1 is used as the host part of the address. </td></tr>
-<tr><td> *-h* </td><td> -- </td><td> Prints a simple usage message listing all available command
-line options. </td></tr>
+<thead>
+<tr>
+<th>Option</th>
+<th>Argument</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><code>start</code></td>
+<td>--</td>
+<td>Open a TCP/IP server socket when starting Sling. Uses option <code>-j</code> to define the local socket address.</td>
+</tr>
+<tr>
+<td><code>status</code></td>
+<td>--</td>
+<td>Check whether a (remote) Sling application is running. Uses option <code>-j</code> to define the address of the Sling instance to check. Note, that the Sling application terminates after checking for the (remote) Sling status.</td>
+</tr>
+<tr>
+<td><code>stop</code></td>
+<td>--</td>
+<td>Stop a (remote) Sling application is running. Uses option <code>-j</code> to define the address of the Sling instance to stop. Note, that the Sling application terminates after stopping the (remote) Sling instance.</td>
+</tr>
+<tr>
+<td><code>-j</code></td>
+<td><a href=""> host ":" </a> port</td>
+<td>The socket address to listen on for control connections (<code>start</code> or to use as the remote endpoint for the control connection (<code>status</code> and <code>stop</code>. If this parameter has no arguments or is not specified, the address defaults to any free port on localhost/127.0.0.1. If only the port is specified localhost/127.0.0.1 is used as the host part of the address.</td>
+</tr>
+<tr>
+<td><code>-c</code></td>
+<td>slinghome</td>
+<td>The directory in which Sling locates its initial configuration file <code>sling.properties</code> and where files of Sling itself such as the Apache Felix bundle archive or the JCR repository files are stored. This defaults to the <code>sling</code> folder in the current working directory. This is the value which is commonly refered to as <code>$\{sling.home}.</code></td>
+</tr>
+<tr>
+<td><code>-i</code></td>
+<td>launchpadhome</td>
+<td>The launchpad directory. If not set, this is the same as <code>$\{sling.home}.</code> (since Sling Launchpad 2.4.0)</td>
+</tr>
+<tr>
+<td><code>-l</code></td>
+<td>loglevel</td>
+<td>Sets the initial loglevel as an integer in the range 0 to 4 or as one of the well known level strings <code>ERROR</code>, <code>WARN</code>, <code>INFO</code>, or <code>DEBUG</code>. This option overwrites the <code>org.apache.sling.osg.log.level</code> setting the <code>sling.properties</code> file. The default is <code>INFO</code>.</td>
+</tr>
+<tr>
+<td><code>-f</code></td>
+<td>logfile</td>
+<td>The log file to use or <code>-</code> to log to standard out. This option overwrites the <code>org.apache.sling.osg.log.file</code> setting in the <code>sling.properties</code> file. The default is <code>$\{sling.home}/logs/error.log</code>.</td>
+</tr>
+<tr>
+<td><code>-a</code></td>
+<td>address</td>
+<td>The interfact to bind to (use 0.0.0.0 for any). This option overwrites the <code>org.apache.felix.http.host</code> setting in the <code>sling.properties</code> file and requires the embedded Http Service implementation to honor this property. (supported since Sling Launchpad 2.4.0)</td>
+</tr>
+<tr>
+<td><code>-p</code></td>
+<td>port</td>
+<td>The port to listen (default 8080) to handle HTTP requests. This option overwrites the <code>org.osgi.service.http.port</code> setting in the <code>sling.properties</code> file.</td>
+</tr>
+<tr>
+<td><code>-r</code></td>
+<td>path</td>
+<td>The root servlet context path for the Http Service (default is /). This option overwrites the <code>org.apache.felix.http.context_path</code> setting in the <code>sling.properties</code> file and requires the embedded Http Service implementation to honor this property. (since Sling Launchpad 2.4.0)</td>
+</tr>
+<tr>
+<td><code>-D</code></td>
+<td>n=v</td>
+<td>Sets the property <code>n</code> to the value <code>v</code>. This option can be added repeatedly setting additional properties. Any property set in this manner overwrites same named properties in the <code>sling.properties</code> file. (since Sling Launchpad 2.4.0)</td>
+</tr>
+<tr>
+<td><code>-h</code></td>
+<td>--</td>
+<td>Prints a simple usage message listing all available command line options.</td>
+</tr>
+</tbody>
 </table>
-
-<p>The Sling Standalone application looks for a definition of the
-<em>sling.home</em> setting in the following locations in order of precendence:</p>
+<p>The Sling Standalone application looks for a definition of the <code>sling.home</code> setting in the following locations in order of precendence:</p>
 <ol>
-<li>The <em>-c</em> command line option</li>
-<li>The <em>sling.home</em> system property</li>
-<li>The <em>SLING_HOME</em> environment variable</li>
-<li>If none of the above resolves to a non-null value, the default value of
-<em>sling</em> is assumed</li>
+<li>The <code>-c</code> command line option</li>
+<li>The <code>sling.home</code> system property</li>
+<li>The <code>SLING_HOME</code> environment variable</li>
+<li>If none of the above resolves to a non-null value, the default value of <code>sling</code> is assumed</li>
 </ol>
-<p><a name="TheSlingLaunchpad-SecurityImplication"></a></p>
-<h3 id="security-implication">Security Implication</h3>
-<p>Note that using a control connection for the Sling Standalone Application
-presents a potential security issue. For this reason the following defaults
-apply:</p>
+<h3 id="control-port">Control Port</h3>
+<p>When starting the Sling Standalone Application with the <code>start</code> command line option, a TCP port is opened. The interface and port is configurable with the <code>-j</code> command line option. The address of the interface and the actual port used are written to the <code>$\{sling.home}/conf/controlport</code> file. So technically the <code>-j</code> option is not required for the <code>status</code> and <code>stop</code> operations because the port information is just read from this file.</p>
+<p>Note that using a control connection for the Sling Standalone Application presents a potential security issue. For this reason the following defaults apply:</p>
 <ul>
-<li>The server side socket for a running Sling Standalone Application is only
-created if the application is started with the <em>start</em> command line
-option. If this option is omitted -- the default -- the server side socket
-is not created and the Sling Standalone Application instance cannot be
-remotely controlled.</li>
-<li>The default host name for the socket is localhost/127.0.0.1 meaning that
-the socket is only accessible from the same system as the Sling Standalone
-Application is running on. If the socket is accessible from remote systems
-additional must be taken to prevent malicious attackers to stop the system.
-The server side control connection implementation implements no security
-precaution (except from supporting to not create such a connection at all).</li>
+<li>The server side socket for a running Sling Standalone Application is only created if the application is started with the <code>start</code> command line option. If this option is omitted -- the default -- the server side socket is not created and the Sling Standalone Application instance cannot be remotely controlled.</li>
+<li>The default host name for the socket is localhost/127.0.0.1 meaning that the socket is only accessible from the same system as the Sling Standalone Application is running on.</li>
+<li>In addition to the IP address and port on which the control port is listening a nonce is written to the <code>controlport</code> file. Any interaction with the server on the control port must include this none.</li>
 </ul>
-<p><a name="TheSlingLaunchpad-ServletParameters"></a></p>
+<p>Suggestions:
+<em> Do not allow the control port to be opened on an externally visible interface. Using the localhost/127.0.0.1 is just sufficient.
+</em> Make sure only legitimate users have access to the installation folder of Sling (<code>$\{sling.home})</code>.</p>
 <h2 id="servlet-parameters">Servlet Parameters</h2>
-<p>The Web Application does not require specific servlet parameters. Those
-which are specified are used to overwrite any properties with the same name
-from the <em>sling.properties</em> file. One exception to this rule is the
-<em>sling.home</em> parameter, which is used to set the value of the
-<em>sling.home</em> property. If no parameter with this name is defined the
-Sling home directory is derived from the context path at which the Sling
-Web Application is registered.</p>
-<p>The <em>sling.home</em> folders for Sling Web Applications without the
-<em>sling.home</em> servlet parameter are all located in the <em>sling</em> folder in
-the current working directory as reported by the <em>user.dir</em> system
-property. The name of the actual directory is derived from the Web
-Application Context Path by replacing all slash characters <em>/</em> by
-underscore characters <em>_</em>. For the root context a single underscore
-character <em>_</em> is used.</p>
+<p>The Web Application does not require specific servlet parameters. Those which are specified are used to overwrite any properties with the same name from the <code>sling.properties</code> file. One exception to this rule is the <code>sling.home</code> parameter, which is used to set the value of the <code>sling.home</code> property. If no parameter with this name is defined the Sling home directory is derived from the context path at which the Sling Web Application is registered.</p>
+<p>The <code>sling.home</code> folders for Sling Web Applications without the <code>sling.home</code> servlet parameter are all located in the <code>sling</code> folder in the current working directory as reported by the <code>user.dir</code> system property. The name of the actual directory is derived from the Web Application Context Path by replacing all slash characters <code>/</code> by underscore characters <code>\*</code>. For the root context a single underscore character <code>\*</code> is used.</p>
 <p>Examples:</p>
 <table>
-<tr><th> Servlet Context </th><th> Default *sling.home* </th></tr>
-<tr><td> _root_ </td><td> *sling/\_* </td></tr>
-<tr><td> */sling* </td><td> *sling/\_sling* </td></tr>
-<tr><td> */sling/instance1* </td><td> *sling/\_sling\_instance1* </td></tr>
+<thead>
+<tr>
+<th>Servlet Context</th>
+<th>Default <code>sling.home</code></th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><em>root</em></td>
+<td><code>sling/\_</code></td>
+</tr>
+<tr>
+<td><code>/sling</code></td>
+<td><code>sling/\_sling</code></td>
+</tr>
+<tr>
+<td><code>/sling/instance1</code></td>
+<td><code>sling/\*sling\*instance1</code></td>
+</tr>
+</tbody>
 </table>
-
-<p>Starting with Launchpad Base 2.2.2 the fixed prefix <em>sling</em> is
-configurable with the <em>sling.home.prefix</em> system property. If this
-property is set the value used as the prefix.</p>
-<p>Examples: Assume the <em>sling.home.prefix</em> system property is set to
-<em>/var/sling</em></p>
+<p>Starting with Launchpad Base 2.2.2 the fixed prefix <code>sling</code> is configurable with the <code>sling.home.prefix</code> system property. If this property is set the value used as the prefix.</p>
+<p>Examples: Assume the <code>sling.home.prefix</code> system property is set to <code>/var/sling</code></p>
 <table>
-<tr><th> Servlet Context </th><th> Default *sling.home* </th></tr>
-<tr><td> _root_ </td><td> */var/sling/\_* </td></tr>
-<tr><td> */sling* </td><td> */var/sling/\_sling* </td></tr>
-<tr><td> */sling/instance1* </td><td> */var/sling/\_sling\_instance1* </td></tr>
+<thead>
+<tr>
+<th>Servlet Context</th>
+<th>Default <code>sling.home</code></th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><em>root</em></td>
+<td><code>/var/sling/\_</code></td>
+</tr>
+<tr>
+<td><code>/sling</code></td>
+<td><code>/var/sling/\_sling</code></td>
+</tr>
+<tr>
+<td><code>/sling/instance1</code></td>
+<td><code>/var/sling/\*sling\*instance1</code></td>
+</tr>
+</tbody>
 </table>
-
-<p><a name="TheSlingLaunchpad-sling.properties"></a></p>
 <h2 id="slingproperties">sling.properties</h2>
-<p>The <em>sling.properties</em> file contains the initial setup of the Sling
-Application and the OSGi framework. Some of the parameters are required and
-should not be modified without a very good reason. Some parameters may be
-freely modified to your needs. Please see the inlined comment in the
-<em>sling.properties</em> file installed when Sling is first started.</p>
-<p>One thing to note is, that the <em>sling.properties</em> file is a simple Java
-Properties file with support for property references. That is, the value of
-properties may refer other property values by means of the well known
-<em>${name</em>} notation. Such property references may even be cascaded as in</p>
+<p>The <code>sling.properties</code> file contains the initial setup of the Sling Application and the OSGi framework. Some of the parameters are required and should not be modified without a very good reason. Some parameters may be freely modified to your needs. Please see the inlined comment in the <code>sling.properties</code> file installed when Sling is first started.</p>
+<p>One thing to note is, that the <code>sling.properties</code> file is a simple Java Properties file with support for property references. That is, the value of properties may refer other property values by means of the well known <code>$\{name</code>} notation. Such property references may even be cascaded as in</p>
 <div class="codehilite"><pre>java.packages=<span class="cp">${</span><span class="n">jre</span><span class="o">-</span><span class="err">$</span><span class="p">{</span><span class="n">java</span><span class="o">.</span><span class="n">specification</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span>}
 </pre></div>
 
 
-<p><a name="TheSlingLaunchpad-Components"></a></p>
 <h2 id="components">Components</h2>
-<p>The Sling Launchapd consists of <em>Launchbad Base</em> project and three
-additional projects which ultimately create a Standalone Java Application
-and a Web Appliction with standard parts of Sling.</p>
-<p><a name="TheSlingLaunchpad-LaunchpadBase"></a></p>
+<p>The Sling Launchapd consists of <em>Launchbad Base</em> project and three additional projects which ultimately create a Standalone Java Application and a Web Appliction with standard parts of Sling.</p>
 <h3 id="launchpad-base">Launchpad Base</h3>
-<p>The <em>Launchpad Base</em> projects creates the following artifacts, which are
-required in actual setups to get a Sling application:</p>
+<p>The <em>Launchpad Base</em> projects creates the following artifacts, which are required in actual setups to get a Sling application:</p>
 <ul>
 <li>
-<p><em>Launcher JAR</em> -- The primary artifact of the Base project contains the
-actual support to launch the Apache Felix OSGi Framework and install
-bundles, which are packaged with the application. It also contains the
-Apache Felix Framework together with the OSGi R4.1 Core and Compendium
-libraries as well as the Equinox HttpService bridge and the Servlet API.</p>
+<p><em>Launcher JAR</em> -- The primary artifact of the Base project contains the actual support to launch the Apache Felix OSGi Framework and install bundles, which are packaged with the application. It also contains the Apache Felix Framework together with the OSGi R4.1 Core and Compendium libraries as well as the Equinox HttpService bridge and the Servlet API.</p>
 </li>
 <li>
-<p><em>App JAR</em> -- The secondary artifact with classifier <em>app</em> is a minimal
-Standalone Java Application which may be started by simply typing</p>
+<p><em>App JAR</em> -- The secondary artifact with classifier <em>app</em> is a minimal Standalone Java Application which may be started by simply typing</p>
 <p>$ java -jar org.apache.sling.launchpad.base-app.jar</p>
 </li>
 <li>
-<p><em>Web App Archive</em> -- The secondary artifact with classifier <em>webapp</em> is a
-minimal Web Application, which may simply be deployed into your favirourite
-servlet container, provided it supports at least Servlet API 2.4.</p>
+<p><em>Web App Archive</em> -- The secondary artifact with classifier <em>webapp</em> is a minimal Web Application, which may simply be deployed into your favirourite servlet container, provided it supports at least Servlet API 2.4.</p>
 </li>
 <li>
-<p><em>Source JAR</em> -- The secondary artifact with the classifier <em>sources</em> is
-simple the source of the <em>Launchpad Base</em> project.</p>
+<p><em>Source JAR</em> -- The secondary artifact with the classifier <em>sources</em> is simple the source of the <em>Launchpad Base</em> project.</p>
 </li>
 </ul>
-<p>To build a very basic Sling launcher, the <em>Launchpad Base</em> is actually all
-you need. But to really glue this together and get a usable system, some
-more work is required. Lets see how the additionaly projects <em>Launchpad
-Bundles</em>, <em>Launchpad App</em>, and <em>Launchpad WebApp</em> get to that.</p>
-<p><a name="TheSlingLaunchpad-LaunchpadBundles"></a></p>
+<p>To build a very basic Sling launcher, the <em>Launchpad Base</em> is actually all you need. But to really glue this together and get a usable system, some more work is required. Lets see how the additionaly projects <em>Launchpad Bundles</em>, <em>Launchpad App</em>, and <em>Launchpad WebApp</em> get to that.</p>
 <h3 id="launchpad-bundles">Launchpad Bundles</h3>
-<p>The second project we want to look at is the <em>Launchpad Bundles</em> project.
-This is a very simple project in that it only collects together a number of
-OSGi bundles, which will make up the final application. The bundles are
-stored in a (big) Java Archive in folders whose path is formed with
-<em>resources/9</em> where <em>9</em> is a start level which is assigned to the
-bundles as they are installed. The special start level <em>0</em> instructs the
-installer to not actually assign a specific start level to the bundles
-contained in that folder.</p>
-<p>Currently the following start level assignement is used by the <em>Launchpad
-Bundles</em> project:</p>
+<p>The second project we want to look at is the <em>Launchpad Bundles</em> project. This is a very simple project in that it only collects together a number of OSGi bundles, which will make up the final application. The bundles are stored in a (big) Java Archive in folders whose path is formed with <code>resources/9</code> where <code>9</code> is a start level which is assigned to the bundles as they are installed. The special start level <code>0</code> instructs the installer to not actually assign a specific start level to the bundles contained in that folder.</p>
+<p>Currently the following start level assignement is used by the <em>Launchpad Bundles</em> project:</p>
 <table>
-<tr><th> Start Level </th><th> Bundle Group </th><th> Bundle(s) </th></tr>
-<tr><td> 1 </td><td> Basic bundles required for the correct operation of Sling </td><td>
-org.apache.sling.commons.log
-</tr>
-<tr><td> 5 </td><td> Apache Felix Web Console </td><td> org.apache.felix.bundlerepository,
-org.apache.felix.webconsole, org.apache.sling.extensions.threaddump </td></tr>
-<tr><td> 10 </td><td> OSGi Compendium Service Implementations </td><td>
-org.apache.felix.configadmin, org.apache.felix.eventadmin,
-org.apache.felix.metatype, org.apache.felix.scr </td></tr>
-<tr><td> 15 </td><td> JCR Repository (Jackrabbit) </td><td> commons-collections,
-commons-io-1.4.jar
-</tr>
-commons-lang, jackrabbit-api, jackrabbit-jcr-commons,
-org.apache.sling.commons.mime, org.apache.sling.commons.osgi,
-org.apache.sling.jcr.api, org.apache.sling.jcr.base,
-org.apache.sling.jcr.jackrabbit.server, org.apache.sling.jcr.webdav |
-<tr><td> 0 </td><td> Actual Sling Application bundles </td><td> org.apache.sling.adapter,
-org.apache.sling.api, org.apache.sling.bundleresource.impl,
-org.apache.sling.commons.json, org.apache.sling.engine,
-org.apache.sling.extensions.apt.parser,
-org.apache.sling.extensions.apt.servlet, org.apache.sling.httpauth,
-org.apache.sling.jcr.classloader, org.apache.sling.jcr.contentloader,
-org.apache.sling.jcr.ocm, org.apache.sling.jcr.resource,
-org.apache.sling.launchpad.content,
-org.apache.sling.samples.path-based.rtp, org.apache.sling.scripting.api,
-org.apache.sling.scripting.core, org.apache.sling.scripting.javascript,
-org.apache.sling.scripting.jsp, org.apache.sling.scripting.jsp.taglib,
-org.apache.sling.servlets.get, org.apache.sling.servlets.post,
-org.apache.sling.servlets.resolver </td></tr>
+<thead>
+<tr>
+<th>Start Level</th>
+<th>Bundle Group</th>
+<th>Bundle(s)</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>1</td>
+<td>Basic bundles required for the correct operation of Sling</td>
+<td>org.apache.sling.commons.log</td>
+</tr>
+<tr>
+<td>5</td>
+<td>Apache Felix Web Console</td>
+<td>org.apache.felix.bundlerepository, org.apache.felix.webconsole, org.apache.sling.extensions.threaddump</td>
+</tr>
+<tr>
+<td>10</td>
+<td>OSGi Compendium Service Implementations</td>
+<td>org.apache.felix.configadmin, org.apache.felix.eventadmin, org.apache.felix.metatype, org.apache.felix.scr</td>
+</tr>
+<tr>
+<td>15</td>
+<td>JCR Repository (Jackrabbit)</td>
+<td>commons-collections, commons-io-1.4.jar</td>
+</tr>
+<tr>
+<td>commons-lang, jackrabbit-api, jackrabbit-jcr-commons, org.apache.sling.commons.mime, org.apache.sling.commons.osgi, org.apache.sling.jcr.api, org.apache.sling.jcr.base, org.apache.sling.jcr.jackrabbit.server, org.apache.sling.jcr.webdav</td>
+<td></td>
+<td></td>
+</tr>
+<tr>
+<td>0</td>
+<td>Actual Sling Application bundles</td>
+<td>org.apache.sling.adapter, org.apache.sling.api, org.apache.sling.bundleresource.impl, org.apache.sling.commons.json, org.apache.sling.engine, org.apache.sling.extensions.apt.parser, org.apache.sling.extensions.apt.servlet, org.apache.sling.httpauth, org.apache.sling.jcr.classloader, org.apache.sling.jcr.contentloader, org.apache.sling.jcr.ocm, org.apache.sling.jcr.resource, org.apache.sling.launchpad.content, org.apache.sling.samples.path-based.rtp, org.apache.sling.scripting.api, org.apache.sling.scripting.core, org.apache.sling.scripting.javascript, org.apache.sling.scripting.jsp, org.apache.sling.scripting.jsp.taglib, org.apache.sling.servlets.get, org.apache.sling.servlets.post, org.apache.sling.servlets.resolver</td>
+</tr>
+</tbody>
 </table>
-
-<p><a name="TheSlingLaunchpad-LaunchpadAppandLaunchpadWebApp"></a></p>
 <h3 id="launchpad-app-and-launchpad-webapp">Launchpad App and Launchpad WebApp</h3>
-<p>The <em>Launchpad App</em> and <em>Launchpad WebApp</em> bundles are actually projects
-which just glue together artifacts from the Launchpad projects. There is
-nothing special about them. Here's what is done:</p>
+<p>The <em>Launchpad App</em> and <em>Launchpad WebApp</em> bundles are actually projects which just glue together artifacts from the Launchpad projects. There is nothing special about them. Here's what is done:</p>
 <ul>
-<li>Take the appropriate secondary artifact from the <em>Launchpad Base</em>
-project: <em>app</em> for the Standalone Java Application or <em>webapp</em> for the Web
-Application and unpack</li>
-<li>Take the <em>Launchpad Base</em> primary artifact and place it under the name
-<em>org.apache.sling.launchpad.base.jar</em> into the <em>resources</em> folder</li>
+<li>Take the appropriate secondary artifact from the <em>Launchpad Base</em> project: <em>app</em> for the Standalone Java Application or <em>webapp</em> for the Web Application and unpack</li>
+<li>Take the <em>Launchpad Base</em> primary artifact and place it under the name <code>org.apache.sling.launchpad.base.jar</code> into the <code>resources</code> folder</li>
 <li>Take the <em>Launchpad Bundles</em> artifact and unpack it</li>
 <li>Finally pack all together into a single big JAR or WAR file</li>
 </ul>
-<p>That's it. The resulting artifact may be directly used to launch the
-Standalone Java Application or may directly be deployed into any Servlet
-API 2.4 (or later) compliant servlet container.</p>
+<p>That's it. The resulting artifact may be directly used to launch the Standalone Java Application or may directly be deployed into any Servlet API 2.4 (or later) compliant servlet container.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1328899 by fmeschbe on Sun, 22 Apr 2012 16:52:13 +0000
+        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Added: websites/staging/sling/trunk/content/tutorials-how-tos.html
==============================================================================
--- websites/staging/sling/trunk/content/tutorials-how-tos.html (added)
+++ websites/staging/sling/trunk/content/tutorials-how-tos.html Tue May 22 08:25:32 2012
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Tutorials &amp; How-Tos</title>
+    <link rel="stylesheet" href="/css/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <p><strong>Documentation</strong> <br />
+<a href="/getting-started.html">Getting Started</a> <br />
+<a href="/the-sling-engine.html">The Sling Engine</a> <br />
+<a href="/development.html">Development</a> <br />
+<a href="/bundles.html">Bundles</a> <br />
+<a href="/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/configuration.html">Configuration</a> <br />
+<a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a> <br />
+<a href="/sitemap.html">Site Map</a></p>
+<p><strong>API Docs</strong>  <br />
+<a href="http://sling.apache.org/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="http://sling.apache.org/apidocs/sling5/index.html">Sling 5</a> <br />
+</p>
+<p><strong>Project info</strong> <br />
+<a href="http://sling.apache.org/site/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a> <br />
+<a href="/security.html">Security</a> <br />
+</p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a> <br />
+</p>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>
+      </div>
+      <h1>Tutorials &amp; How-Tos</h1>
+      <ul>
+<li><a href="/tutorials-how-tos/46-line-blog.html">46 Line Blog</a></li>
+<li><a href="/tutorials-how-tos/getting-resources-and-properties-in-sling.html">Getting Resources and Properties in Sling</a></li>
+<li><a href="/tutorials-how-tos/how-to-manage-events-in-sling.html">How to Manage Events in Sling</a></li>
+<li><a href="/tutorials-how-tos/installing-and-upgrading-bundles.html">Installing and Upgrading Bundles</a></li>
+<li><a href="/tutorials-how-tos/jackrabbit-persistence.html">Jackrabbit Persistence</a></li>
+<li><a href="/tutorials-how-tos/testing-sling-based-applications.html">Testing Sling-based applications</a></li>
+</ul>
+      <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/tutorials-how-tos/46-line-blog.html
==============================================================================
--- websites/staging/sling/trunk/content/tutorials-how-tos/46-line-blog.html (added)
+++ websites/staging/sling/trunk/content/tutorials-how-tos/46-line-blog.html Tue May 22 08:25:32 2012
@@ -0,0 +1,220 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - 46 Line Blog</title>
+    <link rel="stylesheet" href="/css/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <p><strong>Documentation</strong> <br />
+<a href="/getting-started.html">Getting Started</a> <br />
+<a href="/the-sling-engine.html">The Sling Engine</a> <br />
+<a href="/development.html">Development</a> <br />
+<a href="/bundles.html">Bundles</a> <br />
+<a href="/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/configuration.html">Configuration</a> <br />
+<a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a> <br />
+<a href="/sitemap.html">Site Map</a></p>
+<p><strong>API Docs</strong>  <br />
+<a href="http://sling.apache.org/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="http://sling.apache.org/apidocs/sling5/index.html">Sling 5</a> <br />
+</p>
+<p><strong>Project info</strong> <br />
+<a href="http://sling.apache.org/site/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a> <br />
+<a href="/security.html">Security</a> <br />
+</p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a> <br />
+</p>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/tutorials-how-tos.html">Tutorials & How-Tos</a>
+      </div>
+      <h1>46 Line Blog</h1>
+      <p>This tutorial is based on the first <em>Sling Gems</em> on dev.day.com: The <a href="">Sling gems: a blog in 46 lines of code</a>. It has slightly been adapted to fit here.</p>
+<p>In this tutorial, the SlingPostServlet and the sling.js library are brought together using 46 (no kidding: <em>fourty-six</em>) lines of code to create a simple blog (or let's say <em>bloggish</em>) application.</p>
+<p>I used this example in my <a href="">http://us.apachecon.com/c/acus2009/sessions/284</a> presentation at ApacheCon US 09 in Oakland (slides will be available soon), and I think it's a good testimony to the power and simplicity of Sling.</p>
+<h2 id="audience">Audience</h2>
+<p>Although this is a simple sample, it requires some custom settings to work. If you're just starting with Sling, <a href="">SLINGxSITE:Discover Sling in 15 minutes</a> might be a better choice.</p>
+<h2 id="step-0-start-configure-and-login-to-sling">Step 0: Start, configure and login to Sling</h2>
+<p>See <a href="">SLINGxSITE:Getting and Building Sling</a> for how to start Sling. Start it on port 8888 for the below links to work.</p>
+<p>For this sample we need the optional <em>org.apache.sling.samples.path-based.rtp</em> bundle, if it's not present in the <a href="">OSGi console</a>, install and start it. That bundle is not released yet so you might need to build it yourself, from its [source|http://svn.apache.org/repos/asf/sling/trunk/samples/path-based-rtp]. The bundle must then appear in the [OSGI console's list of bundles|http://localhost:8888/system/console/bundles], with name = <em>org.apache.sling.samples.path-based.rtp</em> and status = <em>Active</em>.</p>
+<p>Then, login using http://localhost:8888/?sling:authRequestLogin=1 which should prompt you for a username and password, use <em>admin</em> and <em>admin</em>. Once that's done, http://localhost:8888/index.html should say <em>You are currently logged in as user </em>admin<em> to workspace </em>default**.</p>
+<h2 id="step-1-creating-content">Step 1: Creating content</h2>
+<p>The easiest way to create content in Sling is to use an HTTP POST request, let's use a simple HTML form:</p>
+<p>{code:html}
+<html>
+  <body>
+    <h1>Sling microblog</h1></p>
+<div class="codehilite"><pre><span class="nt">&lt;div&gt;</span>
+  <span class="nt">&lt;form</span> <span class="na">method=</span><span class="s">&quot;POST&quot;</span><span class="nt">&gt;</span>
+    Title:<span class="nt">&lt;br/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">name=</span><span class="s">&quot;title&quot;</span> <span class="na">style=</span><span class="s">&quot;width:100%&quot;</span><span class="nt">/&gt;</span>
+
+    <span class="nt">&lt;br/&gt;</span>Text:<span class="nt">&lt;br/&gt;</span>
+    <span class="nt">&lt;textarea</span> <span class="na">style=</span><span class="s">&quot;width:100%&quot;</span> <span class="na">name=</span><span class="s">&quot;text&quot;</span><span class="nt">&gt;&lt;/textarea&gt;</span>
+
+    <span class="nt">&lt;br/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;submit&quot;</span> <span class="na">value=</span><span class="s">&quot;save&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;hidden&quot;</span> <span class="na">name=</span><span class="s">&quot;:redirect&quot;</span> <span class="na">value=</span><span class="s">&quot;*.html&quot;</span><span class="nt">/&gt;</span>
+  <span class="nt">&lt;/form&gt;</span>
+<span class="nt">&lt;/div&gt;</span>
+
+<span class="c">&lt;!-- code of step 2 comes here --&gt;</span>
+</pre></div>
+
+
+<p></body>
+</html></p>
+<div class="codehilite"><pre><span class="n">That</span><span class="s">&#39;s two input fields, a submit button and a hidden field that tells Sling what to do after the POST (in this case: redirect to the html view of the node that was just created).</span>
+
+<span class="s">To test the form, start Sling and save the above script as  {footnote}ESP is Sling&#39;</span><span class="n">s</span> <span class="n">server</span><span class="o">-</span><span class="n">side</span> <span class="n">javascript</span> <span class="n">language</span><span class="p">{</span><span class="n">footnote</span><span class="p">}</span> <span class="n">in</span> <span class="n">the</span> <span class="n">Sling</span> <span class="n">repository</span> <span class="o">-</span> <span class="n">a</span> <span class="n">WebDAV</span> <span class="n">mount</span> <span class="n">is</span> <span class="n">the</span> <span class="n">easiest</span> <span class="n">way</span> <span class="n">to</span> <span class="k">do</span> <span class="n">that</span><span class="o">.</span> <span class="n">Browsing</span> <span class="n">to</span>  <span class="p">{</span><span class="n">footnote</span><span class="p">}</span> <span class="n">This</span> <span class="n">assum
 es</span> <span class="n">your</span> <span class="n">instance</span> <span class="n">of</span> <span class="n">Sling</span> <span class="n">is</span> <span class="n">running</span> <span class="n">on</span> <span class="n">port</span> <span class="mi">8888</span><span class="o">.</span> <span class="n">If</span> <span class="n">that</span><span class="s">&#39;s not the case, adjust the example URLs accordingly. {footnote} should display the above form.</span>
+
+<span class="s">Input some data (using &quot;foo&quot; for the title, for the sake of our examples below), save the form, and Sling</span>
+<span class="s">should display the form again, using the URL of the node that was just created.</span>
+
+<span class="s">{note:title=AccessDeniedException?}</span>
+<span class="s">If you get an error saying _javax.jcr.AccessDeniedException: ...not allowed to add or modify item_ it means that you are not logged in as user _admin_. See instructions above for logging in.</span>
+<span class="s">{note}</span>
+
+<span class="s">At this point you&#39;</span><span class="n">re</span> <span class="n">probably</span> <span class="n">looking</span> <span class="n">at</span> <span class="n">an</span> <span class="n">empty</span> <span class="n">form</span> <span class="n">with</span> <span class="n">an</span> <span class="n">URL</span> <span class="n">ending</span> <span class="n">in</span> <span class="n">_foo_</span><span class="p">,</span> <span class="k">if</span> <span class="n">you</span> <span class="n">used</span> <span class="n">that</span> <span class="k">for</span> <span class="n">the</span> <span class="n">title</span><span class="o">.</span> <span class="n">Or</span> <span class="n">_foo_0_</span> <span class="ow">or</span> <span class="n">_foo_1_</span> <span class="k">if</span> <span class="n">other</span> <span class="n">_foo_s</span> <span class="n">already</span> <span class="n">existed</span><span class="o">.</span> <span class="n">Don</span><span class="s">&#39;t worry
  about not seeing your content, we&#39;</span><span class="n">ll</span> <span class="n">fix</span> <span class="n">that</span> <span class="n">right</span> <span class="n">away</span><span class="o">.</span>
+
+<span class="n">h2</span><span class="o">.</span> <span class="n">Step</span> <span class="mi">2</span><span class="p">:</span> <span class="n">Where</span><span class="s">&#39;s my content?</span>
+
+<span class="s">To verify that our content has been created, we can have a look at the JSON data at , which should display our new node&#39;</span><span class="n">s</span> <span class="nb">values</span><span class="p">:</span>
+
+<span class="p">{</span><span class="n">code:javascript</span><span class="p">}</span>
+<span class="p">{</span>
+  <span class="s">&quot;jcr:primaryType&quot;</span><span class="p">:</span> <span class="s">&quot;nt:unstructured&quot;</span><span class="p">,</span>
+  <span class="s">&quot;text&quot;</span><span class="p">:</span> <span class="s">&quot;This is the foo text&quot;</span><span class="p">,</span>
+  <span class="s">&quot;title&quot;</span><span class="p">:</span> <span class="s">&quot;foo&quot;</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>That's reassuring, but what we really want is for these values to be displayed on the editing form for our post.</p>
+<p>Thanks to the <em>sling.js</em> client library, we just need to add a <code>Sling.wizard()</code> call to our form to display those values. Let's first add a <code>&lt;head&gt;</code> element to our form to load the <em>sling.js</em> library, before the existing <code>&lt;body&gt;</code> of course:</p>
+<p>{code:html}
+<head>
+  <script src="/system/sling.js"></script>
+</head></p>
+<div class="codehilite"><pre>And add the  after the form, where we had the _code of step 2 comes here_ comment:
+
+{code:html}
+<span class="c">&lt;!-- code of step 2 comes here --&gt;</span>
+<span class="nt">&lt;script&gt;</span>Sling.wizard();<span class="nt">&lt;/script&gt;</span>
+</pre></div>
+
+
+<p>Reloading the form at <code>http://localhost:8888/content/blog/*.html</code> and creating a new post should now redirect to an editable version of the post, with the form fields correctly initialized.</p>
+<p>We can now create and edit posts; let's add some navigation, using more of the <em>sling.js</em> functionality. </p>
+<h2 id="step-3-navigation">Step 3: Navigation</h2>
+<p>The <em>sling.js</em> library provides utilities to access and manipulate content. For our blog, we'll use the <code>getContent(path)</code> method to list the siblings of the current node.</p>
+<p>Add the following code to your script, after the <code>Sling.wizard()</code> call that was added in step 2:</p>
+<p>{code:html}
+<h3>Navigation</h3>
+<ul>
+    <li><em><a href="/content/blog/*.html"><a href="">Create new post</a></a></em></li>
+    <script>
+      var posts = Sling.getContent("/content/blog", 2);
+      for(var i in posts) {
+        document.write("<li>"
+          + "<a href='/content/blog/" + i + ".html'>"  <br />
+          + posts<a href="">i</a>.title
+          + "</a></li>");
+      }
+    </script>
+</ul></p>
+<div class="codehilite"><pre><span class="n">The</span> <span class="n">first</span> <span class="nb">link</span> <span class="n">to</span>  <span class="n">brings</span> <span class="n">us</span> <span class="n">back</span> <span class="n">to</span> <span class="k">our</span> <span class="n">content</span> <span class="n">creating</span> <span class="n">form</span><span class="p">,</span> <span class="n">which</span> <span class="n">is</span> <span class="n">nothing</span> <span class="k">else</span> <span class="n">than</span> <span class="n">the</span> <span class="n">editing</span> <span class="n">form</span> <span class="n">reading</span> <span class="n">empty</span> <span class="nb">values</span> <span class="ow">and</span> <span class="n">posting</span> <span class="n">to</span> <span class="n">the</span> <span class="s">&quot;magic star&quot;</span> <span class="n">URL</span><span class="o">.</span>
+
+<span class="n">The</span> <span class="n">rest</span> <span class="n">of</span> <span class="n">the</span> <span class="n">javascript</span> <span class="n">runs</span> <span class="n">client</span><span class="o">-</span><span class="n">side</span><span class="p">,</span> <span class="n">as</span> <span class="n">it</span> <span class="n">is</span> <span class="ow">not</span> <span class="n">embedded</span> <span class="n">in</span>  <span class="n">code</span> <span class="n">markers</span><span class="p">,</span> <span class="n">calls</span> <span class="n">the</span>  <span class="n">method</span> <span class="n">to</span> <span class="n">get</span> <span class="n">two</span> <span class="n">levels</span> <span class="n">of</span> <span class="n">node</span> <span class="n">data</span> <span class="n">below</span> <span class="p">,</span> <span class="ow">and</span> <span class="n">displays</span> <span class="n">links</span> <span class="n">to</span> <span class="n">no
 des</span> <span class="n">that</span> <span class="n">it</span> <span class="n">finds</span><span class="o">.</span>
+
+<span class="n">That</span><span class="s">&#39;s a basic navigation, of course, in a real blog we&#39;</span><span class="n">d</span> <span class="n">need</span> <span class="n">some</span> <span class="n">paging</span> <span class="ow">and</span> <span class="n">contextualization</span> <span class="n">to</span> <span class="n">cope</span> <span class="n">with</span> <span class="n">large</span> <span class="n">numbers</span> <span class="n">of</span> <span class="n">posts</span><span class="o">.</span>
+
+<span class="n">Nevertheless</span><span class="p">,</span> <span class="n">with</span> <span class="n">this</span> <span class="n">addition</span> <span class="k">our</span> <span class="n">ESP</span> <span class="n">script</span> <span class="n">allows</span> <span class="n">us</span> <span class="n">to</span> <span class="n">create</span><span class="p">,</span> <span class="n">edit</span> <span class="ow">and</span> <span class="n">navigate</span> <span class="n">blog</span> <span class="n">posts</span> <span class="o">-</span> <span class="ow">not</span> <span class="n">bad</span> <span class="k">for</span> <span class="mi">46</span> <span class="n">lines</span> <span class="n">of</span> <span class="n">code</span><span class="p">,</span> <span class="n">including</span> <span class="n">comments</span><span class="p">,</span> <span class="n">whitespace</span> <span class="ow">and</span> <span class="n">output</span> <span class="n">formatting</span><span class="o">.</sp
 an>
+
+<span class="n">h2</span><span class="o">.</span> <span class="n">Step</span> <span class="mi">4</span><span class="p">:</span> <span class="n">Data</span> <span class="n">first</span><span class="p">,</span> <span class="n">structure</span> <span class="n">later</span>
+
+<span class="n">You</span> <span class="n">might</span> <span class="n">have</span> <span class="n">heard</span> <span class="n">this</span> <span class="n">mantra</span><span class="p">,</span> <span class="n">which</span> <span class="n">we</span> <span class="n">apply</span> <span class="n">in</span> <span class="n">many</span> <span class="n">areas</span> <span class="n">of</span> <span class="n">Sling</span><span class="o">.</span>
+
+<span class="n">In</span> <span class="n">this</span> <span class="k">case</span><span class="p">,</span> <span class="n">adding</span> <span class="n">a</span> <span class="k">new</span> <span class="n">field</span> <span class="n">to</span> <span class="k">our</span> <span class="n">blog</span> <span class="n">posts</span> <span class="n">could</span> <span class="ow">not</span> <span class="n">be</span> <span class="n">easier:</span> <span class="n">just</span> <span class="n">add</span> <span class="n">an</span> <span class="n">input</span> <span class="n">field</span> <span class="n">to</span> <span class="n">the</span> <span class="n">form</span><span class="p">,</span> <span class="ow">and</span> <span class="n">Sling</span> <span class="n">will</span> <span class="k">do</span> <span class="n">the</span> <span class="n">rest</span><span class="o">.</span>
+
+<span class="n">Adding</span> <span class="n">this</span> <span class="n">inside</span> <span class="k">our</span> <span class="n">script</span><span class="err">&#39;</span><span class="n">s</span>  <span class="n">element</span><span class="p">,</span> <span class="k">for</span> <span class="n">example:</span>
+
+<span class="p">{</span><span class="n">code:html</span><span class="p">}</span>
+<span class="sr">&lt;br/&gt;</span><span class="n">Author:</span><span class="sr">&lt;br/&gt;</span>
+<span class="o">&lt;</span><span class="n">input</span> <span class="n">type</span><span class="o">=</span><span class="s">&quot;author&quot;</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;author&quot;</span> <span class="n">style</span><span class="o">=</span><span class="s">&quot;width:100%&quot;</span><span class="o">/&gt;</span>
+</pre></div>
+
+
+<p>Allows us to add an author name to our blog posts. No need to define anything at the repository level, as Sling is using it in unstructured mode in this case, and no need to migrate existing data, the author field of existing posts will simply be empty.</p>
+<h2 id="i-want-my-esp">I want my ESP!</h2>
+<p>Now wait...we said we were going to create an ESP script, but our "application" is just static HTML and some client javascript at this point.</p>
+<p>That's correct - as we are using only Sling client-facing features at this point (HTTP POST and <code>sling.js</code>), we do not necessarily need to use ESP code.</p>
+<p>To keep things simple, we'll refrain from adding ESP-based features at this point, but you can of course use any ESP code in the <em>blog.esp</em> "script".</p>
+<h2 id="thats-the-power-of-sling">That's the power of Sling</h2>
+<p>The 46-line blog is a good example of the power of Sling. It leverages the <a href="">SlingPostServlet</a>, which handles POST requests in a form-friendly way, and the <code>[sling.js|http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/resources/system/sling.js]</code> client library, which provides high-level functionality on the client side.</p>
+<hr />
+<p>///Footnotes Go Here///</p>
+      <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/tutorials-how-tos/getting-resources-and-properties-in-sling.html
==============================================================================
--- websites/staging/sling/trunk/content/tutorials-how-tos/getting-resources-and-properties-in-sling.html (added)
+++ websites/staging/sling/trunk/content/tutorials-how-tos/getting-resources-and-properties-in-sling.html Tue May 22 08:25:32 2012
@@ -0,0 +1,170 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Getting Resources and Properties in Sling</title>
+    <link rel="stylesheet" href="/css/site.css" type="text/css" media="all">
+    <link rel="icon" href="http://sling.apache.org/site/media.data/favicon.ico">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/site/index.html">
+          <img border="0" alt="Apache Sling" src="http://sling.apache.org/site/media.data/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="http://sling.apache.org/site/media.data/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <p><strong>Documentation</strong> <br />
+<a href="/getting-started.html">Getting Started</a> <br />
+<a href="/the-sling-engine.html">The Sling Engine</a> <br />
+<a href="/development.html">Development</a> <br />
+<a href="/bundles.html">Bundles</a> <br />
+<a href="/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/configuration.html">Configuration</a> <br />
+<a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a> <br />
+<a href="/sitemap.html">Site Map</a></p>
+<p><strong>API Docs</strong>  <br />
+<a href="http://sling.apache.org/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="http://sling.apache.org/apidocs/sling5/index.html">Sling 5</a> <br />
+</p>
+<p><strong>Project info</strong> <br />
+<a href="http://sling.apache.org/site/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Browse Source Repository</a> <br />
+<a href="/security.html">Security</a> <br />
+</p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a> <br />
+</p>
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/tutorials-how-tos.html">Tutorials & How-Tos</a>
+      </div>
+      <h1>Getting Resources and Properties in Sling</h1>
+      <h1 id="getting-resources-and-properties-in-sling">Getting Resources and Properties in Sling</h1>
+<p>The Resource is one of the central parts of Sling. Extending from JCR's Everything is Content, Sling assumes Everthing is a Resource. Thus Sling is maintaining a virtual tree of resources, which is a merger of the actual contents in the JCR Repository and resources provided by so called resource providers. By doing this Sling fits very well in the paradigm of the REST architecture.</p>
+<p>In this article we will explore a few ways to programmatically map a resource path (String) to a resource object (Resource) and its properties in Sling, from within an OSGI service, a servlet and a JSP.</p>
+<p>The whole game consists in first getting a <code>ResourceResolver</code> and then getting the <code>Resource</code> itself.</p>
+<h2 id="within-an-osgi-servicecompoment">Within an OSGI Service/Compoment</h2>
+<p>You can access a resource through the <code>ResourceResolverFactory</code> service:</p>
+<div class="codehilite"><pre><span class="sr">/** @scr.reference */</span>
+<span class="n">private</span> <span class="n">ResourceResolverFactory</span> <span class="n">resolverFactory</span><span class="p">;</span>
+
+<span class="n">public</span> <span class="n">void</span> <span class="n">myMethod</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">try</span> <span class="p">{</span>
+    <span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="p">;</span>
+        <span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">resolverFactory</span><span class="o">.</span><span class="n">getAdministrativeResourceResolver</span><span class="p">(</span><span class="n">null</span><span class="p">);</span>
+    <span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
+    <span class="sr">//</span> <span class="k">do</span> <span class="n">something</span> <span class="n">with</span> <span class="n">the</span> <span class="n">resource</span>
+    <span class="sr">//</span> <span class="n">when</span> <span class="n">done</span><span class="p">,</span> <span class="nb">close</span> <span class="n">the</span> <span class="n">ResourceResolver</span>
+    <span class="n">resourceResolver</span><span class="o">.</span><span class="nb">close</span><span class="p">();</span>
+    <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">LoginException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+        <span class="sr">//</span> <span class="nb">log</span> <span class="n">the</span> <span class="n">error</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h2 id="within-a-servlet">Within a Servlet</h2>
+<p>You can access the resource defined by the request URL through the <code>SlingHttpServletRequest</code>:</p>
+<div class="codehilite"><pre><span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="n">getResource</span><span class="p">();</span>
+<span class="sr">//</span> <span class="n">req</span> <span class="n">is</span> <span class="n">the</span> <span class="n">SlingHttpServletRequest</span>
+</pre></div>
+
+
+<p>You can access any resource by first accessing the <code>ResourceResolver</code>:</p>
+<div class="codehilite"><pre><span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="p">;</span>
+<span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="n">getResourceResolver</span><span class="p">();</span>
+<span class="sr">//</span> <span class="n">req</span> <span class="n">is</span> <span class="n">the</span> <span class="n">SlingHttpServletRequest</span>
+<span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
+</pre></div>
+
+
+<h2 id="within-a-jsp-file">Within a JSP file</h2>
+<p>When you use the <code>&lt;sling:defineObjects&gt;</code> tag in a JSP file, you have access to a few handy objects, one of them is <code>resource</code>, the resource that is resolved from the URL. Another one is <code>resourceResolver</code>, the <code>ResourceResolver</code> defined through the <code>SlingHttpServletRequest</code>. </p>
+<p>To access a resource:</p>
+<div class="codehilite"><pre><span class="x">&lt;sling:defineObjects&gt;</span>
+<span class="cp">&lt;%</span>
+<span class="nb">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s2">&quot;path/to/resource&quot;</span><span class="p">;</span>
+<span class="no">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
+<span class="cp">%&gt;</span><span class="x"></span>
+</pre></div>
+
+
+<p>If needed you can adapt a Sling Resource to a JCR Node:</p>
+<div class="codehilite"><pre><span class="n">Node</span> <span class="n">node</span> <span class="o">=</span> <span class="n">resource</span><span class="o">.</span><span class="n">adaptTo</span><span class="p">(</span><span class="n">Node</span><span class="o">.</span><span class="n">class</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Note: <code>resource.adaptTo(Node.class)</code> may return null if the resource is not backed by a JCR node. This is particularly the case for <code>NonExistingResource</code> resources or resource provided by a non-JCR resource provider.</p>
+<h2 id="accessing-a-property">Accessing a Property</h2>
+<p>The <code>ValueMap</code> is an easy way to access properties of a resource. With most resources you can use <code>Adaptable.adaptTo(Class)</code> to adapt the resource to a value map:</p>
+<div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="n">adaptTo</span><span class="p">(</span><span class="n">ValueMap</span><span class="o">.</span><span class="n">class</span><span class="p">);</span>
+<span class="sr">//</span> <span class="n">res</span> <span class="n">is</span> <span class="n">the</span> <span class="n">Resource</span>
+</pre></div>
+
+
+<p>You can also access the properties through the <code>ResourceUtil</code> utility class:</p>
+<div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">ResourceUtil</span><span class="o">.</span><span class="n">getValueMap</span><span class="p">(</span><span class="n">res</span><span class="p">);</span>
+<span class="sr">//</span> <span class="n">res</span> <span class="n">is</span> <span class="n">the</span> <span class="n">Resource</span>
+</pre></div>
+
+
+<p>Then, to access a specific String property called <code>propName</code>:</p>
+<div class="codehilite"><pre><span class="n">String</span> <span class="n">rule</span> <span class="o">=</span> <span class="n">properties</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">propName</span><span class="p">,</span> <span class="p">(</span><span class="n">String</span><span class="p">)</span> <span class="n">null</span><span class="p">);</span>
+</pre></div>
+
+
+<p>For more details about resources and how to access them in Sling, you can refer to the <a href="">Sling documentation about Resources</a>.</p>
+      <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
+        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>



Mime
View raw message