TrueZIP 6.8.2

de.schlichtherle.io
Class ArchiveControllers

java.lang.Object
  extended by de.schlichtherle.io.ArchiveControllers

final class ArchiveControllers
extends Object

Provides static utility methods for ArchiveControllers.

Since:
TrueZIP 6.5
Version:
$Id: ArchiveControllers.java 06f3ba684701 2010/11/04 01:15:55 christian $
Author:
Christian Schlichtherle

Nested Class Summary
private static class ArchiveControllers.ControllerEnumeration
           
private static class ArchiveControllers.LiveArchiveStatistics
           
(package private) static class ArchiveControllers.ShutdownHook
          TrueZIP's singleton shutdown hook for the JVM.
 
Field Summary
private static String CLASS_NAME
           
private static Map controllers
          The map of all archive controllers.
private static Logger logger
           
private static Comparator REVERSE_CONTROLLERS
           
 
Constructor Summary
private ArchiveControllers()
          This class cannot get instantiated.
 
Method Summary
(package private) static ArchiveController get(File file)
          Factory method returning an ArchiveController object for the given archive file.
(package private) static ArchiveStatistics getLiveArchiveStatistics()
           
(package private) static void set(File target, Object controller)
          Associates the given archive controller to the target file.
(package private) static void umount(String prefix, boolean waitInputStreams, boolean closeInputStreams, boolean waitOutputStreams, boolean closeOutputStreams, boolean umount)
          Updates all archive files in the real file system which's canonical path name start with prefix with the contents of their virtual file system, resets all cached state and deletes all temporary files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

private static final String CLASS_NAME
See Also:
Constant Field Values

logger

private static final Logger logger

controllers

private static final Map controllers
The map of all archive controllers. The keys are plain File instances and the values are either ArchiveControllers or WeakReferences to ArchiveControllers. All access to this map must be externally synchronized!


REVERSE_CONTROLLERS

private static final Comparator REVERSE_CONTROLLERS
Constructor Detail

ArchiveControllers

private ArchiveControllers()
This class cannot get instantiated.

Method Detail

get

static ArchiveController get(File file)
Factory method returning an ArchiveController object for the given archive file.

Note:


set

static final void set(File target,
                      Object controller)
Associates the given archive controller to the target file.

Parameters:
target - The target file. This must not be null or an instance of the File class in this package!
controller - An ArchiveController or a WeakReference to an archive controller.

umount

static void umount(String prefix,
                   boolean waitInputStreams,
                   boolean closeInputStreams,
                   boolean waitOutputStreams,
                   boolean closeOutputStreams,
                   boolean umount)
            throws ArchiveException
Updates all archive files in the real file system which's canonical path name start with prefix with the contents of their virtual file system, resets all cached state and deletes all temporary files. This method is thread safe.

Parameters:
prefix - The prefix of the canonical path name of the archive files which shall get updated - null is not allowed! If the canonical pathname of an archive file does not start with this string, then it is not updated.
waitInputStreams - Suppose any other thread has still one or more archive entry input streams open. Then if and only if this parameter is true, this method will wait until all other threads have closed their archive entry input streams. Archive entry input streams opened (and not yet closed) by the current thread are always ignored. If the current thread gets interrupted while waiting, it will stop waiting and proceed normally as if this parameter were false. Be careful with this parameter value: If a stream has not been closed because the client application does not always properly close its streams, even on an IOException (which is a typical bug in many Java applications), then this method may not return until the current thread gets interrupted!
closeInputStreams - Suppose there are any open input streams for any archive entries because the application has forgot to close all FileInputStream objects or another thread is still busy doing I/O on an archive. Then if this parameter is true, an update is forced and an ArchiveBusyWarningException is finally thrown to indicate that any subsequent operations on these streams will fail with an ArchiveEntryStreamClosedException because they have been forced to close. This may also be used to recover an application from a FileBusyException thrown by a constructor of FileInputStream or FileOutputStream. If this parameter is false, the respective archive file is not updated and an ArchiveBusyException is thrown to indicate that the application must close all entry input streams first.
waitOutputStreams - Similar to waitInputStreams, but applies to archive entry output streams instead.
closeOutputStreams - Similar to closeInputStreams, but applies to archive entry output streams instead. If this parameter is true, then closeInputStreams must be true, too. Otherwise, an IllegalArgumentException is thrown.
umount - If true, all temporary files get deleted, too. 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. Use this to allow subsequent changes to the archive files by other processes or via the java.io.File* classes before this package is used for read or write access to these archive files again.
Throws:
ArchiveBusyWarningExcepion - If a archive file has been updated while the application is using any open streams to access it concurrently. These streams have been forced to close and the entries of output streams may contain only partial data.
ArchiveWarningException - If only warning conditions occur throughout the course of this method which imply that the respective archive file has been updated with constraints, such as a failure to set the last modification time of the archive file to the last modification time of its virtual root directory.
ArchiveBusyException - If an archive file could not get updated because the application is using an open stream. No data is lost and the archive file can still get updated by calling this method again.
ArchiveException - If any error conditions occur throughout the course of this method which imply loss of data. This usually means that at least one of the archive files has been created externally and was corrupted or it cannot get updated because the file system of the temp file or target file folder is full.
NullPointerException - If prefix is null.
IllegalArgumentException - If closeInputStreams is false and closeOutputStreams is true.

getLiveArchiveStatistics

static final ArchiveStatistics getLiveArchiveStatistics()

TrueZIP 6.8.2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.