/*! Copyright (c) 2018 Siemens AG. Licensed under the MIT License. */ import { CommunicationManager, Controller, Identity } from ".."; import { IController, IControllerStatic } from "../controller/controller"; import { Configuration, ControllerOptions } from "./configuration"; import { Runtime } from "./runtime"; /** * Defines the application-specific container components to be registered with a * Coaty Container. * * The configuration options for the container component classes are specified * in the `controllers` options of a Configuration object. */ export interface Components { /** * Application-specific controller classes to be registered with the * container (optional). * * The configuration options for a controller class listed here are * specified in the controller configuration under a key that matches the * associated name of the controller. */ controllers?: { [controllerName: string]: IControllerStatic; }; } /** * An IoC container that uses constructor dependency injection to create * container components and to resolve dependencies. This container defines the * entry and exit points for any Coaty application providing lifecycle * management for its components. */ export declare class Container { private _identity; private _runtime; private _comManager; private _controllers; private _isShutdown; private _operatingStateSubscription; /** * Creates and bootstraps a Coaty container by registering and resolving the * given components and configuration options. * * @param components the components to set up within this container * @param configuration the configuration options for the components * @param configTransformer a function to transform the given configuration * (optional) * @returns a Container for the given components * @throws if configuration is falsy. */ static resolve(components: Components, configuration: Configuration, configTransformer?: (config: Configuration) => Configuration): Container; /** * Asynchronously creates and bootstraps a Coaty container by registering * and resolving the given components and configuration options. Use this * method if configuration should be retrieved asnychronously (e.g. via * HTTP) by one of the predefined runtime configuration providers (see * runtime-angular, runtime-node). The promise returned will be rejected if * the configuration could not be retrieved or has a falsy value. * * @param components the components to set up within this container * @param configuration a promise for the configuration options * @param configTransformer a function to transform the retrieved * configuration (optional) * @returns a promise on a Container for the given components */ static resolveAsync(components: Components, configuration: Promise, configTransformer?: (config: Configuration) => Configuration): Promise; /** * Dynamically registers and resolves the given controller type with the * specified controller options. The request is silently ignored if the * container has already been shut down. * * @param controllerName the name to be registered with the controller * @param controllerType the class type of the controller * @param controllerOptions the controller's configuration options (optional) * @returns the resolved controller instance or `undefined` if a controller * could not be resolved */ registerController(controllerName: string, controllerType: IControllerStatic, controllerOptions?: ControllerOptions): T; /** * Gets the identity object of this container. * * The identity can be initialized in the common configuration option * `agentIdentity`. */ get identity(): Readonly; /** * Gets the runtime object of this container. */ get runtime(): Runtime; /** * Gets the communication manager of this container. */ get communicationManager(): CommunicationManager; /** * Gets the registered controller of the given controller name. Returns * `undefined` if a controller with the given name is not registered in * `Components`. * * @param controllerName the name of the controller specified as * `Components` key for the controller */ getController(controllerName: string): T; /** * Creates a new array with the results of calling the provided callback * function once for each registered controller * name/controllerType/controller instance triple. * * @param callback function that returns an element of the new array */ mapControllers(callback: (controllerName: string, controllerType: IControllerStatic, controller: IController) => T): T[]; /** * The exit point for a Coaty applicaton. Releases all registered container * components and its associated system resources. This container should no * longer be used afterwards. */ shutdown(): void; private _createIdentity; private _resolveComponents; private _resolveController; private _releaseComponents; private _operatingStateCallback; }