From 40f41364ad53e9d7d614cc306eec1d1198de8044 Mon Sep 17 00:00:00 2001 From: crusader Date: Sat, 7 Apr 2018 03:15:10 +0900 Subject: [PATCH] ing --- registry/registry.go | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/registry/registry.go b/registry/registry.go index d12c7db..095cdaf 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -277,7 +277,9 @@ func GetMethodAnnotation(instanceType reflect.Type, annotationType reflect.Type, return registry.GetMethodAnnotation(instanceType, annotationType, methodName) } func (cr *defaultComponentRegistry) GetMethodAnnotation(instanceType reflect.Type, annotationType reflect.Type, methodName string) cda.Annotation { - def, ok := cr.definitionByType[instanceType] + rt, _, _ := cur.GetTypeInfo(instanceType) + + def, ok := cr.definitionByType[rt] if !ok { return nil } @@ -315,9 +317,14 @@ func parseFields(t reflect.Type, td *TypeDefinition) { f := rt.Field(i) if f.Anonymous { - parseAnonymousField(&f, td) + if parseAnonymousField(&f, td) { + continue + } parseFields(f.Type, td) } else { + if parseMethodAnnotation(&f, td) { + continue + } as, err := cda.ParseAnnotation(f.Tag) if nil != err { return @@ -339,40 +346,41 @@ func parseFields(t reflect.Type, td *TypeDefinition) { } } -func parseAnonymousField(f *reflect.StructField, td *TypeDefinition) { - parseTypeAnnotation(f, td) - parseMethodAnnotation(f, td) +func parseAnonymousField(f *reflect.StructField, td *TypeDefinition) bool { + if parseTypeAnnotation(f, td) { + return true + } + return false } -func parseTypeAnnotation(f *reflect.StructField, td *TypeDefinition) { +func parseTypeAnnotation(f *reflect.StructField, td *TypeDefinition) bool { // if !haveEmbeddingOf(cda.TypeAnnotationType, f.Type) { // return // } if cda.TypeAnnotationType != f.Type { - return + return false } as, err := cda.ParseAnnotation(f.Tag) if nil != err { - return + return false } if nil != as && 0 < len(as) { td.TypeAnnotations = as + return true } + return false } -func parseMethodAnnotation(f *reflect.StructField, td *TypeDefinition) { - // if !haveEmbeddingOf(cda.TypeAnnotationType, f.Type) { - // return - // } +func parseMethodAnnotation(f *reflect.StructField, td *TypeDefinition) bool { if cda.MethodAnnotationType != f.Type { - return + return false } as, err := cda.ParseAnnotation(f.Tag) if nil != err { - return + return false } if nil != as && 0 < len(as) { @@ -380,7 +388,9 @@ func parseMethodAnnotation(f *reflect.StructField, td *TypeDefinition) { td.MethodAnnotations = make(map[string]map[string]cda.Annotation, 0) } td.MethodAnnotations[f.Name] = as + return true } + return false } func haveEmbeddingOf(t reflect.Type, target reflect.Type) bool {