I used XStream many years ago, but I see that the libraries is not updated since 2008 (latest news). Is there now a more modern and up to dates Java XML serialization library?
In order of preference, relevancy and activity:
Visit the JAXB project's site to check out the tutorial and guide. Have also a look at the original JAXB architecture whitepaper.
The JAXB projet listed above is the reference implementation of the API, and is packaged in by the GlassFish Application Server.
Visit the EclipseLink project's site and read this introductory article to EclipseLink on InfoQ, and see Blaise Doughan's answer about MOXy.
EclipseLink originated from Oracle's TopLink and is now open source, managed by the Eclipse Foundation, and used in a number of Eclipse-based products.
Yes, XStream, because it's actually been updated in 2011 with a major update and 2 service releases since you asked, so it seems well-maintained and a pretty good contender used by mature projects. Don't forget to check what's new in version 1.4.x.
Visit the XStream project's site and its tutorial to compare.
Visit the XmlBeans project's site.
XmlBeans is a well-tested project that has been around for a while.
Visit the JiBX project's site, follow the tutorial and guide.
JiBX might be a simpler alternative if you don't like the complexity of XmlBeans or even JAXB.
Note: I'm the EclipseLink JAXB (MOXy) lead, and a member of the JAXB (JSR-222) expert group.
You are correct in considering a libraries release frequency when making a software choice. There are many reasons for a new product release:
Another important aspect of evaluating any open source project is the number of active committers. Sites like ohloh.net are useful for that:
JAXB (JSR-222)
JAXB is more than an implementation, it is a standard that is developed through the Java Community Process (JCP). There have been participants from such object-to-XML libraries as XML Beans (BEA), EMF (IBM), TopLink (Oracle), etc. Because JAXB is part of Java EE it is available in every application server: WebLogic, GlassFish, WebSphere, JBoss, etc.
JAXB Offers:
EclipseLink JAXB (MOXy)
MOXy is a JAXB implementation that offers many useful extensions, including:
True Object to XML Mapping by Leveraging XPath
XPath based mapping allows you to start with both Java classes and an XML schema and map the two together.
Mapping File for Handling 3rd Party Classes
In the current JAXB spec the metadata is supplied via annotations. This can be problematic to use with 3rd party classes that cannot be modified. This is why MOXy offers a way to specify the mappings via XML:
Extensions for Mapping JPA Entities
Often times you need to do more with your Java objects then just map then to XML. You may also need to persist them to a database. This means your object model may have additional constraints on it that you need to account for. MOXy offers a number of extensions for this kind of use case:
Comparisons
Below are a couple comparisons I have done comparing JAXB to XStream and Simple:
The fact that something hasn't been updated for 3 years doesn't mean that it is out of date. It might simply mean that there has been no need to update it. If there is no need to change a project, why change it?
Another explanation for the apparent lack of "progress" is that changing library APIs tends to be disruptive to projects that depend on them. This is particularly problematic for projects that combine lots of third-party components and libraries into one Java application.
Looking for alternatives to a library is a good thing, but simply doing this because the library hasn't been updated recently is not. If XStream does what you need, stick with it. Newer doesn't necessarily mean better.
UPDATE - 2019
XStream has been receiving updates with a new release at least once a year since 2011. Refer to the Changes page for details, and look at the activity on the Github repository for the project. As of now, the theory that XStream is not being maintained is (IMO) thoroughly debunked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With