Merge pull request #70 from dxfeng10/feature/dubbo

Feature/dubbo
This commit is contained in:
dxfeng10
2021-03-04 15:28:43 +08:00
committed by GitHub
5 changed files with 26 additions and 14 deletions

View File

@@ -5,7 +5,10 @@
var common = {
/* *********** private function begin *********** */
// 获取上下文中客户端请求对象
/**
* 获取上下文中客户端请求对象
* @param {*} ctx 上下文 【必填】
*/
getInputReq: function (ctx){
if(!ctx || !ctx['input'] || !ctx['input']['request']){
return {};
@@ -13,7 +16,12 @@ var common = {
return ctx['input']['request']
},
// 获取上下文步骤中请求接口的请求对象
/**
* 获取上下文步骤中请求接口的请求对象
* @param {*} ctx 上下文 【必填】
* @param {*} stepName 步骤名称 【必填】
* @param {*} requestName 请求名称 【必填】
*/
getStepReq: function (ctx, stepName, requestName){
if(!ctx || !stepName || !requestName){
return {};
@@ -25,7 +33,12 @@ var common = {
return ctx[stepName]['requests'][requestName]['request'];
},
// 获取上下文步骤中请求接口的响应对象
/**
* 获取上下文步骤中请求接口的响应对象
* @param {*} ctx 上下文 【必填】
* @param {*} stepName 步骤名称 【必填】
* @param {*} requestName 请求名称 【必填】
*/
getStepResp: function (ctx, stepName, requestName){
if(!ctx || !stepName || !requestName){
return {};

View File

@@ -68,7 +68,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Component
public class ConfigLoader {
@Autowired
public static ConfigurableApplicationContext appContext;
public ConfigurableApplicationContext appContext;
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigLoader.class);
/**

View File

@@ -367,7 +367,7 @@ public class Pipeline {
}
public void setApplicationContext(ConfigurableApplicationContext appContext) {
this.applicationContext = applicationContext;
this.applicationContext = appContext;
}
public ConfigurableApplicationContext getApplicationContext() {

View File

@@ -18,7 +18,6 @@ public class RPCInput extends Input {
protected static final Logger LOGGER = LoggerFactory.getLogger(RPCInput.class.getName());
protected static final String FALLBACK_MODE_STOP = "stop";
protected static final String FALLBACK_MODE_CONTINUE = "continue";
protected Map<String, Object> request = new HashMap<>();
protected Map<String, Object> response = new HashMap<>();

View File

@@ -60,7 +60,6 @@ public class RequestInput extends RPCInput implements IInput{
private InputType type;
protected Map<String, Object> dataMapping;
private static final String CONTENT_TYPE_JSON = "application/json";
private static final String CONTENT_TYPE_XML = "application/xml";
private static final String CONTENT_TYPE_JS = "application/javascript";
@@ -69,7 +68,7 @@ public class RequestInput extends RPCInput implements IInput{
private static final String CONTENT_TYPE = "content-type";
private String respContentType;
public InputType getType() {
return type;
@@ -154,10 +153,11 @@ public class RequestInput extends RPCInput implements IInput{
request.put("url", uriComponents.toUriString());
}
protected void doResponseMapping(InputConfig aConfig, InputContext inputContext, Object responseBody) {
@Override
public void doResponseMapping(InputConfig aConfig, InputContext inputContext, String responseBody) {
RequestInputConfig config = (RequestInputConfig) aConfig;
response.put("body", responseBody);
response.put("body", this.parseBody(this.respContentType, responseBody));
// 数据转换
if (inputContext != null && inputContext.getStepContext() != null) {
@@ -255,8 +255,8 @@ public class RequestInput extends RPCInput implements IInput{
return null;
}
protected void doOnResponseSuccess(ClientResponse cr, long elapsedMillis) {
HttpHeaders httpHeaders = cr.headers().asHttpHeaders();
protected void doOnResponseSuccess(RPCResponse cr, long elapsedMillis) {
HttpHeaders httpHeaders = (HttpHeaders) cr.getHeaders();
Map<String, Object> headers = new HashMap<>();
httpHeaders.forEach((key, value) -> {
if (value.size() > 1) {
@@ -267,6 +267,7 @@ public class RequestInput extends RPCInput implements IInput{
});
headers.put("elapsedTime", elapsedMillis + "ms");
this.response.put("headers", headers);
this.respContentType = httpHeaders.getFirst(CONTENT_TYPE);
inputContext.getStepContext().addElapsedTime(prefix + request.get("url"),
elapsedMillis);
}
@@ -347,5 +348,4 @@ public class RequestInput extends RPCInput implements IInput{
return RequestInputConfig.class;
}
}