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/27 11:47:34 UTC

svn commit: r1001701 - in /websites/staging/sling/trunk/content: ./ documentation/the-sling-engine/servlets.html

Author: buildbot
Date: Sun Nov 27 11:47:34 2016
New Revision: 1001701

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sun Nov 27 11:47:34 2016
@@ -1 +1 @@
-1771468
+1771567

Modified: websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html (original)
+++ websites/staging/sling/trunk/content/documentation/the-sling-engine/servlets.html Sun Nov 27 11:47:34 2016
@@ -173,17 +173,19 @@ to a script or and servlet.</p>
 <p>Each path to be used for registration - either from the <code>sling.servlet.paths</code> property or constructed from the other <code>sling.servlet.\*</code> properties - must be absolute. Any relative path is made absolute by prefixing it with a root path. This prefix may be set with the <code>sling.servlet.prefix</code> service registration property. If this property is not set, the first entry in the <code>ResourceResolver</code> search path for the <code>ResourceResolver.getResource(String)</code> method is used as the prefix. If this entry cannot be derived, a simpe slash - <code>/</code> - is used as the prefix.</p>
 <p>If <code>sling.servlet.methods</code> is not specified, the servlet is only registered for handling GET and HEAD requests. Make sure to list all methods you want to be handled by this servlet.</p>
 <h4 id="registering-a-servlet-using-java-annotations">Registering a Servlet using Java Annotations<a class="headerlink" href="#registering-a-servlet-using-java-annotations" title="Permanent link">&para;</a></h4>
-<p>If you are working with the default Apache Sling development stack you can use Java Annotations from <a href="http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html">Apache Felix Maven SCR Plugin</a> to register your Sling
-servlets and describe their binding details.</p>
-<p>There are two ways of doing this, either with a Sling-specific @SlingServlet annotation or with the more generic maven-scr-plugin annotations:</p>
+<p>If you are working with the default Apache Sling development stack you can either use 
+<em> <a href="https://osgi.org/javadoc/r6/cmpn/org/osgi/service/component/annotations/package-summary.html">OSGi DS annotations</a> (introduced with DS 1.2/OSGi 5, properly supported since <a href="https://github.com/bndtools/bndtools/wiki/Changes-in-3.0.0">bnd 3.0</a>, being used in <a href="http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html">maven-bundle-plugin 3.0.0</a>) or 
+</em> Generic Felix SCR or Sling-specific <code>@SlingServlet</code> annotations from <a href="http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html">Apache Felix Maven SCR Plugin</a> to register your Sling servlets:</p>
 <ol>
-<li>
-<p>The <code>@SlingServlet</code> annotation</p>
-<div class="codehilite"><pre><span class="nd">@SlingServlet</span><span class="o">(</span>
-    <span class="n">resourceTypes</span> <span class="o">=</span> <span class="s">&quot;sling/servlet/default&quot;</span><span class="o">,</span>
-    <span class="n">selectors</span> <span class="o">=</span> <span class="s">&quot;hello&quot;</span><span class="o">,</span>
-    <span class="n">extensions</span> <span class="o">=</span> <span class="s">&quot;html&quot;</span><span class="o">,</span>
-    <span class="n">methods</span> <span class="o">=</span> <span class="s">&quot;GET&quot;</span><span class="o">)</span>
+<li>OSGi DS annotations (recommended)<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span>
+<span class="n">service</span> <span class="o">=</span> <span class="o">{</span> <span class="n">Servlet</span><span class="o">.</span><span class="na">class</span> <span class="o">},</span>
+<span class="n">property</span> <span class="o">=</span> <span class="o">{</span> 
+    <span class="n">SLING_SERVLET_RESOURCE_TYPES</span> <span class="o">+</span> <span class="s">&quot;=/apps/my/type&quot;</span>
+    <span class="n">SLING_SERVLET_METHODS</span> <span class="o">+</span> <span class="s">&quot;=GET&quot;</span><span class="o">,</span>
+    <span class="n">SLING_SERVLET_EXTENSIONS</span> <span class="o">+</span> <span class="s">&quot;=html&quot;</span><span class="o">,</span>
+    <span class="n">SLING_SERVLET_SELECTORS</span> <span class="o">+</span> <span class="s">&quot;=hello&quot;</span><span class="o">,</span>
+  <span class="o">}</span>
+<span class="o">)</span>
 <span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyServlet</span> <span class="kd">extends</span> <span class="n">SlingSafeMethodsServlet</span> <span class="o">{</span>
 
     <span class="nd">@Override</span>
@@ -195,16 +197,14 @@ servlets and describe their binding deta
 
 
 </li>
-<li>
-<p>The <code>@Properties</code> and <code>@Property</code> annotations</p>
-<div class="codehilite"><pre><span class="nd">@Component</span><span class="o">(</span><span class="n">metatype</span> <span class="o">=</span> <span class="kc">true</span><span class="o">)</span>
-<span class="nd">@Service</span><span class="o">(</span><span class="n">Servlet</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
-<span class="nd">@Properties</span><span class="o">({</span>
-    <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;sling.servlet.resourceTypes&quot;</span><span class="o">,</span> <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;sling/servlet/default&quot;</span><span class="o">),</span>
-    <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;sling.servlet.selectors&quot;</span><span class="o">,</span> <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;hello&quot;</span><span class="o">),</span>
-    <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;sling.servlet.extensions&quot;</span><span class="o">,</span> <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;html&quot;</span><span class="o">),</span>
-    <span class="nd">@Property</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;sling.servlet.methods&quot;</span><span class="o">,</span> <span class="n">value</span> <span class="o">=</span> <span class="s">&quot;GET&quot;</span><span class="o">)</span>
-<span class="o">})</span>
+</ol>
+<p>Custom OSGi DS annotations (e.g. for Sling servlets) are not yet supported by the OSGi spec (and therefore by bnd), but this is supposed to be fixed with DS 1.4 (OSGi 7), see also <a href="https://issues.apache.org/jira/browse/FELIX-5396">FELIX-5396</a>).</p>
+<ol>
+<li>The <code>@SlingServlet</code> annotation (evaluated by maven-scr-plugin)<div class="codehilite"><pre><span class="nd">@SlingServlet</span><span class="o">(</span>
+    <span class="n">resourceTypes</span> <span class="o">=</span> <span class="s">&quot;/apps/my/type&quot;</span><span class="o">,</span>
+    <span class="n">selectors</span> <span class="o">=</span> <span class="s">&quot;hello&quot;</span><span class="o">,</span>
+    <span class="n">extensions</span> <span class="o">=</span> <span class="s">&quot;html&quot;</span><span class="o">,</span>
+    <span class="n">methods</span> <span class="o">=</span> <span class="s">&quot;GET&quot;</span><span class="o">)</span>
 <span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyServlet</span> <span class="kd">extends</span> <span class="n">SlingSafeMethodsServlet</span> <span class="o">{</span>
 
     <span class="nd">@Override</span>
@@ -291,7 +291,7 @@ The mechanism helping the provider here
 <h2 id="error-handler-servlets-or-scripts">Error Handler Servlet(s) or Scripts<a class="headerlink" href="#error-handler-servlets-or-scripts" title="Permanent link">&para;</a></h2>
 <p>Error handling support is described on the <a href="/documentation/the-sling-engine/errorhandling.html">Errorhandling</a> page.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1771468 by kwin on Sat, 26 Nov 2016 11:40:10 +0000
+        Rev. 1771567 by kwin on Sun, 27 Nov 2016 11:47:16 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project