a summary of this thread: - there are good ideas how to implement this, if we want to implement it (via the engine, not a servlet filter) - but there are a lot of objections if we should add such a thread-local-based feature at all with good arguments - still there are usecases for some of us (like me) for needing this, and other API changes do not seem to fulfill the goals
to proceed I see this alternatives: A) revert my changes from SLING-4083, and do not support this feature in sling models and sling at all B) do not add this feature as a main sling feature with a dedicated API, but only implement as it is currently in SLING-4083 to be usable inside sling models C) add it as main feature to sling as part of the public API. for B) and C) we would need a vote. for A) i still have the possibility to implement this outside sling in a custom sling models injector and a request filter, so i'll be fine with this way as well if the community does not want A) or B). stefan >-----Original Message----- >From: Stefan Seifert [mailto:sseif...@pro-vision.de] >Sent: Wednesday, October 22, 2014 10:22 AM >To: dev@sling.apache.org >Subject: [RTC] ThreadLocal for getting current request in sling > >i propose to add a new feature to the Sling API and Sling Engine to access to >the current request via an OSGi service, using a servlet filter and a thread >local internally. > >a proposal for such an implementation is currently part of sling models >trunk, but should be renamed and moved to a more central part if we agree if >it is a good idea. interface [1], impl [2]. > >we have already a comparable threadlocal concept for resource resolver [3] > >my current usecases are: >- having the ability to inject context objects like request in any sling >model, regardless of the adaptable. this is e.g. importing when adapting from >a resource, but in context of a request (SLING-4083) >- configuration parameter override provider which injects overrides from HTTP >header for test environments [4] > >stefan > >p.s. as pointed out by justin this topic was discussed already in the past, >e.g. as a side-aspect of this thread [5]. this thread contains some more >usecaes. > > >[1] >https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl/s >rc/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorReques >tContext.java > >[2] >https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl/s >rc/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorReques >tContextFilter.java > >[3] >http://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/Resource >ResolverFactory.html#getThreadResourceResolver-- > >[4] https://github.com/wcm-io/wcm- >io/blob/master/config/core/src/main/java/io/wcm/config/core/override/impl/Req >uestHeaderOverrideProvider.java > >[5] http://sling.markmail.org/thread/epn5vdw3fkmpsk6w