重要:工程运行环境由jdk1.7调整为jdk1.6

This commit is contained in:
jinyu 2015-09-21 22:32:42 +08:00
parent 50b01790af
commit 03ca6e670a
15 changed files with 45 additions and 47 deletions

View File

@ -469,4 +469,8 @@
+ weixin4j-[mp|qy]:version upgrade to 1.6.1 + weixin4j-[mp|qy]:version upgrade to 1.6.1
+ weixin4j-server:version upgrade to 1.1.1 + weixin4j-server:version upgrade to 1.1.1
* 2015-09-21
重要:工程运行环境由jdk1.7调整为jdk1.6

View File

@ -54,8 +54,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version> <version>3.0</version>
<configuration> <configuration>
<source>1.7</source> <source>1.6</source>
<target>1.7</target> <target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding> <encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -94,8 +94,12 @@ public abstract class HttpClientFactory {
new X509TrustManager[] { createX509TrustManager() }, new X509TrustManager[] { createX509TrustManager() },
new java.security.SecureRandom()); new java.security.SecureRandom());
return sslContext; return sslContext;
} catch (NoSuchAlgorithmException | KeyManagementException e) { } catch (NoSuchAlgorithmException e) {
throw new HttpClientException("Create SSLContext Error:", e); throw new HttpClientException(
"Create SSLContext NoSuchAlgorithmException:", e);
} catch (KeyManagementException e) {
throw new HttpClientException(
"Create SSLContext KeyManagementException:", e);
} }
} }

View File

@ -108,10 +108,18 @@ public class Netty4HttpClient extends AbstractHttpClient {
.addListener(listener); .addListener(listener);
response = future.get(); response = future.get();
handleResponse(response); handleResponse(response);
} catch (IOException | InterruptedException | ExecutionException e) { } catch (IOException e) {
throw new HttpClientException("I/O error on " throw new HttpClientException("I/O error on "
+ request.getMethod().name() + " request for \"" + request.getMethod().name() + " request for \""
+ request.getURI().toString() + "\":" + e.getMessage(), e); + request.getURI().toString() + "\":" + e.getMessage(), e);
} catch (InterruptedException e) {
throw new HttpClientException("Execute error on "
+ request.getMethod().name() + " request for \""
+ request.getURI().toString() + "\":" + e.getMessage(), e);
} catch (ExecutionException e) {
throw new HttpClientException("Execute error on "
+ request.getMethod().name() + " request for \""
+ request.getURI().toString() + "\":" + e.getMessage(), e);
} finally { } finally {
if (response != null) { if (response != null) {
response.close(); response.close();
@ -135,9 +143,9 @@ public class Netty4HttpClient extends AbstractHttpClient {
HttpEntity entity = request.getEntity(); HttpEntity entity = request.getEntity();
if (entity != null) { if (entity != null) {
ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(); ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer();
try (ByteBufOutputStream out = new ByteBufOutputStream(byteBuf)) { ByteBufOutputStream out = new ByteBufOutputStream(byteBuf);
entity.writeTo(out); entity.writeTo(out);
} out.close();
uriRequest = new DefaultFullHttpRequest( uriRequest = new DefaultFullHttpRequest(
uriRequest.getProtocolVersion(), uriRequest.getMethod(), uriRequest.getProtocolVersion(), uriRequest.getMethod(),
uriRequest.getUri(), byteBuf); uriRequest.getUri(), byteBuf);

View File

@ -1,9 +1,8 @@
package com.foxinmy.weixin4j.tuple; package com.foxinmy.weixin4j.tuple;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField; import javax.xml.bind.annotation.XmlTransient;
/** /**
* 消息元件 * 消息元件
@ -21,7 +20,6 @@ public interface Tuple extends Serializable {
* *
* @return * @return
*/ */
@Transient @XmlTransient
@JSONField(deserialize = false, serialize = false)
public String getMessageType(); public String getMessageType();
} }

View File

@ -2,7 +2,6 @@ package com.foxinmy.weixin4j.util;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Iterator; import java.util.Iterator;
import java.util.Objects;
import com.foxinmy.weixin4j.model.Consts; import com.foxinmy.weixin4j.model.Consts;
@ -159,8 +158,7 @@ public final class StringUtil {
} }
final Object first = iterator.next(); final Object first = iterator.next();
if (!iterator.hasNext()) { if (!iterator.hasNext()) {
String result = Objects.toString(first); return String.valueOf(first);
return result;
} }
// two or more elements // two or more elements

View File

@ -1,10 +1,9 @@
package com.foxinmy.weixin4j.mp.payment.v2; package com.foxinmy.weixin4j.mp.payment.v2;
import java.beans.Transient;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.WeixinPayAccount; import com.foxinmy.weixin4j.model.WeixinPayAccount;
@ -13,8 +12,7 @@ import com.foxinmy.weixin4j.util.DigestUtil;
import com.foxinmy.weixin4j.util.MapUtil; import com.foxinmy.weixin4j.util.MapUtil;
/** /**
* V2微信JS支付:get_brand_wcpay_request</br> * V2微信JS支付:get_brand_wcpay_request</br> <font color="red">所列参数均为非空字符串</font>
* <font color="red">所列参数均为非空字符串</font>
* <p> * <p>
* get_brand_wcpay_request:ok 支付成功<br> * get_brand_wcpay_request:ok 支付成功<br>
* get_brand_wcpay_request:cancel 支付过程中用户取消<br> * get_brand_wcpay_request:cancel 支付过程中用户取消<br>
@ -33,17 +31,18 @@ public class JsPayRequestV2 extends PayRequest {
private static final long serialVersionUID = -5972173459255255197L; private static final long serialVersionUID = -5972173459255255197L;
protected JsPayRequestV2(){ protected JsPayRequestV2() {
// jaxb required // jaxb required
} }
public JsPayRequestV2(WeixinPayAccount weixinAccount, PayPackageV2 payPackage) { public JsPayRequestV2(WeixinPayAccount weixinAccount,
PayPackageV2 payPackage) {
this.setAppId(weixinAccount.getId()); this.setAppId(weixinAccount.getId());
this.setPackageInfo(package2string(payPackage, this.setPackageInfo(package2string(payPackage,
weixinAccount.getPartnerKey())); weixinAccount.getPartnerKey()));
} }
@Transient @XmlTransient
@JSONField(serialize = false) @JSONField(serialize = false)
private String package2string(PayPackageV2 payPackage, String partnerKey) { private String package2string(PayPackageV2 payPackage, String partnerKey) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@ -48,8 +48,9 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version> <version>3.0</version>
<configuration> <configuration>
<source>1.7</source> <source>1.6</source>
<target>1.7</target> <target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.qy.chat; package com.foxinmy.weixin4j.qy.chat;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@ -111,7 +110,6 @@ public class ChatItem implements Serializable {
return createTime; return createTime;
} }
@Transient
@XmlTransient @XmlTransient
public Date getFormatCreateTime() { public Date getFormatCreateTime() {
return createTime > 0l ? new Date(createTime * 1000l) : null; return createTime > 0l ? new Date(createTime * 1000l) : null;
@ -121,7 +119,6 @@ public class ChatItem implements Serializable {
return msgType; return msgType;
} }
@Transient
@XmlTransient @XmlTransient
public MessageType getFormatMsgType() { public MessageType getFormatMsgType() {
return msgType != null ? MessageType.valueOf(msgType) : null; return msgType != null ? MessageType.valueOf(msgType) : null;
@ -131,7 +128,6 @@ public class ChatItem implements Serializable {
return eventType; return eventType;
} }
@Transient
@XmlTransient @XmlTransient
public ChatEventType getFormatEventType() { public ChatEventType getFormatEventType() {
return eventType != null ? ChatEventType.valueOf(eventType) : null; return eventType != null ? ChatEventType.valueOf(eventType) : null;
@ -153,7 +149,6 @@ public class ChatItem implements Serializable {
return members; return members;
} }
@Transient
@XmlTransient @XmlTransient
public List<String> getFormatMembers() { public List<String> getFormatMembers() {
return members != null ? Arrays.asList(members.split(LIST_SEPARATOR)) return members != null ? Arrays.asList(members.split(LIST_SEPARATOR))
@ -164,7 +159,6 @@ public class ChatItem implements Serializable {
return addMembers; return addMembers;
} }
@Transient
@XmlTransient @XmlTransient
public List<String> getFormatAddMembers() { public List<String> getFormatAddMembers() {
return addMembers != null ? Arrays.asList(addMembers return addMembers != null ? Arrays.asList(addMembers
@ -175,7 +169,6 @@ public class ChatItem implements Serializable {
return deleteMembers; return deleteMembers;
} }
@Transient
@XmlTransient @XmlTransient
public List<String> getFormatDeleteMembers() { public List<String> getFormatDeleteMembers() {
return deleteMembers != null ? Arrays.asList(deleteMembers return deleteMembers != null ? Arrays.asList(deleteMembers

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.qy.chat; package com.foxinmy.weixin4j.qy.chat;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -37,7 +36,6 @@ public class ChatReceiver implements Serializable {
return chatType; return chatType;
} }
@Transient
@XmlTransient @XmlTransient
public ChatType getFormatChatType() { public ChatType getFormatChatType() {
return ChatType.valueOf(chatType); return ChatType.valueOf(chatType);

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.qy.chat; package com.foxinmy.weixin4j.qy.chat;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@ -61,7 +60,6 @@ public class WeixinChatMessage implements Serializable {
return agentType; return agentType;
} }
@Transient
@XmlTransient @XmlTransient
public AgentType getFormatAgentType() { public AgentType getFormatAgentType() {
return AgentType.valueOf(agentType); return AgentType.valueOf(agentType);

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.qy.suite; package com.foxinmy.weixin4j.qy.suite;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -58,7 +57,6 @@ public class WeixinSuiteMessage implements Serializable {
return eventType; return eventType;
} }
@Transient
@XmlTransient @XmlTransient
public SuiteEventType getFormatEventType() { public SuiteEventType getFormatEventType() {
return SuiteEventType.valueOf(eventType); return SuiteEventType.valueOf(eventType);
@ -68,7 +66,6 @@ public class WeixinSuiteMessage implements Serializable {
return timeStamp; return timeStamp;
} }
@Transient
@XmlTransient @XmlTransient
public Date getFormatTimeStamp() { public Date getFormatTimeStamp() {
return timeStamp > 0l ? new Date(timeStamp * 1000l) : null; return timeStamp > 0l ? new Date(timeStamp * 1000l) : null;

View File

@ -1,6 +1,5 @@
package com.foxinmy.weixin4j.request; package com.foxinmy.weixin4j.request;
import java.beans.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -95,7 +94,6 @@ public class WeixinMessage implements Serializable {
return createTime; return createTime;
} }
@Transient
@XmlTransient @XmlTransient
public Date getFormatCreateTime() { public Date getFormatCreateTime() {
return createTime > 0l ? new Date(createTime * 1000l) : null; return createTime > 0l ? new Date(createTime * 1000l) : null;
@ -105,7 +103,6 @@ public class WeixinMessage implements Serializable {
return msgType; return msgType;
} }
@Transient
@XmlTransient @XmlTransient
public MessageType getFormatMsgType() { public MessageType getFormatMsgType() {
return MessageType.valueOf(msgType); return MessageType.valueOf(msgType);

View File

@ -139,7 +139,9 @@ public final class ClassUtil {
bis = new ByteArrayInputStream(bos.toByteArray()); bis = new ByteArrayInputStream(bos.toByteArray());
ois = new ObjectInputStream(bis); ois = new ObjectInputStream(bis);
return ois.readObject(); return ois.readObject();
} catch (IOException | ClassNotFoundException e) { } catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
try { try {

View File

@ -2,7 +2,6 @@ package com.foxinmy.weixin4j.server.test;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
@ -14,6 +13,8 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import com.foxinmy.weixin4j.util.Consts;
/** /**
* 发送消息请求到服务器 * 发送消息请求到服务器
* *
@ -51,7 +52,7 @@ public class MessagePush {
public String push(String para, String xml) throws IOException { public String push(String para, String xml) throws IOException {
httpPost.setURI(URI.create(server + para)); httpPost.setURI(URI.create(server + para));
httpPost.setEntity(new StringEntity(xml, StandardCharsets.UTF_8)); httpPost.setEntity(new StringEntity(xml, Consts.UTF_8));
HttpResponse httpResponse = httpClient.execute(httpPost); HttpResponse httpResponse = httpClient.execute(httpPost);
return entity(httpResponse); return entity(httpResponse);
} }
@ -68,6 +69,6 @@ public class MessagePush {
throw new IOException(Integer.toString(status) + "uri moved"); throw new IOException(Integer.toString(status) + "uri moved");
} }
return EntityUtils.toString(httpResponse.getEntity(), return EntityUtils.toString(httpResponse.getEntity(),
StandardCharsets.UTF_8); Consts.UTF_8);
} }
} }