Class AnnotationConfiguration

  • All Implemented Interfaces:
    Configuration

    public class AnnotationConfiguration
    extends AnnotationConfiguration
    Extend the AnnotationConfiguration to support OSGi: Look for annotations inside WEB-INF/lib and also in the fragments and required bundles. Discover them using a scanner adapted to OSGi instead of the jarscanner.
    • Constructor Detail

      • AnnotationConfiguration

        public AnnotationConfiguration()
    • Method Detail

      • createAnnotationParser

        protected AnnotationParser createAnnotationParser​(int javaTargetVersion)
        This parser scans the bundles using the OSGi APIs instead of assuming a jar.
        Overrides:
        createAnnotationParser in class AnnotationConfiguration
        Parameters:
        javaTargetVersion - The java platform to scan for.
        Returns:
        a new AnnotationParser. This method can be overridden to use a different implementation of the AnnotationParser. Note that this is considered internal API.
      • getJarFor

        public Resource getJarFor​(javax.servlet.ServletContainerInitializer service)
                           throws java.io.IOException
        Overrides:
        getJarFor in class AnnotationConfiguration
        Throws:
        java.io.IOException
      • parseWebInfLib

        public void parseWebInfLib​(WebAppContext context,
                                   AnnotationParser parser)
                            throws java.lang.Exception
        Here is the order in which jars and osgi artifacts are scanned for discoverable annotations.
        1. The container jars are scanned.
        2. The WEB-INF/classes are scanned
        3. The osgi fragment to the web bundle are parsed.
        4. The WEB-INF/lib are scanned
        5. The required bundles are parsed
        Overrides:
        parseWebInfLib in class AnnotationConfiguration
        Parameters:
        context - the context for the scan
        parser - the annotation parser to use
        Throws:
        java.lang.Exception - if unable to scan and/or parse
      • parseFragmentBundle

        protected void parseFragmentBundle​(WebAppContext context,
                                           AnnotationParser parser,
                                           org.osgi.framework.Bundle webbundle,
                                           org.osgi.framework.Bundle fragmentBundle)
                                    throws java.lang.Exception
        Scan a fragment bundle for servlet annotations
        Parameters:
        context - The webapp context
        parser - The parser
        webbundle - The current webbundle
        fragmentBundle - The OSGi fragment bundle to scan
        Throws:
        java.lang.Exception - if unable to parse fragment bundle
      • parseWebBundle

        protected void parseWebBundle​(WebAppContext context,
                                      AnnotationParser parser,
                                      org.osgi.framework.Bundle webbundle)
                               throws java.lang.Exception
        Scan a bundle required by the webbundle for servlet annotations
        Parameters:
        context - The webapp context
        parser - The parser
        webbundle - The current webbundle
        Throws:
        java.lang.Exception - if unable to parse the web bundle
      • parseRequiredBundle

        protected void parseRequiredBundle​(WebAppContext context,
                                           AnnotationParser parser,
                                           org.osgi.framework.Bundle webbundle,
                                           org.osgi.framework.Bundle requiredBundle)
                                    throws java.lang.Exception
        Scan a bundle required by the webbundle for servlet annotations
        Parameters:
        context - The webapp context
        parser - The parser
        webbundle - The current webbundle
        requiredBundle - The OSGi required bundle to scan
        Throws:
        java.lang.Exception - if unable to parse the required bundle
      • parseBundle

        protected void parseBundle​(WebAppContext context,
                                   AnnotationParser parser,
                                   org.osgi.framework.Bundle webbundle,
                                   org.osgi.framework.Bundle bundle)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception