Package aQute.bnd.osgi
Class AnnotationHeaders
- java.lang.Object
-
- aQute.bnd.osgi.ClassDataCollector
-
- aQute.bnd.osgi.AnnotationHeaders
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class AnnotationHeaders extends ClassDataCollector implements java.io.Closeable
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. ThisClassDataCollector
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 Modifier and Type Class Description private class
AnnotationHeaders.MetaAnnotationCollector
-
Field Summary
Fields Modifier and Type Field Description (package private) Analyzer
analyzer
private static Instruction
ANNOTATION_INSTRUCTION
(package private) static java.lang.String
BUNDLE_CATEGORY
(package private) static java.lang.String
BUNDLE_CONTRIBUTORS
(package private) static java.lang.String
BUNDLE_COPYRIGHT
(package private) static java.lang.String
BUNDLE_DEVELOPERS
(package private) static java.lang.String
BUNDLE_DOC_URL
(package private) static java.lang.String
BUNDLE_LICENSE
(package private) static java.lang.String
CARDINALITY
private static Converter
CONVERTER
(package private) Clazz
current
(package private) static java.util.Set<java.lang.String>
DO_NOT_SCAN
(package private) boolean
finalizing
(package private) MultiMap<java.lang.String,java.lang.String>
headers
(package private) Instructions
instructions
(package private) java.util.Set<java.lang.String>
loggedMissing
private static org.slf4j.Logger
logger
(package private) static java.lang.String
PROVIDE_CAPABILITY
(package private) static java.lang.String
REQUIRE_CAPABILITY
(package private) static java.lang.String
RESOLUTION
(package private) static java.util.regex.Pattern
SIMPLE_PARAM_PATTERN
(package private) static java.lang.String
STD_ATTRIBUTE
(package private) static java.lang.String
STD_CAPABILITIES
(package private) static java.lang.String
STD_CAPABILITY
(package private) static java.lang.String
STD_DIRECTIVE
(package private) static java.lang.String
STD_HEADER
(package private) static java.lang.String
STD_HEADERS
(package private) static java.lang.String
STD_REQUIREMENT
(package private) static java.lang.String
STD_REQUIREMENT_CARDINALITY
(package private) static java.lang.String
STD_REQUIREMENT_RESOLUTION
(package private) static java.lang.String
STD_REQUIREMENTS
-
Constructor Summary
Constructors Constructor Description AnnotationHeaders(Analyzer analyzer)
AnnotationHeaders(Analyzer analyzer, Instructions instructions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(Annotation annotation, java.lang.String name, java.lang.String value)
void
annotation(Annotation annotation)
boolean
classStart(Clazz c)
void
close()
(package private) static java.lang.String
convert(java.lang.Object value)
private void
directivesAndVersion(Attrs attrs, java.lang.String... directives)
(package private) void
doAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name, java.util.Set<java.lang.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(java.lang.StringBuilder app, java.lang.String s)
private void
escape(java.lang.StringBuilder app, java.lang.String[] s)
private Attrs
getAttributes(Annotation a, java.lang.String... ignores)
private java.lang.String
getFilter(Annotation a, Requirement annotation)
java.lang.String
getHeader(java.lang.String name)
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 Detail
-
logger
private static final org.slf4j.Logger logger
-
CONVERTER
private static final Converter CONVERTER
-
ANNOTATION_INSTRUCTION
private static final Instruction ANNOTATION_INSTRUCTION
-
SIMPLE_PARAM_PATTERN
static final java.util.regex.Pattern SIMPLE_PARAM_PATTERN
-
DO_NOT_SCAN
static final java.util.Set<java.lang.String> DO_NOT_SCAN
-
analyzer
final Analyzer analyzer
-
headers
final MultiMap<java.lang.String,java.lang.String> headers
-
CARDINALITY
static final java.lang.String CARDINALITY
- See Also:
- Constant Field Values
-
RESOLUTION
static final java.lang.String RESOLUTION
- See Also:
- Constant Field Values
-
BUNDLE_LICENSE
static final java.lang.String BUNDLE_LICENSE
- See Also:
- Constant Field Values
-
REQUIRE_CAPABILITY
static final java.lang.String REQUIRE_CAPABILITY
- See Also:
- Constant Field Values
-
PROVIDE_CAPABILITY
static final java.lang.String PROVIDE_CAPABILITY
- See Also:
- Constant Field Values
-
BUNDLE_CATEGORY
static final java.lang.String BUNDLE_CATEGORY
- See Also:
- Constant Field Values
-
BUNDLE_DOC_URL
static final java.lang.String BUNDLE_DOC_URL
- See Also:
- Constant Field Values
-
BUNDLE_DEVELOPERS
static final java.lang.String BUNDLE_DEVELOPERS
- See Also:
- Constant Field Values
-
BUNDLE_CONTRIBUTORS
static final java.lang.String BUNDLE_CONTRIBUTORS
- See Also:
- Constant Field Values
-
BUNDLE_COPYRIGHT
static final java.lang.String BUNDLE_COPYRIGHT
- See Also:
- Constant Field Values
-
STD_REQUIREMENT
static final java.lang.String STD_REQUIREMENT
- See Also:
- Constant Field Values
-
STD_REQUIREMENT_CARDINALITY
static final java.lang.String STD_REQUIREMENT_CARDINALITY
- See Also:
- Constant Field Values
-
STD_REQUIREMENT_RESOLUTION
static final java.lang.String STD_REQUIREMENT_RESOLUTION
- See Also:
- Constant Field Values
-
STD_REQUIREMENTS
static final java.lang.String STD_REQUIREMENTS
- See Also:
- Constant Field Values
-
STD_CAPABILITY
static final java.lang.String STD_CAPABILITY
- See Also:
- Constant Field Values
-
STD_CAPABILITIES
static final java.lang.String STD_CAPABILITIES
- See Also:
- Constant Field Values
-
STD_HEADER
static final java.lang.String STD_HEADER
- See Also:
- Constant Field Values
-
STD_HEADERS
static final java.lang.String STD_HEADERS
- See Also:
- Constant Field Values
-
STD_ATTRIBUTE
static final java.lang.String STD_ATTRIBUTE
- See Also:
- Constant Field Values
-
STD_DIRECTIVE
static final java.lang.String STD_DIRECTIVE
- See Also:
- Constant Field Values
-
current
Clazz current
-
loggedMissing
final java.util.Set<java.lang.String> loggedMissing
-
instructions
final Instructions instructions
-
finalizing
boolean finalizing
-
-
Constructor Detail
-
AnnotationHeaders
AnnotationHeaders(Analyzer analyzer)
-
AnnotationHeaders
AnnotationHeaders(Analyzer analyzer, Instructions instructions)
-
-
Method Detail
-
convert
static java.lang.String convert(java.lang.Object value)
-
classStart
public boolean classStart(Clazz c)
- Overrides:
classStart
in classClassDataCollector
-
annotation
public void annotation(Annotation annotation) throws java.lang.Exception
- Overrides:
annotation
in classClassDataCollector
- Throws:
java.lang.Exception
-
doAnnotatedAnnotation
void doAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name, java.util.Set<java.lang.String> processed, Attrs baseAttrs) throws java.lang.Exception
Handle the case where an annotation is annotated by one of our header annotations.- Parameters:
annotation
-name
-- Throws:
java.lang.Exception
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
doBundleDevelopers
private void doBundleDevelopers(Annotation a, BundleDevelopers annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleContributors
private void doBundleContributors(Annotation a, BundleContributors annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleCopyright
private void doBundleCopyright(Annotation a, BundleCopyright annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleDocURL
private void doBundleDocURL(Annotation a, BundleDocURL annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleCategory
private void doBundleCategory(Annotation a, BundleCategory annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doProvideCapability
private void doProvideCapability(Annotation a, ProvideCapability annotation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doRequireCapability
private void doRequireCapability(Annotation a, RequireCapability annotation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
replaceParameters
private void replaceParameters(Attrs attrs) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
doLicense
private void doLicense(Annotation a, BundleLicense annotation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doRequirement
private void doRequirement(Annotation a, Requirement annotation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getFilter
private java.lang.String getFilter(Annotation a, Requirement annotation)
-
doCapability
private void doCapability(Annotation a, Capability annotation) throws java.lang.Exception
- Throws:
java.lang.Exception
-
directivesAndVersion
private void directivesAndVersion(Attrs attrs, java.lang.String... directives)
-
getAttributes
private Attrs getAttributes(Annotation a, java.lang.String... ignores)
-
add
private void add(Annotation annotation, java.lang.String name, java.lang.String value) throws java.io.IOException
- Throws:
java.io.IOException
-
getHeader
public java.lang.String getHeader(java.lang.String name)
-
escape
private void escape(java.lang.StringBuilder app, java.lang.String[] s) throws java.io.IOException
- Throws:
java.io.IOException
-
escape
private void escape(java.lang.StringBuilder app, java.lang.String s) throws java.io.IOException
- Throws:
java.io.IOException
-
-