Class AnnotationCollector

java.lang.Object
aQute.bnd.osgi.ClassDataCollector
org.apache.felix.dm.annotation.plugin.bnd.AnnotationCollector

public class AnnotationCollector extends aQute.bnd.osgi.ClassDataCollector
This is the scanner which does all the annotation parsing on a given class. To start the parsing, just invoke the parseClassFileWithCollector and finish methods. Once parsed, the corresponding component descriptors can be built using the "writeTo" method.
Author:
Felix Project Team
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnnotationCollector(Logger reporter, aQute.bnd.osgi.Analyzer analyzer)
    Makes a new Collector for parsing a given class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    annotation(aQute.bnd.osgi.Annotation annotation)
    An annotation has been parsed.
    void
    baseClass(boolean baseClass)
    Indicates that we are parsing a superclass of a given component class.
    void
    classBegin(int access, aQute.bnd.osgi.Descriptors.TypeRef name)
    Parses the name of the class.
    static <K, V> Map.Entry<K,V>
    entry(K key, V value)
     
    void
    extendsClass(aQute.bnd.osgi.Descriptors.TypeRef name)
     
    void
    field(aQute.bnd.osgi.Clazz.FieldDef field)
    Parses a field.
    boolean
    Finishes up the class parsing.
    Returns list of all exported services.
    Returns list of all imported services.
    aQute.bnd.osgi.Descriptors.TypeRef
     
    void
    implementsInterfaces(aQute.bnd.osgi.Descriptors.TypeRef[] interfaces)
    Parses the implemented interfaces ("/" separated).
    void
    method(aQute.bnd.osgi.Clazz.MethodDef method)
    Parses a method.
    static String
    Parse the value of a given annotation attribute (which is of type 'class').
    void
    Writes the generated component descriptor in the given print writer.

    Methods inherited from class aQute.bnd.osgi.ClassDataCollector

    addReference, annotationDefault, annotationDefault, classEnd, classStart, classStart, constant, deprecated, enclosingMethod, innerClass, memberEnd, methodParameters, parameter, referenceMethod, referTo, signature, typeuse, version

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AnnotationCollector

      public AnnotationCollector(Logger reporter, aQute.bnd.osgi.Analyzer analyzer)
      Makes a new Collector for parsing a given class.
      Parameters:
      reporter - the object used to report logs.
      m_analyzer -
  • Method Details

    • baseClass

      public void baseClass(boolean baseClass)
      Indicates that we are parsing a superclass of a given component class.
    • classBegin

      public void classBegin(int access, aQute.bnd.osgi.Descriptors.TypeRef name)
      Parses the name of the class.
      Overrides:
      classBegin in class aQute.bnd.osgi.ClassDataCollector
      Parameters:
      access - the class access
      name - the class name (package are "/" separated).
    • implementsInterfaces

      public void implementsInterfaces(aQute.bnd.osgi.Descriptors.TypeRef[] interfaces)
      Parses the implemented interfaces ("/" separated).
      Overrides:
      implementsInterfaces in class aQute.bnd.osgi.ClassDataCollector
    • method

      public void method(aQute.bnd.osgi.Clazz.MethodDef method)
      Parses a method. Always invoked BEFORE eventual method annotation.
      Overrides:
      method in class aQute.bnd.osgi.ClassDataCollector
    • field

      public void field(aQute.bnd.osgi.Clazz.FieldDef field)
      Parses a field. Always invoked BEFORE eventual field annotation
      Overrides:
      field in class aQute.bnd.osgi.ClassDataCollector
    • extendsClass

      public void extendsClass(aQute.bnd.osgi.Descriptors.TypeRef name)
      Overrides:
      extendsClass in class aQute.bnd.osgi.ClassDataCollector
    • getSuperClass

      public aQute.bnd.osgi.Descriptors.TypeRef getSuperClass()
    • annotation

      public void annotation(aQute.bnd.osgi.Annotation annotation)
      An annotation has been parsed. Always invoked AFTER the "method"/"field"/"classBegin" callbacks.
      Overrides:
      annotation in class aQute.bnd.osgi.ClassDataCollector
    • finish

      public boolean finish()
      Finishes up the class parsing. This method must be called once the parseClassFileWithCollector method has returned.
      Returns:
      true if some annotations have been parsed, false if not.
    • writeTo

      public void writeTo(PrintWriter pw)
      Writes the generated component descriptor in the given print writer. The first line must be the component descriptor (@Component or AspectService, etc ..).
      Parameters:
      pw - the writer where the component descriptor will be written.
    • getImportService

      public Set<String> getImportService()
      Returns list of all imported services. Imported services are deduced from every
      Returns:
      the list of imported services, or null
    • getExportService

      public Set<String> getExportService()
      Returns list of all exported services. Imported services are deduced from every annotations which provides a service (@Component, etc ...)
      Returns:
      the list of exported services, or null
    • parseClassAttrValue

      public static String parseClassAttrValue(Object value)
      Parse the value of a given annotation attribute (which is of type 'class'). This method is compatible with bndtools 2.4.1 (where the annotation.get() method returns a String of the form "Lfull/class/name;"), and with bndtools 3.x.x (where the annotation.get() method returns a TypeRef).
      Parameters:
      annot - the annotation which contains the given attribute
      attr - the attribute name (of 'class' type).
      Returns:
      the annotation class attribute value
    • entry

      public static <K, V> Map.Entry<K,V> entry(K key, V value)