From 993cef1c34849b5a3c92f5ddf4839ccf9047da77 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 1 Aug 2012 08:34:21 -0700 Subject: [PATCH] 386337: more missing support added to SimpleAOPParser --- .../loadtime/definition/SimpleAOPParser.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java b/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java index 9c3c875b7..bcd6ddcd0 100644 --- a/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java +++ b/weaver/src/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java @@ -20,7 +20,9 @@ import java.util.Map; import java.util.Set; import org.aspectj.util.LangUtil; +import org.aspectj.weaver.loadtime.definition.Definition.AdviceKind; import org.aspectj.weaver.loadtime.definition.Definition.DeclareAnnotationKind; +import org.xml.sax.SAXException; /** * This class has been created to avoid deadlocks when instrumenting SAXParser. @@ -55,6 +57,9 @@ public class SimpleAOPParser { 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 static String BEFORE_ELEMENT = "before"; + private final static String AFTER_ELEMENT = "after"; + private final static String AROUND_ELEMENT = "around"; private final Definition m_definition; private boolean m_inAspectJ; private boolean m_inWeaver; @@ -182,6 +187,35 @@ public class SimpleAOPParser { } } + else if (BEFORE_ELEMENT.equals(qName) && m_inAspects ) { + String pointcut = (String) attrMap.get(POINTCUT_ELEMENT); + String adviceClass = (String) attrMap.get("invokeClass"); + String adviceMethod = (String) attrMap.get("invokeMethod"); + if (!isNull(pointcut) && !isNull(adviceClass) && !isNull(adviceMethod)) { + m_lastConcreteAspect.pointcutsAndAdvice.add(new Definition.PointcutAndAdvice(AdviceKind.Before, + replaceXmlAnd(pointcut), adviceClass, adviceMethod)); + } else { + throw new SAXException("Badly formed element"); + } + } else if (AFTER_ELEMENT.equals(qName) && m_inAspects) { + String pointcut = (String) attrMap.get(POINTCUT_ELEMENT); + String adviceClass = (String) attrMap.get("invokeClass"); + String adviceMethod = (String) attrMap.get("invokeMethod"); + if (!isNull(pointcut) && !isNull(adviceClass) && !isNull(adviceMethod)) { + m_lastConcreteAspect.pointcutsAndAdvice.add(new Definition.PointcutAndAdvice(AdviceKind.After, + replaceXmlAnd(pointcut), adviceClass, adviceMethod)); + } else { + throw new SAXException("Badly formed element"); + } + } else if (AROUND_ELEMENT.equals(qName) && m_inAspects) { + String pointcut = (String) attrMap.get(POINTCUT_ELEMENT); + String adviceClass = (String) attrMap.get("invokeClass"); + String adviceMethod = (String) attrMap.get("invokeMethod"); + if (!isNull(pointcut) && !isNull(adviceClass) && !isNull(adviceMethod)) { + m_lastConcreteAspect.pointcutsAndAdvice.add(new Definition.PointcutAndAdvice(AdviceKind.Around, + replaceXmlAnd(pointcut), adviceClass, adviceMethod)); + } + } else { throw new Exception( "Unknown element while parsing element: " + qName); -- 2.39.5