Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serializing immutable java classes to actionscript with LCDS

I've got a complex object which is being managed by the LCDS DataServices data management and being created/updated etc using custom assemblers. The vast majority of the object hierarchy is being serialized/deserialized correctly but I've hit a stumbling block when it comes to serializing immutable java classes.

In a java only world I would use the java writeReplace and readResolve methods as this excellent blog describes: http://lingpipe-blog.com/2009/08/10/serializing-immutable-singletons-serialization-proxy/

This is how I originally wrote my java class, expecting livecycle to call the writeReplace method and duly replace the immutable class with a mutable one for serialization. However it would appear that lcds knows nothing of the writeReplace method and will only call readExternal/writeExternal ignoring readResolve and writeReplace.

Firstly, have other people found this to be the case, or am I missing something?

Secondly, has anyone come up with an appropriate method to deserialize actionscript classes into either immutable objects or singletons?

Many thanks

like image 200
Brett Hannah Avatar asked Oct 06 '09 08:10

Brett Hannah


1 Answers

Yes, it's a common problem. Adobe recommend that the Java type that has immutable properties implements Externalizable and the equivalent ActionScript type implements IExternalizable.

like image 58
Graeme Harker Avatar answered Oct 05 '22 23:10

Graeme Harker