Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-229

introduce @OverridesAttribute for @StereoType

    Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1.EDR
    • Fix Version/s: 2.0 (discussion)
    • Component/s: Beans
    • Labels:
      None

      Description

      We recently had a thread on the DeltaSpike list about using StereoTypes in real world applications: http://markmail.org/thread/ntqwnsyukjvdwspm

      ------
      Imagine the following Stereotype for my Services (I spare out the standard
      stuff)

      @StereoType @Secured @Transactional @ApplicationScoped
      public @interface @Service {}

      The problem here is that there is no way to 'propagate' any rolesAllowed from
      @Service to @Secured, etc.

      What I'd like to have is something like ...

      public @interface @Service

      { String[] rolesAllowed(); TransactionAttributeType transactionType(); }

      where the rolesAllowed() would get propagated to the @Secured meta-annotation
      and transactionType() to the @Transactional
      -----------

      Gerhard Petracek now pointed me to a cool feature which is used in JSR-303 BVAL: @OverridesAttribute
      http://docs.oracle.com/javaee/6/api/javax/validation/OverridesAttribute.html

      We should ping the BVAL EG for the details. There are quite a few little tricks and side effects to consider.

      On the implementation side, we could e.g. pick the @StereoType annotation and automatically propagate those values to the AnnotatedType which get's passed to the Extensions

        Gliffy Diagrams

          Activity

          Hide
          struberg Mark Struberg added a comment -

          Wdyt about naming it @Propagate? Because that's what it does basically...

          Show
          struberg Mark Struberg added a comment - Wdyt about naming it @Propagate? Because that's what it does basically...
          Hide
          spinner José Freitas added a comment - - edited

          That would be very useful.
          I've crossed a dozens times with that need.

          I also liked the @Propagate proposal.

          Show
          spinner José Freitas added a comment - - edited That would be very useful. I've crossed a dozens times with that need. I also liked the @Propagate proposal.
          Hide
          sachsedaniel Daniel Sachse added a comment -

          Yes this would also help me in certain szenarios. The naming sounds good to me too!

          Show
          sachsedaniel Daniel Sachse added a comment - Yes this would also help me in certain szenarios. The naming sounds good to me too!
          Hide
          jharting Jozef Hartinger added a comment -

          Definitely useful. However, note that this does not match the existing SPIs as nicely as it could because CDI currently does not expect stereotypes to have members and thus works with annotation classes instead of annotation instances. For example:

          BeanManager:
          Set<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype)
          BeanAttributes:
          Set<Class<? extends Annotation>> getStereotypes()

          Show
          jharting Jozef Hartinger added a comment - Definitely useful. However, note that this does not match the existing SPIs as nicely as it could because CDI currently does not expect stereotypes to have members and thus works with annotation classes instead of annotation instances. For example: BeanManager: Set<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype) BeanAttributes: Set<Class<? extends Annotation>> getStereotypes()

            People

            • Assignee:
              Unassigned
              Reporter:
              struberg Mark Struberg
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:

                Development