Skip to content

Commit ad352bc

Browse files
committed
Merge pull request #47 from Liuchy1/master
modify client config class
2 parents 8b563e2 + e2c027a commit ad352bc

File tree

7 files changed

+21
-72
lines changed

7 files changed

+21
-72
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@
313313
config.setConnectionTimeout(10 * 1000); // 10 seconds
314314
config.setSSLVersion("TLSv1.1"); // JPush server supports SSLv3, TLSv1, TLSv1.1, TLSv1.2
315315

316-
ClientConfig.setReadTimeout(ClientConfig.getInstance(), 30 * 1000); // 30 seconds
317-
318316
JPushClient jPushClient = new JPushClient(masterSecret, appKey, null, config);
319317
}
320318

example/main/java/cn/jpush/api/examples/ClientExample.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ public class ClientExample {
99
protected static final Logger LOG = LoggerFactory.getLogger(ClientExample.class);
1010

1111
private static final String appKey = "dd1066407b044738b6479275";
12-
private static final String masterSecret = "6b135be0037a5c1e693c3dfa";
13-
private static final String TAG1 = "tag1";
14-
private static final String ALIAS1 = "alias1";
15-
private static final String ALIAS2 = "alias2";
16-
private static final String REGISTRATION_ID1 = "0900e8d85ef";
17-
private static final String REGISTRATION_ID2 = "0a04ad7d8b4";
18-
12+
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
1913

2014
public static void main(String[] args) {
2115
// testDefaultClient();
2216
// testCustomClient();
23-
testCustomPushClient();
17+
// testCustomPushClient();
2418
}
2519

2620
public static void testDefaultClient() {
@@ -35,8 +29,6 @@ public static void testCustomClient() {
3529
config.setConnectionTimeout(10 * 1000); // 10 seconds
3630
config.setSSLVersion("TLSv1.1"); // JPush server supports SSLv3, TLSv1, TLSv1.1, TLSv1.2
3731

38-
ClientConfig.setReadTimeout(ClientConfig.getInstance(), 30 * 1000); // 30 seconds
39-
4032
JPushClient jPushClient = new JPushClient(masterSecret, appKey, null, config);
4133
}
4234

example/main/java/cn/jpush/api/examples/DeviceExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DeviceExample {
1515
protected static final Logger LOG = LoggerFactory.getLogger(DeviceExample.class);
1616

1717
private static final String appKey = "dd1066407b044738b6479275";
18-
private static final String masterSecret = "6b135be0037a5c1e693c3dfa";
18+
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
1919
private static final String TAG1 = "tag1";
2020
private static final String ALIAS1 = "alias1";
2121
private static final String ALIAS2 = "alias2";

example/main/java/cn/jpush/api/examples/PushExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class PushExample {
2222
protected static final Logger LOG = LoggerFactory.getLogger(PushExample.class);
2323

2424
// demo App defined in resources/jpush-api.conf
25-
private static final String appKey ="e5c0d34f58732cf09b2d4d74";
26-
private static final String masterSecret = "4cdda6d3c8b029941dbc5cb3";
25+
private static final String appKey ="dd1066407b044738b6479275";
26+
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
2727

2828
public static final String TITLE = "Test from API example";
2929
public static final String ALERT = "Test from API Example - alert";

example/main/java/cn/jpush/api/examples/ReportsExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ReportsExample {
1616

1717
// demo App defined in resources/jpush-api.conf
1818
private static final String appKey = "dd1066407b044738b6479275";
19-
private static final String masterSecret = "2b38ce69b1de2a7fa95706ea";
19+
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
2020

2121
public static void main(String[] args) {
2222
testGetReport();

example/main/java/cn/jpush/api/examples/ScheduleExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public class ScheduleExample {
1717

1818
protected static final Logger LOG = LoggerFactory.getLogger(ScheduleExample.class);
1919

20-
private static final String appKey ="e5c0d34f58732cf09b2d4d74";
21-
private static final String masterSecret = "4cdda6d3c8b029941dbc5cb3";
20+
private static final String appKey ="dd1066407b044738b6479275";
21+
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
2222

2323
public static void main(String[] args) {
2424

src/main/java/cn/jpush/api/common/ClientConfig.java

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cn.jpush.api.common;
22

33
import java.util.HashMap;
4-
import java.util.Map;
54

65
public class ClientConfig extends HashMap<String, Object> {
76

@@ -117,80 +116,48 @@ public static ClientConfig getInstance() {
117116
return instance;
118117
}
119118

120-
public static void setDeviceHostName(Map conf, String hostName) {
121-
conf.put(DEVICE_HOST_NAME, hostName);
122-
}
123-
124119
/**
125120
* Setup custom device api host name, if using the JPush privacy cloud.
126121
* @param hostName the custom api host name, default is JPush domain name
127122
*/
128123
public void setDeviceHostName(String hostName) {
129-
setDeviceHostName(this, hostName);
130-
}
131-
132-
public static void setPushHostName(Map conf, String hostName) {
133-
conf.put(PUSH_HOST_NAME, hostName);
124+
this.put(DEVICE_HOST_NAME, hostName);
134125
}
135126

136127
/**
137128
* Setup custom push api host name, if using the JPush privacy cloud.
138129
* @param hostName the custom api host name, default is JPush domain name
139130
*/
140131
public void setPushHostName(String hostName) {
141-
setPushHostName(this, hostName);
142-
}
143-
144-
public static void setReportHostName(Map conf, String hostName) {
145-
conf.put(REPORT_HOST_NAME, hostName);
132+
this.put(PUSH_HOST_NAME, hostName);
146133
}
147134

148135
/**
149136
* Setup custom report api host name, if using the JPush privacy cloud.
150137
* @param hostName the custom api host name, default is JPush domain name
151138
*/
152139
public void setReportHostName(String hostName) {
153-
setReportHostName(this, hostName);
154-
}
155-
156-
public static void setScheduleHostName(Map conf, String hostName) {
157-
conf.put(SCHEDULE_HOST_NAME, hostName);
140+
this.put(REPORT_HOST_NAME, hostName);
158141
}
159142

160143
public void setScheduleHostName(String hostName) {
161-
setScheduleHostName(this, hostName);
144+
this.put(SCHEDULE_HOST_NAME, hostName);
162145
}
163146

164147
public void setSSLVersion(String sslVer) {
165-
setSSLVersion(this, sslVer);
166-
}
167-
168-
public static void setSSLVersion(Map conf, String sslVer) {
169-
conf.put(SSL_VERSION, sslVer);
148+
this.put(SSL_VERSION, sslVer);
170149
}
171150

172151
public void setMaxRetryTimes(int maxRetryTimes) {
173-
setMaxRetryTimes(this, maxRetryTimes);
174-
}
175-
176-
public static void setMaxRetryTimes(Map conf, int maxRetryTimes) {
177-
conf.put(MAX_RETRY_TIMES, maxRetryTimes);
152+
this.put(MAX_RETRY_TIMES, maxRetryTimes);
178153
}
179154

180155
public void setReadTimeout(int readTimeout) {
181-
setReadTimeout(this, readTimeout);
182-
}
183-
184-
public static void setReadTimeout(Map conf, int readTimeout) {
185-
conf.put(READ_TIMEOUT, readTimeout);
156+
this.put(READ_TIMEOUT, readTimeout);
186157
}
187158

188159
public void setConnectionTimeout(int connectionTimeout) {
189-
setConnectionTimeout(this, connectionTimeout);
190-
}
191-
192-
public static void setConnectionTimeout(Map conf, int connectionTimeout) {
193-
conf.put(CONNECTION_TIMEOUT, connectionTimeout);
160+
this.put(CONNECTION_TIMEOUT, connectionTimeout);
194161
}
195162

196163
public String getSSLVersion() {
@@ -209,28 +176,20 @@ public Integer getConnectionTimeout() {
209176
return (Integer) this.get(CONNECTION_TIMEOUT);
210177
}
211178

212-
public static void setApnsProduction(Map conf, boolean production) {
179+
public void setApnsProduction(boolean production) {
213180
if(production) {
214-
conf.put(APNS_PRODUCTION, 1);
181+
this.put(APNS_PRODUCTION, 1);
215182
} else {
216-
conf.put(APNS_PRODUCTION, 0);
183+
this.put(APNS_PRODUCTION, 0);
217184
}
218185
}
219186

220-
public void setApnsProduction(boolean production) {
221-
setApnsProduction(this, production);
222-
}
223-
224-
public static void setTimeToLive(Map conf, long timeToLive) {
225-
conf.put(TIME_TO_LIVE, timeToLive);
226-
}
227-
228187
public void setTimeToLive(long timeToLive) {
229-
setTimeToLive(this, timeToLive);
188+
this.put(TIME_TO_LIVE, timeToLive);
230189
}
231190

232191
public void setGlobalPushSetting(boolean apnsProduction, long timeToLive) {
233-
setApnsProduction(this, apnsProduction);
192+
setApnsProduction(apnsProduction);
234193
setTimeToLive(timeToLive);
235194
}
236195
}

0 commit comments

Comments
 (0)