feat: optimize ioc loader
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
47413c6766
commit
86aacf1a1f
@ -20,7 +20,6 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ccms/nashorn": "file:../nashorn",
|
|
||||||
"@javatypes/amqp-client": "^0.0.3",
|
"@javatypes/amqp-client": "^0.0.3",
|
||||||
"@javatypes/bungee-api": "^0.0.3",
|
"@javatypes/bungee-api": "^0.0.3",
|
||||||
"@javatypes/jdk": "^0.0.3",
|
"@javatypes/jdk": "^0.0.3",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"@ccms/common": "file:../common",
|
"@ccms/common": "file:../common",
|
||||||
"@ccms/container": "file:../container",
|
"@ccms/container": "file:../container",
|
||||||
"@ccms/i18n": "file:../i18n",
|
"@ccms/i18n": "file:../i18n",
|
||||||
|
"@ccms/verify": "file:../verify",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0"
|
||||||
}
|
}
|
||||||
|
3
packages/plugin/src/config/config.ts
Normal file
3
packages/plugin/src/config/config.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./loader"
|
||||||
|
export * from "./interfaces"
|
||||||
|
export * from "./file-config"
|
2
packages/plugin/src/config/loader/index.ts
Normal file
2
packages/plugin/src/config/loader/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './json-loader'
|
||||||
|
export * from './yaml-loader'
|
@ -1,10 +1,11 @@
|
|||||||
import './scanner/ms-scanner'
|
import '@ccms/verify'
|
||||||
import './scanner/js-scanner'
|
import './scanner/js-scanner'
|
||||||
|
|
||||||
import './loader/ioc-loader'
|
import './loader/ioc-loader'
|
||||||
import './loader/basic-loader'
|
import './loader/basic-loader'
|
||||||
|
|
||||||
export * from './config'
|
export * from './config'
|
||||||
|
export * from './config/config'
|
||||||
export * from './manager'
|
export * from './manager'
|
||||||
export * from './decorators'
|
export * from './decorators'
|
||||||
export * from './interfaces'
|
export * from './interfaces'
|
||||||
|
@ -63,13 +63,13 @@ export class IocLoader implements plugin.PluginLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bindPlugin(metadata: plugin.PluginMetadata) {
|
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)
|
let pluginInstance = this.container.getNamed<plugin.Plugin>(plugin.Plugin, metadata.name)
|
||||||
if (pluginInstance.description.source + '' !== metadata.source + '') {
|
if (pluginInstance.description.source + '' !== metadata.source + '') {
|
||||||
console.i18n('ms.plugin.manager.build.duplicate', { exists: pluginInstance.description.source, 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)
|
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)
|
this.container.bind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user