aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2007-12-02 11:42:42 +0000
committeraclement <aclement>2007-12-02 11:42:42 +0000
commit9391b1d1cfc643e249cf8f67a11eec2e63f98cfd (patch)
treec837d4e0f0d9325b6cb75d9cdd22c9592a4f3ac1 /weaver
parent9de03b75977599b12208c93c20cfc50fa85d7e22 (diff)
downloadaspectj-9391b1d1cfc643e249cf8f67a11eec2e63f98cfd.tar.gz
aspectj-9391b1d1cfc643e249cf8f67a11eec2e63f98cfd.zip
code for enh193065: pointcutdoctor changes
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/CustomMungerFactory.java21
-rw-r--r--weaver/src/org/aspectj/weaver/World.java24
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java28
3 files changed, 73 insertions, 0 deletions
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<Declare> 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)