public class MyAdvice implements Advice {
long beginTime = 0;
public void afterMethod(Method method) {
// TODO Auto-generated method stub
System.out.println("方法后");
long endTime = System.currentTimeMillis();
System.out.println(method.getName() + " running time of " + (endTime - beginTime));
}
public void beforeMethod(Method method) {
// TODO Auto-generated method stub
System.out.println("方法前");
beginTime = System.currentTimeMillis();
}
}
运行结果:
方法前
方法后
add running time of 0
方法前
方法后
add running time of 0
方法前
方法后
add running time of 0
方法前
方法后
size running time of 0
3
$Proxy0