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

Easier access to InjectionPoint qualifiers.

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Obsolete
    • Major
    • None
    • 1.2.Final
    • Beans
    • None

    Description

      I would like to extend javax.enterprise.inject.spi.InjectionPoint for easier analysis of both static and dynamic qualifiers.

      I have previously used InjectionPoint.getAnnotated(), but have now realised that this is not enough because it cannot include AnnotationLiteral qualifiers added via Instance.select(...). The only reliable way to analyse all of the qualifiers is currently via InjectionPoint.getQualifiers(), which unfortunately returns Set<Annotated>.

      A Set<Annotated>> is not immediately useful to me; about the only thing that I can do with it is iterate over it every time. So I must convert it into something more like this first:

      @SuppressWarnings("unchecked")
      public class QualifierMap extends HashMap<Class<? extends Annotation>, Annotation> {
          private static final long serialVersionUID = 1L;
      
          public QualifierMap(Iterable<? extends Annotation> qualifiers) {
              for (Annotation qualifier : qualifiers) {
                  put(qualifier.annotationType(), qualifier);
              }
          }
      
          public <T extends Annotation> T get(Class<T> key) {
              return (T) super.get(key);
          }
      
      }
      

      However, it would be much more convenient if InjectionPoint could export this functionality automatically instead:

      public interface InjectionPoint {
      
          ...
      
          boolean isQualifierPresent(Class<? extends Annotation> annotationType);  
       
          <T extends Annotation> T getQualifier(Class<T> annotationType);
      
          ....
      
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            chrisjr_jira Chris Rankin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: