You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/03/10 19:27:26 UTC
cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus/server AbstractTestCaller.java
vmassol 02/03/10 10:27:26
Modified: framework/src/java/share/org/apache/cactus/server
AbstractTestCaller.java
Log:
Reapplied patch from Nicholas Lesiecki for using the context classloader for loading test classes by the cactus redirectors. Also added javadoc comments ! :-)
Revision Changes Path
1.3 +22 -3 jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractTestCaller.java
Index: AbstractTestCaller.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractTestCaller.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractTestCaller.java 10 Mar 2002 13:58:25 -0000 1.2
+++ AbstractTestCaller.java 10 Mar 2002 18:27:26 -0000 1.3
@@ -74,8 +74,9 @@
* provides a common abstraction for all test web requests.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
+ * @author <a href="mailto:ndlesiecki@apache.org">Nicholas Lesiecki</a>
*
- * @version $Id: AbstractTestCaller.java,v 1.2 2002/03/10 13:58:25 vmassol Exp $
+ * @version $Id: AbstractTestCaller.java,v 1.3 2002/03/10 18:27:26 vmassol Exp $
*/
public abstract class AbstractTestCaller
{
@@ -295,7 +296,7 @@
// Print info on the classloader used to load this class
if (LOGGER.isDebugEnabled()) {
StringBuffer buffer = new StringBuffer("Classloaders = ");
- ClassLoader classLoader = this.getClass().getClassLoader();
+ ClassLoader classLoader = getAppropriateClassLoader();
while (classLoader != null) {
buffer.append(classLoader.toString());
classLoader = classLoader.getParent();
@@ -337,7 +338,8 @@
// Get the class to call and build an instance of it.
Class testClass = null;
try {
- testClass = Class.forName(theClassName);
+ testClass = Class.forName(theClassName, true,
+ getAppropriateClassLoader());
} catch (Exception e) {
String message = "Error finding class [" + theClassName +
"] in classpath. ";
@@ -354,6 +356,23 @@
}
return testClass;
+ }
+
+ /**
+ * Enable the Cactus jar to be put in the system classpath and still be
+ * able to load classes that must be loaded by the webapp classloader by
+ * using the Context class loader (if set) to load these classes.
+ *
+ * @return either the Context class loader or the class loader that was
+ * used to load the current class.
+ */
+ private ClassLoader getAppropriateClassLoader()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if(loader == null) {
+ loader = this.getClass().getClassLoader();
+ }
+ return loader;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>