@Service(name="file") @PerLookup public class FileArchive extends AbstractReadableArchive implements org.glassfish.api.deployment.archive.WritableArchive
If the directory underlying the FileArchive is created by GlassFish then FileArchive filters its contents so only those files more recent than the creation of the archive itself are visible to consumers.
The main motivation is to hide unwanted "left-over" files from previous deployments that might linger, especially on Windows, after the previous app had been undeployed. (Deployment uses a FileArchive to extract the user's JAR-based archive into the applications directory.) Historically such left-over files arise after GlassFish expands an archive into its exploded form but then some code opens but does not close a file in that exploded directory tree.
An open left-over file can be overwritten-in-place on Windows, and
this happens when a caller invokes putNextEntry(java.lang.String)
to create a new entry (file) inside the archive. But a
left-over file that is not in the new app but is
still open by GlassFish cannot be deleted or renamed on Windows and so it will
remain in the expansion directory. Such left-over files, if not filtered out,
can confuse GlassFish and the application. By "stamping" the archive
creation date we can filter out such old, left-over files.
To support this feature, when FileArchive creates a directory it stores a marker file there, the contents of which records the creation date/time of the archive. We cannot just use the lastModified value for the top-level directory. Users might legitimately use "touch .reload" in the applications/appName directory to trigger a dynamic reload of the app. If .reload does not already exist then touch creates it, and this would update the lastModified of the directory file.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FileArchive.StaleFileManager
API which FileArchive methods should use for dealing with the StaleFileManager
implementation.
|
| Modifier and Type | Field and Description |
|---|---|
static Logger |
deplLogger |
archiveMetaData, extraData, parentArchive| Constructor and Description |
|---|
FileArchive() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
close the abstract archive
|
void |
closeEntry()
Closes the current entry
|
void |
closeEntry(org.glassfish.api.deployment.archive.WritableArchive subArchive)
Close a previously returned sub archive
|
void |
create(URI uri)
creates a new abstract archive with the given path
|
org.glassfish.api.deployment.archive.WritableArchive |
createSubArchive(String name)
create or obtain an embedded archive within this abstraction.
|
boolean |
delete()
delete the archive
|
boolean |
deleteEntry(String name)
delete an entry in the archive
|
Enumeration |
entries() |
Enumeration |
entries(Enumeration embeddedArchives) |
Enumeration<String> |
entries(String prefix)
Returns an enumeration of the module file entries with the
specified prefix.
|
boolean |
exists() |
boolean |
exists(String name)
Returns the existence of the given entry name
The file name must be relative to the root of the module.
|
long |
getArchiveSize()
Get the size of the archive
|
Collection<String> |
getDirectories()
Returns the enumeration of first level directories in this
archive
|
InputStream |
getEntry(String name) |
long |
getEntrySize(String name)
Returns the entry size for a given entry name or 0 if not known
|
Manifest |
getManifest() |
String |
getName()
Returns the name portion of the archive's URI.
|
org.glassfish.api.deployment.archive.ReadableArchive |
getSubArchive(String name)
create or obtain an embedded archive within this abstraction.
|
URI |
getURI()
Returns the URI used to create or open the underlyong archive
|
boolean |
isDirectory(String name) |
void |
open(String uri) |
void |
open(URI uri)
Open an abstract archive
|
OutputStream |
putNextEntry(String name) |
boolean |
renameTo(String name)
rename the archive
|
boolean |
supportsElementsOverwriting() |
addArchiveMetaData, getArchiveMetaData, getExtraData, getParentArchive, removeArchiveMetaData, removeExtraData, setExtraData, setParentArchivepublic static final Logger deplLogger
public void open(URI uri) throws IOException
open in interface org.glassfish.api.deployment.archive.ReadableArchiveuri - path to the archiveIOExceptionpublic void open(String uri) throws IOException
uri - a string representing URIIOExceptionopen(URI)public long getArchiveSize()
throws NullPointerException,
SecurityException
getArchiveSize in interface org.glassfish.api.deployment.archive.ArchiveNullPointerExceptionSecurityExceptionpublic void create(URI uri) throws IOException
create in interface org.glassfish.api.deployment.archive.WritableArchiveuri - path to create the archiveIOExceptionpublic void closeEntry(org.glassfish.api.deployment.archive.WritableArchive subArchive)
throws IOException
closeEntry in interface org.glassfish.api.deployment.archive.WritableArchivesubArchive - output stream to closeIOExceptionpublic void close()
throws IOException
close in interface org.glassfish.api.deployment.archive.ArchiveIOExceptionpublic boolean delete()
delete in interface org.glassfish.api.deployment.archive.ReadableArchivepublic boolean isDirectory(String name)
isDirectory in interface org.glassfish.api.deployment.archive.Archivepublic Enumeration entries()
entries in interface org.glassfish.api.deployment.archive.Archivepublic Collection<String> getDirectories() throws IOException
getDirectories in interface org.glassfish.api.deployment.archive.ArchiveIOExceptionpublic Enumeration entries(Enumeration embeddedArchives)
public Enumeration<String> entries(String prefix)
entries in interface org.glassfish.api.deployment.archive.Archiveprefix - the prefix of entries to be includedpublic boolean exists()
exists in interface org.glassfish.api.deployment.archive.ReadableArchivepublic org.glassfish.api.deployment.archive.ReadableArchive getSubArchive(String name) throws IOException
getSubArchive in interface org.glassfish.api.deployment.archive.ReadableArchivename - name of the embedded archive.IOExceptionpublic org.glassfish.api.deployment.archive.WritableArchive createSubArchive(String name) throws IOException
createSubArchive in interface org.glassfish.api.deployment.archive.WritableArchivename - name of the embedded archive.IOExceptionpublic boolean exists(String name) throws IOException
exists in interface org.glassfish.api.deployment.archive.ReadableArchivename - the file name relative to the root of the module.IOExceptionpublic InputStream getEntry(String name) throws IOException
getEntry in interface org.glassfish.api.deployment.archive.ReadableArchivename - the entry nameIOExceptionpublic long getEntrySize(String name)
getEntrySize in interface org.glassfish.api.deployment.archive.ReadableArchivename - the entry namepublic Manifest getManifest() throws IOException
getManifest in interface org.glassfish.api.deployment.archive.ArchiveIOExceptionpublic URI getURI()
getURI in interface org.glassfish.api.deployment.archive.Archivepublic boolean renameTo(String name)
renameTo in interface org.glassfish.api.deployment.archive.ReadableArchivename - the archive namepublic boolean supportsElementsOverwriting()
public boolean deleteEntry(String name)
name - the entry namepublic void closeEntry()
throws IOException
closeEntry in interface org.glassfish.api.deployment.archive.WritableArchiveIOExceptionpublic OutputStream putNextEntry(String name) throws IOException
putNextEntry in interface org.glassfish.api.deployment.archive.WritableArchivename - the entry nameIOExceptionpublic String getName()
For FileArhive the name is all of the path that follows the last slash (ignoring a slash at the end of the path).
Here are some example archive names for the specified FileArchive paths:
getName in interface org.glassfish.api.deployment.archive.ArchiveCopyright © 2013. All Rights Reserved.