Package org.eclipse.jetty.webapp
Class MetaInfConfiguration
java.lang.Object
org.eclipse.jetty.webapp.AbstractConfiguration
org.eclipse.jetty.webapp.MetaInfConfiguration
- All Implemented Interfaces:
Configuration
- Direct Known Subclasses:
AntMetaInfConfiguration
,OSGiMetaInfConfiguration
MetaInfConfiguration
Scan 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
Modifier and TypeClassDescriptionclass
ContainerPathNameMatcher Matches names of jars on the container classpath against a pattern.class
WebAppPathNameMatcher Matches names of jars or dirs on the webapp classpath against a pattern.Nested classes/interfaces inherited from interface org.eclipse.jetty.webapp.Configuration
Configuration.Wrapper, Configuration.WrapperFunction
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final boolean
static final String
static final String
static final String
static final String
If set, to a list of URLs, these resources are added to the context resource base as a resource collection.static final String
static final String
Fields inherited from interface org.eclipse.jetty.webapp.Configuration
ATTR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(WebAppContext context) Configure WebApp.void
findAndFilterContainerPaths
(WebAppContext context) Find jars and directories that are on the container's classpath and apply an optional filter.void
findAndFilterWebAppPaths
(WebAppContext context) Finds the jars that are either physically or virtually in WEB-INF/lib, and applies an optional filter to their full pathnames.findClassDirs
(WebAppContext context) findExtraClasspathDirs
(WebAppContext context) Get class dirs from WebAppContext.getExtraClasspath as resourcesfindExtraClasspathJars
(WebAppContext context) Get jars from WebAppContext.getExtraClasspath as resourcesfindJars
(WebAppContext context) Look for jars that should be treated as if they are in WEB-INF/libprotected Resource
findWebInfClassesDir
(WebAppContext context) GetWEB-INF/classes
dirfindWebInfLibJars
(WebAppContext context) Look for jars inWEB-INF/lib
getAllContainerJars
(WebAppContext context) Find all .tld files in all subdirs of the given dir.Find all .tld files in the given jar.void
postConfigure
(WebAppContext context) Clear down after configuration.void
preConfigure
(WebAppContext context) Set up for configuration.void
scanForFragment
(WebAppContext context, Resource jar, ConcurrentHashMap<Resource, Resource> cache) Scan for META-INF/web-fragment.xml file in the given jar.void
scanForResources
(WebAppContext context, Resource target, ConcurrentHashMap<Resource, Resource> cache) Scan for META-INF/resources dir in the given jar.void
scanForTlds
(WebAppContext context, Resource jar, ConcurrentHashMap<Resource, Collection<URL>> cache) Discover META-INF/*.tld files in the given jarprotected void
scanJars
(WebAppContext context) void
scanJars
(WebAppContext context, Collection<Resource> jars, boolean useCaches) For backwards compatibility.void
scanJars
(WebAppContext context, Collection<Resource> jars, boolean useCaches, List<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 Details
-
USE_CONTAINER_METAINF_CACHE
- See Also:
-
DEFAULT_USE_CONTAINER_METAINF_CACHE
public static final boolean DEFAULT_USE_CONTAINER_METAINF_CACHE- See Also:
-
CACHED_CONTAINER_TLDS
- See Also:
-
CACHED_CONTAINER_FRAGMENTS
- See Also:
-
CACHED_CONTAINER_RESOURCES
- See Also:
-
METAINF_TLDS
- See Also:
-
METAINF_FRAGMENTS
- See Also:
-
METAINF_RESOURCES
- See Also:
-
CONTAINER_JAR_PATTERN
- See Also:
-
WEBINF_JAR_PATTERN
- See Also:
-
__allScanTypes
-
RESOURCE_DIRS
If set, to a list of URLs, these resources are added to the context resource base as a resource collection.- See Also:
-
-
Constructor Details
-
MetaInfConfiguration
public MetaInfConfiguration()
-
-
Method Details
-
preConfigure
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 interfaceConfiguration
- Overrides:
preConfigure
in classAbstractConfiguration
- Parameters:
context
- The context to configure- Throws:
Exception
- if unable to pre configure
-
findAndFilterContainerPaths
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
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
- Throws:
URISyntaxException
-
configure
Description copied from interface:Configuration
Configure WebApp.Typically this step applies the discovered configuration resources to either the
WebAppContext
or the associatedMetaData
.- Specified by:
configure
in interfaceConfiguration
- Overrides:
configure
in classAbstractConfiguration
- Parameters:
context
- The context to configure- Throws:
Exception
- if unable to configure
-
scanJars
- 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 scanjars
- the jars to scanuseCaches
- 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 scanjars
- the jars resources to scanuseCaches
- if true, cache the info discoveredscanTypes
- 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 ExceptionScan 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:
Exception
- if unable to scan for resources
-
scanForFragment
public void scanForFragment(WebAppContext context, Resource jar, ConcurrentHashMap<Resource, Resource> cache) throws ExceptionScan 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:
Exception
- if unable to scan for fragments
-
scanForTlds
public void scanForTlds(WebAppContext context, Resource jar, ConcurrentHashMap<Resource, Collection<URL>> cache) throws ExceptionDiscover 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:
Exception
- if unable to scan for tlds
-
postConfigure
Description copied from interface:Configuration
Clear down after configuration.- Specified by:
postConfigure
in interfaceConfiguration
- Overrides:
postConfigure
in classAbstractConfiguration
- Parameters:
context
- The context to configure- Throws:
Exception
- if unable to post configure
-
getTlds
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
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
- Throws:
Exception
-
findJars
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
Look for jars inWEB-INF/lib
-
findExtraClasspathJars
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
GetWEB-INF/classes
dir- Parameters:
context
- the context to look for theWEB-INF/classes
directory- Returns:
- the Resource for the
WEB-INF/classes
directory - Throws:
Exception
- if unable to find theWEB-INF/classes
directory
-
findExtraClasspathDirs
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
-