Wrap or Decorate ResourcesPage edited by Justin EdelsonChanges (2)
Full ContentService to wrap resourcesIntroductionThe Sling API provides an easy way to wrap or decorate a resource before returning. Use cases for this could for example be
To add a resource decorator just register one or more services which implement the interface ResourceDecorator
interface ResourceDecorator {
Resource decorate(Resource)
@Deprecated
Resource decorate(Resource, HttpServletRequest)
}
The registered decorators will be called from the resource resolver for each resource returned. The two-argument {{ Unknown macro: {decorate}
}} method will not be invoked, starting with version 2.1.0 of the JCR Resource bundle. Implementors of this interface targeting both newer and older versions of this bundle are advised to implement this method with:
public Resource decorate(Resource resource, HttpServletRequest request) {
return this.decorate(resource);
}
And use some other method (e.g. a {{ Unknown macro: {ThreadLocal}
}}) to obtain the current request if necessary.
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Sling Website > Wrap or Decorate Resources confluence
- [CONF] Apache Sling Website > Wrap or Decorate Resource... confluence
- [CONF] Apache Sling Website > Wrap or Decorate Resource... confluence
