You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bu...@apache.org on 2013/07/07 20:50:12 UTC

svn commit: r868731 [4/6] - in /websites/staging/sling/trunk/content: ./ documentation/ documentation/bundles/ documentation/development/ documentation/getting-started/ documentation/the-sling-engine/ documentation/the-sling-engine/authentication/ docu...

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html (original)
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/errorhandling.html Sun Jul  7 18:50:10 2013
@@ -83,11 +83,6 @@
       </div>
 
       
-      <div class="tip">
-           This page is a translated version of <a href="/site/errorhandling.html" target="sling_cwiki">/site/errorhandling.html</a>. In case of
-           doubt you might want to refer to the old page.
-      </div>
-      
       
       <h1>Errorhandling</h1>
       <p>The Sling Engine includes support for handling uncaught <code>Throwable</code> as well as rendering custom HTTP status code pages. This is implemented by expecting a (single) <code>org.apache.sling.engine.servlets.ErrorHandler</code> service to which handling of uncaught <code>Throwable</code> and HTTP status responses are delegated.</p>
@@ -125,16 +120,16 @@ the status and writing to the response s
 <li>The status code is converted to a string and used as the request extension. Any request extensions, selectors or suffixes from the actual request are ignored.</li>
 <li>The same resource type hierarchy is followed to find the script as for regular script resolution. The difference is that for error handler scripts <code>sling/servlet/errorhandler</code> is used as the implied base resource type (as opposed to <code>sling/servlet/default</code> for regular script resolution.</li>
 </ul>
-<p><em>Examples:</em></p>
+<p><strong>Examples:</strong></p>
 <ul>
 <li>An application provider my provide a default handler for the 404/NOT FOUND status. This script might be located in <code>/libs/sling/servlet/errorhandler/404.jsp</code>.</li>
 <li>An programmer might provide a handler for the 403/FORBIDDEN status in <code>/apps/sling/servlet/errorhandler/403.esp</code>.</li>
 </ul>
 <h2 id="uncaught-throwables">Uncaught Throwables</h2>
 <p>To handle uncaught Throwables the simple name (<code>Class.getSimpleName()</code>) of the <code>Throwable</code> class is used as request extension. Similarly to the Java try-catch 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.</p>
-<p><em>Example:</em>
+<p><strong>Example:</strong>
 To register a catch-all handler for any uncaught Throwables you might create a script <code>/apps/sling/servlet/errorhandler/Throwable.esp</code>.</p>
-<p><em>Note:</em> If no script or servlet to handle an uncaught <code>Throwable</code> is registered, the default handler kicks in, which sends back a 500/INTERNAL SERVER ERROR response containing the <code>Throwable</code> and the stack trace. This response is <em>not</em> handled by the HTTP Status Code handling described above because the response status is sent using <code>HttpServletResponse.setStatus(int, String)</code>. To prevent this default response you have to implement a catch-all handler for the <code>Throwable</code> class as shown in the example.</p>
+<p><strong>Note:</strong> If no script or servlet to handle an uncaught <code>Throwable</code> is registered, the default handler kicks in, which sends back a 500/INTERNAL SERVER ERROR response containing the <code>Throwable</code> and the stack trace. This response is <strong>not</strong> handled by the HTTP Status Code handling described above because the response status is sent using <code>HttpServletResponse.setStatus(int, String)</code>. To prevent this default response you have to implement a catch-all handler for the <code>Throwable</code> class as shown in the example.</p>
 <h2 id="default-handler">Default Handler</h2>
 <p>The Sling Servlet Resolver bundle provides a default error handler servlet which is used if the algorithms described above do not resolve to a handler script or servlet. The provided error handler servlet does the following:</p>
 <ul>
@@ -145,7 +140,7 @@ To register a catch-all handler for any 
 <p>Starting with Sling Servlet Resolver version 2.0.10 the default error handler servlet is looked up using the string <code>default</code> as the request extension and the provided default servlet is registered as <code>&lt;prefix&gt;/sling/servlet/errorhandler/default.servlet</code> where <prefix> is the last entry in the resource resolver search path, <code>/libs</code> by default.</p>
 <p>Thus to overwrite the default error handler servlet provide a servlet or script for the <code>default</code> extension, for example <code>/apps/sling/servlet/errorhandler/default.groovy</code>.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1499238 by fmeschbe on Wed, 3 Jul 2013 07:39:54 +0000
+        Rev. 1500501 by fmeschbe on Sun, 7 Jul 2013 18:49:51 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/eventing-and-jobs.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/eventing-and-jobs.html (original)
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/eventing-and-jobs.html Sun Jul  7 18:50:10 2013
@@ -83,17 +83,14 @@
       </div>
 
       
-      <div class="tip">
-           This page is a translated version of <a href="/site/eventing-and-jobs.html" target="sling_cwiki">/site/eventing-and-jobs.html</a>. In case of
-           doubt you might want to refer to the old page.
-      </div>
-      
       
       <h1>Eventing, Jobs, and Scheulding</h1>
       <p>Apache Sling provides some mechanisms and support for eventing, handling jobs and scheduling. </p>
-<p>To get some hands on code, you can refer to the following tutorials:
-<em> <a href="/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html">How to Manage Events in Sling</a>
-</em> <a href="/documentation/bundles/scheduler-service-commons-scheduler.html">Scheduler Service (commons scheduler)</a></p>
+<p>To get some hands on code, you can refer to the following tutorials:</p>
+<ul>
+<li><a href="/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html">How to Manage Events in Sling</a></li>
+<li><a href="/documentation/bundles/scheduler-service-commons-scheduler.html">Scheduler Service (commons scheduler)</a></li>
+</ul>
 <h3 id="possible-use-cases-for-eventing">Possible Use Cases for Eventing</h3>
 <ul>
 <li>Workflow</li>
@@ -102,11 +99,13 @@
 <li>Auditing</li>
 </ul>
 <h3 id="sources-of-events">Sources of Events</h3>
-<p>There is a variety of sources from which events can be send:
-<em> JCR observation events
-</em> Application generated events
-<em> Events from messaging systems (~JMS)
-</em> "External events"</p>
+<p>There is a variety of sources from which events can be send:</p>
+<ul>
+<li>JCR observation events</li>
+<li>Application generated events</li>
+<li>Events from messaging systems (JMS)</li>
+<li>"External events"</li>
+</ul>
 <p>The events can eiter be generated inside a current user context, e.g. when the user performs an action through the UI, or they can be out of a user context, e.g. for schedulded events. This leads to different weights of events.</p>
 <h3 id="weights-of-events">Weights of Events</h3>
 <p>We can distinguish two different weights of events, depending how they are distributed in a clustered environment:</p>
@@ -118,7 +117,7 @@
 <h3 id="basic-principles">Basic Principles</h3>
 <p>The foundation of the event mechanism is to distribute each event to every node in a clustered environment. The event distribution mechanism has no knowledge about the intent of the event and therefore is not able to make delivery decisions by itself. It is up to the sender to decide what should happen, however the sender must explicitly declare an event to be distributed. There are exceptions to "distributing everything to everywhere" as for example framework related events (bundle stopped, installed etc.) should not be distributed.</p>
 <p>The event mechanism will provide additional functionality making it easier for event receivers to decide if they should process an event. The event receiver can determine if the event is a local event or comming from a remote application node. Therefore a general rule of thumb is to process events only if they're local and just regard remote events as a FYI.</p>
-<p>The event mechanism is an <em>event</em> mechanism which should not be confused with a <em>messaging</em> mechanism. Events are received by the event mechanism and distributed to registered listeners. Concepts like durable listeners, guarantee of processing etc. are not part of the event mechanism itself. However, there will be additional support for such things, like job events.</p>
+<p>The event mechanism is an <strong>event</strong> mechanism which should not be confused with a <strong>messaging</strong> mechanism. Events are received by the event mechanism and distributed to registered listeners. Concepts like durable listeners, guarantee of processing etc. are not part of the event mechanism itself. However, there will be additional support for such things, like job events.</p>
 <p>The application should try to use application events instead of low level JCR events whereever possible. Therefore a bridging between JCR events and the event mechanism is required. However, a general "automatic" mapping will not be provided. It is up to the application to develop such a mapping on a per use case base. There might be some support to make the mapping easier.</p>
 <p>The event handling should be made as transparent to the developer as possible. Therefore the additional code for a developer to make the eventing working in a clustered environment etc. should be kept to a minimum (which will hopefully reduce possible user errors).</p>
 <h2 id="event-mechanism">Event Mechanism</h2>
@@ -132,103 +131,184 @@
 <h2 id="events">Events</h2>
 <p>The type of the event is specified by the hierarchically organized topic. In order to provide clustering of JCR repositories and clustering of the sling based application instances, each event can contain the following properties - if they are absent, a default value is assumed:</p>
 <ul>
-<li>=event.distribute= - this flag is set by the sender of an event to give a hint if the event should be distributed across instances. For example JCR observation based events are already distributed on all instances, so there is no further need to distribute them. If the flag is present, the event will be distributed. The value has currently no meaning, however the EventUtil method should be used to add this property. If the flag is absent the event is distributed locally only.</li>
-<li>=event.application= - An identifier for the current application node in the cluster. This information will be used to detect if an event has been created on different nodes. If the event has been created on the same note, the =event.application= is missing, if it is a remote event, the =event.application= contains the ID of the node, the event has been initially created.</li>
+<li><code>event.distribute</code> &ndash; this flag is set by the sender of an event to give a hint if the event should be distributed across instances. For example JCR observation based events are already distributed on all instances, so there is no further need to distribute them. If the flag is present, the event will be distributed. The value has currently no meaning, however the EventUtil method should be used to add this property. If the flag is absent the event is distributed locally only.</li>
+<li><code>event.application</code> &ndash; An identifier for the current application node in the cluster. This information will be used to detect if an event has been created on different nodes. If the event has been created on the same note, the <code>event.application</code> is missing, if it is a remote event, the <code>event.application</code> contains the ID of the node, the event has been initially created.</li>
 </ul>
-<p>While the =event.distribute= must be set by the sender of an event (if the event should be distributed), the =event.application= property is maintained by the event mechanism. Therefore a client sending an event should <em>never</em> set this information by itself. This will confuse the local event handlers and result in unexpected behaviour. On remote events the =event.application= is set by the event distribution mechanism.</p>
+<p>While the <code>event.distribute</code> must be set by the sender of an event (if the event should be distributed), the <code>event.application</code> property is maintained by the event mechanism. Therefore a client sending an event should <strong>never</strong> set this information by itself. This will confuse the local event handlers and result in unexpected behaviour. On remote events the <code>event.application</code> is set by the event distribution mechanism.</p>
 <h2 id="event-distribution-across-application-nodes-cluster">Event Distribution Across Application Nodes (Cluster)</h2>
 <p>The (local) event admin is the service distributing events locally. The Sling Distributing Event Handler is a registered event handler that is listening for events to be distributed. It distributes the events to remote application notes, the JCR repository is used for distribution. The distributing event handler writes the events into the repository, the distributing event handlers on other application nodes get notified through observation and then distribute the read events locally.</p>
-<p>As mentioned above, the client sending an event has to mark an event to be distributed in a cluster by setting the =event.distribute= in the event properties (through ~EventUtil).
-The existance of this flag allows to register an event handler for all events having this flag. The event handler will add the =event.application= information and write the event into the repository. All other application nodes have an observer registered and get notified each time a new event is added to the repository. They'll read the event from the repository, clear the =event.distribute= and send this event locally and asynchronously.</p>
-<p>An event handler receiving such an event can distinguish it by checking the =event.application= property. If the property is not available, it is a local event - if the property is available it is a remote event.</p>
-<p>This distribution mechanism has the advantage that the application nodes do not need to know each other and the distribution mechanism is independent from the used event admin implementation. Defining the filter for the =event.distribute= is also very simple.</p>
+<p>As mentioned above, the client sending an event has to mark an event to be distributed in a cluster by setting the <code>event.distribute</code> in the event properties (through EventUtil).
+The existance of this flag allows to register an event handler for all events having this flag. The event handler will add the <code>event.application</code> information and write the event into the repository. All other application nodes have an observer registered and get notified each time a new event is added to the repository. They'll read the event from the repository, clear the <code>event.distribute</code> and send this event locally and asynchronously.</p>
+<p>An event handler receiving such an event can distinguish it by checking the <code>event.application</code> property. If the property is not available, it is a local event - if the property is available it is a remote event.</p>
+<p>This distribution mechanism has the advantage that the application nodes do not need to know each other and the distribution mechanism is independent from the used event admin implementation. Defining the filter for the <code>event.distribute</code> is also very simple.</p>
 <h3 id="storing-events-in-the-repository">Storing Events in the Repository</h3>
 <p>Distributable events are stored in the repository, the repository will have a specific area (path) where all events are stored. </p>
-<p>Each event is stored as a separate node with the following properties:
-| <em>Property Name</em>     | <em>Description</em> |
-| =event:topic=       | The topic of the event |
-| =event:application= | The identifier of the application node where the event was created |
-| =event:created=     | The date and time when the event has been created (stored in the repository)
-| =event:properties=  | Serialized properties (except the =event.distribute=, but including the =event.application=) |</p>
+<p>Each event is stored as a separate node with the following properties:</p>
+<table>
+<thead>
+<tr>
+<th>Property Name</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><code>event:topic</code></td>
+<td>The topic of the event</td>
+</tr>
+<tr>
+<td><code>event:application</code></td>
+<td>The identifier of the application node where the event was created</td>
+</tr>
+<tr>
+<td><code>event:created</code></td>
+<td>The date and time when the event has been created (stored in the repository)</td>
+</tr>
+<tr>
+<td><code>event:properties</code></td>
+<td>Serialized properties (except the <code>event.distribute</code>, but including the <code>event.application</code>)</td>
+</tr>
+</tbody>
+</table>
 <p>Each application is periodically removing old events from the repository (using the scheduler).</p>
 <h2 id="jobs-guarantee-of-processing">Jobs (Guarantee of Processing)</h2>
 <p>In general, the eventing mechanism has no knowledge about the contents of an event. Therefore, it can't decide if an event must be processed by a node. As the event mechanism is a "fire event and forget about it" algorithm, there is no way for an event admin to tell if someone has processed the event.</p>
 <p>On the other hand, there are use cases where the guarantee of processing is a must and usually this comes with the requirement of processing this event exactly once. Typical examples are sending notification emails (or sms) or post processing of content (like thumbnail generation of images or documents).</p>
-<p>We will call these events jobs to make clear that someone has to do something with the event (do the job). We will use a special topic =org/apache/sling/event/job= to indicate that the event contains a job, the real topic of the event is stored in the =event.job.topic= property. When a job event (event with the topic =org/apache/sling/event/job=) is received, a new event with the topic from the property =event.job.topic= is fired.</p>
-<p>The event must have the following properties:
-| <em>Property Name</em>   | <em>Description</em> |
-| =event.job.topic= | The topic of the job |
-| =event.job.id=    | A unique identifier for this job (optional) |</p>
-<p>The job event handler listens for all job events (all events with the topic =org/apache/sling/event/job=). The event handler will write the job event into the repository (into the job area), lock it, create a new event with the topic from the property =event.job.topic= and send the job event through the event admin. When the job is finished, the event listener will unlock the node from the repository.</p>
-<p>To avoid timeouts and black listing of event handlers, the job event handler does not assume that the job has been processed if the event could be sent successfully. It is the task of the event handler to notify the job event handler that it has processed the job. In addition, the job processing should be done in the background. The =EventUtil= class has a helper method for this: =processJob(Event, JobProcessor)=. The event handler must implement the =JobProcessor= interface which consists of a single =process(Event)= method. When the event handler receives a job event, it calls =EventUtil.processJob(event, this)= and returns. The =process(Event)= method is now called in the background and when it finishes, the job event handler is notified that the job is completed.</p>
-<p>If the event handler wants to do the background processing by itself or does not need background processing at all, it must signal completition of the job by call =EventUtil.finishedJob(event)=.</p>
-<p>By default an application node is queuing the jobs which means that only one job is processed at a time. If a job can be run in parallel on one application node, the property =event.job.parallel= should be set with any value.</p>
+<p>We will call these events jobs to make clear that someone has to do something with the event (do the job). We will use a special topic <code>org/apache/sling/event/job</code> to indicate that the event contains a job, the real topic of the event is stored in the <code>event.job.topic</code> property. When a job event (event with the topic <code>org/apache/sling/event/job</code>) is received, a new event with the topic from the property <code>event.job.topic</code> is fired.</p>
+<p>The event must have the following properties:</p>
+<table>
+<thead>
+<tr>
+<th>Property Name</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><code>event.job.topic</code></td>
+<td>The topic of the job</td>
+</tr>
+<tr>
+<td><code>event.job.id</code></td>
+<td>A unique identifier for this job (optional)</td>
+</tr>
+</tbody>
+</table>
+<p>The job event handler listens for all job events (all events with the topic <code>org/apache/sling/event/job</code>). The event handler will write the job event into the repository (into the job area), lock it, create a new event with the topic from the property <code>event.job.topic</code> and send the job event through the event admin. When the job is finished, the event listener will unlock the node from the repository.</p>
+<p>To avoid timeouts and black listing of event handlers, the job event handler does not assume that the job has been processed if the event could be sent successfully. It is the task of the event handler to notify the job event handler that it has processed the job. In addition, the job processing should be done in the background. The <code>EventUtil</code> class has a helper method for this: <code>processJob(Event, JobProcessor)</code>. The event handler must implement the <code>JobProcessor</code> interface which consists of a single <code>process(Event)</code> method. When the event handler receives a job event, it calls <code>EventUtil.processJob(event, this)</code> and returns. The <code>process(Event)</code> method is now called in the background and when it finishes, the job event handler is notified that the job is completed.</p>
+<p>If the event handler wants to do the background processing by itself or does not need background processing at all, it must signal completition of the job by call <code>EventUtil.finishedJob(event)</code>.</p>
+<p>By default an application node is queuing the jobs which means that only one job is processed at a time. If a job can be run in parallel on one application node, the property <code>event.job.parallel</code> should be set with any value.</p>
 <p>The job id is optional and can be used to update or reactivate jobs.</p>
 <h3 id="storing-jobs-in-the-repository">Storing Jobs in the Repository</h3>
-<p>Jobs are stored in the repository in order to ensure that exactly one single application node is processing the job. The repository will have a specific area (path) where all jobs are stored. In order to distinguish a job which occured twice and a job which is generated at the same time on several nodes, each job can be uniquely identified by its topic (property =event.job.topic=) and the =event.job.id= property. It is up to the client who is creating the event to ensure that the =event.job.id= property is unqiue <em>and</em> identical on all application nodes. If the job id is not provided for the job, then it is up to the client to ensure that the job even is only fired once.</p>
-<p>When the job event listener tries to write a job into the repository it will check if the repository already contains a job with the given topic =event.job.topic= and =event.job.id= property. If the event has already been written by some other application node, it's not written again. If the event has been written by the same node, it will be set to active again (=event:active= will be set to true and =event:created= will be updated).</p>
-<p>Each job is stored as a separate node with the following properties:
-| <em>Property Name</em>     | <em>Description</em> |
-| =event:topic=       | The topic of the job |
-| =event:application= | The identifier of the node where the job was created |
-| =event:processor=   | The identifier of the node which processed the job |
-| =event:active=      | Indicates if this job is active and should be processed(unlocked) or is currently processed (locked) |
-| =event:created=     | The date and time when the event has been created (stored in the repository)
-| =event:id=          | The unique identifier of this job (optional).
-| =event:properties=  | Serialized properties |
-| =event:finished=    | The date and time when the job has been finished |</p>
-<p>The failover of an application node is accomplished by locking and the =event:active= flag. If a job is locked in the repository a session scoped lock is used. If this application node dies, the lock dies as well. Each application node observes the JCR locking properties and therefore gets aware of unlocked event nodes with the active flag set to true. If an application node finds such a node, it locks it, updates the =event:application= information and processes it accordingly. In this case the event gets the additional property =org/apache/sling/job/retry=. </p>
+<p>Jobs are stored in the repository in order to ensure that exactly one single application node is processing the job. The repository will have a specific area (path) where all jobs are stored. In order to distinguish a job which occured twice and a job which is generated at the same time on several nodes, each job can be uniquely identified by its topic (property <code>event.job.topic</code>) and the <code>event.job.id</code> property. It is up to the client who is creating the event to ensure that the <code>event.job.id</code> property is unqiue <strong>and</strong> identical on all application nodes. If the job id is not provided for the job, then it is up to the client to ensure that the job even is only fired once.</p>
+<p>When the job event listener tries to write a job into the repository it will check if the repository already contains a job with the given topic <code>event.job.topic</code> and <code>event.job.id</code> property. If the event has already been written by some other application node, it's not written again. If the event has been written by the same node, it will be set to active again (<code>event:active</code> will be set to true and <code>event:created</code> will be updated).</p>
+<p>Each job is stored as a separate node with the following properties:</p>
+<table>
+<thead>
+<tr>
+<th>Property Name</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td><code>event:topic</code></td>
+<td>The topic of the job</td>
+</tr>
+<tr>
+<td><code>event:application</code></td>
+<td>The identifier of the node where the job was created</td>
+</tr>
+<tr>
+<td><code>event:processor</code></td>
+<td>The identifier of the node which processed the job</td>
+</tr>
+<tr>
+<td><code>event:active</code></td>
+<td>Indicates if this job is active and should be processed(unlocked) or is currently processed (locked)</td>
+</tr>
+<tr>
+<td><code>event:created</code></td>
+<td>The date and time when the event has been created (stored in the repository)</td>
+</tr>
+<tr>
+<td><code>event:id</code></td>
+<td>The unique identifier of this job (optional).</td>
+</tr>
+<tr>
+<td><code>event:properties</code></td>
+<td>Serialized properties</td>
+</tr>
+<tr>
+<td><code>event:finished</code></td>
+<td>The date and time when the job has been finished</td>
+</tr>
+</tbody>
+</table>
+<p>The failover of an application node is accomplished by locking and the <code>event:active</code> flag. If a job is locked in the repository a session scoped lock is used. If this application node dies, the lock dies as well. Each application node observes the JCR locking properties and therefore gets aware of unlocked event nodes with the active flag set to true. If an application node finds such a node, it locks it, updates the <code>event:application</code> information and processes it accordingly. In this case the event gets the additional property <code>org/apache/sling/job/retry</code>. </p>
 <p>Each application is periodically removing old jobs from the repository (using the scheduler).</p>
 <h3 id="distribution-of-jobs">Distribution of Jobs</h3>
-<p>A job event is an event like any other. Therefore it is up to the client generating the event to decide if the event should be distributed. If the event is distributed, it will be distributed with a set =event.application= on the remote nodes. If the job event handler receives a job with the =event.application= property set, it will not try to write it into the repository. It will just broadcast this event asynchronously as a ~FYI event.</p>
-<p>If a job event is created simultanously on all application nodes, the event will not be distributed. The application node that actually has the lock on the stored job in the repository will clear the =event.application= when sending the event locally. All other application nodes will use the =event.application= stored in the repository when broadcasting the event locally.</p>
+<p>A job event is an event like any other. Therefore it is up to the client generating the event to decide if the event should be distributed. If the event is distributed, it will be distributed with a set <code>event.application</code> on the remote nodes. If the job event handler receives a job with the <code>event.application</code> property set, it will not try to write it into the repository. It will just broadcast this event asynchronously as a FYI event.</p>
+<p>If a job event is created simultanously on all application nodes, the event will not be distributed. The application node that actually has the lock on the stored job in the repository will clear the <code>event.application</code> when sending the event locally. All other application nodes will use the <code>event.application</code> stored in the repository when broadcasting the event locally.</p>
 <h2 id="usage-patterns">Usage Patterns</h2>
 <p>Based on some usage patterns, we discuss the functionality of the eventing mechanism.</p>
 <h3 id="sending-user-generated-events">Sending User Generated Events</h3>
-<p>If a user action results in an event, the event is only created on one single node in the cluster. The event object is generated and delivered to the OSGi event admin. If the =event.distribute= is not explicitly set, the event is only distributed localled.</p>
-<p>If the =event.distribute= is the, the cluster event handler will write the event into the repository. All nodes in the cluster observe the repository area where all events are stored. If a new event is written into that area, each application node will get notified. It will create the event based on the information in the repository, clear the =event.distribute= and publish the event.</p>
-<p>The flow can be described as follows:
-1. Client code generates event using OSGi API, if the =event.distribute= should be set, it is using the ~EventUtil.
-1. Client code sends the event to the (local) event admin.
-1. Event admin delivers the event locally.
-1. Clustering event handler receives the event if =event.distribute= is present
-1. # Event handler adds =event.application= and writes the event to the repository
-1. # Remote repository observers get notified through JCR observation about the new event. They distribute the event locally with the =event.application= (from the node where the event occured first) and cleared =event.distribute=.</p>
+<p>If a user action results in an event, the event is only created on one single node in the cluster. The event object is generated and delivered to the OSGi event admin. If the <code>event.distribute</code> is not explicitly set, the event is only distributed localled.</p>
+<p>If the <code>event.distribute</code> is the, the cluster event handler will write the event into the repository. All nodes in the cluster observe the repository area where all events are stored. If a new event is written into that area, each application node will get notified. It will create the event based on the information in the repository, clear the <code>event.distribute</code> and publish the event.</p>
+<p>The flow can be described as follows:</p>
+<ol>
+<li>Client code generates event using OSGi API, if the <code>event.distribute</code> should be set, it is using the EventUtil.</li>
+<li>Client code sends the event to the (local) event admin.</li>
+<li>Event admin delivers the event locally.</li>
+<li>Clustering event handler receives the event if <code>event.distribute</code> is present<ol>
+<li>Event handler adds <code>event.application</code> and writes the event to the repository</li>
+<li>Remote repository observers get notified through JCR observation about the new event. They distribute the event locally with the <code>event.application</code> (from the node where the event occured first) and cleared <code>event.distribute</code>.</li>
+</ol>
+</li>
+</ol>
 <h3 id="processing-jcr-events">Processing JCR Events</h3>
 <p>JCR events are environment generated events and therefore are sent by the repository to each node in the cluster. In general, it is advisable to not built the application on the low level repository events but to use application events. Therefore the observer of the JCR event should create an OSGi event based on the changes in the repository. A decision has to be made if the event should be a job or a plain event.</p>
-<p>The flow can be described as follows:
-1. Client registers for JCR observation
-1. JCR notifies the client for changes
-1. Client generates OSGi event based on the JCR events (the =event.distribute= will not be set), it decides if it sends this event as a job.
-1. Client code sends the event to the (local) event admin
-1. Event admin publishes the event locally
-1. The distribution event handler does not set see the event as the =event.distribute= is not set.
-1. The job event handler gets the event if it has the job topic
-1. # The job event handler adds the =event.application= property and tries to write the job to the repository
-1. ## If no job with the topic and =id= property is in the repository, the event will be written and locked.
-1. ## If an event with the topic and =id= property is in the repository then:
-1. ### If the =event.application= equals the current application node, the event is set to active (=event:active=) in the repository again and locked
-1. ### If the =event.application= does not equal the current application node, the event is not distributed locally.
-1. ## If the job could be locked in the repository, the job event handler delivers the job locally and synchronously and it unlocks the job and sets =event:active= to false afterwards.</p>
+<p>The flow can be described as follows:</p>
+<ol>
+<li>Client registers for JCR observation</li>
+<li>JCR notifies the client for changes</li>
+<li>Client generates OSGi event based on the JCR events (the <code>event.distribute</code> will not be set), it decides if it sends this event as a job.</li>
+<li>Client code sends the event to the (local) event admin</li>
+<li>Event admin publishes the event locally</li>
+<li>The distribution event handler does not set see the event as the <code>event.distribute</code> is not set.</li>
+<li>The job event handler gets the event if it has the job topic<ol>
+<li>The job event handler adds the <code>event.application</code> property and tries to write the job to the repository<ol>
+<li>If no job with the topic and <code>id</code> property is in the repository, the event will be written and locked.</li>
+<li>If an event with the topic and <code>id</code> property is in the repository then:<ol>
+<li>If the <code>event.application</code> equals the current application node, the event is set to active (<code>event:active</code>) in the repository again and locked</li>
+<li>If the <code>event.application</code> does not equal the current application node, the event is not distributed locally.</li>
+</ol>
+</li>
+<li>If the job could be locked in the repository, the job event handler delivers the job locally and synchronously and it unlocks the job and sets <code>event:active</code> to false afterwards.</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
 <h3 id="sending-scheduled-events">Sending Scheduled Events</h3>
 <p>Scheduled events are OSGi events that have been created by the environemnt. They are generated on each application node of the cluster through an own scheduler instance. Sending these events works the same as sending events based on JCR events (see above).</p>
 <p>In most use cases a scheduler will send job events to ensure that exactly one application node is processing the event.</p>
 <h3 id="receiving-osgi-events">Receiving OSGi Events</h3>
 <p>If you want to receive OSGi events, you can just follow the specification: receive it via a custom event handler which is registered on bundle start - a filter can be specified as a configuration property of the handler. </p>
-<p>As we follow the principle of distributing each event to every registered handler, the handler has to decide if it will process the event. In order to avoid multiple processing of this event in a clustered environment, the event handler should check the =event.application= property. If it is not set, it's a local event and the handler should process the event. If the =event.application= is set, it's a remote event and the handler should not process the event. This is a general rule of thumb - however, it's up to the handler to make its decision either on =event.application= or any other information.</p>
+<p>As we follow the principle of distributing each event to every registered handler, the handler has to decide if it will process the event. In order to avoid multiple processing of this event in a clustered environment, the event handler should check the <code>event.application</code> property. If it is not set, it's a local event and the handler should process the event. If the <code>event.application</code> is set, it's a remote event and the handler should not process the event. This is a general rule of thumb - however, it's up to the handler to make its decision either on <code>event.application</code> or any other information.</p>
 <p>It is advisable to perform the local event check even in a non clustered environment as it makes the migration to a cluster later on much easier and there is nearly no performance overhead caused by the check.</p>
-<p>The ~EventUtil class provides an utility method =isLocalEvent(Event)= which checks the existance of the =event.application= property and returns =true= if it is absend.</p>
+<p>The EventUtil class provides an utility method <code>isLocalEvent(Event)</code> which checks the existance of the <code>event.application</code> property and returns <code>true</code> if it is absend.</p>
 <h2 id="scheduler">Scheduler</h2>
 <p>Each Sling based application will contain a scheduler service (which is based on the Quartz open source project).</p>
 <h2 id="use-cases">Use Cases</h2>
 <h3 id="post-processing-business-processes">Post Processing (Business Processes)</h3>
 <p>A typical example for post processing (or running a business process) is sending an email or creating thumbnails and extracting meta data from the content (like we do in DAM), which we will discuss here.</p>
-<p>An appropriate JCR observer will be registered. This observer detects when new content is put into the repository or when content is changed. In these cases it creates appropriate =CONTENT<em>ADDED=, =CONTENT</em>UPDATED= OSGi events from the JCR events. In order to ensure that these actions get processed accordingly, the event is send as a job (with the special job topic, the =topic= and =id= property).</p>
+<p>An appropriate JCR observer will be registered. This observer detects when new content is put into the repository or when content is changed. In these cases it creates appropriate <code>CONTENT_ADDED</code>, <code>CONTENT_UPDATED</code> OSGi events from the JCR events. In order to ensure that these actions get processed accordingly, the event is send as a job (with the special job topic, the <code>topic</code> and <code>id</code> property).</p>
 <p>The event admin now delivers these jobs to the registered handlers. The job event handler gets notified and (simplified version) sends the contained event synchronously. One of the handlers for these events is the post processing service in DAM. The job mechanism ensures that exactly one application node is post processing and that the process has to be finished even if the application node dies during execution.</p>
 <h2 id="scheduling">Scheduling</h2>
-<p>The scheduler is a service which uses the open source Quartz library. The scheduler has methods to start jobs periodically or with a cron definition. In addition, a service either implementing =java.lang.Runnable= or =org.quartz.job= is started through the whiteboard pattern <em>if</em> it either contains a configuration property =scheduler.expression= or =scheduler.period=. The job is started with the ~PID of the service - if the service has no PID, the configuration property =scheduler.name= must be set.</p>
+<p>The scheduler is a service which uses the open source Quartz library. The scheduler has methods to start jobs periodically or with a cron definition. In addition, a service either implementing <code>java.lang.Runnable</code> or <code>org.quartz.job</code> is started through the whiteboard pattern <strong>if</strong> it either contains a configuration property <code>scheduler.expression</code> or <code>scheduler.period</code>. The job is started with the PID of the service - if the service has no PID, the configuration property <code>scheduler.name</code> must be set.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1499238 by fmeschbe on Wed, 3 Jul 2013 07:39:54 +0000
+        Rev. 1500501 by fmeschbe on Sun, 7 Jul 2013 18:49:51 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/mappings-for-resource-resolution.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/mappings-for-resource-resolution.html (original)
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/mappings-for-resource-resolution.html Sun Jul  7 18:50:10 2013
@@ -83,30 +83,29 @@
       </div>
 
       
-      <div class="tip">
-           This page is a translated version of <a href="/site/mappings-for-resource-resolution.html" target="sling_cwiki">/site/mappings-for-resource-resolution.html</a>. In case of
-           doubt you might want to refer to the old page.
-      </div>
-      
       
       <h1>Mappings for Resource Resolution</h1>
       <h2 id="configuration">Configuration</h2>
 <h3 id="properties">Properties</h3>
 <p>The mapping of request URLs to resources is mainly configured in a configuration tree which is (by default) located below <code>/etc/map</code>. The actual location can be configured with the <code>resource.resolver.map.location</code> property of the <code>org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl</code> configuration.</p>
-<p>When dealing with the new resource resolution we have a number of properties influencing the process:
-<em> <code>sling:match</code> -- This property when set on a node in the <code>/etc/map</code> tree (see below) defines a partial regular expression which is used instead of the node's name to match the incoming request. This property is only needed if the regular expression includes characters which are not valid JCR name characters. The list of invalid characters for JCR names is: /, :, [, ](), *, ', ", \| and any whitespace except blank space. In addition a name without a name space may not be <code>.</code> or <code>..</code> and a blank space is only allowed inside the name.
-</em> <code>sling:redirect</code> -- This property when set on a node in the <code>/etc/map</code> tree (see below) causes a redirect response to be sent to the client, which causes the client to send in a new request with the modified location. The value of this property is applied to the actual request and sent back as the value of <code>Location</code> response header.
-<em> <code>sling:status</code> -- This property defines the HTTP status code sent to the client with the <code>sling:redirect</code> response. If this property is not set, it defaults to 302 (Found). Other status codes supported are 300 (Multiple Choices), 301 (Moved Permanently), 303 (See Other), and 307 (Temporary Redirect).
-</em> <code>sling:internalRedirect</code> -- This property when set on a node in the <code>/etc/map</code> tree (see below) causes the current path to be modified internally to continue with resource resolution.
-* <code>sling:alias</code> -- The property may be set on any resource to indicate an alias name for the resource. For example the resource <code>/content/visitors</code> may have the <code>sling:alias</code> property set to <code>besucher</code> allowing the resource to be addressed in an URL as <code>/content/besucher</code>.</p>
+<p>When dealing with the new resource resolution we have a number of properties influencing the process:</p>
+<ul>
+<li><code>sling:match</code> &ndash; This property when set on a node in the <code>/etc/map</code> tree (see below) defines a partial regular expression which is used instead of the node's name to match the incoming request. This property is only needed if the regular expression includes characters which are not valid JCR name characters. The list of invalid characters for JCR names is: /, :, [, ](), *, ', ", \| and any whitespace except blank space. In addition a name without a name space may not be <code>.</code> or <code>..</code> and a blank space is only allowed inside the name.</li>
+<li><code>sling:redirect</code> &ndash; This property when set on a node in the <code>/etc/map</code> tree (see below) causes a redirect response to be sent to the client, which causes the client to send in a new request with the modified location. The value of this property is applied to the actual request and sent back as the value of <code>Location</code> response header.</li>
+<li><code>sling:status</code> &ndash; This property defines the HTTP status code sent to the client with the <code>sling:redirect</code> response. If this property is not set, it defaults to 302 (Found). Other status codes supported are 300 (Multiple Choices), 301 (Moved Permanently), 303 (See Other), and 307 (Temporary Redirect).</li>
+<li><code>sling:internalRedirect</code> &ndash; This property when set on a node in the <code>/etc/map</code> tree (see below) causes the current path to be modified internally to continue with resource resolution.</li>
+<li><code>sling:alias</code> &ndash; The property may be set on any resource to indicate an alias name for the resource. For example the resource <code>/content/visitors</code> may have the <code>sling:alias</code> property set to <code>besucher</code> allowing the resource to be addressed in an URL as <code>/content/besucher</code>.</li>
+</ul>
 <h3 id="node-types">Node Types</h3>
-<p>To ease with the definition of redirects and aliases, the following node types are defined:
-<em> <code>sling:ResourceAlias</code> -- This mixin node type defines the <code>sling:alias</code> property and may be attached to any node, which does not otherwise allow setting a property named <code>sling:alias</code>
-</em> <code>sling:MappingSpec</code> -- This mixin node type defines the <code>sling:match</code>, <code>sling:redirect</code>, <code>sling:status</code>, and <code>sling:internaleRedirect</code> properties to define a matching and redirection inside the <code>/etc/map</code> hierarchy.
-* <code>sling:Mapping</code> -- Primary node type which may be used to easily construct entries in the <code>/etc/map</code> tree. The node type extends the <code>sling:MappingSpec</code> mixin node type to allow setting the required matching and redirection. In addition the <code>sling:Resource</code> mixin node type is extended to allow setting a resource type and the <code>nt:hierarchyNode</code> node type is extended to allow locating nodes of this node type below <code>nt:folder</code> nodes.</p>
+<p>To ease with the definition of redirects and aliases, the following node types are defined:</p>
+<ul>
+<li><code>sling:ResourceAlias</code> &ndash; This mixin node type defines the <code>sling:alias</code> property and may be attached to any node, which does not otherwise allow setting a property named <code>sling:alias</code></li>
+<li><code>sling:MappingSpec</code> &ndash; This mixin node type defines the <code>sling:match</code>, <code>sling:redirect</code>, <code>sling:status</code>, and <code>sling:internaleRedirect</code> properties to define a matching and redirection inside the <code>/etc/map</code> hierarchy.</li>
+<li><code>sling:Mapping</code> &ndash; Primary node type which may be used to easily construct entries in the <code>/etc/map</code> tree. The node type extends the <code>sling:MappingSpec</code> mixin node type to allow setting the required matching and redirection. In addition the <code>sling:Resource</code> mixin node type is extended to allow setting a resource type and the <code>nt:hierarchyNode</code> node type is extended to allow locating nodes of this node type below <code>nt:folder</code> nodes.</li>
+</ul>
 <p>Note, that these node types only help setting the properties. The implementation itself only cares for the properties and their values and not for any of these node types.</p>
 <h2 id="namespace-mangling">Namespace Mangling</h2>
-<p>There are systems accessing Sling, which have a hard time handling URLs containing colons -- <code>:</code> -- in the path part correctly. Since URLs produced and supported by Sling may colons because JCR Item based resources may be namespaced (e.g. <code>jcr:content</code>), a special namespace mangling feature is built into the <code>ResourceResolver.resolve</code> and <code>ResourceResolver(map)</code> methods.</p>
+<p>There are systems accessing Sling, which have a hard time handling URLs containing colons &ndash; <code>:</code> &ndash; in the path part correctly. Since URLs produced and supported by Sling may colons because JCR Item based resources may be namespaced (e.g. <code>jcr:content</code>), a special namespace mangling feature is built into the <code>ResourceResolver.resolve</code> and <code>ResourceResolver(map)</code> methods.</p>
 <p>Namespace mangling operates such, that any namespace prefix identified in resource path to be mapped as an URL in the <code>map</code> methods is modified such that the prefix is enclosed in underscores and the colon removed.</p>
 <p><em>Example</em>: The path <code>/content/*a*sample/jcr:content/jcr:data.png</code> is modified by namespace mangling in the <code>map</code> method to get at <code>/content/*a*sample/*jcr*content/*jcr*data.png</code>.</p>
 <p>Conversely the <code>resolve</code> methods must undo such namespace mangling to get back at the resource path. This is simple done by modifying any path such that segments starting with an underscore enclosed prefix are changed by removing the underscores and adding a colon after the prefix. There is one catch, tough: Due to the way the SlingPostServlets automatically generates names, there may be cases where the actual name would be matching this mechanism. Therefore only prefixes are modified which are actually namespace prefixes.</p>
@@ -120,102 +119,192 @@
 <div class="codehilite"><pre><span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">map</span>
       <span class="o">+--</span> <span class="n">http</span>
            <span class="o">+--</span> <span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="p">.</span>80
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">redirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">/</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">redirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">/</span>&quot;
            <span class="o">+--</span> <span class="n">www</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="p">.</span>80
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">example</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">example</span>&quot;
            <span class="o">+--</span> <span class="n">any_example</span><span class="p">.</span><span class="n">com</span><span class="p">.</span>80
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">match</span> <span class="p">=</span> &quot;<span class="p">.</span><span class="o">+\</span><span class="p">.</span><span class="n">example</span><span class="o">\</span><span class="p">.</span><span class="n">com</span><span class="o">\</span><span class="p">.</span>80&quot;
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">redirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">/</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">match</span> <span class="p">=</span> &quot;<span class="p">.</span><span class="o">+\</span><span class="p">.</span><span class="n">example</span><span class="o">\</span><span class="p">.</span><span class="n">com</span><span class="o">\</span><span class="p">.</span>80&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">redirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">/</span>&quot;
            <span class="o">+--</span> <span class="n">localhost_any</span>
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">match</span> <span class="p">=</span> &quot;<span class="n">localhost</span><span class="o">\.\</span><span class="n">d</span><span class="o">*</span>&quot;
-                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">content</span>&quot;
-                <span class="o">+--</span> <span class="n">cgi</span><span class="o">-</span><span class="n">bin</span>
-                     <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">scripts</span>&quot;
-                <span class="o">+--</span> <span class="n">gateway</span>
-                     <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">gbiv</span><span class="p">.</span><span class="n">com</span>&quot;
-                <span class="o">+--</span> <span class="p">(</span><span class="n">stories</span><span class="p">)</span>
-                     <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">anecdotes</span><span class="o">/</span>$1&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">match</span> <span class="p">=</span> &quot;<span class="n">localhost</span><span class="o">\.\</span><span class="n">d</span><span class="o">*</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">content</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">cgi</span><span class="o">-</span><span class="n">bin</span>
+           <span class="o">|</span>    <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">scripts</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="n">gateway</span>
+           <span class="o">|</span>    <span class="o">|</span>    <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">gbiv</span><span class="p">.</span><span class="n">com</span>&quot;
+           <span class="o">|</span>    <span class="o">+--</span> <span class="p">(</span><span class="n">stories</span><span class="p">)</span>
+           <span class="o">|</span>         <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">anecdotes</span><span class="o">/</span>$1&quot;
+           <span class="o">+--</span> <span class="n">regexmap</span>
+                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">match</span> <span class="p">=</span> &quot;$1<span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">/</span>$2&quot;
+                <span class="o">+--</span> <span class="n">sling</span><span class="p">:</span><span class="n">internalRedirect</span> <span class="p">=</span> &quot;<span class="o">/</span><span class="n">content</span><span class="o">/</span><span class="p">([</span>^<span class="o">/</span><span class="p">]</span><span class="o">+</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="o">.*</span><span class="p">)</span>&quot;
 </pre></div>
 
 
-<p>This would define the following mapping entries:
-| Regular Expression | Redirect | Internal | Description |
-|--|--|--|--|
-| http/example.com.80 | <a href="http://www.example.com">http://www.example.com</a> | no | Redirect all requests to the Second Level Domain to www |
-| http/www.example.com.80 | /example | yes | Prefix the URI paths of the requests sent to this domain with the string <code>/example</code> |
-| http/.+.example.com.80 | <a href="http://www.example.com">http://www.example.com</a> | no | Redirect all requests to sub domains to www. The actual regular expression for the host.port segment is taken from the <code>sling:match</code> property. |
-| http/localhost.\d* | /content | yes | Prefix the URI paths with <code>/content</code> for requests to localhost, regardless of actual port the request was received on. This entry only applies if the URI path does not start with <code>/cgi-bin</code>, <code>gateway</code> or <code>stories</code> because there are longer match entries. The actual regular expression for the host.port segment is taken from the <code>sling:match</code> property. |
-| http/localhost.\d<em>/cgi-bin | /scripts | yes | Replace the <code>/cgi-bin</code> prefix in the URI path with <code>/scripts</code> for requests to localhost, regardless of actual port the request was received on. |
-| http/localhost.\d</em>/gateway | <a href="http://gbiv.com">http://gbiv.com</a> | yes | Replace the <code>/gateway</code> prefix in the URI path with <code>[http://gbiv.com]</code> for requests to localhost, regardless of actual port the request was received on. |
-| http/localhost.\d*/(stories) | /anecdotes/stories | yes | Prepend the URI paths starting with <code>/stories</code> with <code>/anecdotes</code> for requests to localhost, regardless of actual port the request was received on. |</p>
+<p>This would define the following mapping entries:</p>
+<table>
+<thead>
+<tr>
+<th>Regular Expression</th>
+<th>Redirect</th>
+<th>Internal</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>http/example.com.80</td>
+<td>http://www.example.com</td>
+<td>no</td>
+<td>Redirect all requests to the Second Level Domain to www</td>
+</tr>
+<tr>
+<td>http/www.example.com.80</td>
+<td>/example</td>
+<td>yes</td>
+<td>Prefix the URI paths of the requests sent to this domain with the string <code>/example</code></td>
+</tr>
+<tr>
+<td>http/.+.example.com.80</td>
+<td>http://www.example.com</td>
+<td>no</td>
+<td>Redirect all requests to sub domains to www. The actual regular expression for the host.port segment is taken from the <code>sling:match</code> property.</td>
+</tr>
+<tr>
+<td>http/localhost.\d*</td>
+<td>/content</td>
+<td>yes</td>
+<td>Prefix the URI paths with <code>/content</code> for requests to localhost, regardless of actual port the request was received on. This entry only applies if the URI path does not start with <code>/cgi-bin</code>, <code>gateway</code> or <code>stories</code> because there are longer match entries. The actual regular expression for the host.port segment is taken from the <code>sling:match</code> property.</td>
+</tr>
+<tr>
+<td>http/localhost.\d*/cgi-bin</td>
+<td>/scripts</td>
+<td>yes</td>
+<td>Replace the <code>/cgi-bin</code> prefix in the URI path with <code>/scripts</code> for requests to localhost, regardless of actual port the request was received on.</td>
+</tr>
+<tr>
+<td>http/localhost.\d*/gateway</td>
+<td>http://gbiv.com</td>
+<td>yes</td>
+<td>Replace the <code>/gateway</code> prefix in the URI path with <code>http://gbiv.com</code> for requests to localhost, regardless of actual port the request was received on.</td>
+</tr>
+<tr>
+<td>http/localhost.\d*/(stories)</td>
+<td>/anecdotes/stories</td>
+<td>yes</td>
+<td>Prepend the URI paths starting with <code>/stories</code> with <code>/anecdotes</code> for requests to localhost, regardless of actual port the request was received on.</td>
+</tr>
+</tbody>
+</table>
 <h3 id="regular-expression-matching">Regular Expression matching</h3>
 <p>As said above the mapping entries are regular expressions which are matched against path. As such these regular expressions may also contain capturing groups as shown in the example above: <code>http/localhost\.\d*/(stories)</code>. After matching the path against the regular expression, the replacement pattern is applied which allows references back to the capturing groups.</p>
 <p>To illustrate the matching and replacement is applied according to the following pseudo code:</p>
-<div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="p">=</span> <span class="n">request</span><span class="p">.</span><span class="n">getScheme</span> <span class="o">+</span> &quot;<span class="o">/</span>&quot; <span class="o">+</span> <span class="n">request</span><span class="p">.</span><span class="n">getServerName</span><span class="p">()</span> <span class="o">+</span> &quot;<span class="p">.</span>&quot; <span class="o">+</span> <span class="n">request</span><span class="p">.</span><span class="n">getServerPort</span><span class="p">()</span> <span class="o">+</span> &quot;<span class="o">/</span>&quot; <span class="o">+</span> <span class="n">request</span><span class="p">.</span><span class="n">getPathInfo</span><span class="p">();</span>
-<span class="n">String</span> <span class="n">result</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span>
-<span class="k">for</span> <span class="p">(</span><span class="n">MapEntry</span> <span class="n">entry</span><span class="p">:</span> <span class="n">mapEntries</span><span class="p">)</span> <span class="p">{</span>
-    <span class="n">Matcher</span> <span class="n">matcher</span> <span class="p">=</span> <span class="n">entry</span><span class="p">.</span><span class="n">pattern</span><span class="p">.</span><span class="n">matcher</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">matcher</span><span class="p">.</span><span class="nb">find</span><span class="p">())</span> <span class="p">{</span>
-        <span class="n">StringBuffer</span> <span class="n">buf</span> <span class="p">=</span> <span class="n">new</span> <span class="n">StringBuffer</span><span class="p">();</span>
-        <span class="n">matcher</span><span class="p">.</span><span class="n">appendReplacement</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span> <span class="n">entry</span><span class="p">.</span><span class="n">getRedirect</span><span class="p">());</span>
-        <span class="n">matcher</span><span class="p">.</span><span class="n">appendTail</span><span class="p">(</span><span class="n">buf</span><span class="p">);</span>
-        <span class="n">result</span> <span class="p">=</span> <span class="n">buf</span><span class="p">.</span><span class="n">toString</span><span class="p">();</span>
-        <span class="k">break</span><span class="p">;</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="na">getScheme</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">request</span><span class="o">.</span><span class="na">getServerName</span><span class="o">()</span>
+        <span class="o">+</span> <span class="s">&quot;.&quot;</span> <span class="o">+</span> <span class="n">request</span><span class="o">.</span><span class="na">getServerPort</span><span class="o">()</span> <span class="o">+</span> <span class="s">&quot;/&quot;</span> <span class="o">+</span> <span class="n">request</span><span class="o">.</span><span class="na">getPathInfo</span><span class="o">();</span>
+<span class="n">String</span> <span class="n">result</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+<span class="k">for</span> <span class="o">(</span><span class="n">MapEntry</span> <span class="nl">entry:</span> <span class="n">mapEntries</span><span class="o">)</span> <span class="o">{</span>
+    <span class="n">Matcher</span> <span class="n">matcher</span> <span class="o">=</span> <span class="n">entry</span><span class="o">.</span><span class="na">pattern</span><span class="o">.</span><span class="na">matcher</span><span class="o">(</span><span class="n">path</span><span class="o">);</span>
+    <span class="k">if</span> <span class="o">(</span><span class="n">matcher</span><span class="o">.</span><span class="na">find</span><span class="o">())</span> <span class="o">{</span>
+        <span class="n">StringBuffer</span> <span class="n">buf</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringBuffer</span><span class="o">();</span>
+        <span class="n">matcher</span><span class="o">.</span><span class="na">appendReplacement</span><span class="o">(</span><span class="n">buf</span><span class="o">,</span> <span class="n">entry</span><span class="o">.</span><span class="na">getRedirect</span><span class="o">());</span>
+        <span class="n">matcher</span><span class="o">.</span><span class="na">appendTail</span><span class="o">(</span><span class="n">buf</span><span class="o">);</span>
+        <span class="n">result</span> <span class="o">=</span> <span class="n">buf</span><span class="o">.</span><span class="na">toString</span><span class="o">();</span>
+        <span class="k">break</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>At the end of the loop, <code>result</code> contains the mapped path or <code>null</code> if no entry matches the request <code>path</code>.</p>
-<p><em>NOTE:</em> Since the entries in the <code>/etc/map</code> are also used to reverse map any resource paths to URLs, using regular expressions in the Root Level Mappings prevent the respective entries from being used for reverse mappings. Therefor, it is strongly recommended to not use regular expression matching, unless you have a strong need.</p>
+<p><strong>NOTE:</strong> Since the entries in the <code>/etc/map</code> are also used to reverse map any resource paths to URLs, using regular expressions in the Root Level Mappings prevent the respective entries from being used for reverse mappings. Therefor, it is strongly recommended to not use regular expression matching, unless you have a strong need.</p>
 <h3 id="redirection-values">Redirection Values</h3>
 <p>The result of matching the request path and getting the redirection is either a path into the resource tree or another URL. If the result is an URL, it is converted into a path again and matched against the mapping entries. This may be taking place repeatedly until an absolute or relative path into the resource tree results.</p>
 <p>The following pseudo code summarizes this behaviour:</p>
-<div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="p">=</span> <span class="p">....;</span>
-<span class="n">String</span> <span class="n">result</span> <span class="p">=</span> <span class="n">path</span><span class="p">;</span>
-<span class="n">do</span> <span class="p">{</span>
-    <span class="n">result</span> <span class="p">=</span> <span class="n">applyMapEntries</span><span class="p">(</span><span class="n">result</span><span class="p">);</span>
-<span class="p">}</span> <span class="k">while</span> <span class="p">(</span><span class="n">isURL</span><span class="p">(</span><span class="n">result</span><span class="p">));</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="o">....;</span>
+<span class="n">String</span> <span class="n">result</span> <span class="o">=</span> <span class="n">path</span><span class="o">;</span>
+<span class="k">do</span> <span class="o">{</span>
+    <span class="n">result</span> <span class="o">=</span> <span class="n">applyMapEntries</span><span class="o">(</span><span class="n">result</span><span class="o">);</span>
+<span class="o">}</span> <span class="k">while</span> <span class="o">(</span><span class="n">isURL</span><span class="o">(</span><span class="n">result</span><span class="o">));</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>As soon as the result of applying the map entries is an absolute or relative path (or no more map entries match), Root Level Mapping terminates and the next step in resource resolution, resource tree access, takes place.</p>
 <h2 id="resource-tree-access">Resource Tree Access</h2>
-<p>The result of Root Level Mapping is an absolute or relative path to a resource. If the path is relative -- e.g. <code>myproject/docroot/sample.gif</code> -- the resource resolver search path (<code>ResourceResolver.getSearchPath()</code> is used to build absolute paths and resolve the resource. In this case the first resource found is used. If the result of Root Level Mapping is an absolute path, the path is used as is.</p>
-<p>Accessing the resource tree after applying the Root Level Mappings has four options:
-<em> Check whether the path addresses a so called Star Resource. A Star Resource is a resource whose path ends with or contains <code>/\*</code>. Such resources are used by the <code>SlingPostServlet</code> to create new content below an existing resource. If the path after Root Level Mapping is absolute, it is made absolute by prepending the first search path entry.
-</em> Check whether the path exists in the repository. if the path is absolute, it is tried directly. Otherwise the search path entries are prepended  to the path until a resource is found or the search path is exhausted without finding a resource.
-<em> Drill down the resource tree starting from the root, optionally using the search path until a resource is found.
-</em> If no resource can be resolved, a Missing Resource is returned.</p>
+<p>The result of Root Level Mapping is an absolute or relative path to a resource. If the path is relative &ndash; e.g. <code>myproject/docroot/sample.gif</code> &ndash; the resource resolver search path (<code>ResourceResolver.getSearchPath()</code> is used to build absolute paths and resolve the resource. In this case the first resource found is used. If the result of Root Level Mapping is an absolute path, the path is used as is.</p>
+<p>Accessing the resource tree after applying the Root Level Mappings has four options:</p>
+<ul>
+<li>Check whether the path addresses a so called Star Resource. A Star Resource is a resource whose path ends with or contains <code>/\*</code>. Such resources are used by the <code>SlingPostServlet</code> to create new content below an existing resource. If the path after Root Level Mapping is absolute, it is made absolute by prepending the first search path entry.</li>
+<li>Check whether the path exists in the repository. if the path is absolute, it is tried directly. Otherwise the search path entries are prepended  to the path until a resource is found or the search path is exhausted without finding a resource.</li>
+<li>Drill down the resource tree starting from the root, optionally using the search path until a resource is found.</li>
+<li>If no resource can be resolved, a Missing Resource is returned.</li>
+</ul>
 <h3 id="drilling-down-the-resource-tree">Drilling Down the Resource Tree</h3>
 <p>Drilling down the resource tree starts at the root and for each segment in the path checks whether a child resource of the given name exists or not. If not, a child resource is looked up, which has a <code>sling:alias</code> property whose value matches the given name. If neither exists, the search is terminated and the resource cannot be resolved.</p>
 <p>The following pseudo code shows this algorithm assuming the path is absolute:</p>
-<div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="p">=</span> <span class="p">...;</span> <span class="o">//</span> <span class="n">the</span> <span class="n">absolute</span> <span class="n">path</span>
-<span class="n">Resource</span> <span class="n">current</span> <span class="p">=</span> <span class="n">getResource</span><span class="p">(</span>&quot;<span class="o">/</span>&quot;<span class="p">);</span>
-<span class="n">String</span><span class="p">[]</span> <span class="n">segments</span> <span class="p">=</span> <span class="n">path</span><span class="p">.</span><span class="n">split</span><span class="p">(</span>&quot;<span class="o">/</span>&quot;<span class="p">);</span>
-<span class="k">for</span> <span class="p">(</span><span class="n">String</span> <span class="n">segment</span><span class="p">:</span> <span class="n">segments</span><span class="p">)</span> <span class="p">{</span>
-    <span class="n">Resource</span> <span class="n">child</span> <span class="p">=</span> <span class="n">getResource</span><span class="p">(</span><span class="n">current</span><span class="p">,</span> <span class="n">segment</span><span class="p">);</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">child</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">Iterator</span><span class="o">&lt;</span><span class="n">Resource</span><span class="o">&gt;</span> <span class="n">children</span> <span class="p">=</span> <span class="n">listChildren</span><span class="p">(</span><span class="n">current</span><span class="p">);</span>
-        <span class="n">current</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span>
-        <span class="k">while</span> <span class="p">(</span><span class="n">children</span><span class="p">.</span><span class="n">hasNext</span><span class="p">())</span> <span class="p">{</span>
-            <span class="n">child</span> <span class="p">=</span> <span class="n">children</span><span class="p">.</span><span class="n">next</span><span class="p">();</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">segment</span><span class="p">.</span><span class="n">equals</span><span class="p">(</span><span class="n">getSlingAlias</span><span class="p">(</span><span class="n">child</span><span class="p">)))</span> <span class="p">{</span>
-                <span class="n">current</span> <span class="p">=</span> <span class="n">child</span><span class="p">;</span>
-                <span class="k">break</span><span class="p">;</span>
-            <span class="p">}</span>
-        <span class="p">}</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">current</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-            <span class="o">//</span> <span class="n">fail</span>
-            <span class="k">break</span><span class="p">;</span>
-        <span class="p">}</span>
-    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
-        <span class="n">current</span> <span class="p">=</span> <span class="n">child</span><span class="p">;</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">String</span> <span class="n">path</span> <span class="o">=</span> <span class="o">...;</span> <span class="c1">// the absolute path</span>
+<span class="n">Resource</span> <span class="n">current</span> <span class="o">=</span> <span class="n">getResource</span><span class="o">(</span><span class="s">&quot;/&quot;</span><span class="o">);</span>
+<span class="n">String</span><span class="o">[]</span> <span class="n">segments</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="na">split</span><span class="o">(</span><span class="s">&quot;/&quot;</span><span class="o">);</span>
+<span class="k">for</span> <span class="o">(</span><span class="n">String</span> <span class="nl">segment:</span> <span class="n">segments</span><span class="o">)</span> <span class="o">{</span>
+    <span class="n">Resource</span> <span class="n">child</span> <span class="o">=</span> <span class="n">getResource</span><span class="o">(</span><span class="n">current</span><span class="o">,</span> <span class="n">segment</span><span class="o">);</span>
+    <span class="k">if</span> <span class="o">(</span><span class="n">child</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
+        <span class="n">Iterator</span><span class="o">&lt;</span><span class="n">Resource</span><span class="o">&gt;</span> <span class="n">children</span> <span class="o">=</span> <span class="n">listChildren</span><span class="o">(</span><span class="n">current</span><span class="o">);</span>
+        <span class="n">current</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+        <span class="k">while</span> <span class="o">(</span><span class="n">children</span><span class="o">.</span><span class="na">hasNext</span><span class="o">())</span> <span class="o">{</span>
+            <span class="n">child</span> <span class="o">=</span> <span class="n">children</span><span class="o">.</span><span class="na">next</span><span class="o">();</span>
+            <span class="k">if</span> <span class="o">(</span><span class="n">segment</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="n">getSlingAlias</span><span class="o">(</span><span class="n">child</span><span class="o">)))</span> <span class="o">{</span>
+                <span class="n">current</span> <span class="o">=</span> <span class="n">child</span><span class="o">;</span>
+                <span class="k">break</span><span class="o">;</span>
+            <span class="o">}</span>
+        <span class="o">}</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">current</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
+            <span class="c1">// fail</span>
+            <span class="k">break</span><span class="o">;</span>
+        <span class="o">}</span>
+    <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
+        <span class="n">current</span> <span class="o">=</span> <span class="n">child</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
+</td></tr></table>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1499238 by fmeschbe on Wed, 3 Jul 2013 07:39:54 +0000
+        Rev. 1500501 by fmeschbe on Sun, 7 Jul 2013 18:49:51 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/request-listeners.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/request-listeners.html (original)
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/request-listeners.html Sun Jul  7 18:50:10 2013
@@ -83,43 +83,64 @@
       </div>
 
       
-      <div class="tip">
-           This page is a translated version of <a href="/site/request-listeners.html" target="sling_cwiki">/site/request-listeners.html</a>. In case of
-           doubt you might want to refer to the old page.
-      </div>
-      
       
       <h1>Request Listeners</h1>
       <p>Sling provides the possibility to "listen" to a request processed by the Sling Engine (<code>SlingMainServlet</code>). To get notified you implement the service interface <code>org.apache.sling.api.request.SlingRequestListener</code>.</p>
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>SlingRequestListener</B></DIV><DIV class="codeContent panelContent">
-    public interface SlingRequestListener {
-
-        static final String SERVICE_NAME = "org.apache.sling.api.request.SlingRequestListener"; 
-
-        /**
-         * This method is called from the Sling application for every
-         * <code>EventType</code> appearing during the dispatching of
-         * a Sling request  
-         * 
-         * @param sre the object representing the event
-         * 
-         * @see org.apache.sling.api.request.SlingRequestEvent.EventType
-         */
-        public void onEvent( SlingRequestEvent sre );
-    }
-
-
-There are no special properties to set. 
-
-## Supported types of events
-
-At the moment you will get two different types of `SlingRequestEvent`:
-| events types (`SlingRequestEvent.EventType`) | point in time |
-|--|--|
-| EVENT_INIT | after entering the `service` method in `SlingMainServlet`. Note that this will be *after* the `handleSecurity` call. |
-| EVENT_DESTROY | at the end of the `service` method in `SlingMainServlet` |
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">interface</span> <span class="nc">SlingRequestListener</span> <span class="o">{</span>
+
+    <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">SERVICE_NAME</span> <span class="o">=</span> <span class="s">&quot;org.apache.sling.api.request.SlingRequestListener&quot;</span><span class="o">;</span>
+
+    <span class="cm">/**</span>
+<span class="cm">     * This method is called from the Sling application for every</span>
+<span class="cm">     * &lt;code&gt;EventType&lt;/code&gt; appearing during the dispatching of</span>
+<span class="cm">     * a Sling request  </span>
+<span class="cm">     * </span>
+<span class="cm">     * @param sre the object representing the event</span>
+<span class="cm">     * </span>
+<span class="cm">     * @see org.apache.sling.api.request.SlingRequestEvent.EventType</span>
+<span class="cm">     */</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">onEvent</span><span class="o">(</span> <span class="n">SlingRequestEvent</span> <span class="n">sre</span> <span class="o">);</span>
+<span class="o">}</span>
+</pre></div>
+</td></tr></table>
+
+<p>There are no special properties to set. </p>
+<h2 id="supported-types-of-events">Supported types of events</h2>
+<p>At the moment you will get two different types of <code>SlingRequestEvent</code>:</p>
+<table>
+<thead>
+<tr>
+<th>events types (<code>SlingRequestEvent.EventType</code>)</th>
+<th>point in time</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>EVENT_INIT</td>
+<td>after entering the <code>service</code> method in <code>SlingMainServlet</code>. Note that this will be <strong>after</strong> the <code>handleSecurity</code> call.</td>
+</tr>
+<tr>
+<td>EVENT_DESTROY</td>
+<td>at the end of the <code>service</code> method in <code>SlingMainServlet</code></td>
+</tr>
+</tbody>
+</table>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1499238 by fmeschbe on Wed, 3 Jul 2013 07:39:54 +0000
+        Rev. 1500501 by fmeschbe on Sun, 7 Jul 2013 18:49:51 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project