fix: continer Autowired error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-10-02 19:57:10 +08:00
parent d80e858a89
commit 1d2a528bbb
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { provideSingleton, Autowired } from '@ccms/container' import { provideSingleton, Autowired, optional } from '@ccms/container'
import { channel } from './channel' import { channel } from './channel'
export namespace proxy { export namespace proxy {
@ -147,6 +147,7 @@ export namespace proxy {
} }
@provideSingleton(BungeeCord) @provideSingleton(BungeeCord)
export class BungeeCord { export class BungeeCord {
@optional()
@Autowired() @Autowired()
private channel: channel.Channel private channel: channel.Channel
/** /**

View File

@ -66,7 +66,7 @@ export const Autowired = (className?: any) => {
return inject(className)(target, propertyKey, index) return inject(className)(target, propertyKey, index)
} }
let type = Reflect.getMetadata('design:type', target, propertyKey) let type = Reflect.getMetadata('design:type', target, propertyKey)
if (type && type !== Object && Java.isJavaObject(type)) { if (type && type !== Object && !Java.isJavaObject(type)) {
inject(type)(target, propertyKey, index) inject(type)(target, propertyKey, index)
named(className || propertyKey)(target, propertyKey, index) named(className || propertyKey)(target, propertyKey, index)
} else if (container.isBound(ioc.Autowired)) { } else if (container.isBound(ioc.Autowired)) {