FileDocCategorySizeDatePackage
DirectoryInsideJarURLArchive.javaAPI DocGlassfish v2 API5079Thu Jul 26 10:51:00 BST 2007oracle.toplink.essentials.ejb.cmp3.persistence

DirectoryInsideJarURLArchive

public class DirectoryInsideJarURLArchive extends Object implements Archive
This is an implementation of {@link Archive} which is used when container returns a jar: URL. e.g. jar:file:/tmp/a_ear/b.war!/WEB-INF/classes/
author
Sanjeeb.Sahoo@Sun.COM

Fields Summary
private JarFile
jarFile
private URL
rootURL
private String
relativeRootPath
private List
entries
private Logger
logger
Constructors Summary
public DirectoryInsideJarURLArchive(URL url)


         
        this(url, Logger.global);
    
public DirectoryInsideJarURLArchive(URL url, Logger logger)

        logger.entering("DirectoryInsideJarURLArchive", "DirectoryInsideJarURLArchive",  // NOI18N
                new Object[]{url});
        this.logger = logger;
        assert(url.getProtocol().equals("jar")); // NOI18N
        rootURL = url;
        JarURLConnection conn =
                JarURLConnection.class.cast(url.openConnection());
        jarFile = conn.getJarFile();
        logger.logp(Level.FINER, "DirectoryInsideJarURLArchive",
                "DirectoryInsideJarURLArchive", "jarFile = {0}", jarFile);
        relativeRootPath = conn.getEntryName();
        init();
    
Methods Summary
public java.util.IteratorgetEntries()

        return entries.iterator();
    
public java.io.InputStreamgetEntry(java.lang.String entryPath)

        InputStream is = entries.contains(entryPath) ?
            jarFile.getInputStream(jarFile.getEntry(relativeRootPath + entryPath)) : null;
        return is;
    
public java.net.URLgetEntryAsURL(java.lang.String entryPath)

        URL result = entries.contains(entryPath) ?
            new URL("jar:"+rootURL+"!/"+ relativeRootPath + entryPath) : null; // NOI18N
        return result;
    
public java.net.URLgetRootURL()

        return rootURL;
    
private voidinit()

        for(Enumeration<JarEntry> jarEntries = jarFile.entries();
            jarEntries.hasMoreElements();) {
            JarEntry jarEntry = jarEntries.nextElement();
            if(jarEntry.isDirectory()) {
                continue;
            }
            String jarEntryName = jarEntry.getName();
            if (relativeRootPath==null) {
                entries.add(jarEntryName);
            } else if (jarEntryName.startsWith(relativeRootPath)) {
                entries.add(jarEntryName.substring(relativeRootPath.length()));
            }
        }