Package ortus.boxlang.runtime.services
Class ModuleService
java.lang.Object
ortus.boxlang.runtime.services.BaseService
ortus.boxlang.runtime.services.ModuleService
- All Implemented Interfaces:
IService
This service is in charge of managing BoxLang modules
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringThe module conventionsstatic final Stringstatic final Stringstatic final StringThe module mapping and invocation prefixesstatic final Stringstatic final StringFields inherited from class ortus.boxlang.runtime.services.BaseService
name, runtime, timerUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidActivate a modulevoidActivate all modules that are not disabledaddModulePath(String path) Add a module path to the list of paths to search for modules.addModulePath(Path path) Add a modulePathto the list of paths to search for modules.voidThis method scans all possible module locations and builds the module registry of all modules found.voidbuildRegistryFromPath(Path modulePath) This method scans a single module path and builds the module registryGet a list of module names in the registryGet the list of module paths registered in the module servicegetModuleRecord(Key name) Get a module record from the registrygetModuleSettings(Key name) Retrieves the module settings for a requested moduleGet the module registrybooleanVerify if we have a module in the registryvoidThe configuration load event is fired when the runtime loads the configurationvoidonShutdown(Boolean force) The shutdown event is fired when the runtime shuts downvoidThe startup event is fired when the runtime starts upvoidRegister a module.voidScans all possible module locations and registers all modules found This method doesn't activate the modules, it just registers themvoidHelper to reload a modulevoidReload all modulesvoidUnload a module if it exists, else it's ignoredvoidUnload all modulesvoidverifyModuleAndBoxLangVersion(String moduleVersion, Path directoryPath) Verify a module version and the BoxLang version are compatible.Methods inherited from class ortus.boxlang.runtime.services.BaseService
announce, announce, announce, announce, getName, getRuntime, getTimerUtil
-
Field Details
-
MODULE_MAPPING_PREFIX
The module mapping and invocation prefixes- See Also:
-
MODULE_MAPPING_INVOCATION_PREFIX
- See Also:
-
MODULE_DESCRIPTOR
The module conventions- See Also:
-
MODULE_BIFS
- See Also:
-
MODULE_COMPONENTS
- See Also:
-
MODULE_LIBS
- See Also:
-
MODULE_PACKAGE_PREFIX
- See Also:
-
MODULE_PUBLIC_FOLDER
- See Also:
-
-
Constructor Details
-
ModuleService
Constructor- Parameters:
runtime- The runtime instance
-
-
Method Details
-
getModulePaths
Get the list of module paths registered in the module service- Returns:
- the modulePaths
-
onConfigurationLoad
public void onConfigurationLoad()The configuration load event is fired when the runtime loads the configuration- Specified by:
onConfigurationLoadin interfaceIService- Specified by:
onConfigurationLoadin classBaseService
-
onStartup
public void onStartup()The startup event is fired when the runtime starts up- Specified by:
onStartupin interfaceIService- Specified by:
onStartupin classBaseService
-
onShutdown
The shutdown event is fired when the runtime shuts down- Specified by:
onShutdownin interfaceIService- Specified by:
onShutdownin classBaseService- Parameters:
force- Whether the shutdown is forced
-
registerAll
public void registerAll()Scans all possible module locations and registers all modules found This method doesn't activate the modules, it just registers them -
register
Register a module. This method doesn't activate the module, it just registers it. Duplicate modules are not allowed, first one wins. The module must be in the module registry or it will throw an exception.- Parameters:
name- The name of the module to register- Throws:
BoxRuntimeException- If the module is not in the module registry
-
activateAll
public void activateAll()Activate all modules that are not disabled -
activate
Activate a module- Parameters:
name- The name of the module to activate- Throws:
BoxRuntimeException- If the module is not in the module registry
-
unloadAll
public void unloadAll()Unload all modules -
unload
Unload a module if it exists, else it's ignored- Parameters:
name- The name of the module to unload
-
reloadAll
public void reloadAll()Reload all modules -
reload
Helper to reload a module- Parameters:
name- The name of the module to reload
-
getRegistry
Get the module registry -
getModuleNames
Get a list of module names in the registry- Returns:
- The list of module names
-
getModuleRecord
Get a module record from the registry- Parameters:
name- The name of the module to get- Returns:
- The module record or null if not found
-
getModuleSettings
Retrieves the module settings for a requested module- Parameters:
name- The name of the module to get settings for- Returns:
- The settings for the module as a struct
-
hasModule
Verify if we have a module in the registry- Parameters:
name- The name of the module to verify- Returns:
- True if the module is in the registry, false otherwise
-
addModulePath
Add a module path to the list of paths to search for modules. This has to be an absolute path on disk or a relative path to the runtime resources using forward slashes.- Parameters:
path- The string path to add, package resources path or absolute path using forward slashes.- Returns:
- The ModuleService instance
-
addModulePath
Add a modulePathto the list of paths to search for modules.- Parameters:
path- ThePathto add. It can be relative or absolute, but it must exist or it is ignored.- Returns:
- The ModuleService instance
-
verifyModuleAndBoxLangVersion
Verify a module version and the BoxLang version are compatible.Rules: - If the major version is different, then we are not compatible, so throw an exception - If the minor/path version is different, then we are compatible, but we will log a warning
- Parameters:
moduleVersion- The version of the moduledirectoryPath- The directory path of the module- Throws:
BoxRuntimeException- If the module requires a different major version of BoxLang
-
buildRegistry
public void buildRegistry()This method scans all possible module locations and builds the module registry of all modules found. This method doesn't activate the modules, it just registers them. Duplicate modules are not allowed, first one wins. -
buildRegistryFromPath
This method scans a single module path and builds the module registry- Parameters:
modulePath- The path to scan for modules
-