Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Transactions: Listen for rollbacks / clean up resources
EMF Transactions: Listen for rollbacks / clean up resources [message #423429] Tue, 30 September 2008 15:43 Go to next message
Mario Winterer is currently offline Mario WintererFriend
Messages: 136
Registered: July 2009
Senior Member
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 16:07 Go to previous messageGo to next message
Eclipse UserFriend
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 10:17 Go to previous message
Mario Winterer is currently offline Mario WintererFriend
Messages: 136
Registered: July 2009
Senior Member
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
Previous Topic:[CDO] Should Audit validate the timestamp on instantiation?
Next Topic:[EMF] privileges for user and modification management
Goto Forum:
  


Current Time: Tue Jan 21 19:41:11 GMT 2020

Powered by FUDForum. Page generated in 0.01534 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top