blob: e832d0f68989e45da87ed6f0ada9d620d41b4edc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import java.util.Random;
/**
* Reproduces <a href="https://github.com/eclipse-aspectj/aspectj/issues/250">Github bug 250</a>
*/
@Aspect
public class MyAspect {
@Around("execution(* Application.*(..))")
public Object myAdvice1(ProceedingJoinPoint joinPoint) {
System.out.println(joinPoint);
a(1, "one");
return joinPoint.proceed();
}
@Around("execution(* Application.*(..))")
public Object myAdvice2(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println(joinPoint);
a(2);
return new Random().nextBoolean() ? joinPoint.proceed() : null;
}
private void a(int i) {
System.out.println(i);
}
private void a(int i, String s) {
System.out.println(i + " / " + s);
}
public static void main(String[] args) {
new Application().doSomething();
}
}
class Application {
public void doSomething() {}
}
|