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
ConstructorsConstructorDescriptionAnnotationCollector(Logger reporter, aQute.bnd.osgi.Analyzer analyzer) Makes a new Collector for parsing a given class. -
Method Summary
Modifier and TypeMethodDescriptionvoidannotation(aQute.bnd.osgi.Annotation annotation) An annotation has been parsed.voidbaseClass(boolean baseClass) Indicates that we are parsing a superclass of a given component class.voidclassBegin(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) voidextendsClass(aQute.bnd.osgi.Descriptors.TypeRef name) voidfield(aQute.bnd.osgi.Clazz.FieldDef field) Parses a field.booleanfinish()Finishes up the class parsing.Returns list of all exported services.Returns list of all imported services.aQute.bnd.osgi.Descriptors.TypeRefvoidimplementsInterfaces(aQute.bnd.osgi.Descriptors.TypeRef[] interfaces) Parses the implemented interfaces ("/" separated).voidmethod(aQute.bnd.osgi.Clazz.MethodDef method) Parses a method.static StringparseClassAttrValue(Object value) Parse the value of a given annotation attribute (which is of type 'class').voidwriteTo(PrintWriter pw) 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
-
Constructor Details
-
AnnotationCollector
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:
classBeginin classaQute.bnd.osgi.ClassDataCollector- Parameters:
access- the class accessname- the class name (package are "/" separated).
-
implementsInterfaces
public void implementsInterfaces(aQute.bnd.osgi.Descriptors.TypeRef[] interfaces) Parses the implemented interfaces ("/" separated).- Overrides:
implementsInterfacesin classaQute.bnd.osgi.ClassDataCollector
-
method
public void method(aQute.bnd.osgi.Clazz.MethodDef method) Parses a method. Always invoked BEFORE eventual method annotation.- Overrides:
methodin classaQute.bnd.osgi.ClassDataCollector
-
field
public void field(aQute.bnd.osgi.Clazz.FieldDef field) Parses a field. Always invoked BEFORE eventual field annotation- Overrides:
fieldin classaQute.bnd.osgi.ClassDataCollector
-
extendsClass
public void extendsClass(aQute.bnd.osgi.Descriptors.TypeRef name) - Overrides:
extendsClassin classaQute.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:
annotationin classaQute.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
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
Returns list of all imported services. Imported services are deduced from every- Returns:
- the list of imported services, or null
-
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
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 attributeattr- the attribute name (of 'class' type).- Returns:
- the annotation class attribute value
-
entry
-