mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
1、切面after切点,将目标方法执行返回值,开放给切点
This commit is contained in:
parent
6d310646ad
commit
c32e8d9b55
@ -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);
|
||||
|
||||
/**
|
||||
* 目标方法抛出异常时的操作
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user