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 [18/23] - in /websites/staging/sling/trunk/content: ./ tutorials-how-tos/
Date Tue, 22 May 2012 08:25:36 GMT
Added: websites/staging/sling/trunk/content/scheduler-service-commons-scheduler.html
==============================================================================
--- websites/staging/sling/trunk/content/scheduler-service-commons-scheduler.html (added)
+++ websites/staging/sling/trunk/content/scheduler-service-commons-scheduler.html Tue May 22 08:25:32 2012
@@ -0,0 +1,279 @@
+<!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 - Scheduler Service (commons scheduler)</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>Scheduler Service (commons scheduler)</h1>
+      <h1 id="the-commons-scheduler">The Commons Scheduler</h1>
+<p>The scheduler is a service for scheduling other services/jobs (it uses the open source Quartz library). The scheduler can be used in two ways, by registering the job through the scheduler API and by leveraging the whiteboard pattern that is supported by the scheduler.</p>
+<h2 id="the-scheduler-api">The Scheduler API</h2>
+<p>The scheduler has methods to execute jobs periodically, based on a cron expression or at a given time. For more details please refer to the <a href="">javadocs</a>.</p>
+<h2 id="examples-of-scheduled-jobs-registered-through-the-scheduler-api">Examples of scheduled jobs registered through the scheduler API</h2>
+<p>The following examples show you how to define and schedule a job that is registered through the scheduler api.</p>
+<h3 id="defining-the-job">Defining the job</h3>
+<p>The following code sample defines a <em>job</em> object that writes a message in the logs:</p>
+<div class="codehilite"><pre><span class="n">final</span> <span class="n">Runnable</span> <span class="n">job</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Runnable</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+        <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing the job&quot;</span><span class="p">);</span>
+    <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+
+
+<h3 id="scheduling-with-a-cron-expression">Scheduling with a cron expression</h3>
+<p>To execute the job as defined above at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday, you can use the <em>addJob()</em> method with the following parameters:</p>
+<div class="codehilite"><pre><span class="n">String</span> <span class="n">schedulingExpression</span> <span class="o">=</span> <span class="s">&quot;0 15 10 ? * MON-FRI&quot;</span><span class="p">;</span>
+<span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">addJob</span><span class="p">(</span><span class="s">&quot;myJob&quot;</span><span class="p">,</span> <span class="n">job</span><span class="p">,</span> <span class="n">null</span><span class="p">,</span> <span class="n">schedulingExpression</span><span class="p">,</span> <span class="n">true</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Refer to http://www.docjar.com/docs/api/org/quartz/CronTrigger.html
+ to define more scheduling expressions.</p>
+<h3 id="scheduling-at-periodic-times">Scheduling at periodic times</h3>
+<p>To execute the job as defined above every 3 minutes (180 seconds), you can use the <em>addPeriodicJob()</em> method with the following parameters:</p>
+<div class="codehilite"><pre><span class="n">long</span> <span class="n">period</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="mi">60</span><span class="p">;</span> <span class="sr">//</span><span class="n">the</span> <span class="n">period</span> <span class="n">is</span> <span class="n">expressed</span> <span class="n">in</span> <span class="n">seconds</span>
+<span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">addPeriodicJob</span><span class="p">(</span><span class="s">&quot;myJob&quot;</span><span class="p">,</span> <span class="n">job</span><span class="p">,</span> <span class="n">null</span><span class="p">,</span> <span class="n">period</span><span class="p">,</span> <span class="n">true</span><span class="p">);</span>
+</pre></div>
+
+
+<h3 id="scheduling-at-a-given-time">Scheduling at a given time</h3>
+<p>To execute the job as defined above at a specific date (on January 10th 2020), you can use the <em>fireJobAt()</em> method with the following parameters:</p>
+<div class="codehilite"><pre><span class="n">SimpleDateFormat</span> <span class="n">formatter</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SimpleDateFormat</span><span class="p">(</span><span class="s">&quot;yyyy/MM/dd&quot;</span><span class="p">);</span>
+<span class="n">String</span> <span class="n">date</span> <span class="o">=</span> <span class="s">&quot;2020/01/10&quot;</span><span class="p">;</span>
+<span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Date</span> <span class="n">fireDate</span> <span class="o">=</span> <span class="n">formatter</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">date</span><span class="p">);</span>
+<span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">fireJobAt</span><span class="p">(</span><span class="s">&quot;myJob&quot;</span><span class="p">,</span> <span class="n">job</span><span class="p">,</span> <span class="n">null</span><span class="p">,</span> <span class="n">fireDate</span><span class="p">);</span>
+</pre></div>
+
+
+<h3 id="a-service-scheduling-the-job-based-on-3-different-kinds-of-scheduling">A service scheduling the job based on 3 different kinds of scheduling</h3>
+<p>The code implementing a service that simultaneously executes the job based on 3 different kinds of scheduling can look as follows:</p>
+<div class="codehilite"><pre><span class="nb">package</span> <span class="n">sling</span><span class="o">.</span><span class="n">docu</span><span class="o">.</span><span class="n">examples</span><span class="p">;</span>
+
+<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">io</span><span class="o">.</span><span class="n">Serializable</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Date</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">HashMap</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Map</span><span class="p">;</span>
+
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">sling</span><span class="o">.</span><span class="n">commons</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">Scheduler</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">component</span><span class="o">.</span><span class="n">ComponentContext</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">Logger</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">LoggerFactory</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span>  <span class="n">This</span> <span class="n">service</span> <span class="n">executes</span> <span class="n">scheduled</span> <span class="n">jobs</span>
+ <span class="o">*</span>  
+ <span class="o">*</span>  <span class="nv">@scr</span><span class="o">.</span><span class="n">component</span> <span class="n">immediate</span><span class="o">=</span><span class="s">&quot;true&quot;</span> <span class="n">metatype</span><span class="o">=</span><span class="s">&quot;false&quot;</span>
+ <span class="o">*</span>
+ <span class="o">*/</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">HelloWorldScheduledService</span> <span class="p">{</span>
+
+    <span class="sr">/** Default log. */</span>
+    <span class="n">protected</span> <span class="n">final</span> <span class="n">Logger</span> <span class="nb">log</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">getClass</span><span class="p">());</span>
+
+    <span class="o">/**</span> <span class="n">The</span> <span class="n">scheduler</span> <span class="k">for</span> <span class="n">rescheduling</span> <span class="n">jobs</span><span class="o">.</span>
+     <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">reference</span> <span class="o">*/</span>
+    <span class="n">private</span> <span class="n">Scheduler</span> <span class="n">scheduler</span><span class="p">;</span>
+
+    <span class="n">protected</span> <span class="n">void</span> <span class="n">activate</span><span class="p">(</span><span class="n">ComponentContext</span> <span class="n">componentContext</span><span class="p">)</span> <span class="n">throws</span> <span class="n">Exception</span> <span class="p">{</span>
+        <span class="sr">//c</span><span class="n">ase</span> <span class="mi">1</span><span class="p">:</span> <span class="n">with</span> <span class="n">addJob</span><span class="p">()</span> <span class="n">method:</span> <span class="n">executes</span> <span class="n">the</span> <span class="n">job</span> <span class="n">every</span> <span class="n">minute</span>
+        <span class="n">String</span> <span class="n">schedulingExpression</span> <span class="o">=</span> <span class="s">&quot;0 * * * * ?&quot;</span><span class="p">;</span>
+        <span class="n">String</span> <span class="n">jobName1</span> <span class="o">=</span> <span class="s">&quot;case1&quot;</span><span class="p">;</span>
+        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span> <span class="n">config1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span><span class="p">();</span>
+        <span class="n">boolean</span> <span class="n">canRunConcurrently</span> <span class="o">=</span> <span class="n">true</span><span class="p">;</span>
+        <span class="n">final</span> <span class="n">Runnable</span> <span class="n">job1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Runnable</span><span class="p">()</span> <span class="p">{</span>
+            <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+                <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing job1&quot;</span><span class="p">);</span>
+            <span class="p">}</span>
+        <span class="p">};</span>
+        <span class="n">try</span> <span class="p">{</span>
+            <span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">addJob</span><span class="p">(</span><span class="n">jobName1</span><span class="p">,</span> <span class="n">job1</span><span class="p">,</span> <span class="n">config1</span><span class="p">,</span> <span class="n">schedulingExpression</span><span class="p">,</span> <span class="n">canRunConcurrently</span><span class="p">);</span>
+        <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+            <span class="n">job1</span><span class="o">.</span><span class="n">run</span><span class="p">();</span>
+        <span class="p">}</span>
+
+        <span class="sr">//c</span><span class="n">ase</span> <span class="mi">2</span><span class="p">:</span> <span class="n">with</span> <span class="n">addPeriodicJob</span><span class="p">():</span> <span class="n">executes</span> <span class="n">the</span> <span class="n">job</span> <span class="n">every</span> <span class="mi">3</span> <span class="n">minutes</span>
+        <span class="n">String</span> <span class="n">jobName2</span> <span class="o">=</span> <span class="s">&quot;case2&quot;</span><span class="p">;</span>
+        <span class="n">long</span> <span class="n">period</span> <span class="o">=</span> <span class="mi">180</span><span class="p">;</span>
+        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span> <span class="n">config2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span><span class="p">();</span>
+        <span class="n">final</span> <span class="n">Runnable</span> <span class="n">job2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Runnable</span><span class="p">()</span> <span class="p">{</span>
+            <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+                <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing job2&quot;</span><span class="p">);</span>
+            <span class="p">}</span>
+        <span class="p">};</span>
+        <span class="n">try</span> <span class="p">{</span>
+            <span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">addPeriodicJob</span><span class="p">(</span><span class="n">jobName2</span><span class="p">,</span> <span class="n">job2</span><span class="p">,</span> <span class="n">config2</span><span class="p">,</span> <span class="n">period</span><span class="p">,</span> <span class="n">canRunConcurrently</span><span class="p">);</span>
+        <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+            <span class="n">job2</span><span class="o">.</span><span class="n">run</span><span class="p">();</span>
+        <span class="p">}</span>
+
+        <span class="sr">//c</span><span class="n">ase</span> <span class="mi">3</span><span class="p">:</span> <span class="n">with</span> <span class="n">fireJobAt</span><span class="p">():</span> <span class="n">executes</span> <span class="n">the</span> <span class="n">job</span> <span class="n">at</span> <span class="n">a</span> <span class="n">specific</span> <span class="n">date</span> <span class="p">(</span><span class="n">date</span> <span class="n">of</span> <span class="n">deployment</span> <span class="o">+</span> <span class="n">delay</span> <span class="n">of</span> <span class="mi">30</span> <span class="n">seconds</span><span class="p">)</span>
+        <span class="n">String</span> <span class="n">jobName3</span> <span class="o">=</span> <span class="s">&quot;case3&quot;</span><span class="p">;</span>
+        <span class="n">final</span> <span class="n">long</span> <span class="n">delay</span> <span class="o">=</span> <span class="mi">30</span><span class="o">*</span><span class="mi">1000</span><span class="p">;</span>
+        <span class="n">final</span> <span class="n">Date</span> <span class="n">fireDate</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Date</span><span class="p">();</span>
+        <span class="n">fireDate</span><span class="o">.</span><span class="n">setTime</span><span class="p">(</span><span class="n">System</span><span class="o">.</span><span class="n">currentTimeMillis</span><span class="p">()</span> <span class="o">+</span> <span class="n">delay</span><span class="p">);</span>
+        <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span> <span class="n">config3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Serializable</span><span class="o">&gt;</span><span class="p">();</span>
+        <span class="n">final</span> <span class="n">Runnable</span> <span class="n">job3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Runnable</span><span class="p">()</span> <span class="p">{</span>
+            <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+                <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing job3 at date: {} with a delay of: {} seconds&quot;</span><span class="p">,</span> <span class="n">fireDate</span><span class="p">,</span> <span class="n">delay</span><span class="o">/</span><span class="mi">1000</span><span class="p">);</span>
+            <span class="p">}</span>
+        <span class="p">};</span>
+        <span class="n">try</span> <span class="p">{</span>
+            <span class="n">this</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">fireJobAt</span><span class="p">(</span><span class="n">jobName3</span><span class="p">,</span> <span class="n">job3</span><span class="p">,</span> <span class="n">config3</span><span class="p">,</span> <span class="n">fireDate</span><span class="p">);</span>
+        <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+            <span class="n">job3</span><span class="o">.</span><span class="n">run</span><span class="p">();</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+
+    <span class="n">protected</span> <span class="n">void</span> <span class="n">deactivate</span><span class="p">(</span><span class="n">ComponentContext</span> <span class="n">componentContext</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Deactivated, goodbye!&quot;</span><span class="p">);</span>
+    <span class="p">}</span>
+
+<span class="p">}</span>
+</pre></div>
+
+
+<h2 id="examples-of-jobs-that-are-scheduled-by-leveraging-the-whiteboard-pattern">Examples of jobs that are scheduled by leveraging the whiteboard pattern</h2>
+<p>The following examples show you how to define and schedule a job by leveraging the whiteboard pattern.</p>
+<h3 id="scheduling-with-a-cron-expression_1">Scheduling with a cron expression</h3>
+<p>The following job is executed every minute by setting <em>scheduler.expression</em> to the cron expression <em>"0 * </em> * <em> ?"</em>:</p>
+<div class="codehilite"><pre><span class="nb">package</span> <span class="n">sling</span><span class="o">.</span><span class="n">docu</span><span class="o">.</span><span class="n">examples</span><span class="p">;</span>
+
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">Logger</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">LoggerFactory</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">component</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">service</span> <span class="n">interface</span><span class="o">=</span><span class="s">&quot;java.lang.Runnable&quot;</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">property</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;scheduler.expression&quot;</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;0 * * * * ?&quot;</span>
+ <span class="o">*/</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ScheduledCronJob</span> <span class="n">implements</span> <span class="n">Runnable</span> <span class="p">{</span>
+
+    <span class="sr">/** Default log. */</span>
+    <span class="n">protected</span> <span class="n">final</span> <span class="n">Logger</span> <span class="nb">log</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">getClass</span><span class="p">());</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+        <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing a cron job (job#1) through the whiteboard pattern&quot;</span><span class="p">);</span>
+    <span class="p">}</span>
+<span class="sr">//</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h3 id="scheduling-at-periodic-times_1">Scheduling at periodic times</h3>
+<p>The following job is executed every ten seconds by setting <em>scheduler.period</em> to <em>10</em>:</p>
+<div class="codehilite"><pre><span class="nb">package</span> <span class="n">sling</span><span class="o">.</span><span class="n">docu</span><span class="o">.</span><span class="n">examples</span><span class="p">;</span>
+
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">Logger</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">slf4j</span><span class="o">.</span><span class="n">LoggerFactory</span><span class="p">;</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">component</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">service</span> <span class="n">interface</span><span class="o">=</span><span class="s">&quot;java.lang.Runnable&quot;</span>
+ <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">property</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;scheduler.period&quot;</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;10&quot;</span> <span class="n">type</span><span class="o">=</span><span class="s">&quot;Long&quot;</span>
+ <span class="o">*/</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ScheduledPeriodicJob</span> <span class="n">implements</span> <span class="n">Runnable</span> <span class="p">{</span>
+
+    <span class="sr">/** Default log. */</span>
+    <span class="n">protected</span> <span class="n">final</span> <span class="n">Logger</span> <span class="nb">log</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">getClass</span><span class="p">());</span>
+
+    <span class="n">public</span> <span class="n">void</span> <span class="n">run</span><span class="p">()</span> <span class="p">{</span>
+        <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Executing a perodic job (job#2) through the whiteboard pattern&quot;</span><span class="p">);</span>
+    <span class="p">}</span>
+<span class="sr">//</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h3 id="preventing-concurrent-execution">Preventing concurrent execution</h3>
+<p>By default, jobs can be concurrently executed. To prevent this, set the <em>scheduler.concurrent</em> property to <em>false</em>:</p>
+<div class="codehilite"><pre><span class="nv">@scr</span><span class="o">.</span><span class="n">property</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;scheduler.concurrent&quot;</span> <span class="n">value</span><span class="o">=</span><span class="s">&quot;false&quot;</span> <span class="n">type</span><span class="o">=</span><span class="s">&quot;Boolean&quot;</span>
+</pre></div>
+      <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>

Modified: websites/staging/sling/trunk/content/scriptengineintegration.html
==============================================================================
--- websites/staging/sling/trunk/content/scriptengineintegration.html (original)
+++ websites/staging/sling/trunk/content/scriptengineintegration.html Tue May 22 08:25:32 2012
@@ -82,28 +82,19 @@
         <a href="/">Home</a>
       </div>
       <h1>ScriptEngineIntegration</h1>
-      <p><a name="ScriptEngineIntegration-IntegratingScriptingLanguages"></a></p>
-<h1 id="integrating-scripting-languages">Integrating Scripting Languages</h1>
-<p>This page should be extended with more concrete and detailed information.
-For now, we have the following information:</p>
+      <h1 id="integrating-scripting-languages">Integrating Scripting Languages</h1>
+<p>This page should be extended with more concrete and detailed information. For now, we have the following information:</p>
 <ul>
-<li>There will be a talk at ApacheCon US 08 in New Orleans about creating
-JSR-223 ScriptEngineFactory and ScriptEngine implementaitons as well as how
-to integrate such implementations with Sling.</li>
+<li>There will be a talk at ApacheCon US 08 in New Orleans about creating JSR-223 ScriptEngineFactory and ScriptEngine implementaitons as well as how to integrate such implementations with Sling.</li>
 <li>From a mail on the mailing list, this is a very condensed how-to:
-         <strong> Create the ScriptEngine[Factory](factory.html)
- implementations
-     </strong> Create a bundle comprising the above implementations as well as
-the script language implementation.
-     <em><em> Create the
-</em>META-INF/services/javax.script.ScriptEngineFactory</em> file listing the
-fully qualified name of your ScriptEngineFactory implementaiton</li>
+         <strong> Create the ScriptEngine[Factory]() implementations
+         </strong> Create a bundle comprising the above implementations as well as the script language implementation.
+         ** Create the <code>META-INF/services/javax.script.ScriptEngineFactory</code> file listing the fully qualified name of your ScriptEngineFactory implementaiton</li>
 </ul>
-<p><a name="ScriptEngineIntegration-NotesonScriptEngines"></a></p>
 <h1 id="notes-on-scriptengines">Notes on ScriptEngines</h1>
 <p>{children:sort=title|excerpt=true}</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

Modified: websites/staging/sling/trunk/content/security.html
==============================================================================
--- websites/staging/sling/trunk/content/security.html (original)
+++ websites/staging/sling/trunk/content/security.html Tue May 22 08:25:32 2012
@@ -82,45 +82,26 @@
         <a href="/">Home</a>
       </div>
       <h1>Security</h1>
-      <p><a name="Security-ReportingNewSecurityProblemswithApacheSling"></a></p>
-<h1 id="reporting-new-security-problems-with-apache-sling">Reporting New Security Problems with Apache Sling</h1>
-<p>The Apache Software Foundation takes a very active stance in eliminating
-security problems and denial of service attacks against Apache Sling.</p>
-<p>We strongly encourage folks to report such problems to our private security
-mailing list first, before disclosing them in a public forum.</p>
-<p><em>Please note that the security mailing list should only be used for
-reporting undisclosed security vulnerabilities in Apache Sling and managing
-the process of fixing such vulnerabilities. We cannot accept regular bug
-reports or other queries at this address. All mail sent to this address
-that does not relate to an undisclosed security problem in the Apache Sling
-source code will be ignored.</em></p>
-<p>If you need to report a bug that isn't an undisclosed security
-vulnerability, please use the bug reporting page.</p>
+      <h1 id="reporting-new-security-problems-with-apache-sling">Reporting New Security Problems with Apache Sling</h1>
+<p>The Apache Software Foundation takes a very active stance in eliminating security problems and denial of service attacks against Apache Sling.</p>
+<p>We strongly encourage folks to report such problems to our private security mailing list first, before disclosing them in a public forum.</p>
+<p><em>Please note that the security mailing list should only be used for reporting undisclosed security vulnerabilities in Apache Sling and managing the process of fixing such vulnerabilities. We cannot accept regular bug reports or other queries at this address. All mail sent to this address that does not relate to an undisclosed security problem in the Apache Sling source code will be ignored.</em></p>
+<p>If you need to report a bug that isn't an undisclosed security vulnerability, please use our <a href="">public issue tracker</a>.</p>
 <p>Questions about:</p>
 <ul>
 <li>how to configure Sling securely</li>
-<li>if a vulnerability applies to your particular application</li>
+<li>whether a published vulnerability applies to your particular application</li>
 <li>obtaining further information on a published vulnerability</li>
 <li>availability of patches and/or new releases</li>
 </ul>
-<p>should be addressed to the users mailing list. Please see the <a href="project-information.html">Project Information</a>
- page for details of how to subscribe.</p>
-<p>The private security mailing address is: <a href="mailto:security@sling.apache.org.html">mailto:security@sling.apache.org</a></p>
-<p>Note that all networked servers are subject to denial of service attacks,
-and we cannot promise magic workarounds to generic problems (such as a
-client streaming lots of data to your server, or re-requesting the same URL
-repeatedly). In general our philosophy is to avoid any attacks which can
-cause the server to consume resources in a non-linear relationship to the
-size of inputs.</p>
-<p>For more information on handling security issues at the Apache Software
-Foundation please refer to the <a href="http://www.apache.org/security/">ASF Security Team</a>
- page.</p>
-<p><a name="Security-Errorsandomissions"></a></p>
+<p>should be addressed to our public users mailing list. Please see the <a href="/project-information.html">Project Information</a> page for details of how to subscribe.</p>
+<p>The private security mailing address is: <a href="">mailto:security@sling.apache.org</a>.</p>
+<p>Note that all networked servers are subject to denial of service attacks, and we cannot promise magic workarounds to generic problems (such as a client streaming lots of data to your server, or re-requesting the same URL repeatedly). In general our philosophy is to avoid any attacks which can cause the server to consume resources in a non-linear relationship to the size of inputs.</p>
+<p>For more information on handling security issues at the Apache Software Foundation please refer to the <a href="">ASF Security Team</a> page.</p>
 <h1 id="errors-and-omissions">Errors and omissions</h1>
-<p>Please report any errors or omissions to <a href="mailto:security@sling.apache.org.html">mailto:security@sling.apache.org</a>
-.</p>
+<p>Please report any errors or omissions to <a href="">mailto:security@sling.apache.org</a>.</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

Modified: websites/staging/sling/trunk/content/servlet-resolution.html
==============================================================================
--- websites/staging/sling/trunk/content/servlet-resolution.html (original)
+++ websites/staging/sling/trunk/content/servlet-resolution.html Tue May 22 08:25:32 2012
@@ -82,81 +82,73 @@
         <a href="/">Home</a>
       </div>
       <h1>Servlet Resolution</h1>
-      <p><a name="ServletResolution-ServletResolution"></a></p>
-<h1 id="servlet-resolution">Servlet Resolution</h1>
+      <h1 id="servlet-resolution">Servlet Resolution</h1>
 <p>{warning:title=Out Of Sync}
-Please note that the description on this page is out of sync with the most
-recent developments going on as part of implementing issue <a href="https://issues.apache.org/jira/browse/SLING-387">SLING-387</a>
-. See the links to integration tests at the end of this page for the
-Current Truth.</p>
-<p>Please see the new <a href="servlets.html">Servlets</a>
- page.
+Please note that the description on this page is out of sync with the most recent developments going on as part of implementing issue <a href="">SLING-387</a>. See the links to integration tests at the end of this page for the Current Truth.</p>
+<p>Please see the new <a href="/servlets.html">Servlets</a> page.
 {warning}</p>
-<p>{toc:minLevel=2}</p>
-<p><a name="ServletResolution-ServletsareResources"></a></p>
+<div class="toc">
+<ul>
+<li><a href="#servlet-resolution">Servlet Resolution</a><ul>
+<li><a href="#servlets-are-resources">Servlets are Resources</a><ul>
+<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>
+</ul>
+</li>
+<li><a href="#scripts-are-servlets">Scripts are Servlets</a></li>
+<li><a href="#resolution-process">Resolution Process</a></li>
+<li><a href="#default-servlets">Default Servlet(s)</a></li>
+<li><a href="#error-handler-servlets">Error Handler Servlet(s)</a></li>
+<li><a href="#integration-tests">Integration tests</a></li>
+</ul>
+</li>
+</ul>
+</div>
 <h2 id="servlets-are-resources">Servlets are Resources</h2>
-<p>As explained on the <a href="resources.html">Resources</a>
- page, the Resource is the central data abstraction of Sling. In this
-contexts, Servlets are of course also povided as Resources. As such
-Servlets may be enumerated by iterating the Resource tree and Servlets may
-be retrieved through the <em>ResourceResolver</em>.</p>
-<p>To show a Servlet inside the Resource tree, the <em>sling/servlet-resolver</em>
-project provides a <em>ServletResourceProvider</em> implementing the
-<em>ResourceProvider</em> interface. For each Servlet registered as an OSGi
-service with one or more defined service reference properties a
-<em>ServletResourceProvider</em> instance is registered.</p>
-<p>The following service reference properties are defined for Servlets defined
-as OSGi services of type <em>javax.servlet.Servlet</em>:</p>
+<p>As explained on the <a href="/resources.html">Resources</a> page, the Resource is the central data abstraction of Sling. In this contexts, Servlets are of course also povided as Resources. As such Servlets may be enumerated by iterating the Resource tree and Servlets may be retrieved through the <code>ResourceResolver</code>.</p>
+<p>To show a Servlet inside the Resource tree, the <code>sling/servlet-resolver</code> project provides a <code>ServletResourceProvider</code> implementing the <code>ResourceProvider</code> interface. For each Servlet registered as an OSGi service with one or more defined service reference properties a <code>ServletResourceProvider</code> instance is registered.</p>
+<p>The following service reference properties are defined for Servlets defined as OSGi services of type <code>javax.servlet.Servlet</code>:</p>
 <table>
-<tr><th> Name </th><th> Description </th></tr>
-<tr><td> *sling.servlet.paths* </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> *sling.servlet.resourceTypes* </td><td> The resource type(s) supported by the
-servlet. The property value must either be a single String, an array of
-Strings or a Vector of Strings. This property is ignored if the
-*sling.servlet.paths* property is set. </td></tr>
-<tr><td> *sling.servlet.selectors* </td><td>  The request URL selectors supported by the
-servlet. The selectors must be configured as they would be specified in the
-URL that is as a list of dot-separated strings such as <em>print.a4</em>.
-The property value must either be a single String, an array of Strings or a
-Vector of Strings. This property is ignored if the *sling.servlet.paths*
-property is set. </td></tr>
-<tr><td> *sling.servlet.extensions* </td><td> The request URL extensions supported by
-the servlet for GET requests. The property value must either be a single
-String, an array of Strings or a Vector of Strings. This property is
-ignored if the *sling.servlet.paths* property is set. </td></tr>
-<tr><td> *sling.servlet.methods* </td><td>  The request methods supported by the
-servlet. The property value must either be a single String, an array of
-Strings or a Vector of Strings. This property is ignored if the
-*sling.servlet.paths* property is set. </td></tr>
-<tr><td> *sling.servlet.prefix* </td><td>  The absolute prefix to make relative paths
-absolute. This property is a String and is optional. If it is not set, the
-actual prefix used is derived from the search path of the
-*ResourceResolver* at the time of registration. </td></tr>
+<thead>
+<tr>
+<th>Name</th>
+<th>Description</th>
+</tr>
+</thead>
+<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><code>sling.servlet.resourceTypes</code></td>
+<td>The resource type(s) supported by the servlet. The property value must either be a single String, an array of Strings or a Vector of Strings. This property is ignored if the <code>sling.servlet.paths</code> property is set.</td>
+</tr>
+<tr>
+<td><code>sling.servlet.selectors</code></td>
+<td>The request URL selectors supported by the servlet. The selectors must be configured as they would be specified in the URL that is as a list of dot-separated strings such as <em>print.a4</em>. The property value must either be a single String, an array of Strings or a Vector of Strings. This property is ignored if the <code>sling.servlet.paths</code> property is set.</td>
+</tr>
+<tr>
+<td><code>sling.servlet.extensions</code></td>
+<td>The request URL extensions supported by the servlet for GET requests. The property value must either be a single String, an array of Strings or a Vector of Strings. This property is ignored if the <code>sling.servlet.paths</code> property is set.</td>
+</tr>
+<tr>
+<td><code>sling.servlet.methods</code></td>
+<td>The request methods supported by the servlet. The property value must either be a single String, an array of Strings or a Vector of Strings. This property is ignored if the <code>sling.servlet.paths</code> property is set.</td>
+</tr>
+<tr>
+<td><code>sling.servlet.prefix</code></td>
+<td>The absolute prefix to make relative paths absolute. This property is a String and is optional. If it is not set, the actual prefix used is derived from the search path of the <code>ResourceResolver</code> at the time of registration.</td>
+</tr>
+</tbody>
 </table>
-
-<p>For a Servlet registered as an OSGi service to be used by the Sling Servlet
-Resolver, the following restrictions apply:</p>
+<p>For a Servlet registered as an OSGi service to be used by the Sling Servlet Resolver, the following restrictions apply:</p>
 <ol>
-<li>Either the <em>sling.servlet.paths</em> or the
-<em>sling.servlet.resourceTypes</em> service reference property must be set. If
-neither is set, the Servlet service is ignored.</li>
-<li>If the <em>sling.servlet.paths</em> property is set, all other
-<em>sling.servlet.</em>* properties are ignored.</li>
-<li>Otherwise a Resource provider is registered for the Servlet for each
-permutation resource types, selectors, extensions and methods.</li>
+<li>Either the <code>sling.servlet.paths</code> or the <code>sling.servlet.resourceTypes</code> service reference property must be set. If neither is set, the Servlet service is ignored.</li>
+<li>If the <code>sling.servlet.paths</code> property is set, all other <code>sling.servlet.*</code> properties are ignored.</li>
+<li>Otherwise a Resource provider is registered for the Servlet for each permutation resource types, selectors, extensions and methods.</li>
 </ol>
-<p>Each path to be used for registration -- either from the
-<em>sling.servlet.paths</em> property or constructed from the other
-<em>sling.servlet.</em><em> properties -- must be absolute. Any relative path is
-made absolute by prefixing it with a root path. This prefix may be set with
-the </em>sling.servlet.prefix<em> service registration property. If this
-property is not set, the first entry in the </em>ResourceResolver<em> search
-path for the </em>ResourceResolver.getResource(String)<em> method is used as the
-prefix. If this entry cannot be derived, a simpe slash -- </em>/* -- is used
-as the prefix.</p>
-<p><a name="ServletResolution-Example:RegistrationbyPath"></a></p>
+<p>Each path to be used for registration -- either from the <code>sling.servlet.paths</code> property or constructed from the other <code>sling.servlet.*</code> properties -- must be absolute. Any relative path is made absolute by prefixing it with a root path. This prefix may be set with the <code>sling.servlet.prefix</code> service registration property. If this property is not set, the first entry in the <code>ResourceResolver</code> search path for the <code>ResourceResolver.getResource(String)</code> method is used as the prefix. If this entry cannot be derived, a simpe slash -- <code>/</code> -- is used as the prefix.</p>
 <h3 id="example-registration-by-path">Example: Registration by Path</h3>
 <div class="codehilite"><pre><span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">paths</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;/libs/sling/sample/html&quot;</span><span class="p">,</span> <span class="s">&quot;/libs/sling/sample/txt&quot;</span> <span class="p">]</span>
 <span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">resourceTypes</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;sling/unused&quot;</span> <span class="p">]</span>
@@ -165,16 +157,12 @@ as the prefix.</p>
 </pre></div>
 
 
-<p>A Servlet service registered with these properties is registered under the
-following paths:</p>
+<p>A Servlet service registered with these properties is registered under the following paths:</p>
 <ul>
-<li><em>/libs/sling/sample/html</em></li>
-<li><em>/libs/sling/sample/txt</em></li>
+<li><code>/libs/sling/sample/html</code></li>
+<li><code>/libs/sling/sample/txt</code></li>
 </ul>
-<p>The registration properties <em>sling.servlet.resourceTypes</em>,
-<em>sling.servlet.selectors</em> and <em>sling.servlet.extensions</em> are ignored
-because the <em>sling.servlet.paths</em> property is set.</p>
-<p><a name="ServletResolution-Example:RegistrationbyResourceTypeetc."></a></p>
+<p>The registration properties <code>sling.servlet.resourceTypes</code>, <code>sling.servlet.selectors</code> and <code>sling.servlet.extensions</code> are ignored because the <code>sling.servlet.paths</code> property is set.</p>
 <h3 id="example-registration-by-resource-type-etc">Example: Registration by Resource Type etc.</h3>
 <div class="codehilite"><pre><span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">resourceTypes</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;sling/unused&quot;</span> <span class="p">]</span>
 <span class="n">sling</span><span class="o">.</span><span class="n">servlet</span><span class="o">.</span><span class="n">selectors</span> <span class="o">=</span> <span class="p">[</span> <span class="s">&quot;img&quot;</span><span class="p">,</span> <span class="s">&quot;tab&quot;</span> <span class="p">]</span>
@@ -182,67 +170,30 @@ because the <em>sling.servlet.paths</em>
 </pre></div>
 
 
-<p>A Servlet service registered with these properties is registered under the
-following paths:</p>
+<p>A Servlet service registered with these properties is registered under the following paths:</p>
 <ul>
-<li><em><em>prefix</em>/sling/unused/img/html</em></li>
-<li><em><em>prefix</em>/sling/unused/img/txt</em></li>
-<li><em><em>prefix</em>/sling/unused/img/json</em></li>
-<li><em><em>prefix</em>/sling/unused/tab/html</em></li>
-<li><em><em>prefix</em>/sling/unused/tab/txt</em></li>
-<li><em><em>prefix</em>/sling/unused/tab/json</em></li>
+<li><code>*prefix*/sling/unused/img/html</code></li>
+<li><code>*prefix*/sling/unused/img/txt</code></li>
+<li><code>*prefix*/sling/unused/img/json</code></li>
+<li><code>*prefix*/sling/unused/tab/html</code></li>
+<li><code>*prefix*/sling/unused/tab/txt</code></li>
+<li><code>*prefix*/sling/unused/tab/json</code></li>
 </ul>
-<p>As explained the script is registered for each permutation of the resource
-types, selectors and extension. See above For an explanation of how
-<em><em>prefix</em></em> is defined.</p>
-<p><a name="ServletResolution-ScriptsareServlets"></a></p>
+<p>As explained the script 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>
 <h2 id="scripts-are-servlets">Scripts are Servlets</h2>
-<p>The Sling API defines a <em>SlingScript</em> interface which is used to
-represent (executable) scripts inside of Sling. This interface is
-implemented in the <em>scripting/resolver</em> bundle in the
-<em>DefaultSlingScript</em> class which also implements the
-<em>javax.servlet.Servlet</em>.</p>
-<p>To further simplify the access to scripts from the Resource tree, the
-<em>scripting/resolver</em> bundle registers an <em>AdapterFactory</em> to adapt
-Resources to Scripts and Servlets. In fact the adapter factory returns
-instances of the <em>DefaultSlingScript</em> class for both Scripts and
-Servlets.</p>
-<p>This functionality is used by the <em>ServletResolver.resolveServlet</em>
-implementation in the <em>sling/servlet-resolver</em> bundle: This
-implementation just looks up any Resource in the resource tree according
-its lookup algorithm (see below). The first matching Resource adapting to a
-<em>javax.servlet.Servlet</em> is used for processing the resource.</p>
-<p>So from the perspective of the Servlet resolver, scripts and servlets are
-handled exactly the same.</p>
-<p><a name="ServletResolution-ResolutionProcess"></a></p>
+<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/resolver</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/resolver</code> bundle registers an <code>AdapterFactory</code> to adapt Resources to Scripts and Servlets. In fact the adapter factory returns instances of the <code>DefaultSlingScript</code> class for both Scripts and Servlets.</p>
+<p>This functionality is used by the <code>ServletResolver.resolveServlet</code> implementation in the <code>sling/servlet-resolver</code> bundle: This implementation just looks up any Resource in the resource tree according its lookup algorithm (see below). The first matching Resource adapting to a <code>javax.servlet.Servlet</code> is used for processing the resource.</p>
+<p>So from the perspective of the Servlet resolver, scripts and servlets are handled exactly the same.</p>
 <h2 id="resolution-process">Resolution Process</h2>
-<p>The Servlet Resolution Process four elements of a
-<em>SlingHttpServletRequest</em>:</p>
+<p>The Servlet Resolution Process four elements of a <code>SlingHttpServletRequest</code>:</p>
 <ol>
-<li>The <em>resource type</em> as retrieved through
-<em>request.getResource().getResourceType()</em>. Because the resource type may
-be a node type such as <em>nt:file</em>, the resource type is mangled into a path
-by replacing any colons contained to forward slashs. Also, any backslashes
-contained are replaced to forward slashes. This should give a relative
-path. Of course a resource type may also be set to an absolute path. See
-below.</li>
-<li>The <em>request selectors</em> as retrieved through
-<em>request.getRequestPathInfo().getSelectorString()</em>. The selector string
-is turned into a realtive path by replacing all separating dots by forward
-slashes. For example the selector string <em>print.a4</em> is  converted into
-the relative path <em>print/a4</em>.</li>
-<li>The <em>request extension</em> as retrieved through
-<em>request.getRequestPathInfo().getExtension()</em> if the request method is
-<em>GET</em> or <em>HEAD</em> and the request extension is not empty.</li>
-<li>The <em>request method name</em> for any request method except <em>GET</em> or
-<em>HEAD</em> or if the request extension is empty.</li>
+<li>The <em>resource type</em> as retrieved through <code>request.getResource().getResourceType()</code>. Because the resource type may be a node type such as <em>nt:file</em>, the resource type is mangled into a path by replacing any colons contained to forward slashs. Also, any backslashes contained are replaced to forward slashes. This should give a relative path. Of course a resource type may also be set to an absolute path. See below.</li>
+<li>The <em>request selectors</em> as retrieved through <code>request.getRequestPathInfo().getSelectorString()</code>. The selector string is turned into a realtive path by replacing all separating dots by forward slashes. For example the selector string <code>print.a4</code> is  converted into the relative path <code>print/a4</code>.</li>
+<li>The <em>request extension</em> as retrieved through <code>request.getRequestPathInfo().getExtension()</code> if the request method is <em>GET</em> or <em>HEAD</em> and the request extension is not empty.</li>
+<li>The <em>request method name</em> for any request method except <em>GET</em> or <em>HEAD</em> or if the request extension is empty.</li>
 </ol>
-<p>The <em>resource type</em> is used as a (relative) parent path to the Servlet
-while the <em>request extension</em> or <em>request method</em> is used as the Servlet
-(base) name. The Servlet is retrieved from the Resource tree by calling the
-<em>ResourceResolver.getResource(String)</em> method which handles absolute and
-relative paths correctly by searching realtive paths in the configured
-search path.</p>
+<p>The <em>resource type</em> is used as a (relative) parent path to the Servlet while the <em>request extension</em> or <em>request method</em> is used as the Servlet (base) name. The Servlet is retrieved from the Resource tree by calling the <code>ResourceResolver.getResource(String)</code> method which handles absolute and relative paths correctly by searching realtive paths in the configured search path.</p>
 <p>The pseudo-code for Servlet resolution is as follows:</p>
 <div class="codehilite"><pre><span class="n">Servlet</span> <span class="n">resolveServlet</span><span class="p">(</span><span class="n">SlingHttpServletRequest</span> <span class="n">request</span><span class="p">)</span> <span class="p">{</span>
 
@@ -250,34 +201,31 @@ search path.</p>
     <span class="n">resourceType</span> <span class="o">=</span> <span class="n">resourceType</span><span class="o">.</span><span class="n">replaceAll</span><span class="p">(</span><span class="s">&quot;\\:&quot;</span><span class="p">,</span> <span class="s">&quot;/&quot;</span><span class="p">);</span>
 
     <span class="n">String</span> <span class="n">baseName</span><span class="p">;</span>
-    <span class="k">if</span> <span class="p">((</span><span class="s">&quot;GET&quot;</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getMethod</span><span class="p">())</span> <span class="o">||</span>
-</pre></div>
-
-
-<p>"HEAD".equals(request.getMethod())
-            &amp;&amp; request.getRequestPathInfo().getExtension() != null) {
-        baseName = request.getRequestPathInfo().getExtension();
-        } else {
-        baseName = request.getMethod();
-        }</p>
-<div class="codehilite"><pre>    <span class="k">if</span> <span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">()</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-    <span class="n">String</span> <span class="n">selectors</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">();</span>
-    <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">,</span> <span class="s">&#39;/&#39;</span><span class="p">);</span>
-    <span class="k">while</span> <span class="p">(</span><span class="n">selectors</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">resourceType</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">selectors</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">baseName</span><span class="p">;</span>
-        <span class="n">Servlet</span> <span class="n">servlet</span> <span class="o">=</span> <span class="n">findServletFor</span><span class="p">(</span><span class="n">path</span><span class="p">);</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">servlet</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-        <span class="k">return</span> <span class="n">servlet</span><span class="p">;</span>
-        <span class="p">}</span>
+    <span class="k">if</span> <span class="p">((</span><span class="s">&quot;GET&quot;</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getMethod</span><span class="p">())</span> <span class="o">||</span> <span class="s">&quot;HEAD&quot;</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getMethod</span><span class="p">())</span>
+            <span class="o">&amp;&amp;</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestPathInfo</span><span class="p">()</span><span class="o">.</span><span class="n">getExtension</span><span class="p">()</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">baseName</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestPathInfo</span><span class="p">()</span><span class="o">.</span><span class="n">getExtension</span><span class="p">();</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="n">baseName</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getMethod</span><span class="p">();</span>
+    <span class="p">}</span>
 
-        <span class="nb">int</span> <span class="n">lastSlash</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">lastIndexOf</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">);</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">lastSlash</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">lastSlash</span><span class="p">);</span>
-        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
-        <span class="n">selectors</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">()</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">String</span> <span class="n">selectors</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getRequestPath</span><span class="p">()</span><span class="o">.</span><span class="n">getSelectorString</span><span class="p">();</span>
+        <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">,</span> <span class="s">&#39;/&#39;</span><span class="p">);</span>
+        <span class="k">while</span> <span class="p">(</span><span class="n">selectors</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+            <span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">resourceType</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">selectors</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">baseName</span><span class="p">;</span>
+            <span class="n">Servlet</span> <span class="n">servlet</span> <span class="o">=</span> <span class="n">findServletFor</span><span class="p">(</span><span class="n">path</span><span class="p">);</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">servlet</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
+                <span class="k">return</span> <span class="n">servlet</span><span class="p">;</span>
+            <span class="p">}</span>
+
+            <span class="nb">int</span> <span class="n">lastSlash</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">lastIndexOf</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">);</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">lastSlash</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
+                <span class="n">selectors</span> <span class="o">=</span> <span class="n">selectors</span><span class="o">.</span><span class="n">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">lastSlash</span><span class="p">);</span>
+            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+                <span class="n">selectors</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+            <span class="p">}</span>
         <span class="p">}</span>
     <span class="p">}</span>
-    <span class="p">}</span>
 
     <span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">resourceType</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">baseName</span><span class="p">;</span>
     <span class="k">return</span> <span class="n">findScriptFor</span><span class="p">(</span><span class="n">path</span><span class="p">);</span>
@@ -291,69 +239,27 @@ search path.</p>
 </pre></div>
 
 
-<p><a name="ServletResolution-DefaultServlet(s)"></a></p>
 <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 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 <em>sling/servlet/default</em>.</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 and provided through a Servlet Resource provider or it may be a
-Script stored in the repository or provided by the bundle.</p>
-<p>Finally, if not even a registered default Servlet may be resolved for the
-request, because none has been registered, the <em>sling/servlet-resolve</em>
-bundle provides a fall back <em>DefaultServlet</em> with the following
-functionality:</p>
+<p>As explained in the Resolution Process section above, a default Servlet is selected if no servlet 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 and provided through a Servlet Resource provider or it may be a Script stored in the repository or provided by the bundle.</p>
+<p>Finally, if not even a registered default Servlet may be resolved for the request, because none has been registered, the <code>sling/servlet-resolve</code> bundle provides a fall back <code>DefaultServlet</code> with the following functionality:</p>
 <ul>
-<li>If the request has no extension and the Resource of the request adapts
-to an <em>InputStream</em>, the contents of the resoure is stream out as the
-response. The response content type is taken from the <em>sling.contentType</em>
-Resource meta data or derived from the Resource path. If the
-<em>sling.characterEncoding</em> Resource meta data property is set, that value
-is used as the response character encoding. Currently there is no ETag and
-modification time stamp support.</li>
-<li>Otherwise if the object has an OCM mapping, the properties of the
-mapped object are printed.</li>
+<li>If the request has no extension and the Resource of the request adapts to an <code>InputStream</code>, the contents of the resoure is stream out as the response. The response content type is taken from the <code>sling.contentType</code> Resource meta data or derived from the Resource path. If the <code>sling.characterEncoding</code> Resource meta data property is set, that value is used as the response character encoding. Currently there is no ETag and modification time stamp support.</li>
+<li>Otherwise if the object has an OCM mapping, the properties of the mapped object are printed.</li>
 <li>Otherwise just the path of the Resource is printed.</li>
 </ul>
-<p><a name="ServletResolution-ErrorHandlerServlet(s)"></a></p>
 <h2 id="error-handler-servlets">Error Handler Servlet(s)</h2>
-<p>The <em>sling/servlet-resolver</em> project also provides an implementation of
-the Sling Core <em>ErrorHandler</em> interface, which applies the same Servlet
-resolution process as used for normal request processing. Error handler
-Servlets and Scripts are looked up with the predefined resource
-<em>sling/servlet/errorhandler</em> and an error specific name:</p>
+<p>The <code>sling/servlet-resolver</code> project also provides an implementation of the Sling Core <code>ErrorHandler</code> interface, which applies the same Servlet resolution process as used for normal request processing. Error handler Servlets and Scripts are looked up with the predefined resource <code>sling/servlet/errorhandler</code> and an error specific name:</p>
 <ul>
-<li><em>HTTP Status Code Handling</em>: To handle HTTP status code as used by the
-<em>HttpServletResponse.sendError</em> methods, status code is used as the
-Servlet name. For example to provide a handler for status code 404
-(NOT_FOUND), you could create a script
-<em>prefix/sling/servlet/errorhandler/404.esp</em> or for a status code 500
-(INTERNAL_SERVER_ERRROR), you might want to register a Servlet at
-<em>prefix/sling/servlet/errorhandler/500</em>.</li>
-<li><em>Throwable Handling</em>: To handle uncaught <em>Throwables</em> the simple
-name of the <em>Throwable</em> class is used as the Servlet name. Similarly to
-the Java <em>try-catch</em> clauses the class hierarchy is supported. That is to
-handle an uncaught <em>FileNotFoundException</em>, the names
-<em>FileNotFoundException</em>, <em>IOException</em>, <em>Exception</em>, <em>Throwable</em>
-are checked for a Servlet and the first one found is then used. Again, the
-Serlvet may be a Servlet registered as an OSGi service or may be a plain
-script stored in the JCR repository or provided through some custom
-Resource provider.</li>
+<li><em>HTTP Status Code Handling</em>: To handle HTTP status code as used by the <code>HttpServletResponse.sendError</code> methods, status code is used as the Servlet name. For example to provide a handler for status code 404 (NOT<em>FOUND), you could create a script <code>prefix/sling/servlet/errorhandler/404.esp</code> or for a status code 500 (INTERNAL</em>SERVER_ERRROR), you might want to register a Servlet at <code>prefix/sling/servlet/errorhandler/500</code>.</li>
+<li><em>Throwable Handling</em>: To handle uncaught <code>Throwables</code> the simple name of the <code>Throwable</code> class is used as the Servlet name. Similarly to the Java <code>try-catch</code> clauses the class hierarchy is supported. That is to handle an uncaught <code>FileNotFoundException</code>, the names <code>FileNotFoundException</code>, <code>IOException</code>, <code>Exception</code>, <code>Throwable</code> are checked for a Servlet and the first one found is then used. Again, the Serlvet may be a Servlet registered as an OSGi service or may be a plain script stored in the JCR repository or provided through some custom Resource provider.</li>
 </ul>
-<p><a name="ServletResolution-Integrationtests"></a></p>
 <h2 id="integration-tests">Integration tests</h2>
-<p>A set of simple example servlets is available in the <a href="http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/test-services">launchpad/test-services module</a>
-. </p>
-<p>Integration tests in the <a href="http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution">launchpad/testing module</a>
- verify that these examples are correct.</p>
+<p>A set of simple example servlets is available in the <a href="">launchpad/test-services module</a>. </p>
+<p>Integration tests in the <a href="">launchpad/testing module</a> verify that these examples are correct.</p>
 <p>Contributions to these tests and examples are welcome, of course!</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



Mime
View raw message