diff --git a/registry.go b/registry.go index 32e4de5..b11312c 100644 --- a/registry.go +++ b/registry.go @@ -168,6 +168,7 @@ func (r *InstanceRegistry) GetInstance(t reflect.Type) (instance interface{}, er }() var ( + a oa.Annotation fV interface{} ) @@ -188,13 +189,24 @@ func (r *InstanceRegistry) GetInstance(t reflect.Type) (instance interface{}, er return } - _, ok = as[annotation.InjectAnnotationType] + a, ok = as[annotation.InjectAnnotationType] if ok { if fV, err = r.GetInstance(f.Type()); nil != err { return } } + a, ok = as[annotation.ResourceAnnotationType] + if ok { + name := a.(*annotation.ResourceAnnotation).Name + if "" == name { + name = n + } + if fV, err = r.GetInstanceByName(name); nil != err { + return + } + } + if nil != err { return }