diff --git a/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts b/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts index 0576d25..a80a25e 100644 --- a/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts +++ b/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts @@ -11,6 +11,9 @@ import { Annotation, } from '@loafer/core/annotation'; +import { + PouchDefinitionRegistry, +} from '@loafer/pouches/factory/support'; import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext'; diff --git a/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts b/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts index b372f90..d0b6cef 100644 --- a/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts +++ b/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts @@ -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 { diff --git a/src/ts/@loafer/core/AliasRegistry.ts b/src/ts/@loafer/core/AliasRegistry.ts index 3597200..c4f6479 100644 --- a/src/ts/@loafer/core/AliasRegistry.ts +++ b/src/ts/@loafer/core/AliasRegistry.ts @@ -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; diff --git a/src/ts/@loafer/core/NestedRuntimeException.ts b/src/ts/@loafer/core/NestedRuntimeException.ts new file mode 100644 index 0000000..12b1b22 --- /dev/null +++ b/src/ts/@loafer/core/NestedRuntimeException.ts @@ -0,0 +1,11 @@ +import { + RuntimeException, +} from '@loafer/core/lang'; + +export class NestedRuntimeException extends RuntimeException { + public constructor(message?: string) { + super(message); + } +} + +export default NestedRuntimeException; diff --git a/src/ts/@loafer/core/index.ts b/src/ts/@loafer/core/index.ts new file mode 100644 index 0000000..e489c09 --- /dev/null +++ b/src/ts/@loafer/core/index.ts @@ -0,0 +1,3 @@ +export * from './AliasRegistry'; +export * from './NestedRuntimeException'; +export * from './SimpleAliasRegistry'; diff --git a/src/ts/@loafer/core/lang/IllegalArgumentException.ts b/src/ts/@loafer/core/lang/IllegalArgumentException.ts index 1d14339..f684faa 100644 --- a/src/ts/@loafer/core/lang/IllegalArgumentException.ts +++ b/src/ts/@loafer/core/lang/IllegalArgumentException.ts @@ -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); } diff --git a/src/ts/@loafer/core/lang/IllegalStateException.ts b/src/ts/@loafer/core/lang/IllegalStateException.ts index c651878..8d90067 100644 --- a/src/ts/@loafer/core/lang/IllegalStateException.ts +++ b/src/ts/@loafer/core/lang/IllegalStateException.ts @@ -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); } diff --git a/src/ts/@loafer/core/lang/RuntimeException.ts b/src/ts/@loafer/core/lang/RuntimeException.ts new file mode 100644 index 0000000..500d40c --- /dev/null +++ b/src/ts/@loafer/core/lang/RuntimeException.ts @@ -0,0 +1,7 @@ +export class RuntimeException extends Error { + public constructor(message?: string) { + super(message); + } +} + +export default RuntimeException; diff --git a/src/ts/@loafer/core/lang/index.ts b/src/ts/@loafer/core/lang/index.ts index 972d2f8..2c5db88 100644 --- a/src/ts/@loafer/core/lang/index.ts +++ b/src/ts/@loafer/core/lang/index.ts @@ -1,2 +1,3 @@ export * from './IllegalArgumentException'; export * from './IllegalStateException'; +export * from './RuntimeException'; diff --git a/src/ts/@loafer/pouches/PouchesException.ts b/src/ts/@loafer/pouches/PouchesException.ts new file mode 100644 index 0000000..0c72304 --- /dev/null +++ b/src/ts/@loafer/pouches/PouchesException.ts @@ -0,0 +1,11 @@ +import { + NestedRuntimeException, +} from '@loafer/core'; + +export class PouchesException extends NestedRuntimeException { + public constructor(message?: string) { + super(message); + } +} + +export default PouchesException; diff --git a/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts b/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts new file mode 100644 index 0000000..7d6d6e2 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts @@ -0,0 +1,11 @@ +import { + PouchesException, +} from '@loafer/pouches'; + +export class NoSuchPouchDefinitionException extends PouchesException { + public constructor(message?: string) { + super(message); + } +} + +export default NoSuchPouchDefinitionException; diff --git a/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts b/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts new file mode 100644 index 0000000..4d028c6 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts @@ -0,0 +1,7 @@ +export class PouchDefinitionStoreException extends Error { + public constructor(message?: string) { + super(message); + } +} + +export default PouchDefinitionStoreException; diff --git a/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts b/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts index e69de29..5d3e009 100644 --- a/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts +++ b/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts @@ -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; diff --git a/src/ts/@loafer/pouches/factory/config/index.ts b/src/ts/@loafer/pouches/factory/config/index.ts new file mode 100644 index 0000000..db62fc6 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/config/index.ts @@ -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'; diff --git a/src/ts/@loafer/pouches/factory/index.ts b/src/ts/@loafer/pouches/factory/index.ts new file mode 100644 index 0000000..63db39b --- /dev/null +++ b/src/ts/@loafer/pouches/factory/index.ts @@ -0,0 +1,7 @@ +export * from './FactoryPouch'; +export * from './HierarchicalPouchFactory'; +export * from './ListablePouchFactory'; + +export * from './NoSuchPouchDefinitionException'; +export * from './PouchDefinitionStoreException'; +export * from './PouchFactory'; diff --git a/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts b/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts index 93ca388..51a4d51 100644 --- a/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts +++ b/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts @@ -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; diff --git a/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts b/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts new file mode 100644 index 0000000..07553e4 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts @@ -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; diff --git a/src/ts/@loafer/pouches/factory/support/index.ts b/src/ts/@loafer/pouches/factory/support/index.ts new file mode 100644 index 0000000..48fa5b7 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/support/index.ts @@ -0,0 +1,6 @@ +export * from './AbstractInjectCapablePouchFactory'; +export * from './AbstractPouchFactory'; +export * from './DefaultListablePouchFactory'; +export * from './DefaultSingletonPouchRegistry'; +export * from './FactoryPouchRegistrySupport'; +export * from './PouchDefinitionRegistry'; diff --git a/src/ts/@loafer/pouches/index.ts b/src/ts/@loafer/pouches/index.ts new file mode 100644 index 0000000..9df4309 --- /dev/null +++ b/src/ts/@loafer/pouches/index.ts @@ -0,0 +1 @@ +export * from './PouchesException';