com.yuyenews.resolve.ExecuteEasy Maven / Gradle / Ivy
package com.yuyenews.resolve;
import java.lang.reflect.Method;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.yuyenews.base.EasyInters;
import com.yuyenews.core.util.RequestUtil;
import com.yuyenews.easy.server.request.HttpRequest;
import com.yuyenews.easy.server.request.HttpResponse;
import com.yuyenews.resolve.model.EasyMappingModel;
import io.netty.handler.codec.http.HttpMethod;
/**
* 执行器
*
* @author yuye
*
*/
public class ExecuteEasy {
private Logger log = LoggerFactory.getLogger(ExecuteEasy.class);
private static ExecuteEasy executeEasy;
private ExecuteEasy() {
}
public static ExecuteEasy getExecuteEasy() {
if (executeEasy == null) {
executeEasy = new ExecuteEasy();
}
return executeEasy;
}
/**
* 执行controller
* @param easyMappingModel duix
* @param method fangfa
* @param request qingqiu
* @param response xiangying
* @return duix
*/
public Object execute(EasyMappingModel easyMappingModel, HttpMethod method, HttpRequest request, HttpResponse response) {
try {
if(easyMappingModel == null) {
/* 如果请求方式和controller的映射不一致,则提示客户端 */
JSONObject jsonObject = new JSONObject();
jsonObject.put("error_code", 404);
jsonObject.put("error_info", "服务器上没有相应的接口");
return jsonObject;
}
String strMethod = method.name().toString().toLowerCase();
String mathodReuest = easyMappingModel.getRequestMetohd().name().toLowerCase();
if (strMethod.equals(mathodReuest)) {
/* 获取拦截器 并执行 控制层执行前的方法 */
String uriEnd = RequestUtil.getUriName(request);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy