Hi,
I'm trying to create a pointcut designator that applies an advise after
it skips the first N number of times. For example
************************************
before(): AfterN(10) && execution(* *.*(..)) {
// my advise
}
***************************************
Will skip applying the advise the first 10 times there is a method
execution. And will start applying "my advise" after that.
There are two main things that I'm trying to do.
First: creating a counter for EACH pointcut expression that has AfterN
(not for each method or a class)
Second: Trying to write dynamic code that will do the first thing above
and doing some checks.
So, here is what I did (with the help of Eric).
in my aspectinfo.AfterN class, I have this method
***************************************
protected Residue matchesAt(ShadowMatch sm)
{
return new AfterNDResidue(cutPoint); // start point when advise
is applied
}
***************************************
My problem is that I need to know to write some simple dynamic code that
will:
For each pointcut expression that has AfterN
- create a local counter for that expression (lets call it n) and
initialize it // again a local counter for the expression not the
underlying method or class
- check if n>cutpoint
- if true apply the advise
- if false dont not apply the adivse
- increment n each time the we need to apply the advise
I truly appreciate any help.
Amjad
Received on Fri Aug 28 2009 - 20:18:04 BST
This archive was generated by hypermail 2.2.0 : Mon Aug 31 2009 - 23:50:10 BST