• JAXB vs XMLBeans


    copy from thread here http://forums.oracle.com/forums/thread.jspa?threadID=708859&tstart=0

    XMLBeans and JAXB 2.0 address the need to work with XML in Java, but with radically different architectures. Each architecture has it's advantages and disadvantages. The downsides to the XMLBean architecture as compared with TopLink JAXB include:



    1) XMLBeans builds a DOM tree behind the generated classes. This means you pay the cost for building a DOM tree and for the domain model classes. When using a SAX parser TopLink JAXB does not construct a DOM, only domain model classes. The unmarshall performance of XMLBeans is slower than TopLink JAXB as XMLBeans has to create many more objects. This also affects overall application performance as you will be generating more garbage than with JAXB.



    2) XMLBean object property get/set is slower than in JAXB because you always have to access the DOM. In JAXB accessor methods just set or get a field of an object. This means application logic that interacts with generated XMLBeans objects will perform slower than with JAXB. The previous comment that "XMl beans are light weighted than JAXB" is not true as JAXB just uses POJOS. For example, here's a getter from the XMLBeans easypro tutorial:



    public java.lang.String getName()

    {

    synchronized (monitor())

    {

    check_orphaned();

    org.apache.xmlbeans.SimpleValue target = null;

    target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(NAME$0, 0);

    if (target == null)

    {

    return null;

    }

    return target.getStringValue();

    }

    }



    3) XMLBeans only supports code generation from a schema. 

    JAXB let's you map your objects to an existing schema. It offers the flexibility to work bottom up, top down, or meet in the middle. When building web services for an existing system meet in the middle mapping is ideal.



    There are various other properties of the XMLBeans architecture but those are the most significant ones. Essentially you're stuck with code gen and the costs associated with an architecture based on a wrapped DOM tree. On the up side, XMLBeans marshalling performance is quite good as it has a DOM tree that is always ready to be marshalled. I'll leave it up to XMLBeans users to describe its other pros. 

  • 相关阅读:
    TP5.1:request请求对象(使用四种方式获取)
    TP5.1:facade静态代理
    php:定义时间跳转到指定页面
    TP5.1:依赖注入、绑定一个类到容器里、绑定一个闭包到容器中
    sql:表中数据全部删除之后,重新插入时,从1开始增加
    通过CSS3实现:鼠标悬停图片360度旋转效果
    TP5.1 配置的获取与设置
    详细讲解:通过composer安装TP5.1(Thinkphp5.1)
    TP5.0: 显示错误信息
    socket2
  • 原文地址:https://www.cnblogs.com/daition/p/1773158.html
Copyright © 2020-2023  润新知