- java.lang.Object
-
- org.eclipse.jetty.webapp.AbstractConfiguration
-
- org.eclipse.jetty.webapp.MetaInfConfiguration
-
- All Implemented Interfaces:
Configuration
public class MetaInfConfiguration extends AbstractConfiguration
MetaInfConfigurationScan META-INF of jars to find:
- tlds
- web-fragment.xml
- resources
- those from the container classpath whose pattern matched the WebInfConfiguration.CONTAINER_JAR_PATTERN
- those from WEB-INF/lib
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMetaInfConfiguration.ContainerPathNameMatcherContainerPathNameMatcher Matches names of jars on the container classpath against a pattern.classMetaInfConfiguration.WebAppPathNameMatcherWebAppPathNameMatcher Matches names of jars or dirs on the webapp classpath against a pattern.
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<java.lang.String>__allScanTypesstatic java.lang.StringCACHED_CONTAINER_FRAGMENTSstatic java.lang.StringCACHED_CONTAINER_RESOURCESstatic java.lang.StringCACHED_CONTAINER_TLDSstatic java.lang.StringCONTAINER_JAR_PATTERNstatic booleanDEFAULT_USE_CONTAINER_METAINF_CACHEstatic java.lang.StringMETAINF_FRAGMENTSstatic java.lang.StringMETAINF_RESOURCESstatic java.lang.StringMETAINF_TLDSstatic java.lang.StringRESOURCE_DIRSIf set, to a list of URLs, these resources are added to the context resource base as a resource collection.static java.lang.StringUSE_CONTAINER_METAINF_CACHEstatic java.lang.StringWEBINF_JAR_PATTERN-
Fields inherited from interface org.eclipse.jetty.webapp.Configuration
ATTR
-
-
Constructor Summary
Constructors Constructor Description MetaInfConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(WebAppContext context)Configure WebApp.voidfindAndFilterContainerPaths(WebAppContext context)Find jars and directories that are on the container's classpath and apply an optional filter.voidfindAndFilterWebAppPaths(WebAppContext context)Finds the jars that are either physically or virtually in WEB-INF/lib, and applies an optional filter to their full pathnames.protected java.util.List<org.eclipse.jetty.util.resource.Resource>findClassDirs(WebAppContext context)protected java.util.List<org.eclipse.jetty.util.resource.Resource>findExtraClasspathDirs(WebAppContext context)Get class dirs from WebAppContext.getExtraClasspath as resourcesprotected java.util.List<org.eclipse.jetty.util.resource.Resource>findExtraClasspathJars(WebAppContext context)Get jars from WebAppContext.getExtraClasspath as resourcesprotected java.util.List<org.eclipse.jetty.util.resource.Resource>findJars(WebAppContext context)Look for jars that should be treated as if they are in WEB-INF/libprotected org.eclipse.jetty.util.resource.ResourcefindWebInfClassesDir(WebAppContext context)GetWEB-INF/classesdirprotected java.util.List<org.eclipse.jetty.util.resource.Resource>findWebInfLibJars(WebAppContext context)Look for jars inWEB-INF/libprotected java.util.List<java.net.URI>getAllContainerJars(WebAppContext context)java.util.Collection<java.net.URL>getTlds(java.io.File dir)Find all .tld files in all subdirs of the given dir.java.util.Collection<java.net.URL>getTlds(java.net.URI uri)Find all .tld files in the given jar.voidpostConfigure(WebAppContext context)Clear down after configuration.voidpreConfigure(WebAppContext context)Set up for configuration.voidscanForFragment(WebAppContext context, org.eclipse.jetty.util.resource.Resource jar, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,org.eclipse.jetty.util.resource.Resource> cache)Scan for META-INF/web-fragment.xml file in the given jar.voidscanForResources(WebAppContext context, org.eclipse.jetty.util.resource.Resource target, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,org.eclipse.jetty.util.resource.Resource> cache)Scan for META-INF/resources dir in the given jar.voidscanForTlds(WebAppContext context, org.eclipse.jetty.util.resource.Resource jar, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,java.util.Collection<java.net.URL>> cache)Discover META-INF/*.tld files in the given jarprotected voidscanJars(WebAppContext context)voidscanJars(WebAppContext context, java.util.Collection<org.eclipse.jetty.util.resource.Resource> jars, boolean useCaches)For backwards compatibility.voidscanJars(WebAppContext context, java.util.Collection<org.eclipse.jetty.util.resource.Resource> jars, boolean useCaches, java.util.List<java.lang.String> scanTypes)Look into the jars to discover info in META-INF.-
Methods inherited from class org.eclipse.jetty.webapp.AbstractConfiguration
abort, addDependencies, addDependencies, addDependents, addDependents, cloneConfigure, deconfigure, destroy, expose, getDependencies, getDependents, getServerClasses, getSystemClasses, hide, isEnabledByDefault, protect, protectAndExpose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.webapp.Configuration
isAvailable, replaces
-
-
-
-
Field Detail
-
USE_CONTAINER_METAINF_CACHE
public static final java.lang.String USE_CONTAINER_METAINF_CACHE
- See Also:
- Constant Field Values
-
DEFAULT_USE_CONTAINER_METAINF_CACHE
public static final boolean DEFAULT_USE_CONTAINER_METAINF_CACHE
- See Also:
- Constant Field Values
-
CACHED_CONTAINER_TLDS
public static final java.lang.String CACHED_CONTAINER_TLDS
- See Also:
- Constant Field Values
-
CACHED_CONTAINER_FRAGMENTS
public static final java.lang.String CACHED_CONTAINER_FRAGMENTS
- See Also:
- Constant Field Values
-
CACHED_CONTAINER_RESOURCES
public static final java.lang.String CACHED_CONTAINER_RESOURCES
- See Also:
- Constant Field Values
-
METAINF_TLDS
public static final java.lang.String METAINF_TLDS
- See Also:
- Constant Field Values
-
METAINF_FRAGMENTS
public static final java.lang.String METAINF_FRAGMENTS
- See Also:
- Constant Field Values
-
METAINF_RESOURCES
public static final java.lang.String METAINF_RESOURCES
- See Also:
- Constant Field Values
-
CONTAINER_JAR_PATTERN
public static final java.lang.String CONTAINER_JAR_PATTERN
- See Also:
- Constant Field Values
-
WEBINF_JAR_PATTERN
public static final java.lang.String WEBINF_JAR_PATTERN
- See Also:
- Constant Field Values
-
__allScanTypes
public static final java.util.List<java.lang.String> __allScanTypes
-
RESOURCE_DIRS
public static final java.lang.String RESOURCE_DIRS
If set, to a list of URLs, these resources are added to the context resource base as a resource collection.- See Also:
- Constant Field Values
-
-
Method Detail
-
preConfigure
public void preConfigure(WebAppContext context) throws java.lang.Exception
Description copied from interface:ConfigurationSet 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:
preConfigurein interfaceConfiguration- Overrides:
preConfigurein classAbstractConfiguration- Parameters:
context- The context to configure- Throws:
java.lang.Exception- if unable to pre configure
-
findAndFilterContainerPaths
public void findAndFilterContainerPaths(WebAppContext context) throws java.lang.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:
java.lang.Exception
-
findAndFilterWebAppPaths
public void findAndFilterWebAppPaths(WebAppContext context) throws java.lang.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:
java.lang.Exception
-
getAllContainerJars
protected java.util.List<java.net.URI> getAllContainerJars(WebAppContext context) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
configure
public void configure(WebAppContext context) throws java.lang.Exception
Description copied from interface:ConfigurationConfigure WebApp.Typically this step applies the discovered configuration resources to either the
WebAppContextor the associatedMetaData.- Specified by:
configurein interfaceConfiguration- Overrides:
configurein classAbstractConfiguration- Parameters:
context- The context to configure- Throws:
java.lang.Exception- if unable to configure
-
scanJars
protected void scanJars(WebAppContext context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
scanJars
public void scanJars(WebAppContext context, java.util.Collection<org.eclipse.jetty.util.resource.Resource> jars, boolean useCaches) throws java.lang.Exception
For backwards compatibility. This method will always scan for all types of data.- Parameters:
context- the context for the scanjars- the jars to scanuseCaches- if true, the scanned info is cached- Throws:
java.lang.Exception- if unable to scan the jars
-
scanJars
public void scanJars(WebAppContext context, java.util.Collection<org.eclipse.jetty.util.resource.Resource> jars, boolean useCaches, java.util.List<java.lang.String> scanTypes) throws java.lang.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 scanjars- the jars resources to scanuseCaches- if true, cache the info discoveredscanTypes- the type of things to look for in the jars- Throws:
java.lang.Exception- if unable to scan the jars
-
scanForResources
public void scanForResources(WebAppContext context, org.eclipse.jetty.util.resource.Resource target, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,org.eclipse.jetty.util.resource.Resource> cache) throws java.lang.Exception
Scan for META-INF/resources dir in the given jar.- Parameters:
context- the context for the scantarget- the target resource to scan forcache- the resource cache- Throws:
java.lang.Exception- if unable to scan for resources
-
scanForFragment
public void scanForFragment(WebAppContext context, org.eclipse.jetty.util.resource.Resource jar, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,org.eclipse.jetty.util.resource.Resource> cache) throws java.lang.Exception
Scan for META-INF/web-fragment.xml file in the given jar.- Parameters:
context- the context for the scanjar- the jar resource to scan for fragements incache- the resource cache- Throws:
java.lang.Exception- if unable to scan for fragments
-
scanForTlds
public void scanForTlds(WebAppContext context, org.eclipse.jetty.util.resource.Resource jar, java.util.concurrent.ConcurrentHashMap<org.eclipse.jetty.util.resource.Resource,java.util.Collection<java.net.URL>> cache) throws java.lang.Exception
Discover META-INF/*.tld files in the given jar- Parameters:
context- the context for the scanjar- the jar resources to scan tlds forcache- the resource cache- Throws:
java.lang.Exception- if unable to scan for tlds
-
postConfigure
public void postConfigure(WebAppContext context) throws java.lang.Exception
Description copied from interface:ConfigurationClear down after configuration.- Specified by:
postConfigurein interfaceConfiguration- Overrides:
postConfigurein classAbstractConfiguration- Parameters:
context- The context to configure- Throws:
java.lang.Exception- if unable to post configure
-
getTlds
public java.util.Collection<java.net.URL> getTlds(java.io.File dir) throws java.io.IOExceptionFind all .tld files in all subdirs of the given dir.- Parameters:
dir- the directory to scan- Returns:
- the list of tlds found
- Throws:
java.io.IOException- if unable to scan the directory
-
getTlds
public java.util.Collection<java.net.URL> getTlds(java.net.URI uri) throws java.io.IOExceptionFind all .tld files in the given jar.- Parameters:
uri- the uri to jar file- Returns:
- the collection of tlds as url references
- Throws:
java.io.IOException- if unable to scan the jar file
-
findClassDirs
protected java.util.List<org.eclipse.jetty.util.resource.Resource> findClassDirs(WebAppContext context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
findJars
protected java.util.List<org.eclipse.jetty.util.resource.Resource> findJars(WebAppContext context) throws java.lang.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:
java.lang.Exception- if unable to find the jars
-
findWebInfLibJars
protected java.util.List<org.eclipse.jetty.util.resource.Resource> findWebInfLibJars(WebAppContext context) throws java.lang.Exception
Look for jars inWEB-INF/lib- Parameters:
context- the context to find the lib jars in- Returns:
- the list of jars as
Resource - Throws:
java.lang.Exception- if unable to scan for lib jars
-
findExtraClasspathJars
protected java.util.List<org.eclipse.jetty.util.resource.Resource> findExtraClasspathJars(WebAppContext context) throws java.lang.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:
java.lang.Exception- if unable to find the extra classpath jars
-
findWebInfClassesDir
protected org.eclipse.jetty.util.resource.Resource findWebInfClassesDir(WebAppContext context) throws java.lang.Exception
GetWEB-INF/classesdir- Parameters:
context- the context to look for theWEB-INF/classesdirectory- Returns:
- the Resource for the
WEB-INF/classesdirectory - Throws:
java.lang.Exception- if unable to find theWEB-INF/classesdirectory
-
findExtraClasspathDirs
protected java.util.List<org.eclipse.jetty.util.resource.Resource> findExtraClasspathDirs(WebAppContext context) throws java.lang.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:
java.lang.Exception- if unable to find the extra classpaths
-
-