aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs198/github_128/annotation_syntax/MarkerBAspect.aj
blob: d5548f9da5349c2341ed8f24b7a4580d54b649a4 (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
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Aspect
public class MarkerBAspect {
  @Around("@annotation(MarkerB) && execution(* *(..))")
  public Object intercept(ProceedingJoinPoint thisJoinPoint) throws Throwable {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        try {
          for (int i = 0; i < Application.proceedTimesInner; i++) {
            System.out.println("      >> Inner proceed");
            thisJoinPoint.proceed();
            System.out.println("      << Inner proceed");
          }
        }
        catch (Throwable throwable) {
          throwable.printStackTrace(System.out);
        }
      }
    };

    System.out.println("    >> Inner intercept");
    if (Application.useThreadPool)
      Application.executorService.submit(runnable);
    else
      new Thread(runnable).start();
    System.out.println("    << Inner intercept");
    return null;
  }
}