|
@@ -81,17 +81,15 @@ public class Logging {
|
81
|
81
|
private Object log;
|
82
|
82
|
|
83
|
83
|
/** Create a new Logging. */
|
84
|
|
- @SuppressWarnings("unchecked")
|
|
84
|
+ @SuppressWarnings({"unchecked", "rawtypes"})
|
85
|
85
|
private Logging() {
|
86
|
|
- boolean classExists = false;
|
87
|
86
|
try {
|
88
|
|
- Class factory = null;
|
|
87
|
+ Class<?> factory;
|
89
|
88
|
// Check for classes
|
90
|
89
|
Class.forName("org.apache.commons.logging.Log");
|
91
|
90
|
factory = Class.forName("org.apache.commons.logging.LogFactory");
|
92
|
91
|
|
93
|
|
- classExists = factory != null;
|
94
|
|
- if (classExists) {
|
|
92
|
+ if (factory != null) {
|
95
|
93
|
final Method getLog = factory.getMethod("getLog", new Class[]{Class.class});
|
96
|
94
|
log = getLog.invoke(null, this.getClass());
|
97
|
95
|
}
|
|
@@ -101,7 +99,7 @@ public class Logging {
|
101
|
99
|
} catch (InvocationTargetException ite) {
|
102
|
100
|
}
|
103
|
101
|
|
104
|
|
- isAvailable = classExists && log != null;
|
|
102
|
+ isAvailable = log != null;
|
105
|
103
|
}
|
106
|
104
|
|
107
|
105
|
/**
|
|
@@ -126,7 +124,7 @@ public class Logging {
|
126
|
124
|
public boolean levelEnabled(final LogLevel level) {
|
127
|
125
|
if (isAvailable) {
|
128
|
126
|
try {
|
129
|
|
- final Method check = log.getClass().getMethod(level.getCheckMethodName(), new Class[0]);
|
|
127
|
+ final Method check = log.getClass().getMethod(level.getCheckMethodName());
|
130
|
128
|
return (Boolean) check.invoke(log, new Object[0]);
|
131
|
129
|
} catch (NoSuchMethodException nsme) {
|
132
|
130
|
} catch (IllegalAccessException iae) {
|
|
@@ -160,10 +158,10 @@ public class Logging {
|
160
|
158
|
}
|
161
|
159
|
try {
|
162
|
160
|
if (throwable == null) {
|
163
|
|
- final Method method = log.getClass().getMethod(level.getMethodName(), new Class[]{String.class});
|
|
161
|
+ final Method method = log.getClass().getMethod(level.getMethodName(), String.class);
|
164
|
162
|
method.invoke(log, new Object[]{message});
|
165
|
163
|
} else {
|
166
|
|
- final Method method = log.getClass().getMethod(level.getMethodName(), new Class[]{String.class, Throwable.class});
|
|
164
|
+ final Method method = log.getClass().getMethod(level.getMethodName(), String.class, Throwable.class);
|
167
|
165
|
method.invoke(log, new Object[]{message, throwable});
|
168
|
166
|
}
|
169
|
167
|
} catch (NoSuchMethodException nsme) {
|