Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1920

DI: add support for decorators

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.M2
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: