]> source.dussan.org Git - aspectj.git/commitdiff
code for enh193065: pointcutdoctor changes
authoraclement <aclement>
Sun, 2 Dec 2007 11:42:42 +0000 (11:42 +0000)
committeraclement <aclement>
Sun, 2 Dec 2007 11:42:42 +0000 (11:42 +0000)
weaver/src/org/aspectj/weaver/CustomMungerFactory.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

diff --git a/weaver/src/org/aspectj/weaver/CustomMungerFactory.java b/weaver/src/org/aspectj/weaver/CustomMungerFactory.java
new file mode 100644 (file)
index 0000000..67f0dfc
--- /dev/null
@@ -0,0 +1,21 @@
+/* *******************************************************************
+ * Copyright (c) 2007 Contributors
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Linton Ye https://bugs.eclipse.org/bugs/show_bug.cgi?id=193065
+ * ******************************************************************/
+
+package org.aspectj.weaver;
+
+import java.util.Collection;
+
+public interface CustomMungerFactory {
+       public Collection/*ShadowMunger*/ createCustomShadowMungers(ResolvedType aspectType);
+       public Collection/*ConcreteTypeMunger*/ createCustomTypeMungers(ResolvedType aspectType);
+//     public Collection<Declare> createCustomDeclares(ResolvedType aspectType);
+}
index db432e01498a17e5ff1dbd78af3fc7317fb60945..d0e52546bf514196b9c40cf62b091d510e61cf9f 100644 (file)
@@ -1042,6 +1042,25 @@ public abstract class World implements Dump.INode {
            public int hardSize() {
                return tMap.size();
            }
+           
+               public ResolvedType[] getAllTypes() {
+                       List/*ResolvedType*/ results = new ArrayList();
+
+                       collectTypes(expendableMap, results);
+                       collectTypes(tMap, results);
+                       return (ResolvedType[]) results.toArray(new ResolvedType[results.size()]);
+               }
+
+               private void collectTypes(Map map, List/*ResolvedType*/ results) {
+                       for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
+                               String key = (String) iterator.next();
+                               ResolvedType type = get((String)key);
+                               if (type!=null) results.add(type);
+                               else System.err.println("null!:"+key);
+                       }
+               }
+
+
        }       
        
        /** Reference types we don't intend to weave may be ejected from
@@ -1250,4 +1269,9 @@ public abstract class World implements Dump.INode {
            public boolean isASMAround() { 
                return isASMAround;
            }
+           
+               public ResolvedType[] getAllTypes() {
+                       return typeMap.getAllTypes();
+               }
+
 }
\ No newline at end of file
index 1ca6a5dac30dd5bb1b8ad3875bcc34a2314c7703..b0d2cf61b0bcad32dae48f3e97bd05aa04d1128d 100644 (file)
@@ -64,6 +64,7 @@ import org.aspectj.weaver.AsmRelationshipProvider;
 import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ConcreteTypeMunger;
 import org.aspectj.weaver.CrosscuttingMembersSet;
+import org.aspectj.weaver.CustomMungerFactory;
 import org.aspectj.weaver.IClassFileProvider;
 import org.aspectj.weaver.IWeaveRequestor;
 import org.aspectj.weaver.IWeaver;
@@ -138,6 +139,7 @@ public class BcelWeaver implements IWeaver {
        private List declareParentsList = null; // setup by prepareForWeave
 
     private ZipOutputStream zipOutputStream;
+       private CustomMungerFactory customMungerFactory;
 
        // ----
     
@@ -488,6 +490,8 @@ public class BcelWeaver implements IWeaver {
                typeMungerList = xcutSet.getTypeMungers();
         lateTypeMungerList = xcutSet.getLateTypeMungers();
                declareParentsList = xcutSet.getDeclareParents();
+               
+               addCustomMungers();
        
                // The ordering here used to be based on a string compare on toString() for the two mungers - 
                // that breaks for the @AJ style where advice names aren't programmatically generated.  So we
@@ -519,6 +523,30 @@ public class BcelWeaver implements IWeaver {
                if (trace.isTraceEnabled()) trace.exit("prepareForWeave");
     }
     
+    private void addCustomMungers() {
+               if (customMungerFactory != null) {
+                       for (Iterator i = addedClasses.iterator(); i.hasNext();) {
+                               UnwovenClassFile jc = (UnwovenClassFile) i.next();
+                               String name = jc.getClassName();
+                               ResolvedType type = world.resolve(name);
+                               if (type.isAspect()) {
+                                       Collection/*ShadowMunger*/ shadowMungers = customMungerFactory.createCustomShadowMungers(type);
+                                       if (shadowMungers != null) {
+                                               shadowMungerList.addAll(shadowMungers);
+                                       }
+                                       Collection/*ConcreteTypeMunger*/ typeMungers = customMungerFactory
+                                                       .createCustomTypeMungers(type);
+                                       if (typeMungers != null)
+                                               typeMungerList.addAll(typeMungers);
+                               }
+                       }
+               }
+       }
+    
+    public void setCustomMungerFactory(CustomMungerFactory factory) {
+       customMungerFactory = factory;
+    }
+    
     /*
      * Rewrite all of the pointcuts in the world into their most efficient
      * form for subsequent matching. Also ensure that if pc1.equals(pc2)