zm
2020-06-16 0ef201ff1697460d9209a3b7b227ebc57d62f04a
commit | author | age
a18bfa 1 package com.changhong.epc.config.datasource;
Z 2
3 import com.codingapi.tx.config.service.TxManagerTxUrlService;
4 import com.codingapi.tx.netty.service.TxManagerHttpRequestService;
5 import com.lorne.core.framework.utils.http.HttpUtils;
6 import lombok.extern.slf4j.Slf4j;
7 import org.springframework.beans.factory.annotation.Value;
8 import org.springframework.context.annotation.Bean;
9 import org.springframework.context.annotation.Configuration;
10
11 @Configuration
12 @Slf4j
13 public class TxManagerConfig {
14
0ef201 15     @Value("${tm.manager.url}")
a18bfa 16     private String url;
Z 17
18     @Bean
19     public TxManagerTxUrlService txManagerTxUrlService(){
20         return ()->url;
21     }
22
23     @Bean
24     public TxManagerHttpRequestService txManagerHttpRequestService(){
25         return new TxManagerHttpRequestService(){
26
27             @Override
28             public String httpGet(String url) {
29                 log.debug("httpGet-start:{}", url);
30                 String res = HttpUtils.get(url);
31                 log.debug("httpGet-end:{}", url);
32                 return res;
33             }
34
35             @Override
36             public String httpPost(String url, String params) {
37                 log.debug("httpPost-start:{}@{}", url, params);
38                 String res = HttpUtils.post(url,params);
39                 log.debug("httpPost-end:{}@{}", url, params);
40                 return res;
41             }
42         };
43     }
44 }