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/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestContext.java

[2] 
https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestContextFilter.java

[3] 
http://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolverFactory.html#getThreadResourceResolver--

[4] 
https://github.com/wcm-io/wcm-io/blob/master/config/core/src/main/java/io/wcm/config/core/override/impl/RequestHeaderOverrideProvider.java

[5] http://sling.markmail.org/thread/epn5vdw3fkmpsk6w

Reply via email to