Class MemoryMappedArchive
- java.lang.Object
-
- com.sun.enterprise.deployment.deploy.shared.JarArchive
-
- com.sun.enterprise.deployment.deploy.shared.MemoryMappedArchive
-
- All Implemented Interfaces:
Archive,ReadableArchive
@Service @PerLookup public class MemoryMappedArchive extends JarArchive implements ReadableArchive
- Author:
- Jerome Dochez
-
-
Field Summary
-
Fields inherited from class com.sun.enterprise.deployment.deploy.shared.JarArchive
archiveMetaData, extraData, parentArchive
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMemoryMappedArchive()Creates a new instance of MemoryMappedArchiveMemoryMappedArchive(byte[] bits)MemoryMappedArchive(InputStream is)Creates a new instance of MemoryMappedArchiveMemoryMappedArchive(ReadableArchive source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close the abstract archivebooleandelete()delete the archiveEnumerationentries()Returns an enumeration of the module file 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 archivebyte[]getByteArray()Collection<String>getDirectories()Returns the enumeration of first level directories in this archiveInputStreamgetEntry(String name)Returns the InputStream for the given entry name The file name must be relative to the root of the module.longgetEntrySize(String name)Returns the entry size for a given entry name or 0 if not knownJarEntrygetJarEntry(String name)ManifestgetManifest()Returns the manifest information for this archiveStringgetName()Returns the name for the archive.StringgetPath()ReadableArchivegetSubArchive(String name)create or obtain an embedded archive within this abstraction.URIgetURI()Returns the path used to create or open the underlying archivevoidopen(URI uri)Open an abstract archivebooleanrenameTo(String name)rename the archivevoidsetURI(URI uri)-
Methods inherited from class com.sun.enterprise.deployment.deploy.shared.JarArchive
addArchiveMetaData, entries, getArchiveMetaData, getExtraData, getParentArchive, isDirectory, removeArchiveMetaData, removeExtraData, setExtraData, setParentArchive
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.glassfish.api.deployment.archive.Archive
entries, isDirectory
-
Methods inherited from interface org.glassfish.api.deployment.archive.ReadableArchive
addArchiveMetaData, getArchiveMetaData, getExtraData, getParentArchive, removeArchiveMetaData, removeExtraData, setExtraData, setParentArchive
-
-
-
-
Constructor Detail
-
MemoryMappedArchive
protected MemoryMappedArchive()
Creates a new instance of MemoryMappedArchive
-
MemoryMappedArchive
public MemoryMappedArchive(InputStream is) throws IOException
Creates a new instance of MemoryMappedArchive- Throws:
IOException
-
MemoryMappedArchive
public MemoryMappedArchive(byte[] bits)
-
MemoryMappedArchive
public MemoryMappedArchive(ReadableArchive source) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getByteArray
public byte[] getByteArray()
-
open
public void open(URI uri) throws IOException
Description copied from interface:ReadableArchiveOpen an abstract archive- Specified by:
openin interfaceReadableArchive- Parameters:
uri- path to the archive- Throws:
IOException
-
close
public void close() throws IOExceptionclose the abstract archive- Specified by:
closein interfaceArchive- Throws:
IOException
-
delete
public boolean delete()
delete the archive- Specified by:
deletein interfaceReadableArchive
-
entries
public Enumeration entries()
Description copied from interface:ArchiveReturns an enumeration of the module file entries. All elements in the enumeration are of type String. Each String represents a file name relative to the root of the module.
-
getDirectories
public Collection<String> getDirectories() throws IOException
Description copied from interface:ArchiveReturns the enumeration of first level directories in this archive- Specified by:
getDirectoriesin interfaceArchive- Returns:
- enumeration of directories under the root of this archive
- Throws:
IOException
-
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
-
exists
public boolean exists()
- Specified by:
existsin interfaceReadableArchive- Returns:
- true if this archive exists
-
getPath
public String getPath()
- Returns:
- the archive uri
-
getArchiveSize
public long getArchiveSize() throws NullPointerException, SecurityExceptionGet the size of the archive- Specified by:
getArchiveSizein interfaceArchive- Returns:
- tje the size of this archive or -1 on error
- Throws:
NullPointerExceptionSecurityException
-
getURI
public URI getURI()
Description copied from interface:ArchiveReturns the path used to create or open the underlying archiveTODO: abstraction breakage: Several callers, most notably
DeploymentContext.getSourceDir()implementation, assumes that this URI is an URL, and in fact file URL.If this needs to be URL, use of
URIis misleading. And furthermore, if its needs to be a file URL, this should beFile.
-
setURI
public void setURI(URI uri)
-
getSubArchive
public ReadableArchive getSubArchive(String name) throws IOException
create or obtain an embedded archive within this abstraction.- Specified by:
getSubArchivein interfaceReadableArchive- Parameters:
name- the name of the embedded archive.- Returns:
- the Archive instance for this abstraction, or null if no such entry exists.
- Throws:
IOException
-
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 interfaceReadableArchive- Overrides:
existsin classJarArchive- Parameters:
name- the file name relative to the root of the module.- Returns:
- the existence the given entry name.
- Throws:
IOException
-
getEntry
public InputStream getEntry(String name) throws IOException
Description copied from interface:ReadableArchiveReturns the InputStream for the given entry name The file name must be relative to the root of the module.- Specified by:
getEntryin interfaceReadableArchive- Parameters:
name- the entry name- Returns:
- a @see java.io.InputStream for an existing entry in the current abstract archive
- Throws:
IOException
-
getJarEntry
public JarEntry getJarEntry(String name)
- Specified by:
getJarEntryin classJarArchive
-
getEntrySize
public long getEntrySize(String name)
Returns the entry size for a given entry name or 0 if not known- Specified by:
getEntrySizein interfaceReadableArchive- Parameters:
name- the entry name- Returns:
- the entry size
-
getManifest
public Manifest getManifest() throws IOException
Description copied from interface:ArchiveReturns the manifest information for this archive- Specified by:
getManifestin interfaceArchive- Returns:
- the manifest information for this abstract archive
- Throws:
IOException
-
renameTo
public boolean renameTo(String name)
rename the archive- Specified by:
renameToin interfaceReadableArchive- Parameters:
name- the archive name
-
getName
public String getName()
Returns the name for the archive.For a MemoryMappedArhive there is no name, so an empty string is returned.
- Specified by:
getNamein interfaceArchive- Overrides:
getNamein classJarArchive- Returns:
- the name of the archive
-
-