ing
This commit is contained in:
parent
52ae4371ce
commit
90836c801b
|
@ -25,7 +25,7 @@ type ComponentRegistry interface {
|
|||
GetInstance(t reflect.Type) (interface{}, error)
|
||||
GetInstances(ts []reflect.Type) ([]interface{}, error)
|
||||
GetInstanceByName(name string) (interface{}, error)
|
||||
GetInstancesByAnnotationName(n string) ([]interface{}, error)
|
||||
// GetInstancesByAnnotationName(n string) ([]interface{}, error)
|
||||
GetInstancesByAnnotationType(t reflect.Type) ([]interface{}, error)
|
||||
}
|
||||
|
||||
|
@ -215,27 +215,27 @@ func (cr *defaultComponentRegistry) GetInstances(ts []reflect.Type) ([]interface
|
|||
|
||||
// GetInstancesByAnnotationName returns instance of annotated
|
||||
// n must be name of registered annotation
|
||||
func GetInstancesByAnnotationName(n string) ([]interface{}, error) {
|
||||
return registry.GetInstancesByAnnotationName(n)
|
||||
}
|
||||
func (cr *defaultComponentRegistry) GetInstancesByAnnotationName(n string) ([]interface{}, error) {
|
||||
var (
|
||||
i interface{}
|
||||
err error
|
||||
)
|
||||
instances := make([]interface{}, 0)
|
||||
// func GetInstancesByAnnotationName(n string) ([]interface{}, error) {
|
||||
// return registry.GetInstancesByAnnotationName(n)
|
||||
// }
|
||||
// func (cr *defaultComponentRegistry) GetInstancesByAnnotationName(n string) ([]interface{}, error) {
|
||||
// var (
|
||||
// i interface{}
|
||||
// err error
|
||||
// )
|
||||
// instances := make([]interface{}, 0)
|
||||
|
||||
for _, td := range cr.definitionByType {
|
||||
if nil != td.GetAnnotation(n) {
|
||||
if i, err = cr.GetInstance(td.Type); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
instances = append(instances, i)
|
||||
}
|
||||
}
|
||||
// for _, td := range cr.definitionByType {
|
||||
// if nil != td.GetAnnotation(n) {
|
||||
// if i, err = cr.GetInstance(td.Type); nil != err {
|
||||
// return nil, err
|
||||
// }
|
||||
// instances = append(instances, i)
|
||||
// }
|
||||
// }
|
||||
|
||||
return instances, nil
|
||||
}
|
||||
// return instances, nil
|
||||
// }
|
||||
|
||||
func GetInstancesByAnnotationType(t reflect.Type) ([]interface{}, error) {
|
||||
return registry.GetInstancesByAnnotationType(t)
|
||||
|
|
Loading…
Reference in New Issue
Block a user