Added
Link Here
|
1 |
import org.aspectj.lang.JoinPoint; |
2 |
import org.aspectj.lang.annotation.Aspect; |
3 |
import org.aspectj.lang.annotation.Before; |
4 |
import org.aspectj.lang.annotation.Pointcut; |
5 |
|
6 |
@Aspect |
7 |
class AbstractTracer |
8 |
{ |
9 |
|
10 |
@Pointcut("(execution(public * Foo.anotherMethod*(..)) || execution(public * Foo.methodA(..))) && this(obj)") |
11 |
protected void methodExec(Object obj){}; |
12 |
|
13 |
@Before("methodExec(obj)") |
14 |
public void beforeMethodExec(JoinPoint thisJoinPoint, Object obj) { |
15 |
System.out.println("Before " + thisJoinPoint.getSignature().toString()); |
16 |
} |
17 |
|
18 |
} |
19 |
|
20 |
|
21 |
class Foo { |
22 |
|
23 |
public void methodA() { |
24 |
} |
25 |
|
26 |
public void anotherMethod() { |
27 |
} |
28 |
|
29 |
} |