Total Complexity | 4 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | 1 | package io.mcarle.sciurus.monitor; |
|
10 | @Aspect |
||
11 | 1 | public class MonitorAspect { |
|
12 | |||
13 | /** |
||
14 | * Matches any execution of any method |
||
15 | */ |
||
16 | @Pointcut("execution(* *(..))") |
||
17 | void anyMethod() { |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * Matches any method, which is annotated with {@link Monitor} |
||
22 | */ |
||
23 | @Pointcut("@annotation(monitor)") |
||
24 | void monitorAnnotated(Monitor monitor) { |
||
25 | } |
||
26 | |||
27 | @Around(value = "anyMethod() && monitorAnnotated(monitor)", argNames = "joinPoint,monitor") |
||
28 | public Object startedAndExecutionOfAnyMethodAnnotatedWithMonitor( |
||
29 | ProceedingJoinPoint joinPoint, |
||
30 | Monitor monitor |
||
31 | ) throws Throwable { |
||
32 | 1 | if (Sciurus.isMonitorStarted()) { |
|
33 | 1 | return MonitorAspectHandler.executeAndMeasure(joinPoint); |
|
34 | } else { |
||
35 | 1 | return joinPoint.proceed(); |
|
36 | } |
||
40 |