1、切面after切点,将目标方法执行返回值,开放给切点

This commit is contained in:
刘羽铖 2019-09-25 10:05:38 +08:00
parent 6d310646ad
commit c32e8d9b55
3 changed files with 4 additions and 3 deletions

View File

@ -26,9 +26,10 @@ public interface Aspect{
* @param target 目标对象
* @param method 目标方法
* @param args 参数
* @param returnVal 目标方法执行返回值
* @return 是否允许返回值接下来的操作
*/
boolean after(Object target, Method method, Object[] args);
boolean after(Object target, Method method, Object[] args, Object returnVal);
/**
* 目标方法抛出异常时的操作

View File

@ -20,7 +20,7 @@ public class SimpleAspect implements Aspect, Serializable{
}
@Override
public boolean after(Object target, Method method, Object[] args) {
public boolean after(Object target, Method method, Object[] args, Object returnVal) {
//继承此类后实现此方法
return true;
}

View File

@ -22,7 +22,7 @@ public class TimeIntervalAspect extends SimpleAspect{
}
@Override
public boolean after(Object target, Method method, Object[] args) {
public boolean after(Object target, Method method, Object[] args, Object returnVal) {
Console.log("Method [{}.{}] execute spend [{}]ms", target.getClass().getName(), method.getName(), interval.intervalMs());
return true;
}