Class ContextConfig

java.lang.Object
org.apache.catalina.startup.ContextConfig
All Implemented Interfaces:
LifecycleListener

public class ContextConfig extends Object implements LifecycleListener
Startup event listener for a Context that configures the properties of that Context, and the associated defined servlets.
Author:
Craig R. McClanahan
  • Field Details Link icon

    • sm Link icon

      protected static final StringManager sm
      The string resources for this package.
    • DUMMY_LOGIN_CONFIG Link icon

      protected static final LoginConfig DUMMY_LOGIN_CONFIG
    • authenticators Link icon

      protected static final Properties authenticators
      The set of Authenticators that we know how to configure. The key is the name of the implemented authentication method, and the value is the fully qualified Java class name of the corresponding Valve.
    • deploymentCount Link icon

      protected static long deploymentCount
      Deployment count.
    • hostWebXmlCache Link icon

      protected static final Map<Host,org.apache.catalina.startup.ContextConfig.DefaultWebXmlCacheEntry> hostWebXmlCache
      Cache of default web.xml fragments per Host
    • customAuthenticators Link icon

      protected Map<String,Authenticator> customAuthenticators
      Custom mappings of login methods to authenticators
    • context Link icon

      protected volatile Context context
      The Context we are associated with.
    • defaultWebXml Link icon

      protected String defaultWebXml
      The default web application's deployment descriptor location.
    • ok Link icon

      protected boolean ok
      Track any fatal errors during startup configuration processing.
    • originalDocBase Link icon

      protected String originalDocBase
      Original docBase.
    • initializerClassMap Link icon

      protected final Map<ServletContainerInitializer,Set<Class<?>>> initializerClassMap
      Map of ServletContainerInitializer to classes they expressed interest in.
    • typeInitializerMap Link icon

      protected final Map<Class<?>,Set<ServletContainerInitializer>> typeInitializerMap
      Map of Types to ServletContainerInitializer that are interested in those types.
    • handlesTypesAnnotations Link icon

      protected boolean handlesTypesAnnotations
      Flag that indicates if at least one HandlesTypes entry is present that represents an annotation.
    • handlesTypesNonAnnotations Link icon

      protected boolean handlesTypesNonAnnotations
      Flag that indicates if at least one HandlesTypes entry is present that represents a non-annotation.
  • Constructor Details Link icon

    • ContextConfig Link icon

      public ContextConfig()
  • Method Details Link icon

    • getDefaultWebXml Link icon

      public String getDefaultWebXml()
      Obtain the location of the default deployment descriptor.
      Returns:
      The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
    • setDefaultWebXml Link icon

      public void setDefaultWebXml(String path)
      Set the location of the default deployment descriptor.
      Parameters:
      path - The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
    • setCustomAuthenticators Link icon

      public void setCustomAuthenticators(Map<String,Authenticator> customAuthenticators)
      Sets custom mappings of login methods to authenticators.
      Parameters:
      customAuthenticators - Custom mappings of login methods to authenticators
    • lifecycleEvent Link icon

      public void lifecycleEvent(LifecycleEvent event)
      Process events for an associated Context.
      Specified by:
      lifecycleEvent in interface LifecycleListener
      Parameters:
      event - The lifecycle event that has occurred
    • applicationAnnotationsConfig Link icon

      protected void applicationAnnotationsConfig()
      Process the application classes annotations, if it exists.
    • authenticatorConfig Link icon

      protected void authenticatorConfig()
      Set up an Authenticator automatically if required, and one has not already been configured.
    • createContextDigester Link icon

      protected Digester createContextDigester()
      Create (if necessary) and return a Digester configured to process the context configuration descriptor for an application.
      Returns:
      the digester for context.xml files
    • getGenerateCode Link icon

      protected boolean getGenerateCode()
    • getUseGeneratedCode Link icon

      protected boolean getUseGeneratedCode()
    • getGeneratedCodeLocation Link icon

      protected File getGeneratedCodeLocation()
    • getGeneratedCodePackage Link icon

      protected String getGeneratedCodePackage()
    • getContextXmlPackageName Link icon

      protected static String getContextXmlPackageName(String generatedCodePackage, Container container)
    • getContextXmlJavaSource Link icon

      protected File getContextXmlJavaSource(String contextXmlPackageName, String contextXmlSimpleClassName)
    • generateClassHeader Link icon

      protected void generateClassHeader(Digester digester, String packageName, String resourceName)
    • generateClassFooter Link icon

      protected void generateClassFooter(Digester digester)
    • contextConfig Link icon

      protected void contextConfig(Digester digester)
      Process the default configuration file, if it exists.
      Parameters:
      digester - The digester that will be used for XML parsing
    • processContextConfig Link icon

      protected void processContextConfig(Digester digester, URL contextXml, InputStream stream)
      Process a context.xml.
      Parameters:
      digester - The digester that will be used for XML parsing
      contextXml - The URL to the context.xml configuration
      stream - The XML resource stream
    • fixDocBase Link icon

      protected void fixDocBase() throws IOException
      Adjust docBase.
      Throws:
      IOException - cannot access the context base path
    • antiLocking Link icon

      protected void antiLocking()
    • init Link icon

      protected void init()
      Process a "init" event for this Context.
    • beforeStart Link icon

      protected void beforeStart()
      Process a "before start" event for this Context.
    • configureStart Link icon

      protected void configureStart()
      Process a "contextConfig" event for this Context.
    • configureStop Link icon

      protected void configureStop()
      Process a "stop" event for this Context.
    • destroy Link icon

      protected void destroy()
      Process a "destroy" event for this Context.
    • validateSecurityRoles Link icon

      protected void validateSecurityRoles()
      Validate the usage of security role names in the web application deployment descriptor. If any problems are found, issue warning messages (for backwards compatibility) and add the missing roles. (To make these problems fatal instead, simply set the ok instance variable to false as well).
    • getHostConfigBase Link icon

      protected File getHostConfigBase()
    • webConfig Link icon

      protected void webConfig()
      Scan the web.xml files that apply to the web application and merge them using the rules defined in the spec. For the global web.xml files, where there is duplicate configuration, the most specific level wins. ie an application's web.xml takes precedence over the host level or global web.xml file.
    • processClasses Link icon

      protected void processClasses(WebXml webXml, Set<WebXml> orderedFragments)
    • createWebXml Link icon

      protected WebXml createWebXml()
    • processServletContainerInitializers Link icon

      protected void processServletContainerInitializers()
      Scan JARs for ServletContainerInitializer implementations.
    • processResourceJARs Link icon

      protected void processResourceJARs(Set<WebXml> 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. If static resources are found, add them to the context. Resources are added in web-fragment.xml priority order.
      Parameters:
      fragments - The set of fragments that will be scanned for static resources
    • getGlobalWebXmlSource Link icon

      protected InputSource getGlobalWebXmlSource()
      Identify the default web.xml to be used and obtain an input source for it.
      Returns:
      an input source to the default web.xml
    • getHostWebXmlSource Link icon

      protected InputSource getHostWebXmlSource()
      Identify the host web.xml to be used and obtain an input source for it.
      Returns:
      an input source to the default per host web.xml
    • getContextWebXmlSource Link icon

      protected InputSource getContextWebXmlSource()
      Identify the application web.xml to be used and obtain an input source for it.
      Returns:
      an input source to the context web.xml
    • getConfigBasePath Link icon

      public String getConfigBasePath()
    • getWebXmlSource Link icon

      protected InputSource getWebXmlSource(String filename, boolean global)
      Utility method to create an input source from the specified XML file.
      Parameters:
      filename - Name of the file (possibly with one or more leading path segments) to read
      global - true if processing a shared resource, false if processing a host based resource
      Returns:
      the input source
    • processJarsForWebFragments Link icon

      protected Map<String,WebXml> processJarsForWebFragments(WebXml application, WebXmlParser 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. web-fragment.xml files will be parsed before being added to the map. Every JAR will be added and null will be used if no web-fragment.xml was found. Any JARs known not contain fragments will be skipped.
      Parameters:
      application - The main web.xml metadata
      webXmlParser - The parser to use to process the web.xml file
      Returns:
      A map of JAR name to processed web fragment (if any)
    • processAnnotations Link icon

      protected void processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
    • processAnnotationsInParallel Link icon

      protected void processAnnotationsInParallel(Set<WebXml> fragments, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
      Parallelized version of processAnnotationsInParallel(). Constructs tasks, submits them as they're created, then waits for completion.
      Parameters:
      fragments - Set of parallelizable scans
      handlesTypesOnly - Important parameter for the underlying scan
      javaClassCache - The class cache
    • processAnnotationsWebResource Link icon

      protected void processAnnotationsWebResource(WebResource webResource, WebXml fragment, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
    • processAnnotationsUrl Link icon

      protected void processAnnotationsUrl(URL url, WebXml fragment, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
    • processAnnotationsJar Link icon

      protected void processAnnotationsJar(URL url, WebXml fragment, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
    • processAnnotationsFile Link icon

      protected void processAnnotationsFile(File file, WebXml fragment, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache)
    • processAnnotationsStream Link icon

      protected void processAnnotationsStream(InputStream is, WebXml fragment, boolean handlesTypesOnly, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> javaClassCache) throws ClassFormatException, IOException
      Throws:
      ClassFormatException
      IOException
    • processClass Link icon

      protected void processClass(WebXml fragment, JavaClass clazz)
    • checkHandlesTypes Link icon

      protected void checkHandlesTypes(JavaClass javaClass, Map<String,org.apache.catalina.startup.ContextConfig.JavaClassCacheEntry> 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.
      Parameters:
      javaClass - the class to check
      javaClassCache - a class cache
    • processAnnotationWebServlet Link icon

      protected void processAnnotationWebServlet(String className, AnnotationEntry ae, WebXml fragment)
    • processAnnotationWebFilter Link icon

      protected void processAnnotationWebFilter(String className, AnnotationEntry ae, WebXml fragment)
      Process filter annotation and merge with existing one
      Parameters:
      className - The filter class name
      ae - The filter annotation
      fragment - The corresponding fragment
    • processAnnotationsStringArray Link icon

      protected String[] processAnnotationsStringArray(ElementValue ev)
    • processAnnotationWebInitParams Link icon

      protected Map<String,String> processAnnotationWebInitParams(ElementValue ev)