UNPKG

ajsfw

Version:
89 lines (88 loc) 3.56 kB
import { Ctor } from "ajsfw/types"; import { Exception } from "ajsfw/exceptions"; import { AjsWebWorker } from "./ajs-web-worker/AjsWebWorker"; export declare class ServiceContainerExistsAlreadyException extends Exception { } export declare class ServiceContainerNotExistException extends Exception { } export declare class FailedToLocateWebWorkerException extends Exception { } export declare class ServiceManagerEndpointAssignedAlreadyException extends Exception { } export declare class ServiceManagerNotRegisteredWithTheWebWorkerException extends Exception { } export declare class FailedToLocateNamespaceInParentNamespaceException extends Exception { } export interface IServiceManagerConfig { workerUrl: string; workerLibraries: string[]; mainUiThreadServiceContainerName: string; } export interface IAjsWorkerInfo { worker: AjsWebWorker; serviceManagerId: number; webWokrerReadyResolver: () => void; webWorkerReadyRejector: (reason: any) => void; } export interface INamedServiceInstance { id: number; serviceLocator: string; serviceClass: Ctor; serviceInstance: any; } export interface INamedServiceInstances { [name: string]: INamedServiceInstance; } export interface IServiceContainer { deployedNamespaces: any[]; deployedServices: string[]; instancedServices: number[]; namedServiceInstances: INamedServiceInstances; } export interface IServiceContainerInfo extends IServiceContainer { ajsWorkerInfo: IAjsWorkerInfo; } export interface IServiceContainers { [name: string]: IServiceContainerInfo; } export interface IDeployedNamespace { ns: any; stringified: string; members: any[]; } export interface IDeployedServiceMethods { service: Ctor; methods: string[]; } export declare class ServiceManager { private __config; private __rmiRouter; private __workerUrl; private __workerLibraries; private __localServiceContainer; private __serviceContainers; private __deployedNamespaces; private __deployedServices; private __deployedServicesMethods; constructor(config?: IServiceManagerConfig); createServiceContainer(name: string): Promise<void>; instantiateLocalNamedService(serviceName: string, service: Ctor, ...ctorArgs: any[]): Promise<any>; instantiateLocalService(service: Ctor, ...ctorArgs: any[]): Promise<any>; instantiateNamedService(serviceName: string, serviceContainerName: string, serviceCodeScope: string, service: Ctor, ...ctorArgs: any[]): Promise<any>; instantiateService(serviceContainerName: string, service: Ctor, ...ctorArgs: any[]): Promise<any>; deployNamespace(serviceContainerName: string, ...namespaces: any[]): Promise<void>; private __serializeNamespace(nsName, ns); private __deployServiceCode(serviceContainerName, service); private __createServiceProxy(serviceCtor, serviceId); testCall(rmiId: number, method: string, ...args: any[]): Promise<any>; private __onRMIEndpointCreated(iface, endpointId); private __getServiceContainerByWorker(ajsWorker); private __getDeployedServiceMethods(service); private __extractDeployedServiceMethods(service); private __serializeClass(obj); private __buildClassString(obj); private __defaultConfig(); private __deployServiceCode_call(remoteServiceManager, serviceName, serviceCode); private __instantiateService_call(remoteServiceManager, serviceName, ctorArgs); private __workerCode(); }