From ecf4237a6326ac2ff5b4b4eac3ee5e798c5fcdd3 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 25 Feb 2008 21:42:43 +0000 Subject: [PATCH] annoValMatch: implementation --- .../weaver/reflect/AnnotationFinder.java | 5 +++++ .../ReflectionBasedResolvedMemberImpl.java | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java b/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java index 8fa69f425..bdc3539af 100644 --- a/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java +++ b/weaver/src/org/aspectj/weaver/reflect/AnnotationFinder.java @@ -14,7 +14,9 @@ package org.aspectj.weaver.reflect; import java.lang.reflect.Member; import java.util.Set; +import org.aspectj.weaver.AnnotationX; import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; /** @@ -30,7 +32,10 @@ public interface AnnotationFinder { Object getAnnotation(ResolvedType annotationType, Object onObject); Object getAnnotationFromMember(ResolvedType annotationType, Member aMember); + public AnnotationX getAnnotationOfType(UnresolvedType ofType,Member onMember); + public String getAnnotationDefaultValue(Member onMember); + Object getAnnotationFromClass(ResolvedType annotationType, Class aClass); Set/*ResolvedType*/ getAnnotations(Member onMember); diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java index fb9debd15..ef3a2ab9a 100644 --- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java +++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java @@ -12,12 +12,15 @@ package org.aspectj.weaver.reflect; import java.lang.reflect.Member; +import java.util.Iterator; +import org.aspectj.weaver.AnnotationX; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedMemberImpl; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; + /** * Subtype of ResolvedMemberImpl used in reflection world. * Knows how to get annotations from a java.lang.reflect.Member @@ -168,8 +171,25 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { unpackAnnotations(); return super.getAnnotationTypes(); } + + public AnnotationX getAnnotationOfType(UnresolvedType ofType) { + unpackAnnotations(); + if (annotationFinder==null) return null; + for (Iterator iterator = annotationTypes.iterator(); iterator.hasNext();) { + ResolvedType type = (ResolvedType) iterator.next(); + if (type.getSignature().equals(ofType.getSignature())) { + return annotationFinder.getAnnotationOfType(ofType, reflectMember); + } + } + return null; + } + + public String getAnnotationDefaultValue() { + if (annotationFinder==null) return null; + return annotationFinder.getAnnotationDefaultValue(reflectMember); + } - public ResolvedType[][] getParameterAnnotationTypes() { + public ResolvedType[][] getParameterAnnotationTypes() { if (parameterAnnotationTypes==null && annotationFinder!=null) { parameterAnnotationTypes = annotationFinder.getParameterAnnotationTypes(reflectMember); } -- 2.39.5