Search in sources :

Example 1 with HttpExecutor

use of com.dtflys.forest.backend.HttpExecutor in project forest by dromara.

the class ForestRequest method execute.

/**
 * 执行请求发送过程
 *
 * @param backend HTTP后端,{@link HttpBackend}接口实例
 * @param lifeCycleHandler 生命周期处理器,{@link LifeCycleHandler}接口实例
 * @return 接受到请求响应后,其响应内容反序列化成对象的结果
 */
public Object execute(HttpBackend backend, LifeCycleHandler lifeCycleHandler) {
    setLifeCycleHandler(lifeCycleHandler);
    processRedirectionRequest();
    // 执行 beforeExecute
    if (interceptorChain.beforeExecute(this)) {
        // 从后端HTTP框架创建HTTP请求执行器
        HttpExecutor executor = backend.createExecutor(this, lifeCycleHandler);
        if (executor != null) {
            try {
                // 执行请求,即发生请求到服务端
                executor.execute(lifeCycleHandler);
            } catch (ForestRuntimeException e) {
                throw e;
            } finally {
                executor.close();
            }
        }
    }
    // 返回结果
    return getMethodReturnValue();
}
Also used : HttpExecutor(com.dtflys.forest.backend.HttpExecutor) ForestRuntimeException(com.dtflys.forest.exceptions.ForestRuntimeException)

Aggregations

HttpExecutor (com.dtflys.forest.backend.HttpExecutor)1 ForestRuntimeException (com.dtflys.forest.exceptions.ForestRuntimeException)1