什么是同步2复杂的对象图的状态的最佳方法复杂、对象、状态、方法

2023-09-03 17:28:18 作者:别涉世太深

我有一个复杂的对象图重新present运行调度。 在一个点上,我不得不序列化整个图形到Web界面(通过XML / JSON),让用户可以修改使用一个基于Javascript的甘特图组件的时间表。 在用户完成编辑时,图中的Java /服务器层中的状态都将与修改的状态同步。

I have a complex object graph to represent operation scheduling. At one point, I have to serialize the whole graph to the web UI (via XML/JSON) to let user modify the schedule using a Javascript based gantt chart component. After the user finished editing, the state of the graph in the Java/server layer have to be synchronized with the modified state.

我想请教一下,最好的策略,以实现复杂的对象图,例如这样的状态同步应该如何状态的变化重新presented这样模仿的变化,服务器端可以很容易? 如何将其他人实现这个?

I'd like to ask about the best strategy to implement such state synchronization of complex object graph, e.g. how should the changes of the state represented so that mimicking the changes in the server side can be made easy? How would others implement this?

仅供参考,我目前的技术堆栈:JSF + RichFaces的是,Seam 2.1,在Hibernate 3。 但我认为,解决这个问题可以在其他技术堆栈中使用了。

FYI, my current technology stack: JSF+Richfaces, Seam 2.1, Hibernate 3. But I believe that the solution to this problem can be used in other technology stack too.

推荐答案

我会建议,以避免同步两个图形,但记录的编辑操作为删除节点/插入节点/替换节点操作。发送该操作的服务器,并将其应用到原图。

I would suggest to avoid synchronizing the two graphs but record the edit operations as "Delete Node/Insert Node/Replace Node" operations. Send this operations to the server and apply them to the original graph.

这从一个重写AST(抽象语法树)的想法干。在日食JDT你必须从源一个AST。当重构应用(如重命名方法),它应该是可能创造的变化preVIEW。对于这项工作重写事件(Delte /插入/替换)被记录并应用到AST的副本。据此,preVIEW产生。如果用户接受该事件被应用到原始的AST

This idea stem from rewriting an AST (Abstract Syntax Tree). In eclipse JDT you have an AST from your source. When a refactoring is applied (e.g. rename a method) it should be possible to create a preview of the changes. For this to work rewrite events (Delte/Insert/Replace) are recorded and applied to a copy of the AST. From this the preview is generated. If the user accepts the events are applied to the original AST.

您的问题是在该方式类似,您有开始时相同的,并且应以相同的方式来修改2的对象图。这应该是更容易实现作为一个同步操作,你只需要记录的事件,而用户对矫正图形。

Your problem is similar in that way, that you have two object graphs that start out identical and should be modified in the same way. This should be much easier to implement as an synchronization operation you just have to record the events while the user is modifing the graph.

 
精彩推荐
图片推荐