3 Replies Latest reply on Nov 27, 2009 11:53 AM by kabirkhan



      The BeanAnnotationAdapter currently does this for each bean class/constructor/property/parameter:

      AnnotatedInfo info = class/constructor/property
      MetaDataRetrieval retrieval = //MDR for class/constructor/property/parameter
      List<BeanAnnotationPlugin> list = //get plugins for class/constructor/property/parameter
      for (AnnotationPlugin plugin : list)
       plugin.applyAnnotations(info, retrieval)

      Then the plugin does the following:
      public abstract class AbstractAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends BaseMetaDataAnnotationPlugin<T, C> implements AnnotationPlugin<T, C>
       public final void applyAnnotation(T info, MetaData retrieval, MetaDataVisitor visitor) throws Throwable
       Class<C> annotationClass = getAnnotation();
       C annotation = retrieval.getAnnotation(annotationClass);
       if (annotation == null)
       //create metadata from annotation

      So every class/constructor/property results in a call to MDR.getAnnotation() for each plugin regardless of if annotations exist or not. Would it not make more sense to do something like this instead, which would only hit the MDR.getAnnotation() when there actually are any annotations?
      AnnotatedInfo info = class/constructor/property
      MetaDataRetrieval retrieval = //MDR for class/constructor/property
      Map<Annotation, AnnotationPlugin> map = //get plugins for class/constructor/property
      for (Annotation annotation : info.getAnnotations()){
       AnnotationPlugin plugin = map.get(annotation);
       if (plugin != null)
       plugin.applyAnnotations(info, retrieval);

      For the web beans work the annotation types of the binding types are not known in advance, and so the plugins can not easily be plugged in to the framework. I would like to extend it to accommodate this better as I am currently checking the annotations myself in a custom DescribeAction.