diff options
author | aclement <aclement> | 2009-02-09 20:13:03 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-02-09 20:13:03 +0000 |
commit | 42c34e2fa348eb453be2c953b72f13391d5a9997 (patch) | |
tree | beb35c050acf8450a4e004ae6c2878758bfff7f5 /org.aspectj.matcher | |
parent | c75b7a1696bea21b78e965bccd8d05c81a94494c (diff) | |
download | aspectj-42c34e2fa348eb453be2c953b72f13391d5a9997.tar.gz aspectj-42c34e2fa348eb453be2c953b72f13391d5a9997.zip |
124460: simple basic control of weaving via aop.xml
Diffstat (limited to 'org.aspectj.matcher')
3 files changed, 28 insertions, 9 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java index 186d7ef6f..e5a44bc1b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java @@ -34,6 +34,7 @@ public class CrosscuttingMembersSet { // FIXME AV - ? we may need a sequencedHashMap there to ensure source based precedence for @AJ advice private final Map /* ResolvedType (the aspect) > CrosscuttingMembers */members = new HashMap(); + private World world; private List shadowMungers = null; private List typeMungers = null; private List lateTypeMungers = null; @@ -46,14 +47,12 @@ public class CrosscuttingMembersSet { private boolean changedSinceLastReset = false; private List /* IVerificationRequired */verificationList = null; // List of things to be verified once the type system is - // 'complete' + // 'complete' private static Trace trace = TraceFactory.getTraceFactory().getTrace(CrosscuttingMembersSet.class); public CrosscuttingMembersSet(World world) { - trace.enter("<init>", this, world); - - trace.exit("<init>"); + this.world = world; } public boolean addOrReplaceAspect(ResolvedType aspectType) { @@ -65,7 +64,10 @@ public class CrosscuttingMembersSet { * this */ public boolean addOrReplaceAspect(ResolvedType aspectType, boolean inWeavingPhase) { - trace.enter("addOrReplaceAspect", this, new Object[] { aspectType, new Boolean(inWeavingPhase) }); + + if (!world.isAspectIncluded(aspectType)) { + return false; + } boolean change = false; CrosscuttingMembers xcut = (CrosscuttingMembers) members.get(aspectType); @@ -93,7 +95,6 @@ public class CrosscuttingMembersSet { } changedSinceLastReset = changedSinceLastReset || change; - trace.exit("addOrReplaceAspect", change); return change; } @@ -117,6 +118,9 @@ public class CrosscuttingMembersSet { } public void addAdviceLikeDeclares(ResolvedType aspectType) { + if (!members.containsKey(aspectType)) { + return; + } CrosscuttingMembers xcut = (CrosscuttingMembers) members.get(aspectType); xcut.addDeclares(aspectType.collectDeclares(true)); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java index 9b6dc7dd4..5cb5ca582 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java @@ -21,6 +21,7 @@ import org.aspectj.bridge.SourceLocation; import org.aspectj.util.PartialOrder; import org.aspectj.weaver.patterns.PerClause; import org.aspectj.weaver.patterns.Pointcut; +import org.aspectj.weaver.patterns.TypePattern; /** * For every shadow munger, nothing can be done with it until it is concretized. Then... @@ -66,6 +67,15 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH * All overriding methods should call super */ public boolean match(Shadow shadow, World world) { + if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) { + TypePattern scoped = world.getAspectScope(declaringType); + if (scoped != null) { + boolean b = scoped.matches(shadow.getEnclosingType().resolve(world), TypePattern.STATIC).alwaysTrue(); + if (!b) { + return false; + } + } + } return pointcut.match(shadow).maybeTrue(); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index b0c8b3f12..ed7d3e52f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -38,6 +38,7 @@ import org.aspectj.util.IStructureModel; import org.aspectj.weaver.UnresolvedType.TypeKind; import org.aspectj.weaver.patterns.DeclarePrecedence; import org.aspectj.weaver.patterns.Pointcut; +import org.aspectj.weaver.patterns.TypePattern; import org.aspectj.weaver.tools.PointcutDesignatorHandler; import org.aspectj.weaver.tools.Trace; import org.aspectj.weaver.tools.TraceFactory; @@ -1290,8 +1291,12 @@ public abstract class World implements Dump.INode { return false; } - // public boolean specifiesInclusionOfAspect(String name) { - // return true; - // } + public boolean isAspectIncluded(ResolvedType aspectType) { + return true; + } + + public TypePattern getAspectScope(ResolvedType declaringType) { + return null; + } }
\ No newline at end of file |