Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » feature change notification fails while using transactional editing domain
feature change notification fails while using transactional editing domain [message #423784] Tue, 07 October 2008 09:51 Go to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
Hello,

One of my model element "Plugin" as a feature "status" that is imlemented
by me.
This feature set's a user preference (java.util.prefs.Preferences) and
reads it (see below).
in the PluginImpl I call the following when I am notify of a change in the
preference node

if (eNotificationRequired()) {
StatusType newStatus = isInstalled ? StatusType.INSTALLED :
StatusType.NOTINSTALLED;
StatusType oldStatus = isInstalled ? StatusType.NOTINSTALLED :
StatusType.INSTALLED;
eNotify(new ENotificationImpl(PluginImpl.this, Notification.SET,
MiddlewaresPackage.PLUGIN__STATUS, oldStatus, newStatus));
}

But this fails because (I think) I am using an transactionnalEditingDomain.

Exception in thread "Thread-3" java.lang.IllegalStateException: Cannot
modify resource set without a write transaction
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
com.nds.france.mhdk.middlewares.model.middlewares.impl.Plugi nImpl$1.pluginInstallStateChanged(PluginImpl.java:162)
com.nds.france.mhdk.ide.plugins.PluginLaunchableApp$PluginIn stallNodeListener.childAdded(PluginLaunchableApp.java:92)
java.util.prefs.AbstractPreferences$EventDispatchThread.run( AbstractPreferences.java:1476)

Do you have any idea on how to work around this problem, is this a bug ?

Thank you.

SeB.


PS : the setStatus implementation

/**
* store the installed status in the user preference store provided by the
* JRE
*/
public void setStatus(StatusType newStatus) {
PluginLaunchableApp.setInstalled(getName(), StatusType.INSTALLED ==
newStatus);
}

where

public static void setInstalled(String name, boolean isInstalled) {
if (name != null) {
Preferences pluginsInstalledPrefs = PLUGIN_INSTALL_NODE.node(name);
try {
if (!isInstalled) {//remove the node
pluginsInstalledPrefs.removeNode();
}//else node created so nothing more to do
pluginsInstalledPrefs.flush();
} catch (BackingStoreException e) {
IdePluginsPlugin.logErrorMessage(e);
}
}
}
Re: feature change notification fails while using transactional editing domain [message #423799 is a reply to message #423784] Tue, 07 October 2008 11:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30813
Registered: July 2009
Senior Member
SeB,

I hate to ask just the obvious question, but is this state change being
executed in the context of a write transaction? It would appear not.
It seems to me such change should be produced by executing a command...


SeB.fr wrote:
> Hello,
>
> One of my model element "Plugin" as a feature "status" that is
> imlemented by me.
> This feature set's a user preference (java.util.prefs.Preferences) and
> reads it (see below).
> in the PluginImpl I call the following when I am notify of a change in
> the preference node
> if (eNotificationRequired()) {
> StatusType newStatus = isInstalled ? StatusType.INSTALLED :
> StatusType.NOTINSTALLED;
> StatusType oldStatus = isInstalled ? StatusType.NOTINSTALLED :
> StatusType.INSTALLED;
> eNotify(new ENotificationImpl(PluginImpl.this, Notification.SET,
> MiddlewaresPackage.PLUGIN__STATUS, oldStatus, newStatus));
> }
>
> But this fails because (I think) I am using an
> transactionnalEditingDomain.
>
> Exception in thread "Thread-3" java.lang.IllegalStateException: Cannot
> modify resource set without a write transaction
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
>
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> com.nds.france.mhdk.middlewares.model.middlewares.impl.Plugi nImpl$1.pluginInstallStateChanged(PluginImpl.java:162)
>
> com.nds.france.mhdk.ide.plugins.PluginLaunchableApp$PluginIn stallNodeListener.childAdded(PluginLaunchableApp.java:92)
>
> java.util.prefs.AbstractPreferences$EventDispatchThread.run( AbstractPreferences.java:1476)
>
>
> Do you have any idea on how to work around this problem, is this a bug ?
>
> Thank you.
>
> SeB.
>
>
> PS : the setStatus implementation
>
> /**
> * store the installed status in the user preference store provided by the
> * JRE
> */
> public void setStatus(StatusType newStatus) {
> PluginLaunchableApp.setInstalled(getName(),
> StatusType.INSTALLED == newStatus);
> }
>
> where
>
> public static void setInstalled(String name, boolean isInstalled) {
> if (name != null) {
> Preferences pluginsInstalledPrefs = PLUGIN_INSTALL_NODE.node(name);
> try {
> if (!isInstalled) {//remove the node
> pluginsInstalledPrefs.removeNode();
> }//else node created so nothing more to do
> pluginsInstalledPrefs.flush();
> } catch (BackingStoreException e) {
> IdePluginsPlugin.logErrorMessage(e);
> }
> }
> }
>
>
Re: feature change notification fails while using transactional editing domain [message #423806 is a reply to message #423799] Tue, 07 October 2008 11:43 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Ed and others,

I probably did not make myself clear enought.
This feature is not persisted a file it is a Volatile because it reflects
a preference node in the Preference registry.
So when the preference node in the registry changes (I have attached a
listener), I would like the GUI being notified that the model value
changed so that it is updated.
This means there is not write transaction running, it is just a preference
listener that is notified of a change in the Preference node and then
fires the model eNotification.
More over in the model implementation we do not about the editing domain
being used.
I just want my table cell to reflect the model value itselft reflecting
the Preference node value.

Is it more clear?

SeB.


Ed Merks wrote:

> SeB,

> I hate to ask just the obvious question, but is this state change being
> executed in the context of a write transaction? It would appear not.
> It seems to me such change should be produced by executing a command...


> SeB.fr wrote:
>> Hello,
>>
>> One of my model element "Plugin" as a feature "status" that is
>> imlemented by me.
>> This feature set's a user preference (java.util.prefs.Preferences) and
>> reads it (see below).
>> in the PluginImpl I call the following when I am notify of a change in
>> the preference node
>> if (eNotificationRequired()) {
>> StatusType newStatus = isInstalled ? StatusType.INSTALLED :
>> StatusType.NOTINSTALLED;
>> StatusType oldStatus = isInstalled ? StatusType.NOTINSTALLED :
>> StatusType.INSTALLED;
>> eNotify(new ENotificationImpl(PluginImpl.this, Notification.SET,
>> MiddlewaresPackage.PLUGIN__STATUS, oldStatus, newStatus));
>> }
>>
>> But this fails because (I think) I am using an
>> transactionnalEditingDomain.
>>
>> Exception in thread "Thread-3" java.lang.IllegalStateException: Cannot
>> modify resource set without a write transaction
>>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
>>
>>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
>>
>>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
>>
>>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
>>
>>
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>
>>
com.nds.france.mhdk.middlewares.model.middlewares.impl.Plugi nImpl$1.pluginInstallStateChanged(PluginImpl.java:162)
>>
>>
com.nds.france.mhdk.ide.plugins.PluginLaunchableApp$PluginIn stallNodeListener.childAdded(PluginLaunchableApp.java:92)
>>
>>
java.util.prefs.AbstractPreferences$EventDispatchThread.run( AbstractPreferences.java:1476)
>>
>>
>> Do you have any idea on how to work around this problem, is this a bug ?
>>
>> Thank you.
>>
>> SeB.
>>
>>
>> PS : the setStatus implementation
>>
>> /**
>> * store the installed status in the user preference store provided by the
>> * JRE
>> */
>> public void setStatus(StatusType newStatus) {
>> PluginLaunchableApp.setInstalled(getName(),
>> StatusType.INSTALLED == newStatus);
>> }
>>
>> where
>>
>> public static void setInstalled(String name, boolean isInstalled) {
>> if (name != null) {
>> Preferences pluginsInstalledPrefs = PLUGIN_INSTALL_NODE.node(name);
>> try {
>> if (!isInstalled) {//remove the node
>> pluginsInstalledPrefs.removeNode();
>> }//else node created so nothing more to do
>> pluginsInstalledPrefs.flush();
>> } catch (BackingStoreException e) {
>> IdePluginsPlugin.logErrorMessage(e);
>> }
>> }
>> }
>>
>>
Re: feature change notification fails while using transactional editing domain [message #423809 is a reply to message #423806] Tue, 07 October 2008 12:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30813
Registered: July 2009
Senior Member
SeB,

Comments below.

SeB.fr wrote:
> Hello Ed and others,
>
> I probably did not make myself clear enought.
I don't always listen so well. :-P
> This feature is not persisted a file it is a Volatile because it
> reflects a preference node in the Preference registry.
Volatile has no runtime meaning. In hindsight it should not have been
in the Ecore model at all. It's purely a code generation option...
Probably you intend it to be transient.
> So when the preference node in the registry changes (I have attached a
> listener), I would like the GUI being notified that the model value
> changed so that it is updated.
So from a transaction point of view, it looks like a write modification
and in fact it is.
> This means there is not write transaction running, it is just a
> preference listener that is notified of a change in the Preference
> node and then fires the model eNotification.
You'll need one to make the transaction API happy.
> More over in the model implementation we do not about the editing
> domain being used.
Not sure I follow.
> I just want my table cell to reflect the model value itselft
> reflecting the Preference node value.
>
> Is it more clear?
Mostly. You'll still need a transaction to convince the transaction
APIs that this write access isn't a programming error.
>
> SeB.
>
>
> Ed Merks wrote:
>
>> SeB,
>
>> I hate to ask just the obvious question, but is this state change
>> being executed in the context of a write transaction? It would
>> appear not. It seems to me such change should be produced by
>> executing a command...
>
>
>> SeB.fr wrote:
>>> Hello,
>>>
>>> One of my model element "Plugin" as a feature "status" that is
>>> imlemented by me.
>>> This feature set's a user preference (java.util.prefs.Preferences)
>>> and reads it (see below).
>>> in the PluginImpl I call the following when I am notify of a change
>>> in the preference node
>>> if (eNotificationRequired()) {
>>> StatusType newStatus = isInstalled ? StatusType.INSTALLED :
>>> StatusType.NOTINSTALLED;
>>> StatusType oldStatus = isInstalled ? StatusType.NOTINSTALLED :
>>> StatusType.INSTALLED;
>>> eNotify(new ENotificationImpl(PluginImpl.this, Notification.SET,
>>> MiddlewaresPackage.PLUGIN__STATUS, oldStatus, newStatus));
>>> }
>>>
>>> But this fails because (I think) I am using an
>>> transactionnalEditingDomain.
>>>
>>> Exception in thread "Thread-3" java.lang.IllegalStateException:
>>> Cannot modify resource set without a write transaction
>>>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
>
>>>
>>>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
>
>>>
>>>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
>
>>>
>>>
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
>
>>>
>>>
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
>>>
>>>
> com.nds.france.mhdk.middlewares.model.middlewares.impl.Plugi nImpl$1.pluginInstallStateChanged(PluginImpl.java:162)
>
>>>
>>>
> com.nds.france.mhdk.ide.plugins.PluginLaunchableApp$PluginIn stallNodeListener.childAdded(PluginLaunchableApp.java:92)
>
>>>
>>>
> java.util.prefs.AbstractPreferences$EventDispatchThread.run( AbstractPreferences.java:1476)
>
>>>
>>>
>>> Do you have any idea on how to work around this problem, is this a
>>> bug ?
>>>
>>> Thank you.
>>>
>>> SeB.
>>>
>>>
>>> PS : the setStatus implementation
>>>
>>> /**
>>> * store the installed status in the user preference store provided
>>> by the
>>> * JRE
>>> */
>>> public void setStatus(StatusType newStatus) {
>>> PluginLaunchableApp.setInstalled(getName(),
>>> StatusType.INSTALLED == newStatus);
>>> }
>>>
>>> where
>>>
>>> public static void setInstalled(String name, boolean isInstalled) {
>>> if (name != null) {
>>> Preferences pluginsInstalledPrefs = PLUGIN_INSTALL_NODE.node(name);
>>> try {
>>> if (!isInstalled) {//remove the node
>>> pluginsInstalledPrefs.removeNode();
>>> }//else node created so nothing more to do
>>> pluginsInstalledPrefs.flush();
>>> } catch (BackingStoreException e) {
>>> IdePluginsPlugin.logErrorMessage(e);
>>> }
>>> }
>>> }
>>>
>>>
>
>
Re: feature change notification fails while using transactional editing domain [message #423813 is a reply to message #423809] Tue, 07 October 2008 12:39 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
The problem is that the ecore framework does not know what is the Editing
Domain being used.
And I do not want Editing Domain api to be part of my model implementation.

Is there any possible workaround ?
May I implement notification at the Edit level ?

I'll give a try.

SeB.
Re: feature change notification fails while using transactional editing domain [message #423816 is a reply to message #423813] Tue, 07 October 2008 13:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30813
Registered: July 2009
Senior Member
SeB,

Yes, you'd want to keep the two separate. Maybe there's some way by
specializing some class in transaction framework to ignore notifications
on certain features...


SeB.fr wrote:
> The problem is that the ecore framework does not know what is the
> Editing Domain being used.
> And I do not want Editing Domain api to be part of my model
> implementation.
>
> Is there any possible workaround ?
> May I implement notification at the Edit level ?
>
> I'll give a try.
>
> SeB.
>
Re: feature change notification fails while using transactional editing domain [message #423850 is a reply to message #423816] Wed, 08 October 2008 00:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, SeB, Ed,

There isn't, currently, anything that you can just extend or override in
the Transaction API to exclude certain features from transaction
control. You could, in a custom implementation of the
TransactionalEditingDomain interface, implement a custom
TransactionChangeRecorder, but that would probably be difficult.

If all of the objects of some particular resource should be excluded
from transactions, then you could just remove the
TransactionChangeRecorder from the adapter-lists of it and its contents.
However, doing so eliminates the concerruncy controls that prevent
such phenomena as lost updates and dirty reads.

HTH,

Christian


Ed Merks wrote:
> SeB,
>
> Yes, you'd want to keep the two separate. Maybe there's some way by
> specializing some class in transaction framework to ignore notifications
> on certain features...
>
>
> SeB.fr wrote:
>> The problem is that the ecore framework does not know what is the
>> Editing Domain being used.
>> And I do not want Editing Domain api to be part of my model
>> implementation.
>>
>> Is there any possible workaround ?
>> May I implement notification at the Edit level ?
>>
>> I'll give a try.
>>
>> SeB.
>>
Re: feature change notification fails while using transactional editing domain [message #423908 is a reply to message #423850] Thu, 09 October 2008 14:24 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
Hi Christian, Ed,

That is what I did, I mean I sub-classed the
TransactionalEditingDomainImpl class in order to create a custom
TransactionChangeRecorder that filters out my feature.
This is quiet easy actually.
thanks fo your help.

SeB.


Christian W. Damus wrote:

> Hi, SeB, Ed,

> There isn't, currently, anything that you can just extend or override in
> the Transaction API to exclude certain features from transaction
> control. You could, in a custom implementation of the
> TransactionalEditingDomain interface, implement a custom
> TransactionChangeRecorder, but that would probably be difficult.

> If all of the objects of some particular resource should be excluded
> from transactions, then you could just remove the
> TransactionChangeRecorder from the adapter-lists of it and its contents.
> However, doing so eliminates the concerruncy controls that prevent
> such phenomena as lost updates and dirty reads.

> HTH,

> Christian
Re: feature change notification fails while using transactional editing domain [message #423909 is a reply to message #423908] Thu, 09 October 2008 14:58 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Seb,

Good! I'm glad that it turned out so well for you, and especially that
it was easier than I had anticipated.

cW

SeB.fr wrote:
> Hi Christian, Ed,
>
> That is what I did, I mean I sub-classed the
> TransactionalEditingDomainImpl class in order to create a custom
> TransactionChangeRecorder that filters out my feature.
> This is quiet easy actually.
> thanks fo your help.
>
> SeB.
>
>
> Christian W. Damus wrote:
>
>> Hi, SeB, Ed,
>
>> There isn't, currently, anything that you can just extend or override
>> in the Transaction API to exclude certain features from transaction
>> control. You could, in a custom implementation of the
>> TransactionalEditingDomain interface, implement a custom
>> TransactionChangeRecorder, but that would probably be difficult.
>
>> If all of the objects of some particular resource should be excluded
>> from transactions, then you could just remove the
>> TransactionChangeRecorder from the adapter-lists of it and its
>> contents. However, doing so eliminates the concerruncy controls that
>> prevent such phenomena as lost updates and dirty reads.
>
>> HTH,
>
>> Christian
>
>
>
Previous Topic:Use annotations in JET template
Next Topic:[CDO] SQLException when loading cross CDO models
Goto Forum:
  


Current Time: Fri Jan 24 01:29:22 GMT 2020

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

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

Back to the top