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 Analyzer
private 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 String
private static final Converter
(package private) Clazz
(package private) boolean
(package private) final Instructions
private 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 void
add
(Annotation annotation, String name, String value) void
annotation
(Annotation annotation) boolean
classStart
(Clazz c) void
close()
(package private) static String
private void
directivesAndVersion
(Attrs attrs, String... directives) (package private) void
doAnnotatedAnnotation
(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 void
doBundleCategory
(Annotation a, BundleCategory annotation) private void
doBundleContributors
(Annotation a, BundleContributors annotation) private void
doBundleCopyright
(Annotation a, BundleCopyright annotation) private void
doBundleDevelopers
(Annotation a, BundleDevelopers annotation) private void
doBundleDocURL
(Annotation a, BundleDocURL annotation) private void
doCapability
(Annotation a, Capability annotation) private void
doLicense
(Annotation a, BundleLicense annotation) private void
doProvideCapability
(Annotation a, ProvideCapability annotation) private void
doRequireCapability
(Annotation a, RequireCapability annotation) private void
doRequirement
(Annotation a, Requirement annotation) private void
escape
(StringBuilder app, String s) private void
escape
(StringBuilder app, String[] s) private Attrs
getAttributes
(Annotation a, String... ignores) private String
getFilter
(Annotation a, Requirement annotation) private void
replaceParameters
(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:
classStart
in classClassDataCollector
-
annotation
- Overrides:
annotation
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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
-