Class ComponentService

java.lang.Object
ortus.boxlang.runtime.services.BaseService
ortus.boxlang.runtime.services.ComponentService
All Implemented Interfaces:
IService

public class ComponentService extends BaseService
The ComponentService is in charge of managing the runtime's built-in components. It will also be used by the module services to register components.
  • Constructor Details

    • ComponentService

      public ComponentService(BoxRuntime runtime)
      Constructor
      Parameters:
      runtime - The runtime instance
  • Method Details

    • onConfigurationLoad

      public void onConfigurationLoad()
      The configuration load event is fired when the runtime loads the configuration
      Specified by:
      onConfigurationLoad in interface IService
      Specified by:
      onConfigurationLoad in class BaseService
    • onStartup

      public void onStartup()
      The startup event is fired when the runtime starts up
      Specified by:
      onStartup in interface IService
      Specified by:
      onStartup in class BaseService
    • onShutdown

      public void onShutdown(Boolean force)
      The shutdown event is fired when the runtime shuts down
      Specified by:
      onShutdown in interface IService
      Specified by:
      onShutdown in class BaseService
      Parameters:
      force - Whether or not to force the shutdown
    • getComponentCount

      public long getComponentCount()
      Returns the number of components registered with the service
      Returns:
      The number of components registered with the service
    • getComponentNames

      public String[] getComponentNames()
      Returns the names of the components registered with the service
      Returns:
      A set of component names
    • hasComponent

      public Boolean hasComponent(String name)
      Returns whether or not the service has a component with the given name
      Parameters:
      name - The name of the component
      Returns:
      Whether or not the service has a component with the given name
    • hasComponent

      public Boolean hasComponent(Key name)
      Returns whether or not the service has a component with the given name
      Parameters:
      name - The key name of the component
      Returns:
      Whether or not the service has a component with the given name
    • getComponent

      public ComponentDescriptor getComponent(String name)
      Returns the component with the given name
      Parameters:
      name - The name of the component
      Returns:
      The component with the given name or null if none exists
    • getComponent

      public ComponentDescriptor getComponent(Key name)
      Returns the component with the given name
      Parameters:
      name - The name of the component
      Returns:
      The component with the given name or null if none exists
    • registerComponent

      public void registerComponent(ComponentDescriptor descriptor, Key name, Boolean force)
      Registers a component with the service using a descriptor, a name, and if we want to override if it exists, else it will throw an exception
      Parameters:
      descriptor - The descriptor for the component
      name - The name of the component
      force - Whether or not to force the registration, usually it means an overwrite
      Throws:
      BoxRuntimeException - If the component already exists
    • registerComponent

      public void registerComponent(ComponentDescriptor descriptor, Boolean force)
      Registers a component with the service only using a descriptor. We take the name from the descriptor itself descriptor.name and we do not force the registration.
      Parameters:
      descriptor - The descriptor for the component
      force - Whether or not to force the registration, usually it means an overwrite
      Throws:
      BoxRuntimeException - If the component already exists
    • unregisterComponent

      public void unregisterComponent(Key name)
      Unregisters a component with the service
      Parameters:
      name - The name of the component
    • loadComponentRegistry

      public void loadComponentRegistry() throws IOException
      This method loads all of the components into the service by scanning the ortus.boxlang.runtime.components. package.
      Throws:
      IOException - If there is an error loading the components
    • registerComponent

      public void registerComponent(Class<?> componentClass, Component component, String module)
      Registers a component with the service. This is mostly called by the component loader.
      Parameters:
      componentClass - The component class
      component - The component
      module - The module the component belongs to
      Throws:
      BoxRuntimeException - If no component class or component was provided