/projects/tomcat-7.0.2/java/org/apache/catalina/core/StandardContext.java
Java | 1854 lines | 681 code | 455 blank | 718 comment | 38 complexity | 159a8a46e1de1f93566e8e15d895f7c6 MD5 | raw file
- /*
- * 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 java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.Iterator;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import java.util.Stack;
- import java.util.TreeMap;
- import javax.management.ListenerNotFoundException;
- import javax.management.MBeanNotificationInfo;
- import javax.management.Notification;
- import javax.management.NotificationBroadcasterSupport;
- import javax.management.NotificationEmitter;
- import javax.management.NotificationFilter;
- import javax.management.NotificationListener;
- import javax.management.ObjectName;
- import javax.naming.NamingException;
- import javax.naming.directory.DirContext;
- import javax.servlet.FilterConfig;
- import javax.servlet.ServletContainerInitializer;
- import javax.servlet.ServletContext;
- import javax.servlet.ServletContextAttributeListener;
- import javax.servlet.ServletContextEvent;
- import javax.servlet.ServletContextListener;
- import javax.servlet.ServletException;
- import javax.servlet.ServletRequestAttributeListener;
- import javax.servlet.ServletRequestListener;
- import javax.servlet.descriptor.JspConfigDescriptor;
- import javax.servlet.http.HttpSessionAttributeListener;
- import javax.servlet.http.HttpSessionListener;
- import org.apache.catalina.Authenticator;
- import org.apache.catalina.Container;
- import org.apache.catalina.ContainerListener;
- import org.apache.catalina.Context;
- import org.apache.catalina.Engine;
- import org.apache.catalina.Globals;
- import org.apache.catalina.Host;
- import org.apache.catalina.InstanceListener;
- import org.apache.catalina.Lifecycle;
- import org.apache.catalina.LifecycleException;
- import org.apache.catalina.LifecycleListener;
- import org.apache.catalina.LifecycleState;
- import org.apache.catalina.Loader;
- import org.apache.catalina.Manager;
- import org.apache.catalina.Pipeline;
- import org.apache.catalina.Valve;
- import org.apache.catalina.Wrapper;
- import org.apache.catalina.deploy.ApplicationParameter;
- import org.apache.catalina.deploy.ErrorPage;
- import org.apache.catalina.deploy.FilterDef;
- import org.apache.catalina.deploy.FilterMap;
- import org.apache.catalina.deploy.Injectable;
- import org.apache.catalina.deploy.InjectionTarget;
- import org.apache.catalina.deploy.LoginConfig;
- import org.apache.catalina.deploy.MessageDestination;
- import org.apache.catalina.deploy.MessageDestinationRef;
- import org.apache.catalina.deploy.NamingResources;
- import org.apache.catalina.deploy.SecurityCollection;
- import org.apache.catalina.deploy.SecurityConstraint;
- import org.apache.catalina.loader.WebappLoader;
- import org.apache.catalina.session.StandardManager;
- import org.apache.catalina.startup.TldConfig;
- import org.apache.catalina.util.CharsetMapper;
- import org.apache.catalina.util.ExtensionValidator;
- import org.apache.catalina.util.LifecycleBase;
- import org.apache.catalina.util.RequestUtil;
- import org.apache.catalina.util.URLEncoder;
- import org.apache.juli.logging.Log;
- import org.apache.juli.logging.LogFactory;
- import org.apache.naming.ContextBindings;
- import org.apache.naming.resources.BaseDirContext;
- import org.apache.naming.resources.DirContextURLStreamHandler;
- import org.apache.naming.resources.FileDirContext;
- import org.apache.naming.resources.ProxyDirContext;
- import org.apache.naming.resources.WARDirContext;
- import org.apache.tomcat.InstanceManager;
- import org.apache.tomcat.JarScanner;
- import org.apache.tomcat.util.modeler.Registry;
- import org.apache.tomcat.util.scan.StandardJarScanner;
- /**
- * Standard implementation of the <b>Context</b> interface. Each
- * child container must be a Wrapper implementation to process the
- * requests directed to a particular servlet.
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Id: StandardContext.java 978840 2010-07-24 10:17:45Z markt $
- */
- public class StandardContext extends ContainerBase
- implements Context, NotificationEmitter {
- private static final Log log = LogFactory.getLog(StandardContext.class);
- // ----------------------------------------------------------- Constructors
- /**
- * Create a new StandardContext component with the default basic Valve.
- */
- public StandardContext() {
- super();
- pipeline.setBasic(new StandardContextValve());
- broadcaster = new NotificationBroadcasterSupport();
- }
- // ----------------------------------------------------- Class Variables
- /**
- * The descriptive information string for this implementation.
- */
- private 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 {
- urlEncoder = new URLEncoder();
- urlEncoder.addSafeCharacter('~');
- urlEncoder.addSafeCharacter('-');
- urlEncoder.addSafeCharacter('_');
- urlEncoder.addSafeCharacter('.');
- urlEncoder.addSafeCharacter('*');
- urlEncoder.addSafeCharacter('/');
- }
- // ----------------------------------------------------- Instance Variables
- /**
- * The alternate deployment descriptor name.
- */
- private String altDDName = null;
- /**
- * Lifecycle provider.
- */
- private InstanceManager instanceManager = null;
- /**
- * Associated host name.
- */
- private String hostName;
- /**
- * The antiJARLocking flag for this Context.
- */
- private boolean antiJARLocking = false;
-
- /**
- * The antiResourceLocking flag for this Context.
- */
- private boolean antiResourceLocking = false;
-
- /**
- * The set of application listener class names configured for this
- * application, in the order they were encountered in the web.xml file.
- */
- private String applicationListeners[] = new String[0];
-
- private final Object applicationListenersLock = new Object();
- /**
- * The set of instantiated application event listener objects</code>.
- */
- private Object applicationEventListenersObjects[] =
- new Object[0];
- /**
- * The set of instantiated application lifecycle listener objects</code>.
- */
- private Object applicationLifecycleListenersObjects[] =
- new Object[0];
- /**
- * The ordered set of ServletContainerInitializers for this web application.
- */
- private Map<ServletContainerInitializer,Set<Class<?>>> initializers =
- new LinkedHashMap<ServletContainerInitializer,Set<Class<?>>>();
-
-
- /**
- * The set of application parameters defined for this application.
- */
- private ApplicationParameter applicationParameters[] =
- new ApplicationParameter[0];
- private final Object applicationParametersLock = new Object();
-
- /**
- * The broadcaster that sends j2ee notifications.
- */
- private NotificationBroadcasterSupport broadcaster = null;
-
- /**
- * The Locale to character set mapper for this application.
- */
- private CharsetMapper charsetMapper = null;
- /**
- * The Java class name of the CharsetMapper class to be created.
- */
- private String charsetMapperClass =
- "org.apache.catalina.util.CharsetMapper";
- /**
- * The URL of the XML descriptor for this context.
- */
- private URL configFile = null;
- /**
- * The "correctly configured" flag for this Context.
- */
- private boolean configured = false;
- /**
- * The security constraints for this web application.
- */
- private SecurityConstraint constraints[] = new SecurityConstraint[0];
-
- private final Object constraintsLock = new Object();
- /**
- * The ServletContext implementation associated with this Context.
- */
- protected ApplicationContext context = null;
- /**
- * Compiler classpath to use.
- */
- private String compilerClasspath = null;
- /**
- * Should we attempt to use cookies for session id communication?
- */
- private boolean cookies = true;
- /**
- * Should we allow the <code>ServletContext.getContext()</code> method
- * to access the context of other web applications in this server?
- */
- private boolean crossContext = false;
-
- /**
- * Encoded path.
- */
- private String encodedPath = null;
-
- /**
- * The "follow standard delegation model" flag that will be used to
- * configure our ClassLoader.
- */
- private boolean delegate = false;
- /**
- * The display name of this web application.
- */
- private String displayName = null;
- /**
- * Override the default context xml location.
- */
- private String defaultContextXml;
- /**
- * Override the default web xml location.
- */
- private String defaultWebXml;
- /**
- * The distributable flag for this web application.
- */
- private boolean distributable = false;
- /**
- * The document root for this web application.
- */
- private String docBase = null;
- /**
- * The exception pages for this web application, keyed by fully qualified
- * class name of the Java exception.
- */
- private HashMap<String, ErrorPage> exceptionPages =
- new HashMap<String, ErrorPage>();
- /**
- * The set of filter configurations (and associated filter instances) we
- * have initialized, keyed by filter name.
- */
- private HashMap<String, ApplicationFilterConfig> filterConfigs =
- new HashMap<String, ApplicationFilterConfig>();
- /**
- * The set of filter definitions for this application, keyed by
- * filter name.
- */
- private HashMap<String, FilterDef> filterDefs =
- new HashMap<String, FilterDef>();
- /**
- * The set of filter mappings for this application, in the order
- * they were defined in the deployment descriptor with additional mappings
- * added via the {@link ServletContext} possibly both before and after those
- * defined in the deployment descriptor.
- */
- private final ContextFilterMaps filterMaps = new ContextFilterMaps();
- /**
- * Ignore annotations.
- */
- private boolean ignoreAnnotations = false;
- /**
- * The set of classnames of InstanceListeners that will be added
- * to each newly created Wrapper by <code>createWrapper()</code>.
- */
- private String instanceListeners[] = new String[0];
- private final Object instanceListenersLock = new Object();
- /**
- * The login configuration descriptor for this web application.
- */
- private LoginConfig loginConfig = null;
- /**
- * The mapper associated with this context.
- */
- private org.apache.tomcat.util.http.mapper.Mapper mapper =
- new org.apache.tomcat.util.http.mapper.Mapper();
- /**
- * The naming context listener for this web application.
- */
- private NamingContextListener namingContextListener = null;
- /**
- * The naming resources for this web application.
- */
- private NamingResources namingResources = null;
- private ObjectName onameNamingResources;
- /**
- * The message destinations for this web application.
- */
- private HashMap<String, MessageDestination> messageDestinations =
- new HashMap<String, MessageDestination>();
- /**
- * The MIME mappings for this web application, keyed by extension.
- */
- private HashMap<String, String> mimeMappings =
- new HashMap<String, String>();
- /**
- * Special case: error page for status 200.
- */
- private ErrorPage okErrorPage = null;
- /**
- * The context initialization parameters for this web application,
- * keyed by name.
- */
- private HashMap<String, String> parameters = new HashMap<String, String>();
- /**
- * The request processing pause flag (while reloading occurs)
- */
- private 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.
- */
- private String publicId = null;
- /**
- * The reloadable flag for this web application.
- */
- private boolean reloadable = false;
- /**
- * Unpack WAR property.
- */
- private boolean unpackWAR = true;
- /**
- * The default context override flag for this web application.
- */
- private boolean override = false;
- /**
- * The original document root for this web application.
- */
- private String originalDocBase = null;
-
-
- /**
- * The privileged flag for this web application.
- */
- private boolean privileged = false;
- /**
- * Should the next call to <code>addWelcomeFile()</code> cause replacement
- * of any existing welcome files? This will be set before processing the
- * web application's deployment descriptor, so that application specified
- * choices <strong>replace</strong>, rather than append to, those defined
- * in the global descriptor.
- */
- private boolean replaceWelcomeFiles = false;
- /**
- * The security role mappings for this application, keyed by role
- * name (as used within the application).
- */
- private HashMap<String, String> roleMappings =
- new HashMap<String, String>();
- /**
- * The security roles for this application, keyed by role name.
- */
- private String securityRoles[] = new String[0];
- private final Object securityRolesLock = new Object();
- /**
- * The servlet mappings for this web application, keyed by
- * matching pattern.
- */
- private HashMap<String, String> servletMappings =
- new HashMap<String, String>();
-
- private final Object servletMappingsLock = new Object();
- /**
- * The session timeout (in minutes) for this web application.
- */
- private int sessionTimeout = 30;
- /**
- * The notification sequence number.
- */
- private long sequenceNumber = 0;
-
- /**
- * The status code error pages for this web application, keyed by
- * HTTP status code (as an Integer).
- */
- private HashMap<Integer, ErrorPage> statusPages =
- new HashMap<Integer, ErrorPage>();
- /**
- * Set flag to true to cause the system.out and system.err to be redirected
- * to the logger when executing a servlet.
- */
- private boolean swallowOutput = false;
- /**
- * Amount of ms that the container will wait for servlets to unload.
- */
- private long unloadDelay = 2000;
- /**
- * The watched resources for this application.
- */
- private String watchedResources[] = new String[0];
- private final Object watchedResourcesLock = new Object();
- /**
- * The welcome files for this application.
- */
- private String welcomeFiles[] = new String[0];
- private final Object welcomeFilesLock = new Object();
- /**
- * The set of classnames of LifecycleListeners that will be added
- * to each newly created Wrapper by <code>createWrapper()</code>.
- */
- private String wrapperLifecycles[] = new String[0];
- private final Object wrapperLifecyclesLock = new Object();
- /**
- * The set of classnames of ContainerListeners that will be added
- * to each newly created Wrapper by <code>createWrapper()</code>.
- */
- private String wrapperListeners[] = new String[0];
- private final Object wrapperListenersLock = new Object();
- /**
- * The pathname to the work directory for this context (relative to
- * the server's home if not absolute).
- */
- private String workDir = null;
- /**
- * Java class name of the Wrapper class implementation we use.
- */
- private String wrapperClassName = StandardWrapper.class.getName();
- private Class<?> wrapperClass = null;
- /**
- * JNDI use flag.
- */
- private boolean useNaming = true;
- /**
- * Filesystem based flag.
- */
- private boolean filesystemBased = false;
- /**
- * Name of the associated naming context.
- */
- private String namingContextName = null;
- /**
- * Caching allowed flag.
- */
- private boolean cachingAllowed = true;
- /**
- * Allow linking.
- */
- protected boolean allowLinking = false;
- /**
- * Cache max size in KB.
- */
- protected int cacheMaxSize = 10240; // 10 MB
- /**
- * Cache object max size in KB.
- */
- protected int cacheObjectMaxSize = 512; // 512K
- /**
- * Cache TTL in ms.
- */
- protected int cacheTTL = 5000;
- /**
- * List of resource aliases.
- */
- private String aliases = null;
- /**
- * Non proxied resources.
- */
- private DirContext webappResources = null;
- private long startupTime;
- private long startTime;
- private long tldScanTime;
- /**
- * Name of the engine. If null, the domain is used.
- */
- private String j2EEApplication="none";
- private String j2EEServer="none";
- /**
- * Attribute value used to turn on/off XML validation
- */
- private boolean webXmlValidation = Globals.STRICT_SERVLET_COMPLIANCE;
- /**
- * Attribute value used to turn on/off XML namespace validation
- */
- private boolean webXmlNamespaceAware = Globals.STRICT_SERVLET_COMPLIANCE;
- /**
- * Attribute value used to turn on/off TLD processing
- */
- private boolean processTlds = true;
- /**
- * Attribute value used to turn on/off XML validation
- */
- private boolean tldValidation = Globals.STRICT_SERVLET_COMPLIANCE;
- /**
- * Attribute value used to turn on/off TLD XML namespace validation
- */
- private boolean tldNamespaceAware = Globals.STRICT_SERVLET_COMPLIANCE;
- /**
- * Should we save the configuration.
- */
- private boolean saveConfig = true;
-
- /**
- * The name to use for session cookies. <code>null</code> indicates that
- * the name is controlled by the application.
- */
- private String sessionCookieName;
-
-
- /**
- * The flag that indicates that session cookies should use HttpOnly
- */
- private boolean useHttpOnly = true;
-
- /**
- * The domain to use for session cookies. <code>null</code> indicates that
- * the domain is controlled by the application.
- */
- private String sessionCookieDomain;
-
-
- /**
- * The path to use for session cookies. <code>null</code> indicates that
- * the path is controlled by the application.
- */
- private String sessionCookiePath;
-
-
- /**
- * The Jar scanner to use to search for Jars that might contain
- * configuration information such as TLDs or web-fragment.xml files.
- */
- private JarScanner jarScanner = null;
- /**
- * Should Tomcat attempt to null out any static or final fields from loaded
- * classes when a web application is stopped as a work around for apparent
- * garbage collection bugs and application coding errors? There have been
- * some issues reported with log4j when this option is true. Applications
- * without memory leaks using recent JVMs should operate correctly with this
- * option set to <code>false</code>. If not specified, the default value of
- * <code>false</code> will be used.
- */
- private boolean clearReferencesStatic = false;
-
- /**
- * Should Tomcat attempt to terminate threads that have been started by the
- * web application? Stopping threads is performed via the deprecated (for
- * good reason) <code>Thread.stop()</code> method and is likely to result in
- * instability. As such, enabling this should be viewed as an option of last
- * resort in a development environment and is not recommended in a
- * production environment. If not specified, the default value of
- * <code>false</code> will be used.
- */
- private boolean clearReferencesStopThreads = false;
- /**
- * Should Tomcat attempt to terminate any {@link java.util.TimerThread}s
- * that have been started by the web application? If not specified, the
- * default value of <code>false</code> will be used.
- */
- private boolean clearReferencesStopTimerThreads = false;
-
- /**
- * Should Tomcat attempt to clear any ThreadLocal objects that are instances
- * of classes loaded by this class loader. Failure to remove any such
- * objects will result in a memory leak on web application stop, undeploy or
- * reload. It is disabled by default since the clearing of the ThreadLocal
- * objects is not performed in a thread-safe manner.
- */
- private boolean clearReferencesThreadLocals = false;
-
- /**
- * Should the effective web.xml be logged when the context starts?
- */
- private boolean logEffectiveWebXml = false;
- private int effectiveMajorVersion = 3;
-
- private int effectiveMinorVersion = 0;
- private JspConfigDescriptor jspConfigDescriptor =
- new ApplicationJspConfigDescriptor();
- // ----------------------------------------------------- Context Properties
- public int getEffectiveMajorVersion() {
- return effectiveMajorVersion;
- }
- public void setEffectiveMajorVersion(int effectiveMajorVersion) {
- this.effectiveMajorVersion = effectiveMajorVersion;
- }
- public int getEffectiveMinorVersion() {
- return effectiveMinorVersion;
- }
- public void setEffectiveMinorVersion(int effectiveMinorVersion) {
- this.effectiveMinorVersion = effectiveMinorVersion;
- }
-
- public void setLogEffectiveWebXml(boolean logEffectiveWebXml) {
- this.logEffectiveWebXml = logEffectiveWebXml;
- }
-
- public boolean getLogEffectiveWebXml() {
- return logEffectiveWebXml;
- }
- public Authenticator getAuthenticator() {
- if (this instanceof Authenticator)
- return (Authenticator) this;
-
- Pipeline pipeline = getPipeline();
- if (pipeline != null) {
- Valve basic = pipeline.getBasic();
- if ((basic != null) && (basic instanceof Authenticator))
- return (Authenticator) basic;
- Valve valves[] = pipeline.getValves();
- for (int i = 0; i < valves.length; i++) {
- if (valves[i] instanceof Authenticator)
- return (Authenticator) valves[i];
- }
- }
- return null;
- }
-
- public JarScanner getJarScanner() {
- if (jarScanner == null) {
- jarScanner = new StandardJarScanner();
- }
- return jarScanner;
- }
- public void setJarScanner(JarScanner jarScanner) {
- this.jarScanner = jarScanner;
- }
-
- public InstanceManager getInstanceManager() {
- return instanceManager;
- }
- public void setInstanceManager(InstanceManager instanceManager) {
- this.instanceManager = instanceManager;
- }
-
- public String getEncodedPath() {
- return encodedPath;
- }
- @Override
- public void setName( String name ) {
- super.setName( name );
- encodedPath = urlEncoder.encode(name);
- }
- /**
- * Is caching allowed ?
- */
- public boolean isCachingAllowed() {
- return cachingAllowed;
- }
- /**
- * Set caching allowed flag.
- */
- public void setCachingAllowed(boolean cachingAllowed) {
- this.cachingAllowed = cachingAllowed;
- }
- /**
- * Set allow linking.
- */
- public void setAllowLinking(boolean allowLinking) {
- this.allowLinking = allowLinking;
- }
- /**
- * Is linking allowed.
- */
- public boolean isAllowLinking() {
- return allowLinking;
- }
- /**
- * Set cache TTL.
- */
- public void setCacheTTL(int cacheTTL) {
- this.cacheTTL = cacheTTL;
- }
- /**
- * Get cache TTL.
- */
- public int getCacheTTL() {
- return cacheTTL;
- }
- /**
- * Return the maximum size of the cache in KB.
- */
- public int getCacheMaxSize() {
- return cacheMaxSize;
- }
- /**
- * Set the maximum size of the cache in KB.
- */
- public void setCacheMaxSize(int cacheMaxSize) {
- this.cacheMaxSize = cacheMaxSize;
- }
- /**
- * Return the maximum size of objects to be cached in KB.
- */
- public int getCacheObjectMaxSize() {
- return cacheObjectMaxSize;
- }
- /**
- * Set the maximum size of objects to be placed the cache in KB.
- */
- public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
- this.cacheObjectMaxSize = cacheObjectMaxSize;
- }
- /**
- * Return the list of resource aliases.
- */
- public String getAliases() {
- return this.aliases;
- }
- /**
- * Add a URL for a JAR that contains static resources in a
- * META-INF/resources directory that should be included in the static
- * resources for this context.
- */
- public void addResourceJarUrl(URL url) {
- if (webappResources instanceof BaseDirContext) {
- ((BaseDirContext) webappResources).addResourcesJar(url);
- } else {
- log.error(sm.getString("standardContext.noResourceJar", url,
- getPath()));
- }
- }
-
-
- /**
- * Set the current alias configuration. The list of aliases should be of the
- * form "/aliasPath1=docBase1,/aliasPath2=docBase2" where aliasPathN must
- * include a leading '/' and docBaseN must be an absolute path to either a
- * .war file or a directory.
- */
- public void setAliases(String aliases) {
- this.aliases = aliases;
- }
-
-
- /**
- * Add a ServletContainerInitializer instance to this web application.
- *
- * @param sci The instance to add
- * @param classes The classes in which the initializer expressed an
- * interest
- */
- public void addServletContainerInitializer(
- ServletContainerInitializer sci, Set<Class<?>> classes) {
- initializers.put(sci, classes);
- }
-
- /**
- * Return the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- */
- public boolean getDelegate() {
- return (this.delegate);
- }
- /**
- * Set the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- *
- * @param delegate The new flag
- */
- public void setDelegate(boolean delegate) {
- boolean oldDelegate = this.delegate;
- this.delegate = delegate;
- support.firePropertyChange("delegate", oldDelegate,
- this.delegate);
- }
- /**
- * Returns true if the internal naming support is used.
- */
- public boolean isUseNaming() {
- return (useNaming);
- }
- /**
- * Enables or disables naming.
- */
- public void setUseNaming(boolean useNaming) {
- this.useNaming = useNaming;
- }
- /**
- * Returns true if the resources associated with this context are
- * filesystem based.
- */
- public boolean isFilesystemBased() {
- return (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.
- *
- * @exception IllegalStateException if this method is called before
- * this application has started, or after it has been stopped
- */
- public Object[] getApplicationEventListeners() {
- return (applicationEventListenersObjects);
- }
- /**
- * Store the set of initialized application event listener objects,
- * in the order they were specified in the web application deployment
- * descriptor, for this application.
- *
- * @param listeners The set of instantiated listener objects.
- */
- public void setApplicationEventListeners(Object listeners[]) {
- applicationEventListenersObjects = listeners;
- }
- /**
- * Add a listener to the end of the list of initialized application event
- * listeners.
- */
- public void addApplicationEventListener(Object listener) {
- int len = applicationEventListenersObjects.length;
- Object[] newListeners = Arrays.copyOf(applicationEventListenersObjects,
- len + 1);
- newListeners[len] = listener;
- applicationEventListenersObjects = newListeners;
- }
-
-
- /**
- * Return the set of initialized application lifecycle listener objects,
- * in the order they were specified in the web application deployment
- * descriptor, for this application.
- *
- * @exception IllegalStateException if this method is called before
- * this application has started, or after it has been stopped
- */
- public Object[] getApplicationLifecycleListeners() {
- return (applicationLifecycleListenersObjects);
- }
- /**
- * Store the set of initialized application lifecycle listener objects,
- * in the order they were specified in the web application deployment
- * descriptor, for this application.
- *
- * @param listeners The set of instantiated listener objects.
- */
- public void setApplicationLifecycleListeners(Object listeners[]) {
- applicationLifecycleListenersObjects = listeners;
- }
- /**
- * Add a listener to the end of the list of initialized application
- * lifecycle listeners.
- */
- public void addApplicationLifecycleListener(Object listener) {
- int len = applicationLifecycleListenersObjects.length;
- Object[] newListeners = Arrays.copyOf(
- applicationLifecycleListenersObjects, len + 1);
- newListeners[len] = listener;
- applicationLifecycleListenersObjects = newListeners;
- }
-
- /**
- * Return the antiJARLocking flag for this Context.
- */
- public boolean getAntiJARLocking() {
- return (this.antiJARLocking);
- }
- /**
- * Return the antiResourceLocking flag for this Context.
- */
- public boolean getAntiResourceLocking() {
- return (this.antiResourceLocking);
- }
- /**
- * Set the antiJARLocking feature for this Context.
- *
- * @param antiJARLocking The new flag value
- */
- public void setAntiJARLocking(boolean antiJARLocking) {
- boolean oldAntiJARLocking = this.antiJARLocking;
- this.antiJARLocking = antiJARLocking;
- support.firePropertyChange("antiJARLocking",
- oldAntiJARLocking,
- this.antiJARLocking);
- }
- /**
- * Set the antiResourceLocking feature for this Context.
- *
- * @param antiResourceLocking The new flag value
- */
- public void setAntiResourceLocking(boolean antiResourceLocking) {
- boolean oldAntiResourceLocking = this.antiResourceLocking;
- this.antiResourceLocking = antiResourceLocking;
- support.firePropertyChange("antiResourceLocking",
- oldAntiResourceLocking,
- this.antiResourceLocking);
- }
- /**
- * Return the application available flag for this Context.
- */
- public boolean getAvailable() {
- // TODO Remove this method entirely
- return getState().isAvailable();
- }
- /**
- * Return the Locale to character set mapper for this Context.
- */
- public CharsetMapper getCharsetMapper() {
- // Create a mapper the first time it is requested
- if (this.charsetMapper == null) {
- try {
- Class<?> clazz = Class.forName(charsetMapperClass);
- this.charsetMapper = (CharsetMapper) clazz.newInstance();
- } catch (Throwable t) {
- this.charsetMapper = new CharsetMapper();
- }
- }
- return (this.charsetMapper);
- }
- /**
- * Set the Locale to character set mapper for this Context.
- *
- * @param mapper The new mapper
- */
- public void setCharsetMapper(CharsetMapper mapper) {
- CharsetMapper oldCharsetMapper = this.charsetMapper;
- this.charsetMapper = mapper;
- if( mapper != null )
- this.charsetMapperClass= mapper.getClass().getName();
- support.firePropertyChange("charsetMapper", oldCharsetMapper,
- this.charsetMapper);
- }
- /**
- * Return the URL of the XML descriptor for this context.
- */
- public URL getConfigFile() {
- return (this.configFile);
- }
- /**
- * Set the URL of the XML descriptor for this context.
- *
- * @param configFile The URL of the XML descriptor for this context.
- */
- public void setConfigFile(URL configFile) {
- this.configFile = configFile;
- }
- /**
- * Return the "correctly configured" flag for this Context.
- */
- public boolean getConfigured() {
- return (this.configured);
- }
- /**
- * 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.
- *
- * @param configured The new correctly configured flag
- */
- public void setConfigured(boolean configured) {
- boolean oldConfigured = this.configured;
- this.configured = configured;
- support.firePropertyChange("configured",
- oldConfigured,
- this.configured);
- }
- /**
- * Return the "use cookies for session ids" flag.
- */
- public boolean getCookies() {
- return (this.cookies);
- }
- /**
- * Set the "use cookies for session ids" flag.
- *
- * @param cookies The new flag
- */
- public void setCookies(boolean cookies) {
- boolean oldCookies = this.cookies;
- this.cookies = cookies;
- support.firePropertyChange("cookies",
- oldCookies,
- this.cookies);
- }
-
-
- /**
- * Gets the name to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @return The value of the default session cookie name or null if not
- * specified
- */
- public String getSessionCookieName() {
- return sessionCookieName;
- }
-
-
- /**
- * Sets the name to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @param sessionCookieName The name to use
- */
- public void setSessionCookieName(String sessionCookieName) {
- String oldSessionCookieName = this.sessionCookieName;
- this.sessionCookieName = sessionCookieName;
- support.firePropertyChange("sessionCookieName",
- oldSessionCookieName, sessionCookieName);
- }
-
- /**
- * Gets the value of the use HttpOnly cookies for session cookies flag.
- *
- * @return <code>true</code> if the HttpOnly flag should be set on session
- * cookies
- */
- public boolean getUseHttpOnly() {
- return useHttpOnly;
- }
- /**
- * Sets the use HttpOnly cookies for session cookies flag.
- *
- * @param useHttpOnly Set to <code>true</code> to use HttpOnly cookies
- * for session cookies
- */
- public void setUseHttpOnly(boolean useHttpOnly) {
- boolean oldUseHttpOnly = this.useHttpOnly;
- this.useHttpOnly = useHttpOnly;
- support.firePropertyChange("useHttpOnly",
- oldUseHttpOnly,
- this.useHttpOnly);
- }
-
-
- /**
- * Gets the domain to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @return The value of the default session cookie domain or null if not
- * specified
- */
- public String getSessionCookieDomain() {
- return sessionCookieDomain;
- }
-
-
- /**
- * Sets the domain to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @param sessionCookieDomain The domain to use
- */
- public void setSessionCookieDomain(String sessionCookieDomain) {
- String oldSessionCookieDomain = this.sessionCookieDomain;
- this.sessionCookieDomain = sessionCookieDomain;
- support.firePropertyChange("sessionCookieDomain",
- oldSessionCookieDomain, sessionCookieDomain);
- }
-
- /**
- * Gets the path to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @return The value of the default session cookie path or null if not
- * specified
- */
- public String getSessionCookiePath() {
- return sessionCookiePath;
- }
-
-
- /**
- * Sets the path to use for session cookies. Overrides any setting that
- * may be specified by the application.
- *
- * @param sessionCookiePath The path to use
- */
- public void setSessionCookiePath(String sessionCookiePath) {
- String oldSessionCookiePath = this.sessionCookiePath;
- this.sessionCookiePath = sessionCookiePath;
- support.firePropertyChange("sessionCookiePath",
- oldSessionCookiePath, sessionCookiePath);
- }
-
- /**
- * Return the "allow crossing servlet contexts" flag.
- */
- public boolean getCrossContext() {
- return (this.crossContext);
- }
- /**
- * Set the "allow crossing servlet contexts" flag.
- *
- * @param crossContext The new cross contexts flag
- */
- public void setCrossContext(boolean crossContext) {
- boolean oldCrossContext = this.crossContext;
- this.crossContext = crossContext;
- support.firePropertyChange("crossContext",
- oldCrossContext,
- this.crossContext);
- }
- public String getDefaultContextXml() {
- return defaultContextXml;
- }
- /**
- * Set the location of the default context xml that will be used.
- * If not absolute, it'll be made relative to the engine's base dir
- * ( which defaults to catalina.base system property ).
- *
- * @param defaultContextXml The default web xml
- */
- public void setDefaultContextXml(String defaultContextXml) {
- this.defaultContextXml = defaultContextXml;
- }
- public String getDefaultWebXml() {
- return defaultWebXml;
- }
- /**
- * Set the location of the default web xml that will be used.
- * If not absolute, it'll be made relative to the engine's base dir
- * ( which defaults to catalina.base system property ).
- *
- * @param defaultWebXml The default web xml
- */
- public void setDefaultWebXml(String defaultWebXml) {
- this.defaultWebXml = defaultWebXml;
- }
- /**
- * Gets the time (in milliseconds) it took to start this context.
- *
- * @return Time (in milliseconds) it took to start this context.
- */
- public long getStartupTime() {
- return startupTime;
- }
- public void setStartupTime(long startupTime) {
- this.startupTime = startupTime;
- }
- public long getTldScanTime() {
- return tldScanTime;
- }
- public void setTldScanTime(long tldScanTime) {
- this.tldScanTime = tldScanTime;
- }
- /**
- * Return the display name of this web application.
- */
- public String getDisplayName() {
- return (this.displayName);
- }
- /**
- * Return the alternate Deployment Descriptor name.
- */
- public String getAltDDName(){
- return altDDName;
- }
- /**
- * Set an alternate Deployment Descriptor name.
- */
- public void setAltDDName(String altDDName) {
- this.altDDName = altDDName;
- if (context != null) {
- context.setAttribute(Globals.ALT_DD_ATTR,altDDName);
- }
- }
- /**
- * Return the compiler classpath.
- */
- public String getCompilerClasspath(){
- return compilerClasspath;
- }
- /**
- * Set the compiler classpath.
- */
- public void setCompilerClasspath(String compilerClasspath) {
- this.compilerClasspath = compilerClasspath;
- }
- /**
- * Set the display name of this web application.
- *
- * @param displayName The new display name
- */
- public void setDisplayName(String displayName) {
- String oldDisplayName = this.displayName;
- this.displayName = displayName;
- support.firePropertyChange("displayName", oldDisplayName,
- this.displayName);
- }
- /**
- * Return the distributable flag for this web application.
- */
- public boolean getDistributable() {
- return (this.distributable);
- }
- /**
- * Set the distributable flag for this web application.
- *
- * @param distributable The new distributable flag
- */
- public void setDistributable(boolean distributable) {
- boolean oldDistributable = this.distributable;
- this.distributable = distributable;
- support.firePropertyChange("distributable",
- oldDistributable,
- this.distributable);
- // Bugzilla 32866
- if(getManager() != null) {
- if(log.isDebugEnabled()) {
- log.debug("Propagating distributable=" + distributable
- + " to manager");
- }
- 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.docBase);
- }
- /**
- * Set the document root for this Context. This can be an absolute
- * pathname, a relative pathname, or a URL.
- *
- * @param docBase The new document root
- */
- public void setDocBase(String docBase) {
- this.docBase = docBase;
- }
- /**
- * Return descriptive information about this Container implementation and
- * the corresponding version number, in the format
- * <code><description>/<version></code>.
- */
- @Override
- public String getInfo() {
- return (info);
- }
- public String getJ2EEApplication() {
- return j2EEApplication;
- }
- public void setJ2EEApplication(String j2EEApplication) {
- this.j2EEApplication = j2EEApplication;
- }
- public String getJ2EEServer() {
- return j2EEServer;
- }
- public void setJ2EEServer(String j2EEServer) {
- this.j2EEServer = j2EEServer;
- }
- /**
- * Set the Loader with which this Context is associated.
- *
- * @param loader The newly associated loader
- */
- @Override
- public synchronized void setLoader(Loader loader) {
- super.setLoader(loader);
- }
- /**
- * Return the boolean on the annotations parsing.
- */
- public boolean getIgnoreAnnotations() {
- return this.ignoreAnnotations;
- }
-
-
- /**
- * Set the boolean on the annotations parsing for this web
- * application.
- *
- * @param ignoreAnnotations The boolean on the annotations parsing
- */
- public void setIgnoreAnnotations(boolean ignoreAnnotations) {
- boolean oldIgnoreAnnotations = this.ignoreAnnotations;
- this.ignoreAnnotations = ignoreAnnotations;
- support.firePropertyChange("ignoreAnnotations", oldIgnoreAnnotations,
- this.ignoreAnnotations);
- }
-
-
- /**
- * Return the login configuration descriptor for this web application.
- */
- public LoginConfig getLoginConfig() {
- return (this.loginConfig);
- }
- /**
- * Set the login configuration descriptor for this web application.
- *
- * @param config The new login configuration
- */
- public void setLoginConfig(LoginConfig config) {
- // Validate the incoming property value
- if (config == null)
- throw new IllegalArgumentException
- (sm.getString("standardContext.loginConfig.required"));
- String loginPage = config.getLoginPage();
- if ((loginPage != null) && !loginPage.startsWith("/")) {
- if (isServlet22()) {
- if(log.isDebugEnabled())
- log.debug(sm.getString("standardContext.loginConfig.loginWarning",
- loginPage));
- config.setLoginPage("/" + loginPage);
- } else {
- throw new IllegalArgumentException
- (sm.getString("standardContext.loginConfig.loginPage",
- loginPage));
- }
- }
- String errorPage = config.getErrorPage();
- if ((errorPage != null) && !errorPage.startsWith("/")) {
- if (isServlet22()) {
- if(log.isDebugEnabled())
- log.debug(sm.getString("standardContext.loginConfig.errorWarning",
- errorPage));
- config.setErrorPage("/" + errorPage);
- } else {
- throw new IllegalArgumentException
- (sm.getString("standardContext.loginConfig.errorPage",
- errorPage));
- }
- }
- // Process the property setting change
- LoginConfig oldLoginConfig = this.loginConfig;
- this.loginConfig = config;
- support.firePropertyChange("loginConfig",
- oldLoginConfig, this.loginConfig);
- }
- /**
- * Get the mapper associated with the context.
- */
- public org.apache.tomcat.util.http.mapper.Mapper getMapper() {
- return (mapper);
- }
- /**
- * Return the naming resources associated with this web application.
- */
- public NamingResources getNamingResources() {
- if (namingResources == null) {
- setNamingResources(new NamingResources());
- }
- return (namingResources);
- }
- /**
- * Set the naming resources for this web application.
- *
- * @param namingResources The new naming resources
- */
- public void setNamingResources(NamingResources namingResources) {
- // Process the property setting change
- NamingResources oldNamingResources = this.namingResources;
- this.namingResources = namingResources;
- namingResources.setContainer(this);
- support.firePropertyChange("namingResources",
- oldNamingResources, this.namingResources);
-
- unregister(onameNamingResources);
- onameNamingResources = register(namingResources,
- "type=NamingResources," + getObjectKeyPropertiesNameOnly());
- }
- /**
- * Return the context path for this Context.
- */
- public String getPath() {
- return (getName());
- }
-
- /**
- * Set the context path for this Context.
- * <p>
- * <b>IMPLEMENTATION NOTE</b>: The context path is used as the "name" of
- * a Context, because it must be unique.
- *
- * @param path The new context path
- */
- public void setPath(String path) {
- // XXX Use host in name
- setName(path);
- }
- /**
- * Return the public identifier of the deployment descriptor DTD that is
- * currently being parsed.
- */
- public String getPublicId() {
- return (this.publicId);
- }
- /**
- * Set the public identifier of the deployment descriptor DTD that is
- * currently being parsed.
- *
- * @param publicId The public identifier
- */
- public void setPublicId(String publicId) {
- if (log.isDebugEnabled())
- log.debug("Setting deployment descriptor public ID to '" +
- publicId + "'");
- String oldPublicId = this.publicId;
- this.publicId = publicId;
- support.firePropertyChange("publicId", oldPublicId, publicId);
- }
- /**
- * Return the reloadable flag for this web application.
- */
- public boolean getReloadable() {
- return (this.reloadable);
- }
- /**
- * Return the default context override flag for this web application.
- */
- public boolean getOverride() {
- return (this.override);
- }
- /**
- * Return the original document root for this Context. This can be an absolute
- * pathname, a relative pathname, or a URL.
- * Is only set as deployment has change docRoot!
- */
- public String getOriginalDocBase() {
- return (this.originalDocBase);
- }
- /**
- * Set the original document root for this Context. This can be an absolute
- * pathname, a relative pathname, or a URL.
- *
- * @param docBase The original document root
- */
- public void setO