mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 #2861 XStreamInitializer增加自定义加载类的支持方法
This commit is contained in:
parent
df759717cd
commit
46921e0e55
@ -11,7 +11,6 @@ import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||
import com.thoughtworks.xstream.io.xml.XppDriver;
|
||||
import com.thoughtworks.xstream.security.NoTypePermission;
|
||||
import com.thoughtworks.xstream.security.WildcardTypePermission;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
@ -20,6 +19,13 @@ import java.io.Writer;
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
public class XStreamInitializer {
|
||||
|
||||
public static ClassLoader classLoader;
|
||||
|
||||
public static void setClassLoader(ClassLoader classLoaderInfo) {
|
||||
classLoader = classLoaderInfo;
|
||||
}
|
||||
|
||||
private static final XppDriver XPP_DRIVER = new XppDriver() {
|
||||
@Override
|
||||
public HierarchicalStreamWriter createWriter(Writer out) {
|
||||
@ -87,7 +93,10 @@ public class XStreamInitializer {
|
||||
xstream.addPermission(new WildcardTypePermission(new String[]{
|
||||
"me.chanjar.weixin.**", "cn.binarywang.wx.**", "com.github.binarywang.**"
|
||||
}));
|
||||
xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
|
||||
if (null == classLoader) {
|
||||
classLoader = Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
xstream.setClassLoader(classLoader);
|
||||
return xstream;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user