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

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

[~kwin], I don't 100% agree with that reasoning; I think in 80% of the cases, 
the "adapter.condition"-property is not specified so I don't have a problem 
with it being in a dedicated annotation (just like "adapter.deprecated", which 
is even lesser used). But I think this all comes down to a matter of taste. I'm 
also not against it being in the same annotation.

However, there's one important issue that prevents us from adding the 
"adapter.condition"-member in the @SlingAdapter annotation: There is afaik no 
way to define a default value for the annotation-method that results in the 
property & value being omitted. Hence:

 
{code:java}
@SlingAdapter(adaptables = A.class, adapters = B.class) 
{code}
and

 
{code:java}
@SlingAdapter(adaptables = A.class, adapters = B.class, adapter_condition = "")
{code}
where

 
{code:java}
@SlingAdapter { ... String adapter_condition() default ""; } 
{code}
both result in the same adapter.condition property with an empty string as 
value being added.

It will also be listed in the adapter status page as "Condition: ", instead of 
having the condition omitted.

Do you know of a way to work around this issue? If there is no obvious way to 
do this, I'd suggest to move further with the 3 annotations.

TBH, I think component property types has some serious limitations (but those 
are probably very much backed by the limitations of Java annotations and also 
the Java language spec itself). I do however think it's a very neat way of 
achieving some sort of "API" around often-used configuration metadata.

> 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