I agree with Betrand about just a few more characters to type, either the method takes in the resource or request. ThreadLocals would be cool but I'm not sure of the impacts and complications arising in OSGi.
Sarwar On Mon, May 14, 2012 at 3:07 PM, Bertrand Delacretaz <[email protected] > wrote: > On Mon, May 14, 2012 at 2:55 PM, Chetan Mehrotra > <[email protected]> wrote: > > ...It would be helpful if we can expose the current > SlingHttpServletRequest or > > ResourceResolver via a threadlocal... > > aarghh ;-) > > > ..This would simplify code where we need > > pass the request as method parameters . This can be done via a simple > > FIlter which publishes the request into a thread local and have a new API > > class which makes this request accessible.... > > This would work, but I would be against including such a filter in the > Sling codebase. > > Passing the request to a method clearly indicates that you expect that > method to deal with it. It's a few more characters to type, but it > makes things clear. > > IMHO, it's too easy to create a mess with threadlocals, which are just > another kind of global variables. > > -Bertrand >
