1
0

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
This commit is contained in:
Simon Kitching
2005-05-17 04:27:57 +00:00
parent e985f2a051
commit c1f16b5d2a

View File

@@ -382,19 +382,8 @@ public class LogFactoryImpl extends LogFactory {
("No suitable Log implementation for " + logClassName); ("No suitable Log implementation for " + logClassName);
} }
if (!logInterface.isAssignableFrom(logClass)) { if (!logInterface.isAssignableFrom(logClass)) {
Class interfaces[] = logClass.getInterfaces(); LogConfigurationException ex = reportInvalidLogAdapter(logInterface, logClass);
for (int i = 0; i < interfaces.length; i++) { throw ex;
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 + "'.");
} }
} catch (Throwable t) { } catch (Throwable t) {
throw new LogConfigurationException(t); throw new LogConfigurationException(t);
@@ -419,6 +408,32 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
/**
* Report a problem loading the log adapter, then <i>always</i> 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. * Gets the context classloader.
* This method is a workaround for a java 1.2 compiler bug. * This method is a workaround for a java 1.2 compiler bug.