Jan 10th, 2012, 02:38 AM
Transactions or Server Synchronization?
I'm facing a challenge, where my server (Spring + Jersey for REST) need to have some kind of synchronization mechanism over the model.
For instance, when a Resource changes something in the model, it might not be synced with other resources doing some kind of other operation.
Let's assume I have a main Bean, call it "Tree" that have methods such as insertNode(), getNode(), and removeNode(), and I must make sure these are synced across resources, so not to create an inconsistent model (like if one resource tries to modify a node while another is removing it).
I could, for example, add "synchronized" for each of the methods, but that doesn't seems to be the correct way to resolve such problems, more other, it does not protect me against methods that expose info (like getNode() for example, where the node is been changed outside of the Tree).
What's the correct way to make the server synced with spring?