更新注释说明

This commit is contained in:
jinyu 2015-07-30 14:41:05 +08:00
parent 2058decfa9
commit de4043b90a
2 changed files with 30 additions and 19 deletions

View File

@ -48,7 +48,7 @@ public class WeixinRequestHandler extends
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close(); ctx.close();
logger.error("catch the exception:{}", cause); logger.error("catch the exception:", cause);
} }
@Override @Override

View File

@ -81,7 +81,7 @@ public final class WeixinServerBootstrap {
* 明文模式 * 明文模式
* *
* @param weixinid * @param weixinid
* 微信号(原始ID)或者appid * 微信号(原始ID/appid/cropid)
* @param token * @param token
* 开发者token * 开发者token
* *
@ -104,36 +104,47 @@ public final class WeixinServerBootstrap {
this(new AesToken(appid, token, aesKey)); this(new AesToken(appid, token, aesKey));
} }
public WeixinServerBootstrap(AesToken aesToken) { /**
this(aesToken, new DefaultMessageMatcher()); * 多个公众号的支持
} * <p>
* <font color="red">请注意需在服务接收事件的URL中附加一个名为wexin_id的参数,其值请填写公众号的appid/
public WeixinServerBootstrap(AesToken aesToken, * cropid</font>
WeixinMessageMatcher messageMatcher) { * <p>
this.aesTokenMap = new HashMap<String, AesToken>(); *
this.aesTokenMap.put(aesToken.getWeixinId(), aesToken); * @param aesTokens
this.aesTokenMap.put(null, aesToken); * 多个公众号
this.messageHandlerList = new LinkedList<WeixinMessageHandler>(); * @return
this.messageInterceptorList = new LinkedList<WeixinMessageInterceptor>(); */
this.messageDispatcher = new WeixinMessageDispatcher(messageMatcher); public WeixinServerBootstrap(AesToken... aesToken) {
this(new DefaultMessageMatcher(), aesToken);
} }
/** /**
* 多个公众号的支持 * 多个公众号的支持
* <p> * <p>
* <font color="red">请注意需在服务接收事件的URL中附加一个名为wexin_id的参数,其值视加密模式而定, * <font color="red">请注意需在服务接收事件的URL中附加一个名为wexin_id的参数,其值请填写公众号的appid/
* 如为明文模式weixin_id则填写公众号的微信号(即原始ID),如为AES加密模式weixin_id则填写公众号的应用ID(即appid) * cropid</font>
* </font>
* <p> * <p>
* *
* @param messageMatcher
* 消息匹配器
* @param aesTokens * @param aesTokens
* 多个公众号
* @return * @return
*/ */
public WeixinServerBootstrap multAesToken(AesToken... aesTokens) { public WeixinServerBootstrap(WeixinMessageMatcher messageMatcher,
AesToken... aesTokens) {
this.aesTokenMap = new HashMap<String, AesToken>();
for (AesToken aesToken : aesTokens) { for (AesToken aesToken : aesTokens) {
this.aesTokenMap.put(aesToken.getWeixinId(), aesToken); this.aesTokenMap.put(aesToken.getWeixinId(), aesToken);
} }
return this; // default..
if (aesTokens.length == 1) {
this.aesTokenMap.put(null, aesTokens[0]);
}
this.messageHandlerList = new LinkedList<WeixinMessageHandler>();
this.messageInterceptorList = new LinkedList<WeixinMessageInterceptor>();
this.messageDispatcher = new WeixinMessageDispatcher(messageMatcher);
} }
/** /**