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.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Analyzer
analyzer
(package private) Descriptors.TypeRef
bundleCategoryRef
(package private) Descriptors.TypeRef
bundleContributorRef
(package private) Descriptors.TypeRef
bundleCopyrightRef
(package private) Descriptors.TypeRef
bundleDeveloperRef
(package private) Descriptors.TypeRef
bundleDocURLRef
(package private) Descriptors.TypeRef
bundleLicenseRef
(package private) Clazz
current
(package private) boolean
finalizing
(package private) MultiMap<java.lang.String,java.lang.String>
headers
(package private) java.util.Set<Descriptors.TypeRef>
interesting
(package private) Descriptors.TypeRef
provideCapabilityRef
(package private) Descriptors.TypeRef
requireCapabilityRef
(package private) static java.util.regex.Pattern
SIMPLE_PARAM_PATTERN
-
Constructor Summary
Constructors Constructor Description AnnotationHeaders(Analyzer analyzer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(java.lang.String name, java.lang.String value)
void
annotation(Annotation annotation)
boolean
classStart(Clazz c)
void
close()
private <T> boolean
containsAny(java.util.Set<T> a, java.util.Set<T> b)
private void
directivesAndVersion(Attrs attrs, java.lang.String... directives)
(package private) void
doAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name)
Handle the case where an annotation is annotated by one of our header annotations.private void
doBundeCopyright(BundleCopyright annotation)
private void
doBundleCategory(BundleCategory annotation)
private void
doBundleContributors(BundleContributors annotation)
private void
doBundleDevelopers(BundleDevelopers annotation)
private void
doBundleDocURL(BundleDocURL annotation)
private void
doLicense(Annotation a)
private void
doProvideCapability(Annotation a)
private void
doRequireCapability(Annotation a)
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)
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, parameter, referenceMethod, referTo, signature, version
-
-
-
-
Field Detail
-
SIMPLE_PARAM_PATTERN
static final java.util.regex.Pattern SIMPLE_PARAM_PATTERN
-
analyzer
final Analyzer analyzer
-
interesting
final java.util.Set<Descriptors.TypeRef> interesting
-
headers
final MultiMap<java.lang.String,java.lang.String> headers
-
bundleLicenseRef
final Descriptors.TypeRef bundleLicenseRef
-
requireCapabilityRef
final Descriptors.TypeRef requireCapabilityRef
-
provideCapabilityRef
final Descriptors.TypeRef provideCapabilityRef
-
bundleCategoryRef
final Descriptors.TypeRef bundleCategoryRef
-
bundleDocURLRef
final Descriptors.TypeRef bundleDocURLRef
-
bundleDeveloperRef
final Descriptors.TypeRef bundleDeveloperRef
-
bundleContributorRef
final Descriptors.TypeRef bundleContributorRef
-
bundleCopyrightRef
final Descriptors.TypeRef bundleCopyrightRef
-
current
Clazz current
-
finalizing
boolean finalizing
-
-
Constructor Detail
-
AnnotationHeaders
AnnotationHeaders(Analyzer analyzer)
-
-
Method Detail
-
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) 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(BundleDevelopers annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleContributors
private void doBundleContributors(BundleContributors annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundeCopyright
private void doBundeCopyright(BundleCopyright annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleDocURL
private void doBundleDocURL(BundleDocURL annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doBundleCategory
private void doBundleCategory(BundleCategory annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
doProvideCapability
private void doProvideCapability(Annotation a) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doRequireCapability
private void doRequireCapability(Annotation a) 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) 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(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)
-
containsAny
private <T> boolean containsAny(java.util.Set<T> a, java.util.Set<T> b)
-
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
-
-