diff options
author | aclement <aclement> | 2005-04-19 12:21:44 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-04-19 12:21:44 +0000 |
commit | 609431e58dcf9200c50d3565cfc40cfde25d70eb (patch) | |
tree | 7cc25e15adb987b5bc75ead84d31bf0099877489 | |
parent | c105853907f4ea53f0cc4370651c3adf11b1c641 (diff) | |
download | aspectj-609431e58dcf9200c50d3565cfc40cfde25d70eb.tar.gz aspectj-609431e58dcf9200c50d3565cfc40cfde25d70eb.zip |
from branch: capable of knowing whether it represents an @AJ aspect
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 6fc2d7e93..46a7fe783 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -37,6 +37,9 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; import org.aspectj.weaver.WeaverStateInfo; import org.aspectj.weaver.patterns.PerClause; +import org.aspectj.weaver.ataspectj.Aj5Attributes; +import org.aspectj.weaver.ataspectj.Ajc5MemberMaker; + // ??? exposed for testing public class BcelObjectType extends ResolvedTypeX.ConcreteName { @@ -60,8 +63,11 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { private List typeMungers = Collections.EMPTY_LIST; private List declares = Collections.EMPTY_LIST; private ResolvedMember[] privilegedAccess = null; - - + + private boolean discoveredWhetherAnnotationStyle = false; + private boolean isAnnotationStyleAspect = false;// set upon construction + + public Collection getTypeMungers() { return typeMungers; } @@ -81,7 +87,11 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { BcelObjectType(ResolvedTypeX.Name resolvedTypeX, JavaClass javaClass, boolean exposedToWeaver) { super(resolvedTypeX, exposedToWeaver); this.javaClass = javaClass; - + + //ATAJ: set the delegate right now for @AJ poincut, else it is done too late to lookup + // @AJ pc refs annotation in class hierarchy + resolvedTypeX.setDelegate(this); + if (resolvedTypeX.getSourceContext() == null) { resolvedTypeX.setSourceContext(new BcelSourceContext(this)); } @@ -166,11 +176,28 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { return perClause != null; } + /** + * Check if the type is an @AJ aspect (no matter if used from an LTW point of view). + * Such aspects are annotated with @Aspect + * + * @return true for @AJ aspect + */ + public boolean isAnnotationStyleAspect() { + if (!discoveredWhetherAnnotationStyle) { + discoveredWhetherAnnotationStyle = true; + isAnnotationStyleAspect = hasAnnotation(Ajc5MemberMaker.ASPECT); + } + return isAnnotationStyleAspect; + } + private void unpackAspectAttributes() { List pointcuts = new ArrayList(); typeMungers = new ArrayList(); declares = new ArrayList(); - List l = BcelAttributes.readAjAttributes(javaClass.getClassName(),javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler()); + // Pass in empty list that can store things for readAj5 to process + List l = BcelAttributes.readAjAttributes(javaClass.getClassName(),javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler()); + l.addAll(Aj5Attributes.readAj5ClassAttributes(javaClass, getResolvedTypeX(), getResolvedTypeX().getSourceContext(), getResolvedTypeX().getWorld().getMessageHandler())); + for (Iterator iter = l.iterator(); iter.hasNext();) { AjAttribute a = (AjAttribute) iter.next(); //System.err.println("unpacking: " + this + " and " + a); @@ -232,6 +259,8 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { isObject = (javaClass.getSuperclassNameIndex() == 0); unpackAspectAttributes(); + discoveredWhetherAnnotationStyle = false; + isAnnotationStyleAspect=false; } public void finishedWith() { |