Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Detecting resource saves and loads
Detecting resource saves and loads [message #504612] Mon, 21 December 2009 13:42 Go to next message
Stephen McCants is currently offline Stephen McCantsFriend
Messages: 92
Registered: July 2009
Member
Hello,
I'm looking for a way to detect resource saves and loads, preferably without overriding
ResourceSetImpl or ResourceImpl, so that any type of resource can be supported. I'm not actually
interested in detecting loads, but only saves, however, in my current approach they appear as the
same thing (which is problematic).
Currently, I attach an Adapter to each ResourceSet. This Adapter, in turn, attaches Adapters to
each Resource created in the ResourceSet. Each Resource also as setTrackingModification(true)
called on it. The ResourceAdapter informs other objects about saves to the Resource. The intent is
to allow other parts of the code that are using a different resource set to refresh (reload) when
resources they care about are altered and saved.
My ResourceAdapter is listening to the changes to RESOURCE__IS_MODIFIED. When it is changed from
true to false, I assume that is a save (I don't currently support undos). Unfortunately, a load
does the exact same thing. ResourceImpl.load(InputStream, Map<?,?>) calls "setModified(false)" at
the end of its function. This is because the load likely set isModified to true during the course
of loading/modifying in the data. However, setModified(false) sends out notification. I'd override
this behavior and just set isModified = false, but load(InputStream, Map<?, ?>) is final.
At this point, I'm at a loss as to how to tell saves from loads. Any ideas?
Thanks in advance!

Sincerely,
Stephen McCants
Re: Detecting resource saves and loads [message #504662 is a reply to message #504612] Mon, 21 December 2009 23:21 Go to previous message
Stephen McCants is currently offline Stephen McCantsFriend
Messages: 92
Registered: July 2009
Member
I got around the problem by using a ResourceHandler with a postLoad and postSave.
--Stephen

Stephen McCants wrote:
> Hello,
> I'm looking for a way to detect resource saves and loads, preferably
> without overriding ResourceSetImpl or ResourceImpl, so that any type of
> resource can be supported. I'm not actually interested in detecting
> loads, but only saves, however, in my current approach they appear as
> the same thing (which is problematic).
> Currently, I attach an Adapter to each ResourceSet. This Adapter,
> in turn, attaches Adapters to each Resource created in the ResourceSet.
> Each Resource also as setTrackingModification(true) called on it. The
> ResourceAdapter informs other objects about saves to the Resource. The
> intent is to allow other parts of the code that are using a different
> resource set to refresh (reload) when resources they care about are
> altered and saved.
> My ResourceAdapter is listening to the changes to
> RESOURCE__IS_MODIFIED. When it is changed from true to false, I assume
> that is a save (I don't currently support undos). Unfortunately, a load
> does the exact same thing. ResourceImpl.load(InputStream, Map<?,?>)
> calls "setModified(false)" at the end of its function. This is because
> the load likely set isModified to true during the course of
> loading/modifying in the data. However, setModified(false) sends out
> notification. I'd override this behavior and just set isModified =
> false, but load(InputStream, Map<?, ?>) is final.
> At this point, I'm at a loss as to how to tell saves from loads.
> Any ideas?
> Thanks in advance!
>
> Sincerely,
> Stephen McCants
Previous Topic:ecore model weaving ala aspectj
Next Topic:segmented models and lazy loading
Goto Forum:
  


Current Time: Thu Apr 25 20:04:13 GMT 2024

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

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

Back to the top