zoukankan      html  css  js  c++  java
  • 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. 

  • 相关阅读:
    C# 连接数据库
    MySQL数据类型char与varchar中数字代表的究竟是字节数还是字符数?
    group by与avg(),max(),min(),sum()函数的关系
    MySQL内连接、外连接、交叉连接
    Mysql 插入中文错误:Incorrect string value: 'xE7xA8x8BxE5xBAx8F...' for column 'course' at row 1
    session和token
    session和cookies
    sessionid如何产生?由谁产生?保存在哪里?
    跨域,你需要知道的全在这里
    匈牙利算法模板
  • 原文地址:https://www.cnblogs.com/daition/p/1773158.html
Copyright © 2011-2022 走看看