mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-12 00:24:19 +08:00
增加注释
This commit is contained in:
@@ -43,18 +43,32 @@ import java.util.concurrent.Future;
|
||||
*/
|
||||
public class PayMessageRouter {
|
||||
|
||||
protected final Log log = LogFactory.getLog(PayMessageRouter.class);
|
||||
|
||||
protected final Log LOG = LogFactory.getLog(PayMessageRouter.class);
|
||||
/**
|
||||
* 异步线程大小
|
||||
*/
|
||||
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
|
||||
|
||||
/**
|
||||
* 规则集
|
||||
*/
|
||||
private final List<PayMessageRouterRule> rules = new ArrayList<PayMessageRouterRule>();
|
||||
|
||||
/**
|
||||
* 支付服务
|
||||
*/
|
||||
private final PayService payService;
|
||||
|
||||
/**
|
||||
* 异步线程处理器
|
||||
*/
|
||||
private ExecutorService executorService;
|
||||
|
||||
/**
|
||||
* 支付异常处理器
|
||||
*/
|
||||
private PayErrorExceptionHandler exceptionHandler;
|
||||
|
||||
/**
|
||||
* 根据支付服务创建路由
|
||||
* @param payService 支付服务
|
||||
*/
|
||||
public PayMessageRouter(PayService payService) {
|
||||
this.payService = payService;
|
||||
this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
|
||||
@@ -138,7 +152,7 @@ public class PayMessageRouter {
|
||||
} else {
|
||||
res = rule.service(payMessage, payService, exceptionHandler);
|
||||
// 在同步操作结束,session访问结束
|
||||
log.debug("End session access: async=false, fromPay=" + payMessage.getFromPay());
|
||||
LOG.debug("End session access: async=false, fromPay=" + payMessage.getFromPay());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,12 +163,12 @@ public class PayMessageRouter {
|
||||
for (Future future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
log.debug("End session access: async=true, fromPay=" + payMessage.getFromPay());
|
||||
LOG.debug("End session access: async=true, fromPay=" + payMessage.getFromPay());
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Error happened when wait task finish", e);
|
||||
LOG.error("Error happened when wait task finish", e);
|
||||
} catch (ExecutionException e) {
|
||||
log.error("Error happened when wait task finish", e);
|
||||
LOG.error("Error happened when wait task finish", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,11 +153,11 @@ public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase impleme
|
||||
entity.writeTo((OutputStream)t);
|
||||
return t;
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayErrorException(new PayException("InstantiationException", e.getMessage()));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayErrorException(new PayException("IllegalAccessException", e.getMessage()));
|
||||
}
|
||||
throw new HttpResponseException(statusLine.getStatusCode(), responseType + " 无法进行类型转换");
|
||||
|
||||
}
|
||||
}
|
||||
String charset = "UTF-8";
|
||||
@@ -174,7 +174,7 @@ public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase impleme
|
||||
try {
|
||||
return JSON.parseObject(result, responseType);
|
||||
}catch (JSONException e){
|
||||
throw new PayErrorException(new PayException("failure", "类型转化异常,contentType:" + entity.getContentType().getValue(), result));
|
||||
throw new PayErrorException(new PayException("failure", String.format("类型转化异常,contentType: %s\n%s", entity.getContentType().getValue(), e.getMessage() ), result));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.egzosn.pay.common.util;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMException;
|
||||
@@ -38,9 +40,9 @@ public class XML {
|
||||
try (InputStream in = new ByteArrayInputStream(content.getBytes("UTF-8"))){
|
||||
return (JSONObject) inputStream2Map(in, null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayErrorException(new PayException("IOException", e.getMessage()));
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -58,9 +60,8 @@ public class XML {
|
||||
try {
|
||||
return (JSONObject)inputStream2Map(in, null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayErrorException(new PayException("IOException", e.getMessage()));
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public class XML {
|
||||
m.put(k, v);
|
||||
}
|
||||
} catch (JDOMException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayErrorException(new PayException("JDOMException", e.getMessage()));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user