[ 
https://issues.apache.org/jira/browse/SLING-5726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15296028#comment-15296028
 ] 

Georg Henzler commented on SLING-5726:
--------------------------------------

I think the main driver should be ease of use from a developers perspective 
(maybe we should create a wiki page with example mappings to make it more 
visual how typical scenarios look like!). Mappings should be easy to read and 
write. So introducing something like {{@Inject @Via(value = "resource", 
forAdaptable = SlingHttpServletRequest.class)}} makes sense iff {{@Inject}} 
alone has a different behaviour, but if {{@Inject}} alone is just defunct (when 
it really could just work), then adding the burden to make all developers add 
{{@Via(value = "resource", forAdaptable = SlingHttpServletRequest.class)}} is 
not reasonable (good framework should have good defaults). 

For me the main point is: Sling Models is about mapping resources to java 
Pojos. We have added the ability to map request context to be able to use the 
models in a controller like fashion. In the end a request is (from a Sling 
Models point of view) just a resource with a "a bit of context".  I would 
therefore handle adaptations from requests/resources almost identical (the only 
difference that the information from the request context is missing, but 
setters can be used to set these values in non-request context use-cases).

> Allow ValueMapInjector and ResourcePathInjector to act directly on 
> SlingHttpServletRequest
> ------------------------------------------------------------------------------------------
>
>                 Key: SLING-5726
>                 URL: https://issues.apache.org/jira/browse/SLING-5726
>             Project: Sling
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: Sling Models Impl 1.2.8
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>         Attachments: SLING-5726.patch
>
>
> Currently both injectors only work correctly on objects being adaptable to a 
> {{ValueMap}}. For {{ValueMapInjector}} this is documented but for 
> {{ResourcePathInjector}} it is not 
> (http://sling.apache.org/documentation/bundles/models.html#available-injectors),
>  although for the latter it does only matter if the path is given through a 
> resource property and not in a static way.
> This should be relaxed that both also work with {{SlingHttpServletRequest}} 
> as that always carries the current resource from which the {{ValueMap}} can 
> be easily retrieved.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to