From bd0f94bfe1fde96900130a1bb4c70cea2de52e48 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Tue, 31 Jul 2012 10:21:10 -0700 Subject: [PATCH] 386337: SimpleAOPParser support for declare-annotation --- .../loadtime/definition/SimpleAOPParser.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java b/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java index 88b52e9a2..9c3c875b7 100644 --- a/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java +++ b/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java @@ -17,8 +17,10 @@ import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.Map; +import java.util.Set; import org.aspectj.util.LangUtil; +import org.aspectj.weaver.loadtime.definition.Definition.DeclareAnnotationKind; /** * This class has been created to avoid deadlocks when instrumenting SAXParser. @@ -48,6 +50,11 @@ public class SimpleAOPParser { private final static String POINTCUT_ELEMENT = "pointcut"; private final static String WITHIN_ATTRIBUTE = "within"; private final static String EXPRESSION_ATTRIBUTE = "expression"; + private static final String DECLARE_ANNOTATION = "declare-annotation"; + private static final String ANNONATION_TAG = "annotation"; + private static final String ANNO_KIND_TYPE = "type"; + private static final String ANNO_KIND_METHOD = "method"; + private static final String ANNO_KIND_FIELD = "field"; private final Definition m_definition; private boolean m_inAspectJ; private boolean m_inWeaver; @@ -150,7 +157,32 @@ public class SimpleAOPParser { if (!isNull(typePattern)) { m_definition.getAspectIncludePatterns().add(typePattern); } - } else { + }else if (DECLARE_ANNOTATION.equals(qName) && m_inAspects) { + String anno = (String) attrMap.get(ANNONATION_TAG); + if (!isNull(anno)){ + String pattern = (String) attrMap.get(ANNO_KIND_FIELD); + if (pattern != null){ + m_lastConcreteAspect.declareAnnotations.add(new Definition.DeclareAnnotation( + DeclareAnnotationKind.Field, pattern, anno)); + } + else{ + pattern = (String) attrMap.get(ANNO_KIND_METHOD); + if (pattern != null){ + m_lastConcreteAspect.declareAnnotations.add(new Definition.DeclareAnnotation( + DeclareAnnotationKind.Method, pattern, anno)); + } + else{ + pattern = (String) attrMap.get(ANNO_KIND_TYPE); + if (pattern != null){ + m_lastConcreteAspect.declareAnnotations.add(new Definition.DeclareAnnotation( + DeclareAnnotationKind.Type, pattern, anno)); + } + } + } + + } + } + else { throw new Exception( "Unknown element while parsing element: " + qName); } -- 2.39.5