Qwylt

java.lang.module
Class ModuleRepository

java.lang.Object
  extended by java.lang.module.ModuleRepository

public abstract class ModuleRepository
extends java.lang.Object

This class represents a storage model for ModuleArchive instances.

Since:
Dec 13, 2008
Author:
Bryan Atsatt

Field Summary
protected static java.util.List<ModuleArchive> EMPTY
           
 
Constructor Summary
protected ModuleRepository(java.lang.String name, SearchPolicy searchPolicy)
          Constructs an instance that will delegate all searches to the specified SearchPolicy.
 
Method Summary
protected static void assertDirectoryValid(java.io.File directory, boolean writable)
          Assert that the specified directory is valid, creating it if needed.
protected  void assertOpen(boolean willModify)
          Assert that this instance is open and that it is modifiable if the operation will modify.
 void close()
          Close this repository.
 boolean equals(java.lang.Object other)
          Test if the specified object is equal to this instance, enforcing identity comparison.
abstract  java.net.URI export(ModuleArchive archive)
          Export the specified archive in installable form, identical or equivalent to the originally installed, module system specific archive.
 ModuleArchive find(ModuleQuery query)
          Find the first ModuleArchive that matches the specified query.
 java.util.List<ModuleArchive> findAll(ModuleQuery query)
          Find all ModuleArchives that match the specified query.
abstract  java.util.List<? extends ModuleArchive> findAllLocal(ModuleQuery query)
          Find all ModuleArchives within this ModuleRepository that match the specified query.
abstract  ModuleArchive findLocal(ModuleQuery query)
          Find the first ModuleArchive within this ModuleRepository that matches the specified query.
abstract  long getLastModifiedTime()
          Returns the last modification time of ModuleRepository.
abstract  java.net.URI getLocation()
          Returns the location of this ModuleRepository.
abstract  ModuleSystem getModuleSystem()
          Returns the ModuleSystem of this ModuleRepository.
 java.lang.String getName()
          Returns the name of this ModuleRepository.
static java.util.List<ModuleRepository> getRepositories()
          Returns a list of all registered repositories.
static ModuleRepository getRepository(java.lang.String name)
          Returns the named repository.
static ModuleRepository getRepositoryFor(java.net.URI location)
          Returns the registered repository with the specified location.
static ModuleRepository getRootRepository()
          Returns the root repository.
static ModuleRepository getSystemRepository()
          Returns the system repository.
 int hashCode()
          Returns the identity hash code for this instance.
 java.util.List<? extends ModuleArchive> importFrom(ModuleRepository source, ModuleQuery query)
          Import all matching archives from the specified repository and install them in this instance.
 java.util.List<? extends ModuleArchive> install(java.util.List<java.net.URI> uris)
          Install archives into this ModuleRepository.
abstract  ModuleArchive install(java.net.URI uri)
          Install an archive into this ModuleRepository.
abstract  boolean isReadOnly()
          Returns whether or not this ModuleRepository is read-only.
protected  void register()
          Register this instance and any hosted types.
protected  void registerHostedTypes()
          Load and register any hosted ModuleSystem or EventListener instances contained in this repository.
abstract  int size()
          Returns the number of archives installed in this ModuleRepository.
 java.lang.String toString()
          Returns a string representation of this instance.
 java.lang.String toString(boolean verbose)
          Returns a string representation of this instance.
abstract  void uninstall(ModuleArchive archive)
          Uninstall an archive.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

protected static final java.util.List<ModuleArchive> EMPTY
Constructor Detail

ModuleRepository

protected ModuleRepository(java.lang.String name,
                           SearchPolicy searchPolicy)
Constructs an instance that will delegate all searches to the specified SearchPolicy.

Parameters:
name - The repository name.
searchPolicy - The search policy.
Method Detail

getRootRepository

public static ModuleRepository getRootRepository()
Returns the root repository.

Returns:
The root repository.

getSystemRepository

public static ModuleRepository getSystemRepository()
Returns the system repository.

Returns:
The system repository.

getRepository

public static ModuleRepository getRepository(java.lang.String name)
Returns the named repository.

Parameters:
name - The repository name.
Returns:
The repository or null if not found.

getRepositoryFor

public static ModuleRepository getRepositoryFor(java.net.URI location)
Returns the registered repository with the specified location.

Parameters:
location - The location.
Returns:
The repository or null if not found.

getRepositories

public static java.util.List<ModuleRepository> getRepositories()
Returns a list of all registered repositories.

Returns:
The list.

find

public ModuleArchive find(ModuleQuery query)
Find the first ModuleArchive that matches the specified query.

Parameters:
query - The query.
Returns:
The ModuleArchive or null if no match.

findAll

public java.util.List<ModuleArchive> findAll(ModuleQuery query)
Find all ModuleArchives that match the specified query.

Parameters:
query - The query.
Returns:
The list of ModuleArchives matching the query, in descending version order; empty if no match.

findLocal

public abstract ModuleArchive findLocal(ModuleQuery query)
Find the first ModuleArchive within this ModuleRepository that matches the specified query.

Parameters:
query - The query.
Returns:
The first ModuleArchive matching the query, or null if no match.

findAllLocal

public abstract java.util.List<? extends ModuleArchive> findAllLocal(ModuleQuery query)
Find all ModuleArchives within this ModuleRepository that match the specified query.

Parameters:
query - The query.
Returns:
The list of ModuleArchives, empty if no match.

isReadOnly

public abstract boolean isReadOnly()
Returns whether or not this ModuleRepository is read-only.

Returns:
true if this ModuleRepository is read-only; otherwise, returns false.

install

public abstract ModuleArchive install(java.net.URI uri)
                               throws java.io.IOException
Install an archive into this ModuleRepository.

Parameters:
uri - The URI to the module archive.
Returns:
The installed ModuleArchive.
Throws:
java.lang.UnsupportedOperationException - if this ModuleRepository is read-only.
java.lang.IllegalArgumentException - if the module archive format is not supported by this implementation.
java.lang.IllegalStateException - if the same module archive is already installed in this ModuleRepository.
java.io.IOException - If an I/O error occurs while installing the archive.

install

public java.util.List<? extends ModuleArchive> install(java.util.List<java.net.URI> uris)
                                                throws java.io.IOException
Install archives into this ModuleRepository.

Parameters:
uris - The module archive.
Returns:
The installed ModuleArchives.
Throws:
java.lang.UnsupportedOperationException - if this ModuleRepository is read-only.
java.lang.IllegalArgumentException - if the module archive format is not supported by this implementation.
java.lang.IllegalStateException - if the same module archive is already installed in this ModuleRepository.
java.io.IOException - If an I/O error occurs while installing the archive.}.

uninstall

public abstract void uninstall(ModuleArchive archive)
                        throws java.io.IOException
Uninstall an archive. Will not affect active uses.

Parameters:
archive - The ModuleArchive to uninstall.
Throws:
java.lang.UnsupportedOperationException - if this ModuleRepository is read-only.
java.io.IOException - If an I/O error occurs while uninstalling the archive.

export

public abstract java.net.URI export(ModuleArchive archive)
                             throws java.io.IOException
Export the specified archive in installable form, identical or equivalent to the originally installed, module system specific archive.

Parameters:
archive - The ModuleArchive to export.
Returns:
A URI from which the exported archive may be obtained.
Throws:
java.lang.UnsupportedOperationException - if this ModuleRepository is read-only.
java.io.IOException - If an I/O error occurs while exporting the module.

importFrom

public java.util.List<? extends ModuleArchive> importFrom(ModuleRepository source,
                                                          ModuleQuery query)
                                                   throws java.io.IOException
Import all matching archives from the specified repository and install them in this instance.

Parameters:
source - The source repository.
query - The query to match.
Returns:
The installed ModuleArchives.
Throws:
java.io.IOException - If an I/O exception occurs while exporting an archive from the source repository or when installing into this instance.

getName

public java.lang.String getName()
Returns the name of this ModuleRepository.

Returns:
The name.

getModuleSystem

public abstract ModuleSystem getModuleSystem()
Returns the ModuleSystem of this ModuleRepository.

Returns:
the ModuleSystem.

getLocation

public abstract java.net.URI getLocation()
Returns the location of this ModuleRepository.

Returns:
The location.

size

public abstract int size()
Returns the number of archives installed in this ModuleRepository.

Returns:
The size.

getLastModifiedTime

public abstract long getLastModifiedTime()
Returns the last modification time of ModuleRepository.

Returns:
A long value representing the time the repository was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).

close

public void close()
Close this repository. Any subsequent operations against this instance will throw an IllegalStateException.


equals

public final boolean equals(java.lang.Object other)
Test if the specified object is equal to this instance, enforcing identity comparison.

Overrides:
equals in class java.lang.Object
Parameters:
other - The object to compare to.
Returns:
true if other is the same as this instance; otherwise, returns false.

hashCode

public final int hashCode()
Returns the identity hash code for this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
The identity hash code for this instance.

toString

public java.lang.String toString()
Returns a string representation of this instance.

Overrides:
toString in class java.lang.Object
Returns:
The string.

toString

public java.lang.String toString(boolean verbose)
Returns a string representation of this instance.

Parameters:
verbose - Enable verbose output.
Returns:
The string.

assertDirectoryValid

protected static void assertDirectoryValid(java.io.File directory,
                                           boolean writable)
Assert that the specified directory is valid, creating it if needed.

Parameters:
directory - The directory.
writable - true if write access is required, false otherwise.

register

protected void register()
Register this instance and any hosted types.

Throws:
java.lang.IllegalArgumentException - if repository name is already registered.

assertOpen

protected void assertOpen(boolean willModify)
Assert that this instance is open and that it is modifiable if the operation will modify.

Parameters:
willModify - true iff the operation will modify this instance.

registerHostedTypes

protected void registerHostedTypes()
Load and register any hosted ModuleSystem or EventListener instances contained in this repository.


Qwylt

Send comments or questions to Bryan Atsatt