|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ungoverned.moduleloader.Module
The Module class is a grouping mechanism for application classes and resources. Conceptually, most applications are grouped into entities such as JAR files (containing classes and resources) and native libraries. In some cases, these entities are core application classes and resources, while in other cases, these entities are ancillary, such as dynamically loaded plug-ins. Applications place some level of semantics onto these types of entities or modules, but for the ModuleLoader, no particular semantics are attached to modules (other than they are a grouping mechanism for classes and resources). This means that the application is free to map itself into modules any way that is appropriate.
A module has the following features:
A module's identifier must be unique within the scope of its ModuleManager, but there is no meaning associated with it. The set of attribute-value pairs attached to the module have no meaning to the ModuleManager, nor does it consult them at all. The point of these attributes is to attach meta-data for use by SearchPolicy implementations. Attributes are represented as an array of Object arrays, i.e., Object[][]. Each element in the attribute array is a two-element Object array, where Module.KEY_IDX is the attribute's key and Module.VALUE_IDX is the attribute's value.
The actual contents of a module is contained in two sets of sources for its resources and native libraries, ResourceSources and LibrarySources, respectively. Each module also has a ModuleClassLoader associated with it. The ModuleClassLoader consults these two types of sources to find classes, resources, and native libraries.
ModuleManager
,
ModuleClassLoader
,
ResourceSource
,
LibrarySource
Field Summary | |
static int |
KEY_IDX
This is the index used to retrieve the key of an attribute; an attribute is represented as an Object[] instance. |
static int |
VALUE_IDX
This is the index used to retrieve the value of an attribute; an attribute is represented as an Object[] instance. |
Constructor Summary | |
Module(ModuleManager mgr,
java.lang.String id,
java.lang.Object[][] attributes,
ResourceSource[] resSources,
LibrarySource[] libSources)
Constructs a Module instance that will be associated with the specified ModuleManager and will have the specified identifier, attributes, resource sources, and library sources. |
Method Summary | |
protected void |
dispose()
Disposes the module by closing all resource and library sources. |
java.lang.Object |
getAttribute(java.lang.String key)
Returns the attribute value associated with the specified key. |
java.lang.Object[][] |
getAttributes()
Returns the attribute set associated with this module. |
ModuleClassLoader |
getClassLoader()
Returns the ModuleClassLoader associated with this module. |
java.lang.String |
getId()
Returns the identifier of the module. |
LibrarySource[] |
getLibrarySources()
Returns the array of LibrarySources associated with the module. |
ResourceSource[] |
getResourceSources()
Returns the array of ResourceSources associated with the module. |
protected void |
reset(java.lang.Object[][] attributes,
ResourceSource[] resSources,
LibrarySource[] libSources)
Resets the module by throwing away its associated class loader and re-initializing its attributes, resource sources, and library sources with the specified values. |
void |
setAttribute(java.lang.String key,
java.lang.Object value)
Sets the attribute value associated with the specified key. |
java.lang.String |
toString()
Returns the module's identifier. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int KEY_IDX
public static final int VALUE_IDX
Constructor Detail |
public Module(ModuleManager mgr, java.lang.String id, java.lang.Object[][] attributes, ResourceSource[] resSources, LibrarySource[] libSources)
Constructs a Module instance that will be associated with the specified ModuleManager and will have the specified identifier, attributes, resource sources, and library sources. In general, modules should not be created directly, but should be created by making a call to ModuleManager.addModule().
mgr
- the ModuleManager that will be associated to
the instance.id
- the identifier of the instance.attributes
- the set of attributes associated with the instance.resSources
- the set of ResourceSources associated with
the instance.libSources
- the set of LibrarySources associated with
the instance.ModuleManager
,
ResourceSource
,
LibrarySource
Method Detail |
public java.lang.String getId()
Returns the identifier of the module.
public java.lang.Object[][] getAttributes()
Returns the attribute set associated with this module. Attributes are represented as an array of Object arrays, i.e., Object[][]. Each element in the attribute array is two-element Object array, where Module.KEY_IDX is the index to the attribute key and Module.VALUE_IDX is the index to the attribute value. The returned array is a copy and may be freely modified.
public java.lang.Object getAttribute(java.lang.String key)
Returns the attribute value associated with the specified key.
key
- the key of the attribute whose value is to be retrieved.
public void setAttribute(java.lang.String key, java.lang.Object value)
Sets the attribute value associated with the specified key. The attribute will be added if it does not currently exist.
key
- the key of the attribute whose value is to be set.value
- the new value to be associated with the attribute key.public ResourceSource[] getResourceSources()
Returns the array of ResourceSources associated with the module. The returned array is not a copy and therefore should not be modified.
ResourceSource
public LibrarySource[] getLibrarySources()
Returns the array of LibrarySources associated with the module. The returned array is not a copy and therefore should not be modified.
LibrarySource
public ModuleClassLoader getClassLoader()
Returns the ModuleClassLoader associated with this module. If a security manager is installed, then this method uses a privileged action to avoid a security exception being thrown to the caller.
ModuleClassLoader
public java.lang.String toString()
Returns the module's identifier.
protected void reset(java.lang.Object[][] attributes, ResourceSource[] resSources, LibrarySource[] libSources)
Resets the module by throwing away its associated class loader and re-initializing its attributes, resource sources, and library sources with the specified values.
attributes
- the new attributes to be associated with the module.resSources
- the new resource sources to be associated with the module.libSources
- the new library sources to be associated with the module.ResourceSource
,
LibrarySource
protected void dispose()
Disposes the module by closing all resource and library sources.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |