Skip to content

Commit

Permalink
Factored out initialization of the tool, to allow reusing the code fo…
Browse files Browse the repository at this point in the history
…r other logger class names

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Nov 4, 2009
1 parent 112f64d commit 2af5f24
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/org/openscience/cdk/tools/LoggingToolFactory.java
Expand Up @@ -81,9 +81,17 @@ public static Class<? extends ILoggingTool> getLoggingToolClass() {
*/
@TestMethod("testCreateLoggingTool")
public static ILoggingTool createLoggingTool(Class<?> sourceClass) {
ILoggingTool tool = initializeLoggingTool(
sourceClass, DEFAULT_LOGGING_TOOL_CLASS
);
return tool;
}

private static ILoggingTool initializeLoggingTool(
Class<?> sourceClass, String className) {
try {
Class<?> possibleLoggingToolClass = sourceClass.getClassLoader()
.loadClass(DEFAULT_LOGGING_TOOL_CLASS);
.loadClass(className);
if (ILoggingTool.class.isAssignableFrom(possibleLoggingToolClass)) {
Method createMethod = possibleLoggingToolClass.getMethod(
"create", Class.class
Expand Down

0 comments on commit 2af5f24

Please sign in to comment.