@@ -4,5 +4,5 @@ package me.chanjar.weixin.common.util.http; | |||||
* Created by ecoolper on 2017/4/28. | * Created by ecoolper on 2017/4/28. | ||||
*/ | */ | ||||
public enum HttpType { | public enum HttpType { | ||||
joddHttp, apacheHttp, okHttp; | |||||
JODD_HTTP, APACHE_HTTP, OK_HTTP; | |||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package me.chanjar.weixin.common.util.http; | package me.chanjar.weixin.common.util.http; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddMediaDownloadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkMediaDownloadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaDownloadRequestExecutor; | |||||
import java.io.File; | import java.io.File; | ||||
@@ -22,12 +22,12 @@ public abstract class MediaDownloadRequestExecutor<H, P> implements RequestExecu | |||||
public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) { | public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | return new ApacheMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | ||||
case joddHttp: | |||||
return new JoddMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | |||||
case okHttp: | |||||
return new OkMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | |||||
case JODD_HTTP: | |||||
return new JoddHttpMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | |||||
case OK_HTTP: | |||||
return new OkHttpMediaDownloadRequestExecutor(requestHttp, tmpDirFile); | |||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
@@ -2,8 +2,8 @@ package me.chanjar.weixin.common.util.http; | |||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddMediaUploadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkMediaUploadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaUploadRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaUploadRequestExecutor; | |||||
import java.io.File; | import java.io.File; | ||||
@@ -21,12 +21,12 @@ public abstract class MediaUploadRequestExecutor<H, P> implements RequestExecuto | |||||
public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMediaUploadRequestExecutor(requestHttp); | return new ApacheMediaUploadRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
return new JoddMediaUploadRequestExecutor(requestHttp); | |||||
case okHttp: | |||||
return new OkMediaUploadRequestExecutor(requestHttp); | |||||
case JODD_HTTP: | |||||
return new JoddHttpMediaUploadRequestExecutor(requestHttp); | |||||
case OK_HTTP: | |||||
return new OkHttpMediaUploadRequestExecutor(requestHttp); | |||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
@@ -54,6 +54,6 @@ public interface RequestExecutor<T, E> { | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @throws IOException | * @throws IOException | ||||
*//* | *//* | ||||
T executeOkhttp(ConnectionPool pool, final OkhttpProxyInfo proxyInfo, String uri, E data) throws WxErrorException, IOException; | |||||
T executeOkhttp(ConnectionPool pool, final OkHttpProxyInfo proxyInfo, String uri, E data) throws WxErrorException, IOException; | |||||
*/ | */ | ||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package me.chanjar.weixin.common.util.http; | package me.chanjar.weixin.common.util.http; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheSimpleGetRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.jodd.JoddSimpleGetRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkSimpleGetRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientSimpleGetRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimpleGetRequestExecutor; | |||||
/** | /** | ||||
* 简单的GET请求执行器,请求的参数是String, 返回的结果也是String | * 简单的GET请求执行器,请求的参数是String, 返回的结果也是String | ||||
@@ -19,12 +19,12 @@ public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor< | |||||
public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
return new ApacheSimpleGetRequestExecutor(requestHttp); | |||||
case joddHttp: | |||||
return new JoddSimpleGetRequestExecutor(requestHttp); | |||||
case okHttp: | |||||
return new OkSimpleGetRequestExecutor(requestHttp); | |||||
case APACHE_HTTP: | |||||
return new ApacheHttpClientSimpleGetRequestExecutor(requestHttp); | |||||
case JODD_HTTP: | |||||
return new JoddHttpSimpleGetRequestExecutor(requestHttp); | |||||
case OK_HTTP: | |||||
return new OkHttpSimpleGetRequestExecutor(requestHttp); | |||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
@@ -1,8 +1,8 @@ | |||||
package me.chanjar.weixin.common.util.http; | package me.chanjar.weixin.common.util.http; | ||||
import me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor; | import me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor; | ||||
import me.chanjar.weixin.common.util.http.jodd.JoddSimplePostRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkSimplePostRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimplePostRequestExecutor; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimplePostRequestExecutor; | |||||
/** | /** | ||||
* 用装饰模式实现 | * 用装饰模式实现 | ||||
@@ -19,12 +19,12 @@ public abstract class SimplePostRequestExecutor<H, P> implements RequestExecutor | |||||
public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | public static RequestExecutor<String, String> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheSimplePostRequestExecutor(requestHttp); | return new ApacheSimplePostRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
return new JoddSimplePostRequestExecutor(requestHttp); | |||||
case okHttp: | |||||
return new OkSimplePostRequestExecutor(requestHttp); | |||||
case JODD_HTTP: | |||||
return new JoddHttpSimplePostRequestExecutor(requestHttp); | |||||
case OK_HTTP: | |||||
return new OkHttpSimplePostRequestExecutor(requestHttp); | |||||
default: | default: | ||||
return null; | return null; | ||||
} | } | ||||
@@ -15,9 +15,9 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | * Created by ecoolper on 2017/5/4. | ||||
*/ | */ | ||||
public class ApacheSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> { | |||||
public class ApacheHttpClientSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> { | |||||
public ApacheSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
public ApacheHttpClientSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -23,10 +23,10 @@ import java.util.regex.Pattern; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class JoddMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public class JoddHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public JoddMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | |||||
public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | |||||
super(requestHttp, tmpDirFile); | super(requestHttp, tmpDirFile); | ||||
} | } | ||||
@@ -18,8 +18,8 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class JoddMediaUploadRequestExecutor extends MediaUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public JoddMediaUploadRequestExecutor(RequestHttp requestHttp) { | |||||
public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public JoddHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -13,9 +13,9 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | * Created by ecoolper on 2017/5/4. | ||||
*/ | */ | ||||
public class JoddSimpleGetRequestExecutor extends SimpleGetRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public JoddSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
public JoddHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -16,9 +16,9 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | * Created by ecoolper on 2017/5/4. | ||||
*/ | */ | ||||
public class JoddSimplePostRequestExecutor extends SimplePostRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<HttpConnectionProvider, ProxyInfo> { | |||||
public JoddSimplePostRequestExecutor(RequestHttp requestHttp) { | |||||
public JoddHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -18,10 +18,10 @@ import java.util.regex.Pattern; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | |||||
public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | |||||
super(requestHttp, tmpDirFile); | super(requestHttp, tmpDirFile); | ||||
} | } | ||||
@@ -13,9 +13,9 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkMediaUploadRequestExecutor extends MediaUploadRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkMediaUploadRequestExecutor(RequestHttp requestHttp) { | |||||
public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -7,13 +7,13 @@ import java.net.Proxy; | |||||
* Created by ecoolper on 2017/4/26. | * Created by ecoolper on 2017/4/26. | ||||
* Proxy information. | * Proxy information. | ||||
*/ | */ | ||||
public class OkhttpProxyInfo { | |||||
public class OkHttpProxyInfo { | |||||
private final String proxyAddress; | private final String proxyAddress; | ||||
private final int proxyPort; | private final int proxyPort; | ||||
private final String proxyUsername; | private final String proxyUsername; | ||||
private final String proxyPassword; | private final String proxyPassword; | ||||
private final ProxyType proxyType; | private final ProxyType proxyType; | ||||
public OkhttpProxyInfo(ProxyType proxyType, String proxyHost, int proxyPort, String proxyUser, String proxyPassword) { | |||||
public OkHttpProxyInfo(ProxyType proxyType, String proxyHost, int proxyPort, String proxyUser, String proxyPassword) { | |||||
this.proxyType = proxyType; | this.proxyType = proxyType; | ||||
this.proxyAddress = proxyHost; | this.proxyAddress = proxyHost; | ||||
this.proxyPort = proxyPort; | this.proxyPort = proxyPort; | ||||
@@ -24,8 +24,8 @@ public class OkhttpProxyInfo { | |||||
/** | /** | ||||
* Creates directProxy. | * Creates directProxy. | ||||
*/ | */ | ||||
public static OkhttpProxyInfo directProxy() { | |||||
return new OkhttpProxyInfo(ProxyType.NONE, null, 0, null, null); | |||||
public static OkHttpProxyInfo directProxy() { | |||||
return new OkHttpProxyInfo(ProxyType.NONE, null, 0, null, null); | |||||
} | } | ||||
// ---------------------------------------------------------------- factory | // ---------------------------------------------------------------- factory | ||||
@@ -33,22 +33,22 @@ public class OkhttpProxyInfo { | |||||
/** | /** | ||||
* Creates SOCKS4 proxy. | * Creates SOCKS4 proxy. | ||||
*/ | */ | ||||
public static OkhttpProxyInfo socks4Proxy(String proxyAddress, int proxyPort, String proxyUser) { | |||||
return new OkhttpProxyInfo(ProxyType.SOCKS4, proxyAddress, proxyPort, proxyUser, null); | |||||
public static OkHttpProxyInfo socks4Proxy(String proxyAddress, int proxyPort, String proxyUser) { | |||||
return new OkHttpProxyInfo(ProxyType.SOCKS4, proxyAddress, proxyPort, proxyUser, null); | |||||
} | } | ||||
/** | /** | ||||
* Creates SOCKS5 proxy. | * Creates SOCKS5 proxy. | ||||
*/ | */ | ||||
public static OkhttpProxyInfo socks5Proxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) { | |||||
return new OkhttpProxyInfo(ProxyType.SOCKS5, proxyAddress, proxyPort, proxyUser, proxyPassword); | |||||
public static OkHttpProxyInfo socks5Proxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) { | |||||
return new OkHttpProxyInfo(ProxyType.SOCKS5, proxyAddress, proxyPort, proxyUser, proxyPassword); | |||||
} | } | ||||
/** | /** | ||||
* Creates HTTP proxy. | * Creates HTTP proxy. | ||||
*/ | */ | ||||
public static OkhttpProxyInfo httpProxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) { | |||||
return new OkhttpProxyInfo(ProxyType.HTTP, proxyAddress, proxyPort, proxyUser, proxyPassword); | |||||
public static OkHttpProxyInfo httpProxy(String proxyAddress, int proxyPort, String proxyUser, String proxyPassword) { | |||||
return new OkHttpProxyInfo(ProxyType.HTTP, proxyAddress, proxyPort, proxyUser, proxyPassword); | |||||
} | } | ||||
/** | /** |
@@ -11,9 +11,9 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | * Created by ecoolper on 2017/5/4. | ||||
*/ | */ | ||||
public class OkSimpleGetRequestExecutor extends SimpleGetRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -11,16 +11,16 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/4. | * Created by ecoolper on 2017/5/4. | ||||
*/ | */ | ||||
public class OkSimplePostRequestExecutor extends SimplePostRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkSimplePostRequestExecutor(RequestHttp requestHttp) { | |||||
public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { | |||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@Override | @Override | ||||
public String execute(String uri, String postEntity) throws WxErrorException, IOException { | public String execute(String uri, String postEntity) throws WxErrorException, IOException { | ||||
ConnectionPool pool = requestHttp.getRequestHttpClient(); | ConnectionPool pool = requestHttp.getRequestHttpClient(); | ||||
final OkhttpProxyInfo proxyInfo = requestHttp.getRequestHttpProxy(); | |||||
final OkHttpProxyInfo proxyInfo = requestHttp.getRequestHttpProxy(); | |||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(pool); | OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(pool); | ||||
//设置代理 | //设置代理 |
@@ -1,4 +1,4 @@ | |||||
package me.chanjar.weixin.cp.api.impl.apache; | |||||
package me.chanjar.weixin.cp.api.impl; | |||||
import me.chanjar.weixin.common.bean.WxAccessToken; | import me.chanjar.weixin.common.bean.WxAccessToken; | ||||
@@ -18,7 +18,7 @@ import org.apache.http.impl.client.CloseableHttpClient; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
public class WxCpServiceImpl extends AbstractWxCpServiceImpl<CloseableHttpClient, HttpHost> { | |||||
public class WxCpServiceApacheHttpClientImpl extends AbstractWxCpServiceImpl<CloseableHttpClient, HttpHost> { | |||||
protected CloseableHttpClient httpClient; | protected CloseableHttpClient httpClient; | ||||
protected HttpHost httpProxy; | protected HttpHost httpProxy; | ||||
@@ -34,7 +34,7 @@ public class WxCpServiceImpl extends AbstractWxCpServiceImpl<CloseableHttpClient | |||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.apacheHttp; | |||||
return HttpType.APACHE_HTTP; | |||||
} | } | ||||
@Override | @Override |
@@ -7,5 +7,5 @@ package me.chanjar.weixin.cp.api.impl; | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
public class WxCpServiceImpl extends me.chanjar.weixin.cp.api.impl.apache.WxCpServiceImpl{ | |||||
public class WxCpServiceImpl extends WxCpServiceApacheHttpClientImpl { | |||||
} | } |
@@ -1,4 +1,4 @@ | |||||
package me.chanjar.weixin.cp.api.impl.jodd; | |||||
package me.chanjar.weixin.cp.api.impl; | |||||
import jodd.http.*; | import jodd.http.*; | ||||
import me.chanjar.weixin.common.bean.WxAccessToken; | import me.chanjar.weixin.common.bean.WxAccessToken; | ||||
@@ -8,7 +8,7 @@ import me.chanjar.weixin.common.util.http.HttpType; | |||||
import me.chanjar.weixin.cp.api.WxCpConfigStorage; | import me.chanjar.weixin.cp.api.WxCpConfigStorage; | ||||
import me.chanjar.weixin.cp.api.impl.AbstractWxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.AbstractWxCpServiceImpl; | ||||
public class WxCpServiceImpl extends AbstractWxCpServiceImpl<HttpConnectionProvider, ProxyInfo> { | |||||
public class WxCpServiceJoddHttpImpl extends AbstractWxCpServiceImpl<HttpConnectionProvider, ProxyInfo> { | |||||
protected HttpConnectionProvider httpClient; | protected HttpConnectionProvider httpClient; | ||||
protected ProxyInfo httpProxy; | protected ProxyInfo httpProxy; | ||||
@@ -25,7 +25,7 @@ public class WxCpServiceImpl extends AbstractWxCpServiceImpl<HttpConnectionProvi | |||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.joddHttp; | |||||
return HttpType.JODD_HTTP; | |||||
} | } | ||||
@Override | @Override |
@@ -1,19 +1,19 @@ | |||||
package me.chanjar.weixin.cp.api.impl.okhttp; | |||||
package me.chanjar.weixin.cp.api.impl; | |||||
import me.chanjar.weixin.common.bean.WxAccessToken; | import me.chanjar.weixin.common.bean.WxAccessToken; | ||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.HttpType; | import me.chanjar.weixin.common.util.http.HttpType; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.cp.api.WxCpConfigStorage; | import me.chanjar.weixin.cp.api.WxCpConfigStorage; | ||||
import me.chanjar.weixin.cp.api.impl.AbstractWxCpServiceImpl; | import me.chanjar.weixin.cp.api.impl.AbstractWxCpServiceImpl; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
public class WxCpServiceImpl extends AbstractWxCpServiceImpl<ConnectionPool, OkhttpProxyInfo> { | |||||
public class WxCpServiceOkHttpImpl extends AbstractWxCpServiceImpl<ConnectionPool, OkHttpProxyInfo> { | |||||
protected ConnectionPool httpClient; | protected ConnectionPool httpClient; | ||||
protected OkhttpProxyInfo httpProxy; | |||||
protected OkHttpProxyInfo httpProxy; | |||||
@Override | @Override | ||||
@@ -22,13 +22,13 @@ public class WxCpServiceImpl extends AbstractWxCpServiceImpl<ConnectionPool, Okh | |||||
} | } | ||||
@Override | @Override | ||||
public OkhttpProxyInfo getRequestHttpProxy() { | |||||
public OkHttpProxyInfo getRequestHttpProxy() { | |||||
return httpProxy; | return httpProxy; | ||||
} | } | ||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.okHttp; | |||||
return HttpType.OK_HTTP; | |||||
} | } | ||||
@Override | @Override | ||||
@@ -92,7 +92,7 @@ public class WxCpServiceImpl extends AbstractWxCpServiceImpl<ConnectionPool, Okh | |||||
WxCpConfigStorage configStorage = this.configStorage; | WxCpConfigStorage configStorage = this.configStorage; | ||||
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { | if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { | ||||
httpProxy = new OkhttpProxyInfo(OkhttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||||
httpProxy = new OkHttpProxyInfo(OkHttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||||
} | } | ||||
httpClient = new ConnectionPool(); | httpClient = new ConnectionPool(); |
@@ -1,4 +1,4 @@ | |||||
package me.chanjar.weixin.mp.api.impl.apache; | |||||
package me.chanjar.weixin.mp.api.impl; | |||||
import me.chanjar.weixin.common.bean.WxAccessToken; | import me.chanjar.weixin.common.bean.WxAccessToken; | ||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
@@ -9,7 +9,6 @@ import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | ||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage; | import me.chanjar.weixin.mp.api.WxMpConfigStorage; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl; | |||||
import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||
import org.apache.http.client.methods.CloseableHttpResponse; | import org.apache.http.client.methods.CloseableHttpResponse; | ||||
@@ -23,7 +22,7 @@ import java.util.concurrent.locks.Lock; | |||||
/** | /** | ||||
* apache-http方式实现 | * apache-http方式实现 | ||||
*/ | */ | ||||
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<CloseableHttpClient, HttpHost> { | |||||
public class WxMpServiceApacheHttpClientImpl extends AbstractWxMpServiceImpl<CloseableHttpClient, HttpHost> { | |||||
private CloseableHttpClient httpClient; | private CloseableHttpClient httpClient; | ||||
private HttpHost httpProxy; | private HttpHost httpProxy; | ||||
@@ -39,7 +38,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<CloseableHttpClient | |||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.apacheHttp; | |||||
return HttpType.APACHE_HTTP; | |||||
} | } | ||||
@Override | @Override |
@@ -7,5 +7,5 @@ package me.chanjar.weixin.mp.api.impl; | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
public class WxMpServiceImpl extends me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl{ | |||||
public class WxMpServiceImpl extends WxMpServiceApacheHttpClientImpl { | |||||
} | } |
@@ -1,4 +1,4 @@ | |||||
package me.chanjar.weixin.mp.api.impl.jodd; | |||||
package me.chanjar.weixin.mp.api.impl; | |||||
import jodd.http.*; | import jodd.http.*; | ||||
import jodd.http.net.SocketHttpConnectionProvider; | import jodd.http.net.SocketHttpConnectionProvider; | ||||
@@ -9,14 +9,13 @@ import me.chanjar.weixin.common.util.http.HttpType; | |||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage; | import me.chanjar.weixin.mp.api.WxMpConfigStorage; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl; | |||||
import java.util.concurrent.locks.Lock; | import java.util.concurrent.locks.Lock; | ||||
/** | /** | ||||
* jodd-http方式实现 | * jodd-http方式实现 | ||||
*/ | */ | ||||
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<HttpConnectionProvider, ProxyInfo> { | |||||
public class WxMpServiceJoddHttpImpl extends AbstractWxMpServiceImpl<HttpConnectionProvider, ProxyInfo> { | |||||
private HttpConnectionProvider httpClient; | private HttpConnectionProvider httpClient; | ||||
private ProxyInfo httpProxy; | private ProxyInfo httpProxy; | ||||
@@ -32,7 +31,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<HttpConnectionProvi | |||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.joddHttp; | |||||
return HttpType.JODD_HTTP; | |||||
} | } | ||||
@Override | @Override |
@@ -1,22 +1,21 @@ | |||||
package me.chanjar.weixin.mp.api.impl.okhttp; | |||||
package me.chanjar.weixin.mp.api.impl; | |||||
import me.chanjar.weixin.common.bean.WxAccessToken; | import me.chanjar.weixin.common.bean.WxAccessToken; | ||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.HttpType; | import me.chanjar.weixin.common.util.http.HttpType; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage; | import me.chanjar.weixin.mp.api.WxMpConfigStorage; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl; | |||||
import okhttp3.*; | import okhttp3.*; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.concurrent.locks.Lock; | import java.util.concurrent.locks.Lock; | ||||
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, OkhttpProxyInfo> { | |||||
public class WxMpServiceOkHttpImpl extends AbstractWxMpServiceImpl<ConnectionPool, OkHttpProxyInfo> { | |||||
private ConnectionPool httpClient; | private ConnectionPool httpClient; | ||||
private OkhttpProxyInfo httpProxy; | |||||
private OkHttpProxyInfo httpProxy; | |||||
@Override | @Override | ||||
public ConnectionPool getRequestHttpClient() { | public ConnectionPool getRequestHttpClient() { | ||||
@@ -24,13 +23,13 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, Okh | |||||
} | } | ||||
@Override | @Override | ||||
public OkhttpProxyInfo getRequestHttpProxy() { | |||||
public OkHttpProxyInfo getRequestHttpProxy() { | |||||
return httpProxy; | return httpProxy; | ||||
} | } | ||||
@Override | @Override | ||||
public HttpType getRequestType() { | public HttpType getRequestType() { | ||||
return HttpType.okHttp; | |||||
return HttpType.OK_HTTP; | |||||
} | } | ||||
@Override | @Override | ||||
@@ -89,7 +88,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, Okh | |||||
WxMpConfigStorage configStorage = this.getWxMpConfigStorage(); | WxMpConfigStorage configStorage = this.getWxMpConfigStorage(); | ||||
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { | if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { | ||||
httpProxy = new OkhttpProxyInfo(OkhttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||||
httpProxy = new OkHttpProxyInfo(OkHttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); | |||||
} | } | ||||
httpClient = new ConnectionPool(); | httpClient = new ConnectionPool(); |
@@ -15,11 +15,11 @@ public abstract class MaterialDeleteRequestExecutor<H, P> implements RequestExec | |||||
public static RequestExecutor<Boolean, String> create(RequestHttp requestHttp) { | public static RequestExecutor<Boolean, String> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMaterialDeleteRequestExecutor(requestHttp); | return new ApacheMaterialDeleteRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMaterialDeleteRequestExecutor(requestHttp); | return new JoddMaterialDeleteRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMaterialDeleteRequestExecutor(requestHttp); | return new OkhttpMaterialDeleteRequestExecutor(requestHttp); | ||||
default: | default: | ||||
return null; | return null; | ||||
@@ -16,11 +16,11 @@ public abstract class MaterialNewsInfoRequestExecutor<H, P> implements RequestEx | |||||
public static RequestExecutor<WxMpMaterialNews, String> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialNews, String> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMaterialNewsInfoRequestExecutor(requestHttp); | return new ApacheMaterialNewsInfoRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMaterialNewsInfoRequestExecutor(requestHttp); | return new JoddMaterialNewsInfoRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMaterialNewsInfoRequestExecutor(requestHttp); | return new OkhttpMaterialNewsInfoRequestExecutor(requestHttp); | ||||
default: | default: | ||||
//TODO 需要优化抛出异常 | //TODO 需要优化抛出异常 | ||||
@@ -17,11 +17,11 @@ public abstract class MaterialUploadRequestExecutor<H, P> implements RequestExec | |||||
public static RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMaterialUploadRequestExecutor(requestHttp); | return new ApacheMaterialUploadRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMaterialUploadRequestExecutor(requestHttp); | return new JoddMaterialUploadRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMaterialUploadRequestExecutor(requestHttp); | return new OkhttpMaterialUploadRequestExecutor(requestHttp); | ||||
default: | default: | ||||
return null; | return null; | ||||
@@ -19,11 +19,11 @@ public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestE | |||||
public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMaterialVideoInfoRequestExecutor(requestHttp); | return new ApacheMaterialVideoInfoRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMaterialVideoInfoRequestExecutor(requestHttp); | return new JoddMaterialVideoInfoRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp); | return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp); | ||||
default: | default: | ||||
return null; | return null; | ||||
@@ -22,11 +22,11 @@ public abstract class MaterialVoiceAndImageDownloadRequestExecutor<H, P> impleme | |||||
public static RequestExecutor<InputStream, String> create(RequestHttp requestHttp, File tmpDirFile) { | public static RequestExecutor<InputStream, String> create(RequestHttp requestHttp, File tmpDirFile) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | return new ApacheMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | return new JoddMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | return new OkhttpMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile); | ||||
default: | default: | ||||
return null; | return null; | ||||
@@ -21,11 +21,11 @@ public abstract class MediaImgUploadRequestExecutor<H, P> implements RequestExec | |||||
public static RequestExecutor<WxMediaImgUploadResult, File> create(RequestHttp requestHttp) { | public static RequestExecutor<WxMediaImgUploadResult, File> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheMediaImgUploadRequestExecutor(requestHttp); | return new ApacheMediaImgUploadRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddMediaImgUploadRequestExecutor(requestHttp); | return new JoddMediaImgUploadRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpMediaImgUploadRequestExecutor(requestHttp); | return new OkhttpMediaImgUploadRequestExecutor(requestHttp); | ||||
default: | default: | ||||
return null; | return null; | ||||
@@ -23,11 +23,11 @@ public abstract class QrCodeRequestExecutor<H, P> implements RequestExecutor<Fil | |||||
public static RequestExecutor<File, WxMpQrCodeTicket> create(RequestHttp requestHttp) { | public static RequestExecutor<File, WxMpQrCodeTicket> create(RequestHttp requestHttp) { | ||||
switch (requestHttp.getRequestType()) { | switch (requestHttp.getRequestType()) { | ||||
case apacheHttp: | |||||
case APACHE_HTTP: | |||||
return new ApacheQrCodeRequestExecutor(requestHttp); | return new ApacheQrCodeRequestExecutor(requestHttp); | ||||
case joddHttp: | |||||
case JODD_HTTP: | |||||
return new JoddQrCodeRequestExecutor(requestHttp); | return new JoddQrCodeRequestExecutor(requestHttp); | ||||
case okHttp: | |||||
case OK_HTTP: | |||||
return new OkhttpQrCodeRequestExecutor(requestHttp); | return new OkhttpQrCodeRequestExecutor(requestHttp); | ||||
default: | default: | ||||
//TODO 需要优化,最好抛出异常 | //TODO 需要优化,最好抛出异常 | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.util.http.MaterialDeleteRequestExecutor; | import me.chanjar.weixin.mp.util.http.MaterialDeleteRequestExecutor; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
@@ -12,7 +12,7 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMaterialDeleteRequestExecutor extends MaterialDeleteRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMaterialDeleteRequestExecutor extends MaterialDeleteRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMaterialDeleteRequestExecutor(RequestHttp requestHttp) { | public OkhttpMaterialDeleteRequestExecutor(RequestHttp requestHttp) { | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; | ||||
import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; | import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; | ||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
@@ -14,7 +14,7 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { | public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | import me.chanjar.weixin.mp.bean.material.WxMpMaterial; | ||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | ||||
@@ -18,7 +18,7 @@ import java.util.Map; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMaterialUploadRequestExecutor extends MaterialUploadRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMaterialUploadRequestExecutor extends MaterialUploadRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMaterialUploadRequestExecutor(RequestHttp requestHttp) { | public OkhttpMaterialUploadRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | ||||
import me.chanjar.weixin.mp.util.http.MaterialVideoInfoRequestExecutor; | import me.chanjar.weixin.mp.util.http.MaterialVideoInfoRequestExecutor; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
@@ -13,7 +13,7 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMaterialVideoInfoRequestExecutor extends MaterialVideoInfoRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMaterialVideoInfoRequestExecutor extends MaterialVideoInfoRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMaterialVideoInfoRequestExecutor(RequestHttp requestHttp) { | public OkhttpMaterialVideoInfoRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
import me.chanjar.weixin.mp.util.http.MaterialVoiceAndImageDownloadRequestExecutor; | import me.chanjar.weixin.mp.util.http.MaterialVoiceAndImageDownloadRequestExecutor; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
@@ -17,7 +17,7 @@ import java.io.InputStream; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMaterialVoiceAndImageDownloadRequestExecutor extends MaterialVoiceAndImageDownloadRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMaterialVoiceAndImageDownloadRequestExecutor extends MaterialVoiceAndImageDownloadRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMaterialVoiceAndImageDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | public OkhttpMaterialVoiceAndImageDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { | ||||
super(requestHttp, tmpDirFile); | super(requestHttp, tmpDirFile); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.util.http.okhttp; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | ||||
import me.chanjar.weixin.mp.util.http.MediaImgUploadRequestExecutor; | import me.chanjar.weixin.mp.util.http.MediaImgUploadRequestExecutor; | ||||
import okhttp3.*; | import okhttp3.*; | ||||
@@ -14,7 +14,7 @@ import java.io.IOException; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpMediaImgUploadRequestExecutor extends MediaImgUploadRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpMediaImgUploadRequestExecutor extends MediaImgUploadRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpMediaImgUploadRequestExecutor(RequestHttp requestHttp) { | public OkhttpMediaImgUploadRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
@@ -4,7 +4,7 @@ import me.chanjar.weixin.common.bean.result.WxError; | |||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.fs.FileUtils; | import me.chanjar.weixin.common.util.fs.FileUtils; | ||||
import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo; | |||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; | |||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; | import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; | ||||
import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor; | import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor; | ||||
@@ -19,7 +19,7 @@ import java.util.UUID; | |||||
/** | /** | ||||
* Created by ecoolper on 2017/5/5. | * Created by ecoolper on 2017/5/5. | ||||
*/ | */ | ||||
public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor<ConnectionPool, OkhttpProxyInfo> { | |||||
public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor<ConnectionPool, OkHttpProxyInfo> { | |||||
public OkhttpQrCodeRequestExecutor(RequestHttp requestHttp) { | public OkhttpQrCodeRequestExecutor(RequestHttp requestHttp) { | ||||
super(requestHttp); | super(requestHttp); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api; | |||||
import me.chanjar.weixin.common.bean.result.WxError; | import me.chanjar.weixin.common.bean.result.WxError; | ||||
import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
import me.chanjar.weixin.common.util.http.RequestExecutor; | import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl; | |||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl; | |||||
import org.testng.annotations.*; | import org.testng.annotations.*; | ||||
import java.util.concurrent.ExecutionException; | import java.util.concurrent.ExecutionException; | ||||
@@ -16,7 +16,7 @@ public class WxMpBusyRetryTest { | |||||
@DataProvider(name = "getService") | @DataProvider(name = "getService") | ||||
public Object[][] getService() { | public Object[][] getService() { | ||||
WxMpService service = new WxMpServiceImpl() { | |||||
WxMpService service = new WxMpServiceApacheHttpClientImpl() { | |||||
@Override | @Override | ||||
public synchronized <T, E> T executeInternal( | public synchronized <T, E> T executeInternal( | ||||
@@ -6,7 +6,7 @@ import com.thoughtworks.xstream.XStream; | |||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer; | import me.chanjar.weixin.common.util.xml.XStreamInitializer; | ||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage; | import me.chanjar.weixin.mp.api.WxMpConfigStorage; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl; | |||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
@@ -19,7 +19,7 @@ public class ApiTestModule implements Module { | |||||
try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { | try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { | ||||
TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1); | TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1); | ||||
config.setAccessTokenLock(new ReentrantLock()); | config.setAccessTokenLock(new ReentrantLock()); | ||||
WxMpService wxService = new WxMpServiceImpl(); | |||||
WxMpService wxService = new WxMpServiceApacheHttpClientImpl(); | |||||
wxService.setWxMpConfigStorage(config); | wxService.setWxMpConfigStorage(config); | ||||
binder.bind(WxMpService.class).toInstance(wxService); | binder.bind(WxMpService.class).toInstance(wxService); | ||||
@@ -5,7 +5,7 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage; | |||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler; | import me.chanjar.weixin.mp.api.WxMpMessageHandler; | ||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter; | import me.chanjar.weixin.mp.api.WxMpMessageRouter; | ||||
import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl; | |||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl; | |||||
import org.eclipse.jetty.server.Server; | import org.eclipse.jetty.server.Server; | ||||
import org.eclipse.jetty.servlet.ServletHandler; | import org.eclipse.jetty.servlet.ServletHandler; | ||||
import org.eclipse.jetty.servlet.ServletHolder; | import org.eclipse.jetty.servlet.ServletHolder; | ||||
@@ -47,7 +47,7 @@ public class WxMpDemoServer { | |||||
.fromXml(is1); | .fromXml(is1); | ||||
wxMpConfigStorage = config; | wxMpConfigStorage = config; | ||||
wxMpService = new WxMpServiceImpl(); | |||||
wxMpService = new WxMpServiceApacheHttpClientImpl(); | |||||
wxMpService.setWxMpConfigStorage(config); | wxMpService.setWxMpConfigStorage(config); | ||||
WxMpMessageHandler logHandler = new DemoLogHandler(); | WxMpMessageHandler logHandler = new DemoLogHandler(); | ||||