tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r439501 - in /tomcat/tc6.0.x/trunk/java/org/apache/catalina: loader/WebappLoader.java startup/ContextRuleSet.java
Date Fri, 01 Sep 2006 23:06:03 GMT
Author: remm
Date: Fri Sep  1 16:06:02 2006
New Revision: 439501

URL: http://svn.apache.org/viewvc?rev=439501&view=rev
Log:
- API change for the constructor of Loader: if not specified, the loader will get the parent
CL from the context,
  avoiding the problems of ignoring the privileged flag in some cases as seen in bug 39704.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ContextRuleSet.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java?rev=439501&r1=439500&r2=439501&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java Fri Sep  1 16:06:02
2006
@@ -770,7 +770,7 @@
         WebappClassLoader classLoader = null;
 
         if (parentClassLoader == null) {
-            parentClassLoader = Thread.currentThread().getContextClassLoader();
+            parentClassLoader = container.getParentClassLoader();
         }
         Class[] argTypes = { ClassLoader.class };
         Object[] args = { parentClassLoader };

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ContextRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ContextRuleSet.java?rev=439501&r1=439500&r2=439501&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ContextRuleSet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ContextRuleSet.java Fri Sep  1 16:06:02
2006
@@ -144,10 +144,9 @@
                             "addLifecycleListener",
                             "org.apache.catalina.LifecycleListener");
 
-        digester.addRule(prefix + "Context/Loader",
-                         new CreateLoaderRule
-                             ("org.apache.catalina.loader.WebappLoader",
-                              "className"));
+        digester.addObjectCreate(prefix + "Context/Loader",
+                            "org.apache.catalina.loader.WebappLoader",
+                            "className");
         digester.addSetProperties(prefix + "Context/Loader");
         digester.addSetNext(prefix + "Context/Loader",
                             "setLoader",
@@ -217,76 +216,5 @@
                                "addWrapperListener", 0);
 
     }
-
-}
-
-
-// ----------------------------------------------------------- Private Classes
-
-
-/**
- * Rule that creates a new <code>Loader</code> instance, with the parent
- * class loader associated with the top object on the stack (which must be
- * a <code>Container</code>), and pushes it on to the stack.
- */
-
-final class CreateLoaderRule extends Rule {
-
-    public CreateLoaderRule(String loaderClass, String attributeName) {
-
-        this.loaderClass = loaderClass;
-        this.attributeName = attributeName;
-
-    }
-
-    private String attributeName;
-
-    private String loaderClass;
-
-    public void begin(String namespace, String name, Attributes attributes)
-        throws Exception {
-
-        // Look up the required parent class loader
-        ClassLoader parentClassLoader = null;
-        Object ojb = digester.peek();
-        if (ojb instanceof Container) {
-            parentClassLoader = ((Container)ojb).getParentClassLoader();
-        }
-
-        // Bugzilla 36852: http://issues.apache.org/bugzilla/show_bug.cgi?id=36852
-        if((ojb instanceof org.apache.catalina.Context) &&
-           (((org.apache.catalina.Context) ojb).getPrivileged())) {
-            parentClassLoader = ojb.getClass().getClassLoader();
-        }
-
-        // Instantiate a new Loader implementation object
-        String className = loaderClass;
-        if (attributeName != null) {
-            String value = attributes.getValue(attributeName);
-            if (value != null)
-                className = value;
-        }
-        Class clazz = Class.forName(className);
-        Class types[] = { ClassLoader.class };
-        Object args[] = { parentClassLoader };
-        Constructor constructor = clazz.getDeclaredConstructor(types);
-        Loader loader = (Loader) constructor.newInstance(args);
-
-        // Push the new loader onto the stack
-        digester.push(loader);
-        if (digester.getLogger().isDebugEnabled())
-            digester.getLogger().debug("new " + loader.getClass().getName());
-
-    }
-
-    public void end(String namespace, String name)
-        throws Exception {
-
-        Loader loader = (Loader) digester.pop();
-        if (digester.getLogger().isDebugEnabled())
-            digester.getLogger().debug("pop " + loader.getClass().getName());
-
-    }
-
 
 }



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


Mime
View raw message