]> source.dussan.org Git - aspectj.git/commitdiff
124460 and refactoring
authoraclement <aclement>
Tue, 15 Sep 2009 19:41:37 +0000 (19:41 +0000)
committeraclement <aclement>
Tue, 15 Sep 2009 19:41:37 +0000 (19:41 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java
org.aspectj.matcher/src/org/aspectj/weaver/World.java

index a55c84fd00d11defec3e606139749ba9f3f5157b..f31655ed20d89eac6d2422b5fb1d706c79d82b1a 100644 (file)
@@ -16,9 +16,14 @@ import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
+import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.MessageUtil;
 import org.aspectj.bridge.SourceLocation;
 import org.aspectj.util.PartialOrder;
 import org.aspectj.weaver.patterns.PerClause;
@@ -67,7 +72,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                this.end = end;
                this.sourceContext = sourceContext;
        }
-
+       
        /**
         * All overriding methods should call super
         */
@@ -75,8 +80,24 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                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();
+                               // Check the 'cached' exclusion map 
+                               Set<ResolvedType> excludedTypes = world.getExclusionMap().get(declaringType);
+                               ResolvedType type = shadow.getEnclosingType().resolve(world);
+                               if (excludedTypes!=null && excludedTypes.contains(type)) {
+                                       return false;
+                               }
+                               boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue();
                                if (!b) {
+                                       if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
+                                               world.getMessageHandler().handleMessage(MessageUtil.info("Type '"+type.getName()+"' not woven by aspect '"+declaringType.getName()+"' due to scope exclusion in XML definition"));
+                                       }
+                                       if (excludedTypes==null) {
+                                               excludedTypes = new HashSet<ResolvedType>();
+                                               excludedTypes.add(type);
+                                               world.getExclusionMap().put(declaringType,excludedTypes);
+                                       } else {
+                                               excludedTypes.add(type);
+                                       }                                       
                                        return false;
                                }
                        }
index cdb01a1c8739f5d16432cb127b2397e2a0bbb9ad..dd61947a376590bf6170ea455d40638cdb37e0b5 100644 (file)
@@ -1396,5 +1396,15 @@ public abstract class World implements Dump.INode {
        protected boolean isExpendable(ResolvedType type) {
                return (!type.equals(UnresolvedType.OBJECT) && (!type.isExposedToWeaver()) && (!type.isPrimitiveType()));
        }
+       
+
+       // map from aspect > excluded types
+       // memory issue here?
+       private Map<ResolvedType,Set<ResolvedType>> exclusionMap = new HashMap<ResolvedType,Set<ResolvedType>>();
+
+
+       public Map<ResolvedType,Set<ResolvedType>> getExclusionMap() {
+               return exclusionMap;
+       }
 
 }
\ No newline at end of file