Author: buildbot
Date: Mon Jun 11 01:56:02 2012
New Revision: 821202

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    
websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html
    websites/staging/sling/trunk/content/res/site.css

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Jun 11 01:56:02 2012
@@ -1 +1 @@
-1348702
+1348706

Modified: 
websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html
==============================================================================
--- 
websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html
 (original)
+++ 
websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html
 Mon Jun 11 01:56:02 2012
@@ -83,7 +83,23 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a 
href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a 
href="/documentation/the-sling-engine.html">The Sling Engine</a>
       </div>
       <h1>Servlets and Scripts</h1>
-      <p>Servlets can be registered as OSGi services. The following service 
reference properties are defined for Servlets defined as OSGi services of type 
<code>javax.servlet.Servlet</code>:</p>
+      <div class="toc">
+<ul>
+<li><a href="#servlet-registration">Servlet Registration</a><ul>
+<li><a href="#automated-tests">Automated tests</a></li>
+<li><a href="#example-registration-by-path">Example: Registration by 
Path</a></li>
+<li><a href="#example-registration-by-resource-type-etc">Example: Registration 
by Resource Type etc.</a></li>
+<li><a href="#servlet-lifecycle-issues">Servlet Lifecycle Issues</a></li>
+</ul>
+</li>
+<li><a href="#scripts-are-servlets">Scripts are Servlets</a></li>
+<li><a href="#default-servlets">Default Servlet(s)</a></li>
+<li><a href="#optingservlet-interface">OptingServlet interface</a></li>
+<li><a href="#error-handler-servlets-or-scripts">Error Handler Servlet(s) or 
Scripts</a></li>
+</ul>
+</div>
+<h2 id="servlet-registration">Servlet Registration</h2>
+<p>Servlets can be registered as OSGi services. The following service 
reference properties are defined for Servlets defined as OSGi services of type 
<code>javax.servlet.Servlet</code>:</p>
 <table>
 <thead>
 <tr>
@@ -94,15 +110,7 @@
 <tbody>
 <tr>
 <td><code>sling.servlet.paths</code></td>
-<td>A list of absolute paths under which the servlet is accessible as a 
Resource. The property value must either be a single String, an array of 
Strings or a Vector of Strings.</td>
-</tr>
-<tr>
-<td>A servlet using this property might be ignored unless its path is included 
in the <em>Execution Paths</em> (<code>servletresolver.paths</code>) 
configuration setting of the <code>SlingServletResolver</code> service.</td>
-<td></td>
-</tr>
-<tr>
-<td>Creating a resource at the desired path, with a resource type that maps to 
a servlet, provides the same result in most cases while taking advantage of 
more Sling built-in features.</td>
-<td></td>
+<td>A list of absolute paths under which the servlet is accessible as a 
Resource. The property value must either be a single String, an array of 
Strings or a Vector of Strings.<br>A servlet using this property might be 
ignored unless its path is included in the <em>Execution Paths</em> 
(<code>servletresolver.paths</code>) configuration setting of the 
<code>SlingServletResolver</code> service.<br>Creating a resource at the 
desired path, with a resource type that maps to a servlet, provides the same 
result in most cases while taking advantage of more Sling built-in 
features.</td>
 </tr>
 <tr>
 <td><code>sling.servlet.resourceTypes</code></td>
@@ -165,11 +173,29 @@
 <li><code>{*}prefix*/sling/unused/tab/json</code></li>
 </ul>
 <p>As explained the Servlet is registered for each permutation of the resource 
types, selectors and extension. See above For an explanation of how 
<code>{*}prefix{*</code>} is defined.</p>
+<h3 id="servlet-lifecycle-issues">Servlet Lifecycle Issues</h3>
+<p>The Servlet API specification states the following with respect to the life
+cycle of Servlets:</p>
+<blockquote>
+<p>The servlet container calls the init method exactly once after
+ instantiating the servlet.</p>
+</blockquote>
+<p>This works perfectly in a regular servlet container which both instantiates
+and initializes the servlets. With Sling the tasks of instantiation and
+initialization are split:</p>
+<ul>
+<li>The provider of the Servlet service takes care of creating the servlet 
instance</li>
+<li>The Sling Servlet Resolver picks up the Servlet services and initializes 
and destroys them as needed</li>
+</ul>
+<p>So Sling has not way of making sure a Servlet is only initialized and 
destroyed
+once in the life time of the Servlet object instance.</p>
+<p>The provider of the Servlet service on the other can cope with this
+situation by making sure to drop the servlet instance once it is destroyed.
+The mechanism helping the provider here is the OSGi Service Factory.</p>
 <h2 id="scripts-are-servlets">Scripts are Servlets</h2>
 <p>The Sling API defines a <code>SlingScript</code> interface which is used to 
represent (executable) scripts inside of Sling. This interface is implemented 
in the <code>scripting/core</code> bundle in the 
<code>DefaultSlingScript</code> class which also implements the 
<code>javax.servlet.Servlet</code>.</p>
 <p>To further simplify the access to scripts from the Resource tree, the 
<code>scripting/core</code> bundle registers an <code>AdapterFactory</code> to 
adapt Resources to Scripts and Servlets (the 
<code>SlingScriptAdapterFactory</code>). In fact the adapter factory returns 
instances of the <code>DefaultSlingScript</code> class for both Scripts and 
Servlets.</p>
 <p>From the perspective of the Servlet resolver, scripts and servlets are 
handled exactly the same. In fact, internally, Sling only handles with 
Servlets, whereas scripts are packed inside a Servlet wrapping and representing 
the script.</p>
-<h2></h2>
 <h2 id="default-servlets">Default Servlet(s)</h2>
 <p>As explained in the Resolution Process section above, a default Servlet is 
selected if no servlet (or script) for the current resource type can be found. 
To make the provisioning of a default Servlet as versatile as provisioning per 
resource type Servlets (or scripts), the default Servlet is selected with just 
a special resource type <code>sling/servlet/default</code>.</p>
 <p>The actual Servlet or Script called as the default Servlet is resolved 
exactly the same way as for any resource type. That is, also for the default 
Servlet selection, the request selectors and extension or method are 
considered. Also, the Servlet may be a Servlet registered as an OSGi service or 
it may be a Script stored in the repository or provided by any bundle.</p>
@@ -184,7 +210,7 @@
 <h2 id="error-handler-servlets-or-scripts">Error Handler Servlet(s) or 
Scripts</h2>
 <p>Error handling support is now described on the <a 
href="/documentation/the-sling-engine/errorhandling.html">Errorhandling</a> 
page.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; 
text-align: right;">
-        Rev. 1341376 by fmeschbe on Tue, 22 May 2012 09:41:06 +0000
+        Rev. 1348706 by fmeschbe on Mon, 11 Jun 2012 01:55:58 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache 
Sling project

Modified: websites/staging/sling/trunk/content/res/site.css
==============================================================================
--- websites/staging/sling/trunk/content/res/site.css (original)
+++ websites/staging/sling/trunk/content/res/site.css Mon Jun 11 01:56:02 2012
@@ -212,5 +212,9 @@ td {
     text-align: left;
 }
 
-/* Code High Lighting */
-
+blockquote {
+    font-style: italic;
+    margin: 0;
+    padding-left: 1em;
+    border-left: 1px solid black;
+}
\ No newline at end of file


Reply via email to