Class 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. 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.
    • 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
      • headers

        final MultiMap<java.lang.String,​java.lang.String> headers
      • 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
      • loggedMissing

        final java.util.Set<java.lang.String> loggedMissing
      • finalizing

        boolean finalizing
    • Constructor Detail

      • AnnotationHeaders

        AnnotationHeaders​(Analyzer analyzer)
    • Method Detail

      • convert

        static java.lang.String convert​(java.lang.Object value)
      • 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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
      • 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