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

Henry Kuijpers commented on SLING-2938:
---------------------------------------

Added the annotations here: 
[https://github.com/henrykuijpers/sling-org-apache-sling-adapter-annotations]

Added IT here: 
[https://github.com/henrykuijpers/sling-org-apache-sling-adapter-annotations-it/]

TODO: Add Javadoc above the annotations. But I don't want to start with this 
before the annotations are approved. 

I created 3 dedicated annotations:
 # *@SlingAdapter* - Can be used to specify the "adaptables"- & 
"adapters"-property. I couldn't figure out how to make specifying a value 
required. Defining the 2 fields is required, but they can still be defined as 
empty arrays (as can be seen in the ITs as well, the consequence is that those 
adapter factories don't get picked up, so this could very well be fine already);
 # *@AdapterCondition* - Can be used to specify the 
"adapter.condition"-property. It is an annotation with only a value-field, so 
that the property name will be derived from the class name and therefore 
becomes "adapter.condition". If not done this way, I had to create an optional 
parameter to the @SlingAdapter annotation, with name "adapter_condition", which 
wasn't very sexy;
 # *@AdapterDeprecated* - Can be used to specify the 
"adapter.deprecated"-property. It is a marker annotation so that the property 
name will become "adapter.deprecated" and the value will always be (boolean) 
true. If not done this way, I had to create an optional parameter to the 
@SlingAdapter annotation, with name "adapter_deprecated", which wasn't very 
sexy + a developer could also specify false, which doesn't make sense.

[~kwin] can you please have a look and let me know what you think? Also, if 
this would be good to go I'll do another commit with updated Javadoc and we'll 
have to see how we can push this into Sling?

> AdapterMethods annotation and adapter proxy service
> ---------------------------------------------------
>
>                 Key: SLING-2938
>                 URL: https://issues.apache.org/jira/browse/SLING-2938
>             Project: Sling
>          Issue Type: Bug
>          Components: Engine, Extensions
>    Affects Versions: Adapter 2.1.0
>            Reporter: Bertrand Delacretaz
>            Priority: Minor
>         Attachments: SLING-2938-api.patch, console.jpg
>
>
> Following up on an idea that Olaf Otto presented at CQCon last week, I've 
> been working on an @AdapterMethod annotation that makes it easier to create 
> Sling adapters, as in
>   @Component
>   @Service
>   public class MyAdapters implements AdapterMethodProvider {
>     @AdapterMethod
>     public Bar toBar(Foo f) { ... adapt Foo to Bar ... }
>   }
> As this requires changes to the sling.api bundle, I'll commit to my 
> whiteboard first, for review



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to