Kyle, If you leave the pointcuts as you specified in your first email:
call(* test.*.print*(..)) then aspectj will weave all the methods that start with print in all the classes in the package starting with test and returning anything. However, you can narrow down the classes that get weaved, and also the methods that get intercepted. For example: call(* SomeInterface+.print*(..)) execution(* SomeInterface+.print*(..)) These two pointcut designators will intercept print* methods called on SomeInterface or any class that implements that interface. When a print* method in any of the SomeInterface class hierarchy is called you will have two interceptions: one for the call, and the other for the execution. You are minimizing the performance hit by writing tight pointcuts. You can specify the Annotation you are expecting in your pointcut. You do not need to reflective check for them. Here's how it goes... 1. Make sure the annotations have a retention policy of Runtime. 2. Write the pointcut as call(@MethodAnnotation * SomeInterface+.print*(..)) Refer: http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html#signaturePatterns To summarize narrow down the pointcut to the type, method, and annotation you are interested in. You do not need to reflectively check for the annotation. Now, you will have aspects with much lesser performance impact. Monal http://www.goi18n.com/ http://goi18n.com/ On 1/29/07, Kyle Lomeli <[EMAIL PROTECTED]> wrote:
Monal, Thanks for your suggestions! I had considered your second suggestion but found the cost iterating through the interface definition and class definition for the appropriate method annotation to be too expensive on each joinpoint. However, I do like your first suggestion. I had not thought of using the distinction between call pointcut designators and execution designators to differentiate between an implementation call and a call against an interface. My only concern with this option is the cost of having two joinpoints evaluate against each intercepted (proper terminology?) call. When it comes to byte-code weaving if I follow your suggestion, would each intercepted method now perform two checks to see if it an annotation is present?... or would this check happen only during weaving and any subsequent calls to these methods would only trigger the appropriate advice logic? In any case, thanks again for your advice! -Kyle ----- Original Message ---- From: Monal Daxini <[EMAIL PROTECTED]> To: [email protected] Sent: Monday, January 29, 2007 3:08:25 PM Subject: Re: [aspectj-users] Interfaces vs Concrete Classes? Kyle, As you may know the annotations on methods are not inherited by implementing or overriding methods. You could: 1. Use an execution pointcut designator, and then access the signature and check for the annotation on the implementation method, and also use a call pointcut designator for the calls on the interface method and check on the annotation. You could use a variable to track if the annotation exists on either in your aspect. Note: This may not be an option if you cannot use execution pointcut designator. 2 In adition to the code in MethodAnnotationAspect, you could use thisJoinPoint.getTarget (I think this returns the object implementing the interface) and then check the annotation. Note: This is similar to 1 above except that it does not use the execution pointcut designator. 3. you can use the target pointcut designator http://www.eclipse.org/aspectj/doc/released/progguide/starting-aspectj.html#pointcuts Monal http://www.goi18n.com/ http://goi18n.com/ _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users ________________________________ We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
