Class MetaInfConfiguration

java.lang.Object
org.eclipse.jetty.webapp.AbstractConfiguration
org.eclipse.jetty.webapp.MetaInfConfiguration
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
AntMetaInfConfiguration, MavenMetaInfConfiguration, OSGiMetaInfConfiguration

public class MetaInfConfiguration extends AbstractConfiguration
MetaInfConfiguration

Scan META-INF of jars to find:

  • tlds
  • web-fragment.xml
  • resources
The jars which are scanned are:
  1. those from the container classpath whose pattern matched the WebInfConfiguration.CONTAINER_JAR_PATTERN
  2. those from WEB-INF/lib
  • Field Details

  • Constructor Details

    • MetaInfConfiguration

      public MetaInfConfiguration()
  • Method Details

    • preConfigure

      public void preConfigure(WebAppContext context) throws Exception
      Description copied from interface: Configuration
      Set up for configuration.

      Typically this step discovers configuration resources. Calls to preConfigure may alter the Configurations configured on the WebAppContext, so long as configurations prior to this configuration are not altered.

      Specified by:
      preConfigure in interface Configuration
      Overrides:
      preConfigure in class AbstractConfiguration
      Parameters:
      context - The context to configure
      Throws:
      Exception - if unable to pre configure
    • findAndFilterContainerPaths

      public void findAndFilterContainerPaths(WebAppContext context) throws Exception
      Find jars and directories that are on the container's classpath and apply an optional filter. The filter is a pattern applied to the full jar or directory names. If there is no pattern, then no jar or dir is considered to match. Those jars that do match will be later examined for META-INF information and annotations. To find them, examine the classloaders in the hierarchy above the webapp classloader that are URLClassLoaders. For jdk-9 we also look at the java.class.path, and the jdk.module.path.
      Parameters:
      context - the WebAppContext being deployed
      Throws:
      Exception
    • findAndFilterWebAppPaths

      public void findAndFilterWebAppPaths(WebAppContext context) throws Exception
      Finds the jars that are either physically or virtually in WEB-INF/lib, and applies an optional filter to their full pathnames. The filter selects which jars will later be examined for META-INF information and annotations. If there is no pattern, then all jars are considered selected.
      Parameters:
      context - the WebAppContext being deployed
      Throws:
      Exception
    • getAllContainerJars

      protected List<URI> getAllContainerJars(WebAppContext context) throws URISyntaxException
      Throws:
      URISyntaxException
    • configure

      public void configure(WebAppContext context) throws Exception
      Description copied from interface: Configuration
      Configure WebApp.

      Typically this step applies the discovered configuration resources to either the WebAppContext or the associated MetaData.

      Specified by:
      configure in interface Configuration
      Overrides:
      configure in class AbstractConfiguration
      Parameters:
      context - The context to configure
      Throws:
      Exception - if unable to configure
    • scanJars

      protected void scanJars(WebAppContext context) throws Exception
      Throws:
      Exception
    • scanJars

      public void scanJars(WebAppContext context, Collection<Resource> jars, boolean useCaches) throws Exception
      For backwards compatibility. This method will always scan for all types of data.
      Parameters:
      context - the context for the scan
      jars - the jars to scan
      useCaches - if true, the scanned info is cached
      Throws:
      Exception - if unable to scan the jars
    • scanJars

      public void scanJars(WebAppContext context, Collection<Resource> jars, boolean useCaches, List<String> scanTypes) throws Exception
      Look into the jars to discover info in META-INF. If useCaches == true, then we will cache the info discovered indexed by the jar in which it was discovered: this speeds up subsequent context deployments.
      Parameters:
      context - the context for the scan
      jars - the jars resources to scan
      useCaches - if true, cache the info discovered
      scanTypes - the type of things to look for in the jars
      Throws:
      Exception - if unable to scan the jars
    • scanForResources

      public void scanForResources(WebAppContext context, Resource target, ConcurrentHashMap<Resource,Resource> cache) throws Exception
      Scan for META-INF/resources dir in the given jar.
      Parameters:
      context - the context for the scan
      target - the target resource to scan for
      cache - the resource cache
      Throws:
      Exception - if unable to scan for resources
    • scanForFragment

      public void scanForFragment(WebAppContext context, Resource jar, ConcurrentHashMap<Resource,Resource> cache) throws Exception
      Scan for META-INF/web-fragment.xml file in the given jar.
      Parameters:
      context - the context for the scan
      jar - the jar resource to scan for fragements in
      cache - the resource cache
      Throws:
      Exception - if unable to scan for fragments
    • scanForTlds

      public void scanForTlds(WebAppContext context, Resource jar, ConcurrentHashMap<Resource,Collection<URL>> cache) throws Exception
      Discover META-INF/*.tld files in the given jar
      Parameters:
      context - the context for the scan
      jar - the jar resources to scan tlds for
      cache - the resource cache
      Throws:
      Exception - if unable to scan for tlds
    • postConfigure

      public void postConfigure(WebAppContext context) throws Exception
      Description copied from interface: Configuration
      Clear down after configuration.
      Specified by:
      postConfigure in interface Configuration
      Overrides:
      postConfigure in class AbstractConfiguration
      Parameters:
      context - The context to configure
      Throws:
      Exception - if unable to post configure
    • getTlds

      public Collection<URL> getTlds(File dir) throws IOException
      Find all .tld files in all subdirs of the given dir.
      Parameters:
      dir - the directory to scan
      Returns:
      the list of tlds found
      Throws:
      IOException - if unable to scan the directory
    • getTlds

      public Collection<URL> getTlds(URI uri) throws IOException
      Find all .tld files in the given jar.
      Parameters:
      uri - the uri to jar file
      Returns:
      the collection of tlds as url references
      Throws:
      IOException - if unable to scan the jar file
    • findClassDirs

      protected List<Resource> findClassDirs(WebAppContext context) throws Exception
      Throws:
      Exception
    • findJars

      protected List<Resource> findJars(WebAppContext context) throws Exception
      Look for jars that should be treated as if they are in WEB-INF/lib
      Parameters:
      context - the context to find the jars in
      Returns:
      the list of jar resources found within context
      Throws:
      Exception - if unable to find the jars
    • findWebInfLibJars

      protected List<Resource> findWebInfLibJars(WebAppContext context) throws Exception
      Look for jars in WEB-INF/lib
      Parameters:
      context - the context to find the lib jars in
      Returns:
      the list of jars as Resource
      Throws:
      Exception - if unable to scan for lib jars
    • findExtraClasspathJars

      protected List<Resource> findExtraClasspathJars(WebAppContext context) throws Exception
      Get jars from WebAppContext.getExtraClasspath as resources
      Parameters:
      context - the context to find extra classpath jars in
      Returns:
      the list of Resources with the extra classpath, or null if not found
      Throws:
      Exception - if unable to resolve the extra classpath jars
    • findWebInfClassesDir

      protected Resource findWebInfClassesDir(WebAppContext context) throws Exception
      Get WEB-INF/classes dir
      Parameters:
      context - the context to look for the WEB-INF/classes directory
      Returns:
      the Resource for the WEB-INF/classes directory
      Throws:
      Exception - if unable to find the WEB-INF/classes directory
    • findExtraClasspathDirs

      protected List<Resource> findExtraClasspathDirs(WebAppContext context) throws Exception
      Get class dirs from WebAppContext.getExtraClasspath as resources
      Parameters:
      context - the context to look for extra classpaths in
      Returns:
      the list of Resources to the extra classpath
      Throws:
      Exception - if unable to resolve the extra classpath resources