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. 

  • 相关阅读:
    [国家集训队]单选错位
    [USACO08DEC]Patting Heads S 轻拍牛头
    [SCOI2007]压缩 题解
    Json常用的转换
    cookie的读入和读出
    SQLHelp帮助类
    使用FFmpeg生成HLS视频
    如何选择HLS视频码流
    MacOS下的IntelliJ IDEA & Android Studio 通用配置
    在Windows上配置Django + WSGI
  • 原文地址:https://www.cnblogs.com/daition/p/1773158.html
Copyright © 2011-2022 走看看