From 78995c687f41372764e24f658fa81ea5658d7490 Mon Sep 17 00:00:00 2001 From: jinyu Date: Tue, 1 Dec 2015 12:01:39 +0800 Subject: [PATCH] update md --- weixin4j-base/README.md | 2 ++ .../com/foxinmy/weixin4j/tuple/Article.java | 2 +- weixin4j-mp/README.md | 22 ++++++++------- weixin4j-qy/README.md | 21 ++++++++++----- .../com/foxinmy/weixin4j/util/ClassUtil.java | 27 +++++++++++++++++-- 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/weixin4j-base/README.md b/weixin4j-base/README.md index 7f1cef63..d24b9c18 100644 --- a/weixin4j-base/README.md +++ b/weixin4j-base/README.md @@ -13,5 +13,7 @@ weixin4j-base `HttpClient的实现` +`微信支付的实现` + [更新LOG](./CHANGE.md) --------------------- diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/tuple/Article.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/tuple/Article.java index 74ef0695..7bb06b89 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/tuple/Article.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/tuple/Article.java @@ -45,7 +45,7 @@ public class Article implements Serializable { @JSONCreator public Article(@JSONField(name = "title") String title, - @JSONField(name = "description") String desc, + @JSONField(name = "desc") String desc, @JSONField(name = "picUrl") String picUrl, @JSONField(name = "url") String url) { this.title = title; diff --git a/weixin4j-mp/README.md b/weixin4j-mp/README.md index 5a249da4..08487caa 100644 --- a/weixin4j-mp/README.md +++ b/weixin4j-mp/README.md @@ -56,15 +56,15 @@ weixin4j.properties说明 | 属性名 | 说明 | | :---------- | :-------------- | -| account | 微信公众号信息 `json格式`(按需填写) | -| token_path | 使用FileTokenStorager时token保存的物理路径 | -| qr_path | 调用二维码接口时保存二维码图片的物理路径 | -| media_path | 调用媒体接口时保存媒体文件的物理路径 | -| bill_path | 调用下载对账单接口保存文件的物理路径 | -| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件 | -| user_oauth_redirect_uri | 调用OauthApi接口时需要填写的重定向路径 | +| account | 微信公众号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) | +| token_path | 使用FileTokenStorager时token保存的物理路径(非必须填写) | +| qr_path | 调用二维码接口时保存二维码图片的物理路径(非必须填写) | +| media_path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) | +| bill_path | 调用下载对账单接口保存文件的物理路径(非必须填写) | +| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件(按须填写) | +| user_oauth_redirect_uri | 调用OauthApi接口时需要填写的重定向路径(非必须填写) | -示例(properties中换行用右斜杆\\) +完整填写示例(properties中换行用右斜杆\\) account={"id":"appId","secret":"appSecret",\ "mchId":"V3.x版本下的微信商户号",\ @@ -85,12 +85,14 @@ weixin4j.properties说明 2.实例化微信企业号接口代理对象,调用具体的API方法 - // 微信公众号API + // 微信公众号API 使用classpath的weixin4j.properties WeixinProxy weixinProxy = new WeixinProxy(); + // 直接传入公众号信息 // weixinProxy = new WeixinProxy(appid,appsecret); weixinProxy.getUser(openId); - // 微信支付API + // 微信支付API 使用classpath的weixin4j.properties WeixinPayProxy weixinPayProxy = new WeixinPayProxy(); + // 直接构造WexinAccount对象 // weixinPayProxy = new WeixinPayProxy(weixinAccount); weixinPayProxy.orderQuery(idQuery); diff --git a/weixin4j-qy/README.md b/weixin4j-qy/README.md index da3ac610..94339788 100644 --- a/weixin4j-qy/README.md +++ b/weixin4j-qy/README.md @@ -50,11 +50,11 @@ weixin4j.properties说明 | 属性名 | 说明 | | :---------- | :-------------- | -| account | 微信企业号信息 `json格式`(按需填写) | -| token_path | 使用FileTokenStorager时token保存的物理路径 | -| media_path | 调用媒体接口时保存媒体文件的物理路径 | -| bill_path | 调用下载对账单接口保存文件的物理路径 | -| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件 | +| account | 微信企业号信息 `json格式`(使用new WeixinProxy()缺省构造器时须填写) | +| token_path | 使用FileTokenStorager时token保存的物理路径(非必须填写) | +| media_path | 调用媒体接口时保存媒体文件的物理路径(非必须填写) | +| bill_path | 调用下载对账单接口保存文件的物理路径(非必须填写) | +| ca_file | 调用某些接口(支付相关)强制需要auth的ca授权文件(非必须填写) | | user_oauth_redirect_uri | 企业号用户身份授权后重定向的url(OauthApi接口) | | third_oauth_redirect_uri | 企业号第三方提供商授权后重定向的url(OauthApi接口) | | suite_oauth_redirect_uri | 企业号第三方应用套件授权后重定向的url(OauthApi接口) | @@ -84,12 +84,19 @@ weixin4j.properties说明 2.实例化微信企业号接口代理对象,调用具体的API方法 - // 微信企业号API + // 微信企业号API 使用classpath的weixin4j.properties WeixinProxy weixinProxy = new WeixinProxy(); + // 直接传入企业号信息 // weixinProxy = new WeixinProxy(corpid,corpsecret); weixinProxy.getUser(userid); - // 微信第三方应用API + // 微信支付API 使用classpath的weixin4j.properties + WeixinPayProxy weixinPayProxy = new WeixinPayProxy(); + // 直接构造WexinAccount对象 + // weixinPayProxy = new WeixinPayProxy(weixinAccount); + weixinPayProxy.orderQuery(idQuery); + // 微信第三方应用API 使用classpath的weixin4j.properties WeixinSuiteProxy weixinSuiteProxy = new WeixinSuiteProxy(); + // 直接传入套件信息 //weixinSuiteProxy = new WeixinSuiteProxy(suiteId,suiteSecret); weixinSuiteProxy.api().getOAuthInfo(authCorpid); diff --git a/weixin4j-server/src/main/java/com/foxinmy/weixin4j/util/ClassUtil.java b/weixin4j-server/src/main/java/com/foxinmy/weixin4j/util/ClassUtil.java index bae68375..5d01650c 100644 --- a/weixin4j-server/src/main/java/com/foxinmy/weixin4j/util/ClassUtil.java +++ b/weixin4j-server/src/main/java/com/foxinmy/weixin4j/util/ClassUtil.java @@ -38,8 +38,7 @@ public final class ClassUtil { public static List> getClasses(String packageName) throws RuntimeException { String packageFileName = packageName.replace(".", File.separator); - URL fullPath = Thread.currentThread().getContextClassLoader() - .getResource(packageFileName); + URL fullPath = getDefaultClassLoader().getResource(packageFileName); String protocol = fullPath.getProtocol(); if (protocol.equals(Consts.PROTOCOL_FILE)) { File dir = new File(fullPath.getPath()); @@ -180,6 +179,30 @@ public final class ClassUtil { return clazz; } + public static ClassLoader getDefaultClassLoader() { + ClassLoader cl = null; + try { + cl = Thread.currentThread().getContextClassLoader(); + } catch (Throwable ex) { + // Cannot access thread context ClassLoader - falling back... + } + if (cl == null) { + // No thread context class loader -> use class loader of this class. + cl = ClassUtil.class.getClassLoader(); + if (cl == null) { + // getClassLoader() returning null indicates the bootstrap + // ClassLoader + try { + cl = ClassLoader.getSystemClassLoader(); + } catch (Throwable ex) { + // Cannot access system ClassLoader - oh well, maybe the + // caller can live with null... + } + } + } + return cl; + } + public static void main(String[] args) { System.err .println(getClasses(com.foxinmy.weixin4j.handler.WeixinMessageHandler.class