• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeserializeBeanInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.fastjson.util.DeserializeBeanInfo的典型用法代码示例。如果您正苦于以下问题:Java DeserializeBeanInfo类的具体用法?Java DeserializeBeanInfo怎么用?Java DeserializeBeanInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeserializeBeanInfo类属于com.alibaba.fastjson.util包,在下文中一共展示了DeserializeBeanInfo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: JavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public JavaBeanDeserializer(ParserConfig config, Class<?> clazz, Type type) {
    this.feildDeserializerMap = new IdentityHashMap();
    this.fieldDeserializers = new ArrayList();
    this.sortedFieldDeserializers = new ArrayList();
    this.clazz = clazz;
    this.beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
    for (FieldInfo fieldInfo : this.beanInfo.getFieldList()) {
        addFieldDeserializer(config, clazz, fieldInfo);
    }
    for (FieldInfo fieldInfo2 : this.beanInfo.getSortedFieldList()) {
        this.sortedFieldDeserializers.add((FieldDeserializer) this.feildDeserializerMap.get(fieldInfo2.getName().intern()));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:JavaBeanDeserializer.java


示例2: Context

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public Context(String className, ParserConfig config, DeserializeBeanInfo beanInfo, int initVariantIndex) {
    this.className = className;
    this.clazz = beanInfo.getClazz();
    this.variantIndex = initVariantIndex;
    this.beanInfo = beanInfo;
    this.fieldInfoList = new ArrayList(beanInfo.getFieldList());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:ASMDeserializerFactory.java


示例3: Context

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public Context(String className, ParserConfig config, DeserializeBeanInfo beanInfo, int initVariantIndex){
    this.className = className;
    this.clazz = beanInfo.getClazz();
    this.variantIndex = initVariantIndex;
    this.beanInfo = beanInfo;
    fieldInfoList = new ArrayList<FieldInfo>(beanInfo.getFieldList());
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:8,代码来源:ASMDeserializerFactory.java


示例4: gen

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
@Override
public void gen() throws IOException {
    beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
    genClassName = clazz.getSimpleName() + "GenDecoder";

    print("package ");
    print(clazz.getPackage().getName());
    println(";");
    println();

    println("import java.lang.reflect.Type;");
    println();

    println("import com.alibaba.fastjson.parser.DefaultJSONParser;");
    println("import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask;");
    println("import com.alibaba.fastjson.parser.ParserConfig;");
    println("import com.alibaba.fastjson.parser.Feature;");
    println("import com.alibaba.fastjson.parser.JSONLexerBase;");
    println("import com.alibaba.fastjson.parser.JSONToken;");
    println("import com.alibaba.fastjson.parser.ParseContext;");
    println("import com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer;");
    println("import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;");
    println();

    print("public class ");
    print(genClassName);
    print(" extends ASMJavaBeanDeserializer implements ObjectDeserializer {");
    incrementIndent();
    println();

    genConstructor();

    genCreateInstance();

    genDeserialze();

    endClass();
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:DeserializerGen.java


示例5: createJavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public ObjectDeserializer createJavaBeanDeserializer(ParserConfig config, Class<?> clazz, Type type)
                                                                                                    throws Exception {
    if (clazz.isPrimitive()) {
        throw new IllegalArgumentException("not support type :" + clazz.getName());
    }

    String className = getGenClassName(clazz);

    ClassWriter cw = new ClassWriter();
    cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, className, getType(ASMJavaBeanDeserializer.class), null);

    DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);

    _init(cw, new Context(className, config, beanInfo, 3));
    _createInstance(cw, new Context(className, config, beanInfo, 3));
    _deserialze(cw, new Context(className, config, beanInfo, 4));
    _deserialzeArrayMapping(cw, new Context(className, config, beanInfo, 4));
    byte[] code = cw.toByteArray();

    // org.apache.commons.io.IOUtils.write(code, new java.io.FileOutputStream(
    // "/usr/alibaba/workspace-3.7/fastjson-asm/target/classes/"
    // + className + ".class"));

    Class<?> exampleClass = classLoader.defineClassPublic(className, code, 0, code.length);

    Constructor<?> constructor = exampleClass.getConstructor(ParserConfig.class, Class.class);
    Object instance = constructor.newInstance(config, clazz);

    return (ObjectDeserializer) instance;
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:31,代码来源:ASMDeserializerFactory.java


示例6: JavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public JavaBeanDeserializer(ParserConfig config, Class<?> clazz, Type type){
    this.clazz = clazz;
    this.type = type;

    beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);

    for (FieldInfo fieldInfo : beanInfo.getFieldList()) {
        addFieldDeserializer(config, clazz, fieldInfo);
    }
}
 
开发者ID:baogongtc,项目名称:android_http_demo,代码行数:11,代码来源:JavaBeanDeserializer.java


示例7: getBeanInfo

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public DeserializeBeanInfo getBeanInfo() {
    return this.beanInfo;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ASMDeserializerFactory.java


示例8: createJavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public ObjectDeserializer createJavaBeanDeserializer(ParserConfig config, Class<?> clazz, Type type) throws Exception {
    Exception ex;
    Throwable th;
    if (clazz.isPrimitive()) {
        throw new IllegalArgumentException("not support type :" + clazz.getName());
    }
    String className = getGenClassName(clazz);
    ClassWriter cw = new ClassWriter();
    cw.visit(49, 33, className, "com/alibaba/fastjson/parser/deserializer/ASMJavaBeanDeserializer", null);
    DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
    _init(cw, new Context(className, config, beanInfo, 3));
    _createInstance(cw, new Context(className, config, beanInfo, 3));
    _deserialze(cw, new Context(className, config, beanInfo, 4));
    _deserialzeArrayMapping(cw, new Context(className, config, beanInfo, 4));
    byte[] code = cw.toByteArray();
    if (JSON.DUMP_CLASS != null) {
        FileOutputStream fos = null;
        try {
            FileOutputStream fos2 = new FileOutputStream(JSON.DUMP_CLASS + File.separator + className + ".class");
            try {
                fos2.write(code);
                if (fos2 != null) {
                    fos2.close();
                }
            } catch (Exception e) {
                ex = e;
                fos = fos2;
                try {
                    System.err.println("FASTJSON dump class:" + className + "失败:" + ex.getMessage());
                    if (fos != null) {
                        fos.close();
                    }
                    return (ObjectDeserializer) this.classLoader.defineClassPublic(className, code, 0, code.length).getConstructor(new Class[]{ParserConfig.class, Class.class}).newInstance(new Object[]{config, clazz});
                } catch (Throwable th2) {
                    th = th2;
                    if (fos != null) {
                        fos.close();
                    }
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                fos = fos2;
                if (fos != null) {
                    fos.close();
                }
                throw th;
            }
        } catch (Exception e2) {
            ex = e2;
            System.err.println("FASTJSON dump class:" + className + "失败:" + ex.getMessage());
            if (fos != null) {
                fos.close();
            }
            return (ObjectDeserializer) this.classLoader.defineClassPublic(className, code, 0, code.length).getConstructor(new Class[]{ParserConfig.class, Class.class}).newInstance(new Object[]{config, clazz});
        }
    }
    return (ObjectDeserializer) this.classLoader.defineClassPublic(className, code, 0, code.length).getConstructor(new Class[]{ParserConfig.class, Class.class}).newInstance(new Object[]{config, clazz});
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:60,代码来源:ASMDeserializerFactory.java


示例9: createJavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public ObjectDeserializer createJavaBeanDeserializer(Class<?> clazz, Type type) {
    boolean asmEnable = this.asmEnable;
    if (asmEnable) {
        Class<?> superClass = clazz;
        while (Modifier.isPublic(superClass.getModifiers())) {
            superClass = superClass.getSuperclass();
            if (superClass != Object.class) {
                if (superClass == null) {
                    break;
                }
            }
            break;
        }
        asmEnable = false;
    }
    if (clazz.getTypeParameters().length != 0) {
        asmEnable = false;
    }
    if (asmEnable && this.asmFactory != null && this.asmFactory.isExternalClass(clazz)) {
        asmEnable = false;
    }
    if (asmEnable) {
        asmEnable = ASMUtils.checkName(clazz.getName());
    }
    if (asmEnable) {
        if (clazz.isInterface()) {
            asmEnable = false;
        }
        DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
        if (beanInfo.getFieldList().size() > 200) {
            asmEnable = false;
        }
        if (beanInfo.getDefaultConstructor() == null && !clazz.isInterface()) {
            asmEnable = false;
        }
        for (FieldInfo fieldInfo : beanInfo.getFieldList()) {
            if (fieldInfo.isGetOnly()) {
                asmEnable = false;
                break;
            }
            Class<?> fieldClass = fieldInfo.getFieldClass();
            if (!Modifier.isPublic(fieldClass.getModifiers())) {
                asmEnable = false;
                break;
            }
            if (fieldClass.isMemberClass() && !Modifier.isStatic(fieldClass.getModifiers())) {
                asmEnable = false;
            }
            if (!ASMUtils.checkName(fieldInfo.getMember().getName())) {
                asmEnable = false;
            }
        }
    }
    if (asmEnable && clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers())) {
        asmEnable = false;
    }
    if (!asmEnable) {
        return new JavaBeanDeserializer(this, clazz, type);
    }
    try {
        return this.asmFactory.createJavaBeanDeserializer(this, clazz, type);
    } catch (NoSuchMethodException e) {
        return new JavaBeanDeserializer(this, clazz, type);
    } catch (ASMException e2) {
        return new JavaBeanDeserializer(this, clazz, type);
    } catch (Exception e3) {
        throw new JSONException("create asm deserializer error, " + clazz.getName(), e3);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:70,代码来源:ParserConfig.java


示例10: getBeanInfo

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public DeserializeBeanInfo getBeanInfo() {
    return beanInfo;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:4,代码来源:ASMDeserializerFactory.java


示例11: createJavaBeanDeserializer

import com.alibaba.fastjson.util.DeserializeBeanInfo; //导入依赖的package包/类
public ObjectDeserializer createJavaBeanDeserializer(Class<?> clazz, Type type) {
    boolean asmEnable = this.asmEnable;
    if (asmEnable) {
        Class<?> superClass = clazz;

        for (;;) {
            if (!Modifier.isPublic(superClass.getModifiers())) {
                asmEnable = false;
                break;
            }

            superClass = superClass.getSuperclass();
            if (superClass == Object.class || superClass == null) {
                break;
            }
        }
    }

    if (clazz.getTypeParameters().length != 0) {
        asmEnable = false;
    }

    if (asmFactory.isExternalClass(clazz)) {
        asmEnable = false;
    }

    if (asmEnable) {
        if (clazz.isInterface()) {
            asmEnable = false;
        }
        DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
        if (beanInfo.getFieldList().size() > 200) {
            asmEnable = false;
        }

        Constructor<?> defaultConstructor = beanInfo.getDefaultConstructor();
        if (defaultConstructor == null && !clazz.isInterface()) {
            asmEnable = false;
        }

        for (FieldInfo fieldInfo : beanInfo.getFieldList()) {
            if (fieldInfo.isGetOnly()) {
                asmEnable = false;
                break;
            }

            Class<?> fieldClass = fieldInfo.getFieldClass();
            if (!Modifier.isPublic(fieldClass.getModifiers())) {
                asmEnable = false;
                break;
            }

            if (fieldClass.isMemberClass() && !Modifier.isStatic(fieldClass.getModifiers())) {
                asmEnable = false;
            }
        }
    }

    if (asmEnable) {
        if (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers())) {
            asmEnable = false;
        }
    }

    if (!asmEnable) {
        return new JavaBeanDeserializer(this, clazz, type);
    }

    try {
        return asmFactory.createJavaBeanDeserializer(this, clazz, type);
        // } catch (VerifyError e) {
        // e.printStackTrace();
        // return new JavaBeanDeserializer(this, clazz, type);
    } catch (NoSuchMethodException ex) {
        return new JavaBeanDeserializer(this, clazz, type);
    } catch (ASMException asmError) {
        return new JavaBeanDeserializer(this, clazz, type);
    } catch (Exception e) {
        throw new JSONException("create asm deserializer error, " + clazz.getName(), e);
    }
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:82,代码来源:ParserConfig.java



注:本文中的com.alibaba.fastjson.util.DeserializeBeanInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DropwizardMetricServices类代码示例发布时间:2022-05-22
下一篇:
Java ForwardingServerCall类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap