sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r915763 - in /websites/staging/sling/trunk/content: ./ documentation/bundles/models.html
Date Fri, 11 Jul 2014 07:45:18 GMT
Author: buildbot
Date: Fri Jul 11 07:45:17 2014
New Revision: 915763

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 Jul 11 07:45:17 2014
@@ -1 +1 @@
-1609642
+1609643

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 Jul 11 07:45:17
2014
@@ -172,15 +172,16 @@ individually, e.g. the header above will
 
 <p>If a majority of <code>@Inject</code>ed fields/methods are optional,
it is possible (since Sling Models API 1.0.2/Impl 1.0.6) to change the default injection
 strategy by using adding <code>defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL</code>
to the <code>@Model</code> annotation:</p>
-<p>::java
-  @Model(adaptables=Resource.class, defaultInjectionStrategy=DefaultInjectionStrategy.OPTIONAL)
-  public class MyModel {</p>
-<div class="codehilite"><pre>  <span class="p">@</span><span class="n">Inject</span>
-  <span class="n">private</span> <span class="n">String</span> <span
class="n">otherName</span><span class="p">;</span>
+<div class="codehilite"><pre> <span class="p">::</span><span class="n">java</span>
+ <span class="p">@</span><span class="n">Model</span><span class="p">(</span><span
class="n">adaptables</span><span class="p">=</span><span class="n">Resource</span><span
class="p">.</span><span class="n">class</span><span class="p">,</span>
<span class="n">defaultInjectionStrategy</span><span class="p">=</span><span
class="n">DefaultInjectionStrategy</span><span class="p">.</span><span
class="n">OPTIONAL</span><span class="p">)</span>
+ <span class="n">public</span> <span class="n">class</span> <span
class="n">MyModel</span> <span class="p">{</span>
+
+     <span class="p">@</span><span class="n">Inject</span>
+     <span class="n">private</span> <span class="n">String</span>
<span class="n">otherName</span><span class="p">;</span>
+ <span class="p">}</span>
 </pre></div>
 
 
-<p>}</p>
 <p>A default value can be provided (for Strings &amp; primitives):</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>
@@ -223,23 +224,27 @@ strategy by using adding <code>defaultIn
 
 
 <p>List injection for child resources works by injecting grand child resources. For
example, the class</p>
-<p>::java
-  @Model(adaptables=Resource.class)
-  public class MyModel {</p>
-<div class="codehilite"><pre>  <span class="p">@</span><span class="n">Inject</span>
-  <span class="n">private</span> <span class="n">List</span><span
class="o">&lt;</span><span class="n">Resource</span><span class="o">&gt;</span>
<span class="n">addresses</span><span class="p">;</span>
+<div class="codehilite"><pre> <span class="p">::</span><span class="n">java</span>
+ <span class="p">@</span><span class="n">Model</span><span class="p">(</span><span
class="n">adaptables</span><span class="p">=</span><span class="n">Resource</span><span
class="p">.</span><span class="n">class</span><span class="p">)</span>
+ <span class="n">public</span> <span class="n">class</span> <span
class="n">MyModel</span> <span class="p">{</span>
+
+     <span class="p">@</span><span class="n">Inject</span>
+     <span class="n">private</span> <span class="n">List</span><span
class="o">&lt;</span><span class="n">Resource</span><span class="o">&gt;</span>
<span class="n">addresses</span><span class="p">;</span>
+ <span class="p">}</span>
 </pre></div>
 
 
-<p>}</p>
 <p>Is suitable for a resource structure such as:</p>
-<p>+- resource (being adapted)
-   |
-   +- addresses
-      |
-      +- address1
-      |
-      +- address2</p>
+<div class="codehilite"><pre><span class="o">+-</span> <span class="n">resource</span>
<span class="p">(</span><span class="n">being</span> <span class="n">adapted</span><span
class="p">)</span>
+ <span class="o">|</span>
+ <span class="o">+-</span> <span class="n">addresses</span>
+    <span class="o">|</span>
+    <span class="o">+-</span> <span class="n">address1</span>
+    <span class="o">|</span>
+    <span class="o">+-</span> <span class="n">address2</span>
+</pre></div>
+
+
 <p>In this case, the <code>addresses</code> <code>List</code>
will contain <code>address1</code> and <code>address2</code>.</p>
 <p>OSGi injection can be filtered:</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">SlingHttpServletRequest</span><span class="o">.</span><span
class="na">class</span><span class="o">)</span>
@@ -416,7 +421,7 @@ strategy by using adding <code>defaultIn
 </tbody>
 </table>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1609642 by justin on Fri, 11 Jul 2014 07:43:23 +0000
+        Rev. 1609643 by justin on Fri, 11 Jul 2014 07:45:11 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message