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. 

  • 相关阅读:
    每周进度及工作量统计——2016.10.06-2016.10.13
    SCRUM站立会议模拟
    java词频统计——web版支持
    每周进度及工作量统计——2016.9.22--2016.9.29
    简易四则运算生成程序——第一次改进后的单元测试
    java词频统计——改进后的单元测试
    第一次通读《构建之法》阅读笔记
    centOS6.5网络配置
    webpack安装
    CommonJS和AMD/CMD
  • 原文地址:https://www.cnblogs.com/daition/p/1773158.html
Copyright © 2011-2022 走看看