From c91a3742e1ed391dd3bc051338da495d58c3866a Mon Sep 17 00:00:00 2001 From: Liuchy1 Date: Wed, 16 Dec 2015 15:07:10 +0800 Subject: [PATCH 1/2] modify client config class --- .../cn/jpush/api/examples/ClientExample.java | 12 +--- .../cn/jpush/api/examples/DeviceExample.java | 2 +- .../cn/jpush/api/examples/PushExample.java | 4 +- .../cn/jpush/api/examples/ReportsExample.java | 2 +- .../jpush/api/examples/ScheduleExample.java | 4 +- .../cn/jpush/api/common/ClientConfig.java | 67 ++++--------------- 6 files changed, 21 insertions(+), 70 deletions(-) diff --git a/example/main/java/cn/jpush/api/examples/ClientExample.java b/example/main/java/cn/jpush/api/examples/ClientExample.java index 2b65fb8e..c397ba78 100644 --- a/example/main/java/cn/jpush/api/examples/ClientExample.java +++ b/example/main/java/cn/jpush/api/examples/ClientExample.java @@ -9,18 +9,12 @@ public class ClientExample { protected static final Logger LOG = LoggerFactory.getLogger(ClientExample.class); private static final String appKey = "dd1066407b044738b6479275"; - private static final String masterSecret = "6b135be0037a5c1e693c3dfa"; - private static final String TAG1 = "tag1"; - private static final String ALIAS1 = "alias1"; - private static final String ALIAS2 = "alias2"; - private static final String REGISTRATION_ID1 = "0900e8d85ef"; - private static final String REGISTRATION_ID2 = "0a04ad7d8b4"; - + private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; public static void main(String[] args) { // testDefaultClient(); // testCustomClient(); - testCustomPushClient(); +// testCustomPushClient(); } public static void testDefaultClient() { @@ -35,8 +29,6 @@ public static void testCustomClient() { config.setConnectionTimeout(10 * 1000); // 10 seconds config.setSSLVersion("TLSv1.1"); // JPush server supports SSLv3, TLSv1, TLSv1.1, TLSv1.2 - ClientConfig.setReadTimeout(ClientConfig.getInstance(), 30 * 1000); // 30 seconds - JPushClient jPushClient = new JPushClient(masterSecret, appKey, null, config); } diff --git a/example/main/java/cn/jpush/api/examples/DeviceExample.java b/example/main/java/cn/jpush/api/examples/DeviceExample.java index 76645e57..5f3666f0 100644 --- a/example/main/java/cn/jpush/api/examples/DeviceExample.java +++ b/example/main/java/cn/jpush/api/examples/DeviceExample.java @@ -15,7 +15,7 @@ public class DeviceExample { protected static final Logger LOG = LoggerFactory.getLogger(DeviceExample.class); private static final String appKey = "dd1066407b044738b6479275"; - private static final String masterSecret = "6b135be0037a5c1e693c3dfa"; + private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; private static final String TAG1 = "tag1"; private static final String ALIAS1 = "alias1"; private static final String ALIAS2 = "alias2"; diff --git a/example/main/java/cn/jpush/api/examples/PushExample.java b/example/main/java/cn/jpush/api/examples/PushExample.java index 4a8f6f8a..ece51cc7 100644 --- a/example/main/java/cn/jpush/api/examples/PushExample.java +++ b/example/main/java/cn/jpush/api/examples/PushExample.java @@ -22,8 +22,8 @@ public class PushExample { protected static final Logger LOG = LoggerFactory.getLogger(PushExample.class); // demo App defined in resources/jpush-api.conf - private static final String appKey ="e5c0d34f58732cf09b2d4d74"; - private static final String masterSecret = "4cdda6d3c8b029941dbc5cb3"; + private static final String appKey ="dd1066407b044738b6479275"; + private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; public static final String TITLE = "Test from API example"; public static final String ALERT = "Test from API Example - alert"; diff --git a/example/main/java/cn/jpush/api/examples/ReportsExample.java b/example/main/java/cn/jpush/api/examples/ReportsExample.java index 2482f7bb..37ccdab7 100644 --- a/example/main/java/cn/jpush/api/examples/ReportsExample.java +++ b/example/main/java/cn/jpush/api/examples/ReportsExample.java @@ -16,7 +16,7 @@ public class ReportsExample { // demo App defined in resources/jpush-api.conf private static final String appKey = "dd1066407b044738b6479275"; - private static final String masterSecret = "2b38ce69b1de2a7fa95706ea"; + private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; public static void main(String[] args) { testGetReport(); diff --git a/example/main/java/cn/jpush/api/examples/ScheduleExample.java b/example/main/java/cn/jpush/api/examples/ScheduleExample.java index de4df8c4..98253799 100644 --- a/example/main/java/cn/jpush/api/examples/ScheduleExample.java +++ b/example/main/java/cn/jpush/api/examples/ScheduleExample.java @@ -17,8 +17,8 @@ public class ScheduleExample { protected static final Logger LOG = LoggerFactory.getLogger(ScheduleExample.class); - private static final String appKey ="e5c0d34f58732cf09b2d4d74"; - private static final String masterSecret = "4cdda6d3c8b029941dbc5cb3"; + private static final String appKey ="dd1066407b044738b6479275"; + private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; public static void main(String[] args) { diff --git a/src/main/java/cn/jpush/api/common/ClientConfig.java b/src/main/java/cn/jpush/api/common/ClientConfig.java index 9cde3d1d..20163bf1 100644 --- a/src/main/java/cn/jpush/api/common/ClientConfig.java +++ b/src/main/java/cn/jpush/api/common/ClientConfig.java @@ -1,7 +1,6 @@ package cn.jpush.api.common; import java.util.HashMap; -import java.util.Map; public class ClientConfig extends HashMap { @@ -117,20 +116,12 @@ public static ClientConfig getInstance() { return instance; } - public static void setDeviceHostName(Map conf, String hostName) { - conf.put(DEVICE_HOST_NAME, hostName); - } - /** * Setup custom device api host name, if using the JPush privacy cloud. * @param hostName the custom api host name, default is JPush domain name */ public void setDeviceHostName(String hostName) { - setDeviceHostName(this, hostName); - } - - public static void setPushHostName(Map conf, String hostName) { - conf.put(PUSH_HOST_NAME, hostName); + this.put(DEVICE_HOST_NAME, hostName); } /** @@ -138,11 +129,7 @@ public static void setPushHostName(Map conf, String hostName) { * @param hostName the custom api host name, default is JPush domain name */ public void setPushHostName(String hostName) { - setPushHostName(this, hostName); - } - - public static void setReportHostName(Map conf, String hostName) { - conf.put(REPORT_HOST_NAME, hostName); + this.put(PUSH_HOST_NAME, hostName); } /** @@ -150,47 +137,27 @@ public static void setReportHostName(Map conf, String hostName) { * @param hostName the custom api host name, default is JPush domain name */ public void setReportHostName(String hostName) { - setReportHostName(this, hostName); - } - - public static void setScheduleHostName(Map conf, String hostName) { - conf.put(SCHEDULE_HOST_NAME, hostName); + this.put(REPORT_HOST_NAME, hostName); } public void setScheduleHostName(String hostName) { - setScheduleHostName(this, hostName); + this.put(SCHEDULE_HOST_NAME, hostName); } public void setSSLVersion(String sslVer) { - setSSLVersion(this, sslVer); - } - - public static void setSSLVersion(Map conf, String sslVer) { - conf.put(SSL_VERSION, sslVer); + this.put(SSL_VERSION, sslVer); } public void setMaxRetryTimes(int maxRetryTimes) { - setMaxRetryTimes(this, maxRetryTimes); - } - - public static void setMaxRetryTimes(Map conf, int maxRetryTimes) { - conf.put(MAX_RETRY_TIMES, maxRetryTimes); + this.put(MAX_RETRY_TIMES, maxRetryTimes); } public void setReadTimeout(int readTimeout) { - setReadTimeout(this, readTimeout); - } - - public static void setReadTimeout(Map conf, int readTimeout) { - conf.put(READ_TIMEOUT, readTimeout); + this.put(READ_TIMEOUT, readTimeout); } public void setConnectionTimeout(int connectionTimeout) { - setConnectionTimeout(this, connectionTimeout); - } - - public static void setConnectionTimeout(Map conf, int connectionTimeout) { - conf.put(CONNECTION_TIMEOUT, connectionTimeout); + this.put(CONNECTION_TIMEOUT, connectionTimeout); } public String getSSLVersion() { @@ -209,28 +176,20 @@ public Integer getConnectionTimeout() { return (Integer) this.get(CONNECTION_TIMEOUT); } - public static void setApnsProduction(Map conf, boolean production) { + public void setApnsProduction(boolean production) { if(production) { - conf.put(APNS_PRODUCTION, 1); + this.put(APNS_PRODUCTION, 1); } else { - conf.put(APNS_PRODUCTION, 0); + this.put(APNS_PRODUCTION, 0); } } - public void setApnsProduction(boolean production) { - setApnsProduction(this, production); - } - - public static void setTimeToLive(Map conf, long timeToLive) { - conf.put(TIME_TO_LIVE, timeToLive); - } - public void setTimeToLive(long timeToLive) { - setTimeToLive(this, timeToLive); + this.put(TIME_TO_LIVE, timeToLive); } public void setGlobalPushSetting(boolean apnsProduction, long timeToLive) { - setApnsProduction(this, apnsProduction); + setApnsProduction(apnsProduction); setTimeToLive(timeToLive); } } From e2c027a4afe8190d2661e24483c19695d27a9111 Mon Sep 17 00:00:00 2001 From: Liuchy1 Date: Wed, 16 Dec 2015 15:09:53 +0800 Subject: [PATCH 2/2] fix readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 0e77e014..abccdacd 100644 --- a/README.md +++ b/README.md @@ -313,8 +313,6 @@ config.setConnectionTimeout(10 * 1000); // 10 seconds config.setSSLVersion("TLSv1.1"); // JPush server supports SSLv3, TLSv1, TLSv1.1, TLSv1.2 - ClientConfig.setReadTimeout(ClientConfig.getInstance(), 30 * 1000); // 30 seconds - JPushClient jPushClient = new JPushClient(masterSecret, appKey, null, config); }