ing
This commit is contained in:
parent
9a95712637
commit
7c45f214ff
|
@ -1,8 +1,22 @@
|
||||||
|
import {
|
||||||
|
PropertyType,
|
||||||
|
} from '@loafer/core/constants/types';
|
||||||
|
|
||||||
|
import EnvironmentCapable from '@loafer/core/env/EnvironmentCapable';
|
||||||
|
|
||||||
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
||||||
import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory';
|
import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory';
|
||||||
|
import ListablePouchFactory from '@loafer/pouches/factory/ListablePouchFactory';
|
||||||
|
import HierarchicalPouchFactory from '@loafer/pouches/factory/HierarchicalPouchFactory';
|
||||||
|
import InjectCapablePouchFactory from '@loafer/pouches/factory/config/InjectCapablePouchFactory';
|
||||||
|
|
||||||
interface ApplicationContext extends PouchFactory {
|
export interface ApplicationContext extends EnvironmentCapable, ListablePouchFactory, HierarchicalPouchFactory {
|
||||||
getPouchFactory(): DefaultPouchFactory;
|
getId?(): PropertyType;
|
||||||
|
getApplicationName(): string;
|
||||||
|
getDisplayName(): string;
|
||||||
|
getParent?(): ApplicationContext;
|
||||||
|
|
||||||
|
getInjectCapablePouchFactory(): InjectCapablePouchFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ApplicationContext;
|
export default ApplicationContext;
|
||||||
|
|
18
src/ts/@loafer/context/ConfigurableApplicationContext.ts
Normal file
18
src/ts/@loafer/context/ConfigurableApplicationContext.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import {
|
||||||
|
PropertyType,
|
||||||
|
} from '@loafer/core/constants/types';
|
||||||
|
import ConfigurableEnvironment from '@loafer/core/env/ConfigurableEnvironment';
|
||||||
|
import ApplicationContext from '@loafer/context/ApplicationContext';
|
||||||
|
import Lifecycle from '@loafer/context/Lifecycle';
|
||||||
|
|
||||||
|
export interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle {
|
||||||
|
setId(id: PropertyType): void;
|
||||||
|
setEnvironment(environment: ConfigurableEnvironment): void;
|
||||||
|
getEnvironment(): ConfigurableEnvironment;
|
||||||
|
addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor): void;
|
||||||
|
addApplicationListener(ApplicationListener< ? > listener ): void;
|
||||||
|
refresh(): void;
|
||||||
|
getBeanFactory(): ConfigurableListablePouchFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurableApplicationContext;
|
7
src/ts/@loafer/context/Lifecycle.ts
Normal file
7
src/ts/@loafer/context/Lifecycle.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
export interface Lifecycle {
|
||||||
|
start(): void;
|
||||||
|
stop(): void;
|
||||||
|
isRunning(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Lifecycle;
|
|
@ -5,7 +5,7 @@ import {
|
||||||
import {
|
import {
|
||||||
Decorator,
|
Decorator,
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
|
|
|
@ -6,7 +6,9 @@ import {
|
||||||
import {
|
import {
|
||||||
Decorator,
|
Decorator,
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
|
@ -17,10 +19,11 @@ export interface PouchConfig {
|
||||||
type?: ClassType;
|
type?: ClassType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PouchAnnotation implements DecoratorHandler {
|
export class PouchAnnotation extends Annotation implements DecoratorHandler {
|
||||||
private readonly Qualifier: PropertyType;
|
private readonly Qualifier: PropertyType;
|
||||||
private readonly Type: ClassType;
|
private readonly Type: ClassType;
|
||||||
public constructor(config: PouchConfig = {}) {
|
public constructor(config: PouchConfig = {}) {
|
||||||
|
super();
|
||||||
this.Qualifier = config.qualifier;
|
this.Qualifier = config.qualifier;
|
||||||
this.Type = config.type;
|
this.Type = config.type;
|
||||||
}
|
}
|
||||||
|
|
4
src/ts/@loafer/core/annotation/Annotation.ts
Normal file
4
src/ts/@loafer/core/annotation/Annotation.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export abstract class Annotation {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Annotation;
|
1
src/ts/@loafer/core/annotation/index.ts
Normal file
1
src/ts/@loafer/core/annotation/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from './Annotation';
|
|
@ -5,10 +5,11 @@ import {
|
||||||
import * as ReflectConstants from '@loafer/core/constants/reflect';
|
import * as ReflectConstants from '@loafer/core/constants/reflect';
|
||||||
import Reflection from '@loafer/core/reflect/Reflection';
|
import Reflection from '@loafer/core/reflect/Reflection';
|
||||||
import Class from '@loafer/core/reflect/Class';
|
import Class from '@loafer/core/reflect/Class';
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
import DecoratorType from './DecoratorType';
|
import DecoratorType from './DecoratorType';
|
||||||
|
|
||||||
export class Decorator {
|
export class Decorator {
|
||||||
public static create = (Annotation: Construtorable<any>) => {
|
public static create = (Annotation: Construtorable<Annotation>) => {
|
||||||
return (...handlerArgs: any[]) => {
|
return (...handlerArgs: any[]) => {
|
||||||
let annotation = new Annotation(...handlerArgs);
|
let annotation = new Annotation(...handlerArgs);
|
||||||
|
|
||||||
|
|
11
src/ts/@loafer/core/env/ConfigurableEnvironment.ts
vendored
Normal file
11
src/ts/@loafer/core/env/ConfigurableEnvironment.ts
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import Environment from '@loafer/core/env/Environment';
|
||||||
|
|
||||||
|
export interface ConfigurableEnvironment extends Environment {
|
||||||
|
setActiveProfiles(...profiles: string[]): void;
|
||||||
|
addActiveProfiles(profile: string): void;
|
||||||
|
setDefaultProfiles(...profiles: string[]): void;
|
||||||
|
getSystemEnvironment(): Map<string, any>;
|
||||||
|
getSystemProperties(): Map<string, any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Environment;
|
6
src/ts/@loafer/core/env/ConfigurablePropertyResolver.ts
vendored
Normal file
6
src/ts/@loafer/core/env/ConfigurablePropertyResolver.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import PropertyResolver from '@loafer/core/env/PropertyResolver';
|
||||||
|
|
||||||
|
export interface ConfigurablePropertyResolver extends PropertyResolver {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurablePropertyResolver;
|
9
src/ts/@loafer/core/env/Environment.ts
vendored
Normal file
9
src/ts/@loafer/core/env/Environment.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import PropertyResolver from '@loafer/core/env/PropertyResolver';
|
||||||
|
|
||||||
|
export interface Environment extends PropertyResolver {
|
||||||
|
getActiveProfiles(): string[];
|
||||||
|
getDefaultProfiles(): string[];
|
||||||
|
acceptsProfiles(...profiles: string[]): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Environment;
|
7
src/ts/@loafer/core/env/EnvironmentCapable.ts
vendored
Normal file
7
src/ts/@loafer/core/env/EnvironmentCapable.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import Environment from '@loafer/core/env/Environment';
|
||||||
|
|
||||||
|
export interface EnvironmentCapable {
|
||||||
|
getEnvironment(): Environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EnvironmentCapable;
|
6
src/ts/@loafer/core/env/PropertyResolver.ts
vendored
Normal file
6
src/ts/@loafer/core/env/PropertyResolver.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export interface PropertyResolver {
|
||||||
|
containsProperty(key: string): boolean;
|
||||||
|
getProperty(key: string, defaultValue?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PropertyResolver;
|
|
@ -8,6 +8,8 @@ import {
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
@ -18,12 +20,13 @@ export interface InjectConfig {
|
||||||
type?: ClassType;
|
type?: ClassType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InjectAnnotation implements DecoratorHandler {
|
export class InjectAnnotation extends Annotation implements DecoratorHandler {
|
||||||
private readonly Qualifier: PropertyType;
|
private readonly Qualifier: PropertyType;
|
||||||
private readonly Required: boolean;
|
private readonly Required: boolean;
|
||||||
private readonly Type: ClassType;
|
private readonly Type: ClassType;
|
||||||
|
|
||||||
public constructor(config: InjectConfig = {}) {
|
public constructor(config: InjectConfig = {}) {
|
||||||
|
super();
|
||||||
this.Qualifier = config.qualifier;
|
this.Qualifier = config.qualifier;
|
||||||
this.Required = config.required;
|
this.Required = config.required;
|
||||||
this.Type = config.type;
|
this.Type = config.type;
|
||||||
|
|
|
@ -7,14 +7,17 @@ import {
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
export class InjectableAnnotation implements DecoratorHandler {
|
export class InjectableAnnotation extends Annotation implements DecoratorHandler {
|
||||||
private readonly Qualifier: PropertyType;
|
private readonly Qualifier: PropertyType;
|
||||||
|
|
||||||
public constructor(qualifier?: PropertyType) {
|
public constructor(qualifier?: PropertyType) {
|
||||||
|
super();
|
||||||
this.Qualifier = qualifier;
|
this.Qualifier = qualifier;
|
||||||
}
|
}
|
||||||
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => {
|
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => {
|
||||||
|
|
|
@ -5,13 +5,15 @@ import {
|
||||||
import {
|
import {
|
||||||
Decorator,
|
Decorator,
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
export class PostConstructAnnotation implements DecoratorHandler {
|
export class PostConstructAnnotation extends Annotation implements DecoratorHandler {
|
||||||
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
|
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
|
||||||
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
|
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
|
||||||
console.log('PostConstruct');
|
console.log('PostConstruct');
|
||||||
|
|
|
@ -5,13 +5,15 @@ import {
|
||||||
import {
|
import {
|
||||||
Decorator,
|
Decorator,
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
export class PreDestroyAnnotation implements DecoratorHandler {
|
export class PreDestroyAnnotation extends Annotation implements DecoratorHandler {
|
||||||
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
|
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
|
||||||
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
|
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
|
||||||
console.log('PreDestroy');
|
console.log('PreDestroy');
|
||||||
|
|
|
@ -11,10 +11,13 @@ import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
export class ScopeAnnotation implements DecoratorHandler {
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
|
export class ScopeAnnotation extends Annotation implements DecoratorHandler {
|
||||||
private readonly Qualifier: PropertyType;
|
private readonly Qualifier: PropertyType;
|
||||||
|
|
||||||
public constructor(qualifier?: PropertyType) {
|
public constructor(qualifier?: PropertyType) {
|
||||||
|
super();
|
||||||
this.Qualifier = qualifier;
|
this.Qualifier = qualifier;
|
||||||
}
|
}
|
||||||
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => {
|
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => {
|
||||||
|
|
|
@ -6,16 +6,19 @@ import {
|
||||||
import {
|
import {
|
||||||
Decorator,
|
Decorator,
|
||||||
DecoratorHandler,
|
DecoratorHandler,
|
||||||
} from '@loafer/core/decorator';
|
} from '@loafer/core/decorator';
|
||||||
|
|
||||||
|
import Annotation from '@loafer/core/annotation/Annotation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Class,
|
Class,
|
||||||
} from '@loafer/core/reflect';
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
export class ValueAnnotation implements DecoratorHandler {
|
export class ValueAnnotation extends Annotation implements DecoratorHandler {
|
||||||
private readonly Value: PropertyType;
|
private readonly Value: PropertyType;
|
||||||
|
|
||||||
public constructor(value: PropertyType) {
|
public constructor(value: PropertyType) {
|
||||||
|
super();
|
||||||
this.Value = value;
|
this.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
||||||
|
|
||||||
|
export interface HierarchicalPouchFactory extends PouchFactory {
|
||||||
|
getParentBeanFactory(): PouchFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HierarchicalPouchFactory;
|
9
src/ts/@loafer/pouches/factory/ListablePouchFactory.ts
Normal file
9
src/ts/@loafer/pouches/factory/ListablePouchFactory.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
||||||
|
|
||||||
|
export interface ListablePouchFactory extends PouchFactory {
|
||||||
|
containsPouchDefinition(pouchName: string): boolean;
|
||||||
|
getPouchDefinitionCount(): number;
|
||||||
|
getPouchDefinitionNames(): string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ListablePouchFactory;
|
|
@ -3,22 +3,30 @@ import {
|
||||||
PropertyType,
|
PropertyType,
|
||||||
} from '@loafer/core/constants/types';
|
} from '@loafer/core/constants/types';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Class,
|
||||||
|
} from '@loafer/core/reflect';
|
||||||
|
|
||||||
interface PouchFactory {
|
interface PouchFactory {
|
||||||
/**
|
/**
|
||||||
* @param qualifier is identity of pouch
|
* @param name is identity of pouch
|
||||||
* @param clazz is type of pouch (if clazz is not specified, set the undefined)
|
* @param type is type of pouch (if type is not specified, set the undefined)
|
||||||
* @param args are argument of target constructor
|
* @param args are argument of target constructor
|
||||||
* @returns an instance of pouch
|
* @returns an instance of pouch
|
||||||
*/
|
*/
|
||||||
getPouch(qualifier: PropertyType, clazz: ClassType, ...args: any[]): any;
|
getPouch(name: PropertyType, type: ClassType, ...args: any[]): any;
|
||||||
/**
|
/**
|
||||||
* @param clazz is type of pouch
|
* @param type is type of pouch
|
||||||
* @param qualifier is identity of pouch (if qualifier is not specified, set the undefined)
|
* @param qualifier is identity of pouch (if qualifier is not specified, set the undefined)
|
||||||
* @param args are argument of target constructor
|
* @param args are argument of target constructor
|
||||||
* @returns an instance of pouch
|
* @returns an instance of pouch
|
||||||
*/
|
*/
|
||||||
getPouchByClass(clazz: ClassType, qualifier: PropertyType, ...args: any[]): any;
|
getPouchByType(type: ClassType, ...args: any[]): any;
|
||||||
|
|
||||||
|
containsPouch(name: string): boolean;
|
||||||
|
isSingleton(name: string): boolean;
|
||||||
|
isTransient(name: string): boolean;
|
||||||
|
getClass(name: string): Class;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PouchFactory;
|
export default PouchFactory;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import {
|
||||||
|
ClassType,
|
||||||
|
PropertyType,
|
||||||
|
} from '@loafer/core/constants/types';
|
||||||
|
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
||||||
|
|
||||||
|
export interface InjectCapablePouchFactory extends PouchFactory {
|
||||||
|
createPouch(type: ClassType, injectMode?: number, dependencyCheck?: boolean): any;
|
||||||
|
injectPouch(existingPouch: any): void;
|
||||||
|
configureBean(existingBean: any, pouchName: PropertyType): any;
|
||||||
|
inject(type: ClassType, injectMode: number, dependencyCheck: boolean): any;
|
||||||
|
injectPouchProperties(existingPouch: any, injectMode: number, dependencyCheck: boolean): void;
|
||||||
|
applyPouchPropertyValues(existingPouch: any, pouchName: PropertyType): void;
|
||||||
|
initializePouch?(existingPouch: any, pouchName: PropertyType): any;
|
||||||
|
applyPouchPostProcessorsBeforeInitialization?(existingPouch: any, pouchName: PropertyType): any;
|
||||||
|
applyPouchPostProcessorsAfterInitialization?(existingPouch: any, pouchName: PropertyType): any;
|
||||||
|
destroyPouch(existingPouch: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InjectCapablePouchFactory;
|
Loading…
Reference in New Issue
Block a user