类 InterceptorChain

java.lang.Object
com.dtflys.forest.interceptor.InterceptorChain
所有已实现的接口:
OnCanceled, OnError, OnLoadCookie, OnProgress, OnRedirection, OnRetry, OnSaveCookie, OnSuccess, Interceptor

public class InterceptorChain extends Object implements Interceptor
拦截器调用链
从以下版本开始:
2017-05-12 18:30
作者:
gongjun[jun.gong@thebeastshop.com]
  • 构造器详细资料

    • InterceptorChain

      public InterceptorChain()
  • 方法详细资料

    • addInterceptor

      public InterceptorChain addInterceptor(Interceptor interceptor)
    • getInterceptorSize

      public int getInterceptorSize()
    • onInvokeMethod

      public void onInvokeMethod(ForestRequest request, ForestMethod method, Object[] args)
      从接口复制的说明: Interceptor
      默认回调函数: 接口方法执行时调用该方法

      默认为什么都不做

      指定者:
      onInvokeMethod 在接口中 Interceptor
      参数:
      request - Forest请求对象
      method - Forest方法对象
      args - 方法调用入参数组
    • beforeExecute

      public boolean beforeExecute(ForestRequest request)
      从接口复制的说明: Interceptor
      默认回调函数: 请求执行前调用该方法

      其返回值为布尔类型,可以控制请求是否继续执行

      默认为什么都不做

      指定者:
      beforeExecute 在接口中 Interceptor
      参数:
      request - Forest请求对象
      返回:
      true: 继续执行该请求, 否则中断请求
    • onBodyEncode

      public byte[] onBodyEncode(ForestRequest request, ForestEncoder encoder, byte[] encodedData)
      从接口复制的说明: Interceptor
      在请求体数据序列化后,发送请求数据前调用该方法

      默认为什么都不做

      注: mutlipart/data类型的文件上传格式的 Body 数据不会调用该回调函数

      指定者:
      onBodyEncode 在接口中 Interceptor
      参数:
      request - Forest请求对象
      encoder - Forest转换器
      encodedData - 序列化后的请求体数据
    • onSuccess

      public void onSuccess(Object data, ForestRequest request, ForestResponse response)
      从接口复制的说明: Interceptor
      默认回调函数: 请求成功后调用该方法

      默认为什么都不做

      指定者:
      onSuccess 在接口中 Interceptor
      指定者:
      onSuccess 在接口中 OnSuccess
      参数:
      data - 请求响应返回后经过序列化后的数据
      request - Forest请求对象
      response - Forest响应对象
    • onRetry

      public void onRetry(ForestRequest request, ForestResponse response)
      从接口复制的说明: Interceptor
      默认回调函数: 在触发请求重试时执行

      默认为什么都不做

      指定者:
      onRetry 在接口中 Interceptor
      指定者:
      onRetry 在接口中 OnRetry
      参数:
      request - Forest请求对象
      response - Forest响应对象
    • onError

      public void onError(ForestRuntimeException ex, ForestRequest request, ForestResponse response)
      从接口复制的说明: Interceptor
      默认回调函数: 请求失败后调用该方法

      默认为什么都不做

      指定者:
      onError 在接口中 Interceptor
      指定者:
      onError 在接口中 OnError
      参数:
      ex - 请求失败的异常对象
      request - Forest请求对象
      response - Forest响应对象
    • onCanceled

      public void onCanceled(ForestRequest request, ForestResponse response)
      从接口复制的说明: Interceptor
      默认回调函数: 请求取消后调用该方法

      默认为什么都不做

      指定者:
      onCanceled 在接口中 Interceptor
      指定者:
      onCanceled 在接口中 OnCanceled
      参数:
      request - Forest请求对象
      response - Forest响应对象
    • onRedirection

      public void onRedirection(ForestRequest redirectReq, ForestRequest prevReq, ForestResponse prevRes)
      从接口复制的说明: Interceptor
      默认回调函数:在请求重定向时触发

      默认为什么都不做

      指定者:
      onRedirection 在接口中 Interceptor
      指定者:
      onRedirection 在接口中 OnRedirection
      参数:
      redirectReq - 进行重定向的新请求
      prevReq - 上一个请求
      prevRes - 上一个请求的响应
    • onProgress

      public void onProgress(ForestProgress progress)
      从接口复制的说明: Interceptor
      默认文件上传或下载监听传输进度时调用该方法

      默认为什么都不做

      指定者:
      onProgress 在接口中 Interceptor
      指定者:
      onProgress 在接口中 OnProgress
      参数:
      progress - Forest进度对象
    • onLoadCookie

      public void onLoadCookie(ForestRequest request, ForestCookies cookies)
      从接口复制的说明: Interceptor
      默认回调函数: 在发送请求加载Cookie时调用该方法

      默认为什么都不做

      指定者:
      onLoadCookie 在接口中 Interceptor
      指定者:
      onLoadCookie 在接口中 OnLoadCookie
      参数:
      request - Forest请求对象
      cookies - Cookie集合, 需要通过请求发送的Cookie都添加到该集合
    • onSaveCookie

      public void onSaveCookie(ForestRequest request, ForestCookies cookies)
      从接口复制的说明: Interceptor
      默认回调函数: 在请求响应成功后,需要保存Cookie时调用该方法

      默认为什么都不做

      指定者:
      onSaveCookie 在接口中 Interceptor
      指定者:
      onSaveCookie 在接口中 OnSaveCookie
      参数:
      request - Forest请求对象
      cookies - Cookie集合,通过响应返回的Cookie都从该集合获取
    • afterExecute

      public void afterExecute(ForestRequest request, ForestResponse response)
      从接口复制的说明: Interceptor
      默认回调函数: 请求完成后(成功/失败后) 调用该方法

      默认为什么都不做

      指定者:
      afterExecute 在接口中 Interceptor
      参数:
      request - Forest请求对象
      response - Forest响应对象