java.module
Class ModuleSystem

java.lang.Object
  extended by java.module.ModuleSystem
Direct Known Subclasses:
ModuleSystemImpl

public abstract class ModuleSystem
extends Object

This class represents the module system which constructs a module instance from a module definition.

Since:
1.7.0
Author:
Andreas Sterbenz, Stanley M. Ho
See Also:
Module, ModuleDefinition

Constructor Summary
protected ModuleSystem()
          Constructor used by subclasses.
 
Method Summary
abstract  void disableModuleDefinition(ModuleDefinition moduleDef)
          Disables the specified ModuleDefinition in the ModuleSystem.
static ModuleSystem getDefault()
          Returns the system's default module system.
abstract  Module getModule(ModuleDefinition moduleDef)
          Returns a Module instance for the specified ModuleDefinition in the ModuleSystem.
abstract  void releaseModule(ModuleDefinition moduleDef)
          Releases an existing Module instance corresponding to the specified ModuleDefinition in the ModuleSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleSystem

protected ModuleSystem()
Constructor used by subclasses.

Method Detail

getModule

public abstract Module getModule(ModuleDefinition moduleDef)
                          throws ModuleInitializationException
Returns a Module instance for the specified ModuleDefinition in the ModuleSystem. The module is initialized and ready to use.

If there is an existing module instance for the specified ModuleDefinition, that instance is returned. Otherwise, a new module instance is instantiated and returned.

Parameters:
moduleDef - a ModuleDefinition
Returns:
a Module instance of the ModuleDefinition.
Throws:
ModuleInitializationException - if the module instance cannot be initialized.
IllegalStateException - if the specified module definition has already been disabled.

releaseModule

public abstract void releaseModule(ModuleDefinition moduleDef)
Releases an existing Module instance corresponding to the specified ModuleDefinition in the ModuleSystem.

If there is an existing module instance for the specified module definition, it will never be returned by the ModuleSystem after this method returns. Further, if that module instance is imported by other module instances, each of these importing module instance will also be released.

If there is no module instance corresponding to the module definition, calling this method has no effect.

Module instances corresponding to the ModuleDefinition with name that begins with "java.", or from the bootstrap repository cannot be released.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("releaseModule") permission to ensure it's ok to release the existing module instance of the specified module definition.

Parameters:
moduleDef - a ModuleDefinition.
Throws:
SecurityException - if a security manager exists and its checkPermission method denies access to release the module instance of the specified module definition.
UnsupportedOperationException - if the existing module instance cannot be released.

disableModuleDefinition

public abstract void disableModuleDefinition(ModuleDefinition moduleDef)
Disables the specified ModuleDefinition in the ModuleSystem.

The ModuleDefinition is released and marked to disallow creation of new Module instances. Subsequent calls to getModule with this ModuleDefinition throw an IllegalStateException.

ModuleDefinition with name that begins with "java.", or from the bootstrap repository cannot be disabled.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("disableModuleDefinition") permission to ensure it's ok to disable the specified module definition in the module system.

Parameters:
moduleDef - a ModuleDefinition.
Throws:
SecurityException - if a security manager exists and its checkPermission method denies access to disable the specified module definition in the module system.
UnsupportedOperationException - if the specified module definition cannot be disabled.
IllegalStateException - if the specified module definition has already been disabled.

getDefault

public static ModuleSystem getDefault()
Returns the system's default module system.

The default class of the module system can be overridden using the java.module.ModuleSystem system property.

Returns:
the system's default module system.