Class InputJarArchive
- java.lang.Object
-
- com.sun.enterprise.deployment.deploy.shared.JarArchive
-
- com.sun.enterprise.deployment.deploy.shared.InputJarArchive
-
- All Implemented Interfaces:
org.glassfish.api.deployment.archive.Archive,org.glassfish.api.deployment.archive.ReadableArchive
@Service(name="jar") @PerLookup public class InputJarArchive extends JarArchive implements org.glassfish.api.deployment.archive.ReadableArchive
This implementation of the Archive deal with reading jar files either from a JarFile or from a JarInputStream- Author:
- Jerome Dochez
-
-
Field Summary
Fields Modifier and Type Field Description static LoggerdeplLoggerprotected JarFilejarFileprotected JarInputStreamjarIS-
Fields inherited from class com.sun.enterprise.deployment.deploy.shared.JarArchive
archiveMetaData, extraData
-
-
Constructor Summary
Constructors Constructor Description InputJarArchive()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputStreamaddEntry(String name)voidclose()close the abstract archivevoidcreate(URI uri)creates a new abstract archive with the given pathbooleandelete()deletes the underlying jar fileEnumeration<String>entries()Enumerationentries(Enumeration embeddedArchives)booleanexists()booleanexists(String name)Returns the existence of the given entry name The file name must be relative to the root of the module.longgetArchiveSize()Get the size of the archiveCollection<String>getDirectories()Returns the collection of first level directories in this archive.InputStreamgetEntry(String entryName)longgetEntrySize(String name)Returns the entry size for a given entry name or 0 if not knownJarEntrygetJarEntry(String name)protected static JarFilegetJarFile(URI uri)ManifestgetManifest()org.glassfish.api.deployment.archive.ReadableArchivegetSubArchive(String name)URIgetURI()Returns the path used to create or open the underlying archivevoidopen(URI uri)Open an abstract archivebooleanrenameTo(String name)rename the underlying jar file-
Methods inherited from class com.sun.enterprise.deployment.deploy.shared.JarArchive
addArchiveMetaData, entries, getArchiveMetaData, getExtraData, getName, getParentArchive, isDirectory, removeArchiveMetaData, removeExtraData, setExtraData, setParentArchive
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
deplLogger
public static final Logger deplLogger
-
jarFile
protected volatile JarFile jarFile
-
jarIS
protected volatile JarInputStream jarIS
-
-
Method Detail
-
getArchiveSize
public long getArchiveSize() throws NullPointerException, SecurityExceptionGet the size of the archive- Specified by:
getArchiveSizein interfaceorg.glassfish.api.deployment.archive.Archive- Returns:
- tje the size of this archive or -1 on error
- Throws:
NullPointerExceptionSecurityException
-
addEntry
public OutputStream addEntry(String name) throws IOException
- Parameters:
name- the entry name- Returns:
- an @see java.io.OutputStream for a new entry in this current abstract archive.
- Throws:
IOException
-
close
public void close() throws IOExceptionclose the abstract archive- Specified by:
closein interfaceorg.glassfish.api.deployment.archive.Archive- Throws:
IOException
-
getDirectories
public Collection<String> getDirectories() throws IOException
Returns the collection of first level directories in this archive.Avoid having to fetch all the entries if we can avoid it. The only time we must do that is if size() is invoked on the collection. Use the CollectionWrappedEnumeration for this optimization which will create a full in-memory list of the entries only if and when needed to satisfy the size() method.
- Specified by:
getDirectoriesin interfaceorg.glassfish.api.deployment.archive.Archive- Returns:
- collection of directories under the root of this archive
- Throws:
IOException
-
create
public void create(URI uri) throws IOException
creates a new abstract archive with the given path- Parameters:
uri- the path to create the archive- Throws:
IOException
-
entries
public Enumeration<String> entries()
- Specified by:
entriesin interfaceorg.glassfish.api.deployment.archive.Archive
-
entries
public Enumeration entries(Enumeration embeddedArchives)
- Returns:
- an @see java.util.Enumeration of entries in this abstract archive, providing the list of embedded archive to not count their entries as part of this archive
-
getJarEntry
public JarEntry getJarEntry(String name)
- Specified by:
getJarEntryin classJarArchive
-
exists
public boolean exists(String name) throws IOException
Returns the existence of the given entry name The file name must be relative to the root of the module.- Specified by:
existsin interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Overrides:
existsin classJarArchive- Parameters:
name- the file name relative to the root of the module. * @return the existence the given entry name.- Throws:
IOException
-
getEntry
public InputStream getEntry(String entryName) throws IOException
- Specified by:
getEntryin interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Parameters:
entryName- entry name- Returns:
- a @see java.io.InputStream for an existing entry in the current abstract archive
- Throws:
IOException
-
getEntrySize
public long getEntrySize(String name)
Returns the entry size for a given entry name or 0 if not known- Specified by:
getEntrySizein interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Parameters:
name- the entry name- Returns:
- the entry size
-
open
public void open(URI uri) throws IOException
Open an abstract archive- Specified by:
openin interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Parameters:
uri- the path to the archive- Throws:
IOException
-
getJarFile
protected static JarFile getJarFile(URI uri) throws IOException
- Returns:
- a JarFile instance for a file path
- Throws:
IOException
-
getManifest
public Manifest getManifest() throws IOException
- Specified by:
getManifestin interfaceorg.glassfish.api.deployment.archive.Archive- Returns:
- the manifest information for this abstract archive
- Throws:
IOException
-
getURI
public URI getURI()
Returns the path used to create or open the underlying archive- Specified by:
getURIin interfaceorg.glassfish.api.deployment.archive.Archive- Returns:
- the path for this archive.
-
exists
public boolean exists()
- Specified by:
existsin interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Returns:
- true if this abstract archive maps to an existing jar file
-
delete
public boolean delete()
deletes the underlying jar file- Specified by:
deletein interfaceorg.glassfish.api.deployment.archive.ReadableArchive
-
renameTo
public boolean renameTo(String name)
rename the underlying jar file- Specified by:
renameToin interfaceorg.glassfish.api.deployment.archive.ReadableArchive
-
getSubArchive
public org.glassfish.api.deployment.archive.ReadableArchive getSubArchive(String name) throws IOException
- Specified by:
getSubArchivein interfaceorg.glassfish.api.deployment.archive.ReadableArchive- Returns:
- an Archive for an embedded archive indentified with the name parameter
- Throws:
IOException
-
-