Top Description Inners Fields Constructors Methods
org.apache.catalina.startup

public Class ContextConfig

extends Object
implements LifecycleListener
Class Inheritance
All Implemented Interfaces
org.apache.catalina.LifecycleListener
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .FileWriter, .IOException, .InputStream, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, .URLConnection, java.util.ArrayList, .Collections, .HashMap, .HashSet, .LinkedHashMap, .LinkedHashSet, .List, .Locale, .Map, .Map.Entry, .Properties, .Set, java.util.concurrent.ConcurrentHashMap, .ExecutorService, .Future, jakarta.servlet.MultipartConfigElement, .ServletContainerInitializer, .ServletContext, .SessionCookieConfig, jakarta.servlet.annotation.HandlesTypes, org.apache.catalina.Authenticator, .Container, .Context, .Engine, .Globals, .Host, .Lifecycle, .LifecycleEvent, .LifecycleListener, .Pipeline, .Server, .Service, .Valve, .WebResource, .WebResourceRoot, .Wrapper, org.apache.catalina.core.StandardContext, .StandardHost, org.apache.catalina.util.ContextName, .Introspection, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.Jar, .JarScanType, .JarScanner, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.bcel.classfile.AnnotationElementValue, .AnnotationEntry, .ArrayElementValue, .ClassFormatException, .ClassParser, .ElementValue, .ElementValuePair, .JavaClass, org.apache.tomcat.util.buf.UriUtil, org.apache.tomcat.util.descriptor.InputSourceUtil, .XmlErrorHandler, org.apache.tomcat.util.descriptor.web.ContextEjb, .ContextEnvironment, .ContextLocalEjb, .ContextResource, .ContextResourceEnvRef, .ContextService, .ErrorPage, .FilterDef, .FilterMap, .FragmentJarScannerCallback, .JspPropertyGroup, .LoginConfig, .MessageDestinationRef, .MultipartDef, .SecurityConstraint, .SecurityRoleRef, .ServletDef, .SessionConfig, .WebXml, .WebXmlParser, org.apache.tomcat.util.digester.Digester, .RuleSet, org.apache.tomcat.util.file.ConfigFileLoader, .ConfigurationSource, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.scan.JarFactory, org.xml.sax.InputSource, .SAXParseException

Startup event listener for a Context that configures the properties of that Context, and the associated defined servlets.
Author
Craig R. McClanahan

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ContextConfig.AnnotationScanTask

Executable task to scan a segment for annotations.

public static interface
private static class
private static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private File
antiLockingDocBase

Anti-locking docBase.

protected static final Properties
authenticators

The set of Authenticators that we know how to configure.

protected volatile Context
context

The Context we are associated with.

protected Map<String, Authenticator>
customAuthenticators

Custom mappings of login methods to authenticators

protected String
defaultWebXml

The default web application's deployment descriptor location.

protected static long
deploymentCount

Deployment count.

protected static final LoginConfig
private static final Set<ServletContainerInitializer>
EMPTY_SCI_SET

Set used as the value for JavaClassCacheEntry.sciSet when there are no SCIs associated with a class.

protected boolean
handlesTypesAnnotations

Flag that indicates if at least one HandlesTypes entry is present that represents an annotation.

protected boolean
handlesTypesNonAnnotations

Flag that indicates if at least one HandlesTypes entry is present that represents a non-annotation.

protected static final Map<Host, ContextConfig.DefaultWebXmlCacheEntry>
hostWebXmlCache

Cache of default web.xml fragments per Host

protected final Map<ServletContainerInitializer, Set<Class<?>>>
initializerClassMap

Map of ServletContainerInitializer to classes they expressed interest in.

private static final Log
protected boolean
ok

Track any fatal errors during startup configuration processing.

protected String
originalDocBase

Original docBase.

protected static final StringManager
sm

The string resources for this package.

protected final Map<Class<?>, Set<ServletContainerInitializer>>
typeInitializerMap

Map of Types to ServletContainerInitializer that are interested in those types.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
applicationAnnotationsConfig()

Process the application classes annotations, if it exists.

protected void
authenticatorConfig()

Set up an Authenticator automatically if required, and one has not already been configured.

protected synchronized void
beforeStart()

Process a "before start" event for this Context.

protected void
checkHandlesTypes(JavaClass
the class to check
javaClass
,
Map<String, ContextConfig.JavaClassCacheEntry>
a class cache
javaClassCache
)

For classes packaged with the web application, the class and each super class needs to be checked for a match with HandlesTypes or for an annotation that matches HandlesTypes.

private String
private void
protected synchronized void
configureStart()

Process a "contextConfig" event for this Context.

protected synchronized void
configureStop()

Process a "stop" event for this Context.

protected void
contextConfig(Digester
The digester that will be used for XML parsing
digester
)

Process the default configuration file, if it exists.

private void
convertJsp(ServletDef servletDef, Map<String, String> jspInitParams)

private void
protected Digester

Returns:

the digester for context.xml files
createContextDigester
()

Create (if necessary) and return a Digester configured to process the context configuration descriptor for an application.

protected WebXml
protected synchronized void
destroy()

Process a "destroy" event for this Context.

protected void
fixDocBase()

Adjust docBase.

protected void
protected void
generateClassHeader(Digester digester, String packageName, String resourceName)

private static String
getClassName(String internalForm)

public String
protected InputSource

Returns:

an input source to the context web.xml
getContextWebXmlSource
()

Identify the application web.xml to be used and obtain an input source for it.

protected File
getContextXmlJavaSource(String contextXmlPackageName, String contextXmlSimpleClassName)

protected static String
getContextXmlPackageName(String generatedCodePackage, Container container)

public String

Returns:

The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
getDefaultWebXml
()

Obtain the location of the default deployment descriptor.

private WebXml
protected boolean
protected File
protected String
protected InputSource

Returns:

an input source to the default web.xml
getGlobalWebXmlSource
()

Identify the default web.xml to be used and obtain an input source for it.

protected File
protected InputSource

Returns:

an input source to the default per host web.xml
getHostWebXmlSource
()

Identify the host web.xml to be used and obtain an input source for it.

private Set<ServletContainerInitializer>
private Server
private WebXml
protected boolean
protected InputSource

Returns:

the input source
getWebXmlSource
(String
Name of the file (possibly with one or more leading path segments) to read
filename
,
boolean
true if processing a shared resource, false if processing a host based resource
global
)

Utility method to create an input source from the specified XML file.

protected synchronized void
init()

Process a "init" event for this Context.

public void
lifecycleEvent(LifecycleEvent
The lifecycle event that has occurred
event
)

Implements org.apache.catalina.LifecycleListener.lifecycleEvent.

Process events for an associated Context.

private void
private void
private void
protected void
processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected void
processAnnotationsFile(File file, WebXml fragment, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected void
processAnnotationsInParallel(Set<WebXml>
Set of parallelizable scans
fragments
,
boolean
Important parameter for the underlying scan
handlesTypesOnly
,
Map<String, ContextConfig.JavaClassCacheEntry>
The class cache
javaClassCache
)

Parallelized version of processAnnotationsInParallel().

protected void
processAnnotationsJar(URL url, WebXml fragment, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected void
processAnnotationsStream(InputStream is, WebXml fragment, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected String[]
protected void
processAnnotationsUrl(URL url, WebXml fragment, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected void
processAnnotationsWebResource(WebResource webResource, WebXml fragment, boolean handlesTypesOnly, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

protected void
processAnnotationWebFilter(String
The filter class name
className
,
AnnotationEntry
The filter annotation
ae
,
WebXml
The corresponding fragment
fragment
)

process filter annotation and merge with existing one!

protected Map<String, String>
protected void
protected void
processClass(WebXml fragment, JavaClass clazz)

protected void
processClasses(WebXml webXml, Set<WebXml> orderedFragments)

protected void
processContextConfig(Digester
The digester that will be used for XML parsing
digester
,
URL
The URL to the context.xml configuration
contextXml
,
InputStream
The XML resource stream
stream
)

Process a context.xml.

protected Map<String, WebXml>

Returns:

A map of JAR name to processed web fragment (if any)
processJarsForWebFragments
(WebXml
The main web.xml metadata
application
,
WebXmlParser
The parser to use to process the web.xml file
webXmlParser
)

Scan /WEB-INF/lib for JARs and for each one found add it and any /META-INF/web-fragment.xml to the resulting Map.

protected void
processResourceJARs(Set<WebXml>
The set of fragments that will be scanned for static resources
fragments
)

Scan JARs that contain web-fragment.xml files that will be used to configure this application to see if they also contain static resources.

protected void
processServletContainerInitializers()

Scan JARs for ServletContainerInitializer implementations.

private void
scanWebXmlFragment(boolean handlesTypesOnly, WebXml fragment, Map<String, ContextConfig.JavaClassCacheEntry> javaClassCache)

public void
setCustomAuthenticators(Map<String, Authenticator>
Custom mappings of login methods to authenticators
customAuthenticators
)

Sets custom mappings of login methods to authenticators.

public void
setDefaultWebXml(String
The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
path
)

Set the location of the default deployment descriptor.

protected void
validateSecurityRoles()

Validate the usage of security role names in the web application deployment descriptor.

protected void
webConfig()

Scan the web.xml files that apply to the web application and merge them using the rules defined in the spec.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait