public interface Interceptor
拦截器接口
这个拦截器可以拦截到对象的所有方法,进行业务的主次解耦
建议直接使用默认的拦截器,选择性覆盖方法
Email: fishinlove@163.com
created by 2019/04/14 13:41:06
Interceptor interface
It will intercept all methods in an object
You may use default interceptor, and override methods seletively
,
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
|
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
method - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)boolean after(InterceptedMethod method)
在执行切面方法之后执行这个方法
注意:
如果需要获取被拦截方法的执行结果,调用 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
method - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.getResult()boolean afterThrowing(InterceptedMethod method)
在执行切面方法抛出异常之后执行这个方法
注意:
在执行这个方法的时候,由于被拦截的方法抛出了异常,所以这个时候有可能是拿不到返回值的,
如果你需要返回结果,请调用 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
method - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)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.
Update result in this method is not recommended
return false to prevent invoking intercepted method
method - 被拦截方法的信息
Intercepted method
true 允许下一个拦截器继续执行,false 反之
true allow next interceptor invoking
InterceptedMethod.setResult(java.lang.Object)Copyright © 2019. All Rights Reserved.