1 22 package org.jboss.virtual.plugins.context.jar; 23 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.net.URL ; 27 import java.util.List ; 28 import java.util.jar.JarEntry ; 29 import java.util.jar.JarFile ; 30 import java.util.zip.ZipInputStream ; 31 32 import org.jboss.virtual.spi.VFSContext; 33 import org.jboss.virtual.spi.VirtualFileHandler; 34 35 41 public class NoCopyNestedJarHandler extends AbstractJarHandler 42 { 43 44 private static final long serialVersionUID = 1L; 45 46 47 private transient JarEntry entry; 48 private NestedJarFromStream njar; 49 50 61 public NoCopyNestedJarHandler(VFSContext context, VirtualFileHandler parent, JarFile parentJar, JarEntry entry, URL url) throws IOException 62 { 63 super(context, parent, url, getEntryName(entry)); 64 65 66 try 67 { 68 InputStream is = parentJar.getInputStream(entry); 69 ZipInputStream jis; 70 if( (is instanceof ZipInputStream ) ) 71 { 72 jis = (ZipInputStream ) is; 73 } 74 else 75 { 76 jis = new ZipInputStream (is); 77 } 78 njar = new NestedJarFromStream(context, parent, jis, url, entry); 79 } 80 catch (IOException original) 81 { 82 IOException e = new IOException ("Error opening jar file: " + url + " reason=" + original.getMessage()); 84 e.setStackTrace(original.getStackTrace()); 85 throw e; 86 } 87 88 this.entry = entry; 89 } 90 91 96 protected JarEntry getEntry() 97 { 98 checkClosed(); 99 return entry; 100 } 101 102 @Override 103 public long getLastModified() throws IOException 104 { 105 return getEntry().getTime(); 106 } 107 108 @Override 109 public long getSize() throws IOException 110 { 111 return getEntry().getSize(); 112 } 113 114 @Override 115 public InputStream openStream() throws IOException 116 { 117 return getJar().getInputStream(getEntry()); 118 } 119 120 @Override 121 public VirtualFileHandler findChild(String path) throws IOException 122 { 123 return njar.findChild(path); 124 } 125 126 @Override 127 public List <VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException 128 { 129 return super.getChildren(ignoreErrors); 131 } 132 133 } 134 | Popular Tags |