This module is part of the Apache Sling project.
Grafting or graftage is a horticultural technique whereby tissues of plants are joined so as to continue their growth together. The upper part of the combined plant is called the scion while the lower part is called the rootstock.
Source: https://en.wikipedia.org/wiki/Grafting
This bundle contains utilities for grafting resource trees (scions) onto existing resources (rootstocks). It is intended to be used with Sling's ResourecDecorator API.
@Component public class ExampleResourceDecorator implements ResourceDecorator { public Resource decorate(final Resource rootstock) { GraftedResource scion = GraftedResource.graftOnto(rootstock); scion.appendChild("foo") // see also appendChild() and insertBefore() .setProperty("bar", this is foo") .parent() // navigate back from "foo" to scion .setProperty("virtual-property", "I'm not persisted') .removeProperty("existing") // hide existing property .removeChild("subtree"); // remove a complete subtree return scion; } ... }