|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap
de.schlichtherle.io.ArchiveDriverRegistry
de.schlichtherle.io.GlobalArchiveDriverRegistry
final class GlobalArchiveDriverRegistry
A global registry for archive file suffixes and archive drivers which is
configured by the set of all configuration files on the class path.
This registry does not have a delegate, so it can only be used as the tail
in a registry chain.
When this class is instantiated, it enumerate all instances of the relative path META-INF/services/de.schlichtherle.io.registry.properties on the class path (this ensures that TrueZIP is compatible with JNLP as used by Java Web Start and can be safely added to the Extension Class Path).
The configuration files are processed in arbitrary order.
However, configuration files which contain the entry
DRIVER=true have lesser priority and will be overruled by
any other configuration files which do not contain this entry.
This is used by the default configuration file in TrueZIP's JAR:
It contains this entry in order to allow any client application provided
configuration file to overrule it.
This class may appear to be a singleton (there's not much point in
having multiple instances of this class, all with the same configuration).
However, it actually isn't a true singleton because it's
Serializable in order to support serialization of File
instances.
This implies that a JVM can send an instance of this class to another JVM,
which's own global archive driver registry instance may be configured
completely different by its local configuration files.
This requires that the
ArchiveDrivers used by the global
archive driver registry are serializable, too.
Note that it's actually discouraged to serialize File instances.
It's only supported due to the implementation of this feature in its base
class java.io.File.
Instead of serializing File instances, a client application
should serialize path names instead, which are plain strings.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class de.schlichtherle.io.ArchiveDriverRegistry |
|---|
ArchiveDriverRegistry.IllegalArchiveDriverException |
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Field Summary | |
|---|---|
String |
allSuffixes
The canonical list of all archive file suffixes in the global registry. |
private static String |
CLASS_NAME
|
String |
defaultSuffixes
The canonical list of archive file suffixes in the global registry which have been configured to be recognized by default. |
static GlobalArchiveDriverRegistry |
INSTANCE
The (pseudo) singleton instance. |
private static String |
KWD_ALL
|
private static String |
KWD_NULL
|
private static Logger |
logger
|
private static String |
PROP_KEY_DEFAULT_SUFFIXES
|
private static String |
PROP_KEY_REGISTRY
|
private static long |
serialVersionUID
|
| Fields inherited from class de.schlichtherle.io.ArchiveDriverRegistry |
|---|
KWD_DEFAULT, KWD_DRIVER |
| Constructor Summary | |
|---|---|
private |
GlobalArchiveDriverRegistry()
Creates a new GlobalArchiveDriverRegistry. |
| Method Summary | |
|---|---|
private SuffixSet |
defaultSuffixes()
Consumes and processes the entry for the keyword DEFAULT
in the map. |
private static String[] |
getServices()
Returns the ordered list of relative path names for configuration files. |
private void |
logConfiguration()
|
private void |
registerArchiveDrivers()
|
private static void |
registerArchiveDrivers(Map config,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
Processes the given config in order to register
its archive drivers. |
private static void |
registerArchiveDrivers(String service,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
Enumerates all resource URLs for service on the class
path and calls
registerArchiveDrivers(URL, ArchiveDriverRegistry, ArchiveDriverRegistry)
on each instance. |
private static void |
registerArchiveDrivers(URL url,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
Loads and processes the given url in order to register
the archive drivers in its config resource file. |
| Methods inherited from class de.schlichtherle.io.ArchiveDriverRegistry |
|---|
decorate, getArchiveDriver, registerArchiveDrivers, suffixes |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
private static final long serialVersionUID
private static final String CLASS_NAME
private static final Logger logger
private static final String KWD_NULL
private static final String KWD_ALL
private static final String PROP_KEY_DEFAULT_SUFFIXES
private static final String PROP_KEY_REGISTRY
public static final GlobalArchiveDriverRegistry INSTANCE
public final String defaultSuffixes
public final String allSuffixes
| Constructor Detail |
|---|
private GlobalArchiveDriverRegistry()
GlobalArchiveDriverRegistry.
This constructor logs some configuration messages at
Level.CONFIG.
If an exception occurs during processing of the configuration resource
files or no archive drivers are registered, then one or more warnings
messages are logged at Level.WARNING, but otherwise the
constructor terminates normally.
This is to ensure that TrueZIP can be used without throwing exceptions
in static initializers just because of a bug in a configuration
resource file.
| Method Detail |
|---|
private static String[] getServices()
private void registerArchiveDrivers()
private static void registerArchiveDrivers(String service,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
service on the class
path and calls
registerArchiveDrivers(URL, ArchiveDriverRegistry, ArchiveDriverRegistry)
on each instance.
Ensures that configuration files specified by client applications always override configuration files specified by driver implementations.
private static void registerArchiveDrivers(URL url,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
url in order to register
the archive drivers in its config resource file.
private static void registerArchiveDrivers(Map config,
ArchiveDriverRegistry driverRegistry,
ArchiveDriverRegistry clientRegistry)
config in order to register
its archive drivers.
NullPointerException - If any archive driver ID in the
configuration is null.private SuffixSet defaultSuffixes()
DEFAULT
in the map.
If a suffix is specified for which no driver is registered, then a
warning is logged and the suffix is removed from the return value.
DEFAULT in the map of drivers.
May be empty, but never null.private void logConfiguration()
|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||