[
https://issues.apache.org/jira/browse/SLING-3876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14107006#comment-14107006
]
Justin Edelson commented on SLING-3876:
---------------------------------------
Addressed in r1619847. If there is no @Self annotation, then the self injector
only injects on the first constructor parameter. I think this preserves
backwards compatibility. Basically, you should always use the @Self annotation.
> SelfInjector is too aggressive
> ------------------------------
>
> Key: SLING-3876
> URL: https://issues.apache.org/jira/browse/SLING-3876
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Reporter: Justin Edelson
> Assignee: Justin Edelson
> Labels: models
> Fix For: Sling Models Implementation 1.0.8
>
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> The service ranking of the self injector is currently 100. Since the only
> restriction it has is based on class, this blocks any of the other standard
> injectors from providing an object which has the same supertype as the
> adaptable. For example, if you did:
> Resource someOtherResource = resourceResolver.getResource("/something");
> request.setAttribute("foo", someOtherResource);
> @Model(adaptable=Resource.class)
> public interface GettingFoo {
> @Inject @Named("foo")
> Resource getFooResource();
> }
> getFooResource() would return the adaptable, not the resource.
> I'll increase the service ranking to MAX_INTEGER as a first step, but this
> might require something additional.
--
This message was sent by Atlassian JIRA
(v6.2#6252)