blob: 180e10b9b205001ce4ccee956f6c112248ee25cd (
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
|
package test;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
class Monitor {
@Pointcut(value="execution(@PerformanceMonitor * *(..)) && @annotation(monitoringAnnot)", argNames="monitoringAnnot")
public void monitored(PerformanceMonitor monitoringAnnot) {}
// Not enough entries in argNames
@Around(value="monitored(monitoringAnnot)", argNames="")
public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformanceMonitor monitoringAnnot) throws Throwable {
//long start = System.nanoTime();
Object ret = pjp.proceed();
//long end = System.nanoTime();
//if(end - start > monitoringAnnot.expected()) {
// System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t"
// + "Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start));
//}
System.out.println("This method was intercepted by the advice: "+pjp.getSignature().toShortString());
return ret;
}
}
|