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

Konrad Windszus edited comment on SLING-5992 at 8/24/16 2:36 PM:
-----------------------------------------------------------------

Thanks, looks much better now. The only thing which worries me a bit is how to 
deal with relative resource types.
Currently the javadoc on the field {{resourceType}} doesn't say anything about 
relative/absolute resource types. Which ones are supposed to be supported?
What in case you want to support overlays as well (i.e. consider the resource 
resolver's search path)?
For a similar issue in Sling Validation look at 
https://issues.apache.org/jira/browse/SLING-4262.

In reality {{Resource.getResourceType()}} might either return a relative or an 
absolute resource type (depending on the "resourceType" property on your 
content resource). Currently your patch does not take that into account.
I would suggest to allow only to register on a relative resource type (relative 
to one of the RR's search paths). In case an absolute resourceType is being 
returned by {{Resource.getResourceType()}} that should be made relative by 
stripping the according prefix.
Then the comparison/lookup will always only work with relative resource paths. 
The only drawback is, that it is not possible to register models for resource 
types outside of the RR's search patchs.


was (Author: kwin):
Thanks, looks much better now. The only thing which worries me a bit is how to 
deal with relative resource types.
Currently the javadoc on the field {{resourceType}} doesn't say anything about 
relative/absolute resource types. Which ones are supposed to be supported?
What in case you want to support overlays as well (i.e. consider the resource 
resolver's search path)?
For a similar issue in Sling Validation look at 
https://issues.apache.org/jira/browse/SLING-4262.

> Provide a way to map Sling Model classes to resource types
> ----------------------------------------------------------
>
>                 Key: SLING-5992
>                 URL: https://issues.apache.org/jira/browse/SLING-5992
>             Project: Sling
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Justin Edelson
>             Fix For: Sling Models API 1.3.0, Sling Models Impl 1.3.0
>
>         Attachments: SLING-5992.patch, SLING-5992.patch
>
>
> For ease of script development, I would like to introduce a mechanism for 
> mapping Sling Model classes to resource types for Resource and 
> SlingHttpServletRequest objects.
> From an API perspective, this introduces two new methods on ModelFactory:
> {code}
> public Object getModelFromResource(@Nonnull Resource resource);
> public Object getModelFromRequest(@Nonnull SlingHttpServletRequest request);
> {code}
> And a new attribute on the @Model annotations
> {code}
> public String resourceType() default "";
> {code}



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

Reply via email to