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:06: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>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~mykee">Mike
Mueller</a>
    </h4>
         <br/>
    <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 servie does
not want to decorate the resource, it should return the original resource. </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/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