/** * 基础的ObjectFactory和ApplicationContext实现 */ import { IApplicationContext, ILifeCycle, IMessageSource, IObjectDefinition, IObjectDefinitionRegistry, IObjectFactory, ObjectDependencyTree, ObjectIdentifier } from '../interfaces'; import { ObjectConfiguration } from '../base/configuration'; import { ManagedResolverFactory } from './common/managedResolverFactory'; export declare const ContextEvent: { START: string; READY: string; ONREFRESH: string; STOP: string; }; export declare class ObjectDefinitionRegistry extends Map implements IObjectDefinitionRegistry { private singletonIds; get identifiers(): any[]; get count(): number; getSingletonDefinitionIds(): ObjectIdentifier[]; getDefinitionByName(name: string): IObjectDefinition[]; registerDefinition(identifier: ObjectIdentifier, definition: IObjectDefinition): void; getDefinition(identifier: ObjectIdentifier): IObjectDefinition; getDefinitionByPath(path: string): IObjectDefinition; removeDefinition(identifier: ObjectIdentifier): void; hasDefinition(identifier: ObjectIdentifier): boolean; clearAll(): void; hasObject(identifier: ObjectIdentifier): boolean; registerObject(identifier: ObjectIdentifier, target: any): void; getObject(identifier: ObjectIdentifier): any; } export declare class BaseApplicationContext implements IApplicationContext, IObjectFactory { protected refreshing: boolean; protected readied: boolean; protected lifeCycle: ILifeCycle; private _resolverFactory; private _registry; private _props; private _dependencyMap; baseDir: string; parent: IApplicationContext; configLocations: string[]; messageSource: IMessageSource; constructor(baseDir?: string, parent?: IApplicationContext); get dependencyMap(): Map; get props(): ObjectConfiguration; get registry(): IObjectDefinitionRegistry; protected getManagedResolverFactory(): ManagedResolverFactory; /** * 继承实现时需要调用super */ protected init(): void; stop(): Promise; ready(): Promise; refreshAsync(): Promise; protected loadDefinitions(configLocations?: string[]): void; isAsync(identifier: ObjectIdentifier): boolean; get(identifier: ObjectIdentifier, args?: any): T; getAsync(identifier: ObjectIdentifier, args?: any): Promise; addLifeCycle(lifeCycle: ILifeCycle): void; removeLifeCycle(): void; get isReady(): boolean; /** * proxy registry.registerDefinition * @param {ObjectIdentifier} identifier * @param {IObjectDefinition} definition */ registerDefinition(identifier: ObjectIdentifier, definition: IObjectDefinition): void; /** * proxy registry.registerObject * @param {ObjectIdentifier} identifier * @param target */ registerObject(identifier: ObjectIdentifier, target: any): void; /** * register handler after instance create * @param fn */ afterEachCreated(fn: (ins: any, context: IApplicationContext, definition?: IObjectDefinition) => void): void; /** * register handler before instance create * @param fn */ beforeEachCreated(fn: (Clzz: any, constructorArgs: any[], context: IApplicationContext) => void): void; protected createObjectDependencyTree(identifier: any, definition: any): void; dumpDependency(): void; }