使用 LCDS 将不可变的 Java 类序列化为 ActionScript
我有一个复杂的对象,该对象由 LCDS DataServices 数据管理进行管理,并使用自定义组装程序进行创建/更新等。绝大多数对象层次结构都已正确序列化/反序列化,但在序列化不可变的 java 类时我遇到了障碍。
在仅使用 java 的世界中,我将使用 java writeReplace 和 readResolve 方法,如这个优秀博客所描述的: http://lingpipe-blog.com/2009/08/10/serializing-immutable-singletons-serialization-proxy/
这就是我最初编写 java 类的方式,期望 livecycle 调用 writeReplace 方法并及时用可变类替换不可变类以进行序列化。然而,lcds 似乎对 writeReplace 方法一无所知,只会调用 readExternal/writeExternal 而忽略 readResolve 和 writeReplace。
首先,其他人是否发现了这种情况,或者我错过了什么?
其次,有没有人想出一种适当的方法将动作脚本类反序列化为不可变对象或单例?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是一个常见问题。 Adobe 建议具有不可变属性的 Java 类型实现Externalizable,而等效的 ActionScript 类型实现 IExternalizable。
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.
目前没有处理 writeReplace 和 readResolve 的计划,但您可以提出功能请求 http:// /bugs.adobe.com/jira/browse/BLZ
在实现自定义序列化时,请注意,您将失去一些好处,例如压缩数字和识别重复字符串。一个想法是查看实际的序列化机制并进行相应的修改。
但是,如果您只是对序列化只读属性感兴趣,请查看此处:http://bugs.adobe.com/jira/browse/BLZ-427
There is no plan to handle the writeReplace and readResolve, but you can ask for a feature request http://bugs.adobe.com/jira/browse/BLZ
When implementing your custom serialization take care that you will lose some benefits like compressing numbers and identifying duplicate strings. One idea is to take a look on the actual serialization mechanism and to modify it accordingly.
However, if you are interested just in serializing the read only properties this enhancement was implemented in the BlazeDS, take a look here: http://bugs.adobe.com/jira/browse/BLZ-427
我发现的最短和最全面的答案: http://expertdevelopers.blogspot.com /2010/07/serialized-vs-externalizable.html
shortest and most comprehensive answer i found: http://expertdevelopers.blogspot.com/2010/07/serializable-vs-externalizable.html