Package aQute.bnd.osgi
Class AnnotationHeaders
java.lang.Object
aQute.bnd.osgi.ClassDataCollector
aQute.bnd.osgi.AnnotationHeaders
- All Implemented Interfaces:
Closeable,AutoCloseable
This class parses the 'header annotations'. Header annotations are
annotations that cause headers in the manifest. There are a number of those
headers annotations defined in the aQute.bnd.annotation.headers package, e.g.
BundleCopyright. This module applies the semantics of the defined
fields in those annotations. It is called at the post parse phase in
Analyzer. This ClassDataCollector is called for all classes in our
scope. We first look if any header annotations are applied. We also keep
track of what other annotations are applied to these classes. After all the
classes have been parsed, we look at any of the annotations that was applied
to one of the contained classes. These annotations are also parsed then to
check if they have header annotations applied to them.
This may sound a bit bizarre, so let me explain. The idea is that you can create a custom annotation for a specific resource.
@RequireCapability("osgi.webresource;filter:='(&(osgi.
webresource=/google/angular)(version>=${@version}))") @interface
Angular {}
Now all a user has to do is apply the @Angular annotation. It will then
automatically create a Require-Capability, with the version of the package.
@Angular public class MySpace {...}
About provides some more information.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Analyzerprivate static final Instruction(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringprivate static final Converter(package private) Clazz(package private) boolean(package private) final Instructionsprivate static final org.slf4j.Logger(package private) static final String(package private) static final String(package private) static final String(package private) static final Pattern(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationHeaders(Analyzer analyzer) AnnotationHeaders(Analyzer analyzer, Instructions instructions) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadd(Annotation annotation, String name, String value) voidannotation(Annotation annotation) booleanclassStart(Clazz c) voidclose()(package private) static Stringprivate voiddirectivesAndVersion(Attrs attrs, String... directives) (package private) voiddoAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name, Set<String> processed, Attrs baseAttrs) Handle the case where an annotation is annotated by one of our header annotations.private voiddoBundleCategory(Annotation a, BundleCategory annotation) private voiddoBundleContributors(Annotation a, BundleContributors annotation) private voiddoBundleCopyright(Annotation a, BundleCopyright annotation) private voiddoBundleDevelopers(Annotation a, BundleDevelopers annotation) private voiddoBundleDocURL(Annotation a, BundleDocURL annotation) private voiddoCapability(Annotation a, Capability annotation) private voiddoLicense(Annotation a, BundleLicense annotation) private voiddoProvideCapability(Annotation a, ProvideCapability annotation) private voiddoRequireCapability(Annotation a, RequireCapability annotation) private voiddoRequirement(Annotation a, Requirement annotation) private voidescape(StringBuilder app, String s) private voidescape(StringBuilder app, String[] s) private AttrsgetAttributes(Annotation a, String... ignores) private StringgetFilter(Annotation a, Requirement annotation) private voidreplaceParameters(Attrs attrs) Methods inherited from class aQute.bnd.osgi.ClassDataCollector
addReference, annotationDefault, annotationDefault, classBegin, classEnd, classStart, constant, deprecated, enclosingMethod, extendsClass, field, implementsInterfaces, innerClass, memberEnd, method, methodParameters, parameter, referenceMethod, referTo, signature, typeuse, version
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
CONVERTER
-
ANNOTATION_INSTRUCTION
-
SIMPLE_PARAM_PATTERN
-
DO_NOT_SCAN
-
analyzer
-
headers
-
CARDINALITY
- See Also:
-
RESOLUTION
- See Also:
-
BUNDLE_LICENSE
- See Also:
-
REQUIRE_CAPABILITY
- See Also:
-
PROVIDE_CAPABILITY
- See Also:
-
BUNDLE_CATEGORY
- See Also:
-
BUNDLE_DOC_URL
- See Also:
-
BUNDLE_DEVELOPERS
- See Also:
-
BUNDLE_CONTRIBUTORS
- See Also:
-
BUNDLE_COPYRIGHT
- See Also:
-
STD_REQUIREMENT
- See Also:
-
STD_REQUIREMENT_CARDINALITY
- See Also:
-
STD_REQUIREMENT_RESOLUTION
- See Also:
-
STD_REQUIREMENTS
- See Also:
-
STD_CAPABILITY
- See Also:
-
STD_CAPABILITIES
- See Also:
-
STD_HEADER
- See Also:
-
STD_HEADERS
- See Also:
-
STD_ATTRIBUTE
- See Also:
-
STD_DIRECTIVE
- See Also:
-
current
Clazz current -
loggedMissing
-
instructions
-
finalizing
boolean finalizing
-
-
Constructor Details
-
AnnotationHeaders
AnnotationHeaders(Analyzer analyzer) -
AnnotationHeaders
AnnotationHeaders(Analyzer analyzer, Instructions instructions)
-
-
Method Details
-
convert
-
classStart
- Overrides:
classStartin classClassDataCollector
-
annotation
- Overrides:
annotationin classClassDataCollector- Throws:
Exception
-
doAnnotatedAnnotation
void doAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name, Set<String> processed, Attrs baseAttrs) throws Exception Handle the case where an annotation is annotated by one of our header annotations.- Parameters:
annotation-name-- Throws:
Exception
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
doBundleDevelopers
- Throws:
IOException
-
doBundleContributors
- Throws:
IOException
-
doBundleCopyright
- Throws:
IOException
-
doBundleDocURL
- Throws:
IOException
-
doBundleCategory
- Throws:
IOException
-
doProvideCapability
- Throws:
Exception
-
doRequireCapability
- Throws:
Exception
-
replaceParameters
- Throws:
IllegalArgumentException
-
doLicense
- Throws:
Exception
-
doRequirement
- Throws:
Exception
-
getFilter
-
doCapability
- Throws:
Exception
-
directivesAndVersion
-
getAttributes
-
add
- Throws:
IOException
-
getHeader
-
escape
- Throws:
IOException
-
escape
- Throws:
IOException
-