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. 

  • 相关阅读:
    New Skateboard
    1127
    一张图看懂开源许可协议,开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
    vim 快捷键绑定
    使用git 上传项目到gitee/github
    Linux进程/线程调度策略与 进程优先级
    【框架】共享内存组设计思路与实现(更新中)
    linux下六大IPC机制【转】
    详解Linux内核红黑树算法的实现
    Linux 内核里的数据结构:红黑树(rb-tree)
  • 原文地址:https://www.cnblogs.com/daition/p/1773158.html
Copyright © 2011-2022 走看看