|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.ArchiveController
de.schlichtherle.io.ArchiveFileSystemController
de.schlichtherle.io.UpdatingArchiveController
final class UpdatingArchiveController
This archive controller implements the mounting/unmounting strategy by performing a full update of the target archive file.
| Nested Class Summary |
|---|
| Field Summary | |
|---|---|
private static String |
CLASS_NAME
|
private InputArchive |
inArchive
An InputArchive object used to mount the virtual file system
and read the entries from the archive file. |
private File |
inFile
The actual archive file as a plain java.io.File object
which serves as the input file for the virtual file system managed
by this ArchiveController object. |
private static Logger |
logger
|
private boolean |
needsReassembly
Whether or not nesting this archive file to its enclosing archive file has been deferred. |
private OutputArchive |
outArchive
The (possibly temporary) OutputArchive we are writing newly
created or modified entries to. |
private File |
outFile
Plain java.io.File object used for temporary output. |
(package private) static String |
TEMP_FILE_PREFIX
Prefix for temporary files created by this class. |
(package private) static String |
TEMP_FILE_SUFFIX
Suffix for temporary files created by this class - should not be null for enhanced unit tests. |
| Fields inherited from interface de.schlichtherle.io.Entry |
|---|
ROOT_NAME, SEPARATOR, SEPARATOR_CHAR |
| Constructor Summary | |
|---|---|
UpdatingArchiveController(File target,
ArchiveController enclController,
String enclEntryName,
ArchiveDriver driver)
|
|
| Method Summary | |
|---|---|
private ArchiveException |
checkNoDeletedEntriesWithNewData(ArchiveException exceptionChain)
|
(package private) InputStream |
createInputStream(ArchiveEntry entry,
ArchiveEntry dstEntry)
Important: This controller's read or write lock must be acquired. |
(package private) OutputStream |
createOutputStream(ArchiveEntry entry,
ArchiveEntry srcEntry)
Important: This controller's write lock must be acquired. |
private void |
ensureOutArchive()
|
(package private) boolean |
hasNewData(String entryName)
Tests if the archive entry with the given name has received or is currently receiving new data via an output stream. |
private void |
initInArchive(File inFile)
Initializes inArchive with a newly created
InputArchive for reading inFile. |
private void |
initOutArchive(File outFile)
Initializes outArchive with a newly created
OutputArchive for writing outFile. |
(package private) void |
mount(boolean autoCreate)
Mounts the virtual file system from the target file. |
private void |
mount0(boolean autoCreate)
|
private ArchiveException |
reassemble(ArchiveException exceptionChain)
Uses the updated output archive file to reassemble the target archive file, which may be an entry in an enclosing archive file. |
(package private) void |
reset()
Resets the archive controller to its initial state - all changes to the archive file which have not yet been updated get lost! |
private ArchiveException |
shutdownStep1(ArchiveException exceptionChain)
Closes and disconnects all entry streams of the output and input archive. |
private void |
shutdownStep2(ArchiveException exceptionChain)
Discards the file system and closes the output and input archive. |
private void |
shutdownStep3(boolean deleteOutFile)
Cleans up temporary files. |
(package private) void |
touch()
Called by this controller's ArchiveFileSystem to notify it
that the file system has been touched. |
(package private) void |
umount(ArchiveException exceptionChain,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams,
boolean umount,
boolean reassemble)
Synchronizes the contents of the target archive file managed by this archive controller to the real file system. |
private void |
umount0(ArchiveException exceptionChain,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams,
boolean umount,
boolean reassemble)
|
private void |
unwrap(ArchiveController controller,
String entryName,
boolean autoCreate)
|
private void |
unwrapFromLockedController(ArchiveController controller,
String entryName,
boolean autoCreate)
|
private ArchiveException |
update(ArchiveException exceptionChain)
Updates all nodes in the virtual file system to the (temporary) output archive file. |
(package private) int |
waitAllInputStreamsByOtherThreads(long timeout)
|
(package private) int |
waitAllOutputStreamsByOtherThreads(long timeout)
|
private void |
wrap(ArchiveController controller,
String entryName)
|
private void |
wrapToWriteLockedController(ArchiveController controller,
String entryName)
|
| Methods inherited from class de.schlichtherle.io.ArchiveFileSystemController |
|---|
autoMount, createArchiveEntry, getFileSystem, isTouched, setFileSystem |
| Methods inherited from class de.schlichtherle.io.ArchiveController |
|---|
autoUmount, canRead, canWrite, createInputStream, createInputStream0, createNewFile, createOutputStream, createOutputStream0, delete, enclEntryName, exists, getClosedIcon, getDriver, getEnclArchive, getEnclController, getEnclEntryName, getOpenIcon, getPath, getTarget, isDirectory, isFile, isRfsEntryTarget, isRoot, lastModified, length, list, list, listFiles, listFiles, mkdir, readLock, runWriteLocked, setDriver, setLastModified, setReadOnly, setScheduled, toString, writeLock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final String CLASS_NAME
private static final Logger logger
static final String TEMP_FILE_PREFIX
static final String TEMP_FILE_SUFFIX
null for enhanced unit tests.
private File inFile
java.io.File object
which serves as the input file for the virtual file system managed
by this ArchiveController object.
Note that this will be set to a tempory file if the archive file is
enclosed within another archive file.
private InputArchive inArchive
InputArchive object used to mount the virtual file system
and read the entries from the archive file.
private File outFile
java.io.File object used for temporary output.
Maybe identical to inFile.
private OutputArchive outArchive
OutputArchive we are writing newly
created or modified entries to.
private boolean needsReassembly
| Constructor Detail |
|---|
UpdatingArchiveController(File target,
ArchiveController enclController,
String enclEntryName,
ArchiveDriver driver)
| Method Detail |
|---|
void mount(boolean autoCreate)
throws IOException
ArchiveFileSystemController
Upon normal termination, this method is expected to have called
ArchiveFileSystemController.ResetFileSystem to assign the fully initialized file system
to this controller.
Other than this, the method must not have any side effects on the
state of this class or its super class.
It may, however, have side effects on the state of the sub class.
mount in class ArchiveFileSystemControllerautoCreate - If the archive file does not exist and this is
true, a new file system with only a virtual root
directory is created with its last modification time set to the
system's current time.
IOException - On any other I/O related issue with the target file
or the target file of any enclosing archive file's controller.
private void mount0(boolean autoCreate)
throws IOException
IOException
private void unwrap(ArchiveController controller,
String entryName,
boolean autoCreate)
throws IOException
IOException
private void unwrapFromLockedController(ArchiveController controller,
String entryName,
boolean autoCreate)
throws IOException
IOException
private void initInArchive(File inFile)
throws IOException
inArchive with a newly created
InputArchive for reading inFile.
IOException - On any I/O related issue with inFile.
InputStream createInputStream(ArchiveEntry entry,
ArchiveEntry dstEntry)
throws IOException
ArchiveControllerentry must not have received
new data.
createInputStream in class ArchiveControllerIOException
OutputStream createOutputStream(ArchiveEntry entry,
ArchiveEntry srcEntry)
throws IOException
ArchiveControllerentry must not have received
new data.
createOutputStream in class ArchiveControllerIOException
void touch()
throws IOException
ArchiveFileSystemControllerArchiveFileSystem to notify it
that the file system has been touched.
A file system is touched if an operation has been performed on it
which modifies it.
Warning: The write lock of this controller must be acquired while this method is called!
touch in class ArchiveFileSystemControllerIOException
private void ensureOutArchive()
throws IOException
IOException
private void initOutArchive(File outFile)
throws IOException
outArchive with a newly created
OutputArchive for writing outFile.
This method will delete outFile if it has successfully
opened it for overwriting, but failed to write the archive file header.
IOException - On any I/O related issue with outFile.boolean hasNewData(String entryName)
ArchiveControllerArchiveController.umount(de.schlichtherle.io.ArchiveException, boolean, boolean, boolean, boolean, boolean, boolean).
Note that for directories this method will always return
false!
hasNewData in class ArchiveController
void umount(ArchiveException exceptionChain,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams,
boolean umount,
boolean reassemble)
throws ArchiveException
ArchiveControllerWarning: As a side effect, all data structures returned by this controller get reset (filesystem, entries, streams, etc.)! As an implication, this method requires external synchronization on this controller's write lock!
umount in class ArchiveControllerwaitInputStreams - See ArchiveControllers.umount(java.lang.String, boolean, boolean, boolean, boolean, boolean).closeInputStreams - See ArchiveControllers.umount(java.lang.String, boolean, boolean, boolean, boolean, boolean).waitOutputStreams - See ArchiveControllers.umount(java.lang.String, boolean, boolean, boolean, boolean, boolean).closeOutputStreams - See ArchiveControllers.umount(java.lang.String, boolean, boolean, boolean, boolean, boolean).umount - See ArchiveControllers.umount(java.lang.String, boolean, boolean, boolean, boolean, boolean).reassemble - Let's assume this archive file is enclosed
in another archive file.
Then if this parameter is true, the updated archive
file is also written to its enclosing archive file.
Note that this parameter must be set if umount
is set as well. Failing to comply to this requirement may throw
a AssertionError and will incur loss of data!
ArchiveException - If any exception condition occurs throughout
the course of this method, an ArchiveException
is created, prepended to exceptionChain and finally
thrown.ArchiveController.autoUmount(java.lang.String),
ArchiveException
private void umount0(ArchiveException exceptionChain,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams,
boolean umount,
boolean reassemble)
throws ArchiveException
ArchiveExceptionfinal int waitAllInputStreamsByOtherThreads(long timeout)
waitAllInputStreamsByOtherThreads in class ArchiveControllerfinal int waitAllOutputStreamsByOtherThreads(long timeout)
waitAllOutputStreamsByOtherThreads in class ArchiveController
private ArchiveException update(ArchiveException exceptionChain)
throws ArchiveException
This method is intended to be called by update() only!
exceptionChain - the head of a chain of exceptions created so far.
ArchiveWarningException is created
(but not thrown), prepended to exceptionChain and
finally returned.
If multiple warning exception conditions occur, the prepended
exceptions are ordered by appearance so that the last
exception created is the head of the returned exception chain.
ArchiveException - If any exception condition occurs throughout
the course of this method, an ArchiveException
is created, prepended to exceptionChain and finally
thrown unless it's an ArchiveWarningException.private ArchiveException checkNoDeletedEntriesWithNewData(ArchiveException exceptionChain)
private ArchiveException reassemble(ArchiveException exceptionChain)
throws ArchiveException
This method is intended to be called by update() only!
exceptionChain - the head of a chain of exceptions created so far.
ArchiveWarningException is created (but not
thrown), prepended to exceptionChain and finally
returned.
If multiple warning conditions occur,
the prepended exceptions are ordered by appearance so that the
last exception created is the head of the returned
exception chain.
ArchiveException - If any exception condition occurs throughout
the course of this method, an ArchiveException
is created, prepended to exceptionChain and finally
thrown unless it's an ArchiveWarningException.
private void wrap(ArchiveController controller,
String entryName)
throws IOException
IOException
private void wrapToWriteLockedController(ArchiveController controller,
String entryName)
throws IOException
IOException
void reset()
throws IOException
Thereafter, the archive controller will behave as if it has just been created and any subsequent operations on its entries will remount the virtual file system from the archive file again.
reset in class ArchiveFileSystemControllerIOExceptionprivate ArchiveException shutdownStep1(ArchiveException exceptionChain)
private void shutdownStep2(ArchiveException exceptionChain)
throws IOException
IOExceptionprivate void shutdownStep3(boolean deleteOutFile)
deleteOutFile - If this parameter is true,
this method also deletes the temporary output file unless it's
the target archive file (i.e. unless the archive file has been
newly created).
|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||