Reputation: 26809
I have web application with Spring MVC and Webflow. I'm implementing "snapshot" mechanism: Developers by special parameter in the URL can save their current state (page, components states etc.), and then come back to this state in the future.
The state is stored in their disk. To realize this I need to store whole HttpSession - unfortunately not all objects there, are serialized. I use XStream but it generates huge XML (300MB) which makes my tomcat crash during deserializing.
Could you advice other library or way to serialize/save http session with objects not implemented Serializable?
Upvotes: 1
Views: 2072
Reputation: 26713
You could have a look at different serialization strategies of memcached-session-manager.
Upvotes: 1
Reputation: 22672
First approach - create intermediate "session DTOs" layer for objects which needs to be serialized. All "session DTOs" will be serializable and used for serializing session only. Obviously that means quite a lot of code that would copy properties from session DTOs objects to true objects used in the application, but there is a planty of property objects copiers.
Second approach - create Java maps that would store all objects and their properties as a key-value pairs (each object will be another map, that can be embedded inside another map). Then that map will be serialized. Obviously there would be a lot of work involved with copying map structure to actual objecs used in application. This is more or less "hand made Java map based JSON format".
Third approach - try to use JSON instead of XML, parsing should be less resource consuming. I would start with that one.
Upvotes: 4