Browse Source

Declare annotation: support for new declare collections.

tags/V1_5_0M2
aclement 19 years ago
parent
commit
b75f15d483

+ 45
- 1
weaver/src/org/aspectj/weaver/CrosscuttingMembers.java View File

@@ -53,6 +53,10 @@ public class CrosscuttingMembers {
private List declareSofts = new ArrayList(0);
private List declareDominates = new ArrayList(4);
// These are like declare parents type mungers
private List declareAnnotationsOnType = new ArrayList();
private List declareAnnotationsOnField = new ArrayList();
private List declareAnnotationsOnMethods = new ArrayList(); // includes ctors
public CrosscuttingMembers(ResolvedTypeX inAspect) {
this.inAspect = inAspect;
@@ -116,7 +120,16 @@ public class CrosscuttingMembers {
declareSofts.add(new DeclareSoft(d.getException(), concretePointcut));
addConcreteShadowMunger(m);
} else if (declare instanceof DeclareAnnotation) {
System.err.println("Need to implement CrosscuttingMembers.addDeclare for annotations");
// FIXME asc perf Possible Improvement. Investigate why this is called twice in a weave ?
DeclareAnnotation da = (DeclareAnnotation)declare;
da.setAspect(this.inAspect);
if (da.isDeclareAtType()) {
declareAnnotationsOnType.add(da);
} else if (da.isDeclareAtField()) {
declareAnnotationsOnField.add(da);
} else if (da.isDeclareAtMethod() || da.isDeclareAtConstuctor()) {
declareAnnotationsOnMethods.add(da);
}
} else {
throw new RuntimeException("unimplemented");
}
@@ -199,6 +212,22 @@ public class CrosscuttingMembers {
declareSofts = other.declareSofts;
}
// DECAT for when attempting to replace an aspect
if (!declareAnnotationsOnType.equals(other.declareAnnotationsOnType)) {
changed = true;
declareAnnotationsOnType = other.declareAnnotationsOnType;
}
if (!declareAnnotationsOnField.equals(other.declareAnnotationsOnField)) {
changed = true;
declareAnnotationsOnField = other.declareAnnotationsOnField;
}
if (!declareAnnotationsOnMethods.equals(other.declareAnnotationsOnMethods)) {
changed = true;
declareAnnotationsOnMethods = other.declareAnnotationsOnMethods;
}
return changed;
}

@@ -229,5 +258,20 @@ public class CrosscuttingMembers {
public List getTypeMungers() {
return typeMungers;
}
public List getDeclareAnnotationOnTypes() {
return declareAnnotationsOnType;
}
public List getDeclareAnnotationOnFields() {
return declareAnnotationsOnField;
}
/**
* includes declare @method and @constructor
*/
public List getDeclareAnnotationOnMethods() {
return declareAnnotationsOnMethods;
}

}

+ 40
- 0
weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java View File

@@ -37,6 +37,9 @@ public class CrosscuttingMembersSet {
private List typeMungers = null;
private List declareSofts = null;
private List declareParents = null;
private List declareAnnotationOnTypes = null;
private List declareAnnotationOnFields = null;
private List declareAnnotationOnMethods= null; // includes ctors
private List declareDominates = null;
public CrosscuttingMembersSet(World world) {
@@ -138,6 +141,43 @@ public class CrosscuttingMembersSet {
return declareParents;
}
// DECAT Merge multiple together
public List getDeclareAnnotationOnTypes() {
if (declareAnnotationOnTypes == null) {
ArrayList ret = new ArrayList();
for (Iterator i = members.values().iterator(); i.hasNext(); ) {
ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnTypes());
}
declareAnnotationOnTypes = ret;
}
return declareAnnotationOnTypes;
}
public List getDeclareAnnotationOnFields() {
if (declareAnnotationOnFields == null) {
ArrayList ret = new ArrayList();
for (Iterator i = members.values().iterator(); i.hasNext(); ) {
ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnFields());
}
declareAnnotationOnFields = ret;
}
return declareAnnotationOnFields;
}
/**
* Return an amalgamation of the declare @method/@constructor statements.
*/
public List getDeclareAnnotationOnMethods() {
if (declareAnnotationOnMethods == null) {
ArrayList ret = new ArrayList();
for (Iterator i = members.values().iterator(); i.hasNext(); ) {
ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnMethods());
}
declareAnnotationOnMethods = ret;
}
return declareAnnotationOnMethods;
}
public List getDeclareDominates() {
if (declareDominates == null) {
ArrayList ret = new ArrayList();

+ 12
- 0
weaver/src/org/aspectj/weaver/World.java View File

@@ -400,6 +400,18 @@ public abstract class World implements Dump.INode {
public List getDeclareParents() {
return crosscuttingMembersSet.getDeclareParents();
}
public List getDeclareAnnotationOnTypes() {
return crosscuttingMembersSet.getDeclareAnnotationOnTypes();
}
public List getDeclareAnnotationOnFields() {
return crosscuttingMembersSet.getDeclareAnnotationOnFields();
}
public List getDeclareAnnotationOnMethods() {
return crosscuttingMembersSet.getDeclareAnnotationOnMethods();
}

public List getDeclareSoft() {
return crosscuttingMembersSet.getDeclareSofts();

Loading…
Cancel
Save