From 17c6d98369a44ee7724b1e5821d69e73c637d132 Mon Sep 17 00:00:00 2001 From: Simon Kitching Date: Thu, 2 Jun 2005 10:28:35 +0000 Subject: [PATCH] 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 --- .../commons/logging/impl/LogFactoryImpl.java | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java index a78f5f1..2236ea2 100644 --- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -100,13 +100,6 @@ public class LogFactoryImpl extends LogFactory { "org.apache.commons.logging.log"; - /** - *

The name of the {@link Log} interface class.

- */ - private static final String LOG_INTERFACE = - "org.apache.commons.logging.Log"; - - // ----------------------------------------------------- Instance Variables @@ -858,27 +851,17 @@ public class LogFactoryImpl extends LogFactory { private LogConfigurationException reportInvalidLogAdapter(Class logClass, Throwable cause) { + String logInterfaceName = Log.class.getName(); Class interfaces[] = logClass.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { - if (LOG_INTERFACE.equals(interfaces[i].getName())) { + if (logInterfaceName.equals(interfaces[i].getName())) { if (isDiagnosticsEnabled()) { try { // Need to load the log interface so we know its // classloader for diagnostics - Class logInterface = null; - 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 logInterfaceClassLoader = getClassLoader(Log.class); ClassLoader logAdapterClassLoader = getClassLoader(logClass); Class logAdapterInterface = interfaces[i]; ClassLoader logAdapterInterfaceClassLoader = getClassLoader(logAdapterInterface); @@ -899,14 +882,14 @@ public class LogFactoryImpl extends LogFactory { return new LogConfigurationException ("Invalid class loader hierarchy. " + "You have more than one version of '" + - LOG_INTERFACE + "' visible, which is " + + logInterfaceName + "' visible, which is " + "not allowed.", cause); } } return new LogConfigurationException - ("Class " + logClassName + " does not implement '" + - LOG_INTERFACE + "'.", cause); + ("Class " + logClass.getName() + " does not implement '" + + logInterfaceName + "'.", cause); } }