Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    * 
    *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  package org.apache.catalina.core;
  
  import static org.jboss.web.CatalinaMessages.MESSAGES;
  
  import java.io.File;
  import java.util.EnumSet;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Set;
  import java.util.TreeMap;
  
  
Standard implementation of the Context interface. Each child container must be a Wrapper implementation to process the requests directed to a particular servlet.

Author(s):
Craig R. McClanahan
Remy Maucherat
Version:
$Revision: 2044 $ $Date: 2012-06-27 17:29:53 +0200 (Wed, 27 Jun 2012) $
 
 
 public class StandardContext
     extends ContainerBase
     implements ContextNotificationEmitter
 {
 
     // ----------------------------------------------------------- Constructors
 

    
Create a new StandardContext component with the default basic Valve.
 
     public StandardContext() {
 
         super();
         .setBasic(new StandardContextValve());
          = new NotificationBroadcasterSupport();
 
     }
 
 
     // ----------------------------------------------------- Class Variables
 

    
The descriptive information string for this implementation.
 
     protected static final String info =
         "org.apache.catalina.core.StandardContext/1.0";


    
Array containing the safe characters set.
 
     protected static URLEncoder urlEncoder;


    
GMT timezone - all HTTP dates are on GMT
 
     static {
          = new URLEncoder();
         .addSafeCharacter('~');
         .addSafeCharacter('-');
         .addSafeCharacter('_');
         .addSafeCharacter('.');
         .addSafeCharacter('*');
         .addSafeCharacter('/');
     }
 
 
     // ----------------------------------------------------- Instance Variables
 

    
The alternate deployment descriptor name.
 
     protected String altDDName = null;


    
Lifecycle provider.
 
     protected InstanceManager instanceManager = null;


   
Associated host name.
 
     protected String hostName;

    
    
The set of application listener class names configured for this application, in the order they were encountered in the web.xml file.
 
     protected String applicationListeners[] = new String[0];


    
The set of application listener class names configured for this application that have been added from TLDs, and have a limited access to the servlet context.
 
     protected HashSet<StringrestrictedApplicationListeners = new HashSet<String>();


    
The set of application listener class names configured for this application, in the order they were encountered in the web.xml file.
 
     protected EventListener applicationListenerInstances[] = new EventListener[0];


    
The set of instantiated application event listener objects.
 
     protected Object applicationEventListenersInstances[] = null;


    
The set of instantiated application lifecycle listener objects.
 
     protected Object applicationLifecycleListenersInstances[] = null;


    
The set of instantiated application session lifecycle listener objects.
 
     protected Object applicationSessionLifecycleListenersInstances[] = null;


    
The set of instantiated listener objects.
 
     protected Object listenersInstances[] = null;


    
The set of application parameters defined for this application.
 
         new ApplicationParameter[0];


    
The application authenticator for this Context. This is simply a reference and the authenticator should still be set as a valve.
 
     protected Authenticator authenticator = null;
    
    
The application available flag for this Context.
 
     protected boolean available = false;
    
    
The application starting flag for this Context.
 
     protected boolean starting = false;
    
    
The broadcaster that sends j2ee notifications.
 
     protected NotificationBroadcasterSupport broadcaster = null;
    
    
The Locale to character set mapper for this application.
 
     protected CharsetMapper charsetMapper = null;


    
The Java class name of the CharsetMapper class to be created.
 
     protected String charsetMapperClass =
       "org.apache.catalina.util.CharsetMapper";


    
The "correctly configured" flag for this Context.
 
     protected boolean configured = false;


    
The security constraints for this web application.
 
     protected SecurityConstraint constraints[] = new SecurityConstraint[0];


    
The ServletContext implementation associated with this Context.
 
     protected ApplicationContext context = null;


    
The class name of the context configurator.
 
     protected String configClass = null;


    
Session tracking modes.
 
         EnumSet.of(.. /*TODO:, SessionTrackingMode.SSL*/);
    

    
Session tracking modes.
 
     protected Set<SessionTrackingModesessionTrackingModes = null;
    

   
Should we allow the ServletContext.getContext() method to access the context of other web applications in this server?
 
     protected boolean crossContext = 
         Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardContext.CROSS_CONTEXT""false")).booleanValue();

    
    
Encoded path.
 
     protected String encodedPath = null;
    

    
The display name of this web application.
 
     protected String displayName = null;


    
The distributable flag for this web application.
 
     protected boolean distributable = false;


    
The document root for this web application.
 
     protected String docBase = null;


    
The exception pages for this web application, keyed by fully qualified class name of the Java exception.
 
     protected HashMap<StringErrorPageexceptionPages = new HashMap<StringErrorPage>();


    
The set of filter configurations (and associated filter instances) we have initialized, keyed by filter name.
 
The set of filter definitions for this application, keyed by filter name.
 
     protected HashMap<StringFilterDeffilterDefs = new HashMap<StringFilterDef>();


    
The set of filter mappings for this application, in the order they were defined in the deployment descriptor with additional mappings added via the javax.servlet.ServletContext possibly both before and after those defined in the deployment descriptor.
 
     protected FilterMap filterMaps[] = new FilterMap[0];


    
Filter mappings added via javax.servlet.ServletContext may have to be inserted before the mappings in the deploymenmt descriptor but must be inserted in the order the javax.servlet.ServletContext methods are called. This isn't an issue for the mappings added after the deployment descriptor - they are just added to the end - but correctly the adding mappings before the deployment descriptor mappings requires knowing where the last 'before' mapping was added.
 
     protected int filterMapInsertPoint = 0;


    
Ignore annotations.
 
     protected boolean ignoreAnnotations = false;


    
The set of classnames of InstanceListeners that will be added to each newly created Wrapper by createWrapper().
 
     protected String instanceListeners[] = new String[0];

    
    
The set of JSP property groups defined for the webapp, keyed by pattern.
 
     protected LinkedHashMap<StringJspPropertyGroupjspPropertyGroups = new LinkedHashMap<StringJspPropertyGroup>();
    

    
The set of taglibs defined for the webapp, keyed by uri.
 
     protected HashMap<StringTagLibraryInfojspTagLibraries = new HashMap<StringTagLibraryInfo>();
    

    
The logical name of the webapp, if any which may be used in other descriptors.
 
     protected String logicalName = null;


    
The login configuration descriptor for this web application.
 
     protected LoginConfig loginConfig = null;


    
The mapper associated with this context.
 
     protected org.apache.tomcat.util.http.mapper.Mapper mapper = 
         new org.apache.tomcat.util.http.mapper.Mapper();


    
The MIME mappings for this web application, keyed by extension.
 
     protected HashMap<StringStringmimeMappings = new HashMap<StringString>();


     
Special case: error page for status 200.
 
      protected ErrorPage okErrorPage = null;


    
The context initialization parameters for this web application, keyed by name.
 
     protected HashMap<StringStringparameters = new HashMap<StringString>();


    
The request processing pause flag (while reloading occurs)
 
     protected boolean paused = false;


    
The public identifier of the DTD for the web application deployment descriptor version we are currently parsing. This is used to support relaxed validation rules when processing version 2.2 web.xml files.
 
     protected String publicId = null;

    
    
Version number.
 
     protected String version = null;


    
Version number.
 
     protected int versionMinor = 0;


    
Version number.
 
     protected int versionMajor = 0;


    
The override flag for this web application.
 
     protected boolean override = false;


    
The privileged flag for this web application.
 
     protected boolean privileged = false;


    
Should the next call to addWelcomeFile() cause replacement of any existing welcome files? This will be set before processing the web application's deployment descriptor, so that application specified choices replace, rather than append to, those defined in the global descriptor.
 
     protected boolean replaceWelcomeFiles = false;


    
The security role mappings for this application, keyed by role name (as used within the application).
 
     protected HashMap<StringStringroleMappings = new HashMap<StringString>();


    
The security roles for this application, keyed by role name.
 
     protected String securityRoles[] = new String[0];


    
The servlet mappings for this web application, keyed by matching pattern.
 
     protected HashMap<StringStringservletMappings = new HashMap<StringString>();


    
The session timeout (in minutes) for this web application.
 
     protected int sessionTimeout = 30;

    
The notification sequence number.
 
     protected long sequenceNumber = 0;

    
The session cookie.
 
     protected SessionCookie sessionCookie = new SessionCookie();
    
    
The status code error pages for this web application, keyed by HTTP status code (as an Integer).
 
     protected HashMap<IntegerErrorPagestatusPages = new HashMap<IntegerErrorPage>();


    
The JSP tag libraries for this web application, keyed by URI
 
     protected HashMap<StringStringtaglibs = new HashMap<StringString>();


    
Amount of ms that the container will wait for servlets to unload.
 
     protected long unloadDelay = 2000;


    
The welcome files for this application.
 
     protected String welcomeFiles[] = new String[0];


    
The set of classnames of LifecycleListeners that will be added to each newly created Wrapper by createWrapper().
 
     protected String wrapperLifecycles[] = new String[0];


    
The set of classnames of ContainerListeners that will be added to each newly created Wrapper by createWrapper().
 
     protected String wrapperListeners[] = new String[0];


    
The pathname to the work directory for this context (relative to the server's home if not absolute).
 
     protected String workDir = null;


    
Java class name of the Wrapper class implementation we use.
 
     protected String wrapperClassName = StandardWrapper.class.getName();
     protected Class<?> wrapperClass = null;


    
Filesystem based flag.
 
     protected boolean filesystemBased = false;


    
Caching allowed flag.
 
     protected boolean cachingAllowed = true;


    
Case sensitivity.
 
     protected boolean caseSensitive = true;


    
Allow linking.
 
     protected boolean allowLinking = false;


    
Cache max size in KB.
 
     protected int cacheMaxSize = (.....) ? 128 : 10240; // 10 MB
 

    
Cache object max size in KB.
 
     protected int cacheObjectMaxSize = (.....) ? 8 : 256; // 256K
 

    
Cache TTL in ms.
 
     protected int cacheTTL = 5000;


    
Non proxied resources.
 
     protected DirContext webappResources = null;
 
     protected long startupTime;
     protected long startTime;
     protected long tldScanTime;

    
Name of the engine. If null, the domain is used.
  
     protected String engineName = null;
     protected String j2EEApplication="none";
     protected String j2EEServer="none";
 
 
     protected static final ThreadBindingListener DEFAULT_NAMING_LISTENER = (new ThreadBindingListener() {
         public void bind() {}
         public void unbind() {}
     });
 
 
     // ----------------------------------------------------- Context Properties
 
 
     public InstanceManager getInstanceManager() {
        return ;
     }
 
 
     public void setInstanceManager(InstanceManager instanceManager) {
        this. = instanceManager;
     }
 
     
     public String getEncodedPath() {
         return ;
     }
 
 
     public void setNameString name ) {
         super.setNamename );
          = .encode(name);
     }


    
Is caching allowed ?
 
     public boolean isCachingAllowed() {
         return ;
     }


    
Set caching allowed flag.
 
     public void setCachingAllowed(boolean cachingAllowed) {
         this. = cachingAllowed;
     }


    
Set case sensitivity.
 
     public void setCaseSensitive(boolean caseSensitive) {
         this. = caseSensitive;
     }


    
Is case sensitive ?
 
     public boolean isCaseSensitive() {
         return ;
     }


    
Set allow linking.
 
     public void setAllowLinking(boolean allowLinking) {
         this. = allowLinking;
     }


    
Is linking allowed.
 
     public boolean isAllowLinking() {
         return ;
     }


    
Set cache TTL.
 
     public void setCacheTTL(int cacheTTL) {
         this. = cacheTTL;
     }


    
Get cache TTL.
 
     public int getCacheTTL() {
         return ;
     }


    
Return the maximum size of the cache in KB.
 
     public int getCacheMaxSize() {
         return ;
     }


    
Set the maximum size of the cache in KB.
 
     public void setCacheMaxSize(int cacheMaxSize) {
         this. = cacheMaxSize;
     }


    
Return the maximum size of objects to be cached in KB.
 
     public int getCacheObjectMaxSize() {
         return ;
     }


    
Set the maximum size of objects to be placed the cache in KB.
 
     public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
         this. = cacheObjectMaxSize;
     }


    
Returns true if the resources associated with this context are filesystem based.
 
     public boolean isFilesystemBased() {
         return ();
     }


    
Force setting if filesystem based.
 
     public void setFilesystemBased(boolean filesystemBased) {
         this. = filesystemBased;
     }


    
Return the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Throws:
java.lang.IllegalStateException if this method is called before this application has started, or after it has been stopped
 
     public Object[] getApplicationEventListeners() {
         return ( != null 
                 ?  : );
     }


    
Store the set of initialized application event listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Parameters:
listeners The set of instantiated listener objects.
 
     public void setApplicationEventListeners(Object listeners[]) {
          = listeners;
     }


    
Return the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Throws:
java.lang.IllegalStateException if this method is called before this application has started, or after it has been stopped
 
         return ( != null 
                 ?  : );
     }


    
Store the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Parameters:
listeners The set of instantiated listener objects.
 
     public void setApplicationSessionLifecycleListeners(Object listeners[]) {
          = listeners;
     }


    
Return the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Throws:
java.lang.IllegalStateException if this method is called before this application has started, or after it has been stopped
 
         return ();
     }


    
Store the set of initialized application lifecycle listener objects, in the order they were specified in the web application deployment descriptor, for this application.

Parameters:
listeners The set of instantiated listener objects.
 
     public void setApplicationLifecycleListeners(Object listeners[]) {
          = listeners;
     }


    
Return the application authenticator for this Context.
 
     public Authenticator getAuthenticator() {
         return (this.);
     }


    
Set the application authenticator for this Context.

Parameters:
authenticator The new application authenticator
 
     public void setAuthenticator(Authenticator authenticator) {
         Authenticator oldAuthenticator = this.;
         this. = authenticator;
         .firePropertyChange("authenticator"oldAuthenticator
                 this.);
     }


    
Return the application available flag for this Context.
 
     public boolean getAvailable() {
         return (this.);
     }


    
Set the application available flag for this Context.

Parameters:
available The new application available flag
 
     public void setAvailable(boolean available) {
         boolean oldAvailable = this.;
         this. = available;
         .firePropertyChange("available"oldAvailablethis.);
     }


    
Return the application starting flag for this Context.
 
     public boolean isStarting() {
         return (this.);
     }


    
Set the application starting flag for this Context.

Parameters:
starting The new application starting flag
 
     public void setStarting(boolean starting) {
         this. = starting;
     }


   
Return the Locale to character set mapper for this Context.
 
     public CharsetMapper getCharsetMapper() {
 
         // Create a mapper the first time it is requested
         if (this. == null) {
             try {
                 Class<?> clazz = Class.forName();
                 this. = (CharsetMapperclazz.newInstance();
             } catch (Throwable t) {
                 this. = new CharsetMapper();
             }
         }
 
         return (this.);
 
     }


    
Set the Locale to character set mapper for this Context.

Parameters:
mapper The new mapper
 
     public void setCharsetMapper(CharsetMapper mapper) {
         CharsetMapper oldCharsetMapper = this.;
         this. = mapper;
         ifmapper != null )
             this.mapper.getClass().getName();
         .firePropertyChange("charsetMapper"oldCharsetMapper,
                                    this.);
     }

    
Return the class name of the context configurator.
 
     public String getConfigClass() {
         return (this.);
     }


    
Set the class name of the context configurator.

Parameters:
configClass The class name of the listener.
 
     public void setConfigClass(String configClass) {
         this. = configClass;
     }
    
    
    
Return the "correctly configured" flag for this Context.
 
     public boolean getConfigured() {
         return (this.);
     }


    
Set the "correctly configured" flag for this Context. This can be set to false by startup listeners that detect a fatal configuration error to avoid the application from being made available.

Parameters:
configured The new correctly configured flag
 
     public void setConfigured(boolean configured) {
         boolean oldConfigured = this.;
         this. = configured;
         .firePropertyChange("configured"oldConfiguredthis.);
     }


    
Return the "use cookies for session ids" flag.
    public boolean getCookies() {
    }


    
Set the "use cookies for session ids" flag.

Parameters:
cookies The new flag
    public void setCookies(boolean cookies) {
        boolean oldCookies = .contains(.);
        if (oldCookies && !cookies) {
        }
        if (!oldCookies && cookies) {
        }
        if (oldCookies != cookies) {
            .firePropertyChange("cookies"oldCookiescookies);
        }
    }


    
Return the "allow crossing servlet contexts" flag.
    public boolean getCrossContext() {
        return (this.);
    }


    
Set the "allow crossing servlet contexts" flag.

Parameters:
crossContext The new cross contexts flag
    public void setCrossContext(boolean crossContext) {
        boolean oldCrossContext = this.;
        this. = crossContext;
        .firePropertyChange("crossContext"oldCrossContextthis.);
    }

    
Gets the time (in milliseconds) it took to start this context.

Returns:
Time (in milliseconds) it took to start this context.
    public long getStartupTime() {
        return ;
    }
    public void setStartupTime(long startupTime) {
        this. = startupTime;
    }
    public long getTldScanTime() {
        return ;
    }
    public void setTldScanTime(long tldScanTime) {
        this. = tldScanTime;
    }

    
Return the display name of this web application.
    public String getDisplayName() {
        return (this.);
    }


    
Return the alternate Deployment Descriptor name.
    public String getAltDDName(){
        return ;
    }


    
Set an alternate Deployment Descriptor name.
    public void setAltDDName(String altDDName) {
        this. = altDDName;
        if ( != null) {
            .setAttribute(.,altDDName);
        }
    }


    
Set the display name of this web application.

Parameters:
displayName The new display name
    public void setDisplayName(String displayName) {
        String oldDisplayName = this.;
        this. = displayName;
        .firePropertyChange("displayName"oldDisplayNamethis.);
    }


    
Return the distributable flag for this web application.
    public boolean getDistributable() {
        return (this.);
    }

    
Set the distributable flag for this web application.

Parameters:
distributable The new distributable flag
    public void setDistributable(boolean distributable) {
        boolean oldDistributable = this.;
        this. = distributable;
        .firePropertyChange("distributable"oldDistributablethis.);
        // Bugzilla 32866
        ifgetManager() != null) {
            getManager().setDistributable(distributable);
        }
    }


    
Return the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.
    public String getDocBase() {
        return (this.);
    }

    
Set the document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.

Parameters:
docBase The new document root
    public void setDocBase(String docBase) {
        this. = docBase;
    }

    
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
    public String getInfo() {
        return ();
    }
    public String getEngineName() {
        if != null ) return ;
        return ;
    }
    public void setEngineName(String engineName) {
        this. = engineName;
    }
    public String getJ2EEApplication() {
        return ;
    }
    public void setJ2EEApplication(String j2EEApplication) {
        this. = j2EEApplication;
    }
    public String getJ2EEServer() {
        return ;
    }
    public void setJ2EEServer(String j2EEServer) {
        this. = j2EEServer;
    }


    
Set the Loader with which this Context is associated.

Parameters:
loader The newly associated loader
    public void setLoader(Loader loader) {
        super.setLoader(loader);
    }


    
Return the boolean on the annotations parsing.
    public boolean getIgnoreAnnotations() {
        return this.;
    }
    
    
    
Set the boolean on the annotations parsing for this web application.

Parameters:
ignoreAnnotations The boolean on the annotations parsing
    public void setIgnoreAnnotations(boolean ignoreAnnotations) {
        boolean oldIgnoreAnnotations = this.;
        this. = ignoreAnnotations;
        .firePropertyChange("ignoreAnnotations"oldIgnoreAnnotationsthis.);
    }
    
    
    
Set the session cookie configuration.

Parameters:
sessionCookie The new value
    public void setSessionCookie(SessionCookie sessionCookie) {
        SessionCookie oldSessionCookie = this.;
        this. = sessionCookie;
        .firePropertyChange("sessionCookie"oldSessionCookiesessionCookie);
    }


    
Return the session cookie configuration.
    public SessionCookie getSessionCookie() {
        return this.;
    }


    
Return the logical name for this web application.
    public String getLogicalName() {
        return ;
    }


    
Set the logical name for this web application.

Parameters:
logicalName The new logical name
    public void setLogicalName(String logicalName) {
        String oldLogicalName = this.;
        this. = logicalName;
        .firePropertyChange("logicalName"oldLogicalNamelogicalName);
    }


    
Return the login configuration descriptor for this web application.
    public LoginConfig getLoginConfig() {
        return (this.);
    }


    
Set the login configuration descriptor for this web application.

Parameters:
config The new login configuration
    public void setLoginConfig(LoginConfig config) {
        // Validate the incoming property value
        if (config == null)
            throw .nullLoginConfig();
        String loginPage = config.getLoginPage();
        if ((loginPage != null) && !loginPage.startsWith("/")) {
            if (isServlet22()) {
                ..loginPageStartsWithSlash(loginPage);
                config.setLoginPage("/" + loginPage);
            } else {
                throw .loginPageMustStartWithSlash(loginPage);
            }
        }
        String errorPage = config.getErrorPage();
        if ((errorPage != null) && !errorPage.startsWith("/")) {
            if (isServlet22()) {
                ..errorPageStartsWithSlash(errorPage);
                config.setErrorPage("/" + errorPage);
            } else {
                throw .errorPageMustStartWithSlash(errorPage);
            }
        }
        // Process the property setting change
        LoginConfig oldLoginConfig = this.;
        this. = config;
        .firePropertyChange("loginConfig",
                                   oldLoginConfigthis.);
    }


    
Get the mapper associated with the context.
        return ();
    }


    
Return the context path for this Context.
    public String getPath() {
        return (getName());
    }

    
    
Set the context path for this Context.

IMPLEMENTATION NOTE: The context path is used as the "name" of a Context, because it must be unique.

Parameters:
path The new context path
    public void setPath(String path) {
        setName(path);
    }


    
Return the public identifier of the deployment descriptor DTD that is currently being parsed.
    public String getPublicId() {
        return (this.);
    }


    
Set the public identifier of the deployment descriptor DTD that is currently being parsed.

Parameters:
publicId The public identifier
    public void setPublicId(String publicId) {
        String oldPublicId = this.;
        this. = publicId;
        .firePropertyChange("publicId"oldPublicIdpublicId);
    }


    
Return the Servlet API version defined for the webapp.
    public String getVersion() {
        return this.;
    }


    
Return the Servlet API version defined for the webapp.
    public int getVersionMajor() {
        if ( != null) {
            int pos = .indexOf('.');
            if (pos != -1) {
                 = Integer.parseInt(.substring(0, pos));
            }
        }
        return ;
    }


    
Return the Servlet API version defined for the webapp.
    public int getVersionMinor() {
        if ( != null) {
            int pos = .indexOf('.');
            if (pos < .length()) {
                 = Integer.parseInt(.substring(pos + 1));
            }
        }
        return ;
    }


    
Set the Servlet API version defined for the webapp.

Parameters:
version The version
    public void setVersion(String version) {
        String oldVersion = this.;
        this. = version;
        getVersionMajor();
        getVersionMinor();
        .firePropertyChange("version"oldVersionversion);
    }


    
Return the DefaultContext override flag for this web application.
    public boolean getOverride() {
        return (this.);
    }


    
Return the parent class loader (if any) for this web application. This call is meaningful only after a Loader has been configured.
        if ( != null)
            return ();
        if (getPrivileged()) {
            return this.getClass().getClassLoader();
        } else if ( != null) {
            return (.getParentClassLoader());
        }
        return (ClassLoader.getSystemClassLoader());
    }

    
    
Return the privileged flag for this web application.
    public boolean getPrivileged() {
        return (this.);
    }


    
Set the privileged flag for this web application.

Parameters:
privileged The new privileged flag
    public void setPrivileged(boolean privileged) {
        boolean oldPrivileged = this.;
        this. = privileged;
        .firePropertyChange("privileged"oldPrivilegedthis.);
    }


    
Set the override flag for this web application.

Parameters:
override The new override flag
    public void setOverride(boolean override) {
        boolean oldOverride = this.;
        this. = override;
        .firePropertyChange("override"oldOverridethis.);
    }
        return ;
    }
        if ( == null) {
            return ;
        } else {
            return ;
        }
    }
    public void setSessionTrackingModes(
            Set<SessionTrackingModesessionTrackingModes) {
        this. = sessionTrackingModes;
    }
    
    
    public void addSessionTrackingMode(String trackingMode) {
        SessionTrackingMode mode = SessionTrackingMode.valueOf(trackingMode);
        if (mode == null) {
            // FIXME: error message
            throw new IllegalArgumentException();
        }
        if ( == null) {
             = new HashSet<SessionTrackingMode>();
        }
        .add(mode);
    }
    
    
    
Return the "replace welcome files" property.
    public boolean isReplaceWelcomeFiles() {
        return (this.);
    }


    
Set the "replace welcome files" property.

Parameters:
replaceWelcomeFiles The new property value
    public void setReplaceWelcomeFiles(boolean replaceWelcomeFiles) {
        boolean oldReplaceWelcomeFiles = this.;
        this. = replaceWelcomeFiles;
        .firePropertyChange("replaceWelcomeFiles"oldReplaceWelcomeFilesthis.);
    }


    
Return the servlet context for which this Context is a facade.
        if ( == null) {
             = new ApplicationContext(getBasePath(), this);
            if ( != null)
                .setAttribute(.,);
        }
        return (.getFacade());
    }


    
Return the default session timeout (in minutes) for this web application.
    public int getSessionTimeout() {
        return (this.);
    }


    
Set the default session timeout (in minutes) for this web application.

Parameters:
timeout The new default session timeout
    public void setSessionTimeout(int timeout) {
        int oldSessionTimeout = this.;
        /*
         * SRV.13.4 ("Deployment Descriptor"):
         * If the timeout is 0 or less, the container ensures the default
         * behaviour of sessions is never to time out.
         */
        this. = (timeout == 0) ? -1 : timeout;
        .firePropertyChange("sessionTimeout"oldSessionTimeoutthis.);
    }


    
Return the value of the unloadDelay flag.
    public long getUnloadDelay() {
        return (this.);
    }

    
    
Set the value of the unloadDelay flag, which represents the amount of ms that the container will wait when unloading servlets. Setting this to a small value may cause more requests to fail to complete when stopping a web application.

Parameters:
unloadDelay The new value
    public void setUnloadDelay(long unloadDelay) {
        long oldUnloadDelay = this.;
        this. = unloadDelay;
        .firePropertyChange("unloadDelay"oldUnloadDelaythis.);
    }


    
Return the Java class name of the Wrapper implementation used for servlets registered in this Context.
    public String getWrapperClass() {
        return (this.);
    }


    
Set the Java class name of the Wrapper implementation used for servlets registered in this Context.

Parameters:
wrapperClassName The new wrapper class name
Throws:
java.lang.IllegalArgumentException if the specified wrapper class cannot be found or is not a subclass of StandardWrapper
    public void setWrapperClass(String wrapperClassName) {
        this. = wrapperClassName;
        try {
             = Class.forName(wrapperClassName);         
            if (!StandardWrapper.class.isAssignableFrom()) {
                throw .invalidWrapperClass(wrapperClassName);
            }
        } catch (ClassNotFoundException cnfe) {
            throw new IllegalArgumentException(cnfe.getMessage());
        }
    }


    
Set the resources DirContext object with which this Container is associated.

Parameters:
resources The newly associated DirContext
    public void setResources(DirContext resources) {
        if () {
            throw .cannotSetResourcesAfterStart();
        }
        DirContext oldResources = this.;
        if (oldResources == resources)
            return;
        if (resources instanceof BaseDirContext) {
            ((BaseDirContextresources).setCached(isCachingAllowed());
            ((BaseDirContextresources).setCacheTTL(getCacheTTL());
            ((BaseDirContextresources).setCacheMaxSize(getCacheMaxSize());
            ((BaseDirContextresources).setCacheObjectMaxSize(getCacheObjectMaxSize());
        }
        if (resources instanceof FileDirContext) {
             = true;
            ((FileDirContextresources).setCaseSensitive(isCaseSensitive());
            ((FileDirContextresources).setAllowLinking(isAllowLinking());
        }
        this. = resources;
        // The proxied resources will be refreshed on start
        this. = null;
        .firePropertyChange("resources"oldResources,
                                   this.);
    }


    
Get the associated ThreadBindingListener.
        return ;
    }


    
Get the associated ThreadBindingListener.
    public void setThreadBindingListener(ThreadBindingListener threadBindingListener) {
        this. = threadBindingListener;
    }
    // ------------------------------------------------------ Public Properties


    
Return the Locale to character set mapper class for this Context.
    public String getCharsetMapperClass() {
        return (this.);
    }


    
Set the Locale to character set mapper class for this Context.

Parameters:
mapper The new mapper class
    public void setCharsetMapperClass(String mapper) {
        String oldCharsetMapperClass = this.;
        this. = mapper;
        .firePropertyChange("charsetMapperClass",
                                   oldCharsetMapperClass,
                                   this.);
    }


    
Get the absolute path to the work dir. To avoid duplication.

Returns:
The work path
    public String getWorkPath() {
        if (getWorkDir() == null) {
            return null;
        }
        File workDir = new File(getWorkDir());
        if (!workDir.isAbsolute()) {
            File catalinaHome = workBase();
            String catalinaHomePath = null;
            try {
                catalinaHomePath = catalinaHome.getCanonicalPath();
                workDir = new File(catalinaHomePath,
                        getWorkDir());
            } catch (IOException e) {
                ..failedObtainingWorkDirectory(getPath(), e);
            }
        }
        return workDir.getAbsolutePath();
    }
    
    
Return the work directory for this Context.
    public String getWorkDir() {
        return (this.);
    }


    
Set the work directory for this Context.

Parameters:
workDir The new work directory
    public void setWorkDir(String workDir) {
        this. = workDir;
        if () {
            postWorkDirectory();
        }
    }
    // -------------------------------------------------------- Context Methods


    
Add a new Listener class name to the set of Listeners configured for this application.

Parameters:
listener Java class name of a listener class
    public void addApplicationListener(String listener) {
        addApplicationListener(listenerfalse);
    }


    
Add a new Listener class name to the set of Listeners configured for this application.

Parameters:
listener Java class name of a listener class
    protected void addApplicationListener(String listenerboolean restricted) {
        String results[] = new String[. + 1];
        for (int i = 0; i < .i++) {
            if (listener.equals([i])) {
                ..duplicateListener(listener);
                if (!restricted && .contains(listener)) {
                    .remove(listener);
                }
                return;
            }
            results[i] = [i];
        }
        results[.] = listener;
        if (restricted && !.contains(listener)) {
            boolean found = false;
            for (String check : ) {
                if (check.equals(listener)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                .add(listener);
            }