@@ -4,12 +4,12 @@ import { ConfigParseError } from "./configParseError";
4
4
import * as model from "./model" ;
5
5
import { lowerInitialChar } from "./utils" ;
6
6
7
- interface BeanWithName {
7
+ interface NamedComponent {
8
8
qualifiedClassName : string ;
9
- bean : jsonConfig . Bean ;
9
+ component : jsonConfig . Component ;
10
10
}
11
11
12
- const beansById = new Map < string , BeanWithName > ( ) ;
12
+ const beansById = new Map < string , NamedComponent > ( ) ;
13
13
14
14
export async function collectBeansFromConfigFile ( filePath : string ) : Promise < string [ ] > {
15
15
let json : string ;
@@ -19,22 +19,22 @@ export async function collectBeansFromConfigFile(filePath: string): Promise<stri
19
19
throw new ConfigParseError ( `Can't open input file '${ filePath } ': ${ err . message } ` ) ;
20
20
}
21
21
const annotationConfig : jsonConfig . AnnotationConfig = JSON . parse ( json ) ;
22
- for ( const qualifiedClassName in annotationConfig . beans ) {
23
- if ( ! annotationConfig . beans . hasOwnProperty ( qualifiedClassName ) )
22
+ for ( const qualifiedClassName in annotationConfig . components ) {
23
+ if ( ! annotationConfig . components . hasOwnProperty ( qualifiedClassName ) )
24
24
continue ;
25
25
// Create bean ID
26
26
// TODO: Handle name parameter to @Component constructor
27
27
const id = lowerInitialChar ( < string > qualifiedClassName . split ( "." ) . pop ( ) ) ;
28
28
// Check for duplicate ids from other beans
29
29
if ( beansById . has ( id ) )
30
- throw new ConfigParseError ( `Found multiple beans with id '${ id } '` ) ;
30
+ throw new ConfigParseError ( `Found multiple components with id '${ id } '` ) ;
31
31
const aliasedBeanId = model . Bean . getAlias ( id ) ;
32
32
if ( aliasedBeanId !== undefined )
33
33
throw new ConfigParseError ( `Found a bean with id same as an alias for '${ aliasedBeanId } '` ) ;
34
34
// Create a bean model for the bean
35
- const bean = { qualifiedClassName : qualifiedClassName , bean : annotationConfig . beans [ qualifiedClassName ] } ;
36
- beansById . set ( id , bean ) ;
37
- model . Bean . registerIdForClass ( bean . qualifiedClassName , id ) ;
35
+ const component = { qualifiedClassName : qualifiedClassName , component : annotationConfig . components [ qualifiedClassName ] } ;
36
+ beansById . set ( id , component ) ;
37
+ model . Bean . registerIdForClass ( component . qualifiedClassName , id ) ;
38
38
}
39
39
// TODO: Return paths to XML config files specified in code
40
40
return [ ] ;
@@ -60,21 +60,21 @@ export function parseBean(id: string): model.Bean {
60
60
return parseJsonBean ( id , bean ) ;
61
61
}
62
62
63
- function parseJsonBean ( id : string | undefined , namedBean : BeanWithName ) : model . Bean {
64
- const bean = namedBean . bean ;
63
+ function parseJsonBean ( id : string | undefined , namedBean : NamedComponent ) : model . Bean {
64
+ const component = namedBean . component ;
65
65
const properties : model . BeanProperty [ ] = [ ] ;
66
- for ( const fieldName in bean . fields ) {
67
- if ( ! bean . fields . hasOwnProperty ( fieldName ) )
66
+ for ( const fieldName in component . fields ) {
67
+ if ( ! component . fields . hasOwnProperty ( fieldName ) )
68
68
continue ;
69
- const fieldClass = bean . fields [ fieldName ] . type ;
69
+ const fieldClass = component . fields [ fieldName ] . type ;
70
70
71
71
const fieldBeanId = model . Bean . tryGetIdByClass ( fieldClass ) ;
72
72
if ( fieldBeanId === undefined )
73
73
throw new ConfigParseError (
74
- `Autowired field '${ namedBean . qualifiedClassName } .${ fieldName } ' depends on a class '${ fieldClass } ' `
74
+ `Auto-wired field '${ namedBean . qualifiedClassName } .${ fieldName } ' depends on a class '${ fieldClass } ' `
75
75
+ `that has ${ model . Bean . hasMultipleBeansForClass ( fieldClass ) ? "multiple" : "no" } implementations` ) ;
76
76
properties . push ( { name : fieldName , value : new model . BeanRefValue ( fieldBeanId ) } ) ;
77
77
}
78
78
// TODO: Handle constructor arguments
79
- return new model . Bean ( undefined , id , namedBean . qualifiedClassName , model . BeanCreationPolicy . Singleton , [ ] , properties ) ;
79
+ return new model . Bean ( undefined , id , namedBean . qualifiedClassName , false , [ ] , properties ) ;
80
80
}
0 commit comments