[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to capture non-recursive execution of 'a kind of' method

Hi all,

  i am trying to capture the non-recursive execution of 'a kind of method',
but don't know how to write the
pointcut. 
(similar to the solution 'move() && !cflowbelow(move())' where move() is a
execution pointcut to a 
method).

  the problem is that, the execution pointcut is defined in an abstract
aspect and other sub-aspects
 supply the real definitions. the above 'move() && !cflowbelow(move())'
idiom not work.

  let me illustrate the problem with the code below:

sample class to be weaved
--------------------------------
public class Test1 {

	public static void main(String[] args) {		
       
           new Test1().doGet(null);
        
	}
	
	public void doGet(String ooo) {
		
             //print message by aspect in before() advice
        
             doPost(ooo);
	}

	public void doPost(String o) {
		
	     //do not want to print message by aspect, as in cflowbelow of another
pointcut
	}	
}
--------------------------------------------------

public abstract aspect TestingAspect {

    //match doGet

    public static aspect KK extends TestingAspect {
        public  pointcut topLevelPoint() : execution(* Test1.doGet(..));        
    }

    //match doPost

    public static aspect YY extends TestingAspect{
        public  pointcut topLevelPoint() : execution(* Test1.doPost(..));
    }


    public abstract pointcut topLevelPoint();

    //only want to match outermost method

    before() : topLevelPoint() && !cflowbelow(topLevelPoint()) {
        
        System.out.println(thisJoinPoint + " : " +
thisJoinPoint.getSourceLocation());

    }
	
}  
------------------------------------------

the problem is that, in the definition 'topLevelPoint() &&
!cflowbelow(topLevelPoint()) ',
 KK.topLevelPoint() and YY.topLevelPoint() seems to be considered as
different.

so a message will be printed at execution of both doGet() and doPost(),
though execution of 
doPost() is in the cflowbelow of KK.topLevelPoint(). (called by doGet()
method)

(doGet call doGet or doPost call doPost do match by the above pointcut
definition, but doGet call doPost
or vice versa don't match).


what i want is to match the execution of a method, which is not in
cflowbelow of any method defined
by topLevelPoint() pointcut of other aspects.

i CAN'T HARDCODE the class name/method name as i am writing a non-intrusive
tool to be used by
other projects.

could you please give suggestion how to handle this problem???

thank you.

ppkluk

-- 
View this message in context: http://www.nabble.com/How-to-capture-non-recursive-execution-of-%27a-kind-of%27-method-tp24736637p24736637.html
Sent from the AspectJ - users mailing list archive at Nabble.com.