DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

The Latest Languages Topics

article thumbnail
Migrating Sencha EXTJS to ReactJS
Migrate from Sencha EXTJS to ReactJS in a few, simple steps.
October 14, 2019
by Shital Agarwal
· 10,280 Views · 3 Likes
article thumbnail
Migrating a Vue.js App to Vuex
Curious about Vue's application data store? Read on to learn how to move your exiting Vue.js project to Vuex, and get an expert's opinion on what this does.
Updated February 4, 2020
by Anthony Gore CORE
· 9,547 Views · 5 Likes
article thumbnail
Migrate Serialized Java Objects with XStream and XMT
Java serialization is convenient to store the state of Java objects. However, there are some drawbacks of serialized data: It is not human-readable. It is Java-specific and is not exchangeable with other programming languages. It is not migratable if fields of the associated Java class have been changed. These drawbacks make Java serialization not a practical approach to storing object states for real-world projects. In a product developed recently, we use XStream to serialize/deserialize Java objects, which solves the first and second problems. The third problem is addressed with XMT, an open source tool developed by us to migrate XStream serialized XMLs. This article introduces this tool with some examples. Computer Languages Need to be Simplified So many of the issues that we all run into when we are working on converting computer languages into something that can be better understood by human beings is the fact that computer languages need to be simplified if possible. These languages are great for the computers that speak back and forth with one another, but they don’t necessarily work out as well when humans try to become involved with them. Many humans end up confused and unable to make much progress at all on getting these systems cleared up. Thus, it is necessary to get them cleaned up and made more usable. There are people who are actively working on this problem right now, but in the meantime, we may simply have to deal with computers that can’t do everything we would like for them to do. XStream deserialization problem when class is evolved Assume a Task class below with a prioritized field indicating whether it is a prioritized task: package example; public class Task { public boolean prioritized; } With XStream, we can serialize objects of this class to XML like below: import com.thoughtworks.xstream.XStream; public class Test { public static void main(String args[]) { Task task = new Task(); task.prioritized = true; String xml = new XStream().toXML(task); saveXMLToFileOrDatabase(xml); } private static void saveXMLToFileOrDatabase(String xml) { // save XML to file or database here } } The resulting XML will be: true And you can deserialize the XML to get back task object: import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; public class Test { public static void main(String args[]) { String xml = readXMLFromFileOrDatabase(); Task task = (Task) new XStream(new DomDriver()).fromXML(xml); } private static String readXMLFromFileOrDatabase() { // read XML from file or database here } } Everything is fine. Now we find that a prioritized flag is not enough, so we enhance the Task class to be able to distinguish between high priority, medium priority and low priority: package example; public class Task { enum Priority {HIGH, MEDIUM, LOW} public Priority priority; } However, deserialization of previously saved XML is no longer possible since the new Task class is not compatible with the previous version. How does XMT Address the Problem XMT comes to the rescue: it introduces the class VersionedDocument to version serialized XMLs and handles the migration. With XMT, serialization of task object can be written as: package example; import com.pmease.commons.xmt.VersionedDocument; public class Test { public static void main(String args[]) { Task task = new Task(); task.prioritized = true; String xml = VersionedDocument.fromBean(task).toXML(); saveXMLToFileOrDatabase(xml); } private static void saveXMLToFileOrDatabase(String xml) { // save XML to file or database here } } For task class of the old version, the resulting XML will be: true Compared with the XML generated previously with XStream, an additional attribute version is added to the root element indicating the version of the XML. The value is set to "0" unless there are migration methods defined in the class as we will introduce below. When Task class is evolved to use enum based priority field, we add a migrated method like the below: package example; import java.util.Stack; import org.dom4j.Element; import com.pmease.commons.xmt.VersionedDocument; public class Task { enum Priority {HIGH, MEDIUM, LOW} public Priority priority; @SuppressWarnings("unused") private void migrate1(VersionedDocument dom, Stack versions) { Element element = dom.getRootElement().element("prioritized"); element.setName("priority"); if (element.getText().equals("true")) element.setText("HIGH"); else element.setText("LOW"); } } Migration methods need to be declared as a private method with the name in the form of "migrateXXX", where "XXX" is a number indicating the current version of the class. Here method "migrate1" indicates that the current version of the Task class is of "1", and the method migrates the XML from version "0" to "1". The XML to be migrated is passed as a VersionedDocument object which implements the dom4j Document interface and you may use dom4j to migrate it to be compatible with the current version of the class. In this migration method, we read back the "prioritized" element of version "0", rename it as "priority", and set the value as "HIGH" if the task is originally a prioritized task; otherwise, set the value as "LOW". With this migration method defined, you can now safely deserialize the task object from XML: package example; import com.pmease.commons.xmt.VersionedDocument; public class Test { public static void main(String args[]) { String xml = readXMLFromFileOrDatabase(); Task task = (Task) VersionedDocument.fromXML(xml).toBean(); } private static String readXMLFromFileOrDatabase() { // read XML from file or database here } } The deserialization works not only for XML of the old version but also for XML of the new version. At deserialization time, XMT compares the version of the XML (recorded in the version attribute as we mentioned earlier) with the current version of the class (maximum suffix number of various migrate methods), and runs applicable migrate methods one by one. In this case, if an XML of version "0" is read, method migrate1 will be called; if an XML of version "1" is read, no migration methods will be called since it is already up to date. As the class keeps evolving, more migration methods can be added to the class by increasing the suffix number of the latest migration method. For example, let's further enhance our Task class so that the priority field is taking a numeric value ranging from "1" to "10". We add another migrate method to the Task class to embrace the change: @SuppressWarnings("unused") private void migrate2(VersionedDocument dom, Stack versions) { Element element = dom.getRootElement().element("priority"); if (element.getText().equals("HIGH")) element.setText("10"); else if (element.getText().equals("MEDIUM")) element.setText("5"); else element.setText("1"); } This method only handles the migration from version "1" to version "2", and we do not need to care about version "0" anymore, since the XML of version "0" will first be migrated to version "1" by calling the method migrate1 before running this method. With this change, you will be able to deserialize the task object from XML of the current version and any previous versions. This article demonstrates the idea of how to migrate field change of classes. XMT can handle many complicated scenarios, such as migrating data defined in multiple tiers of class hierarchy, addressing class hierarchy change, etc. For more information of XMT, please visit http://wiki.pmease.com/display/xmt/Documentation+Home
August 13, 2022
by Robin Shen
· 19,172 Views · 1 Like
article thumbnail
Microsoft Azure Key Vault Service
Azure Key Vault is a Key Management system that can be used. The encryption keys to encrypt your data are simple to create and manage.
February 3, 2023
by Sardar Mudassar Ali Khan
· 4,133 Views · 1 Like
article thumbnail
Microservices: Quarkus vs Spring Boot
In the era of containers (the ''Docker Age'') Java is still on top, but which is better? Spring Boot or Quarkus?
Updated October 13, 2021
by Ualter Junior CORE
· 143,517 Views · 42 Likes
article thumbnail
Micronaut JPA Application Performance in AWS Lambda
How to deploy a Micronaut application using GET, PUT, and POST, and how its performance compares to when it's deployed with JVM runtime vs. as a native language.
September 9, 2021
by Amrut Prabhu
· 4,213 Views · 2 Likes
article thumbnail
Maven Plugin Testing in a Modern Way - Part VI
In this series on Maven plugin testing, we will take a deeper look how we can define profile(s) for a Maven call to be used.
October 12, 2020
by Karl Heinz Marbaise
· 4,124 Views · 1 Like
article thumbnail
Maven Plugin Testing In a Modern Way Part IV
In this part fo our series, we will take a deeper look into which goals will run for each test case and how we can change that.
September 17, 2020
by Karl Heinz Marbaise
· 5,452 Views · 2 Likes
article thumbnail
Make Windows Green Again (Part 4)
The quest to bring Linux to Windows continues. Let's tackle an error caused by mismatched tech, namely getting the distro to run on something other than VMware.
February 24, 2017
by Hannes Kuhnemund
· 4,228 Views · 2 Likes
article thumbnail
Local Microservices: First-Class Procedures
In this post, a microservices expert considers local (pass by reference) microservices and their impact on development.
June 21, 2019
by Daniel Sagenschneider CORE
· 8,448 Views · 6 Likes
article thumbnail
List of Dot Net Interview Questions
NET is a computer framework that programmers use to create various applications. To know more about the .NET framework, keep reading this article and prepare.
November 3, 2022
by Shailendra Chauhan
· 4,179 Views · 1 Like
article thumbnail
Linked List Popular Problems Vol. 1
This article will show how to solve three popular linked list problems: Linked List Cycle, Middle of the Linked List, and Remove Duplicates from Sorted List.
November 17, 2022
by Sergei Golitsyn
· 9,871 Views · 3 Likes
article thumbnail
Big Data Case Study: Zhihu's 1.3 Trillion Rows of Data, Milliseconds of Response Time
1.3 trillion rows of data, milliseconds of response time.
September 4, 2019
by Xiaoguang Sun
· 22,176 Views · 15 Likes
article thumbnail
Kotlin Was Predicted to Overtake Java by December 2018. What Happened?
In 2018, the Realm Report predicted that Kotlin, a cross-platform programming language, would overtake Java by the end of the year. Was the forecast accurate?
Updated July 24, 2022
by Tom Smith CORE
· 7,249 Views · 2 Likes
article thumbnail
Kick the Tires: Rust Crash Course Lesson One Exercise Solutions
In the last post, we gave you some homework. Today, we go over the answers to those questions, explaining the Rust code along the way.
October 30, 2018
by Michael Snoyman CORE
· 7,324 Views · 1 Like
article thumbnail
July in Security: SQL Injection, DevSecOps, and Spring Boot
Here's the best of security from July as decided by you, the awesome DZone readership, and a few other cybersecurity items of interest.
August 7, 2017
by Jordan Baker
· 4,932 Views · 6 Likes
article thumbnail
July in Performance: SQL, Java Memory, and Python Performance
These articles have performed so well that we thought we'd give them an encore. Check out Dzone's best Performance articles from July, plus a few more items of interest.
July 25, 2017
by Jordan Baker
· 4,222 Views · 2 Likes
article thumbnail
Journey to Containers - Part III
In the third part of this series, we dive into the deployment of an application and the configuration of Kubernetes.
January 22, 2019
by Ajay Kanse CORE
· 9,334 Views · 10 Likes
article thumbnail
JEP 355 Text Blocks in JDK 13
Check out one of the more exciting features from JDK 13 — text blocks!
October 7, 2019
by Mohamed Sanaulla CORE
· 8,712 Views · 2 Likes
article thumbnail
JDK 14: CMS GC Is OBE
JDK 14 Early Access Build #23 is now available.
November 19, 2019
by Dustin Marx
· 36,381 Views · 6 Likes
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • ...
  • Next

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: