1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 import java.util.jar.*; 38 39 import org.apache.log4j.*; 40 41 public class JarClassfileLoader extends ZipClassfileLoader { 42 public JarClassfileLoader(ClassfileLoader loader) { 43 super(loader); 44 } 45 46 protected void load(String filename) { 47 Logger.getLogger(getClass()).debug("Reading " + filename); 48 49 JarFile jarfile = null; 50 try { 51 jarfile = new JarFile(filename); 52 53 fireBeginGroup(filename, jarfile.size()); 54 load(jarfile); 55 fireEndGroup(filename); 56 } catch (IOException ex) { 57 Logger.getLogger(getClass()).error("Cannot load JAR file \"" + filename + "\"", ex); 58 } finally { 59 if (jarfile != null) { 60 try { 61 jarfile.close(); 62 } catch (IOException ex) { 63 } 65 } 66 } 67 } 68 69 protected void load(String filename, InputStream in) { 70 Logger.getLogger(getClass()).debug("Reading " + filename); 71 72 JarInputStream jarfile = null; 73 try { 74 jarfile = new JarInputStream(in); 75 76 fireBeginGroup(filename, -1); 77 load(jarfile); 78 fireEndGroup(filename); 79 } catch (IOException ex) { 80 Logger.getLogger(getClass()).error("Cannot load JAR file \"" + filename + "\"", ex); 81 } finally { 82 if (jarfile != null) { 83 try { 84 jarfile.close(); 85 } catch (IOException ex) { 86 } 88 } 89 } 90 } 91 } 92 | Popular Tags |