incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling Website > Wrap or Decorate Resources
Date Tue, 24 Aug 2010 19:12:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Wrap+or+Decorate+Resources">Wrap
or Decorate Resources</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~mykee">Mike
Mueller</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>The registered decorators
will be called from the resource resolver for each resource returned.  <br></td></tr>
            <tr><td class="diff-changed-lines" >If the service decorates the resource
it should return the new resource. <span class="diff-changed-words">I<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">F</span><span
class="diff-added-chars"style="background-color: #dfd;">f</span></span> the
<span class="diff-changed-words">servi<span class="diff-added-chars"style="background-color:
#dfd;">c</span>e</span> does not want to decorate the resource, it should return
the original <span class="diff-changed-words">resource<span class="diff-added-chars"style="background-color:
#dfd;"> or null</span>.</span> <br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="WraporDecorateResources-Servicetowrapresources"></a>Service
to wrap resources</h1>

<h2><a name="WraporDecorateResources-Introduction"></a>Introduction</h2>

<p>The Sling API provides an easy way to wrap or decorate a resource before returning.
Use cases for this could for example be</p>
<ul>
	<li>overwrite resource type/resource super type (for example based on the resource
path)</li>
	<li>add metadata</li>
</ul>


<h2><a name="WraporDecorateResources-"></a></h2>

<p>To add a resource decorator just register one or more services which implement the
interface <tt>ResourceDecorator</tt></p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">interface</span> ResourceDecorator {
    Resource decorate(Resource)
    Resource decorate(Resource, HttpServletRequest)
} 
</pre>
</div></div>

<p>The registered decorators will be called from the resource resolver for each resource
returned. <br/>
If the service decorates the resource it should return the new resource. If the service does
not want to decorate the resource, it should return the original resource or null. </p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Wrap+or+Decorate+Resources">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23335935&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Wrap+or+Decorate+Resources?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message