public class Module extends Object
Modifier and Type | Field and Description |
---|---|
static String |
RUN_METHOD_NAME
Name of the run method on a class.
|
protected ClassLoader |
theClassLoader
This Module's ClassLoader.
|
protected ModuleMeta |
theModuleMeta
The ModuleMeta for this Module.
|
protected ClassLoader |
theParentClassLoader
The parent ClassLoader of this Module's ClassLoader.
|
protected ModuleRegistry |
theRegistry
The AbstractModuleRegistry in which this Module is registered.
|
Constructor and Description |
---|
Module(ModuleMeta meta,
AbstractModuleRegistry registry,
ClassLoader parentClassLoader)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
activateRecursively()
This recursively activates this Module.
|
void |
activateRecursively(ModuleActivator activator)
This recursively activates this Module.
|
void |
deactivateRecursively()
This recursively deactivates this Module.
|
void |
deactivateRecursively(ModuleActivator activator)
This recursively deactivates this Module.
|
Module[] |
determineRuntimeDependencies()
Convenience method to determine the dependent Modules of this Module
at run-time.
|
Module[] |
determineRuntimeUses()
Convenience method to determine the Modules that use this Module at
run-time.
|
boolean |
equals(Object other)
Determine Module equality.
|
ClassLoader |
getClassLoader()
Obtain a ClassLoader that knows how to load the code belonging to this Module.
|
Object |
getContextObject()
Obtain the context object returned by the activation method of this Module, if any.
|
ModuleActivator |
getDefaultModuleActivator()
Obtain the default ModuleActivator for this Module.
|
String |
getModuleArtifactId()
Obtain the artifactId of this Module.
|
String |
getModuleGroupId()
Obtain the groupId of this Module.
|
ModuleMeta |
getModuleMeta()
Obtain the ModuleMeta for this Module.
|
ModuleRegistry |
getModuleRegistry()
Obtain the ModuleRegistry in which this Module has been registered.
|
String |
getModuleVersion()
Obtain the version of this Module.
|
int |
hashCode()
Determine hash code.
|
boolean |
isActive()
Determine whether this Module is active.
|
void |
run(String[] arguments)
Run this Module as a root Module.
|
int |
run(String overriddenRunClassName,
String overriddenRunMethodName,
String[] arguments)
Run this Module as a root Module.
|
String |
toString()
For debugging.
|
protected ModuleRegistry theRegistry
protected ModuleMeta theModuleMeta
protected ClassLoader theClassLoader
protected ClassLoader theParentClassLoader
public static final String RUN_METHOD_NAME
public Module(ModuleMeta meta, AbstractModuleRegistry registry, ClassLoader parentClassLoader)
meta
- this Module's ModuleMetaregistry
- the registry of Modules in which we try to find dependent ModulesparentClassLoader
- the class loader of our parent Modulepublic final String getModuleGroupId()
public final String getModuleArtifactId()
public final String getModuleVersion()
public final ModuleMeta getModuleMeta()
public final ModuleRegistry getModuleRegistry()
public final Module[] determineRuntimeDependencies()
public final Module[] determineRuntimeUses()
public final ClassLoader getClassLoader() throws MalformedURLException
MalformedURLException
- thrown if one of the URLs identifying the Module's JAR files is malformedpublic final boolean isActive()
public final void activateRecursively() throws ModuleResolutionException, ModuleNotFoundException, ModuleActivationException
ModuleResolutionException
- thrown if a dependent Module cannot be resolvedModuleNotFoundException
- thrown if a dependent Module cannot be foundModuleActivationException
- thrown if this Module, or a dependent Module could not be activatedpublic final void activateRecursively(ModuleActivator activator) throws ModuleResolutionException, ModuleNotFoundException, ModuleActivationException
activator
- a ModuleActivator instance that knows how to activate this ModuleModuleResolutionException
- thrown if a dependent Module cannot be resolvedModuleNotFoundException
- thrown if a dependent Module cannot be foundModuleActivationException
- thrown if this Module, or a dependent Module could not be activatedpublic final void deactivateRecursively() throws ModuleDeactivationException
ModuleDeactivationException
- throws if the Module could not be deactivatedpublic final void deactivateRecursively(ModuleActivator activator) throws ModuleDeactivationException
activator
- a ModuleActivator instance that knows how to deactivate instead of the default one specified in the ModuleMetaModuleDeactivationException
- throws if the Module could not be deactivatedpublic final Object getContextObject()
public final void run(String[] arguments) throws ClassNotFoundException, ModuleRunException, NoRunMethodException, InvocationTargetException
arguments
- arguments to run, similar to the arguments of a standard main(...) methodClassNotFoundException
- thrown if the specified run class cannot be foundModuleRunException
- thrown if the specified run method threw an ExceptionNoRunMethodException
- thrown if a suitable run method cannot be foundInvocationTargetException
- thrown if the run method throws an Exceptionpublic int run(String overriddenRunClassName, String overriddenRunMethodName, String[] arguments) throws ClassNotFoundException, ModuleRunException, NoRunMethodException, InvocationTargetException
overriddenRunClassName
- optional name of the class to run instead of the default one specified in the ModuleMetaoverriddenRunMethodName
- optional name of the method in the class to run instead of the default one specified in the ModuleMetaarguments
- arguments to run, similar to the arguments of a standard main(...) methodClassNotFoundException
- thrown if the specified run class cannot be foundModuleRunException
- thrown if the specified run method threw an ExceptionNoRunMethodException
- thrown if a suitable run method cannot be foundInvocationTargetException
- thrown if the run method throws an Exceptionpublic ModuleActivator getDefaultModuleActivator()
public boolean equals(Object other)
public int hashCode()
Copyright © 2018. All rights reserved.