Remove ugly LOG_INTERFACE string and weird log-class-lookup code
from within the reportInvalidLogAdapter method. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@179571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -100,13 +100,6 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
"org.apache.commons.logging.log";
|
"org.apache.commons.logging.log";
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>The name of the {@link Log} interface class.</p>
|
|
||||||
*/
|
|
||||||
private static final String LOG_INTERFACE =
|
|
||||||
"org.apache.commons.logging.Log";
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- Instance Variables
|
// ----------------------------------------------------- Instance Variables
|
||||||
|
|
||||||
|
|
||||||
@@ -858,27 +851,17 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
private LogConfigurationException reportInvalidLogAdapter(Class logClass,
|
private LogConfigurationException reportInvalidLogAdapter(Class logClass,
|
||||||
Throwable cause) {
|
Throwable cause) {
|
||||||
|
|
||||||
|
String logInterfaceName = Log.class.getName();
|
||||||
Class interfaces[] = logClass.getInterfaces();
|
Class interfaces[] = logClass.getInterfaces();
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
for (int i = 0; i < interfaces.length; i++) {
|
||||||
if (LOG_INTERFACE.equals(interfaces[i].getName())) {
|
if (logInterfaceName.equals(interfaces[i].getName())) {
|
||||||
|
|
||||||
if (isDiagnosticsEnabled()) {
|
if (isDiagnosticsEnabled()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Need to load the log interface so we know its
|
// Need to load the log interface so we know its
|
||||||
// classloader for diagnostics
|
// classloader for diagnostics
|
||||||
Class logInterface = null;
|
ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
|
||||||
ClassLoader cl = getClassLoader(this.getClass());
|
|
||||||
if (cl == null) {
|
|
||||||
// we are probably in Java 1.1, but may also be
|
|
||||||
// running in some sort of embedded system..
|
|
||||||
logInterface = loadClass(LOG_INTERFACE);
|
|
||||||
} else {
|
|
||||||
// normal situation
|
|
||||||
logInterface = cl.loadClass(LOG_INTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassLoader logInterfaceClassLoader = getClassLoader(logInterface);
|
|
||||||
ClassLoader logAdapterClassLoader = getClassLoader(logClass);
|
ClassLoader logAdapterClassLoader = getClassLoader(logClass);
|
||||||
Class logAdapterInterface = interfaces[i];
|
Class logAdapterInterface = interfaces[i];
|
||||||
ClassLoader logAdapterInterfaceClassLoader = getClassLoader(logAdapterInterface);
|
ClassLoader logAdapterInterfaceClassLoader = getClassLoader(logAdapterInterface);
|
||||||
@@ -899,14 +882,14 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
return new LogConfigurationException
|
return new LogConfigurationException
|
||||||
("Invalid class loader hierarchy. " +
|
("Invalid class loader hierarchy. " +
|
||||||
"You have more than one version of '" +
|
"You have more than one version of '" +
|
||||||
LOG_INTERFACE + "' visible, which is " +
|
logInterfaceName + "' visible, which is " +
|
||||||
"not allowed.", cause);
|
"not allowed.", cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LogConfigurationException
|
return new LogConfigurationException
|
||||||
("Class " + logClassName + " does not implement '" +
|
("Class " + logClass.getName() + " does not implement '" +
|
||||||
LOG_INTERFACE + "'.", cause);
|
logInterfaceName + "'.", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user