/**
* Generates bytecode for concrete-aspect.
* <p>
- * The concrete aspect is @AspectJ code generated. As it is build during aop.xml definitions registration we perform the type
- * munging for perclause, ie. aspectOf() artifact directly, instead of waiting for it to go thru the weaver (that we are in the
- * middle of configuring).
+ * The concrete aspect is generated annotation style aspect (so traditional Java constructs annotated with our AspectJ annotations).
+ * As it is built during aop.xml definitions registration we perform the type munging for perclause, ie. aspectOf() artifact
+ * directly, instead of waiting for it to go thru the weaver (that we are in the middle of configuring).
*
* @author Alexandre Vasseur
* @author Andy Clement
private byte[] bytes;
/**
- * Create a new compiler for a concrete aspect
+ * Create a new generator for a concrete aspect
*
- * @param concreteAspect
- * @param world
+ * @param concreteAspect the aspect definition
+ * @param world the related world (for type resolution, etc)
*/
ConcreteAspectCodeGen(Definition.ConcreteAspect concreteAspect, World world) {
this.concreteAspect = concreteAspect;
}
/**
- * Checks that concrete aspect is valid
+ * Checks that concrete aspect is valid.
*
* @return true if ok, false otherwise
*/
List<String> elligibleAbstractions = new ArrayList<String>();
Collection<ResolvedMember> abstractMethods = getOutstandingAbstractMethods(parent);
- // for (Iterator iter = abstractMethods.iterator(); iter.hasNext();) {
- // ResolvedMember method = (ResolvedMember) iter.next();
for (ResolvedMember method : abstractMethods) {
if ("()V".equals(method.getSignature())) {
String n = method.getName();
}
} else {
if (method.getName().startsWith("ajc$pointcut") || hasPointcutAnnotation(method)) {
- // it may be a pointcut but it doesn't meet the requirements
- // for XML concretization
+ // it may be a pointcut but it doesn't meet the requirements for XML concretization
reportError("Abstract method '"
+ method.toString()
+ "' cannot be concretized as a pointcut (illegal signature, must have no arguments, must return void): "
sb.append("' perclause='");
sb.append(concreteAspect.perclause);
sb.append("'/> in aop.xml");
+ // TODO needs the extra state from the definition (concretized pointcuts and advice definitions)
return sb.toString();
}
}
}
- // TODO AV - abstract away from BCEL...
// @Aspect //inherit clause from m_parent
// @DeclarePrecedence("....") // if any
// public class xxxName [extends xxxExtends] {
}
}
// @Aspect public class ...
- // TODO AV - we could point to the aop.xml that defines it and use
- // JSR-45
+ // TODO AV - we could point to the aop.xml that defines it and use JSR-45
LazyClassGen cg = new LazyClassGen(concreteAspect.name.replace('.', '/'), parentName, null, Modifier.PUBLIC
+ Constants.ACC_SUPER, EMPTY_STRINGS, world);
if (parent != null && parent.isParameterizedType()) {
cg.addMethodGen(mg);
}
+ // Construct any defined declare error/warnings
if (concreteAspect.deows.size() > 0) {
-
int counter = 1;
for (Definition.DeclareErrorOrWarning deow : concreteAspect.deows) {
-
// Building this:
-
// @DeclareWarning("call(* javax.sql..*(..)) && !within(org.xyz.daos..*)")
// static final String aMessage = "Only DAOs should be calling JDBC.";
field.setValue(deow.message);
cg.addField(field, null);
-
}
}