java.module
Class Modules

java.lang.Object
  extended by java.module.Modules

public class Modules
extends Object

XXX

Since:
1.7.0

Method Summary
static ImportOverridePolicy getImportOverridePolicy()
          Returns the system's import override policy for module definitions.
static VisibilityPolicy getVisibilityPolicy()
          Returns the system's default visibility policy for module definitions in the repository of the module system.
static ModuleDefinition newJamsModuleDefinition(byte[] metadata, ModuleDefinitionContent content, Repository repository)
          Returns a new ModuleDefinition for modules based on the Java Module System format.
static ModuleDefinition newJamsModuleDefinition(String name, Version version, Callable<byte[]> metadataHandle, ModuleDefinitionContent content, Repository repository)
          Returns a new ModuleDefinition for modules based on the Java Module System format.
static Repository newLocalRepository(Repository parent, String name, URL source)
          Returns an initialized repository for module definitions stored on the file system.
static Repository newLocalRepository(Repository parent, String name, URL source, Map<String,String> config)
          Returns a repository for module definitions stored on the file system.
static Repository newLocalRepository(String name, URL source)
          Returns an initialized repository for module definitions stored on the file system.
static Repository newLocalRepository(String name, URL source, Map<String,String> config)
          Returns a repository for module definitions stored on the file system.
static Repository newURLRepository(Repository parent, String name, URL source)
          Returns a repository that loads module definitions from a codebase URL.
static Repository newURLRepository(String name, URL source)
          Returns a repository that loads module definitions from a codebase URL.
static void setImportOverridePolicy(ImportOverridePolicy policy)
          Set the system's import override policy for module definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newLocalRepository

public static Repository newLocalRepository(Repository parent,
                                            String name,
                                            URL source)
Returns an initialized repository for module definitions stored on the file system.


newLocalRepository

public static Repository newLocalRepository(String name,
                                            URL source)
Returns an initialized repository for module definitions stored on the file system.


newLocalRepository

public static Repository newLocalRepository(Repository parent,
                                            String name,
                                            URL source,
                                            Map<String,String> config)
                                     throws IOException
Returns a repository for module definitions stored on the file system. Initializes the repository from the given Map.

Throws:
IOException

newLocalRepository

public static Repository newLocalRepository(String name,
                                            URL source,
                                            Map<String,String> config)
                                     throws IOException
Returns a repository for module definitions stored on the file system. Initializes the repository from the given Map.

Throws:
IOException

newURLRepository

public static Repository newURLRepository(Repository parent,
                                          String name,
                                          URL source)
Returns a repository that loads module definitions from a codebase URL.

Information about the module definitions available from the codebase URL must be published in a repository metadata file. The contents of the file must follow the schema of the URL Repository metadata for the Java Module System.

{codebase}/repository-metadata.xml

When the repository is initialized, the repository metadata file (i.e. repository-metadata.xml) would be downloaded from the codebase URL.

In the repository metadata file, each module definition is described with a name, a version, a platform binding, and a path (relative to the codebase URL where the module file, the module archive, and/or the packed module archive are located). If no path and no platform binding is specified, the default path is "{name}/{version}". If the path is not specified and the module definition has platform binding, the default path is "{name}/{version}/{platform}-{arch}".

After the URL repository instance successfully downloads the repository metadata file, the module file of each module definition (i.e. MODULE.METADATA file) in the repository is downloaded based on the information in the repository metadata file:

{codebase}/{path}/MODULE.METADATA

If a module definition is platform-specific, its module file is downloaded if and only if the platform binding described in the repository metadata file matches the platform and the architecture of the system.

Module definitions are available for searches after the URL repository instance is initialized. If a module instance is instantiated from a module definition that has no platform binding, the module archive is downloaded by probing in the following order:

{codebase}/{path}/{name}-{version}.jam.pack.gz

{codebase}/{path}/{name}-{version}.jam

On the other hand, if a module instance is instantiated from a platform-specific module definition, the module archive is downloaded by probing in the following order:

{codebase}/{path}/{name}-{version}-{platform}-{arch}.jam.pack.gz

{codebase}/{path}/{name}-{version}-{platform}-{arch}.jam

To ensure the integrity of the separately-hosted module file is in sync with that in the module archive of the same module definition, they are compared bit-wise against each other after the module archive is downloaded.


newURLRepository

public static Repository newURLRepository(String name,
                                          URL source)
Returns a repository that loads module definitions from a codebase URL.


getImportOverridePolicy

public static ImportOverridePolicy getImportOverridePolicy()
Returns the system's import override policy for module definitions.

The default class of the override policy can be changed using the java.module.ImportOverridePolicy system property.

Returns:
the system's default import override policy for module definitions.

setImportOverridePolicy

public static void setImportOverridePolicy(ImportOverridePolicy policy)
Set the system's import override policy for module definitions.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("setImportOverridePolicy") permission to ensure it's ok to set the system's default import override policy..

Parameters:
policy - the import override policy for module definitions.
Throws:
NullPointerException - if the policy is null.
SecurityException - if a security manager exists and its checkPermission method denies access to set the system's default import override policy.

getVisibilityPolicy

public static VisibilityPolicy getVisibilityPolicy()
Returns the system's default visibility policy for module definitions in the repository of the module system.

The default class of the visibility policy can be overridden using the java.module.VisibilityPolicy system property.

Returns:
the system's default visibility policy for module definitions.

newJamsModuleDefinition

public static ModuleDefinition newJamsModuleDefinition(byte[] metadata,
                                                       ModuleDefinitionContent content,
                                                       Repository repository)
                                                throws ModuleFormatException
Returns a new ModuleDefinition for modules based on the Java Module System format.

This method will typically called by repository implementations and not by applications.

Parameters:
metadata - the contents of the MODULE-INF/METADATA.MODULE file
content - the ModuleDefinitionContent to be used to access the contents of the module archive
repository - the repository in which the module archive is stored
Returns:
a new ModuleDefinition
Throws:
NullPointerException - if one of metadata, content, or repository are null
ModuleFormatException - if the contents of metadata are not well formed.

newJamsModuleDefinition

public static ModuleDefinition newJamsModuleDefinition(String name,
                                                       Version version,
                                                       Callable<byte[]> metadataHandle,
                                                       ModuleDefinitionContent content,
                                                       Repository repository)
Returns a new ModuleDefinition for modules based on the Java Module System format.

This method will typically called by repository implementations and not by applications. It is useful in case the metadata has not yet been retrieved but the module name and version are available.

Parameters:
name - the name of the module definition
version - the version of the module definition
metadataHandle - a Callable from which the contents of the MODULE-INF/METADATA.MODULE file can be retrieved
content - the ModuleDefinitionContent to be used to access the contents of the module archive
repository - the repository in which the module archive is stored
Returns:
a new ModuleDefinition
Throws:
NullPointerException - if one of name, version, metadataHandle, content, or repository are null