Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » How to unregister a TransactionalEditingDomain?
How to unregister a TransactionalEditingDomain? [message #80965] Tue, 24 April 2007 19:01 Go to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hello,


I create a TransactionalEditingDomain via:



transactionalEditingdomain = (TransactionalEditingDomainImpl)
TransactionalEditingDomain.Factory.INSTANCE.createEditingDom ain(MyResourceSet);


By that, I can rollback or commit changes I do subsequently. But after
rollback/commit, I want to delete the editing domain or at least to
detatch it from the resourceset. But I fail in that somehow. For
subsequent modifications I get following exception:


java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessResourceNotification(TransactionChangeRecorder.java:22 7)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:193)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatc hNotification(NotifyingListImpl.java:260)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:292)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 00)
...





I tried to do

transactionalEditingdomain.getResourceSet().eAdapters().clea r();

or

transactionalEditingdomain.dispose();

or

((TransactionalEditingDomainImpl.FactoryImpl)TransactionalEd itingDomain.Factory.INSTANCE).unmapResourceSet(transactional Editingdomain);


but all without success.


Any ideas would be appreciated!


Thanks
Re: How to unregister a TransactionalEditingDomain? [message #80980 is a reply to message #80965] Tue, 24 April 2007 19:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

TransactionalEditingDomain.dispose() should suffice.

Are you sure that all of the objects that you are modifying were not
"shared" by some other transactional editing domain, also? For example, by
moving them from one resource set (managed by transactions) to another
(also managed by transactions)?

If you put a breakpoint on the throw statement in
TransactionChangeRecorder.assertWriting(), which editing domain is
referenced by the recorder's 'domain' field? Is it the same editing domain
that you had previously dispose()d? I suspect it's a different one ...

Cheers,

Christian



John Smith wrote:

> Hello,
>
>
> I create a TransactionalEditingDomain via:
>
>
>
> transactionalEditingdomain = (TransactionalEditingDomainImpl)
>
TransactionalEditingDomain.Factory.INSTANCE.createEditingDom ain(MyResourceSet);
>
>
> By that, I can rollback or commit changes I do subsequently. But after
> rollback/commit, I want to delete the editing domain or at least to
> detatch it from the resourceset. But I fail in that somehow. For
> subsequent modifications I get following exception:
>
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessResourceNotification(TransactionChangeRecorder.java:22 7)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:193)
> at
>
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatc hNotification(NotifyingListImpl.java:260)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:292)
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 00)
> ..
>
>
>
>
>
> I tried to do
>
> transactionalEditingdomain.getResourceSet().eAdapters().clea r();
>
> or
>
> transactionalEditingdomain.dispose();
>
> or
>
>
((TransactionalEditingDomainImpl.FactoryImpl)TransactionalEd itingDomain.Factory.INSTANCE).unmapResourceSet(transactional Editingdomain);
>
>
> but all without success.
>
>
> Any ideas would be appreciated!
>
>
> Thanks
Re: How to unregister a TransactionalEditingDomain? [message #81011 is a reply to message #80980] Wed, 25 April 2007 07:53 Go to previous messageGo to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hi Christian


> Hi, John,
>
> TransactionalEditingDomain.dispose() should suffice.
>
> Are you sure that all of the objects that you are modifying were not
> "shared" by some other transactional editing domain, also? For example, by
> moving them from one resource set (managed by transactions) to another
> (also managed by transactions)?
>
> If you put a breakpoint on the throw statement in
> TransactionChangeRecorder.assertWriting(), which editing domain is
> referenced by the recorder's 'domain' field? Is it the same editing domain
> that you had previously dispose()d? I suspect it's a different one ...

No its the one I disposed before.

Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
I debugged, it calls ChangeRecorder.dispose(). But the
ChangeRecorder.targetObjects is empty, so the adapters are not removed..
Re: How to unregister a TransactionalEditingDomain? [message #81026 is a reply to message #81011] Wed, 25 April 2007 08:54 Go to previous messageGo to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hi Christian
>
>
>> Hi, John,
>>
>> TransactionalEditingDomain.dispose() should suffice.
>>
>> Are you sure that all of the objects that you are modifying were not
>> "shared" by some other transactional editing domain, also? For
>> example, by
>> moving them from one resource set (managed by transactions) to another
>> (also managed by transactions)?
>>
>> If you put a breakpoint on the throw statement in
>> TransactionChangeRecorder.assertWriting(), which editing domain is
>> referenced by the recorder's 'domain' field? Is it the same editing
>> domain
>> that you had previously dispose()d? I suspect it's a different one ...
>
> No its the one I disposed before.
>
> Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
> I debugged, it calls ChangeRecorder.dispose(). But the
> ChangeRecorder.targetObjects is empty, so the adapters are not removed..

However it works now by manually removing the change recorder:


TransactionChangeRecorder cr =
transactionalEditingdomain.getChangeRecorder();
transactionalEditingdomain.dispose();
transactionalEditingdomain.getResourceSet().eAdapters().remo ve(cr);

for (Iterator
iter=transactionalEditingdomain.getResourceSet().getAllConte nts();
iter.hasNext(); ) {
Notifier res=(Notifier) iter.next();
res.eAdapters().remove(cr);
}



With EMFT/Transaction, I hoped to have rollback/commit functionality,
and this works now perfectly now. I aimed at the "Batched Events"
feature, however it seems other adapters (ResourceItemProvider in my
case) still are notified , resulting in
ConcurrentModificationExceptions. How can the change notifications be
delayed, so that after a commit() all those are fired (after a
rollback() nothing should be needed to be fired)?

Thanks again in advance
Re: How to unregister a TransactionalEditingDomain? [message #81102 is a reply to message #81011] Wed, 25 April 2007 12:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

Are you working with Transaction 1.0.x? This is a bug that was fixed in
1.1. Sorry, I should have remembered that sooner (without your prompting).

If you step up to 1.1, you should be fine. Note that there are not many
differences between 1.1 and 1.0, and it should work with all of the same
dependencies (Eclipse, EMF, etc.) that you are using today.

Cheers,

Christian


John Smith wrote:

> Hi Christian
>
>
>> Hi, John,
>>
>> TransactionalEditingDomain.dispose() should suffice.
>>
>> Are you sure that all of the objects that you are modifying were not
>> "shared" by some other transactional editing domain, also? For example,
>> by moving them from one resource set (managed by transactions) to another
>> (also managed by transactions)?
>>
>> If you put a breakpoint on the throw statement in
>> TransactionChangeRecorder.assertWriting(), which editing domain is
>> referenced by the recorder's 'domain' field? Is it the same editing
>> domain
>> that you had previously dispose()d? I suspect it's a different one ...
>
> No its the one I disposed before.
>
> Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
> I debugged, it calls ChangeRecorder.dispose(). But the
> ChangeRecorder.targetObjects is empty, so the adapters are not removed..
Re: How to unregister a TransactionalEditingDomain? [message #81117 is a reply to message #81026] Wed, 25 April 2007 13:03 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

As I mentioned in my other reply, Transaction 1.1 will fix your problem so
you can remove your work-around.

We can batch-and-delay the notifications that are sent to your
ResourceSetListeners, but any adapters that you attach to objects will
continue to behave as usual. It would require some fancy interception of
the adapter mechanism to do otherwise, and would probably be dangerous
(perhaps some adapters will require immediate notification?). You may be
able, yourself, to wrap certain adapters (e.g., item providers) to batch
the notifications, but then you would be breaking their assumption that
each notification is a delta relative to the current state of the object
....

How are your item providers running into ConcurrentModificationExceptions?
Is it a concurrency problem? The transactions should eliminate that, as
they guarantee strictly serial ordering of changes on multiple threads.
Can you elaborate on the scenario?

Cheers,

Christian


John Smith wrote:

<snip>

> However it works now by manually removing the change recorder:
>
>
> TransactionChangeRecorder cr =
> transactionalEditingdomain.getChangeRecorder();
> transactionalEditingdomain.dispose();
> transactionalEditingdomain.getResourceSet().eAdapters().remo ve(cr);
>
> for (Iterator
> iter=transactionalEditingdomain.getResourceSet().getAllConte nts();
> iter.hasNext(); ) {
> Notifier res=(Notifier) iter.next();
> res.eAdapters().remove(cr);
> }
>
>
>
> With EMFT/Transaction, I hoped to have rollback/commit functionality,
> and this works now perfectly now. I aimed at the "Batched Events"
> feature, however it seems other adapters (ResourceItemProvider in my
> case) still are notified , resulting in
> ConcurrentModificationExceptions. How can the change notifications be
> delayed, so that after a commit() all those are fired (after a
> rollback() nothing should be needed to be fired)?
>
> Thanks again in advance
Re: How to unregister a TransactionalEditingDomain? [message #605010 is a reply to message #80965] Tue, 24 April 2007 19:56 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

TransactionalEditingDomain.dispose() should suffice.

Are you sure that all of the objects that you are modifying were not
"shared" by some other transactional editing domain, also? For example, by
moving them from one resource set (managed by transactions) to another
(also managed by transactions)?

If you put a breakpoint on the throw statement in
TransactionChangeRecorder.assertWriting(), which editing domain is
referenced by the recorder's 'domain' field? Is it the same editing domain
that you had previously dispose()d? I suspect it's a different one ...

Cheers,

Christian



John Smith wrote:

> Hello,
>
>
> I create a TransactionalEditingDomain via:
>
>
>
> transactionalEditingdomain = (TransactionalEditingDomainImpl)
>
TransactionalEditingDomain.Factory.INSTANCE.createEditingDom ain(MyResourceSet);
>
>
> By that, I can rollback or commit changes I do subsequently. But after
> rollback/commit, I want to delete the editing domain or at least to
> detatch it from the resourceset. But I fail in that somehow. For
> subsequent modifications I get following exception:
>
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessResourceNotification(TransactionChangeRecorder.java:22 7)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:193)
> at
>
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatc hNotification(NotifyingListImpl.java:260)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:292)
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 00)
> ..
>
>
>
>
>
> I tried to do
>
> transactionalEditingdomain.getResourceSet().eAdapters().clea r();
>
> or
>
> transactionalEditingdomain.dispose();
>
> or
>
>
((TransactionalEditingDomainImpl.FactoryImpl)TransactionalEd itingDomain.Factory.INSTANCE).unmapResourceSet(transactional Editingdomain);
>
>
> but all without success.
>
>
> Any ideas would be appreciated!
>
>
> Thanks
Re: How to unregister a TransactionalEditingDomain? [message #605018 is a reply to message #80980] Wed, 25 April 2007 07:53 Go to previous message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hi Christian


> Hi, John,
>
> TransactionalEditingDomain.dispose() should suffice.
>
> Are you sure that all of the objects that you are modifying were not
> "shared" by some other transactional editing domain, also? For example, by
> moving them from one resource set (managed by transactions) to another
> (also managed by transactions)?
>
> If you put a breakpoint on the throw statement in
> TransactionChangeRecorder.assertWriting(), which editing domain is
> referenced by the recorder's 'domain' field? Is it the same editing domain
> that you had previously dispose()d? I suspect it's a different one ...

No its the one I disposed before.

Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
I debugged, it calls ChangeRecorder.dispose(). But the
ChangeRecorder.targetObjects is empty, so the adapters are not removed..
Re: How to unregister a TransactionalEditingDomain? [message #605021 is a reply to message #81011] Wed, 25 April 2007 08:54 Go to previous message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hi Christian
>
>
>> Hi, John,
>>
>> TransactionalEditingDomain.dispose() should suffice.
>>
>> Are you sure that all of the objects that you are modifying were not
>> "shared" by some other transactional editing domain, also? For
>> example, by
>> moving them from one resource set (managed by transactions) to another
>> (also managed by transactions)?
>>
>> If you put a breakpoint on the throw statement in
>> TransactionChangeRecorder.assertWriting(), which editing domain is
>> referenced by the recorder's 'domain' field? Is it the same editing
>> domain
>> that you had previously dispose()d? I suspect it's a different one ...
>
> No its the one I disposed before.
>
> Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
> I debugged, it calls ChangeRecorder.dispose(). But the
> ChangeRecorder.targetObjects is empty, so the adapters are not removed..

However it works now by manually removing the change recorder:


TransactionChangeRecorder cr =
transactionalEditingdomain.getChangeRecorder();
transactionalEditingdomain.dispose();
transactionalEditingdomain.getResourceSet().eAdapters().remo ve(cr);

for (Iterator
iter=transactionalEditingdomain.getResourceSet().getAllConte nts();
iter.hasNext(); ) {
Notifier res=(Notifier) iter.next();
res.eAdapters().remove(cr);
}



With EMFT/Transaction, I hoped to have rollback/commit functionality,
and this works now perfectly now. I aimed at the "Batched Events"
feature, however it seems other adapters (ResourceItemProvider in my
case) still are notified , resulting in
ConcurrentModificationExceptions. How can the change notifications be
delayed, so that after a commit() all those are fired (after a
rollback() nothing should be needed to be fired)?

Thanks again in advance
Re: How to unregister a TransactionalEditingDomain? [message #605037 is a reply to message #81011] Wed, 25 April 2007 12:55 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

Are you working with Transaction 1.0.x? This is a bug that was fixed in
1.1. Sorry, I should have remembered that sooner (without your prompting).

If you step up to 1.1, you should be fine. Note that there are not many
differences between 1.1 and 1.0, and it should work with all of the same
dependencies (Eclipse, EMF, etc.) that you are using today.

Cheers,

Christian


John Smith wrote:

> Hi Christian
>
>
>> Hi, John,
>>
>> TransactionalEditingDomain.dispose() should suffice.
>>
>> Are you sure that all of the objects that you are modifying were not
>> "shared" by some other transactional editing domain, also? For example,
>> by moving them from one resource set (managed by transactions) to another
>> (also managed by transactions)?
>>
>> If you put a breakpoint on the throw statement in
>> TransactionChangeRecorder.assertWriting(), which editing domain is
>> referenced by the recorder's 'domain' field? Is it the same editing
>> domain
>> that you had previously dispose()d? I suspect it's a different one ...
>
> No its the one I disposed before.
>
> Actually, transactionalEditingdomain.dispose(); has nearly no effect. As
> I debugged, it calls ChangeRecorder.dispose(). But the
> ChangeRecorder.targetObjects is empty, so the adapters are not removed..
Re: How to unregister a TransactionalEditingDomain? [message #605039 is a reply to message #81026] Wed, 25 April 2007 13:03 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

As I mentioned in my other reply, Transaction 1.1 will fix your problem so
you can remove your work-around.

We can batch-and-delay the notifications that are sent to your
ResourceSetListeners, but any adapters that you attach to objects will
continue to behave as usual. It would require some fancy interception of
the adapter mechanism to do otherwise, and would probably be dangerous
(perhaps some adapters will require immediate notification?). You may be
able, yourself, to wrap certain adapters (e.g., item providers) to batch
the notifications, but then you would be breaking their assumption that
each notification is a delta relative to the current state of the object
....

How are your item providers running into ConcurrentModificationExceptions?
Is it a concurrency problem? The transactions should eliminate that, as
they guarantee strictly serial ordering of changes on multiple threads.
Can you elaborate on the scenario?

Cheers,

Christian


John Smith wrote:

<snip>

> However it works now by manually removing the change recorder:
>
>
> TransactionChangeRecorder cr =
> transactionalEditingdomain.getChangeRecorder();
> transactionalEditingdomain.dispose();
> transactionalEditingdomain.getResourceSet().eAdapters().remo ve(cr);
>
> for (Iterator
> iter=transactionalEditingdomain.getResourceSet().getAllConte nts();
> iter.hasNext(); ) {
> Notifier res=(Notifier) iter.next();
> res.eAdapters().remove(cr);
> }
>
>
>
> With EMFT/Transaction, I hoped to have rollback/commit functionality,
> and this works now perfectly now. I aimed at the "Batched Events"
> feature, however it seems other adapters (ResourceItemProvider in my
> case) still are notified , resulting in
> ConcurrentModificationExceptions. How can the change notifications be
> delayed, so that after a commit() all those are fired (after a
> rollback() nothing should be needed to be fired)?
>
> Thanks again in advance
Previous Topic:How to unregister a TransactionalEditingDomain?
Next Topic:[Teneo] : Transient annotation not working on EClass.
Goto Forum:
  


Current Time: Fri Apr 26 12:16:22 GMT 2024

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

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

Back to the top