ing
This commit is contained in:
parent
72e95d73d4
commit
e7c032b720
|
@ -11,6 +11,9 @@ import {
|
|||
Annotation,
|
||||
} from '@loafer/core/annotation';
|
||||
|
||||
import {
|
||||
PouchDefinitionRegistry,
|
||||
} from '@loafer/pouches/factory/support';
|
||||
|
||||
|
||||
import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext';
|
||||
|
|
|
@ -7,9 +7,12 @@ import {
|
|||
} from '@loafer/core/util';
|
||||
|
||||
import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext';
|
||||
import AnnotatedPouchDefinitionReader from '@loafer/context/annotation/AnnotatedPouchDefinitionReader';
|
||||
|
||||
|
||||
|
||||
export class AnnotationConfigApplicationContext extends GenericApplicationContext {
|
||||
private readonly reader: AnnotatedBeanDefinitionReader;
|
||||
private readonly reader: AnnotatedPouchDefinitionReader;
|
||||
|
||||
|
||||
public register(...annotatedClasses: ClassType[]): void {
|
||||
|
|
|
@ -3,6 +3,10 @@ import {
|
|||
} from '@loafer/core/constants/types';
|
||||
|
||||
export interface AliasRegistry {
|
||||
registerAlias(name: PropertyType, alias: PropertyType): void;
|
||||
removeAlias(alias: PropertyType): void;
|
||||
isAlias(name: PropertyType): boolean;
|
||||
getAliases(name: PropertyType): PropertyType[];
|
||||
}
|
||||
|
||||
export default AliasRegistry;
|
||||
|
|
11
src/ts/@loafer/core/NestedRuntimeException.ts
Normal file
11
src/ts/@loafer/core/NestedRuntimeException.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import {
|
||||
RuntimeException,
|
||||
} from '@loafer/core/lang';
|
||||
|
||||
export class NestedRuntimeException extends RuntimeException {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export default NestedRuntimeException;
|
3
src/ts/@loafer/core/index.ts
Normal file
3
src/ts/@loafer/core/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export * from './AliasRegistry';
|
||||
export * from './NestedRuntimeException';
|
||||
export * from './SimpleAliasRegistry';
|
|
@ -1,4 +1,8 @@
|
|||
export class IllegalArgumentException extends Error {
|
||||
import {
|
||||
RuntimeException,
|
||||
} from '@loafer/core/lang';
|
||||
|
||||
export class IllegalArgumentException extends RuntimeException {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
export class IllegalStateException extends Error {
|
||||
import {
|
||||
RuntimeException,
|
||||
} from '@loafer/core/lang';
|
||||
|
||||
export class IllegalStateException extends RuntimeException {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
|
|
7
src/ts/@loafer/core/lang/RuntimeException.ts
Normal file
7
src/ts/@loafer/core/lang/RuntimeException.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export class RuntimeException extends Error {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export default RuntimeException;
|
|
@ -1,2 +1,3 @@
|
|||
export * from './IllegalArgumentException';
|
||||
export * from './IllegalStateException';
|
||||
export * from './RuntimeException';
|
||||
|
|
11
src/ts/@loafer/pouches/PouchesException.ts
Normal file
11
src/ts/@loafer/pouches/PouchesException.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import {
|
||||
NestedRuntimeException,
|
||||
} from '@loafer/core';
|
||||
|
||||
export class PouchesException extends NestedRuntimeException {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export default PouchesException;
|
|
@ -0,0 +1,11 @@
|
|||
import {
|
||||
PouchesException,
|
||||
} from '@loafer/pouches';
|
||||
|
||||
export class NoSuchPouchDefinitionException extends PouchesException {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export default NoSuchPouchDefinitionException;
|
|
@ -0,0 +1,7 @@
|
|||
export class PouchDefinitionStoreException extends Error {
|
||||
public constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export default PouchDefinitionStoreException;
|
|
@ -0,0 +1,10 @@
|
|||
import {
|
||||
ClassType,
|
||||
PropertyType,
|
||||
} from '@loafer/core/constants/types';
|
||||
import PouchFactory from '@loafer/pouches/factory/PouchFactory';
|
||||
|
||||
export interface ConfigurableListablePouchFactory {
|
||||
}
|
||||
|
||||
export default ConfigurableListablePouchFactory;
|
8
src/ts/@loafer/pouches/factory/config/index.ts
Normal file
8
src/ts/@loafer/pouches/factory/config/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export * from './ConfigurableListablePouchFactory';
|
||||
export * from './ConfigurablePouchFactory';
|
||||
export * from './InjectCapablePouchFactory';
|
||||
export * from './PouchDefinition';
|
||||
export * from './PouchExpressionContext';
|
||||
export * from './PouchExpressionResolver';
|
||||
export * from './Scope';
|
||||
export * from './SingletonPouchRegistry';
|
7
src/ts/@loafer/pouches/factory/index.ts
Normal file
7
src/ts/@loafer/pouches/factory/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export * from './FactoryPouch';
|
||||
export * from './HierarchicalPouchFactory';
|
||||
export * from './ListablePouchFactory';
|
||||
|
||||
export * from './NoSuchPouchDefinitionException';
|
||||
export * from './PouchDefinitionStoreException';
|
||||
export * from './PouchFactory';
|
|
@ -3,8 +3,69 @@ import {
|
|||
} from '@loafer/core/constants/types';
|
||||
import AliasRegistry from '@loafer/core/AliasRegistry';
|
||||
import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition';
|
||||
import {
|
||||
PouchDefinitionStoreException,
|
||||
NoSuchPouchDefinitionException,
|
||||
} from '@loafer/pouches/factory';
|
||||
|
||||
|
||||
export interface PouchDefinitionRegistry extends AliasRegistry {
|
||||
|
||||
/**
|
||||
* Register a new pouch definition with this registry.
|
||||
* Must support RootPouchDefinition and ChildPouchDefinition.
|
||||
* @param pouchName the name of the pouch instance to register
|
||||
* @param pouchDefinition definition of the pouch instance to register
|
||||
* @throws PouchDefinitionStoreException if the PouchDefinition is invalid
|
||||
* or if there is already a PouchDefinition for the specified pouch name
|
||||
* (and we are not allowed to override it)
|
||||
* @see RootPouchDefinition
|
||||
* @see ChildPouchDefinition
|
||||
*/
|
||||
registerPouchDefinition(pouchName: PropertyType, pouchDefinition: PouchDefinition): void;
|
||||
|
||||
/**
|
||||
* Remove the PouchDefinition for the given name.
|
||||
* @param pouchName the name of the pouch instance to register
|
||||
* @throws NoSuchPouchDefinitionException if there is no such pouch definition
|
||||
*/
|
||||
removePouchDefinition(pouchName: PropertyType): void;
|
||||
|
||||
/**
|
||||
* Return the PouchDefinition for the given pouch name.
|
||||
* @param pouchName name of the pouch to find a definition for
|
||||
* @return the PouchDefinition for the given name (never {@code null})
|
||||
* @throws NoSuchPouchDefinitionException if there is no such pouch definition
|
||||
*/
|
||||
getPouchDefinition(pouchName: PropertyType): PouchDefinition;
|
||||
|
||||
/**
|
||||
* Check if this registry contains a pouch definition with the given name.
|
||||
* @param pouchName the name of the pouch to look for
|
||||
* @return if this registry contains a pouch definition with the given name
|
||||
*/
|
||||
containsPouchDefinition(pouchName: PropertyType): boolean;
|
||||
|
||||
/**
|
||||
* Return the names of all pouchs defined in this registry.
|
||||
* @return the names of all pouchs defined in this registry,
|
||||
* or an empty array if none defined
|
||||
*/
|
||||
getPouchDefinitionNames(): PropertyType[];
|
||||
|
||||
/**
|
||||
* Return the number of pouchs defined in the registry.
|
||||
* @return the number of pouchs defined in the registry
|
||||
*/
|
||||
getPouchDefinitionCount(): number;
|
||||
|
||||
/**
|
||||
* Determine whether the given pouch name is already in use within this registry,
|
||||
* i.e. whether there is a local pouch or alias registered under this name.
|
||||
* @param pouchName the name to check
|
||||
* @return whether the given pouch name is already in use
|
||||
*/
|
||||
isPouchNameInUse(pouchName: PropertyType): boolean;
|
||||
}
|
||||
|
||||
export default AliasRegistry;
|
||||
export default PouchDefinitionRegistry;
|
||||
|
|
31
src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts
Normal file
31
src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {
|
||||
ClassType,
|
||||
PropertyType,
|
||||
} from '@loafer/core/constants/types';
|
||||
|
||||
import AliasRegistry from '@loafer/core/AliasRegistry';
|
||||
|
||||
import {
|
||||
FactoryPouch,
|
||||
} from '@loafer/pouches/factory';
|
||||
|
||||
import {
|
||||
PouchDefinition,
|
||||
} from '@loafer/pouches/factory/config';
|
||||
|
||||
import {
|
||||
DefaultSingletonPouchRegistry,
|
||||
} from '@loafer/pouches/factory/support';
|
||||
|
||||
export interface PouchNameGenerator {
|
||||
/**
|
||||
* Generate a pouch name for the given pouch definition.
|
||||
* @param definition the pouch definition to generate a name for
|
||||
* @param registry the pouch definition registry that the given definition
|
||||
* is supposed to be registered with
|
||||
* @return the generated pouch name
|
||||
*/
|
||||
generatePouchName(definition: PouchDefinition, registry: PouchDefinitionRegistry): PropertyType;
|
||||
}
|
||||
|
||||
export default PouchNameGenerator;
|
6
src/ts/@loafer/pouches/factory/support/index.ts
Normal file
6
src/ts/@loafer/pouches/factory/support/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export * from './AbstractInjectCapablePouchFactory';
|
||||
export * from './AbstractPouchFactory';
|
||||
export * from './DefaultListablePouchFactory';
|
||||
export * from './DefaultSingletonPouchRegistry';
|
||||
export * from './FactoryPouchRegistrySupport';
|
||||
export * from './PouchDefinitionRegistry';
|
1
src/ts/@loafer/pouches/index.ts
Normal file
1
src/ts/@loafer/pouches/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './PouchesException';
|
Loading…
Reference in New Issue
Block a user