mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 提供方法方便第三方类使用 XStreamTransformer进行序列化, 以及支持XStream 1.4.18 以上增加安全许可
This commit is contained in:
parent
82c1e9a120
commit
f936325b0c
@ -54,7 +54,22 @@ public class XStreamTransformer {
|
||||
public static void register(Class<?> clz, XStream xStream) {
|
||||
CLASS_2_XSTREAM_INSTANCE.put(clz, xStream);
|
||||
}
|
||||
/**
|
||||
* 注册第三方的该类及其子类.
|
||||
* 便利第三方类使用 XStreamTransformer进行序列化, 以及支持XStream 1.4.18 以上增加安全许可
|
||||
* @param clz 要注册的类
|
||||
*/
|
||||
public static void registerExtendClass(Class<?> clz){
|
||||
XStream xstream = XStreamInitializer.getInstance();
|
||||
|
||||
Class<?>[] innerClz = getInnerClasses(clz);
|
||||
xstream.processAnnotations(clz);
|
||||
xstream.processAnnotations(innerClz);
|
||||
xstream.allowTypes(new Class[]{clz});
|
||||
xstream.allowTypes(innerClz);
|
||||
|
||||
register(clz, xstream);
|
||||
}
|
||||
/**
|
||||
* 会自动注册该类及其子类.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user