codingapi / tx-lcn

LCN distributed transaction framework, compatible with dubbo, spring cloud and Motan framework, supports various relational databases
https://www.codingapi.com
Apache License 2.0
4.22k stars 1.46k forks source link

通过ek发现TxManager需要重写哪个接口 #41

Closed xlorne closed 5 years ago

xlorne commented 6 years ago
  1. TxManagerHttpRequestService 重写Client发起请求的方式
xlorne commented 6 years ago
@Service
public class TxManagerHttpRequestServiceImpl implements TxManagerHttpRequestService{

    @Override
    public String httpGet(String url) {
        System.out.println("httpGet-start");
        String res = HttpUtils.get(url);
        System.out.println("httpGet-end");
        return res;
    }

    @Override
    public String httpPost(String url, String params) {
        System.out.println("httpPost-start");
        String res = HttpUtils.post(url,params);
        System.out.println("httpPost-end");
        return res;
    }
}
xlorne commented 6 years ago
  1. TxManagerTxUrlService 重写Client获取TxManager配置信息的规则
@Service
public class TxManagerTxUrlServiceImpl implements TxManagerTxUrlService{

    @Value("${tm.manager.url}")
    private String url;

    @Override
    public String getTxUrl() {
        System.out.println("load tm.manager.url ");
        return url;
    }
}
xlorne commented 6 years ago

参看代码: https://github.com/codingapi/springcloud-lcn-demo/tree/master/mybatis-demo/springcloud-mybatis-demo1/src/main/java/com/example/demo/service/impl