/*! Copyright (c) 2018 Siemens AG. Licensed under the MIT License. */ import { Container, ControllerOptions, Log } from ".."; import { IDisposable } from "../runtime/disposable"; /** * Defines lifecycle methods for controllers. */ export interface IController extends IDisposable { /** * Called when the container has completely set up and injected all * dependency components, including all its controllers. */ onInit(): any; /** * Called when the Communication Manager is about to start. */ onCommunicationManagerStarting(): any; /** * Called when the Communication Manager is about to stop. */ onCommunicationManagerStopping(): any; } /** * Defines static constructor signature for controllers that implement the * IController interface. To be used for constructor dependency injection * in a Coaty container. */ export declare type IControllerStatic = new (container: Container, options: ControllerOptions, controllerName: string) => T; /** * The base controller class. */ export declare abstract class Controller implements IController { private _container; private _options; private _controllerName; /** * @internal For internal use in framework only. * * Never instantiate Controller objects in your application; they are * created automatically by dependency injection. */ constructor(_container: Container, _options: ControllerOptions, _controllerName: string); /** * Gets the container object of this controller. */ get container(): Container; /** * Gets the container's Runtime object. */ get runtime(): import("..").Runtime; /** * Gets the controller's options as specified in the configuration options. */ get options(): Readonly; /** * Gets the container's communication manager. */ get communicationManager(): import("..").CommunicationManager; /** * Gets the registered name of this controller. * * The registered name is either defined by the corresponding key in the * `Components.controllers` object in the container configuration, or by * invoking `Container.registerController` method with this name. */ get registeredName(): string; /** * Advertise a Log object for debugging purposes. * * @param message a debug message * @param tags any number of log tags */ logDebug(message: string, ...tags: string[]): void; /** * Advertise an informational Log object. * * @param message an informational message * @param tags any number of log tags */ logInfo(message: string, ...tags: string[]): void; /** * Advertise a Log object for a warning. * * @param message a warning message * @param tags any number of log tags */ logWarning(message: string, ...tags: string[]): void; /** * Advertise a Log object for an error. * * @param error an error (object) * @param message additional error message * @param tags any number of log tags */ logError(error: any, message: string, ...tags: string[]): void; /** * Advertise a Log object for an error with stacktrace information. * * @param error an error (object) * @param message additional error message * @param tags any number of log tags */ logErrorWithStacktrace(error: any, message: string, ...tags: string[]): void; /** * Advertise a Log object for a fatal error. * * @param error an error (object) * @param message additional error message * @param tags any number of log tags */ logFatal(error: any, message: string, ...tags: string[]): void; /** * Called when the container has completely set up and injected all * dependency components, including all its controllers. * * Override this method to perform initializations in your custom controller * class instead of defining a constructor. Although the base implementation * does nothing it is good practice to call `super.onInit()` in your * override method; especially if your custom controller class does not * extend from the base `Controller` class directly. */ onInit(): void; /** * Called when the communication manager is about to start or restart. * * Override this method to implement side effects here. Ensure that * `super.onCommunicationManagerStarting` is called in your override. The * base implementation does nothing. */ onCommunicationManagerStarting(): void; /** * Called when the communication manager is about to stop. * * Override this method to implement side effects here. Ensure that * `super.onCommunicationManagerStopping` is called in your override. The * base implementation does nothing. */ onCommunicationManagerStopping(): void; /** * Called by the container when this instance should be disposed. * * Implement cleanup side effects here. Ensure that `super.onDispose` is * called in your override. The base implementation does nothing. */ onDispose(): void; /** * Whenever one of the controller's log methods (e.g. `logDebug`, `logInfo`, * `logWarning`, `logError`, `logFatal`) is called by application code, the * controller creates a Log object with appropriate property values and * passes it to this method before advertising it. * * You can override this method to additionally set certain properties (such * as `LogHost.hostname` or `Log.logLabels`). Ensure that * `super.extendLogObject` is called in your override. The base method does * nothing. * * @param log log object to be extended before being advertised */ protected extendLogObject(log: Log): void; private _log; }