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

Justin Edelson commented on SLING-5739:
---------------------------------------

In terms of other `@Via` providers, one more that could make sense is a path 
reference provider.

{code}
- foo (nt:unstructured)
  + otherPath (String) = "/bar"
  + myProperty (String) = "mine"
- bar (nt:unstructured)
  + otherProperty (String) = "other"
 {code}

And then...

{code}
@Model(adaptable = Resource.class)
public interface Foo {

    @Inject @Via(value = "otherPath", type = PathReference.class)
    String getOtherProperty();

    @Inject
    String  getMyProperty();

}
{code}

{code}
Resource r = resourceResolver.getResource("/foo");
Foo foo = r.adaptTo(Foo.class);
assertEquals("other", foo.getOtherProperty());
{code}

> [Sling Models] Allow for extensible @Via providers
> --------------------------------------------------
>
>                 Key: SLING-5739
>                 URL: https://issues.apache.org/jira/browse/SLING-5739
>             Project: Sling
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Justin Edelson
>
> Currently, @Via support in Sling Models is limited to JavaBean properties. It 
> would be useful to be able to extend this and allow for downstream projects 
> to add new @Via providers.
> Proposing to support this by extending the @Via annotation
> {code}
> @Via(value = "jcr:content", type = ChildResource.class)
> {code}
> The default type is BeanProperty (the current behavior).
> New providers can be added by implementing a ViaProvider SPI and provide a 
> marker class for use in the annotation.



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

Reply via email to