Module¶
-
public class
Module
extends Component¶ A Module is described by a module descriptor and contains zero to many components. Each module has its own classloader for loading its components, which are defined in the module descriptor, and its resources.
Author: Hugo Y. K. Lam See also:
Component
Constructors¶
Module¶
Module¶
-
public
Module
(String descriptorLocation, boolean shouldInitialize)¶ Creates a new instance of Module.
Parameters: - descriptorLocation – the module descriptor.
- shouldInitialize – true if the module should be initialized.
Throws: - ModuleException – if errors encountered when loading the module descriptor.
Module¶
-
public
Module
(String descriptorLocation, ClassLoader loader)¶ Creates and initializes a new instance of Module.
Parameters: - descriptorLocation – the module descriptor.
- loader – the class loader for this module.
Throws: - ModuleException – if errors encountered when loading the module descriptor.
Module¶
-
public
Module
(String descriptorLocation, ClassLoader loader, boolean shouldInitialize)¶ Creates a new instance of Module.
Parameters: - descriptorLocation – the module descriptor.
- loader – the class loader for this module.
- shouldInitialize – true if the module should be initialized.
Throws: - ModuleException – if errors encountered when loading the module descriptor.
Methods¶
createComponents¶
-
protected void
createComponents
()¶ Creates all the components defined in the module descriptor.
Throws: - ModuleException – if unable to create any component.
getClassLoader¶
-
public ClassLoader
getClassLoader
()¶ Gets the class loader that this module uses to load classes.
Returns: the class loader for this module.
getComponent¶
getComponentCount¶
-
public int
getComponentCount
()¶ Gets the number of components in this module.
Returns: the number of components in this module.
getComponents¶
-
public Collection
getComponents
()¶ Gets all the components in this module.
Returns: all module components
getDescriptor¶
getGroup¶
-
public ModuleGroup
getGroup
()¶ Gets the module group to which this module belongs.
Returns: the module group.
getLogger¶
getRequiredParameter¶
-
protected String
getRequiredParameter
(String key)¶ Get the mandatory parameter from the current module, throw ModuleException if not found.
Parameters: - key – the key in the parameters list.
Throws: - ModuleException – if the parameter with
key
does not exist.
Returns: The value of the parameter if found.
getResource¶
getResource¶
-
public static URL
getResource
(String name, ClassLoader loader)¶ Gets a resource as URL.
The specified name can be an absolute path or a relative path to the current directory or classpaths.
If the specified name is a relative path, it will be searched through the current directory and then the classpaths.
Parameters: - name – the name of the resource.
- loader – the class loader for finding the resource.
Returns: the URL of the resource.
getResourceAsStream¶
-
public InputStream
getResourceAsStream
(String name)¶ Gets a resource as stream.
Parameters: - name – the name of the resource.
Returns: an input stream of the resource.
See also:
.getResource(String)
getString¶
getVersion¶
init¶
-
public void
init
()¶ Initializes the module and all its components.
Throws: - ModuleException – if unable to initialize the module.
initComponents¶
-
protected void
initComponents
()¶ Initializes all the created components.
Throws: - ModuleException – if unable to initialize any component.
setComponent¶
setGroup¶
-
public void
setGroup
(ModuleGroup group)¶ Sets the module group to which this module belongs.
Parameters: - group – the module group.
toString¶
-
public String
toString
()¶ Returns a string representation of this module.
Returns: a string representation of this module. See also:
java.lang.Object.toString()