From: aclement Date: Sun, 2 Dec 2007 11:42:42 +0000 (+0000) Subject: code for enh193065: pointcutdoctor changes X-Git-Tag: V1_5_4rc1~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9391b1d1cfc643e249cf8f67a11eec2e63f98cfd;p=aspectj.git code for enh193065: pointcutdoctor changes --- diff --git a/weaver/src/org/aspectj/weaver/CustomMungerFactory.java b/weaver/src/org/aspectj/weaver/CustomMungerFactory.java new file mode 100644 index 000000000..67f0dfc1a --- /dev/null +++ b/weaver/src/org/aspectj/weaver/CustomMungerFactory.java @@ -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 createCustomDeclares(ResolvedType aspectType); +} diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index db432e014..d0e52546b 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -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 diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 1ca6a5dac..b0d2cf61b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -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)