浏览代码

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

刘羽铖 6 年之前
父节点
当前提交
c32e8d9b55

+ 2 - 1
hutool-aop/src/main/java/cn/hutool/aop/aspects/Aspect.java

@@ -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);
 
 	/**
 	 * 目标方法抛出异常时的操作

+ 1 - 1
hutool-aop/src/main/java/cn/hutool/aop/aspects/SimpleAspect.java

@@ -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;
 	}

+ 1 - 1
hutool-aop/src/main/java/cn/hutool/aop/aspects/TimeIntervalAspect.java

@@ -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;
 	}