1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 38 import org.apache.log4j.*; 39 40 public class DirectoryClassfileLoader extends ClassfileLoaderDecorator { 41 public DirectoryClassfileLoader(ClassfileLoader loader) { 42 super(loader); 43 } 44 45 protected void load(String filename) { 46 Logger.getLogger(getClass()).debug("Starting group from path \"" + filename + "\""); 47 48 try { 49 DirectoryExplorer explorer = new DirectoryExplorer(filename); 50 51 fireBeginGroup(filename, explorer.getCollection().size()); 52 53 Iterator i = explorer.getCollection().iterator(); 54 while (i.hasNext()) { 55 File file = (File) i.next(); 56 57 fireBeginFile(file.getPath()); 58 59 Logger.getLogger(getClass()).debug("Starting file \"" + file.getPath() + "\" (" + file.length() + " bytes)"); 60 61 if (!file.isDirectory()) { 62 try { 66 InputStream in = new FileInputStream(file); 67 getLoader().load(file.getPath(), in); 68 in.close(); 69 } catch (IOException ex) { 70 Logger.getLogger(getClass()).error("Cannot load file \"" + file.getPath() + "\"", ex); 71 } 72 } 73 74 fireEndFile(file.getPath()); 75 } 76 } catch (IOException ex) { 77 Logger.getLogger(getClass()).error("Cannot load group \"" + filename + "\"", ex); 78 } finally { 79 fireEndGroup(filename); 80 } 81 } 82 83 protected void load(String filename, InputStream in) { 84 } 86 } 87 | Popular Tags |