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

Justin Edelson commented on SLING-5726:
---------------------------------------

(Trying to move this conversation to JIRA now that I figured out my login 
issue):

I'm entirely supportive of the notion of using models in multiple contexts, 
which is the basis for this request. My concern here is one of separation of 
concerns. AbstractInjector is *not* API, it is an internal helper. Putting 
additional expectations on Injectors just seems wrong to me.

What we could do as an alternative would be to extend the @Via annotation to 
express some kind of condition, e.g.

@Inject @Via(value = "resource", forAdaptable = SlingHttpServletRequest.class)
private String description;

Which says "for this injection point, use the actual adaptable via 
getResource() when the adaptable is of type SlingHttpServletRequest"

That would work consistently across all Injectors.

This could also eventually necessitate creating a @Vias annotation to wrap 
multiple @Via annotations, but I'd prefer to defer that until it is requested.

WDYT?

> 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