[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: [CDO] CDOSavePoint and rollback question

Sebastian,

Comments below...


Sebastian Paul schrieb:
Hello Kai,
Yes, that is what I meant. I am designing my app at the moment for single user, but keep a multi user setup in the back of my mind.
CDO makes this very easy, but it also has many advantages for single user applications.
I use the rollback for example to undo all changes of a bigger model that is modified by a large wizard dialog when the cancel button is pressed.
I exercised a small example with a CDO model, a view that displays model data and a wizard that adds or modifies data. As you certainly do, my wizard creates a CDOSavePoint hen it is initialized. When the wizard is canceled, the transaction is rolled back to the savepoint. When the wizard performs finish, the transaction is committed. As wizard modifications of the model would trigger UI updates in the view, I open a separate transaction from where I retrieve model objects that are passed to the wizard. All modifications are isolated until the wizard commits the transaction. After the wizard dialog is closed, the wizard transaction is closed, regardless of the dialog's return code.
That is certainly a good design!
It looks similar to the one I suggest in the eDine example applications:
http://thegordian.blogspot.com/2009/04/modeling-goes-enterprise.html


My application used CDO with a JVMConnector and MemStore. Committing a transaction does not mean that the document is actually saved.
If your editor contains a ResourceSet that is associated with one or more CDOTransactions I suggest that you register an IListener with these transactions to receive these IEvents:

You can react by firing DIRTY events from the editor so that the "*" disappears.

As an alternative or addition you can hook up a CDOTransactionHandler that gives access to more finegrained transaction and commit/rollback info with the possibility to veto some of the events. See the implementations that we provide for examples.

Btw. the opposite direction should work out of the box: Workbench save action causes commit on all CDOTransactions associated with the editors ResourceSet.

In applications where commit is equivalent to saving the document, above approach would not be appropriate. A real nested, isolated transaction would be fine for that, but I don't think CDO will support that.
Some time ago we decided not to support nested transactions. I can't remember the reasons anymore. I think it was related with difficulties to come up with a concise API for this.

Cheers
/Eike

----
http://thegordian.blogspot.com


JPEG image