Skip to content

Commit 42bdfd1

Browse files
committed
http://code.google.com/p/mybatis/issues/detail?id=64 : ResolverUtil has hard-coded dependency on Log4j
applied patch submitted by zpejder
1 parent 16fb93d commit 42bdfd1

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/main/java/org/apache/ibatis/io/ResolverUtil.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
*/
1515
package org.apache.ibatis.io;
1616

17-
import org.apache.log4j.Logger;
17+
import org.apache.ibatis.logging.Log;
18+
import org.apache.ibatis.logging.LogFactory;
1819

1920
import java.io.BufferedReader;
2021
import java.io.File;
@@ -72,7 +73,7 @@ public class ResolverUtil<T> {
7273
/**
7374
* An instance of Log to use for logging in this class.
7475
*/
75-
private static final Logger log = Logger.getLogger(ResolverUtil.class);
76+
private static final Log log = LogFactory.getLog(ResolverUtil.class);
7677

7778
/**
7879
* The magic header that indicates a JAR (ZIP) file.
@@ -295,7 +296,7 @@ protected List<String> listClassResources(URL url, String path) throws IOExcepti
295296
is = url.openStream();
296297
JarInputStream jarInput = new JarInputStream(is);
297298
for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null;) {
298-
log.trace("Jar entry: " + entry.getName());
299+
log.debug("Jar entry: " + entry.getName());
299300
if (isRelevantResource(entry.getName())) {
300301
children.add(entry.getName());
301302
}
@@ -306,7 +307,7 @@ protected List<String> listClassResources(URL url, String path) throws IOExcepti
306307
is = url.openStream();
307308
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
308309
for (String line; (line = reader.readLine()) != null;) {
309-
log.trace("Reader entry: " + line);
310+
log.debug("Reader entry: " + line);
310311
if (isRelevantResource(line)) {
311312
children.add(line);
312313
}
@@ -321,7 +322,7 @@ protected List<String> listClassResources(URL url, String path) throws IOExcepti
321322
*/
322323
if ("file".equals(url.getProtocol())) {
323324
File file = new File(url.getFile());
324-
log.trace("Listing directory " + file.getAbsolutePath());
325+
log.debug("Listing directory " + file.getAbsolutePath());
325326
if (file.isDirectory()) {
326327
children = Arrays.asList(file.list(new FilenameFilter() {
327328
public boolean accept(File dir, String name) {
@@ -344,7 +345,7 @@ public boolean accept(File dir, String name) {
344345
for (String child : children) {
345346
String resourcePath = path + "/" + child;
346347
if (child.endsWith(".class")) {
347-
log.trace("Found class file: " + resourcePath);
348+
log.debug("Found class file: " + resourcePath);
348349
resources.add(resourcePath);
349350
} else {
350351
URL childUrl = new URL(prefix + child);
@@ -391,7 +392,7 @@ protected List<String> listClassResources(JarInputStream jar, String path) throw
391392

392393
// Check file name
393394
if (name.endsWith(".class") && name.startsWith(path)) {
394-
log.trace("Found class file: " + name);
395+
log.debug("Found class file: " + name);
395396
resources.add(name.substring(1)); // Trim leading slash
396397
}
397398
}
@@ -411,13 +412,13 @@ protected List<String> listClassResources(JarInputStream jar, String path) throw
411412
* @throws MalformedURLException
412413
*/
413414
protected URL findJarForResource(URL url, String path) throws MalformedURLException {
414-
log.trace("Find JAR URL: " + url);
415+
log.debug("Find JAR URL: " + url);
415416

416417
// If the file part of the URL is itself a URL, then that URL probably points to the JAR
417418
try {
418419
for (; ;) {
419420
url = new URL(url.getFile());
420-
log.trace("Inner URL: " + url);
421+
log.debug("Inner URL: " + url);
421422
}
422423
}
423424
catch (MalformedURLException e) {
@@ -429,9 +430,9 @@ protected URL findJarForResource(URL url, String path) throws MalformedURLExcept
429430
int index = jarUrl.lastIndexOf(".jar");
430431
if (index >= 0) {
431432
jarUrl.setLength(index + 4);
432-
log.trace("Extracted JAR URL: " + jarUrl);
433+
log.debug("Extracted JAR URL: " + jarUrl);
433434
} else {
434-
log.trace("Not a JAR: " + jarUrl);
435+
log.debug("Not a JAR: " + jarUrl);
435436
return null;
436437
}
437438

@@ -442,7 +443,7 @@ protected URL findJarForResource(URL url, String path) throws MalformedURLExcept
442443
return testUrl;
443444
} else {
444445
// WebLogic fix: check if the URL's file exists in the filesystem.
445-
log.trace("Not a JAR: " + jarUrl);
446+
log.debug("Not a JAR: " + jarUrl);
446447
jarUrl.replace(0, jarUrl.length(), testUrl.getFile());
447448
File file = new File(jarUrl.toString());
448449

@@ -452,7 +453,7 @@ protected URL findJarForResource(URL url, String path) throws MalformedURLExcept
452453
// }
453454

454455
if (file.exists()) {
455-
log.trace("Trying real file: " + file.getAbsolutePath());
456+
log.debug("Trying real file: " + file.getAbsolutePath());
456457
testUrl = file.toURI().toURL();
457458
if (isJar(testUrl)) {
458459
return testUrl;
@@ -464,7 +465,7 @@ protected URL findJarForResource(URL url, String path) throws MalformedURLExcept
464465
log.warn("Invalid JAR URL: " + jarUrl);
465466
}
466467

467-
log.trace("Not a JAR: " + jarUrl);
468+
log.debug("Not a JAR: " + jarUrl);
468469
return null;
469470
}
470471

@@ -544,7 +545,7 @@ protected void addIfMatching(Test test, String fqn) {
544545
try {
545546
String externalName = fqn.substring(0, fqn.indexOf('.')).replace('/', '.');
546547
ClassLoader loader = getClassLoader();
547-
log.trace("Checking to see if class " + externalName + " matches criteria [" + test + "]");
548+
log.debug("Checking to see if class " + externalName + " matches criteria [" + test + "]");
548549

549550
Class type = loader.loadClass(externalName);
550551
if (test.matches(type)) {

0 commit comments

Comments
 (0)