com.codingapi.tx.netty.service.TxManagerHttpRequestHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tx-client Show documentation
Show all versions of tx-client Show documentation
tx-client project for Spring Boot
package com.codingapi.tx.netty.service;
import com.lorne.core.framework.utils.http.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
* create by lorne on 2017/11/17
*/
@Component
public class TxManagerHttpRequestHelper {
private TxManagerHttpRequestService httpRequestService;
@Autowired
private ApplicationContext spring;
private Logger logger = LoggerFactory.getLogger(TxManagerHttpRequestHelper.class);
private void reloadHttpRequestService(){
try {
httpRequestService = spring.getBean(TxManagerHttpRequestService.class);
}catch (Exception e){
logger.error(e.getLocalizedMessage());
}
if(httpRequestService==null){
httpRequestService = new TxManagerHttpRequestService() {
@Override
public String httpGet(String url) {
return HttpUtils.get(url);
}
@Override
public String httpPost(String url, String params) {
return HttpUtils.post(url, params);
}
};
logger.info("load default HttpRequestService .");
}else {
logger.info("load HttpRequestService .");
}
}
public String httpGet(String url) {
reloadHttpRequestService();
return httpRequestService.httpGet(url);
}
public String httpPost(String url, String params) {
reloadHttpRequestService();
return httpRequestService.httpPost(url,params);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy