class AnnotationHeaders extends ClassDataCollector implements java.io.Closeable
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.Modifier and Type | Class and Description |
---|---|
private class |
AnnotationHeaders.MetaAnnotationCollector |
Modifier and Type | Field and Description |
---|---|
(package private) Analyzer |
analyzer |
(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) 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.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_REQUIREMENTS |
Constructor and Description |
---|
AnnotationHeaders(Analyzer analyzer) |
AnnotationHeaders(Analyzer analyzer,
Instructions instructions) |
Modifier and Type | Method and Description |
---|---|
private void |
add(java.lang.String name,
java.lang.String value) |
void |
annotation(Annotation annotation) |
boolean |
classStart(Clazz c) |
void |
close() |
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 |
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 |
doCapability(Annotation a,
Capability annotation) |
private void |
doLicense(Annotation a) |
private void |
doProvideCapability(Annotation a) |
private void |
doRequireCapability(Annotation a) |
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) |
addReference, annotationDefault, annotationDefault, classBegin, classEnd, classStart, constant, deprecated, enclosingMethod, extendsClass, field, implementsInterfaces, innerClass, memberEnd, method, methodParameters, parameter, referenceMethod, referTo, signature, typeuse, version
private static final org.slf4j.Logger logger
static final java.util.regex.Pattern SIMPLE_PARAM_PATTERN
static final java.util.Set<java.lang.String> DO_NOT_SCAN
final Analyzer analyzer
final MultiMap<java.lang.String,java.lang.String> headers
static final java.lang.String BUNDLE_LICENSE
static final java.lang.String REQUIRE_CAPABILITY
static final java.lang.String PROVIDE_CAPABILITY
static final java.lang.String BUNDLE_CATEGORY
static final java.lang.String BUNDLE_DOC_URL
static final java.lang.String BUNDLE_DEVELOPERS
static final java.lang.String BUNDLE_CONTRIBUTORS
static final java.lang.String BUNDLE_COPYRIGHT
static final java.lang.String STD_REQUIREMENT
static final java.lang.String STD_REQUIREMENTS
static final java.lang.String STD_CAPABILITY
static final java.lang.String STD_CAPABILITIES
static final java.lang.String STD_HEADER
static final java.lang.String STD_HEADERS
static final java.lang.String STD_ATTRIBUTE
static final java.lang.String STD_DIRECTIVE
Clazz current
final java.util.Set<java.lang.String> loggedMissing
final Instructions instructions
boolean finalizing
AnnotationHeaders(Analyzer analyzer)
AnnotationHeaders(Analyzer analyzer, Instructions instructions)
public boolean classStart(Clazz c)
classStart
in class ClassDataCollector
public void annotation(Annotation annotation) throws java.lang.Exception
annotation
in class ClassDataCollector
java.lang.Exception
void doAnnotatedAnnotation(Annotation annotation, Descriptors.TypeRef name, java.util.Set<java.lang.String> processed, Attrs baseAttrs) throws java.lang.Exception
annotation
- name
- java.lang.Exception
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
private void doBundleDevelopers(BundleDevelopers annotation) throws java.io.IOException
java.io.IOException
private void doBundleContributors(BundleContributors annotation) throws java.io.IOException
java.io.IOException
private void doBundeCopyright(BundleCopyright annotation) throws java.io.IOException
java.io.IOException
private void doBundleDocURL(BundleDocURL annotation) throws java.io.IOException
java.io.IOException
private void doBundleCategory(BundleCategory annotation) throws java.io.IOException
java.io.IOException
private void doProvideCapability(Annotation a) throws java.lang.Exception
java.lang.Exception
private void doRequireCapability(Annotation a) throws java.lang.Exception
java.lang.Exception
private void replaceParameters(Attrs attrs) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
private void doLicense(Annotation a) throws java.lang.Exception
java.lang.Exception
private void doRequirement(Annotation a, Requirement annotation) throws java.lang.Exception
java.lang.Exception
private java.lang.String getFilter(Annotation a, Requirement annotation)
private void doCapability(Annotation a, Capability annotation) throws java.lang.Exception
java.lang.Exception
private void directivesAndVersion(Attrs attrs, java.lang.String... directives)
private Attrs getAttributes(Annotation a, java.lang.String... ignores)
private void add(java.lang.String name, java.lang.String value) throws java.io.IOException
java.io.IOException
public java.lang.String getHeader(java.lang.String name)
private void escape(java.lang.StringBuilder app, java.lang.String[] s) throws java.io.IOException
java.io.IOException
private void escape(java.lang.StringBuilder app, java.lang.String s) throws java.io.IOException
java.io.IOException