sun.module.repository
Class ExpandedJamRepository

java.lang.Object
  extended by java.module.Repository
      extended by sun.module.repository.ExpandedJamRepository

public class ExpandedJamRepository
extends Repository

Represents a repository whose contents are .jam files that have been expanded into their directory structure. The URL of each .jam that is given to install is used as a directory name. The expansion is done into the directory given as source when the repository is created.


Constructor Summary
ExpandedJamRepository(Repository parent, String name, URL source)
          Creates a new instance of ExpandedJamRepository.
 
Method Summary
 List<ModuleDefinition> findModuleDefinitions(Query constraint)
          Find all matching module definitions in the repository.
 void initialize(Map<String,String> config)
          Initializes the repository instance using the supplied configuration.
 ModuleArchiveInfo install(URL u)
          Installs a .jam file by expanding it into a set of files and directories.
 boolean isActive()
          Returns whether or not the repository instance is active.
 boolean isReadOnly()
          Returns whether or not this repository is read-only.
 List<ModuleArchiveInfo> list()
          Returns an unmodifiable list of the installed module archives' information in the repository.
 void reload()
          Reload the repository.
 void shutdown()
          Shutdown the repository.
 boolean uninstall(ModuleArchiveInfo m)
          Uninstall a module archive from the repository.
 
Methods inherited from class java.module.Repository
equals, find, find, find, findAll, getBootstrapRepository, getModuleSystem, getName, getParent, getSourceLocation, getSystemRepository, hashCode, initialize, shutdownOnExit, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpandedJamRepository

public ExpandedJamRepository(Repository parent,
                             String name,
                             URL source)
Creates a new instance of ExpandedJamRepository. Caller must ensure that the given source is a writable directory. If there is a ModuleDefinition in the source directory, it is installed.

Parameters:
parent - Parent of this repository
name - the name of this repository
source - the source location of this repository, which must be a writable directory
Throws:
IllegalArgumentException - if the source does not refer to a writable directory.
Method Detail

findModuleDefinitions

public List<ModuleDefinition> findModuleDefinitions(Query constraint)
Description copied from class: Repository
Find all matching module definitions in the repository. This method should be overridden by repository implementations for finding matching module definitions, and will be invoked by the find method after checking the parent repository for the requested module definitions.

If this repository instance has not been initialized when this method is called, it will be initialized automatically by calling the initialize method with no argument.

Specified by:
findModuleDefinitions in class Repository
Parameters:
constraint - the constraint.
Returns:
the collection of matching module definitions.
Throws:
IllegalStateException - if the repository instance has not been initialized or has been shutdown.
See Also:
Repository.findModuleDefinitions(Query).

install

public ModuleArchiveInfo install(URL u)
                          throws IOException
Installs a .jam file by expanding it into a set of files and directories. The .jam is expanded into a temporary directory which is then renamed to correspond with the name of the given .jam file.

Specified by:
install in class Repository
Parameters:
u - URL naming a JAM file.
Returns:
the ModuleArchiveInfo object that represents the installed module archive.
Throws:
IOException - if moduleDef does not refer to a file, or if if there is a problem while expanding the.jam. In the latter case, any files or directories resulting from partially incomplete expansion are not removed.
See Also:
Repository.install(URL moduleDef)

initialize

public void initialize(Map<String,String> config)
                throws IOException
Description copied from class: Repository
Initializes the repository instance using the supplied configuration. Configuration properties are described in the class description.

This method will not modify config or save a reference to it, but may save a clone.

Specified by:
initialize in class Repository
Parameters:
config - - config used to initialize the repository instance.
Throws:
IOException - if an I/O error occurs.

shutdown

public void shutdown()
              throws IOException
Description copied from class: Repository
Shutdown the repository. If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("shutdownRepository") permission to ensure it's ok to shutdown a repository.

Specified by:
shutdown in class Repository
Throws:
IOException - if an I/O error occurs.

isReadOnly

public boolean isReadOnly()
Description copied from class: Repository
Returns whether or not this repository is read-only.

Specified by:
isReadOnly in class Repository
Returns:
true if this repository is read-only.

reload

public void reload()
            throws IOException
Description copied from class: Repository
Reload the repository. The behavior of this method depends on the implementation.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("reloadRepository") permission to ensure it's ok to reload module definitions in a repository.

Specified by:
reload in class Repository
Throws:
IOException - If an error occurs while reloading the module definitions.

uninstall

public boolean uninstall(ModuleArchiveInfo m)
                  throws IOException
Description copied from class: Repository
Uninstall a module archive from the repository.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("uninstallModuleArchive") permission to ensure it's ok to uninstall a module archive from a repository.

Specified by:
uninstall in class Repository
Parameters:
m - the module archive to be uninstalled.
Returns:
true if the module archive is found and uninstalled, returns false otherwise.
Throws:
IOException - If an error occurs while uninstalling the module archive.

list

public List<ModuleArchiveInfo> list()
Description copied from class: Repository
Returns an unmodifiable list of the installed module archives' information in the repository. The list will contain a snapshot of the installed module archives in the repository at the time of the given invocation of this method.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("listModuleArchive") permission to ensure it's ok to return the information of the installed module archives in a repository.

Specified by:
list in class Repository
Returns:
an unmodifiable list of the installed module archives' information.

isActive

public boolean isActive()
Description copied from class: Repository
Returns whether or not the repository instance is active.

A repository instance is active if it has been initialized but has not been shutdown.

Specified by:
isActive in class Repository
Returns:
true if this repository instance is active.