You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/11/10 14:39:14 UTC

svn commit: r1769130 - /sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext

Author: cziegeler
Date: Thu Nov 10 14:39:14 2016
New Revision: 1769130

URL: http://svn.apache.org/viewvc?rev=1769130&view=rev
Log:
Clarify immediate attribute

Modified:
    sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext

Modified: sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext?rev=1769130&r1=1769129&r2=1769130&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext (original)
+++ sling/site/trunk/content/documentation/tutorials-how-tos/how-to-manage-events-in-sling.mdtext Thu Nov 10 14:39:14 2016
@@ -58,13 +58,13 @@ To start a job, the *JobManager* service
 To receive the resource event, the service needs to implement the **org.osgi.service.event.EventHandler** interface and register it as an EventHandler service:
 
     :::java
-    @Component(immediate=true)
+    @Component(immediate=true) // immediate should only be used in rare cases (see below)
     @Service(value=EventHandler.class)
     public class DropBoxService implements EventHandler {
         ...
     }
 
-As this service is an event handler, we have set the immediate flag to true on the component.
+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.
 
 To start the job we need a reference to the JobManager: