feat: optimize ioc loader

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2022-05-11 10:56:47 +08:00
parent 47413c6766
commit 86aacf1a1f
6 changed files with 10 additions and 4 deletions

View File

@ -20,7 +20,6 @@
"packages/*"
],
"devDependencies": {
"@ccms/nashorn": "file:../nashorn",
"@javatypes/amqp-client": "^0.0.3",
"@javatypes/bungee-api": "^0.0.3",
"@javatypes/jdk": "^0.0.3",

View File

@ -23,6 +23,7 @@
"@ccms/common": "file:../common",
"@ccms/container": "file:../container",
"@ccms/i18n": "file:../i18n",
"@ccms/verify": "file:../verify",
"crypto-js": "^4.1.1",
"js-yaml": "^4.1.0"
}

View File

@ -0,0 +1,3 @@
export * from "./loader"
export * from "./interfaces"
export * from "./file-config"

View File

@ -0,0 +1,2 @@
export * from './json-loader'
export * from './yaml-loader'

View File

@ -1,10 +1,11 @@
import './scanner/ms-scanner'
import '@ccms/verify'
import './scanner/js-scanner'
import './loader/ioc-loader'
import './loader/basic-loader'
export * from './config'
export * from './config/config'
export * from './manager'
export * from './decorators'
export * from './interfaces'

View File

@ -63,13 +63,13 @@ export class IocLoader implements plugin.PluginLoader {
}
private bindPlugin(metadata: plugin.PluginMetadata) {
try {
if (this.container.isBoundNamed(plugin.Plugin, metadata.name)) {
let pluginInstance = this.container.getNamed<plugin.Plugin>(plugin.Plugin, metadata.name)
if (pluginInstance.description.source + '' !== metadata.source + '') {
console.i18n('ms.plugin.manager.build.duplicate', { exists: pluginInstance.description.source, source: metadata.source })
}
this.container.rebind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
} catch {
} else {
this.container.bind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
}
}