Package ortus.boxlang.runtime.services
Class ComponentService
java.lang.Object
ortus.boxlang.runtime.services.BaseService
ortus.boxlang.runtime.services.ComponentService
- All Implemented Interfaces:
IService
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.-
Field Summary
Fields inherited from class ortus.boxlang.runtime.services.BaseService
name, runtime, timerUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetComponent(String name) Returns the component with the given namegetComponent(Key name) Returns the component with the given namelongReturns the number of components registered with the serviceString[]Returns the names of the components registered with the servicehasComponent(String name) Returns whether or not the service has a component with the given namehasComponent(Key name) Returns whether or not the service has a component with the given namevoidThis method loads all of the components into the service by scanning theortus.boxlang.runtime.components.package.voidThe 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 upvoidregisterComponent(Class<?> componentClass, Component component, String module) Registers a component with the service.voidregisterComponent(ComponentDescriptor descriptor, Boolean force) Registers a component with the service only using a descriptor.voidregisterComponent(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 exceptionvoidunregisterComponent(Key name) Unregisters a component with the serviceMethods inherited from class ortus.boxlang.runtime.services.BaseService
announce, announce, announce, announce, getName, getRuntime, getTimerUtil
-
Constructor Details
-
ComponentService
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:
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 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
Returns the names of the components registered with the service- Returns:
- A set of component names
-
hasComponent
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
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
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
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
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 componentname- The name of the componentforce- Whether or not to force the registration, usually it means an overwrite- Throws:
BoxRuntimeException- If the component already exists
-
registerComponent
Registers a component with the service only using a descriptor. We take the name from the descriptor itselfdescriptor.nameand we do not force the registration.- Parameters:
descriptor- The descriptor for the componentforce- Whether or not to force the registration, usually it means an overwrite- Throws:
BoxRuntimeException- If the component already exists
-
unregisterComponent
Unregisters a component with the service- Parameters:
name- The name of the component
-
loadComponentRegistry
This method loads all of the components into the service by scanning theortus.boxlang.runtime.components.package.- Throws:
IOException- If there is an error loading the components
-
registerComponent
Registers a component with the service. This is mostly called by the component loader.- Parameters:
componentClass- The component classcomponent- The componentmodule- The module the component belongs to- Throws:
BoxRuntimeException- If no component class or component was provided
-