diff --git a/weixin4j-server/README.md b/weixin4j-server/README.md
index d9819783..c67cf302 100644
--- a/weixin4j-server/README.md
+++ b/weixin4j-server/README.md
@@ -1,7 +1,7 @@
weixin4j-server
===============
-微信回调消息服务器
+[微信回调消息](http://mp.weixin.qq.com/wiki/1/6239b44c206cab9145b1d52c67e6c551.html)服务器
----------------
base on netty.
@@ -15,13 +15,6 @@ base on netty.
如何使用
-------
-###maven依赖(1.1.6,2016-02-04 released)
-
-
- com.foxinmy
- weixin4j-server
- 1.1.6
-
###编写服务启动类
明文模式并总是调试输出微信请求信息的服务启动类.
diff --git a/weixin4j-server/src/main/java/com/foxinmy/weixin4j/exception/WeixinException.java b/weixin4j-server/src/main/java/com/foxinmy/weixin4j/exception/WeixinException.java
index f3222b46..217e4f69 100644
--- a/weixin4j-server/src/main/java/com/foxinmy/weixin4j/exception/WeixinException.java
+++ b/weixin4j-server/src/main/java/com/foxinmy/weixin4j/exception/WeixinException.java
@@ -1,7 +1,7 @@
package com.foxinmy.weixin4j.exception;
/**
- * 调用微信接口抛出的异常
+ * 微信异常
*
* @className WeixinException
* @author jy.hu
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 44a02967..e86c19fc 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
@@ -10,6 +10,7 @@ import java.io.ObjectOutputStream;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.JarURLConnection;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.LinkedList;
@@ -17,6 +18,8 @@ import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import com.foxinmy.weixin4j.exception.WeixinException;
+
/**
* 对class的获取
*
@@ -27,6 +30,8 @@ import java.util.jar.JarFile;
* @see
*/
public final class ClassUtil {
+ private final static String POINT = ".";
+ private final static String CLASS = ".class";
/**
* 获取某个包下所有的class信息
@@ -36,21 +41,25 @@ public final class ClassUtil {
* @return
*/
public static List> getClasses(String packageName)
- throws RuntimeException {
- String packageFileName = packageName.replace(".", File.separator);
+ throws WeixinException {
+ String packageFileName = packageName.replace(POINT, File.separator);
URL fullPath = getDefaultClassLoader().getResource(packageFileName);
String protocol = fullPath.getProtocol();
if (protocol.equals(ServerToolkits.PROTOCOL_FILE)) {
- File dir = new File(fullPath.getPath());
- return findClassesByFile(dir, packageName);
+ try {
+ File dir = new File(fullPath.toURI());
+ return findClassesByFile(dir, packageName);
+ } catch (URISyntaxException e) {
+ throw new WeixinException(e);
+ }
} else if (protocol.equals(ServerToolkits.PROTOCOL_JAR)) {
try {
return findClassesByJar(
((JarURLConnection) fullPath.openConnection())
.getJarFile(),
- packageFileName);
+ packageName);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WeixinException(e);
}
}
return null;
@@ -70,18 +79,18 @@ public final class ClassUtil {
File[] files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
- return file.isDirectory() || file.getName().endsWith(".class");
+ return file.isDirectory() || file.getName().endsWith(CLASS);
}
});
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
- classes.addAll(findClassesByFile(file, packageName + "."
+ classes.addAll(findClassesByFile(file, packageName + POINT
+ file.getName()));
} else {
try {
- classes.add(Class.forName(packageName + "."
- + file.getName().replace(".class", "")));
+ classes.add(Class.forName(packageName + POINT
+ + file.getName().replace(CLASS, "")));
} catch (ClassNotFoundException e) {
;
}
@@ -113,12 +122,12 @@ public final class ClassUtil {
if (!entryName.startsWith(packageName)) {
continue;
}
- if (!entryName.endsWith(".class")) {
+ if (!entryName.endsWith(CLASS)) {
continue;
}
try {
- classes.add(Class.forName(entryName.replaceAll("/", ".")
- .replace(".class", "")));
+ classes.add(Class.forName(entryName.replace(File.separator,
+ POINT).replace(CLASS, "")));
} catch (ClassNotFoundException e) {
;
}
@@ -126,7 +135,7 @@ public final class ClassUtil {
return classes;
}
- public static Object deepClone(Object obj) throws RuntimeException {
+ public static Object deepClone(Object obj) throws WeixinException {
ByteArrayOutputStream bos = null;
ObjectOutputStream oos = null;
ByteArrayInputStream bis = null;
@@ -139,9 +148,9 @@ public final class ClassUtil {
ois = new ObjectInputStream(bis);
return ois.readObject();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WeixinException(e);
} catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
+ throw new WeixinException(e);
} finally {
try {
if (bos != null) {
@@ -203,8 +212,7 @@ public final class ClassUtil {
return cl;
}
- public static void main(String[] args) {
- System.err
- .println(getClasses("com.foxinmy.weixin4j.qy.event"));
+ public static void main(String[] args) throws WeixinException {
+ System.err.println(getClasses("com.foxinmy.weixin4j.qy.event"));
}
}