1 22 package org.jboss.virtual.plugins.context.jar; 23 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.net.JarURLConnection ; 27 import java.net.URL ; 28 29 import org.jboss.virtual.spi.VFSContext; 30 import org.jboss.virtual.spi.VirtualFileHandler; 31 32 38 public class JarHandler extends AbstractJarHandler 39 { 40 41 private static final long serialVersionUID = 1L; 42 43 53 public JarHandler(VFSContext context, VirtualFileHandler parent, URL url, String name) throws IOException 54 { 55 super(context, parent, url, name); 56 57 try 58 { 59 JarURLConnection connection = (JarURLConnection ) url.openConnection(); 60 initJarFile(connection.getJarFile()); 61 } 62 catch (IOException original) 63 { 64 IOException e = new IOException ("Error opening jar file: " + url + " reason=" + original.getMessage()); 66 e.setStackTrace(original.getStackTrace()); 67 throw e; 68 } 69 } 70 71 76 @Override 77 public InputStream openStream() throws IOException 78 { 79 checkClosed(); 80 String jarURL = getURL().toString(); 81 String underlyingURL = jarURL.substring(4, jarURL.length()-2); 82 URL realURL = new URL (underlyingURL); 83 InputStream is = realURL.openStream(); 84 return is; 85 } 86 } 87 | Popular Tags |