Hi Bertrand

Cool stuff. Let me add some comments:

(1) I think the @AdapterMethod annotation should be just called @Adapter. 
Having an annotation on a method is called "...Method" is strange. And maybe it 
should be in a separate package.
(2) The AdapterMethodProxyManagerImpl class should verify the methods as 
follows: Ensure non-void return type, ensure single argument, ensure no checked 
exceptions declared (@Adapter[Method] JavaDoc must define these requirements). 
Hence the proxy need not catch checked exceptions and re-throw them as 
RuntimeExceptions. In fact, no exceptions should be thrown at all -- rather a 
problem should just be logged and null returned.
(3) Maybe we can find a better name for the AdapterMethodProvider interface -- 
something which is more in line with the AdapterFactory service name. I am also 
undecided whether we need a specific marker interface at all ? Maybe any 
service having annotated methods will do ? Or is this too expensive to check ?

Regards
Felix

Am 01.07.2013 um 11:13 schrieb Bertrand Delacretaz:

> Hi,
> 
> Following up on Olaf Otto's excellent suggestions for simpler/cleaner
> adapters at CQCon, I have created a prototype (in my whiteboard) that
> handles @AdapterMethod annotations - you basically just need to
> annotate a method like
> 
>  @AdapterMethod
>  public Bar adaptToBar(Foo f) { ... }
> 
> in a service that implements the (empty) AdapterMethodsProvider
> interface, to provide a Foo to Bar adapter.
> 
> See SLING-2938 for details, [1] has two examples of
> AdapterMethodsProvider services.
> 
> Feedback is welcome.
> 
> -Bertrand
> 
> [1] 
> https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/adapter-methods/extensions-adapter/src/test/java/org/apache/sling/adapter/internal/AdapterMethodManagerIT.java

Reply via email to