Author: skitching
Date: Tue Jan 17 19:38:38 2006
New Revision: 370030
URL: http://svn.apache.org/viewcvs?rev=370030&view=rev
Log:
Add feature to disable loading of Log implementations from the TCCL.
Modified:
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Modified:
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java?rev=370030&r1=370029&r2=370030&view=diff
==============================================================================
---
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
(original)
+++
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Tue Jan 17 19:38:38 2006
@@ -159,6 +159,11 @@
// ----------------------------------------------------- Instance Variables
+ /**
+ * Determines whether logging classes should be loaded using the
thread-context
+ * classloader, or via the classloader that loaded this LogFactoryImpl
class.
+ */
+ private boolean useTCCL = true;
/**
* The string prefixed to every message output by the logDiagnostic method.
@@ -375,6 +380,10 @@
} else {
attributes.put(name, value);
}
+
+ if (name.equals(TCCL_KEY)) {
+ useTCCL = Boolean.valueOf(value.toString()).booleanValue();
+ }
}
@@ -699,7 +708,6 @@
String specifiedLogClassName = findUserSpecifiedLogClassName();
if (specifiedLogClassName != null) {
- // note: createLogFromClass never returns null..
result = createLogFromClass(specifiedLogClassName,
logCategory,
true);
@@ -834,7 +842,7 @@
Class c = Class.forName(logAdapterClassName, true, currentCL);
constructor = c.getConstructor(logConstructorSignature);
Object o = constructor.newInstance(params);
-
+
// Note that we do this test after trying to create an instance
// [rather than testing Log.class.isAssignableFrom(c)] so that
// we don't complain about Log hierarchy problems when the
@@ -969,12 +977,17 @@
*
*/
private ClassLoader getBaseClassLoader() throws LogConfigurationException {
- ClassLoader contextClassLoader = getContextClassLoader();
ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
+ if (useTCCL == false) {
+ return thisClassLoader;
+ }
+
+ ClassLoader contextClassLoader = getContextClassLoader();
+
ClassLoader baseClassLoader = getLowestClassLoader(
contextClassLoader, thisClassLoader);
-
+
if (baseClassLoader == null) {
// The two classloaders are not part of a parent child relationship.
// In some classloading setups (e.g. JBoss with its
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]