类 InterceptorChain
java.lang.Object
com.dtflys.forest.interceptor.InterceptorChain
- 所有已实现的接口:
OnCanceled,OnError,OnLoadCookie,OnProgress,OnRedirection,OnRetry,OnSaveCookie,OnSuccess,Interceptor
拦截器调用链
- 从以下版本开始:
- 2017-05-12 18:30
- 作者:
- gongjun[jun.gong@thebeastshop.com]
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明addInterceptor(Interceptor interceptor) voidafterExecute(ForestRequest request, ForestResponse response) 默认回调函数: 请求完成后(成功/失败后) 调用该方法booleanbeforeExecute(ForestRequest request) 默认回调函数: 请求执行前调用该方法intbyte[]onBodyEncode(ForestRequest request, ForestEncoder encoder, byte[] encodedData) 在请求体数据序列化后,发送请求数据前调用该方法voidonCanceled(ForestRequest request, ForestResponse response) 默认回调函数: 请求取消后调用该方法voidonError(ForestRuntimeException ex, ForestRequest request, ForestResponse response) 默认回调函数: 请求失败后调用该方法voidonInvokeMethod(ForestRequest request, ForestMethod method, Object[] args) 默认回调函数: 接口方法执行时调用该方法voidonLoadCookie(ForestRequest request, ForestCookies cookies) 默认回调函数: 在发送请求加载Cookie时调用该方法voidonProgress(ForestProgress progress) 默认文件上传或下载监听传输进度时调用该方法voidonRedirection(ForestRequest redirectReq, ForestRequest prevReq, ForestResponse prevRes) 默认回调函数:在请求重定向时触发voidonRetry(ForestRequest request, ForestResponse response) 默认回调函数: 在触发请求重试时执行voidonSaveCookie(ForestRequest request, ForestCookies cookies) 默认回调函数: 在请求响应成功后,需要保存Cookie时调用该方法voidonSuccess(Object data, ForestRequest request, ForestResponse response) 默认回调函数: 请求成功后调用该方法从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 com.dtflys.forest.interceptor.Interceptor
addAttribute, getAttribute, getAttribute, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsString, getAttributes
-
构造器详细资料
-
InterceptorChain
public InterceptorChain()
-
-
方法详细资料
-
addInterceptor
-
getInterceptorSize
public int getInterceptorSize() -
onInvokeMethod
从接口复制的说明:Interceptor默认回调函数: 接口方法执行时调用该方法默认为什么都不做
- 指定者:
onInvokeMethod在接口中Interceptor- 参数:
request- Forest请求对象method- Forest方法对象args- 方法调用入参数组
-
beforeExecute
从接口复制的说明:Interceptor默认回调函数: 请求执行前调用该方法其返回值为布尔类型,可以控制请求是否继续执行
默认为什么都不做
- 指定者:
beforeExecute在接口中Interceptor- 参数:
request- Forest请求对象- 返回:
true: 继续执行该请求, 否则中断请求
-
onBodyEncode
从接口复制的说明:Interceptor在请求体数据序列化后,发送请求数据前调用该方法默认为什么都不做
注: mutlipart/data类型的文件上传格式的 Body 数据不会调用该回调函数
- 指定者:
onBodyEncode在接口中Interceptor- 参数:
request- Forest请求对象encoder- Forest转换器encodedData- 序列化后的请求体数据
-
onSuccess
从接口复制的说明:Interceptor默认回调函数: 请求成功后调用该方法默认为什么都不做
- 指定者:
onSuccess在接口中Interceptor- 指定者:
onSuccess在接口中OnSuccess- 参数:
data- 请求响应返回后经过序列化后的数据request- Forest请求对象response- Forest响应对象
-
onRetry
从接口复制的说明:Interceptor默认回调函数: 在触发请求重试时执行默认为什么都不做
- 指定者:
onRetry在接口中Interceptor- 指定者:
onRetry在接口中OnRetry- 参数:
request- Forest请求对象response- Forest响应对象
-
onError
从接口复制的说明:Interceptor默认回调函数: 请求失败后调用该方法默认为什么都不做
- 指定者:
onError在接口中Interceptor- 指定者:
onError在接口中OnError- 参数:
ex- 请求失败的异常对象request- Forest请求对象response- Forest响应对象
-
onCanceled
从接口复制的说明:Interceptor默认回调函数: 请求取消后调用该方法默认为什么都不做
- 指定者:
onCanceled在接口中Interceptor- 指定者:
onCanceled在接口中OnCanceled- 参数:
request- Forest请求对象response- Forest响应对象
-
onRedirection
从接口复制的说明:Interceptor默认回调函数:在请求重定向时触发默认为什么都不做
- 指定者:
onRedirection在接口中Interceptor- 指定者:
onRedirection在接口中OnRedirection- 参数:
redirectReq- 进行重定向的新请求prevReq- 上一个请求prevRes- 上一个请求的响应
-
onProgress
从接口复制的说明:Interceptor默认文件上传或下载监听传输进度时调用该方法默认为什么都不做
- 指定者:
onProgress在接口中Interceptor- 指定者:
onProgress在接口中OnProgress- 参数:
progress- Forest进度对象
-
onLoadCookie
从接口复制的说明:Interceptor默认回调函数: 在发送请求加载Cookie时调用该方法默认为什么都不做
- 指定者:
onLoadCookie在接口中Interceptor- 指定者:
onLoadCookie在接口中OnLoadCookie- 参数:
request- Forest请求对象cookies- Cookie集合, 需要通过请求发送的Cookie都添加到该集合
-
onSaveCookie
从接口复制的说明:Interceptor默认回调函数: 在请求响应成功后,需要保存Cookie时调用该方法默认为什么都不做
- 指定者:
onSaveCookie在接口中Interceptor- 指定者:
onSaveCookie在接口中OnSaveCookie- 参数:
request- Forest请求对象cookies- Cookie集合,通过响应返回的Cookie都从该集合获取
-
afterExecute
从接口复制的说明:Interceptor默认回调函数: 请求完成后(成功/失败后) 调用该方法默认为什么都不做
- 指定者:
afterExecute在接口中Interceptor- 参数:
request- Forest请求对象response- Forest响应对象
-