From c1f16b5d2a81d37b5a8dc0c9a195bb76761998d1 Mon Sep 17 00:00:00 2001 From: Simon Kitching Date: Tue, 17 May 2005 04:27:57 +0000 Subject: [PATCH] Just moved some code out of method getLogConstructor into its own method reportInvalidLogAdapter to make code easier to read (esp. as I'm going to add more code to this method later). git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@170512 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/logging/impl/LogFactoryImpl.java | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java index df0ba52..d0487e1 100644 --- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -382,19 +382,8 @@ public class LogFactoryImpl extends LogFactory { ("No suitable Log implementation for " + logClassName); } if (!logInterface.isAssignableFrom(logClass)) { - Class interfaces[] = logClass.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - if (LOG_INTERFACE.equals(interfaces[i].getName())) { - throw new LogConfigurationException - ("Invalid class loader hierarchy. " + - "You have more than one version of '" + - LOG_INTERFACE + "' visible, which is " + - "not allowed."); - } - } - throw new LogConfigurationException - ("Class " + logClassName + " does not implement '" + - LOG_INTERFACE + "'."); + LogConfigurationException ex = reportInvalidLogAdapter(logInterface, logClass); + throw ex; } } catch (Throwable t) { throw new LogConfigurationException(t); @@ -419,6 +408,32 @@ public class LogFactoryImpl extends LogFactory { } } + /** + * Report a problem loading the log adapter, then always throw + * a LogConfigurationException. + * + * @param logInterface + * @param logClass + */ + private LogConfigurationException reportInvalidLogAdapter( + Class logInterface, Class logClass) { + + Class interfaces[] = logClass.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) { + if (LOG_INTERFACE.equals(interfaces[i].getName())) { + throw new LogConfigurationException + ("Invalid class loader hierarchy. " + + "You have more than one version of '" + + LOG_INTERFACE + "' visible, which is " + + "not allowed."); + } + } + + return new LogConfigurationException + ("Class " + logClassName + " does not implement '" + + LOG_INTERFACE + "'."); + } + /** * Gets the context classloader. * This method is a workaround for a java 1.2 compiler bug.