FileDocCategorySizeDatePackage
StandardDefaultContext.javaAPI DocGlassfish v2 API53421Fri May 04 22:31:54 BST 2007org.apache.catalina.core

StandardDefaultContext

public class StandardDefaultContext extends Object implements org.apache.catalina.LifecycleListener, org.apache.catalina.DefaultContext, MBeanRegistration
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 override="true".
author
Glenn Nielsen
version
$Revision: 1.5 $ $Date: 2007/05/05 05:31:54 $

Fields Summary
private Hashtable
contexts
Contexts we are currently associated with.
private String[]
applicationListeners
The set of application listener class names configured for this application, in the order they were encountered in the web.xml file.
private org.apache.catalina.deploy.ApplicationParameter[]
applicationParameters
The set of application parameters defined for this application.
private boolean
cookies
Should we attempt to use cookies for session id communication?
private boolean
crossContext
Should we allow the ServletContext.getContext() method to access the context of other web applications in this server?
private static final String
info
The descriptive information string for this implementation.
private String[]
instanceListeners
The set of classnames of InstanceListeners that will be added to each newly created Wrapper by createWrapper().
private String
mapperClass
The Java class name of the default Mapper class for this Container.
private org.apache.catalina.deploy.NamingResources
namingResources
The associated naming resources.
private HashMap
parameters
The context initialization parameters for this web application, keyed by name.
private boolean
reloadable
The reloadable flag for this web application.
private boolean
swallowOutput
The swallowOutput flag for this web application.
private String[]
wrapperLifecycles
The set of classnames of LifecycleListeners that will be added to each newly created Wrapper by createWrapper().
private String[]
wrapperListeners
The set of classnames of ContainerListeners that will be added to each newly created Wrapper by createWrapper().
private String
wrapperClass
Java class name of the Wrapper class implementation we use.
private boolean
useNaming
JNDI use flag.
DirContext
dirContext
The resources DirContext object with which this Container is associated.
protected String
name
The human-readable name of this Container.
protected org.apache.catalina.Container
parent
The parent Container to which this Container is a child.
protected Vector
lifecycle
The Context LifecycleListener's
protected org.apache.catalina.Loader
loader
The Loader implementation with which this Container is associated.
protected org.apache.catalina.Manager
manager
The Manager implementation with which this Container is associated.
protected boolean
caseSensitive
Case sensitivity.
protected boolean
allowLinking
Allow linking.
protected int
cacheMaxSize
Cache max size in KB.
protected int
cacheTTL
Cache TTL in ms.
protected boolean
cachingAllowed
CachingAllowed.
protected int
managerChecksFrequency
Frequency of manager checks.
protected static final org.apache.catalina.util.StringManager
sm
The string manager for this package.
protected PropertyChangeSupport
support
The property change support for this component.
protected String
type
protected String
domain
protected String
suffix
protected ObjectName
oname
protected MBeanServer
mserver
Constructors Summary
public StandardDefaultContext()
Create the DefaultContext


        namingResources.setContainer(this);

    
Methods Summary
public voidaddApplicationListener(java.lang.String listener)
Add a new Listener class name to the set of Listeners configured for this application.

param
listener Java class name of a listener class


        synchronized (applicationListeners) {
            String results[] =new String[applicationListeners.length + 1];
            for (int i = 0; i < applicationListeners.length; i++)
                results[i] = applicationListeners[i];
            results[applicationListeners.length] = listener;
            applicationListeners = results;
        }

    
public voidaddApplicationParameter(org.apache.catalina.deploy.ApplicationParameter parameter)
Add a new application parameter for this application.

param
parameter The new application parameter


        synchronized (applicationParameters) {
            ApplicationParameter results[] =
                new ApplicationParameter[applicationParameters.length + 1];
            System.arraycopy(applicationParameters, 0, results, 0,
                             applicationParameters.length);
            results[applicationParameters.length] = parameter;
            applicationParameters = results;
        }

    
public voidaddEjb(org.apache.catalina.deploy.ContextEjb ejb)
Add an EJB resource reference for this web application.

param
ejb New EJB resource reference


        namingResources.addEjb(ejb);

    
public voidaddEnvironment(org.apache.catalina.deploy.ContextEnvironment environment)
Add an environment entry for this web application.

param
environment New environment entry


        namingResources.addEnvironment(environment);

    
public java.lang.StringaddEnvironment(java.lang.String envName, java.lang.String type)
Add an environment entry for this web application.

param
envName New environment entry name


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextEnvironment env = nresources.findEnvironment(envName);
        if (env != null) {
            throw new IllegalArgumentException
                ("Invalid environment name - already exists '" + envName + "'");
        }
        env = new ContextEnvironment();
        env.setName(envName);
        env.setType(type);
        nresources.addEnvironment(env);

        // Return the corresponding MBean name
        ManagedBean managed = Registry.getRegistry().findManagedBean("ContextEnvironment");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), env);
        return (oname.toString());

    
public voidaddInstanceListener(java.lang.String listener)
Add the classname of an InstanceListener to be added to each Wrapper appended to this Context.

param
listener Java class name of an InstanceListener class


        synchronized (instanceListeners) {
            String results[] =new String[instanceListeners.length + 1];
            for (int i = 0; i < instanceListeners.length; i++)
                results[i] = instanceListeners[i];
            results[instanceListeners.length] = listener;
            instanceListeners = results;
        }

    
public voidaddLifecycleListener(org.apache.catalina.LifecycleListener listener)
Add a lifecycle event listener to this component.

param
listener The listener to add

        lifecycle.add(listener);
    
public voidaddParameter(java.lang.String name, java.lang.String value)
Add a new context initialization parameter, replacing any existing value for the specified name.

param
name Name of the new parameter
param
value Value of the new parameter
exception
IllegalArgumentException if the name or value is missing, or if this context initialization parameter has already been registered

        // Validate the proposed context initialization parameter
        if ((name == null) || (value == null))
            throw new IllegalArgumentException
                (sm.getString("standardContext.parameter.required"));
        if (parameters.get(name) != null)
            throw new IllegalArgumentException
                (sm.getString("standardContext.parameter.duplicate", name));

        // Add this parameter to our defined set
        synchronized (parameters) {
            parameters.put(name, value);
        }

    
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component.

param
listener The listener to add


        support.addPropertyChangeListener(listener);

    
public voidaddResource(org.apache.catalina.deploy.ContextResource resource)
Add a resource reference for this web application.

param
resource New resource reference


        namingResources.addResource(resource);

    
public java.lang.StringaddResource(java.lang.String resourceName, java.lang.String type)
Add a resource reference for this web application.

param
resourceName New resource reference name


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextResource resource = nresources.findResource(resourceName);
        if (resource != null) {
            throw new IllegalArgumentException
                ("Invalid resource name - already exists'" + resourceName + "'");
        }
        resource = new ContextResource();
        resource.setName(resourceName);
        resource.setType(type);
        nresources.addResource(resource);

        // Return the corresponding MBean name
        ManagedBean managed = Registry.getRegistry().findManagedBean("ContextResource");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), resource);

        return (oname.toString());
    
public voidaddResourceEnvRef(java.lang.String name, java.lang.String type)
Add a resource environment reference for this web application.

param
name The resource environment reference name
param
type The resource environment reference type


        namingResources.addResourceEnvRef(name, type);

    
public voidaddResourceLink(org.apache.catalina.deploy.ContextResourceLink resourceLink)
Add a resource link for this web application.

param
resource New resource link


        namingResources.addResourceLink(resourceLink);

    
public java.lang.StringaddResourceLink(java.lang.String resourceLinkName, java.lang.String global, java.lang.String name, java.lang.String type)
Add a resource link for this web application.

param
resourceLinkName New resource link name


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextResourceLink resourceLink =
                                nresources.findResourceLink(resourceLinkName);
        if (resourceLink != null) {
            throw new IllegalArgumentException
                ("Invalid resource link name - already exists'" +
                                                        resourceLinkName + "'");
        }
        resourceLink = new ContextResourceLink();
        resourceLink.setGlobal(global);
        resourceLink.setName(resourceLinkName);
        resourceLink.setType(type);
        nresources.addResourceLink(resourceLink);

        // Return the corresponding MBean name
        ManagedBean managed = Registry.getRegistry().findManagedBean("ContextResourceLink");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
        return (oname.toString());
    
public voidaddResourceParams(org.apache.catalina.deploy.ResourceParams resourceParameters)
Add resource parameters for this web application.

param
resourceParameters New resource parameters


        namingResources.addResourceParams(resourceParameters);

    
public voidaddWrapperLifecycle(java.lang.String listener)
Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.

param
listener Java class name of a LifecycleListener class


        synchronized (wrapperLifecycles) {
            String results[] =new String[wrapperLifecycles.length + 1];
            for (int i = 0; i < wrapperLifecycles.length; i++)
                results[i] = wrapperLifecycles[i];
            results[wrapperLifecycles.length] = listener;
            wrapperLifecycles = results;
        }

    
public voidaddWrapperListener(java.lang.String listener)
Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.

param
listener Java class name of a ContainerListener class


        synchronized (wrapperListeners) {
            String results[] =new String[wrapperListeners.length + 1];
            for (int i = 0; i < wrapperListeners.length; i++)
                results[i] = wrapperListeners[i];
            results[wrapperListeners.length] = listener;
            wrapperListeners = results;
        }

    
public java.lang.String[]findApplicationListeners()
Return the set of application listener class names configured for this application.


        return (applicationListeners);

    
public org.apache.catalina.deploy.ApplicationParameter[]findApplicationParameters()
Return the set of application parameters for this application.


        return (applicationParameters);

    
public org.apache.catalina.deploy.ContextEjbfindEjb(java.lang.String name)
Return the EJB resource reference with the specified name, if any; otherwise, return null.

param
name Name of the desired EJB resource reference


        return namingResources.findEjb(name);

    
public org.apache.catalina.deploy.ContextEjb[]findEjbs()
Return the defined EJB resource references for this application. If there are none, a zero-length array is returned.


        return namingResources.findEjbs();

    
public org.apache.catalina.deploy.ContextEnvironmentfindEnvironment(java.lang.String name)
Return the environment entry with the specified name, if any; otherwise, return null.

param
name Name of the desired environment entry


        return namingResources.findEnvironment(name);

    
public org.apache.catalina.deploy.ContextEnvironment[]findEnvironments()
Return the set of defined environment entries for this web application. If none have been defined, a zero-length array is returned.


        return namingResources.findEnvironments();

    
public java.lang.String[]findInstanceListeners()
Return the set of InstanceListener classes that will be added to newly created Wrappers automatically.


        return (instanceListeners);

    
public java.lang.StringfindParameter(java.lang.String name)
Return the value for the specified context initialization parameter name, if any; otherwise return null.

param
name Name of the parameter to return


        synchronized (parameters) {
            return ((String) parameters.get(name));
        }

    
public java.lang.String[]findParameters()
Return the names of all defined context initialization parameters for this Context. If no parameters are defined, a zero-length array is returned.


        synchronized (parameters) {
            String results[] = new String[parameters.size()];
            return ((String[]) parameters.keySet().toArray(results));
        }

    
public org.apache.catalina.deploy.ContextResourcefindResource(java.lang.String name)
Return the resource reference with the specified name, if any; otherwise return null.

param
name Name of the desired resource reference


        return namingResources.findResource(name);

    
public java.lang.StringfindResourceEnvRef(java.lang.String name)
Return the resource environment reference type for the specified name, if any; otherwise return null.

param
name Name of the desired resource environment reference


        return namingResources.findResourceEnvRef(name);

    
public java.lang.String[]findResourceEnvRefs()
Return the set of resource environment reference names for this web application. If none have been specified, a zero-length array is returned.


        return namingResources.findResourceEnvRefs();

    
public org.apache.catalina.deploy.ContextResourceLinkfindResourceLink(java.lang.String name)
Return the resource link with the specified name, if any; otherwise return null.

param
name Name of the desired resource link


        return namingResources.findResourceLink(name);

    
public org.apache.catalina.deploy.ContextResourceLink[]findResourceLinks()
Return the defined resource links for this application. If none have been defined, a zero-length array is returned.


        return namingResources.findResourceLinks();

    
public org.apache.catalina.deploy.ResourceParams[]findResourceParams()
Return the set of defined resource parameters for this web application. If none have been defined, a zero-length array is returned.


        return namingResources.findResourceParams();

    
public org.apache.catalina.deploy.ContextResource[]findResources()
Return the defined resource references for this application. If none have been defined, a zero-length array is returned.


        return namingResources.findResources();

    
public java.lang.String[]findWrapperLifecycles()
Return the set of LifecycleListener classes that will be added to newly created Wrappers automatically.


        return (wrapperLifecycles);

    
public java.lang.String[]findWrapperListeners()
Return the set of ContainerListener classes that will be added to newly created Wrappers automatically.


        return (wrapperListeners);

    
public intgetCacheMaxSize()
Return the maximum size of the cache in KB.

        return cacheMaxSize;
    
public intgetCacheTTL()
Get cache TTL.

        return cacheTTL;
    
public booleangetCookies()
Return the "use cookies for session ids" flag.


        return (this.cookies);

    
public booleangetCrossContext()
Return the "allow crossing servlet contexts" flag.


        return (this.crossContext);

    
public java.lang.StringgetDomain()

        return domain;
    
public java.lang.String[]getEnvironments()
Return the MBean Names of the set of defined environment entries for this web application

        ContextEnvironment[] envs = getNamingResources().findEnvironments();
        ArrayList results = new ArrayList();
        for (int i = 0; i < envs.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(this.getDomain(), envs[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for environment " + envs[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public java.lang.StringgetInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.


        return (info);

    
protected java.lang.StringgetJSR77Suffix()

        return suffix;
    
public org.apache.catalina.LoadergetLoader()
Return the Loader with which this Container is associated. If there is no associated Loader return null.


        return loader;

    
public org.apache.catalina.ManagergetManager()
Return the Manager with which this Container is associated. If there is no associated Manager return null.


        return manager;

    
public intgetManagerChecksFrequency()
Get manager checks frquency.

        return managerChecksFrequency;
    
public java.lang.StringgetName()
The name of this DefaultContext

        return (this.name);
    
public org.apache.catalina.deploy.NamingResourcesgetNamingResources()
Return the naming resources associated with this web application.


        return (this.namingResources);

    
public javax.management.ObjectNamegetObjectName()

        return oname;
    
public org.apache.catalina.ContainergetParent()
Return the Container for which this Container is a child, if there is one. If there is no defined parent, return null.


        return (parent);

    
public booleangetReloadable()
Return the reloadable flag for this web application.


        return (this.reloadable);

    
public java.lang.String[]getResourceLinks()
Return the MBean Names of all the defined resource links for this application


        ContextResourceLink[] links = getNamingResources().findResourceLinks();
        ArrayList results = new ArrayList();
        for (int i = 0; i < links.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(getDomain(), links[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for resource " + links[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public java.lang.String[]getResourceNames()
Return the MBean Names of all the defined resource references for this application. XXX This changed - due to conflict


        ContextResource[] resources = getNamingResources().findResources();
        ArrayList results = new ArrayList();
        for (int i = 0; i < resources.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(getDomain(), resources[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for resource " + resources[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public javax.naming.directory.DirContextgetResources()
Get the resources DirContext object with which this Container is associated.

param
resources The new associated DirContext


        return this.dirContext;

    
public booleangetSwallowOutput()
Return the swallowOutput flag for this web application.


        return (this.swallowOutput);

    
public java.lang.StringgetType()

        return type;
    
public java.lang.StringgetWrapperClass()
Return the Java class name of the Wrapper implementation used for servlets registered in this Context.


        return (this.wrapperClass);

    
public voidimportDefaultContext(org.apache.catalina.Context context)
Import the configuration from the DefaultContext into current Context.

param
context current web application context


        context.setCookies(getCookies());
        context.setCrossContext(getCrossContext());
        context.setReloadable(getReloadable());

        String [] listeners = findApplicationListeners();
        for( int i = 0; i < listeners.length; i++ ) {
            context.addApplicationListener(listeners[i]);
        }
        listeners = findInstanceListeners();
        for( int i = 0; i < listeners.length; i++ ) {
            context.addInstanceListener(listeners[i]);
        }
        String [] wrapper = findWrapperListeners();
        for( int i = 0; i < wrapper.length; i++ ) {
            context.addWrapperListener(wrapper[i]);
        }
        wrapper = findWrapperLifecycles();
        for( int i = 0; i < wrapper.length; i++ ) {
            context.addWrapperLifecycle(wrapper[i]);
        }
        String [] parameters = findParameters();
        for( int i = 0; i < parameters.length; i++ ) {
            context.addParameter(parameters[i],findParameter(parameters[i]));
        }
        ApplicationParameter [] appParam = findApplicationParameters();
        for( int i = 0; i < appParam.length; i++ ) {
            context.addApplicationParameter(appParam[i]);
        }

        if (!(context instanceof StandardContext)) {
            ContextEjb [] contextEjb = findEjbs();
            for( int i = 0; i < contextEjb.length; i++ ) {
                context.addEjb(contextEjb[i]);
            }
            ContextEnvironment [] contextEnv = findEnvironments();
            for( int i = 0; i < contextEnv.length; i++ ) {
                context.addEnvironment(contextEnv[i]);
            }
            /*
            if (context instanceof StandardContext) {
                ResourceParams [] resourceParams = findResourceParams();
                for( int i = 0; i < resourceParams.length; i++ ) {
                    ((StandardContext)context).addResourceParams
                        (resourceParams[i]);
                }
            }
            */
            ContextResource [] resources = findResources();
            for( int i = 0; i < resources.length; i++ ) {
                context.addResource(resources[i]);
            }
            ContextResourceLink [] resourceLinks = findResourceLinks();
            for( int i = 0; i < resourceLinks.length; i++ ) {
                context.addResourceLink(resourceLinks[i]);
            }
            String [] envRefs = findResourceEnvRefs();
            for( int i = 0; i < envRefs.length; i++ ) {
                context.addResourceEnvRef
                    (envRefs[i],findResourceEnvRef(envRefs[i]));
            }
        }

    
public voidinstallDefaultContext(org.apache.catalina.Context context)
Install the StandardContext portion of the DefaultContext configuration into current Context.

param
context current web application context

  
        if (context instanceof StandardContext) {
            ((StandardContext)context).setUseNaming(isUseNaming());
            ((StandardContext)context).setSwallowOutput(getSwallowOutput());
            ((StandardContext)context).setCachingAllowed(isCachingAllowed());
            ((StandardContext)context).setCacheTTL(getCacheTTL());
            ((StandardContext)context).setCacheMaxSize(getCacheMaxSize());
            ((StandardContext)context).setAllowLinking(isAllowLinking());
            ((StandardContext)context).setCaseSensitive(isCaseSensitive());
            ((StandardContext)context).setManagerChecksFrequency
                (getManagerChecksFrequency());
            if (!contexts.containsKey(context)) {
                ((StandardContext) context).addLifecycleListener(this);
            }
            Enumeration lifecycleListeners = lifecycle.elements();
            while (lifecycleListeners.hasMoreElements()) {
                ((StandardContext)context).addLifecycleListener(
                    (LifecycleListener)lifecycleListeners.nextElement());
              }
        }

        if (!context.getPrivileged() && loader != null) {
            ClassLoader parentClassLoader = context.getParent().getParentClassLoader();
            Class clazz = loader.getClass();
            Class types[] = { ClassLoader.class };
            Object args[] = { parentClassLoader };
            try {
                Constructor constructor = clazz.getDeclaredConstructor(types);
                Loader context_loader = (Loader) constructor.newInstance(args);
                context_loader.setDelegate(loader.getDelegate());
                context_loader.setReloadable(loader.getReloadable());
                if (loader instanceof WebappLoader) {
                    ((WebappLoader)context_loader).setDebug
                        (((WebappLoader)loader).getDebug());
                    ((WebappLoader)context_loader).setLoaderClass
                        (((WebappLoader)loader).getLoaderClass());
                }
                context.setLoader(context_loader);
            } catch(Exception e) {
                IllegalArgumentException iae = new IllegalArgumentException
                   ("DefaultContext custom Loader install failed");
                iae.initCause(e);
                throw iae;
            }
        }
    
public booleanisAllowLinking()
Is linking allowed.

        return allowLinking;
    
public booleanisCachingAllowed()
Is cachingAllowed ?

        return cachingAllowed;
    
public booleanisCaseSensitive()
Is case sensitive ?

        return caseSensitive;
    
public booleanisUseNaming()
Returns true if the internal naming support is used.


        return (useNaming);

    
public voidlifecycleEvent(org.apache.catalina.LifecycleEvent event)
Process the START event for an associated Context.

param
event The lifecycle event that has occurred


        StandardContext context = null;
        NamingContextListener listener = null;

        if (event.getLifecycle() instanceof StandardContext) {
            context = (StandardContext) event.getLifecycle();
            LifecycleListener[] listeners = context.findLifecycleListeners();
            for (int i = 0; i < listeners.length; i++) {
                if (listeners[i] instanceof NamingContextListener) {
                    listener = (NamingContextListener) listeners[i];
                    break;
                }
            }
        }

        if (listener == null) {
            return;
        }

        if ((event.getType().equals(Lifecycle.BEFORE_STOP_EVENT))
            || (event.getType().equals(Context.RELOAD_EVENT))) {

            // Remove context
            contexts.remove(context);

            // Remove listener from the NamingResource listener list
            namingResources.removePropertyChangeListener(listener);

            // Remove listener from lifecycle listeners
            if (!(event.getType().equals(Context.RELOAD_EVENT))) {
                context.removeLifecycleListener(this);
            }

        }

        if ((event.getType().equals(Lifecycle.AFTER_START_EVENT))
            || (event.getType().equals(Context.RELOAD_EVENT))) {

            // Add context
            contexts.put(context, context);

            NamingResources contextResources = context.getNamingResources();

            // Setting the context in read/write mode
            ContextAccessController.setWritable(listener.getName(), context);

            // Send notifications to the listener to add the appropriate 
            // resources
            ContextEjb [] contextEjb = findEjbs();
            for (int i = 0; i < contextEjb.length; i++) {
                ContextEjb contextEntry = contextEjb[i];
                if (contextResources.exists(contextEntry.getName())) {
                    listener.removeEjb(contextEntry.getName());
                }
                listener.addEjb(contextEntry);
            }
            ContextEnvironment [] contextEnv = findEnvironments();
            for (int i = 0; i < contextEnv.length; i++) {
                ContextEnvironment contextEntry = contextEnv[i];
                if (contextResources.exists(contextEntry.getName())) {
                    listener.removeEnvironment(contextEntry.getName());
                }
                listener.addEnvironment(contextEntry);
            }
            ContextResource [] resources = findResources();
            for (int i = 0; i < resources.length; i++) {
                ContextResource contextEntry = resources[i];
                if (contextResources.exists(contextEntry.getName())) {
                    listener.removeResource(contextEntry.getName());
                }
                listener.addResource(contextEntry);
            }
            ContextResourceLink [] resourceLinks = findResourceLinks();
            for (int i = 0; i < resourceLinks.length; i++) {
                ContextResourceLink contextEntry = resourceLinks[i];
                if (contextResources.exists(contextEntry.getName())) {
                    listener.removeResourceLink(contextEntry.getName());
                }
                listener.addResourceLink(contextEntry);
            }
            String [] envRefs = findResourceEnvRefs();
            for (int i = 0; i < envRefs.length; i++) {
                if (contextResources.exists(envRefs[i])) {
                    listener.removeResourceEnvRef(envRefs[i]);
                }
                listener.addResourceEnvRef
                    (envRefs[i], findResourceEnvRef(envRefs[i]));
            }

            // Setting the context in read only mode
            ContextAccessController.setReadOnly(listener.getName());

            // Add listener to the NamingResources listener list
            namingResources.addPropertyChangeListener(listener);

        }

    
public voidpostDeregister()

    
public voidpostRegister(java.lang.Boolean registrationDone)

    
public voidpreDeregister()

    
public javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName name)

        oname=name;
        mserver=server;
        domain=name.getDomain();

        type=name.getKeyProperty("type");
        if( type==null ) {
            type=name.getKeyProperty("j2eeType");
        }

        String j2eeApp=name.getKeyProperty("J2EEApplication");
        String j2eeServer=name.getKeyProperty("J2EEServer");
        if( j2eeApp==null ) {
            j2eeApp="none";
        }
        if( j2eeServer==null ) {
            j2eeServer="none";
        }
        suffix=",J2EEApplication=" + j2eeApp + ",J2EEServer=" + j2eeServer;
        return name;
    
public voidremoveApplicationListener(java.lang.String listener)
Remove the specified application listener class from the set of listeners for this application.

param
listener Java class name of the listener to be removed


        synchronized (applicationListeners) {

            // Make sure this application listener is currently present
            int n = -1;
            for (int i = 0; i < applicationListeners.length; i++) {
                if (applicationListeners[i].equals(listener)) {
                    n = i;
                    break;
                }
            }
            if (n < 0)
                return;

            // Remove the specified application listener
            int j = 0;
            String results[] = new String[applicationListeners.length - 1];
            for (int i = 0; i < applicationListeners.length; i++) {
                if (i != n)
                    results[j++] = applicationListeners[i];
            }
            applicationListeners = results;

        }


    
public voidremoveApplicationParameter(java.lang.String name)
Remove the application parameter with the specified name from the set for this application.

param
name Name of the application parameter to remove


        synchronized (applicationParameters) {

            // Make sure this parameter is currently present
            int n = -1;
            for (int i = 0; i < applicationParameters.length; i++) {
                if (name.equals(applicationParameters[i].getName())) {
                    n = i;
                    break;
                }
            }
            if (n < 0)
                return;

            // Remove the specified parameter
            int j = 0;
            ApplicationParameter results[] =
                new ApplicationParameter[applicationParameters.length - 1];
            for (int i = 0; i < applicationParameters.length; i++) {
                if (i != n)
                    results[j++] = applicationParameters[i];
            }
            applicationParameters = results;

        }

    
public voidremoveEjb(java.lang.String name)
Remove any EJB resource reference with the specified name.

param
name Name of the EJB resource reference to remove


        namingResources.removeEjb(name);

    
public voidremoveEnvironment(java.lang.String envName)
Remove any environment entry with the specified name.

param
name Name of the environment entry to remove


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextEnvironment env = nresources.findEnvironment(envName);
        if (env == null) {
            throw new IllegalArgumentException
                ("Invalid environment name '" + envName + "'");
        }
        nresources.removeEnvironment(envName);
    
public voidremoveInstanceListener(java.lang.String listener)
Remove a class name from the set of InstanceListener classes that will be added to newly created Wrappers.

param
listener Class name of an InstanceListener class to be removed


        synchronized (instanceListeners) {

            // Make sure this InstanceListener is currently present
            int n = -1;
            for (int i = 0; i < instanceListeners.length; i++) {
                if (instanceListeners[i].equals(listener)) {
                    n = i;
                    break;
                }
            }
            if (n < 0)
                return;

            // Remove the specified InstanceListener
            int j = 0;
            String results[] = new String[instanceListeners.length - 1];
            for (int i = 0; i < instanceListeners.length; i++) {
                if (i != n)
                    results[j++] = instanceListeners[i];
            }
            instanceListeners = results;

        }

    
public voidremoveParameter(java.lang.String name)
Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.

param
name Name of the parameter to remove


        synchronized (parameters) {
            parameters.remove(name);
        }

    
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component.

param
listener The listener to remove


        support.removePropertyChangeListener(listener);

    
public voidremoveResource(java.lang.String resourceName)
Remove any resource reference with the specified name.

param
resourceName Name of the resource reference to remove


        // That should be done in the UI
        // resourceName = URLDecoder.decode(resourceName);
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextResource resource = nresources.findResource(resourceName);
        if (resource == null) {
            throw new IllegalArgumentException
                ("Invalid resource name '" + resourceName + "'");
        }
        nresources.removeResource(resourceName);
    
public voidremoveResourceEnvRef(java.lang.String name)
Remove any resource environment reference with the specified name.

param
name Name of the resource environment reference to remove


        namingResources.removeResourceEnvRef(name);

    
public voidremoveResourceLink(java.lang.String resourceLinkName)
Remove any resource link with the specified name.

param
resourceName Name of the resource reference to remove


        //resourceLinkName = URLDecoder.decode(resourceLinkName);
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextResourceLink resource = nresources.findResourceLink(resourceLinkName);
        if (resource == null) {
            throw new IllegalArgumentException
                ("Invalid resource name '" + resourceLinkName + "'");
        }
        nresources.removeResourceLink(resourceLinkName);
    
public voidremoveWrapperLifecycle(java.lang.String listener)
Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.

param
listener Class name of a LifecycleListener class to be removed



        synchronized (wrapperLifecycles) {

            // Make sure this LifecycleListener is currently present
            int n = -1;
            for (int i = 0; i < wrapperLifecycles.length; i++) {
                if (wrapperLifecycles[i].equals(listener)) {
                    n = i;
                    break;
                }
            }
            if (n < 0)
                return;

            // Remove the specified LifecycleListener
            int j = 0;
            String results[] = new String[wrapperLifecycles.length - 1];
            for (int i = 0; i < wrapperLifecycles.length; i++) {
                if (i != n)
                    results[j++] = wrapperLifecycles[i];
            }
            wrapperLifecycles = results;

        }

    
public voidremoveWrapperListener(java.lang.String listener)
Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.

param
listener Class name of a ContainerListener class to be removed



        synchronized (wrapperListeners) {

            // Make sure this ContainerListener is currently present
            int n = -1;
            for (int i = 0; i < wrapperListeners.length; i++) {
                if (wrapperListeners[i].equals(listener)) {
                    n = i;
                    break;
                }
            }
            if (n < 0)
                return;

            // Remove the specified ContainerListener
            int j = 0;
            String results[] = new String[wrapperListeners.length - 1];
            for (int i = 0; i < wrapperListeners.length; i++) {
                if (i != n)
                    results[j++] = wrapperListeners[i];
            }
            wrapperListeners = results;

        }

    
public voidsetAllowLinking(boolean allowLinking)
Set allow linking.

        this.allowLinking = allowLinking;
    
public voidsetCacheMaxSize(int cacheMaxSize)
Set the maximum size of the cache in KB.

        this.cacheMaxSize = cacheMaxSize;
    
public voidsetCacheTTL(int cacheTTL)
Set cache TTL.

        this.cacheTTL = cacheTTL;
    
public voidsetCachingAllowed(boolean cachingAllowed)
Set cachingAllowed.

        this.cachingAllowed = cachingAllowed;
    
public voidsetCaseSensitive(boolean caseSensitive)
Set case sensitivity.



    // ----------------------------------------------------- Context Properties


            
        
        this.caseSensitive = caseSensitive;
    
public voidsetCookies(boolean cookies)
Set the "use cookies for session ids" flag.

param
cookies The new flag

        boolean oldCookies = this.cookies;
        this.cookies = cookies;

    
public voidsetCrossContext(boolean crossContext)
Set the "allow crossing servlet contexts" flag.

param
crossContext The new cross contexts flag

        boolean oldCrossContext = this.crossContext;
        this.crossContext = crossContext;

    
public voidsetLoader(org.apache.catalina.Loader loader)
Set the Loader with which this Context is associated.

param
loader The newly associated loader

        Loader oldLoader = this.loader;
        this.loader = loader;

        // Report this property change to interested listeners
        support.firePropertyChange("loader", oldLoader, this.loader);
    
public voidsetManager(org.apache.catalina.Manager manager)
Set the Manager with which this Container is associated.

param
manager The newly associated Manager

        Manager oldManager = this.manager;
        this.manager = manager;
        
        // Report this property change to interested listeners
        support.firePropertyChange("manager", oldManager, this.manager);
    
public voidsetManagerChecksFrequency(int managerChecksFrequency)
Set the manager checks frequency.

        this.managerChecksFrequency = managerChecksFrequency;
    
public voidsetName(java.lang.String name)

        this.name = name;
    
public voidsetParent(org.apache.catalina.Container container)
Set the parent Container to which this Container is being added as a child. This Container may refuse to become attached to the specified Container by throwing an exception.

param
container Container to which this Container is being added as a child
exception
IllegalArgumentException if this Container refuses to become attached to the specified Container

        Container oldParent = this.parent;
        this.parent = container;
        support.firePropertyChange("parent", oldParent, this.parent);

    
public voidsetReloadable(boolean reloadable)
Set the reloadable flag for this web application.

param
reloadable The new reloadable flag

        boolean oldReloadable = this.reloadable;
        this.reloadable = reloadable;

    
public voidsetResources(javax.naming.directory.DirContext resources)
Set the resources DirContext object with which this Container is associated.

param
resources The newly associated DirContext

        this.dirContext = resources;

    
public voidsetSwallowOutput(boolean swallowOutput)
Set the swallowOutput flag for this web application.

param
swallowOutput The new swallowOutput flag

        boolean oldSwallowOutput = this.swallowOutput;
        this.swallowOutput = swallowOutput;

    
public voidsetUseNaming(boolean useNaming)
Enables or disables naming.

        this.useNaming = useNaming;
    
public voidsetWrapperClass(java.lang.String wrapperClass)
Set the Java class name of the Wrapper implementation used for servlets registered in this Context.

param
wrapperClass The new wrapper class

        this.wrapperClass = wrapperClass;

    
public java.lang.StringtoString()
Return a String representation of this component.


        StringBuffer sb = new StringBuffer();
        if (getParent() != null) {
            sb.append(getParent().toString());
            sb.append(".");
        }
        sb.append("DefaultContext[");
        sb.append("]");
        return (sb.toString());