EMF Transactions: Listen for rollbacks / clean up resources [message #423429] |
Tue, 30 September 2008 11:43  |
Eclipse User |
|
|
|
Hi!
I'm currently working on a feature called "model change journal" and I
do have some troubles concerning EMF Transactions and transaction
rollback. Maybe someone can help.
The idea is to provider a user readable high-level journal of model
changes per model object. This journal is for the user only and should
not contain fine grained change notifications (like the ChangeRecorder)
but instead coarse grained user interactions for each model object.
To use this feature, the developer has to explicitely mark each object
during a command execution:
ModelChangeJournal.markAsChanged(EObject object, String description);
The change information is stored in a list and a pre-commit listener
converts them to journal entries (containing a timestamp etc.) and adds
them to the corresponding model object before the transaction is
committed. The change storage is cleared at the end of
transactionAboutToCommit().
The problem is that I cannot clear the change storage when the entire
transaction rolls back! There is no possibility to listen for rollbacks.
As an effect, the change storage stays as is and will be processed when
the next transaction commits which is definitely wrong!
It would be nice if there was a way to get notified about transaction
boundaries, that is
(1) when a transaction starts
(2) when a transaction is about to commit (already possible)
(3) when a transaction has been committed (already possible)
(4) when a transaction has been rolled back
What do you think about that?
Best regards,
Mario
|
|
|
Re: EMF Transactions: Listen for rollbacks / clean up resources [message #423430 is a reply to message #423429] |
Tue, 30 September 2008 12:07   |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Mario,
Today is your lucky day :-D
The recent 1.3 M2 release adds a new listener API to the
TransactionalEditingDomain that gives you exactly the call-backs that
you are asking for:
http://download.eclipse.org/modeling/emf/transaction/javadoc /1.3.0/org/eclipse/emf/transaction/TransactionalEditingDomai nListener.html
To detect rollback, look for an ERROR status (or more severe) in the
Transaction referenced by the event object in the transactionClosed
call-back.
To attach your listener, get the TransactionalEditingDomain.Lifecycle
adapter from your editing domain and (if it isn't null) add the listener
to it.
Cheers,
Christian
Mario Winterer wrote:
> Hi!
>
> I'm currently working on a feature called "model change journal" and I
> do have some troubles concerning EMF Transactions and transaction
> rollback. Maybe someone can help.
>
> The idea is to provider a user readable high-level journal of model
> changes per model object. This journal is for the user only and should
> not contain fine grained change notifications (like the ChangeRecorder)
> but instead coarse grained user interactions for each model object.
>
> To use this feature, the developer has to explicitely mark each object
> during a command execution:
> ModelChangeJournal.markAsChanged(EObject object, String description);
>
> The change information is stored in a list and a pre-commit listener
> converts them to journal entries (containing a timestamp etc.) and adds
> them to the corresponding model object before the transaction is
> committed. The change storage is cleared at the end of
> transactionAboutToCommit().
>
> The problem is that I cannot clear the change storage when the entire
> transaction rolls back! There is no possibility to listen for rollbacks.
> As an effect, the change storage stays as is and will be processed when
> the next transaction commits which is definitely wrong!
>
> It would be nice if there was a way to get notified about transaction
> boundaries, that is
> (1) when a transaction starts
> (2) when a transaction is about to commit (already possible)
> (3) when a transaction has been committed (already possible)
> (4) when a transaction has been rolled back
>
> What do you think about that?
>
>
> Best regards,
> Mario
|
|
|
Re: EMF Transactions: Listen for rollbacks / clean up resources [message #423487 is a reply to message #423430] |
Wed, 01 October 2008 06:17  |
Eclipse User |
|
|
|
Cool. Thanks!
Christian W. Damus schrieb:
> Hi, Mario,
>
> Today is your lucky day :-D
>
> The recent 1.3 M2 release adds a new listener API to the
> TransactionalEditingDomain that gives you exactly the call-backs that
> you are asking for:
>
> http://download.eclipse.org/modeling/emf/transaction/javadoc /1.3.0/org/eclipse/emf/transaction/TransactionalEditingDomai nListener.html
>
>
> To detect rollback, look for an ERROR status (or more severe) in the
> Transaction referenced by the event object in the transactionClosed
> call-back.
>
> To attach your listener, get the TransactionalEditingDomain.Lifecycle
> adapter from your editing domain and (if it isn't null) add the listener
> to it.
>
> Cheers,
>
> Christian
>
>
> Mario Winterer wrote:
>> Hi!
>>
>> I'm currently working on a feature called "model change journal" and I
>> do have some troubles concerning EMF Transactions and transaction
>> rollback. Maybe someone can help.
>>
>> The idea is to provider a user readable high-level journal of model
>> changes per model object. This journal is for the user only and should
>> not contain fine grained change notifications (like the
>> ChangeRecorder) but instead coarse grained user interactions for each
>> model object.
>>
>> To use this feature, the developer has to explicitely mark each object
>> during a command execution:
>> ModelChangeJournal.markAsChanged(EObject object, String description);
>>
>> The change information is stored in a list and a pre-commit listener
>> converts them to journal entries (containing a timestamp etc.) and
>> adds them to the corresponding model object before the transaction is
>> committed. The change storage is cleared at the end of
>> transactionAboutToCommit().
>>
>> The problem is that I cannot clear the change storage when the entire
>> transaction rolls back! There is no possibility to listen for
>> rollbacks. As an effect, the change storage stays as is and will be
>> processed when the next transaction commits which is definitely wrong!
>>
>> It would be nice if there was a way to get notified about transaction
>> boundaries, that is
>> (1) when a transaction starts
>> (2) when a transaction is about to commit (already possible)
>> (3) when a transaction has been committed (already possible)
>> (4) when a transaction has been rolled back
>>
>> What do you think about that?
>>
>>
>> Best regards,
>> Mario
|
|
|
Powered by
FUDForum. Page generated in 0.03127 seconds