9 Feb 23:09
10 Feb 19:38
Re: Capturing join points based on thread
Andy Clement <andrew.clement <at> gmail.com>
2012-02-10 18:38:55 GMT
2012-02-10 18:38:55 GMT
You can use the thread information but only in an if() clause. Here
is an example program that selectively applies to joinpoints on a
thread:
===
aspect X {
before(): call(* foo(..)) &&
if(Thread.currentThread().getName().equals("two")) {
System.out.println("Intercepted call to foo on thread 'two'");
}
}
public class Flibble {
public static void main(String[] args) {
Thread s = new Thread(new MyRunnable(),"one");
Thread t = new Thread(new MyRunnable(),"two");
s.start();
t.start();
}
}
class MyRunnable implements Runnable {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
foo();
}
}
(Continue reading)
RSS Feed