public class DefaultInterceptor extends java.lang.Object implements Interceptor
默认的拦截器
建议继承这个类,选择性覆盖要拦截的方法
Default interceptor
Recommend to extend this class, and override methods selectively
Email: fishinlove@163.com
created by 2019/04/14 16:21:27
Interceptor| 构造器和说明 |
|---|
DefaultInterceptor() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
after(InterceptedMethod method)
在执行切面方法之后执行这个方法
注意:
如果需要获取被拦截方法的执行结果,调用 cn.com.fishin.tuz.entity.InterceptedMethod#getResult()。
|
boolean |
afterReturning(InterceptedMethod method)
在方法返回之后执行,实质是在 finally 块中执行
注意:
在执行这个方法的时候,由于被拦截的方法可能抛出了异常,所以这个时候有可能是拿不到返回值的,
不建议在这个方法中操作被拦截方法的执行结果
Invoke this method when intercepted method throws an exception
Notice:
When this method is invoking, you may not get the result of the intercepted method.
|
boolean |
afterThrowing(InterceptedMethod method)
在执行切面方法抛出异常之后执行这个方法
注意:
在执行这个方法的时候,由于被拦截的方法抛出了异常,所以这个时候有可能是拿不到返回值的,
如果你需要返回结果,请调用 cn.com.fishin.tuz.entity.InterceptedMethod#setResult(java.lang.Object)。
|
boolean |
before(InterceptedMethod method)
在执行切面方法之前执行这个方法
注意:
在执行这个方法的时候,由于被拦截的方法还没有执行,所以这个时候是拿不到返回值的,
如果你在做缓存-数据库的拦截,需要将从缓存中拿到的数据设置进 InterceptedMethod#result,
然后返回 false 以阻止继续执行被拦截的方法
Invoke before intercepted method
Notice:
When this method is invoking, you can not get the result of the intercepted method,
so if you are develop a cache-database service, you should set the result from cache by
cn.com.fishin.tuz.entity.InterceptedMethod#setResult(java.lang.Object),
and return false to prevent invoking intercepted method
|
public boolean before(InterceptedMethod method)
Interceptor在执行切面方法之前执行这个方法
注意:
在执行这个方法的时候,由于被拦截的方法还没有执行,所以这个时候是拿不到返回值的,
如果你在做缓存-数据库的拦截,需要将从缓存中拿到的数据设置进 InterceptedMethod#result,
然后返回 false 以阻止继续执行被拦截的方法
Invoke before intercepted method
Notice:
When this method is invoking, you can not get the result of the intercepted method,
so if you are develop a cache-database service, you should set the result from cache by
cn.com.fishin.tuz.entity.InterceptedMethod#setResult(java.lang.Object),
and return false to prevent invoking intercepted method
before 在接口中 Interceptormethod - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)public boolean after(InterceptedMethod method)
Interceptor在执行切面方法之后执行这个方法
注意:
如果需要获取被拦截方法的执行结果,调用 cn.com.fishin.tuz.entity.InterceptedMethod#getResult()。
返回 false 可以阻止继续下一个拦截器执行
Invoke after intercepted method
Notice:
If you want the result of intercepted method,
call cn.com.fishin.tuz.entity.InterceptedMethod#getResult().
return false to prevent invoking next interceptor
after 在接口中 Interceptormethod - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.getResult()public boolean afterThrowing(InterceptedMethod method)
Interceptor在执行切面方法抛出异常之后执行这个方法
注意:
在执行这个方法的时候,由于被拦截的方法抛出了异常,所以这个时候有可能是拿不到返回值的,
如果你需要返回结果,请调用 cn.com.fishin.tuz.entity.InterceptedMethod#setResult(java.lang.Object)。
返回 false 可以阻止继续下一个拦截器执行
Invoke this method when intercepted method throws an exception
Notice:
When this method is invoking, you may not get the result of the intercepted method,
so if you want to return a result, you should set the result by invoking
cn.com.fishin.tuz.entity.InterceptedMethod#setResult(java.lang.Object).
return false to prevent invoking intercepted method
afterThrowing 在接口中 Interceptormethod - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)public boolean afterReturning(InterceptedMethod method)
Interceptor在方法返回之后执行,实质是在 finally 块中执行
注意:
在执行这个方法的时候,由于被拦截的方法可能抛出了异常,所以这个时候有可能是拿不到返回值的,
不建议在这个方法中操作被拦截方法的执行结果
Invoke this method when intercepted method throws an exception
Notice:
When this method is invoking, you may not get the result of the intercepted method.
Update result in this method is not recommended
return false to prevent invoking intercepted method
afterReturning 在接口中 Interceptormethod - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)Copyright © 2019. All Rights Reserved.