Using Standard Java Serialization for Externalizable Classes Using XStream

I use XStream as part of my application to serialize objects. For one use case, I have to serialize some objects that implement the Externalizable interface. For my use case, I would like to serialize them using my own Java serialization.

I found a link on the Internet http://old.nabble.com/How-to-remove-Externalizable-Converter-td22747484.html that helped me solve this problem and started using Reflection Converter for Externalizable objects.

When testing the application, I see that the application spends a lot of time (10 seconds) on the converter code during simultaneous access. I see that the problem is with the buildMap FieldDictionary method.

I was wondering if there is a better way to solve my original problem? Is the performance of the Reflection converter expected to be poor if there is a high parallel environment?

To give extra context to the environment. This is a web application, and serialization occurs during request processing, and the application can have 100 simultaneous threads.

I really appreciate any help / advice on this.

+4
source share
1 answer

This is technically not the answer. But I hope this helps anyway.

When creating a Java Swing-based desktop application that was used to model molecular research, we produced a series of very complex and interconnected object plots on disk.

Even after we made our way on issues related to external and serializable communication, we had to abandon the whole approach and start a new one, since Java serialization is very sensitive to the structure of the object / name, etc. This means that innocent model refactoring led to production disruptions when users tried to load old serialized models.

In the end, we created a data structure compatible with the data warehouse (without strong links to other nodes on the chart) and serialized this structure. It was much simpler, fewer errors, and much faster than serializing and deserializing the original graph. It also meant that we could reorganize / modify our domain graph objects at our discretion if the adapters (the components that converted the Domain objects to DataStore objects) were properly updated.

0
source

Source: https://habr.com/ru/post/1432176/


All Articles