JAXB and XStream Comparisons

Source: Internet
Author: User
Tags oocl

These two things are inherently different, JAXB is called the OX binding tool, XStream should be counted as a serialization tool, but the OX binding tool will also Marshall and Unmarshall , so this part of serialization is included. The serialization tool does not necessarily need to provide binding functionality. Now that you're all playing with serialization, simply compare the two of them in terms of serialization.

JAXB: Toplink jaxb 10133, which should be the JAXB 1.1 standard (the validation function of the schema is removed)

XStream: 1.3.1

Data length:

type

length

content

Xstraem

351

<com.oocl.frm.ws.sample.Employee>

<name>Liufei</name>

<age>40</age>

<address>

<street>Zhaojiabang</street>

<country>China</country>

<city>Shanghai</city>

<doorNum>789</doorNum>

<empname>afka liu</empname>

</address>

<salary>20000.0</salary>

<isActive>false</isActive>

<sexy>F</sexy>

</com.oocl.frm.ws.sample.Employee>

Toplink JAXB

589 ( The white space has been removed )

<?xml version= "1.0" encoding= "UTF-8"?>

<ns0:employee xsi:schemalocation= "HTTP://WWW.OOCL.COM/FRM/WS/JAXB" xmlns:xs= "Http://www.w3.org/2001/XMLSchema "Xmlns:ns0=" HTTP://WWW.OOCL.COM/FRM/WS/JAXB "xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "><NS0: Name>liufei</ns0:name><ns0:age>40</ns0:age><ns0:salary>20000.0</ns0:salary> <NS0:SEXY>F</NS0:SEXY><NS0:ISACTIVE>FALSE</NS0:ISACTIVE><NS0:ADDRESS><NS0: Street>zhaojiabang</ns0:street><ns0:country>china</ns0:country><ns0:city>shanghai </ns0:city><ns0:doornum>789</ns0:doornum><ns0:empname>afka liu</ns0:empName></ Ns0:address></ns0:employee>

Time: Serialization and deserialization of 1000000 times.

type

serialization (ms

deserialization (ms

Xstraem

90148

135878

Toplink JAXB

34872

56557

Results comparison: Data volume XStream dominant, time performance TopLink JAXB accounted for obvious advantages

Summary (from the point of view of serialization functionality only)

JAXB: Benefits

    • Java Standard
    • less run time than XStream

Disadvantages

    • Inconvenient to use: you need to convert the business object manually into schema object, or you can use the schema object directly as a business object, or as a reflection method.
    • Have certain limitations: Need schema or annotation
    • Slightly larger amount of data

XStream Advantages:

    • Easy to use.
    • Don't need schema, just take it and turn it.
    • Slightly smaller amount of data

Disadvantages:

    • Non-standard
    • Poor time performance

JAXB and XStream Comparisons

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.