@@ -181,10 +181,10 @@ module.exports = class ApplicationContext {
181
181
&& component ?. constructor ?. name !== 'Singleton'
182
182
&& component ?. constructor ?. name !== 'Prototype' ) {
183
183
component = new Component (
184
- component , component . name ,
185
- component . qualifier ,
186
- component . scope ,
187
- component . properties , component . profiles ,
184
+ component , component . name ,
185
+ component . qualifier ,
186
+ component . scope ,
187
+ component . properties , component . profiles ,
188
188
) ;
189
189
component . require = componentArg . require ;
190
190
}
@@ -285,7 +285,8 @@ module.exports = class ApplicationContext {
285
285
const insKeys = Object . keys ( instance ) ;
286
286
for ( let j = 0 ; j < insKeys . length ; j ++ ) {
287
287
const property = instance [ insKeys [ j ] ] ;
288
- const autowire = property ?. name === 'Autowired' || _ . lowerCase ( property ) === 'autowired' ;
288
+ const autowire = property ?. name === 'Autowired'
289
+ || ( typeof property === 'string' && _ . lowerCase ( property ) ) === 'autowired' ;
289
290
if ( autowire ) {
290
291
// eslint-disable-next-line no-param-reassign
291
292
instance [ insKeys [ j ] ] = this . get ( insKeys [ j ] , undefined , component ) ;
@@ -386,7 +387,7 @@ module.exports = class ApplicationContext {
386
387
387
388
static registerDestroyer ( destroyer ) {
388
389
if ( destroyer ) {
389
- process . on ( 'exit' , destroyer ?. bind ( ) ) ;
390
+ // process.on('exit', destroyer?.bind());
390
391
// catches ctrl+c event
391
392
process . on ( 'SIGINT' , destroyer ?. bind ( ) ) ;
392
393
// catches "kill pid" (for example: nodemon restart)
@@ -405,19 +406,17 @@ module.exports = class ApplicationContext {
405
406
if ( component . scope === Scopes . SINGLETON ) {
406
407
let destroyer = null ;
407
408
if ( typeof component . instance . destroy === 'function' ) {
408
- destroyer = component . instance . destroy ;
409
+ destroyer = ( ) => component . instance . destroy ( component . instance ) ;
409
410
} else if ( typeof component . destroy === 'string' ) {
410
- destroyer = component . instance [ component . destroy ] ( ) ;
411
+ destroyer = ( ) => component . instance [ component . destroy ] ( component . instance ) ;
411
412
}
412
413
ApplicationContext . registerDestroyer ( destroyer ) ;
413
- ApplicationContext . registerDestroyer ( ( ) => {
414
- logger . verbose ( `ApplicationContext (${ this . name } ) lifecycle completed.` ) ;
415
- } ) ;
416
-
417
414
logger . verbose ( `Registering singleton (${ component . name } ) destroyer` ) ;
418
415
}
419
416
}
420
-
417
+ ApplicationContext . registerDestroyer ( ( ) => {
418
+ logger . verbose ( `ApplicationContext (${ this . name } ) lifecycle completed.` ) ;
419
+ } ) ;
421
420
logger . verbose ( 'Registering singleton destroyers completed' ) ;
422
421
}
423
422
@@ -465,7 +464,7 @@ module.exports = class ApplicationContext {
465
464
args = [ args ] ;
466
465
}
467
466
prototype = this . get (
468
- this . components [ reference ] . factory ,
467
+ this . components [ reference ] . factory ,
469
468
) [ this . components [ reference ] . factoryFunction ] ( ...args ) ;
470
469
} else if ( typeof this . components [ reference ] . wireFactory === 'function' ) {
471
470
let args = targetArgs ;
0 commit comments