|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.enterprise.deploy.shared.AbstractReadableArchive
com.sun.enterprise.deploy.shared.FileArchive
@Service(name="file") @Scoped(value=org.jvnet.hk2.component.PerLookup.class) public class FileArchive
This implementation of the Archive interface maps to a directory/file structure.
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.
| Nested Class Summary | |
|---|---|
static interface |
FileArchive.StaleFileManager
API which FileArchive methods should use for dealing with the StaleFileManager implementation. |
| Field Summary |
|---|
| Fields inherited from class com.sun.enterprise.deploy.shared.AbstractReadableArchive |
|---|
extraData, parentArchive |
| Constructor Summary | |
|---|---|
FileArchive()
|
|
| Method Summary | |
|---|---|
void |
close()
close the abstract archive |
void |
closeEntry()
Closes the current entry |
void |
closeEntry(WritableArchive subArchive)
Close a previously returned sub archive |
void |
create(java.net.URI uri)
creates a new abstract archive with the given path |
WritableArchive |
createSubArchive(java.lang.String name)
create or obtain an embedded archive within this abstraction. |
boolean |
delete()
delete the archive |
boolean |
deleteEntry(java.lang.String name)
delete an entry in the archive |
java.util.Enumeration |
entries()
|
java.util.Enumeration |
entries(java.util.Enumeration embeddedArchives)
|
java.util.Enumeration<java.lang.String> |
entries(java.lang.String prefix)
Returns an enumeration of the module file entries with the specified prefix. |
boolean |
exists()
|
boolean |
exists(java.lang.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 |
java.util.Collection<java.lang.String> |
getDirectories()
Returns the enumeration of first level directories in this archive |
java.io.InputStream |
getEntry(java.lang.String name)
|
long |
getEntrySize(java.lang.String name)
Returns the entry size for a given entry name or 0 if not known |
java.util.jar.Manifest |
getManifest()
|
java.lang.String |
getName()
Returns the name portion of the archive's URI. |
ReadableArchive |
getSubArchive(java.lang.String name)
create or obtain an embedded archive within this abstraction. |
java.net.URI |
getURI()
Returns the URI used to create or open the underlyong archive |
boolean |
isDirectory(java.lang.String name)
|
void |
open(java.lang.String uri)
|
void |
open(java.net.URI uri)
Open an abstract archive |
java.io.OutputStream |
putNextEntry(java.lang.String name)
|
boolean |
renameTo(java.lang.String name)
rename the archive |
boolean |
supportsElementsOverwriting()
|
| Methods inherited from class com.sun.enterprise.deploy.shared.AbstractReadableArchive |
|---|
getExtraData, getParentArchive, removeExtraData, setExtraData, setParentArchive |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileArchive()
| Method Detail |
|---|
public void open(java.net.URI uri)
throws java.io.IOException
open in interface ReadableArchiveuri - path to the archive
java.io.IOException
public void open(java.lang.String uri)
throws java.io.IOException
uri - a string representing URI
java.io.IOExceptionopen(URI)
public long getArchiveSize()
throws java.lang.NullPointerException,
java.lang.SecurityException
getArchiveSize in interface Archivejava.lang.NullPointerException
java.lang.SecurityException
public void create(java.net.URI uri)
throws java.io.IOException
create in interface WritableArchiveuri - path to create the archive
java.io.IOException
public void closeEntry(WritableArchive subArchive)
throws java.io.IOException
closeEntry in interface WritableArchivesubArchive - output stream to close
java.io.IOException
public void close()
throws java.io.IOException
close in interface Archivejava.io.IOExceptionpublic boolean delete()
delete in interface ReadableArchivepublic boolean isDirectory(java.lang.String name)
isDirectory in interface Archivepublic java.util.Enumeration entries()
entries in interface Archive
public java.util.Collection<java.lang.String> getDirectories()
throws java.io.IOException
getDirectories in interface Archivejava.io.IOExceptionpublic java.util.Enumeration entries(java.util.Enumeration embeddedArchives)
public java.util.Enumeration<java.lang.String> entries(java.lang.String prefix)
entries in interface Archiveprefix - the prefix of entries to be included
public boolean exists()
exists in interface ReadableArchive
public ReadableArchive getSubArchive(java.lang.String name)
throws java.io.IOException
getSubArchive in interface ReadableArchivename - name of the embedded archive.
java.io.IOException
public WritableArchive createSubArchive(java.lang.String name)
throws java.io.IOException
createSubArchive in interface WritableArchivename - name of the embedded archive.
java.io.IOException
public boolean exists(java.lang.String name)
throws java.io.IOException
exists in interface ReadableArchivename - the file name relative to the root of the module.
java.io.IOException
public java.io.InputStream getEntry(java.lang.String name)
throws java.io.IOException
getEntry in interface ReadableArchivename - the entry name
java.io.IOExceptionpublic long getEntrySize(java.lang.String name)
getEntrySize in interface ReadableArchivename - the entry name
public java.util.jar.Manifest getManifest()
throws java.io.IOException
getManifest in interface Archivejava.io.IOExceptionpublic java.net.URI getURI()
getURI in interface Archivepublic boolean renameTo(java.lang.String name)
renameTo in interface ReadableArchivename - the archive namepublic boolean supportsElementsOverwriting()
public boolean deleteEntry(java.lang.String name)
name - the entry name
public void closeEntry()
throws java.io.IOException
closeEntry in interface WritableArchivejava.io.IOException
public java.io.OutputStream putNextEntry(java.lang.String name)
throws java.io.IOException
putNextEntry in interface WritableArchivename - the entry name
java.io.IOExceptionpublic java.lang.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 Archive
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||