> On Jan 14, 2010, at 7:30 AM, Vidar Ramdal <[email protected]> wrote: >> I often write PostProcessors to catch a modification to a resource or >> property based on certain criteria. >> [...]
On Thu, Jan 14, 2010 at 3:40 PM, Justin Edelson <[email protected]> wrote: > +1 to the registering PostProcessor for specific resource types. > > I'm less sure of registering by property name and modification type, mostly > because you'll still need to iterate through the modification list. Yes, but that iteration is often duplicated in postprocessors (in my case, anyway), so it would be useful to centralize it. We could introduce a new method (in a new interface extending SlingPostProcessor): public void process(Modification modification, List<Modification> allModifications>, SlingHttpServletRequest req); The 'modification' param would be the actual modification that this postprocessor is subscribed to. 'allModifications' would be the same old modification list. I'm including it because I often inspect other modifications when deciding what to do with the subscribed modification. > Also, it seems like there could be ambiguous cases, e.g. If I register a > PostProcessor with modifiedPropertyNames = [ 'title', 'description' ], does > the PostProcessor get called when only one of those properties is called? We would have to define what to do in those cases. In your example, I would say the PostProcessor gets called twice, once for title, and once for description. If you want your PostProcessor to get called ONLY when BOTH properties are modified, you could of course just iterate through the modification list just as before, and return early from process(). But anyway, we need a clear definition. >> It strikes me that this would make registering a SlingPostProcessor >> somewhat similar to registering a Servlet. Maybe there are some >> synergies here. How about registering PostProcessors on paths, just like we do with servlets? That would allow for fine-grained registering, like multiple /postprocessors/resourceType/propertyName registrations, and even /postprocessors/anyResourceType/propertyName. -- Vidar S. Ramdal <[email protected]> - http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway + 47 22 00 84 00 / +47 21 531941, ext 2070
