incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Sling Website > Wrap or Decorate Resources
Date Tue, 24 Aug 2010 19:06:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
<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="">Wrap
or Decorate Resources</a></h2>
    <h4>Page  <b>added</b> by             <a href="">Mike
    <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>
	<li>overwrite resource type/resource super type (for example based on the resource
	<li>add metadata</li>

<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)

<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 id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message