incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r820191 [1/2] - in /websites/staging/sling/trunk/content: ./ documentation/tutorials-how-tos/
Date Mon, 04 Jun 2012 07:41:24 GMT
Author: buildbot
Date: Mon Jun  4 07:41:23 2012
New Revision: 820191

Log:
Staging update by buildbot for sling

Added:
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxEventHandler.java
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxService.java
Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/getting-resources-and-properties-in-sling.html
    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/installing-and-upgrading-bundles.html
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Jun  4 07:41:23 2012
@@ -1 +1 @@
-1345729
+1345850

Added: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxEventHandler.java
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxEventHandler.java (added)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxEventHandler.java Mon Jun  4 07:41:23 2012
@@ -0,0 +1,92 @@
+
+package mypackage;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.event.EventUtil;
+import org.apache.sling.event.JobProcessor;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>DropBoxEventHandler</code> moves files posted to /tmp/dropbox to the appropriate locations:
+ * images (MIME type: image/png) to /dropbox/images/
+ * music (MIME type: audio/mpeg) to /dropbox/music/
+ * movies (MIME type: video/x-msvideo) to /dropbox/movies/
+ * otherwise to /dropbox/other/
+ * 
+ * @scr.component  immediate="true"
+ * @scr.service interface="org.osgi.service.event.EventHandler"
+ * @scr.property name="event.topics" valueRef="mypackage.DropBoxService.JOB_TOPIC"
+ */
+
+public class DropBoxEventHandler implements JobProcessor, EventHandler {
+
+    /** Default log. */
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    /** @scr.reference */
+    private SlingRepository repository;
+    
+    /**
+     * @scr.reference
+     */
+    private JcrResourceResolverFactory resolverFactory;
+    
+    private final static String IMAGES_PATH = "/dropbox/images/";
+    private final static String MUSIC_PATH = "/dropbox/music/";
+    private final static String MOVIES_PATH = "/dropbox/movies/";
+    private final static String OTHER_PATH = "/dropbox/other/";
+
+	public void handleEvent(Event event) {
+	    if (EventUtil.isLocal(event)) {
+	        EventUtil.processJob(event, this);
+	    }
+	}
+
+	public boolean process(Event event) {
+		Session adminSession = null;
+		try {
+			String resourcePath = (String) event.getProperty("resourcePath");
+			String resourceName = resourcePath.substring(resourcePath.lastIndexOf("/") + 1);
+        	adminSession = repository.loginAdministrative(null);
+	        ResourceResolver resourceResolver = resolverFactory.getResourceResolver(adminSession);
+	        Resource res = resourceResolver.getResource(resourcePath);
+	        if (ResourceUtil.isA(res, "nt:file")) {
+	        	String mimeType = res.getResourceMetadata().getContentType();
+	        	String destDir;
+	        	if (mimeType.equals("image/png")) {
+	        		destDir = IMAGES_PATH;
+	        	}
+	        	else if (mimeType.equals("audio/mpeg")) {
+	        		destDir = MUSIC_PATH;
+	        	}
+	        	else if (mimeType.equals("video/x-msvideo")) {
+	        		destDir = MOVIES_PATH;
+	        	}
+	        	else {
+	        		destDir = OTHER_PATH;
+	        	}
+        		adminSession.move(resourcePath, destDir + resourceName);
+	        	adminSession.save();
+	        	log.info("The file {} has been moved to {}", resourceName, destDir);
+	        }
+	        return true;
+		} catch (RepositoryException e) {
+			log.error("RepositoryException: " + e);
+			return false;
+        } finally {
+            if (adminSession != null && adminSession.isLive()) {
+            	adminSession.logout();
+            	adminSession = null;
+            }
+        }
+	}
+}

Added: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxService.java
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxService.java (added)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/DropBoxService.java Mon Jun  4 07:41:23 2012
@@ -0,0 +1,57 @@
+
+package mypackage;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.sling.api.SlingConstants;
+import org.apache.sling.event.EventUtil;
+import org.apache.sling.event.JobProcessor;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>DropBoxService</code> is listening content added to /tmp/dropbox by using OSGI events
+ * 
+ * @scr.component  immediate="true"
+ * @scr.service interface="org.osgi.service.event.EventHandler"
+ * @scr.property name="event.topics" valueRef="org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED"
+ */
+public class DropBoxService implements JobProcessor, EventHandler {
+
+    /** Default log. */
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
+	
+	/** 
+	 * The OSGI event admin used for sending events 
+	 * @scr.reference
+	 */
+	private EventAdmin eventAdmin;
+	
+    /** The job topic for dropbox job events. */
+    public static final String JOB_TOPIC = "com/sling/eventing/dropbox/job";
+
+	public void handleEvent(Event event) {
+	    if (EventUtil.isLocal(event)) {
+	        EventUtil.processJob(event, this);
+	    }
+	}
+
+	public boolean process(Event event) {
+		String propPath = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
+		String propResType = (String) event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE);
+		// an event is sent if a file is added to /tmp/dropbox
+		if (propPath.startsWith("/tmp/dropbox") && propResType.equals("nt:file")) {
+    		final Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put(EventUtil.PROPERTY_JOB_TOPIC, JOB_TOPIC);
+    		props.put("resourcePath", propPath);
+    		Event dropboxJobEvent = new Event(EventUtil.TOPIC_JOB, props);
+    		eventAdmin.sendEvent(dropboxJobEvent);
+    		log.info("the dropbox job has been sent: {}", propPath);
+		}
+		return true;
+	}
+}

Modified: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/getting-resources-and-properties-in-sling.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/getting-resources-and-properties-in-sling.html (original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/getting-resources-and-properties-in-sling.html Mon Jun  4 07:41:23 2012
@@ -82,83 +82,106 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/tutorials-how-tos.html">Tutorials & How-Tos</a>
       </div>
       <h1>Getting Resources and Properties in Sling</h1>
-      <h1 id="getting-resources-and-properties-in-sling">Getting Resources and Properties in Sling</h1>
-<p>The Resource is one of the central parts of Sling. Extending from JCR's Everything is Content, Sling assumes Everthing is a Resource. Thus Sling is maintaining a virtual tree of resources, which is a merger of the actual contents in the JCR Repository and resources provided by so called resource providers. By doing this Sling fits very well in the paradigm of the REST architecture.</p>
+      <p>The Resource is one of the central parts of Sling. Extending from JCR's Everything is Content, Sling assumes Everthing is a Resource. Thus Sling is maintaining a virtual tree of resources, which is a merger of the actual contents in the JCR Repository and resources provided by so called resource providers. By doing this Sling fits very well in the paradigm of the REST architecture.</p>
 <p>In this article we will explore a few ways to programmatically map a resource path (String) to a resource object (Resource) and its properties in Sling, from within an OSGI service, a servlet and a JSP.</p>
 <p>The whole game consists in first getting a <code>ResourceResolver</code> and then getting the <code>Resource</code> itself.</p>
 <h2 id="within-an-osgi-servicecompoment">Within an OSGI Service/Compoment</h2>
 <p>You can access a resource through the <code>ResourceResolverFactory</code> service:</p>
-<div class="codehilite"><pre><span class="sr">/** @scr.reference */</span>
-<span class="n">private</span> <span class="n">ResourceResolverFactory</span> <span class="n">resolverFactory</span><span class="p">;</span>
-
-<span class="n">public</span> <span class="n">void</span> <span class="n">myMethod</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">try</span> <span class="p">{</span>
-    <span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="p">;</span>
-        <span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">resolverFactory</span><span class="o">.</span><span class="n">getAdministrativeResourceResolver</span><span class="p">(</span><span class="n">null</span><span class="p">);</span>
-    <span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
-    <span class="sr">//</span> <span class="k">do</span> <span class="n">something</span> <span class="n">with</span> <span class="n">the</span> <span class="n">resource</span>
-    <span class="sr">//</span> <span class="n">when</span> <span class="n">done</span><span class="p">,</span> <span class="nb">close</span> <span class="n">the</span> <span class="n">ResourceResolver</span>
-    <span class="n">resourceResolver</span><span class="o">.</span><span class="nb">close</span><span class="p">();</span>
-    <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">LoginException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
-        <span class="sr">//</span> <span class="nb">log</span> <span class="n">the</span> <span class="n">error</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</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nd">@Reference</span>
+<span class="kd">private</span> <span class="n">ResourceResolverFactory</span> <span class="n">resolverFactory</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kt">void</span> <span class="nf">myMethod</span><span class="o">()</span> <span class="o">{</span>
+    <span class="k">try</span> <span class="o">{</span>
+    <span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="o">;</span>
+        <span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">resolverFactory</span><span class="o">.</span><span class="na">getAdministrativeResourceResolver</span><span class="o">(</span><span class="kc">null</span><span class="o">);</span>
+    <span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="na">getResource</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">);</span>
+    <span class="c1">// do something with the resource</span>
+    <span class="c1">// when done, close the ResourceResolver</span>
+    <span class="n">resourceResolver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
+    <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">LoginException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+        <span class="c1">// log the error</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
-
+</td></tr></table>
 
 <h2 id="within-a-servlet">Within a Servlet</h2>
 <p>You can access the resource defined by the request URL through the <code>SlingHttpServletRequest</code>:</p>
-<div class="codehilite"><pre><span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="n">getResource</span><span class="p">();</span>
-<span class="sr">//</span> <span class="n">req</span> <span class="n">is</span> <span class="n">the</span> <span class="n">SlingHttpServletRequest</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="na">getResource</span><span class="o">();</span>
+<span class="c1">// req is the SlingHttpServletRequest</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>You can access any resource by first accessing the <code>ResourceResolver</code>:</p>
-<div class="codehilite"><pre><span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="p">;</span>
-<span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="n">getResourceResolver</span><span class="p">();</span>
-<span class="sr">//</span> <span class="n">req</span> <span class="n">is</span> <span class="n">the</span> <span class="n">SlingHttpServletRequest</span>
-<span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="o">;</span>
+<span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">req</span><span class="o">.</span><span class="na">getResourceResolver</span><span class="o">();</span>
+<span class="c1">// req is the SlingHttpServletRequest</span>
+<span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="na">getResource</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">);</span>
 </pre></div>
-
+</td></tr></table>
 
 <h2 id="within-a-jsp-file">Within a JSP file</h2>
 <p>When you use the <code>&lt;sling:defineObjects&gt;</code> tag in a JSP file, you have access to a few handy objects, one of them is <code>resource</code>, the resource that is resolved from the URL. Another one is <code>resourceResolver</code>, the <code>ResourceResolver</code> defined through the <code>SlingHttpServletRequest</code>. </p>
 <p>To access a resource:</p>
-<div class="codehilite"><pre><span class="x">&lt;sling:defineObjects&gt;</span>
-<span class="cp">&lt;%</span>
-<span class="nb">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s2">&quot;path/to/resource&quot;</span><span class="p">;</span>
-<span class="no">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
-<span class="cp">%&gt;</span><span class="x"></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="nt">&lt;sling:defineObjects&gt;</span>
+<span class="k">&lt;%</span>
+<span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="s">&quot;path/to/resource&quot;</span><span class="o">;</span>
+<span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="na">getResource</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">);</span>
+<span class="k">%&gt;</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>If needed you can adapt a Sling Resource to a JCR Node:</p>
-<div class="codehilite"><pre><span class="n">Node</span> <span class="n">node</span> <span class="o">=</span> <span class="n">resource</span><span class="o">.</span><span class="n">adaptTo</span><span class="p">(</span><span class="n">Node</span><span class="o">.</span><span class="n">class</span><span class="p">);</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">Node</span> <span class="n">node</span> <span class="o">=</span> <span class="n">resource</span><span class="o">.</span><span class="na">adaptTo</span><span class="o">(</span><span class="n">Node</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>Note: <code>resource.adaptTo(Node.class)</code> may return null if the resource is not backed by a JCR node. This is particularly the case for <code>NonExistingResource</code> resources or resource provided by a non-JCR resource provider.</p>
 <h2 id="accessing-a-property">Accessing a Property</h2>
 <p>The <code>ValueMap</code> is an easy way to access properties of a resource. With most resources you can use <code>Adaptable.adaptTo(Class)</code> to adapt the resource to a value map:</p>
-<div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="n">adaptTo</span><span class="p">(</span><span class="n">ValueMap</span><span class="o">.</span><span class="n">class</span><span class="p">);</span>
-<span class="sr">//</span> <span class="n">res</span> <span class="n">is</span> <span class="n">the</span> <span class="n">Resource</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="na">adaptTo</span><span class="o">(</span><span class="n">ValueMap</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
+<span class="c1">// res is the Resource</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>You can also access the properties through the <code>ResourceUtil</code> utility class:</p>
-<div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">ResourceUtil</span><span class="o">.</span><span class="n">getValueMap</span><span class="p">(</span><span class="n">res</span><span class="p">);</span>
-<span class="sr">//</span> <span class="n">res</span> <span class="n">is</span> <span class="n">the</span> <span class="n">Resource</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">ValueMap</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">ResourceUtil</span><span class="o">.</span><span class="na">getValueMap</span><span class="o">(</span><span class="n">res</span><span class="o">);</span>
+<span class="c1">// res is the Resource</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>Then, to access a specific String property called <code>propName</code>:</p>
-<div class="codehilite"><pre><span class="n">String</span> <span class="n">rule</span> <span class="o">=</span> <span class="n">properties</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">propName</span><span class="p">,</span> <span class="p">(</span><span class="n">String</span><span class="p">)</span> <span class="n">null</span><span class="p">);</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="codehilite"><pre><span class="n">String</span> <span class="n">rule</span> <span class="o">=</span> <span class="n">properties</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">propName</span><span class="o">,</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="kc">null</span><span class="o">);</span>
 </pre></div>
+</td></tr></table>
 
-
-<p>For more details about resources and how to access them in Sling, you can refer to the <a href="">Sling documentation about Resources</a>.</p>
+<p>For more details about resources and how to access them in Sling, you can refer to the <a href="/documentation/the-sling-engine/resources.html">Sling documentation about Resources</a>.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+        Rev. 1345850 by fmeschbe on Mon, 4 Jun 2012 07:40:42 +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/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 Mon Jun  4 07:41:23 2012
@@ -82,188 +82,279 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/tutorials-how-tos.html">Tutorials & How-Tos</a>
       </div>
       <h1>How to Manage Events in Sling</h1>
-      <h1 id="how-to-manage-events-in-sling">How to Manage Events in Sling</h1>
-<p>Apache Sling provides some mechanisms and support for managing events.</p>
+      <p>Apache Sling provides some mechanisms and support for managing events.</p>
 <p>The event mechanism is leveraging the OSGi Event Admin Specification (OSGi Compendium 113). The OSGi API is very simple and lightweight. Sending an event is just generating the event object and calling the event admin. Receiving the event is implementing a single interface and declaring through properties which topics one is interested in. 
 Sling makes a distinction between events and job events. Unlike events, job events are garanteed to be processed. In other words: someone has to do something with the job event (do the job). </p>
-<p>For more details please refer to the following resources:
-<em> <a href="">Eventing, Jobs and Scheduling section</a> to get detailed information on the eventing mechanisms in Sling.
-</em> package <a href="">org.osgi.service.event</a> of the OSGI API.
-* package <a href="">org.apache.sling.event</a> of the Sling API.</p>
+<p>For more details please refer to the following resources:</p>
+<ul>
+<li><a href="/documentation/the-sling-engine/eventing-and-jobs.html">Eventing, Jobs and Scheduling section</a> to get detailed information on the eventing mechanisms in Sling.</li>
+<li>Package <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/event/package-summary.html">org.osgi.service.event</a> of the OSGI API.</li>
+<li>Package <a href="/apidocs/sling6/org/apache/sling/event/package-summary.html">org.apache.sling.event</a> of the Sling API.</li>
+</ul>
 <p>This page drives you through the implementation of two services that rely on the Sling eventing mechanisms. The services implement the following use case: whenever a file is uploaded to a temporary location in your web application, the file is moved to a specific location according to its MIME type.</p>
 <h2 id="introduction">Introduction</h2>
-<p>You will now implement the logic to listen to files posted to <em>/tmp/dropbox</em> and to move them to the appropriate locations depending on the MIME type:
-<em> images (.png) are moved to </em>/dropbox/images/<em>
-</em> music (.mp3) are moved to <em>/dropbox/music/</em>
-<em> movies (.avi) are moved to </em>/dropbox/movies/<em>
-</em> otherwise the files are moved to <em>/dropbox/other/</em></p>
-<p>To do that, you will implement two services. The first one, called <em>DropBoxService</em>:
-<em> Listens to OSGI events.
-</em> Sends a job event if a resource has been added to <em>/tmp/dropbox</em>.</p>
-<p>The second one, called <em>DropBoxEventHandler</em>:
-<em> Listens to the former job event.
-</em> Moves the file according to its extension.</p>
+<p>You will now implement the logic to listen to files posted to <em>/tmp/dropbox</em> and to move them to the appropriate locations depending on the MIME type:</p>
+<ul>
+<li>images (.png) are moved to <strong>/dropbox/images/</strong></li>
+<li>music (.mp3) are moved to <strong>/dropbox/music/</strong></li>
+<li>movies (.avi) are moved to <strong>/dropbox/movies/</strong></li>
+<li>otherwise the files are moved to <strong>/dropbox/other/</strong></li>
+</ul>
+<p>To do that, you will implement two services. The first one, called <strong>DropBoxService</strong>:</p>
+<ul>
+<li>Listens to OSGI events.</li>
+<li>Sends a job event if a resource has been added to <strong>/tmp/dropbox</strong>.</li>
+</ul>
+<p>The second one, called <strong>DropBoxEventHandler</strong>:</p>
+<ul>
+<li>Listens to the former job event.</li>
+<li>Moves the file according to its extension.</li>
+</ul>
 <h2 id="listening-to-osgi-events">Listening to OSGI Events</h2>
-<p>To listen to the specific OSGI event <em>"resource added"</em>:
-<em> The property </em>event.topics<em> needs to be set to </em>org.apache.sling.api.SlingConstants.TOPIC<em>RESOURCE</em>ADDED* in the class annotations.</p>
-<div class="codehilite"><pre> <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">property</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;event.topics&quot;</span> <span class="n">valueRef</span><span class="o">=</span><span class="s">&quot;org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED&quot;</span>
+<p>To listen to the specific OSGI event <strong>resource added<em> the property </em>event.topics* needs to be set to </strong>org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED** in the class annotations.</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre> <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;event.topics&quot;</span><span class="o">,</span>
+    <span class="n">value</span><span class="o">=</span><span class="n">org</span><span class="o">.</span><span class="na">apache</span><span class="o">.</span><span class="na">sling</span><span class="o">.</span><span class="na">api</span><span class="o">.</span><span class="na">SlingConstants</span><span class="o">.</span><span class="na">TOPIC_RESOURCE_ADDED</span><span class="o">)</span>
 </pre></div>
+</td></tr></table>
 
-
-<p>You can refer to the <a href="">org.apache.sling.api.SlingConstants</a> class in the Javadocs to know about other events available in Sling.</p>
+<p>You can refer to the <a href="/apidocs/sling6/org/apache/sling/api/SlingConstants.html">org.apache.sling.api.SlingConstants</a> class in the Javadocs to know about other events available in Sling.</p>
 <h2 id="sending-job-events">Sending Job Events</h2>
-<p>To send a job event the service needs to implement:
-<em> the </em>org.osgi.service.event.EventHandler<em> interface.
-</em> the <em>org.apache.sling.event.JobProcessor</em> interface.</p>
-<div class="codehilite"><pre><span class="n">public</span> <span class="n">class</span> <span class="n">DropBoxService</span> <span class="n">implements</span> <span class="n">JobProcessor</span><span class="p">,</span> <span class="n">EventHandler</span> <span class="p">{</span>
+<p>To send a job event the service needs to implement the <strong>org.osgi.service.event.EventHandler</strong> and <strong>org.apache.sling.event.JobProcessor</strong> interfaces:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">DropBoxService</span> <span class="kd">implements</span> <span class="n">JobProcessor</span><span class="o">,</span> <span class="n">EventHandler</span> <span class="o">{</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>To send the job event the Event Admin service needs to be referenced:</p>
-<div class="codehilite"><pre>    <span class="o">/**</span> 
-     <span class="o">*</span> <span class="n">The</span> <span class="n">OSGI</span> <span class="n">event</span> <span class="n">admin</span> <span class="n">used</span> <span class="k">for</span> <span class="n">sending</span> <span class="n">events</span> 
-     <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">reference</span>
-     <span class="o">*/</span>
-    <span class="n">private</span> <span class="n">EventAdmin</span> <span class="n">eventAdmin</span><span class="p">;</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nd">@Reference</span>
+<span class="kd">private</span> <span class="n">EventAdmin</span> <span class="n">eventAdmin</span><span class="o">;</span>
 </pre></div>
-
+</td></tr></table>
 
 <p>The job topic for dropbox job events needs to be defined:</p>
-<div class="codehilite"><pre>    <span class="sr">/** The job topic for dropbox job events. */</span>
-    <span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">JOB_TOPIC</span> <span class="o">=</span> <span class="s">&quot;com/sling/eventing/dropbox/job&quot;</span><span class="p">;</span>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="cm">/** The job topic for dropbox job events. */</span>
+<span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">JOB_TOPIC</span> <span class="o">=</span> <span class="s">&quot;com/sling/eventing/dropbox/job&quot;</span><span class="o">;</span>
 </pre></div>
+</td></tr></table>
 
-
-<p>The <em>org.osgi.service.event.EventHandler#handleEvent(Event event)</em> method needs to be implemented:</p>
-<div class="codehilite"><pre>    <span class="n">public</span> <span class="n">void</span> <span class="n">handleEvent</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="n">isLocal</span><span class="p">(</span><span class="n">event</span><span class="p">))</span> <span class="p">{</span>
-            <span class="n">EventUtil</span><span class="o">.</span><span class="n">processJob</span><span class="p">(</span><span class="n">event</span><span class="p">,</span> <span class="n">this</span><span class="p">);</span>
-        <span class="p">}</span>
-    <span class="p">}</span>
+<p>The <strong>org.osgi.service.event.EventHandler#handleEvent(Event event)</strong> method needs to be implemented:</p>
+<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="kd">public</span> <span class="kt">void</span> <span class="nf">handleEvent</span><span class="o">(</span><span class="n">Event</span> <span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+    <span class="k">if</span> <span class="o">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="na">isLocal</span><span class="o">(</span><span class="n">event</span><span class="o">))</span> <span class="o">{</span>
+        <span class="n">EventUtil</span><span class="o">.</span><span class="na">processJob</span><span class="o">(</span><span class="n">event</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
+</td></tr></table>
 
-
-<p>The <em>org.apache.sling.event.JobProcessor#process(Event event)</em> method needs to be implemented.</p>
-<p>Its logic is as follows:
-<em> The OSGI event is analyzed.
-</em> If the event is a file that has been added to <em>/tmp/dropbox</em>:
-<strong> An event is created with 2 properties:
-<strong><em> A property to set the event as a job event.
-</em></strong> A property for the file path.
-</strong> The job event is sent to all the listeners that subscribe to the topic of the event.</p>
-<div class="codehilite"><pre>    <span class="n">public</span> <span class="n">boolean</span> <span class="n">process</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">String</span> <span class="n">propPath</span> <span class="o">=</span> <span class="p">(</span><span class="n">String</span><span class="p">)</span> <span class="n">event</span><span class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span class="n">SlingConstants</span><span class="o">.</span><span class="n">PROPERTY_PATH</span><span class="p">);</span>
-        <span class="n">String</span> <span class="n">propResType</span> <span class="o">=</span> <span class="p">(</span><span class="n">String</span><span class="p">)</span> <span class="n">event</span><span class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span class="n">SlingConstants</span><span class="o">.</span><span class="n">PROPERTY_RESOURCE_TYPE</span><span class="p">);</span>
-        <span class="sr">//</span> <span class="n">an</span> <span class="n">event</span> <span class="n">is</span> <span class="n">sent</span> <span class="k">if</span> <span class="n">a</span> <span class="n">file</span> <span class="n">is</span> <span class="n">added</span> <span class="n">to</span> <span class="sr">/tmp/</span><span class="n">dropbox</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">propPath</span><span class="o">.</span><span class="n">startsWith</span><span class="p">(</span><span class="s">&quot;/tmp/dropbox&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="n">propResType</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="s">&quot;nt:file&quot;</span><span class="p">))</span> <span class="p">{</span>
-            <span class="n">final</span> <span class="n">Dictionary</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">props</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">Object</span><span class="o">&gt;</span><span class="p">();</span>
-            <span class="n">props</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="n">PROPERTY_JOB_TOPIC</span><span class="p">,</span> <span class="n">JOB_TOPIC</span><span class="p">);</span>
-            <span class="n">props</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s">&quot;resourcePath&quot;</span><span class="p">,</span> <span class="n">propPath</span><span class="p">);</span>
-            <span class="n">Event</span> <span class="n">dropboxJobEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Event</span><span class="p">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="n">TOPIC_JOB</span><span class="p">,</span> <span class="n">props</span><span class="p">);</span>
-            <span class="n">eventAdmin</span><span class="o">.</span><span class="n">sendEvent</span><span class="p">(</span><span class="n">dropboxJobEvent</span><span class="p">);</span>
-            <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;the dropbox job has been sent: {}&quot;</span><span class="p">,</span> <span class="n">propPath</span><span class="p">);</span>
-        <span class="p">}</span>
-        <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
-    <span class="p">}</span>
+<p>The <strong>org.apache.sling.event.JobProcessor#process(Event event)</strong> method needs to be implemented:</p>
+<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
+24
+25
+26</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">process</span><span class="o">(</span><span class="n">Event</span> <span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+
+    <span class="c1">// get the resource event information</span>
+    <span class="n">String</span> <span class="n">propPath</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="n">event</span><span class="o">.</span><span class="na">getProperty</span><span class="o">(</span><span class="n">SlingConstants</span><span class="o">.</span><span class="na">PROPERTY_PATH</span><span class="o">);</span>
+    <span class="n">String</span> <span class="n">propResType</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="n">event</span><span class="o">.</span><span class="na">getProperty</span><span class="o">(</span><span class="n">SlingConstants</span><span class="o">.</span><span class="na">PROPERTY_RESOURCE_TYPE</span><span class="o">);</span>
+
+    <span class="c1">// an event is sent if a file is added to /tmp/dropbox</span>
+    <span class="k">if</span> <span class="o">(</span><span class="n">propPath</span><span class="o">.</span><span class="na">startsWith</span><span class="o">(</span><span class="s">&quot;/tmp/dropbox&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="n">propResType</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="s">&quot;nt:file&quot;</span><span class="o">))</span> <span class="o">{</span>
+
+        <span class="c1">// configure the job event</span>
+        <span class="kd">final</span> <span class="n">Dictionary</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">props</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
+        <span class="n">props</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="na">PROPERTY_JOB_TOPIC</span><span class="o">,</span> <span class="n">JOB_TOPIC</span><span class="o">);</span>
+        <span class="n">props</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;resourcePath&quot;</span><span class="o">,</span> <span class="n">propPath</span><span class="o">);</span>
+
+        <span class="c1">// create the job event</span>
+        <span class="n">Event</span> <span class="n">dropboxJobEvent</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Event</span><span class="o">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="na">TOPIC_JOB</span><span class="o">,</span> <span class="n">props</span><span class="o">);</span>
+
+        <span class="c1">// deliver the job event</span>
+        <span class="n">eventAdmin</span><span class="o">.</span><span class="na">sendEvent</span><span class="o">(</span><span class="n">dropboxJobEvent</span><span class="o">);</span>
+
+        <span class="n">log</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;the dropbox job has been sent: {}&quot;</span><span class="o">,</span> <span class="n">propPath</span><span class="o">);</span>
+    <span class="o">}</span>
+
+    <span class="c1">// all set and done</span>
+    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
+<span class="o">}</span>
 </pre></div>
+</td></tr></table>
 
-
-<p>The complete code for the <em>DropBoxService</em> service is available <a href="">here</a>.</p>
+<p>The complete code for the <strong>DropBoxService</strong> service is available <a href="DropBoxService.java">here</a>.</p>
 <h2 id="listening-to-job-events">Listening to Job Events</h2>
-<p>Now that you have implemented a service that sends a job event when a file is uploaded to <em>/tmp/dropbox</em>, you will implement the service <em>DropBoxEventHandler</em> that listens to those job events and moves the files to a location according to their MIME types.</p>
-<p>To listen to the job events that have been defined before:
-<em> The property </em>event.topics<em> needs to be set to </em>mypackage.DropBoxService.JOB_TOPIC* in the class annotations.</p>
-<div class="codehilite"><pre> <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">property</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;event.topics&quot;</span> <span class="n">valueRef</span><span class="o">=</span><span class="s">&quot;mypackage.DropBoxService.JOB_TOPIC&quot;</span>
+<p>Now that you have implemented a service that sends a job event when a file is uploaded to <strong>/tmp/dropbox</strong>, you will implement the service <strong>DropBoxEventHandler</strong> that listens to those job events and moves the files to a location according to their MIME types.</p>
+<p>To listen to the job events that have been defined before the property <strong>event.topics</strong> needs to be set to <strong>mypackage.DropBoxService.JOB_TOPIC</strong> in the class annotations:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nd">@Property</span><span class="o">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;event.topics&quot;</span><span class="o">,</span>
+    <span class="n">value</span><span class="o">=</span><span class="n">mypackage</span><span class="o">.</span><span class="na">DropBoxService</span><span class="o">.</span><span class="na">JOB_TOPIC</span><span class="o">)</span>
 </pre></div>
-
+</td></tr></table>
 
 <h2 id="handling-job-events">Handling Job Events</h2>
-<p>To move the files the service needs to implement:
-<em> the </em>org.osgi.service.event.EventHandler<em> interface.
-</em> the <em>org.apache.sling.event.JobProcessor</em> interface.</p>
-<div class="codehilite"><pre><span class="n">public</span> <span class="n">class</span> <span class="n">DropBoxEventHandler</span> <span class="n">implements</span> <span class="n">JobProcessor</span><span class="p">,</span> <span class="n">EventHandler</span> <span class="p">{</span>
-</pre></div>
-
-
-<p>Some class fields need to be defined for:
-<em> The default log.
-</em> The references to the SlingRepository and the JcrResourceResolverFactory services, which are used in the implementation.
-* The destination paths of the files.</p>
-<p>{code}
-   /*<em> Default log. </em>/
-    protected final Logger log = LoggerFactory.getLogger(this.getClass());</p>
-<div class="codehilite"><pre><span class="sr">/** @scr.reference */</span>
-<span class="n">private</span> <span class="n">SlingRepository</span> <span class="n">repository</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="nv">@scr</span><span class="o">.</span><span class="n">reference</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">JcrResourceResolverFactory</span> <span class="n">resolverFactory</span><span class="p">;</span>
-
-<span class="n">private</span> <span class="n">final</span> <span class="n">static</span> <span class="n">String</span> <span class="n">IMAGES_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/images/&quot;</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">final</span> <span class="n">static</span> <span class="n">String</span> <span class="n">MUSIC_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/music/&quot;</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">final</span> <span class="n">static</span> <span class="n">String</span> <span class="n">MOVIES_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/movies/&quot;</span><span class="p">;</span>
-<span class="n">private</span> <span class="n">final</span> <span class="n">static</span> <span class="n">String</span> <span class="n">OTHER_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/other/&quot;</span><span class="p">;</span>
-
-<span class="n">The</span> <span class="o">*</span><span class="n">org</span><span class="o">.</span><span class="n">osgi</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">event</span><span class="o">.</span><span class="n">EventHandler</span><span class="c1">#handleEvent(Event event)* method needs to be implemented:</span>
-
-<span class="n">public</span> <span class="n">void</span> <span class="n">handleEvent</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="n">isLocal</span><span class="p">(</span><span class="n">event</span><span class="p">))</span> <span class="p">{</span>
-        <span class="n">EventUtil</span><span class="o">.</span><span class="n">processJob</span><span class="p">(</span><span class="n">event</span><span class="p">,</span> <span class="n">this</span><span class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
-
-<span class="n">The</span> <span class="o">*</span><span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">sling</span><span class="o">.</span><span class="n">event</span><span class="o">.</span><span class="n">JobProcessor</span><span class="c1">#process(Event event)* method needs to be implemented.</span>
-
-<span class="n">Its</span> <span class="n">logic</span> <span class="n">is</span> <span class="n">as</span> <span class="n">follows:</span>
-<span class="o">*</span> <span class="n">The</span> <span class="n">resource</span> <span class="n">path</span> <span class="n">is</span> <span class="n">extracted</span> <span class="n">from</span> <span class="n">the</span> <span class="n">job</span> <span class="n">event</span> <span class="n">property</span><span class="o">.</span>
-<span class="o">*</span> <span class="n">The</span> <span class="n">resource</span> <span class="n">is</span> <span class="n">obtained</span> <span class="n">from</span> <span class="n">the</span> <span class="n">resource</span> <span class="n">path</span><span class="o">.</span>
-<span class="o">*</span> <span class="n">If</span> <span class="n">the</span> <span class="n">resource</span> <span class="n">is</span> <span class="n">a</span> <span class="n">file</span><span class="p">,</span> <span class="n">the</span> <span class="n">destination</span> <span class="n">path</span> <span class="n">is</span> <span class="nb">defined</span> <span class="n">based</span> <span class="n">on</span> <span class="n">the</span> <span class="n">file</span> <span class="n">MIME</span> <span class="n">type</span><span class="o">.</span>
-<span class="o">*</span> <span class="n">The</span> <span class="n">file</span> <span class="n">is</span> <span class="n">moved</span> <span class="n">to</span> <span class="n">the</span> <span class="k">new</span> <span class="n">location</span><span class="o">.</span>
-
-<span class="n">public</span> <span class="n">boolean</span> <span class="n">process</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
-    <span class="n">Session</span> <span class="n">adminSession</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
-    <span class="n">try</span> <span class="p">{</span>
-        <span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="p">(</span><span class="n">String</span><span class="p">)</span> <span class="n">event</span><span class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span class="s">&quot;resourcePath&quot;</span><span class="p">);</span>
-        <span class="n">String</span> <span class="n">resourceName</span> <span class="o">=</span> <span class="n">resourcePath</span><span class="o">.</span><span class="n">substring</span><span class="p">(</span><span class="n">resourcePath</span><span class="o">.</span><span class="n">lastIndexOf</span><span class="p">(</span><span class="s">&quot;/&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
-        <span class="n">adminSession</span> <span class="o">=</span> <span class="n">repository</span><span class="o">.</span><span class="n">loginAdministrative</span><span class="p">(</span><span class="n">null</span><span class="p">);</span>
-        <span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">resolverFactory</span><span class="o">.</span><span class="n">getResourceResolver</span><span class="p">(</span><span class="n">adminSession</span><span class="p">);</span>
-        <span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="n">getResource</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">);</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">ResourceUtil</span><span class="o">.</span><span class="n">isA</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="s">&quot;nt:file&quot;</span><span class="p">))</span> <span class="p">{</span>
-            <span class="n">String</span> <span class="n">mimeType</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="n">getResourceMetadata</span><span class="p">()</span><span class="o">.</span><span class="n">getContentType</span><span class="p">();</span>
-            <span class="n">String</span> <span class="n">destDir</span><span class="p">;</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">mimeType</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="s">&quot;image/png&quot;</span><span class="p">))</span> <span class="p">{</span>
-                <span class="n">destDir</span> <span class="o">=</span> <span class="n">IMAGES_PATH</span><span class="p">;</span>
-            <span class="p">}</span>
-            <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">mimeType</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="s">&quot;audio/mpeg&quot;</span><span class="p">))</span> <span class="p">{</span>
-                <span class="n">destDir</span> <span class="o">=</span> <span class="n">MUSIC_PATH</span><span class="p">;</span>
-            <span class="p">}</span>
-            <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">mimeType</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="s">&quot;video/x-msvideo&quot;</span><span class="p">))</span> <span class="p">{</span>
-                <span class="n">destDir</span> <span class="o">=</span> <span class="n">MOVIES_PATH</span><span class="p">;</span>
-            <span class="p">}</span>
-            <span class="k">else</span> <span class="p">{</span>
-                <span class="n">destDir</span> <span class="o">=</span> <span class="n">OTHER_PATH</span><span class="p">;</span>
-            <span class="p">}</span>
-            <span class="n">adminSession</span><span class="o">.</span><span class="n">move</span><span class="p">(</span><span class="n">resourcePath</span><span class="p">,</span> <span class="n">destDir</span> <span class="o">+</span> <span class="n">resourceName</span><span class="p">);</span>
-            <span class="n">adminSession</span><span class="o">.</span><span class="n">save</span><span class="p">();</span>
-            <span class="nb">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;The file {} has been moved to {}&quot;</span><span class="p">,</span> <span class="n">resourceName</span><span class="p">,</span> <span class="n">destDir</span><span class="p">);</span>
-        <span class="p">}</span>
-        <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
-    <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">RepositoryException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
-        <span class="nb">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&quot;RepositoryException: &quot;</span> <span class="o">+</span> <span class="n">e</span><span class="p">);</span>
-        <span class="k">return</span> <span class="n">false</span><span class="p">;</span>
-    <span class="p">}</span> <span class="n">finally</span> <span class="p">{</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">adminSession</span> <span class="o">!=</span> <span class="n">null</span> <span class="o">&amp;&amp;</span> <span class="n">adminSession</span><span class="o">.</span><span class="n">isLive</span><span class="p">())</span> <span class="p">{</span>
-            <span class="n">adminSession</span><span class="o">.</span><span class="n">logout</span><span class="p">();</span>
-            <span class="n">adminSession</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
-        <span class="p">}</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<p>To move the files the service needs to implement the <strong>org.osgi.service.event.EventHandler</strong> and <strong>org.apache.sling.event.JobProcessor</strong> interfaces:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">DropBoxEventHandler</span> <span class="kd">implements</span> <span class="n">JobProcessor</span><span class="o">,</span> <span class="n">EventHandler</span> <span class="o">{</span>
+</pre></div>
+</td></tr></table>
+
+<p>Some class fields need to be defined:</p>
+<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="cm">/** Default log. */</span>
+<span class="kd">protected</span> <span class="kd">final</span> <span class="n">Logger</span> <span class="n">log</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="na">getLogger</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="na">getClass</span><span class="o">());</span>
+
+<span class="nd">@Reference</span>
+<span class="kd">private</span> <span class="n">SlingRepository</span> <span class="n">repository</span><span class="o">;</span>
+
+<span class="nd">@Reference</span>    
+<span class="kd">private</span> <span class="n">JcrResourceResolverFactory</span> <span class="n">resolverFactory</span><span class="o">;</span>
+
+<span class="kd">private</span> <span class="kd">final</span> <span class="kd">static</span> <span class="n">String</span> <span class="n">IMAGES_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/images/&quot;</span><span class="o">;</span>
+<span class="kd">private</span> <span class="kd">final</span> <span class="kd">static</span> <span class="n">String</span> <span class="n">MUSIC_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/music/&quot;</span><span class="o">;</span>
+<span class="kd">private</span> <span class="kd">final</span> <span class="kd">static</span> <span class="n">String</span> <span class="n">MOVIES_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/movies/&quot;</span><span class="o">;</span>
+<span class="kd">private</span> <span class="kd">final</span> <span class="kd">static</span> <span class="n">String</span> <span class="n">OTHER_PATH</span> <span class="o">=</span> <span class="s">&quot;/dropbox/other/&quot;</span><span class="o">;</span>
+</pre></div>
+</td></tr></table>
 
-<span class="n">The</span> <span class="n">complete</span> <span class="n">code</span> <span class="k">for</span> <span class="n">the</span> <span class="o">*</span><span class="n">DropBoxEventHandler</span><span class="o">*</span> <span class="n">service</span> <span class="n">is</span> <span class="n">available</span> <span class="p">[</span><span class="n">here</span><span class="o">|^</span><span class="n">DropBoxEventHandler</span><span class="o">.</span><span class="n">java</span><span class="p">]</span><span class="o">.</span>
+<p>The <strong>org.osgi.service.event.EventHandler#handleEvent(Event event)</strong> method needs to be implemented:</p>
+<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="kd">public</span> <span class="kt">void</span> <span class="nf">handleEvent</span><span class="o">(</span><span class="n">Event</span> <span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+    <span class="k">if</span> <span class="o">(</span><span class="n">EventUtil</span><span class="o">.</span><span class="na">isLocal</span><span class="o">(</span><span class="n">event</span><span class="o">))</span> <span class="o">{</span>
+        <span class="n">EventUtil</span><span class="o">.</span><span class="na">processJob</span><span class="o">(</span><span class="n">event</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
+</td></tr></table>
+
+<p>The <strong>org.apache.sling.event.JobProcessor#process(Event event)</strong> method needs to be implemented.</p>
+<p>Its logic is as follows:</p>
+<ul>
+<li>The resource path is extracted from the job event property.</li>
+<li>The resource is obtained from the resource path.</li>
+<li>If the resource is a file, the destination path is defined based on the file MIME type.</li>
+<li>The file is moved to the new location.</li>
+</ul>
+<p>or in Java Code:</p>
+<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
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">process</span><span class="o">(</span><span class="n">Event</span> <span class="n">event</span><span class="o">)</span> <span class="o">{</span>
+    <span class="n">Session</span> <span class="n">adminSession</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+    <span class="k">try</span> <span class="o">{</span>
+        <span class="n">String</span> <span class="n">resourcePath</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="n">event</span><span class="o">.</span><span class="na">getProperty</span><span class="o">(</span><span class="s">&quot;resourcePath&quot;</span><span class="o">);</span>
+        <span class="n">String</span> <span class="n">resourceName</span> <span class="o">=</span> <span class="n">resourcePath</span><span class="o">.</span><span class="na">substring</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">.</span><span class="na">lastIndexOf</span><span class="o">(</span><span class="s">&quot;/&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">);</span>
+        <span class="n">adminSession</span> <span class="o">=</span> <span class="n">repository</span><span class="o">.</span><span class="na">loginAdministrative</span><span class="o">(</span><span class="kc">null</span><span class="o">);</span>
+        <span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">resolverFactory</span><span class="o">.</span><span class="na">getResourceResolver</span><span class="o">(</span><span class="n">adminSession</span><span class="o">);</span>
+        <span class="n">Resource</span> <span class="n">res</span> <span class="o">=</span> <span class="n">resourceResolver</span><span class="o">.</span><span class="na">getResource</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">);</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">ResourceUtil</span><span class="o">.</span><span class="na">isA</span><span class="o">(</span><span class="n">res</span><span class="o">,</span> <span class="s">&quot;nt:file&quot;</span><span class="o">))</span> <span class="o">{</span>
+            <span class="n">String</span> <span class="n">mimeType</span> <span class="o">=</span> <span class="n">res</span><span class="o">.</span><span class="na">getResourceMetadata</span><span class="o">().</span><span class="na">getContentType</span><span class="o">();</span>
+            <span class="n">String</span> <span class="n">destDir</span><span class="o">;</span>
+            <span class="k">if</span> <span class="o">(</span><span class="n">mimeType</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="s">&quot;image/png&quot;</span><span class="o">))</span> <span class="o">{</span>
+                <span class="n">destDir</span> <span class="o">=</span> <span class="n">IMAGES_PATH</span><span class="o">;</span>
+            <span class="o">}</span>
+            <span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">mimeType</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="s">&quot;audio/mpeg&quot;</span><span class="o">))</span> <span class="o">{</span>
+                <span class="n">destDir</span> <span class="o">=</span> <span class="n">MUSIC_PATH</span><span class="o">;</span>
+            <span class="o">}</span>
+            <span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">mimeType</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="s">&quot;video/x-msvideo&quot;</span><span class="o">))</span> <span class="o">{</span>
+                <span class="n">destDir</span> <span class="o">=</span> <span class="n">MOVIES_PATH</span><span class="o">;</span>
+            <span class="o">}</span>
+            <span class="k">else</span> <span class="o">{</span>
+                <span class="n">destDir</span> <span class="o">=</span> <span class="n">OTHER_PATH</span><span class="o">;</span>
+            <span class="o">}</span>
+            <span class="n">adminSession</span><span class="o">.</span><span class="na">move</span><span class="o">(</span><span class="n">resourcePath</span><span class="o">,</span> <span class="n">destDir</span> <span class="o">+</span> <span class="n">resourceName</span><span class="o">);</span>
+            <span class="n">adminSession</span><span class="o">.</span><span class="na">save</span><span class="o">();</span>
+            <span class="n">log</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;The file {} has been moved to {}&quot;</span><span class="o">,</span> <span class="n">resourceName</span><span class="o">,</span> <span class="n">destDir</span><span class="o">);</span>
+        <span class="o">}</span>
+        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
+    <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">RepositoryException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+        <span class="n">log</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;RepositoryException: &quot;</span> <span class="o">+</span> <span class="n">e</span><span class="o">);</span>
+        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
+    <span class="o">}</span> <span class="k">finally</span> <span class="o">{</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">adminSession</span> <span class="o">!=</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="n">adminSession</span><span class="o">.</span><span class="na">isLive</span><span class="o">())</span> <span class="o">{</span>
+            <span class="n">adminSession</span><span class="o">.</span><span class="na">logout</span><span class="o">();</span>
+            <span class="n">adminSession</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+</td></tr></table>
+
+<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. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+        Rev. 1345850 by fmeschbe on Mon, 4 Jun 2012 07:40:42 +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/tutorials-how-tos/installing-and-upgrading-bundles.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/installing-and-upgrading-bundles.html (original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/installing-and-upgrading-bundles.html Mon Jun  4 07:41:23 2012
@@ -82,14 +82,13 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/tutorials-how-tos.html">Tutorials & How-Tos</a>
       </div>
       <h1>Installing and Upgrading Bundles</h1>
-      <h1 id="installing-and-upgrading-bundles">Installing and Upgrading Bundles</h1>
-<p>{note}
-We recommend to use the Apache Felix Web Console. The documentation below describes the old Sling Management Console, which isn't in use any more. Please refer to the documentation of the <a href="">Apache Felix Web Console</a>.
+      <p>{note}
+We recommend to use the Apache Felix Web Console. The documentation below describes the old Sling Management Console, which isn't in use any more. Please refer to the documentation of the <a href="http://felix.apache.org/site/apache-felix-web-console.html">Apache Felix Web Console</a>.
 {note}</p>
 <p>OSGi bundles installed in the OSGi framework, which is provided by Sling, may be upgraded or removed and new bundles may be installed by using the Sling Management Console. This page is about using the Sling Management Console for those tasks.</p>
 <p>Basically, you have two choices to install and upgrade bundles: Upload the bundle files or install them from a Bundle Repository.</p>
 <h2 id="sling-management-console">Sling Management Console</h2>
-<p>The Sling Management Console is installed by default when Sling is running and may be reached at on the page <code>/system/console</code> in the Sling Context by default. For example if you installed the Sling Web Application in the <code>/sample</code> context of the Servlet Container running at <code>http``://somehost:4402</code>, you would access the Sling Management Console at <code>http``://somehost:4402/sample/system/console</code>.</p>
+<p>The Sling Management Console is installed by default when Sling is running and may be reached at on the page <code>/system/console</code> in the Sling Context by default. For example if you installed the Sling Web Application in the <code>/sample</code> context of the Servlet Container running at <code>http://somehost:4402</code>, you would access the Sling Management Console at <code>http://somehost:4402/sample/system/console</code>.</p>
 <p>You will be prompted for a user name and password to access the Sling Management Console. This password is preset to be <em>admin</em> for the user name and <em>admin</em> for the password.</p>
 <p>NB: Both the username and password and the location of the Sling Management Console inside the Web Application Context is configurable in the <em>Sling Management Console</em> configuration on the <em>Configuration</em> page.</p>
 <h2 id="installing-and-upgrading-bundles-by-upload">Installing and upgrading bundles by Upload</h2>
@@ -115,13 +114,28 @@ We recommend to use the Apache Felix Web
 <p>Currently management of known OSGi Bundle Repositories is very simple. If a configured bundle repository is not available on startup, it will be marked as being inactive. If you know the repository is now available, you may click on the <em>Refresh</em> button, to activate it. Similarly, the contents of the repository may be modified by for example adding new bundles or updating bundles in the repository, these changes will be made known to Sling by clicking the <em>Refresh</em> button.</p>
 <p>There exists no GUI functionality yet to add a new repository to the list of known repositories. Instead you may submit a request with parameters <code>action</code> whose value must be <code>refreshOBR</code> and <code>repository</code> whose value must be the URL to the repository descriptor file generally called <code>repository.xml</code>.</p>
 <p>For example, if you run Sling on <code>http``://localhost:7402/sample</code> with default location of the Sling Management Console, the following request would add a repository at <code>/tmp/repo/repository.xml</code> in the filesystem:</p>
-<div class="codehilite"><pre><span class="n">http:</span><span class="sr">//</span><span class="n">localhost:7402</span><span class="sr">/sample/s</span><span class="n">ystem</span><span class="sr">/console/</span><span class="n">bundlerepo</span><span class="p">?</span><span class="n">action</span><span class="o">=</span><span class="n">refreshOBR</span><span class="o">&amp;</span><span class="n">repository</span><span class="o">=</span><span class="n">file:</span><span class="sr">///tmp/</span><span class="n">repo</span><span class="o">/</span><span class="n">repository</span><span class="o">.</span><span class="n">xml</span>
+<div class="codehilite"><pre>http://localhost:7402/sample/system/console/bundlerepo?action=refreshOBR<span class="err">&amp;</span>repository=file:///tmp/repo/repository.xml
 </pre></div>
 
 
+<p>Some Java Sample:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5
+6</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Test</span> <span class="o">{</span>
+    <span class="kd">public</span> <span class="kd">static</span> <span class="n">String</span> <span class="n">x</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">;</span>
+    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
+        <span class="kt">int</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+</td></tr></table>
+
 <p>Note: Only use <code>file:</code> URLs if you know Sling has access to the named file !</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+        Rev. 1345850 by fmeschbe on Mon, 4 Jun 2012 07:40:42 +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/tutorials-how-tos/jackrabbit-persistence.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html (original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html Mon Jun  4 07:41:23 2012
@@ -98,15 +98,23 @@
 <ol>
 <li>Get the JDBC driver for your database from the driver provider</li>
 <li>
-<p>Wrap the JDBC driver library into an OSGi bundle:</p>
-<h1 id="example-for-postgresql-jdbc-3-driver-84-701">Example for PostgreSQL JDBC 3 driver 8.4-701</h1>
-<p>$ java -jar bnd.jar wrap postgresql-8.4-701.jdbc3.jar
-$ mv postgresql-8.4-701.jdbc3.bar postgresql-8.4-701.jdbc3-bnd.jar</p>
+<p>Wrap the JDBC driver library into an OSGi bundle:  <br />
+</p>
+<div class="codehilite"><pre><span class="c"># Example for PostgreSQL JDBC 3 driver 8.4-701</span>
+<span class="nv">$ </span>java -jar bnd.jar wrap postgresql-8.4-701.jdbc3.jar
+<span class="nv">$ </span>mv postgresql-8.4-701.jdbc3.bar postgresql-8.4-701.jdbc3-bnd.jar
+</pre></div>
+
+
 </li>
 <li>
 <p>Deploy the driver to your local Maven 2 Repository (Required if adding the JDBC driver to a Maven build, e.g. using the Sling Launchpad Plugin)</p>
-<p>$ mvn install:install-file -DgroupId=postgresql -DartifactId=postgresql -Dversion=8.4.701.jdbc3 \  <br />
-        -Dpackaging=jar -Dfile=postgresql-8.4-701.jdbc3-bnd.jar</p>
+<div class="codehilite"><pre><span class="nv">$ </span>mvn install:install-file <span class="se">\ </span> 
+    -DgroupId<span class="o">=</span>postgresql -DartifactId<span class="o">=</span>postgresql -Dversion<span class="o">=</span>8.4.701.jdbc3 <span class="se">\ </span> 
+    -Dpackaging<span class="o">=</span>jar -Dfile<span class="o">=</span>postgresql-8.4-701.jdbc3-bnd.jar
+</pre></div>
+
+
 </li>
 </ol>
 <p>Tony reports no success with the Spring Source bundle, whily the BND approach worked for the PostgreSQL JDBC driver.</p>
@@ -127,30 +135,30 @@ This needs to be reconfigured and restar
 <p>For example to use PostgreSQL instead of Derby modify the <code>&lt;PersistenceManager&gt;</code> elements as follows:</p>
 <div class="codehilite"><pre><span class="nt">&lt;Repository&gt;</span>
     ...
-    <span class="nt">&lt;Workspace</span> <span class="na">name=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">wsp</span><span class="o">.</span><span class="n">name</span><span class="cp">}</span><span class="s">&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;Workspace</span> <span class="na">name=</span><span class="s">&quot;${wsp.name}&quot;</span><span class="nt">&gt;</span>
         ...
         <span class="nt">&lt;PersistenceManager</span> <span class="na">class=</span><span class="s">&quot;org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager&quot;</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;driver&quot;</span> <span class="na">value=</span><span class="s">&quot;org.postgresql.Driver&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;url&quot;</span> <span class="na">value=</span><span class="s">&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schema&quot;</span> <span class="na">value=</span><span class="s">&quot;postgresql&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;user&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_USER_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;password&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_PASSWORD_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schemaObjectPrefix&quot;</span> <span class="na">value=</span><span class="s">&quot;jcr_</span><span class="cp">${</span><span class="n">wsp</span><span class="o">.</span><span class="n">name</span><span class="cp">}</span><span class="s">_&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;externalBLOBs&quot;</span> <span class="na">value=</span><span class="s">&quot;false&quot;/</span><span class="nt">&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;driver&quot;</span> <span class="na">value=</span><span class="s">&quot;org.postgresql.Driver&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;url&quot;</span> <span class="na">value=</span><span class="s">&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schema&quot;</span> <span class="na">value=</span><span class="s">&quot;postgresql&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;user&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_USER_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;password&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_PASSWORD_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schemaObjectPrefix&quot;</span> <span class="na">value=</span><span class="s">&quot;jcr_${wsp.name}_&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;externalBLOBs&quot;</span> <span class="na">value=</span><span class="s">&quot;false&quot;</span><span class="nt">/&gt;</span>
         <span class="nt">&lt;/PersistenceManager&gt;</span>
         ...
     <span class="nt">&lt;/Workspace&gt;</span>
 
-    <span class="nt">&lt;Versioning</span> <span class="na">rootPath=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">rep</span><span class="o">.</span><span class="n">home</span><span class="cp">}</span><span class="s">/version&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;Versioning</span> <span class="na">rootPath=</span><span class="s">&quot;${rep.home}/version&quot;</span><span class="nt">&gt;</span>
         ...
         <span class="nt">&lt;PersistenceManager</span> <span class="na">class=</span><span class="s">&quot;org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager&quot;</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;driver&quot;</span> <span class="na">value=</span><span class="s">&quot;org.postgresql.Driver&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;url&quot;</span> <span class="na">value=</span><span class="s">&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schema&quot;</span> <span class="na">value=</span><span class="s">&quot;postgresql&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;user&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_USER_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;password&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_PASSWORD_HERE&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schemaObjectPrefix&quot;</span> <span class="na">value=</span><span class="s">&quot;version_&quot;/</span><span class="nt">&gt;</span>
-            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;externalBLOBs&quot;</span> <span class="na">value=</span><span class="s">&quot;false&quot;/</span><span class="nt">&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;driver&quot;</span> <span class="na">value=</span><span class="s">&quot;org.postgresql.Driver&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;url&quot;</span> <span class="na">value=</span><span class="s">&quot;jdbc:postgresql://localhost:5432/YOUR_DB_NAME_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schema&quot;</span> <span class="na">value=</span><span class="s">&quot;postgresql&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;user&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_USER_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;password&quot;</span> <span class="na">value=</span><span class="s">&quot;YOUR_PASSWORD_HERE&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;schemaObjectPrefix&quot;</span> <span class="na">value=</span><span class="s">&quot;version_&quot;</span><span class="nt">/&gt;</span>
+            <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">&quot;externalBLOBs&quot;</span> <span class="na">value=</span><span class="s">&quot;false&quot;</span><span class="nt">/&gt;</span>
         <span class="nt">&lt;/PersistenceManager&gt;</span>
     <span class="nt">&lt;/Versioning&gt;</span>
     ...
@@ -164,7 +172,7 @@ This needs to be reconfigured and restar
 <h2 id="credits">Credits</h2>
 <p>This description is based on Tony Giaccone's description <a href="http://markmail.org/message/wlbfrukmjjsl33hh">Swapping Postgres for Derby</a> sent to the Sling Users mailing list.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1345726 by fmeschbe on Sun, 3 Jun 2012 17:57:55 +0000
+        Rev. 1345850 by fmeschbe on Mon, 4 Jun 2012 07:40:42 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message