Class ModuleRecord

java.lang.Object
ortus.boxlang.runtime.modules.ModuleRecord

public class ModuleRecord extends Object
This class represents a module record
  • Field Details

    • id

      public final String id
      Unique internal ID for the module
    • name

      public Key name
      The name of the module, defaults to the folder name on disk
    • version

      public String version
      The version of the module, defaults to 1.0.0
    • author

      public String author
      The author of the module or empty if not set
    • description

      public String description
      The description of the module or empty if not set
    • webURL

      public String webURL
      The web URL of the module or empty if not set
    • mapping

      public String mapping
      The BoxLang mapping of the module used to construct classes from within it. All mappings have a prefix of ModuleService.MODULE_MAPPING_INVOCATION_PREFIX
    • enabled

      public boolean enabled
      If the module is enabled for activation, defaults to false
    • activated

      public boolean activated
      Flag to indicate if the module has been activated or not yet
    • settings

      public Struct settings
      The settings of the module
    • objectMappings

      public Struct objectMappings
      The object mappings of the module
    • datasources

      public Struct datasources
      The datasources to register by the module
    • dependencies

      public Array dependencies
      Any module activation dependencies
    • interceptors

      public Array interceptors
      The interceptors of the module
    • bifs

      public Array bifs
      The BIFS collaborated by the module
    • components

      public Array components
      The Components collaborated by the module
    • memberMethods

      public Array memberMethods
      The member Methods collaborated by the module
    • customInterceptionPoints

      public Array customInterceptionPoints
      The custom interception points of the module
    • physicalPath

      public Path physicalPath
      The physical path of the module on disk as a Java Path
    • path

      public String path
      The physical path of the module but in string format. Used by BoxLang code mostly Same as the physicalPath but in string format
    • invocationPath

      public String invocationPath
      The invocation path of the module which is a composition of the ModuleService.MODULE_MAPPING_INVOCATION_PREFIX and the module name. Example: /bxModules/MyModule is the mapping for the module the invocation path would be bxModules.MyModule
    • registeredOn

      public Instant registeredOn
      The timestamp when the module was registered
    • registrationTime

      public long registrationTime
      The time it took in ms to register the module
    • activatedOn

      public Instant activatedOn
      The timestamp when the module was activated
    • activationTime

      public long activationTime
      The time it took in ms to activate the module
    • classLoader

      public DynamicClassLoader classLoader
      The Dynamic class loader for the module
    • moduleConfig

      public IClassRunnable moduleConfig
      The descriptor for the module
  • Constructor Details

    • ModuleRecord

      public ModuleRecord(String physicalPath)
      Constructor
      Parameters:
      physicalPath - The physical path of the module
  • Method Details

    • loadDescriptor

      public ModuleRecord loadDescriptor(IBoxContext context)
      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

      public ModuleRecord register(IBoxContext context)
      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

      public ModuleRecord unload(IBoxContext context)
      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 libs
      safe - Whether to throw an exception if the class is not found
      context - The current context of execution
      Returns:
      The class if found, null otherwise
      Throws:
      ClassNotFoundException - If the class is not found
    • activate

      public ModuleRecord activate(IBoxContext context)
      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 mandatory
      BoxRuntimeException - If an interceptor class is not found locally or with any mappings
    • execute

      public void execute(IBoxContext context, String[] args)
      Execute the module via the BoxRunner
      Parameters:
      context - The current context of execution
      args - 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:
      true if the module is enabled for activation, false otherwise
    • isActivated

      public boolean isActivated()
      If the module is activated
      Returns:
      true if the module is activated, false otherwise
    • toString

      public String toString()
      Get a string representation of the module record
      Overrides:
      toString in class Object
    • asStruct

      public IStruct asStruct()
      Get a struct representation of the module record
      Returns:
      A struct representation of the module record