refactor some packages and class files name

This commit is contained in:
Binary Wang
2017-06-10 17:02:14 +08:00
parent c1967bc1f8
commit 26272bb7e5
41 changed files with 130 additions and 133 deletions

View File

@@ -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.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.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -23,7 +22,7 @@ import java.util.concurrent.locks.Lock;
/**
* apache-http方式实现
*/
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<CloseableHttpClient, HttpHost> {
public class WxMpServiceApacheHttpClientImpl extends AbstractWxMpServiceImpl<CloseableHttpClient, HttpHost> {
private CloseableHttpClient httpClient;
private HttpHost httpProxy;
@@ -39,7 +38,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<CloseableHttpClient
@Override
public HttpType getRequestType() {
return HttpType.apacheHttp;
return HttpType.APACHE_HTTP;
}
@Override

View File

@@ -7,5 +7,5 @@ package me.chanjar.weixin.mp.api.impl;
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* </pre>
*/
public class WxMpServiceImpl extends me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl{
public class WxMpServiceImpl extends WxMpServiceApacheHttpClientImpl {
}

View File

@@ -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.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.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl;
import java.util.concurrent.locks.Lock;
/**
* jodd-http方式实现
*/
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<HttpConnectionProvider, ProxyInfo> {
public class WxMpServiceJoddHttpImpl extends AbstractWxMpServiceImpl<HttpConnectionProvider, ProxyInfo> {
private HttpConnectionProvider httpClient;
private ProxyInfo httpProxy;
@@ -32,7 +31,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<HttpConnectionProvi
@Override
public HttpType getRequestType() {
return HttpType.joddHttp;
return HttpType.JODD_HTTP;
}
@Override

View File

@@ -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.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
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.WxMpService;
import me.chanjar.weixin.mp.api.impl.AbstractWxMpServiceImpl;
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.locks.Lock;
public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, OkhttpProxyInfo> {
public class WxMpServiceOkHttpImpl extends AbstractWxMpServiceImpl<ConnectionPool, OkHttpProxyInfo> {
private ConnectionPool httpClient;
private OkhttpProxyInfo httpProxy;
private OkHttpProxyInfo httpProxy;
@Override
public ConnectionPool getRequestHttpClient() {
@@ -24,13 +23,13 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, Okh
}
@Override
public OkhttpProxyInfo getRequestHttpProxy() {
public OkHttpProxyInfo getRequestHttpProxy() {
return httpProxy;
}
@Override
public HttpType getRequestType() {
return HttpType.okHttp;
return HttpType.OK_HTTP;
}
@Override
@@ -89,7 +88,7 @@ public class WxMpServiceImpl extends AbstractWxMpServiceImpl<ConnectionPool, Okh
WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
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();

View File

@@ -15,11 +15,11 @@ public abstract class MaterialDeleteRequestExecutor<H, P> implements RequestExec
public static RequestExecutor<Boolean, String> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMaterialDeleteRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddMaterialDeleteRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpMaterialDeleteRequestExecutor(requestHttp);
default:
return null;

View File

@@ -16,11 +16,11 @@ public abstract class MaterialNewsInfoRequestExecutor<H, P> implements RequestEx
public static RequestExecutor<WxMpMaterialNews, String> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMaterialNewsInfoRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddMaterialNewsInfoRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpMaterialNewsInfoRequestExecutor(requestHttp);
default:
//TODO 需要优化抛出异常

View File

@@ -17,11 +17,11 @@ public abstract class MaterialUploadRequestExecutor<H, P> implements RequestExec
public static RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMaterialUploadRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddMaterialUploadRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpMaterialUploadRequestExecutor(requestHttp);
default:
return null;

View File

@@ -19,11 +19,11 @@ public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestE
public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMaterialVideoInfoRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddMaterialVideoInfoRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp);
default:
return null;

View File

@@ -22,11 +22,11 @@ public abstract class MaterialVoiceAndImageDownloadRequestExecutor<H, P> impleme
public static RequestExecutor<InputStream, String> create(RequestHttp requestHttp, File tmpDirFile) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile);
case joddHttp:
case JODD_HTTP:
return new JoddMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile);
case okHttp:
case OK_HTTP:
return new OkhttpMaterialVoiceAndImageDownloadRequestExecutor(requestHttp, tmpDirFile);
default:
return null;

View File

@@ -21,11 +21,11 @@ public abstract class MediaImgUploadRequestExecutor<H, P> implements RequestExec
public static RequestExecutor<WxMediaImgUploadResult, File> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheMediaImgUploadRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddMediaImgUploadRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpMediaImgUploadRequestExecutor(requestHttp);
default:
return null;

View File

@@ -23,11 +23,11 @@ public abstract class QrCodeRequestExecutor<H, P> implements RequestExecutor<Fil
public static RequestExecutor<File, WxMpQrCodeTicket> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case apacheHttp:
case APACHE_HTTP:
return new ApacheQrCodeRequestExecutor(requestHttp);
case joddHttp:
case JODD_HTTP:
return new JoddQrCodeRequestExecutor(requestHttp);
case okHttp:
case OK_HTTP:
return new OkhttpQrCodeRequestExecutor(requestHttp);
default:
//TODO 需要优化,最好抛出异常

View File

@@ -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.exception.WxErrorException;
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 okhttp3.*;
@@ -12,7 +12,7 @@ import java.io.IOException;
/**
* 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) {

View File

@@ -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.exception.WxErrorException;
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.util.http.MaterialNewsInfoRequestExecutor;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
@@ -14,7 +14,7 @@ import java.io.IOException;
/**
* 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) {
super(requestHttp);
}

View File

@@ -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.exception.WxErrorException;
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.mp.bean.material.WxMpMaterial;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
@@ -18,7 +18,7 @@ import java.util.Map;
/**
* 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) {
super(requestHttp);
}

View File

@@ -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.exception.WxErrorException;
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.util.http.MaterialVideoInfoRequestExecutor;
import okhttp3.*;
@@ -13,7 +13,7 @@ import java.io.IOException;
/**
* 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) {
super(requestHttp);
}

View File

@@ -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.exception.WxErrorException;
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.mp.util.http.MaterialVoiceAndImageDownloadRequestExecutor;
import okhttp3.*;
@@ -17,7 +17,7 @@ import java.io.InputStream;
/**
* 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) {
super(requestHttp, tmpDirFile);
}

View File

@@ -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.exception.WxErrorException;
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.util.http.MediaImgUploadRequestExecutor;
import okhttp3.*;
@@ -14,7 +14,7 @@ import java.io.IOException;
/**
* 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) {
super(requestHttp);

View File

@@ -4,7 +4,7 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
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.util.http.QrCodeRequestExecutor;
@@ -19,7 +19,7 @@ import java.util.UUID;
/**
* 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) {
super(requestHttp);
}

View File

@@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
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 java.util.concurrent.ExecutionException;
@@ -16,7 +16,7 @@ public class WxMpBusyRetryTest {
@DataProvider(name = "getService")
public Object[][] getService() {
WxMpService service = new WxMpServiceImpl() {
WxMpService service = new WxMpServiceApacheHttpClientImpl() {
@Override
public synchronized <T, E> T executeInternal(

View File

@@ -6,7 +6,7 @@ import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
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.InputStream;
@@ -19,7 +19,7 @@ public class ApiTestModule implements Module {
try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) {
TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1);
config.setAccessTokenLock(new ReentrantLock());
WxMpService wxService = new WxMpServiceImpl();
WxMpService wxService = new WxMpServiceApacheHttpClientImpl();
wxService.setWxMpConfigStorage(config);
binder.bind(WxMpService.class).toInstance(wxService);

View File

@@ -5,7 +5,7 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
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.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
@@ -47,7 +47,7 @@ public class WxMpDemoServer {
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceImpl();
wxMpService = new WxMpServiceApacheHttpClientImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();