Creates a new instance of the container.
(optional) a container name (accessible via ContextInfo)
(optional) a container description (accessible via ContextInfo)
Adds a factory to the container. The factory is used to create components added to the container by their locators (descriptors).
a component factory to be added.
Closes component and frees used resources.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Configures component by passing configuration parameters.
configuration parameters to be set.
Checks if the component is opened.
true if the component has been opened and false otherwise.
Opens the component.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Reads container configuration from JSON or YAML file and parameterizes it with given values.
(optional) transaction id to trace execution through call chain.
a path to configuration file
values to parameters the configuration or null to skip parameterization.
Sets references to dependent components.
references to locate the component dependencies.
Unsets (clears) previously set references to dependent components.
Generated using TypeDoc
Inversion of control (IoC) container that creates components and manages their lifecycle.
The container is driven by configuration, that usually stored in JSON or YAML file. The configuration contains a list of components identified by type or locator, followed by component configuration.
On container start it performs the following actions:
On container stop actions are performed in reversed order:
The component configuration can be parameterized by dynamic values. That allows specialized containers to inject parameters from command line or from environment variables.
The container automatically creates a ContextInfo component that carries detail information about the container and makes it available for other components.
IConfigurable (in the PipServices "Commons" package)
IReferenceable (in the PipServices "Commons" package)
IOpenable (in the PipServices "Commons" package)
Configuration parameters
Example
======= config.yml ======== - descriptor: mygroup:mycomponent1:default:default:1.0 param1: 123 param2: ABC - type: mycomponent2,mypackage param1: 321 param2: XYZ ============================ let container = new Container(); container.addFactory(new MyComponentFactory()); let parameters = ConfigParams.fromValue(process.env); container.readConfigFromFile("123", "./config/config.yml", parameters); container.open("123", (err) => { console.log("Container is opened"); ... container.close("123", (err) => { console.log("Container is closed"); }); });