This commit is contained in:
crusader 2018-03-21 21:19:27 +09:00
parent 52e9415760
commit e216cb7671

View File

@ -151,7 +151,8 @@ func (cr *defaultComponentRegistry) GetInstance(t reflect.Type) (interface{}, er
} }
if annotation = fd.GetAnnotationByType(reflect.TypeOf((*cdia.Inject)(nil)), false); nil != annotation { if annotation = fd.GetAnnotationByType(reflect.TypeOf((*cdia.Inject)(nil)), false); nil != annotation {
if fV, err = cr.GetInstance(fd.Type); nil != err { fV, err = cr.GetInstance(fd.Type)
if nil != err {
return nil, err return nil, err
} }
} }
@ -161,7 +162,8 @@ func (cr *defaultComponentRegistry) GetInstance(t reflect.Type) (interface{}, er
if "" == n { if "" == n {
n = fd.FieldName n = fd.FieldName
} }
if fV, err = cr.GetInstanceByName(n); nil != err { fV, err = cr.GetInstanceByName(n)
if nil != err {
return nil, err return nil, err
} }
} }
@ -200,7 +202,8 @@ func (cr *defaultComponentRegistry) GetInstances(ts []reflect.Type) ([]interface
) )
instances := make([]interface{}, 0) instances := make([]interface{}, 0)
for _, t := range ts { for _, t := range ts {
if i, err = cr.GetInstance(t); nil != err { i, err = cr.GetInstance(t)
if nil != err {
return nil, err return nil, err
} }
instances = append(instances, i) instances = append(instances, i)
@ -223,7 +226,8 @@ func (cr *defaultComponentRegistry) GetInstancesByAnnotationName(n string) ([]in
for _, td := range cr.definitionByType { for _, td := range cr.definitionByType {
if nil != td.GetAnnotation(n) { if nil != td.GetAnnotation(n) {
if i, err = cr.GetInstance(td.Type); nil != err { i, err = cr.GetInstance(td.Type)
if nil != err {
return nil, err return nil, err
} }
instances = append(instances, i) instances = append(instances, i)