You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2014/03/16 15:04:42 UTC

[jira] [Created] (CAY-1920) DI: add support for decorators

Andrus Adamchik created CAY-1920:
------------------------------------

             Summary: DI: add support for decorators
                 Key: CAY-1920
                 URL: https://issues.apache.org/jira/browse/CAY-1920
             Project: Cayenne
          Issue Type: Improvement
            Reporter: Andrus Adamchik
            Assignee: Andrus Adamchik
             Fix For: 3.2.M2


Decorators are a cheap alternative to AOP in DI. They have an advantage of being plain Java code (have you ever seen typical AOP interceptors ... insane unreadable mess) and having good performance (reading a ResultSet using a proxy-based strategy is going to be painful). So adding this simple construct that can be used in DI modules:

binder.bind(I1.class).to(C1.class);       binder.decorate(I1.class).after(D1.class).before(D2.class);

Each decorator declares access to a decorated "delegate" using normal @Inject annotation either in constructor or via a field. As mentioned before, a decorator is simply a class implementing a given interface. Very clean.




--
This message was sent by Atlassian JIRA
(v6.2#6252)