This commit is contained in:
crusader 2017-08-04 00:52:13 +09:00
parent 72e95d73d4
commit e7c032b720
19 changed files with 197 additions and 4 deletions

View File

@ -11,6 +11,9 @@ import {
Annotation,
} from '@loafer/core/annotation';
import {
PouchDefinitionRegistry,
} from '@loafer/pouches/factory/support';
import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext';

View File

@ -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 {

View File

@ -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;

View 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;

View File

@ -0,0 +1,3 @@
export * from './AliasRegistry';
export * from './NestedRuntimeException';
export * from './SimpleAliasRegistry';

View File

@ -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);
}

View File

@ -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);
}

View File

@ -0,0 +1,7 @@
export class RuntimeException extends Error {
public constructor(message?: string) {
super(message);
}
}
export default RuntimeException;

View File

@ -1,2 +1,3 @@
export * from './IllegalArgumentException';
export * from './IllegalStateException';
export * from './RuntimeException';

View File

@ -0,0 +1,11 @@
import {
NestedRuntimeException,
} from '@loafer/core';
export class PouchesException extends NestedRuntimeException {
public constructor(message?: string) {
super(message);
}
}
export default PouchesException;

View File

@ -0,0 +1,11 @@
import {
PouchesException,
} from '@loafer/pouches';
export class NoSuchPouchDefinitionException extends PouchesException {
public constructor(message?: string) {
super(message);
}
}
export default NoSuchPouchDefinitionException;

View File

@ -0,0 +1,7 @@
export class PouchDefinitionStoreException extends Error {
public constructor(message?: string) {
super(message);
}
}
export default PouchDefinitionStoreException;

View File

@ -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;

View 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';

View File

@ -0,0 +1,7 @@
export * from './FactoryPouch';
export * from './HierarchicalPouchFactory';
export * from './ListablePouchFactory';
export * from './NoSuchPouchDefinitionException';
export * from './PouchDefinitionStoreException';
export * from './PouchFactory';

View File

@ -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;

View 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;

View File

@ -0,0 +1,6 @@
export * from './AbstractInjectCapablePouchFactory';
export * from './AbstractPouchFactory';
export * from './DefaultListablePouchFactory';
export * from './DefaultSingletonPouchRegistry';
export * from './FactoryPouchRegistrySupport';
export * from './PouchDefinitionRegistry';

View File

@ -0,0 +1 @@
export * from './PouchesException';