Package ortus.boxlang.runtime.modules
Class ModuleRecord
java.lang.Object
ortus.boxlang.runtime.modules.ModuleRecord
This class represents a module record
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanFlag to indicate if the module has been activated or not yetThe timestamp when the module was activatedlongThe time it took in ms to activate the moduleThe author of the module or empty if not setThe BIFS collaborated by the moduleThe Dynamic class loader for the moduleThe Components collaborated by the moduleThe custom interception points of the moduleThe datasources to register by the moduleAny module activation dependenciesThe description of the module or empty if not setbooleanIf the module is enabled for activation, defaults to falsefinal StringUnique internal ID for the moduleThe interceptors of the moduleThe invocation path of the module which is a composition of theModuleService.MODULE_MAPPING_INVOCATION_PREFIXand the module name.The BoxLang mapping of the module used to construct classes from within it.The member Methods collaborated by the moduleThe descriptor for the moduleThe name of the module, defaults to the folder name on diskThe object mappings of the moduleThe physical path of the module but in string format.The physical path of the module on disk as a JavaPathThe timestamp when the module was registeredlongThe time it took in ms to register the moduleThe settings of the moduleThe version of the module, defaults to 1.0.0The web URL of the module or empty if not set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivate(IBoxContext context) This method activates the module in the runtime.asStruct()Get a struct representation of the module recordvoidexecute(IBoxContext context, String[] args) Execute the module via the BoxRunnerClass<?> findModuleClass(String className, Boolean safe, IBoxContext context) Find a class in the module class loader first and then the parent.booleanIf the module is activatedbooleanIf the module is enabled for activationloadDescriptor(IBoxContext context) Load the ModuleConfig.bx from disk, construct it and store it Then populate the module record with the information from the descriptorregister(IBoxContext context) This method registers the module with all the runtime services.toString()Get a string representation of the module recordunload(IBoxContext context) Unload the module from the runtime
-
Field Details
-
id
Unique internal ID for the module -
name
The name of the module, defaults to the folder name on disk -
version
The version of the module, defaults to 1.0.0 -
author
The author of the module or empty if not set -
description
The description of the module or empty if not set -
webURL
The web URL of the module or empty if not set -
mapping
The BoxLang mapping of the module used to construct classes from within it. All mappings have a prefix ofModuleService.MODULE_MAPPING_INVOCATION_PREFIX -
enabled
public boolean enabledIf the module is enabled for activation, defaults to false -
activated
public boolean activatedFlag to indicate if the module has been activated or not yet -
settings
The settings of the module -
objectMappings
The object mappings of the module -
datasources
The datasources to register by the module -
dependencies
Any module activation dependencies -
interceptors
The interceptors of the module -
bifs
The BIFS collaborated by the module -
components
The Components collaborated by the module -
memberMethods
The member Methods collaborated by the module -
customInterceptionPoints
The custom interception points of the module -
physicalPath
The physical path of the module on disk as a JavaPath -
path
The physical path of the module but in string format. Used by BoxLang code mostly Same as thephysicalPathbut in string format -
invocationPath
The invocation path of the module which is a composition of theModuleService.MODULE_MAPPING_INVOCATION_PREFIXand the module name. Example:/bxModules/MyModuleis the mapping for the module the invocation path would bebxModules.MyModule -
registeredOn
The timestamp when the module was registered -
registrationTime
public long registrationTimeThe time it took in ms to register the module -
activatedOn
The timestamp when the module was activated -
activationTime
public long activationTimeThe time it took in ms to activate the module -
classLoader
The Dynamic class loader for the module -
moduleConfig
The descriptor for the module
-
-
Constructor Details
-
ModuleRecord
Constructor- Parameters:
physicalPath- The physical path of the module
-
-
Method Details
-
loadDescriptor
Load the ModuleConfig.bx from disk, construct it and store it Then populate the module record with the information from the descriptor- Parameters:
context- The current context of execution- Returns:
- The ModuleRecord
-
register
This method registers the module with all the runtime services. This is called by the ModuleService if the module is allowed to be registered or not- Parameters:
context- The current context of execution- Returns:
- The ModuleRecord
-
unload
Unload the module from the runtime- Parameters:
context- The current context of execution- Returns:
- The ModuleRecord
-
findModuleClass
public Class<?> findModuleClass(String className, Boolean safe, IBoxContext context) throws ClassNotFoundException Find a class in the module class loader first and then the parent.- Parameters:
className- The name of the class to find in the module's libssafe- Whether to throw an exception if the class is not foundcontext- The current context of execution- Returns:
- The class if found, null otherwise
- Throws:
ClassNotFoundException- If the class is not found
-
activate
This method activates the module in the runtime. Called by the ModuleService if the module is allowed to be activated or not- Parameters:
context- The current context of execution- Returns:
- The ModuleRecord
- Throws:
BoxRuntimeException- If an interceptor record is missing the [class] which is mandatoryBoxRuntimeException- If an interceptor class is not found locally or with any mappings
-
execute
Execute the module via the BoxRunner- Parameters:
context- The current context of executionargs- The arguments to pass to the module- Throws:
BoxRuntimeException- If the module is not executable, meaning it doesn't have a main method
-
isEnabled
public boolean isEnabled()If the module is enabled for activation- Returns:
trueif the module is enabled for activation,falseotherwise
-
isActivated
public boolean isActivated()If the module is activated- Returns:
trueif the module is activated,falseotherwise
-
toString
Get a string representation of the module record -
asStruct
Get a struct representation of the module record- Returns:
- A struct representation of the module record
-