tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1239082 - in /tomcat/trunk/java/org/apache/catalina: core/LocalStrings.properties core/StandardContext.java loader/WebappLoader.java
Date Wed, 01 Feb 2012 11:32:57 GMT
Author: markt
Date: Wed Feb  1 11:32:56 2012
New Revision: 1239082

URL: http://svn.apache.org/viewvc?rev=1239082&view=rev
Log:
Remove dependency on StandardContext from WebappLoader

Modified:
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1239082&r1=1239081&r2=1239082&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Wed Feb  1 11:32:56
2012
@@ -123,6 +123,7 @@ standardContext.startFailed=Context [{0}
 standardContext.startingContext=Exception starting Context with name [{0}]
 standardContext.stoppingContext=Exception stopping Context with name [{0}]
 standardContext.urlPattern.patternWarning=WARNING: URL pattern {0} must start with a ''/''
in Servlet 2.4
+standardContext.webappClassLoader.missingProperty=Unable to set the web application class
loader property [{0}] to [{1}] as the property does not exist.
 standardContext.workPath=Exception obtaining work path for context [{0}]
 standardContext.workCreateException=Failed to determine absolute work directory from directory
[{0}] and CATALINA_HOME [{1}] for context [{2}]
 standardContext.workCreateFail=Failed to create work directory [{0}] for context [{1}]

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1239082&r1=1239081&r2=1239082&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Wed Feb  1 11:32:56 2012
@@ -116,6 +116,7 @@ import org.apache.naming.resources.WARDi
 import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.JarScanner;
 import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.IntrospectionUtils;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
@@ -5032,6 +5033,16 @@ public class StandardContext extends Con
 
                 // since the loader just started, the webapp classloader is now
                 // created.
+                setClassLoaderProperty("antiJARLocking", getAntiJARLocking());
+                setClassLoaderProperty("clearReferencesStatic",
+                        getClearReferencesStatic());
+                setClassLoaderProperty("clearReferencesStopThreads",
+                        getClearReferencesStopThreads());
+                setClassLoaderProperty("clearReferencesStopTimerThreads",
+                        getClearReferencesStopTimerThreads());
+                setClassLoaderProperty("clearReferencesHttpClientKeepAliveThread",
+                        getClearReferencesHttpClientKeepAliveThread());
+
                 // By calling unbindThread and bindThread in a row, we setup the
                 // current Thread CCL to be the webapp classloader
                 unbindThread(oldCCL);
@@ -5232,6 +5243,16 @@ public class StandardContext extends Con
         }
     }
 
+    private void setClassLoaderProperty(String name, boolean value) {
+        ClassLoader cl = getLoader().getClassLoader();
+        if (IntrospectionUtils.setProperty(cl, name, Boolean.toString(value))) {
+            // Failed to set
+            log.info(sm.getString(
+                    "standardContext.webappClassLoader.missingProperty",
+                    name, Boolean.toString(value)));
+        }
+    }
+
     private Map<String, Map<String, String>> buildInjectionMap(NamingResources
namingResources) {
         Map<String, Map<String, String>> injectionMap = new HashMap<String,
Map<String, String>>();
         for (Injectable resource: namingResources.findLocalEjbs()) {

Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java?rev=1239082&r1=1239081&r2=1239082&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java Wed Feb  1 11:32:56 2012
@@ -53,7 +53,6 @@ import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Loader;
-import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.mbeans.MBeanUtils;
 import org.apache.catalina.util.LifecycleMBeanBase;
 import org.apache.naming.resources.DirContextURLStreamHandler;
@@ -402,8 +401,8 @@ public class WebappLoader extends Lifecy
             try {
                 Thread.currentThread().setContextClassLoader
                     (WebappLoader.class.getClassLoader());
-                if (container instanceof StandardContext) {
-                    ((StandardContext) container).reload();
+                if (container instanceof Context) {
+                    ((Context) container).reload();
                 }
             } finally {
                 if (container.getLoader() != null) {
@@ -564,19 +563,6 @@ public class WebappLoader extends Lifecy
             classLoader.setResources(container.getResources());
             classLoader.setDelegate(this.delegate);
             classLoader.setSearchExternalFirst(searchExternalFirst);
-            if (container instanceof StandardContext) {
-                classLoader.setAntiJARLocking(
-                        ((StandardContext) container).getAntiJARLocking());
-                classLoader.setClearReferencesStatic(
-                        ((StandardContext) container).getClearReferencesStatic());
-                classLoader.setClearReferencesStopThreads(
-                        ((StandardContext) container).getClearReferencesStopThreads());
-                classLoader.setClearReferencesStopTimerThreads(
-                        ((StandardContext) container).getClearReferencesStopTimerThreads());
-                classLoader.setClearReferencesHttpClientKeepAliveThread(
-                        ((StandardContext) container).getClearReferencesHttpClientKeepAliveThread());
-            }
-
             for (int i = 0; i < repositories.length; i++) {
                 classLoader.addRepository(repositories[i]);
             }
@@ -593,14 +579,14 @@ public class WebappLoader extends Lifecy
             DirContextURLStreamHandler.bind(classLoader,
                     this.container.getResources());
 
-            StandardContext ctx=(StandardContext)container;
-            String contextName = ctx.getName();
+            String contextName = container.getName();
             if (!contextName.startsWith("/")) {
                 contextName = "/" + contextName;
             }
-            ObjectName cloname = new ObjectName
-                (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
-                 + contextName + ",host=" + ctx.getParent().getName());
+            ObjectName cloname = new ObjectName(
+                    MBeanUtils.getDomain(container) +
+                    ":type=WebappClassLoader,context=" + contextName +
+                    ",host=" + container.getParent().getName());
             Registry.getRegistry(null, null)
                 .registerComponent(classLoader, cloname, null);
 
@@ -642,14 +628,14 @@ public class WebappLoader extends Lifecy
         DirContextURLStreamHandler.unbind(classLoader);
 
         try {
-            StandardContext ctx=(StandardContext)container;
-            String contextName = ctx.getName();
+            String contextName = container.getName();
             if (!contextName.startsWith("/")) {
                 contextName = "/" + contextName;
             }
-            ObjectName cloname = new ObjectName
-                (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
-                 + contextName + ",host=" + ctx.getParent().getName());
+            ObjectName cloname = new ObjectName(
+                    MBeanUtils.getDomain(container) +
+                    ":type=WebappClassLoader,context=" + contextName +
+                    ",host=" + container.getParent().getName());
             Registry.getRegistry(null, null).unregisterComponent(cloname);
         } catch (Exception e) {
             log.error("LifecycleException ", e);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message