📄 standarddefaultcontext.java
字号:
/*
* $Header: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardDefaultContext.java,v 1.11 2004/01/26 20:19:10 remm Exp $
* $Revision: 1.11 $
* $Date: 2004/01/26 20:19:10 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.core;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Vector;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.naming.directory.DirContext;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.DefaultContext;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Loader;
import org.apache.catalina.Manager;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.deploy.ContextEjb;
import org.apache.catalina.deploy.ContextEnvironment;
import org.apache.catalina.deploy.ContextResource;
import org.apache.catalina.deploy.ContextResourceLink;
import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.deploy.ResourceParams;
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.mbeans.MBeanUtils;
import org.apache.catalina.util.StringManager;
import org.apache.commons.modeler.ManagedBean;
import org.apache.commons.modeler.Registry;
import org.apache.naming.ContextAccessController;
/**
* Used to store the default configuration a Host will use
* when creating a Context. A Context configured in server.xml
* can override these defaults by setting the Context attribute
* <CODE>override="true"</CODE>.
*
* @author Glenn Nielsen
* @version $Revision: 1.11 $ $Date: 2004/01/26 20:19:10 $
*/
public class StandardDefaultContext
implements DefaultContext, LifecycleListener, MBeanRegistration {
// ----------------------------------------------------------- Constructors
/**
* Create the DefaultContext
*/
public StandardDefaultContext() {
namingResources.setContainer(this);
}
// ----------------------------------------------------- Instance Variables
/**
* Contexts we are currently associated with.
*/
private Hashtable contexts = new Hashtable();
/**
* 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];
/**
* The set of application parameters defined for this application.
*/
private ApplicationParameter applicationParameters[] =
new ApplicationParameter[0];
/**
* 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 = true;
/**
* The descriptive information string for this implementation.
*/
private static final String info =
"org.apache.catalina.core.DefaultContext/1.0";
/**
* 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];
/**
* The Java class name of the default Mapper class for this Container.
*/
private String mapperClass =
"org.apache.catalina.core.StandardContextMapper";
/**
* The associated naming resources.
*/
private NamingResources namingResources = new NamingResources();
/**
* The context initialization parameters for this web application,
* keyed by name.
*/
private HashMap parameters = new HashMap();
/**
* The reloadable flag for this web application.
*/
private boolean reloadable = false;
/**
* The swallowOutput flag for this web application.
*/
private boolean swallowOutput = false;
/**
* 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];
/**
* 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];
/**
* Java class name of the Wrapper class implementation we use.
*/
private String wrapperClass = "org.apache.catalina.core.StandardWrapper";
/**
* JNDI use flag.
*/
private boolean useNaming = true;
/**
* The resources DirContext object with which this Container is
* associated.
*
*/
DirContext dirContext = null;
/**
* The human-readable name of this Container.
*/
protected String name = "defaultContext";
/**
* The parent Container to which this Container is a child.
*/
protected Container parent = null;
/**
* The Context LifecycleListener's
*/
protected Vector lifecycle = new Vector();
/**
* The Loader implementation with which this Container is associated.
*/
protected Loader loader = null;
/**
* The Manager implementation with which this Container is associated.
*/
protected Manager manager = null;
/**
* Case sensitivity.
*/
protected boolean caseSensitive = true;
/**
* Allow linking.
*/
protected boolean allowLinking = false;
/**
* Cache max size in KB.
*/
protected int cacheMaxSize = 10240; // 10 MB
/**
* Cache TTL in ms.
*/
protected int cacheTTL = 5000;
/**
* CachingAllowed.
*/
protected boolean cachingAllowed = true;
/**
* Frequency of manager checks.
*/
protected int managerChecksFrequency = 6;
/**
* The string manager for this package.
*/
protected static StringManager sm =
StringManager.getManager(Constants.Package);
/**
* The property change support for this component.
*/
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
// ----------------------------------------------------- Context Properties
/**
* Set case sensitivity.
*/
public void setCaseSensitive(boolean caseSensitive) {
this.caseSensitive = caseSensitive;
}
/**
* Is case sensitive ?
*/
public boolean isCaseSensitive() {
return caseSensitive;
}
/**
* 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;
}
/**
* Set cachingAllowed.
*/
public void setCachingAllowed(boolean cachingAllowed) {
this.cachingAllowed = cachingAllowed;
}
/**
* Is cachingAllowed ?
*/
public boolean isCachingAllowed() {
return cachingAllowed;
}
/**
* Set the manager checks frequency.
*/
public void setManagerChecksFrequency(int managerChecksFrequency) {
this.managerChecksFrequency = managerChecksFrequency;
}
/**
* Get manager checks frquency.
*/
public int getManagerChecksFrequency() {
return managerChecksFrequency;
}
/**
* 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;
}
/**
* 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;
}
/**
* Return the "allow crossing servlet contexts" flag.
*/
public boolean getCrossContext() {
return (this.crossContext);
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -