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 2014/01/31 05:15:06 UTC

svn commit: r895890 - in /websites/staging/sling/trunk/content: ./ documentation/bundles/models.html

Author: buildbot
Date: Fri Jan 31 04:15:06 2014
New Revision: 895890

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/bundles/models.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Jan 31 04:15:06 2014
@@ -1 +1 @@
-1562473
+1563050

Modified: websites/staging/sling/trunk/content/documentation/bundles/models.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/models.html (original)
+++ websites/staging/sling/trunk/content/documentation/bundles/models.html Fri Jan 31 04:15:06 2014
@@ -280,8 +280,25 @@
 
 
 <p>When a resource is adapted to <code>MyModel</code>, a child resource named <code>image</code> is automatically adapted to an instance of <code>ImageModel</code>.</p>
+<p>Constructor injection is supported for the adaptable itself. For example:</p>
+<div class="codehilite"><pre><span class="nd">@Model</span><span class="o">(</span><span class="n">adaptables</span><span class="o">=</span><span class="n">Resource</span><span class="o">.</span><span class="na">class</span><span class="o">)</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyModel</span> <span class="o">{</span>
+
+    <span class="kd">public</span> <span class="nf">MyModel</span><span class="o">(</span><span class="n">Resource</span> <span class="n">resource</span><span class="o">)</span> <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span class="na">resource</span> <span class="o">=</span> <span class="n">resource</span><span class="o">;</span>
+    <span class="o">}</span>
+
+    <span class="kd">private</span> <span class="kd">final</span> <span class="n">Resource</span> <span class="n">resource</span><span class="o">;</span>
+
+    <span class="nd">@Inject</span>
+    <span class="kd">private</span> <span class="n">String</span> <span class="n">propertyName</span><span class="o">;</span>
+<span class="o">}</span>
+</pre></div>
+
+
 <h1 id="custom-injectors">Custom Injectors</h1>
 <p>To create a custom injector, simply implement the <code>org.apache.sling.models.spi.Injector</code> interface and register your implementation with the OSGi service registry. Please refer to the standard injectors in <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/injectors/">Subversion</a> for examples.</p>
+<p>Injectors are invoked in order of their service ranking, from lowest to highest. See the table below for the rankings of the standard injectors.</p>
 <h1 id="annotation-reference">Annotation Reference</h1>
 <dl>
 <dt><code>@Model</code></dt>
@@ -309,51 +326,51 @@
 <tr>
 <th>Title</th>
 <th>Name (for <code>@Source</code>)</th>
+<th>Service Ranking</th>
 <th>Description</th>
 <th>Applicable To (including using <code>@Via</code>)</th>
-<th>Notes</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td>Value Map</td>
-<td><code>valuemap</code></td>
-<td>Gets a property from a <code>ValueMap</code></td>
-<td>Any object which is or can be adapted to a <code>ValueMap</code></td>
-<td></td>
-</tr>
-<tr>
-<td>OSGI Services</td>
-<td><code>osgi-services</code></td>
-<td>Lookup services based on class name</td>
-<td>Any object</td>
-<td>Effectively ignores name.</td>
-</tr>
-<tr>
 <td>Script Bindings</td>
 <td><code>script-bindings</code></td>
+<td>1000</td>
 <td>Lookup objects in the script bindings object</td>
 <td>A ServletRequest object which has the <code>Sling Bindings</code> attribute defined</td>
-<td></td>
+</tr>
+<tr>
+<td>Value Map</td>
+<td><code>valuemap</code></td>
+<td>2000</td>
+<td>Gets a property from a <code>ValueMap</code></td>
+<td>Any object which is or can be adapted to a <code>ValueMap</code></td>
 </tr>
 <tr>
 <td>Child Resources</td>
 <td><code>child-resources</code></td>
+<td>3000</td>
 <td>Gets a child resource by name</td>
 <td><code>Resource</code> objects</td>
-<td></td>
 </tr>
 <tr>
 <td>Request Attributes</td>
 <td><code>request-attributes</code></td>
+<td>4000</td>
 <td>Get a request attribute</td>
 <td><code>ServletRequest</code> objects</td>
-<td></td>
+</tr>
+<tr>
+<td>OSGI Services</td>
+<td><code>osgi-services</code></td>
+<td>5000</td>
+<td>Lookup services based on class name</td>
+<td>Any object</td>
 </tr>
 </tbody>
 </table>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1560710 by justin on Thu, 23 Jan 2014 15:13:22 +0000
+        Rev. 1563050 by justin on Fri, 31 Jan 2014 04:14:34 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project