Hi Please don't mingle resource decoration with the feature flag. The use cases are different and returning null from the ResourceDecorator is clearly defined to be same as returning the same resource, i.e. no decoration at all. If this results in NPEs the calling code must be fixed.
Feature flag is about optional hiding (or showing) resources. Decoration is about making the Resource appear differently. Also a ResourceDecorator does not solve the problem: Resource resolution effectively generates a (virtual) list of candidate resources and picks the first of this list to return. Adding feature flags to this actually may influence the selection from the list in that the first (or second or …) is ignored and the second (or third or …) is actually returned. Think back and forth I really think that we should put feature flag support into the ResourceResolver proper. I am opposed to changing API to implement a feature flag solution, which is not complete. Regards Felix — Felix Meschberger | Principal Scientist | Adobe Am 06.12.2013 um 11:48 schrieb Bertrand Delacretaz <bdelacre...@apache.org>: > Hi, > > On Fri, Nov 15, 2013 at 8:40 AM, Felix Meschberger <fmesc...@adobe.com> wrote: >> So, finally, I agree that baking the feature flag support directly into the >> ResourceResolver >> implementation is suboptimal, it is probably still the most comprehensive >> and complete >> solution to the requirements... > > I had another look at this, and the existing ResourceDecorator already > plays a similar role as an extension point to "do something" to each > Resource while it's being resolved. That's already baked in the > resource resolver, so we can leverage it without requiring much code > changes. > > ResourceDecorator.decorate(Resource r) returning null is currently > only vaguely specified and certainly not used, as that causes NPEs in > places - I think we just need to clarify that decorate returning null > causes a Resource to be ignored, fix the code so that it's true and > we're good. > > I have created SLING-3267 to track that, I'll create a patch for review there. > > -Bertrand