| Summary: | construction of entire aspects using aop.xml | ||
|---|---|---|---|
| Product: | [Tools] AspectJ | Reporter: | Andrew Clement <aclement> |
| Component: | LTWeaving | Assignee: | aspectj inbox <aspectj-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | DEVELOPMENT | ||
| Target Milestone: | 1.6.12 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Andrew Clement
basic version committed. We don't want to go as far as allowing java code to be written in the XML, so what we have now is that you can define a pointcut and link it to a Java method. AspectJ will then generate an aspect containing the necessary advice construct and that advice will simply delegate to the Java method that was selected. Currently supports before/after/around advice - but doesn't allow differentiation between after returning and after throwing (those can be added by whoever first wants the support!). proceed works too.
Examples:
<aspects>
<concrete-aspect name="ConjuredUp">
<before pointcut="execution(* Hello2.say2(..)) AND args(w) " invokeClass="JavaHelper" invokeMethod="advice2(java.lang.String w)"/>
</concrete-aspect>
</aspects>
public class JavaHelper {
public static void advice2(String s) {
System.out.println("in advice: s="+s);
}
}
(notice arg binding is done based on the names in the XML file, not the names in the delegate method)
<concrete-aspect name="ConjuredUp">
<before pointcut="execution(* Hello2.say2(..)) AND args(w) " invokeClass="JavaHelper" invokeMethod="advice4(JoinPoint tjp, java.lang.String w)"/>
<after pointcut="execution(* Hello2.say2(..)) AND args(w) " invokeClass="JavaHelper" invokeMethod="advice5(JoinPoint tjp, java.lang.String w)"/>
</concrete-aspect>
public static void advice4(org.aspectj.lang.JoinPoint tjp, String s) {
System.out.println("in advice4: s="+s+" at "+tjp);
}
public static void advice5(org.aspectj.lang.JoinPoint tjp, String s) {
System.out.println("in advice5: s="+s+" at "+tjp);
}
(notice types are fully specified *except* JoinPoint since we know what that one is they can just use the unqualifed name in the XML)
There is more checking that could be done which I haven't added yet (e.g. whether the selected method is static). A similar model could be extended to support any declares too (anntation/parents).
complete enough for now. |