@@ -181,10 +181,10 @@ module.exports = class ApplicationContext {
181181 && component ?. constructor ?. name !== 'Singleton'
182182 && component ?. constructor ?. name !== 'Prototype' ) {
183183 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 ,
188188 ) ;
189189 component . require = componentArg . require ;
190190 }
@@ -285,7 +285,8 @@ module.exports = class ApplicationContext {
285285 const insKeys = Object . keys ( instance ) ;
286286 for ( let j = 0 ; j < insKeys . length ; j ++ ) {
287287 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' ;
289290 if ( autowire ) {
290291 // eslint-disable-next-line no-param-reassign
291292 instance [ insKeys [ j ] ] = this . get ( insKeys [ j ] , undefined , component ) ;
@@ -386,7 +387,7 @@ module.exports = class ApplicationContext {
386387
387388 static registerDestroyer ( destroyer ) {
388389 if ( destroyer ) {
389- process . on ( 'exit' , destroyer ?. bind ( ) ) ;
390+ // process.on('exit', destroyer?.bind());
390391 // catches ctrl+c event
391392 process . on ( 'SIGINT' , destroyer ?. bind ( ) ) ;
392393 // catches "kill pid" (for example: nodemon restart)
@@ -405,19 +406,17 @@ module.exports = class ApplicationContext {
405406 if ( component . scope === Scopes . SINGLETON ) {
406407 let destroyer = null ;
407408 if ( typeof component . instance . destroy === 'function' ) {
408- destroyer = component . instance . destroy ;
409+ destroyer = ( ) => component . instance . destroy ( component . instance ) ;
409410 } else if ( typeof component . destroy === 'string' ) {
410- destroyer = component . instance [ component . destroy ] ( ) ;
411+ destroyer = ( ) => component . instance [ component . destroy ] ( component . instance ) ;
411412 }
412413 ApplicationContext . registerDestroyer ( destroyer ) ;
413- ApplicationContext . registerDestroyer ( ( ) => {
414- logger . verbose ( `ApplicationContext (${ this . name } ) lifecycle completed.` ) ;
415- } ) ;
416-
417414 logger . verbose ( `Registering singleton (${ component . name } ) destroyer` ) ;
418415 }
419416 }
420-
417+ ApplicationContext . registerDestroyer ( ( ) => {
418+ logger . verbose ( `ApplicationContext (${ this . name } ) lifecycle completed.` ) ;
419+ } ) ;
421420 logger . verbose ( 'Registering singleton destroyers completed' ) ;
422421 }
423422
@@ -465,7 +464,7 @@ module.exports = class ApplicationContext {
465464 args = [ args ] ;
466465 }
467466 prototype = this . get (
468- this . components [ reference ] . factory ,
467+ this . components [ reference ] . factory ,
469468 ) [ this . components [ reference ] . factoryFunction ] ( ...args ) ;
470469 } else if ( typeof this . components [ reference ] . wireFactory === 'function' ) {
471470 let args = targetArgs ;
0 commit comments