[
https://issues.apache.org/jira/browse/SLING-5992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15435086#comment-15435086
]
Justin Edelson commented on SLING-5992:
---------------------------------------
I see your point, but I'd prefer a different solution.
* If the annotation's resourceType is absolute, register it with the absolute
type but log a warning.
* When the model class is looked up and the value of resource.getResourceType()
doesn't result in a direct match, iterate over the search paths.
* If the lookup resource type is absolute and starts with a search path, look
up the relative resource type (i.e. /libs/components/foo, lookup components/foo)
* If the lookup resource type is relative, look up each of the absolute
resource types (i.e. components/foo -> /libs/components/foo,
/apps/components/foo)
This accomplishes the same end effect while avoiding the need to use an
administrative resource resolver in the listener and doesn't prevent the
(albeit rare) registration of an absolute type outside of the search path.
> 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)