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.
    • Constructor Detail

      • AnnotationHeaders

        AnnotationHeaders​(Analyzer analyzer)
    • Method Detail

      • 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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