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. ThisClassDataCollectoris 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 {...}Aboutprovides some more information.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAnnotationHeaders.MetaAnnotationCollector
-
Field Summary
Fields Modifier and Type Field Description (package private) Analyzeranalyzerprivate static InstructionANNOTATION_INSTRUCTION(package private) static java.lang.StringBUNDLE_CATEGORY(package private) static java.lang.StringBUNDLE_CONTRIBUTORS(package private) static java.lang.StringBUNDLE_COPYRIGHT(package private) static java.lang.StringBUNDLE_DEVELOPERS(package private) static java.lang.StringBUNDLE_DOC_URL(package private) static java.lang.StringBUNDLE_LICENSE(package private) static java.lang.StringCARDINALITYprivate static ConverterCONVERTER(package private) Clazzcurrent(package private) static java.util.Set<java.lang.String>DO_NOT_SCAN(package private) booleanfinalizing(package private) MultiMap<java.lang.String,java.lang.String>headers(package private) Instructionsinstructions(package private) java.util.Set<java.lang.String>loggedMissingprivate static org.slf4j.Loggerlogger(package private) static java.lang.StringPROVIDE_CAPABILITY(package private) static java.lang.StringREQUIRE_CAPABILITY(package private) static java.lang.StringRESOLUTION(package private) static java.util.regex.PatternSIMPLE_PARAM_PATTERN(package private) static java.lang.StringSTD_ATTRIBUTE(package private) static java.lang.StringSTD_CAPABILITIES(package private) static java.lang.StringSTD_CAPABILITY(package private) static java.lang.StringSTD_DIRECTIVE(package private) static java.lang.StringSTD_HEADER(package private) static java.lang.StringSTD_HEADERS(package private) static java.lang.StringSTD_REQUIREMENT(package private) static java.lang.StringSTD_REQUIREMENT_CARDINALITY(package private) static java.lang.StringSTD_REQUIREMENT_RESOLUTION(package private) static java.lang.StringSTD_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 voidadd(Annotation annotation, java.lang.String name, java.lang.String value)voidannotation(Annotation annotation)booleanclassStart(Clazz c)voidclose()(package private) static java.lang.Stringconvert(java.lang.Object value)private voiddirectivesAndVersion(Attrs attrs, java.lang.String... directives)(package private) voiddoAnnotatedAnnotation(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 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(java.lang.StringBuilder app, java.lang.String s)private voidescape(java.lang.StringBuilder app, java.lang.String[] s)private AttrsgetAttributes(Annotation a, java.lang.String... ignores)private java.lang.StringgetFilter(Annotation a, Requirement annotation)java.lang.StringgetHeader(java.lang.String name)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 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:
classStartin classClassDataCollector
-
annotation
public void annotation(Annotation annotation) throws java.lang.Exception
- Overrides:
annotationin 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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
-
-