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 2016/11/10 14:39:29 UTC

svn commit: r1000856 - in /websites/staging/sling/trunk/content: ./ documentation/tutorials-how-tos/how-to-manage-events-in-sling.html

Author: buildbot
Date: Thu Nov 10 14:39:28 2016
New Revision: 1000856

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Nov 10 14:39:28 2016
@@ -1 +1 @@
-1769079
+1769130

Modified: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html (original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html Thu Nov 10 14:39:28 2016
@@ -164,7 +164,7 @@ class lists and explains the available e
 
 
 <p>To receive the resource event, the service needs to implement the <strong>org.osgi.service.event.EventHandler</strong> interface and register it as an EventHandler service:</p>
-<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span><span class="n">immediate</span><span class="o">=</span><span class="kc">true</span><span class="o">)</span>
+<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span><span class="n">immediate</span><span class="o">=</span><span class="kc">true</span><span class="o">)</span> <span class="c1">// immediate should only be used in rare cases (see below)</span>
 <span class="nd">@Service</span><span class="o">(</span><span class="n">value</span><span class="o">=</span><span class="n">EventHandler</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
 <span class="kd">public</span> <span class="kd">class</span> <span class="nc">DropBoxService</span> <span class="kd">implements</span> <span class="n">EventHandler</span> <span class="o">{</span>
     <span class="o">...</span>
@@ -172,7 +172,7 @@ class lists and explains the available e
 </pre></div>
 
 
-<p>As this service is an event handler, we have set the immediate flag to true on the component.</p>
+<p>Usually a service should be lazy and therefore not declare itself to be immediate (in the Component annotation). However as this service is an event handler and might receive a lot of events even concurrently, it is advised to set the immediate flag to true on the component. Otherwise our event handler would be created and destroyed with every event coming in.</p>
 <p>To start the job we need a reference to the JobManager:</p>
 <div class="codehilite"><pre><span class="nd">@Reference</span>
 <span class="kd">private</span> <span class="n">JobManager</span> <span class="n">jobManager</span><span class="o">;</span>
@@ -304,7 +304,7 @@ class lists and explains the available e
 
 <p>The complete code for the <strong>DropBoxEventHandler</strong> service is available <a href="DropBoxEventHandler.java">here</a>.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1619803 by cziegeler on Fri, 22 Aug 2014 13:35:49 +0000
+        Rev. 1769130 by cziegeler on Thu, 10 Nov 2016 14:39:14 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project