[ 
https://issues.apache.org/jira/browse/SLING-4212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Seifert updated SLING-4212:
----------------------------------
    Attachment: resourcePath-API_updated.patch

i've checked the updated patch and did some cosmetic fixes (removed some unused 
imports, slight formatting chagens, one typo), attached new patch:
[^resourcePath-API_updated.patch]

the only real logic change i did was in ResourcePathInjector.getResources. 
there is a log statement:
{code:java}
LOG.warn("Could not retrieve resource at path {} for field {}", path, 
fieldName);
{code}
but this happens if the injection is marked as optional. if it is optional and 
could not be injected this should not be a warning. i changed it to DEBUG.

but before applying this patch i found a last problem:
* you added a new method "isRequired" to detect whether the injection is 
successfull or not of not all paths could be resolved
* normally it is not the responsibility of an injector to resolve all these 
variants of injection annotations, this is done by the model adapter factory 
itself. but in this case this is required because there is no other possibility 
for the injector to get this information, thus this code is a bit duplicated.
* but the biggest problem is that the {{defaultInjectionStrategy}} property is 
ignored, which can be defined on the @Model annotation. thus the implementation 
of isRequired is not correct. furthermore i see no possibility to get hold of 
the @Model annotation without changing all SPI interfaces to path it through to 
the injector (or at least path through the required state of the injection).

we cannot apply it as it is with false required detection. is it worth to 
change the whole SPI infrastructure (e.g. introduction a new Injector2 
interface with a different signature for getValue)? or other ideas to solve 
this?

> Sling Models: Allow multiple values from ValueMap in the resource-path 
> injector
> -------------------------------------------------------------------------------
>
>                 Key: SLING-4212
>                 URL: https://issues.apache.org/jira/browse/SLING-4212
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: santiago garcĂ­a pimentel
>            Assignee: Stefan Seifert
>             Fix For: Sling Models API 1.2.0, Sling Models Impl 1.2.0
>
>         Attachments: resourcePath-API.patch, resourcePath-API_updated.patch
>
>
> The current implementation of the resource-path injector does not support 
> multiple values. I think it could be useful to inject a list of paths from 
> the valuemap.
>  I have created a small patch to allow this. Right now it only allows them 
> from the value map since I didn't want to change the API without consulting 
> you first. I you agree I can do this change as well. I also added a test case 
> for it.
> You can see a pull request in https://github.com/apache/sling/pull/51
> If there anything I can do to improve this patch, please let me know.



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

Reply via email to