You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2011/01/21 02:53:05 UTC
svn commit: r1061594 -
/geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java
Author: xuhaihong
Date: Fri Jan 21 01:53:04 2011
New Revision: 1061594
URL: http://svn.apache.org/viewvc?rev=1061594&view=rev
Log:
Revert back the changes, still use new Thread for initialization, and make the bindThread/unbindThread methods protected
Modified:
geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java
Modified: geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java?rev=1061594&r1=1061593&r2=1061594&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java (original)
+++ geronimo/external/trunk/tomcat-parent-7.0.6/catalina/src/main/java/org/apache/catalina/core/StandardContext.java Fri Jan 21 01:53:04 2011
@@ -5,9 +5,9 @@
* 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.
@@ -37,6 +37,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
+import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicLong;
import javax.management.ListenerNotFoundException;
@@ -118,6 +119,7 @@ import org.apache.tomcat.JarScanner;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.scan.StandardJarScanner;
+import org.apache.tomcat.util.threads.DedicatedThreadExecutor;
/**
* Standard implementation of the <b>Context</b> interface. Each
@@ -211,33 +213,33 @@ public class StandardContext extends Con
*/
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[] =
+ private Object applicationEventListenersObjects[] =
new Object[0];
/**
* The set of instantiated application lifecycle listener objects</code>.
*/
- private Object applicationLifecycleListenersObjects[] =
+ private Object applicationLifecycleListenersObjects[] =
new Object[0];
@@ -246,8 +248,8 @@ public class StandardContext extends Con
*/
private Map<ServletContainerInitializer,Set<Class<?>>> initializers =
new LinkedHashMap<ServletContainerInitializer,Set<Class<?>>>();
-
-
+
+
/**
* The set of application parameters defined for this application.
*/
@@ -255,13 +257,13 @@ public class StandardContext extends Con
new ApplicationParameter[0];
private final Object applicationParametersLock = new Object();
-
+
/**
- * The broadcaster that sends j2ee notifications.
+ * The broadcaster that sends j2ee notifications.
*/
private NotificationBroadcasterSupport broadcaster = null;
-
+
/**
* The Locale to character set mapper for this application.
*/
@@ -291,7 +293,7 @@ public class StandardContext extends Con
* The security constraints for this web application.
*/
private SecurityConstraint constraints[] = new SecurityConstraint[0];
-
+
private final Object constraintsLock = new Object();
@@ -319,12 +321,12 @@ public class StandardContext extends Con
*/
private boolean crossContext = false;
-
+
/**
* Encoded path.
*/
private String encodedPath = null;
-
+
/**
* Unencoded path for this web application.
@@ -345,13 +347,13 @@ public class StandardContext extends Con
private String displayName = null;
- /**
+ /**
* Override the default context xml location.
*/
private String defaultContextXml;
- /**
+ /**
* Override the default web xml location.
*/
private String defaultWebXml;
@@ -425,7 +427,7 @@ public class StandardContext extends Con
/**
* The mapper associated with this context.
*/
- private org.apache.tomcat.util.http.mapper.Mapper mapper =
+ private org.apache.tomcat.util.http.mapper.Mapper mapper =
new org.apache.tomcat.util.http.mapper.Mapper();
@@ -504,8 +506,8 @@ public class StandardContext extends Con
* The original document root for this web application.
*/
private String originalDocBase = null;
-
-
+
+
/**
* The privileged flag for this web application.
*/
@@ -544,7 +546,7 @@ public class StandardContext extends Con
*/
private HashMap<String, String> servletMappings =
new HashMap<String, String>();
-
+
private final Object servletMappingsLock = new Object();
@@ -557,7 +559,7 @@ public class StandardContext extends Con
* The notification sequence number.
*/
private AtomicLong sequenceNumber = new AtomicLong(0);
-
+
/**
* The status code error pages for this web application, keyed by
* HTTP status code (as an Integer).
@@ -688,9 +690,9 @@ public class StandardContext extends Con
private long startTime;
private long tldScanTime;
- /**
+ /**
* Name of the engine. If null, the domain is used.
- */
+ */
private String j2EEApplication="none";
private String j2EEServer="none";
@@ -728,37 +730,37 @@ public class StandardContext extends Con
*/
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.
+ * configuration information such as TLDs or web-fragment.xml files.
*/
private JarScanner jarScanner = null;
@@ -769,10 +771,10 @@ public class StandardContext extends Con
* 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.
+ * <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
@@ -798,14 +800,14 @@ public class StandardContext extends Con
* StandardThreadExecutor of ThreadPoolExecutor be set to a positive value.
*/
private boolean renewThreadsWhenStoppingContext = true;
-
+
/**
* 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 =
@@ -894,12 +896,12 @@ public class StandardContext extends Con
public void setEffectiveMinorVersion(int effectiveMinorVersion) {
this.effectiveMinorVersion = effectiveMinorVersion;
}
-
+
@Override
public void setLogEffectiveWebXml(boolean logEffectiveWebXml) {
this.logEffectiveWebXml = logEffectiveWebXml;
}
-
+
@Override
public boolean getLogEffectiveWebXml() {
return logEffectiveWebXml;
@@ -909,7 +911,7 @@ public class StandardContext extends Con
public Authenticator getAuthenticator() {
if (this instanceof Authenticator)
return (Authenticator) this;
-
+
Pipeline pipeline = getPipeline();
if (pipeline != null) {
Valve basic = pipeline.getBasic();
@@ -923,7 +925,7 @@ public class StandardContext extends Con
}
return null;
}
-
+
@Override
public JarScanner getJarScanner() {
if (jarScanner == null) {
@@ -938,7 +940,7 @@ public class StandardContext extends Con
this.jarScanner = jarScanner;
}
-
+
public InstanceManager getInstanceManager() {
return instanceManager;
}
@@ -948,7 +950,7 @@ public class StandardContext extends Con
this.instanceManager = instanceManager;
}
-
+
@Override
public String getEncodedPath() {
return encodedPath;
@@ -1036,7 +1038,7 @@ public class StandardContext extends Con
/**
- * Return the list of resource aliases.
+ * Return the list of resource aliases.
*/
public String getAliases() {
return this.aliases;
@@ -1057,8 +1059,8 @@ public class StandardContext extends Con
getName()));
}
}
-
-
+
+
/**
* Set the current alias configuration. The list of aliases should be of the
* form "/aliasPath1=docBase1,/aliasPath2=docBase2" where aliasPathN must
@@ -1068,11 +1070,11 @@ public class StandardContext extends Con
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
@@ -1083,7 +1085,7 @@ public class StandardContext extends Con
initializers.put(sci, classes);
}
-
+
/**
* Return the "follow standard delegation model" flag used to configure
* our ClassLoader.
@@ -1178,8 +1180,8 @@ public class StandardContext extends Con
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
@@ -1219,7 +1221,7 @@ public class StandardContext extends Con
applicationLifecycleListenersObjects = newListeners;
}
-
+
/**
* Return the antiJARLocking flag for this Context.
*/
@@ -1402,12 +1404,12 @@ public class StandardContext extends Con
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
*/
@@ -1415,12 +1417,12 @@ public class StandardContext extends Con
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
*/
@Override
@@ -1431,10 +1433,10 @@ public class StandardContext extends Con
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
*/
@@ -1446,7 +1448,7 @@ public class StandardContext extends Con
/**
* Sets the use HttpOnly cookies for session cookies flag.
- *
+ *
* @param useHttpOnly Set to <code>true</code> to use HttpOnly cookies
* for session cookies
*/
@@ -1458,12 +1460,12 @@ public class StandardContext extends Con
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
*/
@@ -1471,12 +1473,12 @@ public class StandardContext extends Con
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
*/
@Override
@@ -1486,12 +1488,12 @@ public class StandardContext extends Con
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
*/
@@ -1499,12 +1501,12 @@ public class StandardContext extends Con
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
*/
@Override
@@ -1514,7 +1516,7 @@ public class StandardContext extends Con
support.firePropertyChange("sessionCookiePath",
oldSessionCookiePath, sessionCookiePath);
}
-
+
/**
* Return the "allow crossing servlet contexts" flag.
@@ -1547,12 +1549,12 @@ public class StandardContext extends Con
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
+ * @param defaultContextXml The default web xml
*/
public void setDefaultContextXml(String defaultContextXml) {
this.defaultContextXml = defaultContextXml;
@@ -1562,12 +1564,12 @@ public class StandardContext extends Con
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
+ * @param defaultWebXml The default web xml
*/
public void setDefaultWebXml(String defaultWebXml) {
this.defaultWebXml = defaultWebXml;
@@ -1765,12 +1767,12 @@ public class StandardContext extends Con
public boolean getIgnoreAnnotations() {
return this.ignoreAnnotations;
}
-
-
+
+
/**
- * Set the boolean on the annotations parsing for this web
+ * Set the boolean on the annotations parsing for this web
* application.
- *
+ *
* @param ignoreAnnotations The boolean on the annotations parsing
*/
@Override
@@ -1780,8 +1782,8 @@ public class StandardContext extends Con
support.firePropertyChange("ignoreAnnotations", oldIgnoreAnnotations,
this.ignoreAnnotations);
}
-
-
+
+
/**
* Return the login configuration descriptor for this web application.
*/
@@ -1878,9 +1880,9 @@ public class StandardContext extends Con
namingResources.setContainer(this);
support.firePropertyChange("namingResources",
oldNamingResources, this.namingResources);
-
+
// If set from server.xml, getObjectKeyPropertiesNameOnly() will
- // trigger an NPE. Initial registration takes place on INIT.
+ // trigger an NPE. Initial registration takes place on INIT.
if (getState() != LifecycleState.NEW) {
unregister(onameNamingResources);
onameNamingResources = register(namingResources,
@@ -1900,7 +1902,7 @@ public class StandardContext extends Con
/**
* Set the context path for this Context.
- *
+ *
* @param path The new context path
*/
@Override
@@ -1988,7 +1990,7 @@ public class StandardContext extends Con
this.originalDocBase = docBase;
}
-
+
/**
* Return the parent class loader (if any) for this web application.
@@ -2007,7 +2009,7 @@ public class StandardContext extends Con
return (ClassLoader.getSystemClassLoader());
}
-
+
/**
* Return the privileged flag for this web application.
*/
@@ -2190,7 +2192,7 @@ public class StandardContext extends Con
/**
* Set the value of the unloadDelay flag, which represents the amount
* of ms that the container will wait when unloading servlets.
- * Setting this to a small value may cause more requests to fail
+ * Setting this to a small value may cause more requests to fail
* to complete when stopping a web application.
*
* @param unloadDelay The new value
@@ -2252,7 +2254,7 @@ public class StandardContext extends Con
this.wrapperClassName = wrapperClassName;
try {
- wrapperClass = Class.forName(wrapperClassName);
+ wrapperClass = Class.forName(wrapperClassName);
if (!StandardWrapper.class.isAssignableFrom(wrapperClass)) {
throw new IllegalArgumentException(
sm.getString("standardContext.invalidWrapperClass",
@@ -2306,7 +2308,7 @@ public class StandardContext extends Con
}
-
+
@Override
public JspConfigDescriptor getJspConfigDescriptor() {
return jspConfigDescriptor;
@@ -2344,9 +2346,9 @@ public class StandardContext extends Con
/** Get the absolute path to the work dir.
* To avoid duplication.
- *
+ *
* @return The work path
- */
+ */
public String getWorkPath() {
if (getWorkDir() == null) {
return null;
@@ -2366,7 +2368,7 @@ public class StandardContext extends Con
}
return workDir.getAbsolutePath();
}
-
+
/**
* Return the work directory for this Context.
*/
@@ -2719,7 +2721,7 @@ public class StandardContext extends Con
fireContainerEvent("addFilterMap", filterMap);
}
-
+
/**
* Add a filter mapping to this Context before the mappings defined in the
* deployment descriptor but after any other mappings added via this method.
@@ -2751,8 +2753,8 @@ public class StandardContext extends Con
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.name", filterName));
- if (!filterMap.getMatchAllServletNames() &&
- !filterMap.getMatchAllUrlPatterns() &&
+ if (!filterMap.getMatchAllServletNames() &&
+ !filterMap.getMatchAllUrlPatterns() &&
(servletNames.length == 0) && (urlPatterns.length == 0))
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
@@ -3295,8 +3297,8 @@ public class StandardContext extends Con
public Context findMappingObject() {
return (Context) getMappingObject();
}
-
-
+
+
/**
* Return the message destination with the specified name, if any;
* otherwise, return <code>null</code>.
@@ -3564,7 +3566,7 @@ public class StandardContext extends Con
/**
- * Return the set of watched resources for this Context. If none are
+ * Return the set of watched resources for this Context. If none are
* defined, a zero length array will be returned.
*/
@Override
@@ -3573,8 +3575,8 @@ public class StandardContext extends Con
return watchedResources;
}
}
-
-
+
+
/**
* Return the set of welcome files defined for this Context. If none are
* defined, a zero-length array is returned.
@@ -4047,12 +4049,12 @@ public class StandardContext extends Con
/**
* Remove the specified watched resource name from the list associated
* with this Context.
- *
+ *
* @param name Name of the watched resource to be removed
*/
@Override
public void removeWatchedResource(String name) {
-
+
synchronized (watchedResourcesLock) {
// Make sure this watched resource is currently present
@@ -4080,8 +4082,8 @@ public class StandardContext extends Con
fireContainerEvent("removeWatchedResource", name);
}
-
-
+
+
/**
* Remove the specified welcome file name from the list recognized
* by this Context.
@@ -4210,7 +4212,7 @@ public class StandardContext extends Con
* StandardContext
*/
public long getProcessingTime() {
-
+
long result = 0;
Container[] children = findChildren();
@@ -4292,7 +4294,7 @@ public class StandardContext extends Con
/**
* Add a filter mapping at the end of the current set of filter
* mappings.
- *
+ *
* @param filterMap
* The filter mapping to be added
*/
@@ -4307,7 +4309,7 @@ public class StandardContext extends Con
/**
* Add a filter mapping before the mappings defined in the deployment
* descriptor but after any other mappings added via this method.
- *
+ *
* @param filterMap
* The filter mapping to be added
*/
@@ -4501,7 +4503,7 @@ public class StandardContext extends Con
// Ensure context is not null
getServletContext();
context.setNewServletContextListenerAllowed(false);
-
+
Object instances[] = getApplicationLifecycleListeners();
if (instances == null)
return (ok);
@@ -4597,7 +4599,7 @@ public class StandardContext extends Con
}
}
}
-
+
setApplicationEventListeners(null);
setApplicationLifecycleListeners(null);
@@ -4645,8 +4647,8 @@ public class StandardContext extends Con
if (!contextName.startsWith("/")) {
contextName = "/" + contextName;
}
- ObjectName resourcesName =
- new ObjectName(this.getDomain() + ":type=Cache,host="
+ ObjectName resourcesName =
+ new ObjectName(this.getDomain() + ":type=Cache,host="
+ getHostname() + ",context=" + contextName);
Registry.getRegistry(null, null).registerComponent
(proxyDirContext.getCache(), resourcesName, null);
@@ -4684,10 +4686,10 @@ public class StandardContext extends Con
if (!contextName.startsWith("/")) {
contextName = "/" + contextName;
}
- ObjectName resourcesName =
+ ObjectName resourcesName =
new ObjectName(this.getDomain()
- + ":type=Cache,host="
- + getHostname() + ",context="
+ + ":type=Cache,host="
+ + getHostname() + ",context="
+ contextName);
Registry.getRegistry(null, null)
.unregisterComponent(resourcesName);
@@ -4763,7 +4765,7 @@ public class StandardContext extends Con
if(log.isDebugEnabled())
log.debug("Starting " + getBaseName());
- // Send j2ee.state.starting notification
+ // Send j2ee.state.starting notification
if (this.getObjectName() != null) {
Notification notification = new Notification("j2ee.state.starting",
this.getObjectName(), sequenceNumber.getAndIncrement());
@@ -4837,19 +4839,19 @@ public class StandardContext extends Con
setNamingContextListener(ncl);
}
}
-
+
// Standard container startup
if (log.isDebugEnabled())
log.debug("Processing standard container startup");
-
+
// Binding thread
ClassLoader oldCCL = bindThread();
try {
if (ok) {
-
+
// Start our subordinate components, if any
if ((loader != null) && (loader instanceof Lifecycle))
((Lifecycle) loader).start();
@@ -4861,13 +4863,13 @@ public class StandardContext extends Con
unbindThread(oldCCL);
oldCCL = bindThread();
- // Initialize logger again. Other components might have used it too early,
+ // Initialize logger again. Other components might have used it too early,
// so it should be reset.
logger = null;
getLogger();
if ((logger != null) && (logger instanceof Lifecycle))
((Lifecycle) logger).start();
-
+
if ((cluster != null) && (cluster instanceof Lifecycle))
((Lifecycle) cluster).start();
if ((realm != null) && (realm instanceof Lifecycle))
@@ -4877,7 +4879,7 @@ public class StandardContext extends Con
// Notify our interested LifecycleListeners
fireLifecycleEvent(Lifecycle.CONFIGURE_START_EVENT, null);
-
+
// Start our child containers, if not already started
for (Container child : findChildren()) {
if (!child.getState().isAvailable()) {
@@ -4890,7 +4892,7 @@ public class StandardContext extends Con
if (pipeline instanceof Lifecycle) {
((Lifecycle) pipeline).start();
}
-
+
// Acquire clustered manager
Manager contextManager = null;
if (manager == null) {
@@ -4909,8 +4911,8 @@ public class StandardContext extends Con
} else {
contextManager = new StandardManager();
}
- }
-
+ }
+
// Configure default manager if none was specified
if (contextManager != null) {
if (log.isDebugEnabled()) {
@@ -4963,9 +4965,9 @@ public class StandardContext extends Con
}
}
- //DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
+ DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
try {
-
+
// Create context attributes that will be required
if (ok) {
getServletContext().setAttribute(
@@ -4990,7 +4992,6 @@ public class StandardContext extends Con
// Configure and call application event listeners
if (ok) {
- if(!listenerStart()) {/*
// we do it in a dedicated thread for memory leak protection, in
// case the Listeners registers some ThreadLocals that they
// forget to cleanup
@@ -5006,18 +5007,18 @@ public class StandardContext extends Con
}
}
});
- if (!listenerStarted.booleanValue()) {*/
+ if (!listenerStarted.booleanValue()) {
log.error( "Error listenerStart");
ok = false;
}
}
-
+
try {
// Start manager
if ((manager != null) && (manager instanceof Lifecycle)) {
((Lifecycle) getManager()).start();
}
-
+
// Start ContainerBackgroundProcessor thread
super.threadStart();
} catch(Exception e) {
@@ -5027,8 +5028,7 @@ public class StandardContext extends Con
// Configure and call application filters
if (ok) {
- if(!filterStart()) {
- /*// we do it in a dedicated thread for memory leak protection, in
+ // we do it in a dedicated thread for memory leak protection, in
// case the Filters register some ThreadLocals that they forget
// to cleanup
Boolean filterStarted =
@@ -5043,15 +5043,14 @@ public class StandardContext extends Con
}
}
});
- if (!filterStarted.booleanValue()) {*/
+ if (!filterStarted.booleanValue()) {
log.error("Error filterStart");
ok = false;
}
}
-
+
// Load and initialize all "load on startup" servlets
if (ok) {
- loadOnStartup(findChildren());/*
// we do it in a dedicated thread for memory leak protection, in
// case the Servlets register some ThreadLocals that they forget
// to cleanup
@@ -5066,13 +5065,13 @@ public class StandardContext extends Con
unbindThread(old);
}
}
- });*/
+ });
}
-
+
} finally {
// Unbinding thread
unbindThread(oldCCL);
- //temporaryExecutor.shutdown();
+ temporaryExecutor.shutdown();
}
// Set available status depending upon startup success
@@ -5084,16 +5083,16 @@ public class StandardContext extends Con
}
startTime=System.currentTimeMillis();
-
- // Send j2ee.state.running notification
+
+ // Send j2ee.state.running notification
if (ok && (this.getObjectName() != null)) {
- Notification notification =
+ Notification notification =
new Notification("j2ee.state.running", this.getObjectName(),
sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
}
- // Close all JARs right away to avoid always opening a peak number
+ // Close all JARs right away to avoid always opening a peak number
// of files on startup
if (getLoader() instanceof WebappLoader) {
((WebappLoader) getLoader()).closeJARs(true);
@@ -5149,7 +5148,7 @@ public class StandardContext extends Con
}
}
-
+
/**
* Merge the context initialization parameters specified in the application
@@ -5159,7 +5158,7 @@ public class StandardContext extends Con
*/
private void mergeParameters() {
ServletContext sc = getServletContext();
-
+
String names[] = findParameters();
for (int i = 0; i < names.length; i++) {
sc.setInitParameter(names[i], findParameter(names[i]));
@@ -5189,14 +5188,14 @@ public class StandardContext extends Con
@Override
protected synchronized void stopInternal() throws LifecycleException {
- // Send j2ee.state.stopping notification
+ // Send j2ee.state.stopping notification
if (this.getObjectName() != null) {
- Notification notification =
- new Notification("j2ee.state.stopping", this.getObjectName(),
+ Notification notification =
+ new Notification("j2ee.state.stopping", this.getObjectName(),
sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
}
-
+
setState(LifecycleState.STOPPING);
// Binding thread
@@ -5206,24 +5205,7 @@ public class StandardContext extends Con
// Stop our child containers, if any
final Container[] children = findChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].stop();
- }
-
- // Stop our filters
- filterStop();
-
- // Stop ContainerBackgroundProcessor thread
- threadStop();
-
- if ((manager != null) &&
- (manager instanceof Lifecycle)) {
- ((Lifecycle) manager).stop();
- }
-
- // Stop our application listeners
- listenerStop();
- /*// we do it in a dedicated thread for memory leak protection, in
+ // we do it in a dedicated thread for memory leak protection, in
// case some webapp code registers some ThreadLocals that they
// forget to cleanup
DedicatedThreadExecutor.executeInOwnThread(
@@ -5235,18 +5217,18 @@ public class StandardContext extends Con
for (int i = 0; i < children.length; i++) {
children[i].stop();
}
-
+
// Stop our filters
filterStop();
-
+
// Stop ContainerBackgroundProcessor thread
threadStop();
-
- if ((manager != null) &&
+
+ if ((manager != null) &&
(manager instanceof Lifecycle)) {
((Lifecycle) manager).stop();
}
-
+
// Stop our application listeners
listenerStop();
return null;
@@ -5254,7 +5236,7 @@ public class StandardContext extends Con
unbindThread(old);
}
}
- });*/
+ });
// Finalize our character set mapper
setCharsetMapper(null);
@@ -5297,24 +5279,24 @@ public class StandardContext extends Con
}
- // Send j2ee.state.stopped notification
+ // Send j2ee.state.stopped notification
if (this.getObjectName() != null) {
- Notification notification =
- new Notification("j2ee.state.stopped", this.getObjectName(),
+ Notification notification =
+ new Notification("j2ee.state.stopped", this.getObjectName(),
sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
}
-
+
// Reset application context
context = null;
- // This object will no longer be visible or used.
+ // This object will no longer be visible or used.
try {
resetContext();
} catch( Exception ex ) {
log.error( "Error reseting context " + this + " " + ex, ex );
}
-
+
//reset the instance manager
instanceManager = null;
@@ -5324,20 +5306,20 @@ public class StandardContext extends Con
}
/** Destroy needs to clean up the context completely.
- *
- * The problem is that undoing all the config in start() and restoring
+ *
+ * The problem is that undoing all the config in start() and restoring
* a 'fresh' state is impossible. After stop()/destroy()/init()/start()
* we should have the same state as if a fresh start was done - i.e
- * read modified web.xml, etc. This can only be done by completely
+ * read modified web.xml, etc. This can only be done by completely
* removing the context object and remapping a new one, or by cleaning
* up everything.
- *
+ *
* XXX Should this be done in stop() ?
- *
- */
+ *
+ */
@Override
protected void destroyInternal() throws LifecycleException {
-
+
if ((manager != null) && (manager instanceof Lifecycle)) {
((Lifecycle) manager).destroy();
}
@@ -5354,9 +5336,9 @@ public class StandardContext extends Con
((Lifecycle) loader).destroy();
}
- // Send j2ee.object.deleted notification
- Notification notification =
- new Notification("j2ee.object.deleted", this.getObjectName(),
+ // Send j2ee.object.deleted notification
+ Notification notification =
+ new Notification("j2ee.object.deleted", this.getObjectName(),
sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
@@ -5368,11 +5350,11 @@ public class StandardContext extends Con
super.destroyInternal();
}
-
+
private void resetContext() throws Exception {
// Restore the original state ( pre reading web.xml in start )
// If you extend this - override this method and make sure to clean up
-
+
// Don't reset anything that is read from a <Context.../> element since
// <Context .../> elements are read at initialisation will not be read
// again for this object
@@ -5388,9 +5370,9 @@ public class StandardContext extends Con
applicationEventListenersObjects = new Object[0];
applicationLifecycleListenersObjects = new Object[0];
jspConfigDescriptor = new ApplicationJspConfigDescriptor();
-
+
initializers.clear();
-
+
if(log.isDebugEnabled())
log.debug("resetContext " + getObjectName());
}
@@ -5547,7 +5529,7 @@ public class StandardContext extends Con
*
* @return the previous context class loader
*/
- private ClassLoader bindThread() {
+ protected ClassLoader bindThread() {
ClassLoader oldContextClassLoader =
Thread.currentThread().getContextClassLoader();
@@ -5560,8 +5542,7 @@ public class StandardContext extends Con
(getLoader().getClassLoader());
}
- //DirContextURLStreamHandler.bindThread(getResources());
- DirContextURLStreamHandler.bind(getResources());
+ DirContextURLStreamHandler.bindThread(getResources());
if (isUseNaming()) {
try {
@@ -5580,20 +5561,15 @@ public class StandardContext extends Con
/**
* Unbind thread.
*/
- private void unbindThread(ClassLoader oldContextClassLoader) {
-
- Thread.currentThread().setContextClassLoader(oldContextClassLoader);
-
- oldContextClassLoader = null;
+ protected void unbindThread(ClassLoader oldContextClassLoader) {
if (isUseNaming()) {
ContextBindings.unbindThread(this, this);
}
- DirContextURLStreamHandler.unbind();
- //DirContextURLStreamHandler.unbindThread();
+ DirContextURLStreamHandler.unbindThread();
- //Thread.currentThread().setContextClassLoader(oldContextClassLoader);
+ Thread.currentThread().setContextClassLoader(oldContextClassLoader);
}
@@ -5671,14 +5647,14 @@ public class StandardContext extends Con
return namingContextName;
}
-
+
/**
* Naming context listener accessor.
*/
public NamingContextListener getNamingContextListener() {
return namingContextListener;
}
-
+
/**
* Naming context listener setter.
@@ -5686,7 +5662,7 @@ public class StandardContext extends Con
public void setNamingContextListener(NamingContextListener namingContextListener) {
this.namingContextListener = namingContextListener;
}
-
+
/**
* Return the request processing paused flag for this Context.
@@ -5717,7 +5693,7 @@ public class StandardContext extends Con
if ((instances != null) && (instances.length > 0)) {
- ServletRequestEvent event =
+ ServletRequestEvent event =
new ServletRequestEvent(getServletContext(), request);
for (int i = 0; i < instances.length; i++) {
@@ -5727,7 +5703,7 @@ public class StandardContext extends Con
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[i];
-
+
try {
// Don't fire the listener for async requests
if (!DispatcherType.ASYNC.equals(
@@ -5754,7 +5730,7 @@ public class StandardContext extends Con
if ((instances != null) && (instances.length > 0)) {
- ServletRequestEvent event =
+ ServletRequestEvent event =
new ServletRequestEvent(getServletContext(), request);
for (int i = 0; i < instances.length; i++) {
@@ -5765,7 +5741,7 @@ public class StandardContext extends Con
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[j];
-
+
try {
// Don't fire the listener for async requests
if (!DispatcherType.ASYNC.equals(
@@ -5922,10 +5898,10 @@ public class StandardContext extends Con
/**
* JSR77 deploymentDescriptor attribute
*
- * @return string deployment descriptor
+ * @return string deployment descriptor
*/
public String getDeploymentDescriptor() {
-
+
InputStream stream = null;
ServletContext servletContext = getServletContext();
if (servletContext != null) {
@@ -5954,17 +5930,17 @@ public class StandardContext extends Con
}
}
- return sb.toString();
+ return sb.toString();
}
-
-
+
+
/**
* JSR77 servlets attribute
*
* @return list of all servlets ( we know about )
*/
public String[] getServlets() {
-
+
String[] result = null;
Container[] children = findChildren();
@@ -5977,7 +5953,7 @@ public class StandardContext extends Con
return result;
}
-
+
@Override
protected String getObjectNameKeyProperties() {
@@ -5992,7 +5968,7 @@ public class StandardContext extends Con
return keyProperties.toString();
}
-
+
private String getObjectKeyPropertiesNameOnly() {
StringBuilder result = new StringBuilder("name=//");
String hostname = getParent().getName();
@@ -6001,7 +5977,7 @@ public class StandardContext extends Con
} else {
result.append(hostname);
}
-
+
String contextName = getName();
if (!contextName.startsWith("/")) {
result.append('/');
@@ -6014,7 +5990,7 @@ public class StandardContext extends Con
@Override
protected void initInternal() throws LifecycleException {
super.initInternal();
-
+
if (processTlds) {
this.addLifecycleListener(new TldConfig());
}
@@ -6025,7 +6001,7 @@ public class StandardContext extends Con
"type=NamingResources," + getObjectNameKeyProperties());
}
- // Send j2ee.object.created notification
+ // Send j2ee.object.created notification
if (this.getObjectName() != null) {
Notification notification = new Notification("j2ee.object.created",
this.getObjectName(), sequenceNumber.getAndIncrement());
@@ -6034,17 +6010,17 @@ public class StandardContext extends Con
}
- /* Remove a JMX notficationListener
+ /* Remove a JMX notficationListener
* @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/
@Override
- public void removeNotificationListener(NotificationListener listener,
+ public void removeNotificationListener(NotificationListener listener,
NotificationFilter filter, Object object) throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener,filter,object);
}
-
+
private MBeanNotificationInfo[] notificationInfo;
-
+
/* Get JMX Broadcaster Info
* @TODO use StringManager for international support!
* @TODO This two events we not send j2ee.state.failed and j2ee.attribute.changed!
@@ -6059,7 +6035,7 @@ public class StandardContext extends Con
"j2ee.object.created"},
Notification.class.getName(),
"web application is created"
- ),
+ ),
new MBeanNotificationInfo(new String[] {
"j2ee.state.starting"},
Notification.class.getName(),
@@ -6086,34 +6062,34 @@ public class StandardContext extends Con
"web application is deleted"
)
};
-
+
}
-
+
return notificationInfo;
}
-
-
+
+
/* Add a JMX-NotificationListener
* @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/
@Override
- public void addNotificationListener(NotificationListener listener,
+ public void addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object object) throws IllegalArgumentException {
broadcaster.addNotificationListener(listener,filter,object);
}
-
-
+
+
/**
- * Remove a JMX-NotificationListener
+ * Remove a JMX-NotificationListener
* @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener)
*/
@Override
- public void removeNotificationListener(NotificationListener listener)
+ public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener);
}
-
-
+
+
// ------------------------------------------------------------- Attributes
@@ -6129,7 +6105,7 @@ public class StandardContext extends Con
/**
* Return the naming resources associated with this web application.
- * FIXME: Fooling introspection ...
+ * FIXME: Fooling introspection ...
*/
public javax.naming.directory.DirContext findStaticResources() {
@@ -6154,7 +6130,7 @@ public class StandardContext extends Con
*/
@Override
public void setXmlValidation(boolean webXmlValidation){
-
+
this.webXmlValidation = webXmlValidation;
}
@@ -6188,17 +6164,17 @@ public class StandardContext extends Con
@Override
public void setXmlNamespaceAware(boolean webXmlNamespaceAware){
this.webXmlNamespaceAware= webXmlNamespaceAware;
- }
+ }
/**
* Set the validation feature of the XML parser used when
- * parsing tlds files.
+ * parsing tlds files.
* @param tldValidation true to enable xml instance validation
*/
@Override
public void setTldValidation(boolean tldValidation){
-
+
this.tldValidation = tldValidation;
}
@@ -6247,61 +6223,61 @@ public class StandardContext extends Con
@Override
public void setTldNamespaceAware(boolean tldNamespaceAware){
this.tldNamespaceAware= tldNamespaceAware;
- }
+ }
- /**
- * Support for "stateManageable" JSR77
+ /**
+ * Support for "stateManageable" JSR77
*/
public boolean isStateManageable() {
return true;
}
-
+
public void startRecursive() throws LifecycleException {
// nothing to start recursive, the servlets will be started by load-on-startup
start();
}
-
+
/**
* The J2EE Server ObjectName this module is deployed on.
- */
+ */
private String server = null;
-
+
/**
* The Java virtual machines on which this module is running.
- */
+ */
private String[] javaVMs = null;
-
+
public String getServer() {
return server;
}
-
+
public String setServer(String server) {
return this.server=server;
}
-
+
public String[] getJavaVMs() {
return javaVMs;
}
-
+
public String[] setJavaVMs(String[] javaVMs) {
return this.javaVMs = javaVMs;
}
-
+
/**
* Gets the time this context was started.
*
* @return Time (in milliseconds since January 1, 1970, 00:00:00) when this
- * context was started
+ * context was started
*/
public long getStartTime() {
return startTime;
}
-
+
public boolean isEventProvider() {
return false;
}
-
+
public boolean isStatisticsProvider() {
return false;
}