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

JarInputStreamURLArchive

public class JarInputStreamURLArchive extends Object implements Archive
This is an implementation of {@link Archive} which is used when container returns some form of URL from which an InputStream in jar format can be obtained. e.g. jar:file:/tmp/a_ear/b.war!/WEB-INF/lib/pu.jar
author
Sanjeeb.Sahoo@Sun.COM

Fields Summary
private URL
url
private List
entries
private Logger
logger
Constructors Summary
public JarInputStreamURLArchive(URL url)


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

        logger.entering("JarInputStreamURLArchive", "JarInputStreamURLArchive", // NOI18N
                new Object[]{url});
        this.logger = logger;
        this.url = url;
        init();
    
Methods Summary
public java.util.IteratorgetEntries()

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

        if (!entries.contains(entryPath)) {
            return null;
        }
        JarInputStream jis = new JarInputStream(
                new BufferedInputStream(url.openStream()));
        do {
            ZipEntry ze = jis.getNextEntry();
            if (ze == null) {
                break;
            }
            if (ze.getName().equals(entryPath)) {
                return jis;
            }
        } while (true);

        // don't close the stream, as the caller has to read from it.

        assert(false); // should not reach here
        return null;
    
public java.net.URLgetEntryAsURL(java.lang.String entryPath)

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

        return url;
    
private voidinit()

        JarInputStream jis = new JarInputStream(
                new BufferedInputStream(url.openStream()));
        try {
            do {
                ZipEntry ze = jis.getNextEntry();
                if (ze == null) {
                    break;
                }
                if (!ze.isDirectory()) {
                    entries.add(ze.getName());
                }
            } while (true);
        } finally {
            jis.close();
        }