Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Notify model objects about completion of their deserialization
Notify model objects about completion of their deserialization [message #414265] Mon, 29 October 2007 10:55 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey,

I´d like to do something weird: I load an EMF model from a single file,
and immediately after the model deserialization is complete, I´d like my
model objects to "doSomething()". I could add an EOperation
"doSomething()" or so to each object, which is then called from a
central point after I get my model root from the EMF runtime. But I´d
rather keep the doSomething() method in private and let EMF somehow
"notify" each object about the completion of the deserialization process.

Is this understandable? Does this even work in theory, and if so, does
EMF implement something like this?
Re: Notify model objects about completion of their deserialization [message #414267 is a reply to message #414265] Mon, 29 October 2007 11:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Felix,

I suppose you want this to happen after the entire load process is
complete not as objects are added during loading? Is there a similar
need if you were to say copy the contents of the resource, create a new
resource, and add the copy to it? Using OPTION_DEFER_ATTACHMENT might
be useful to make the attach happen last, but ID resolution still needs
to take place as that point. Using OPTION_RESOURCE_HANDLER might be
useful for getting allowing the root object to get callbacks when the
resource containing it finishes loading. Of course it could listen as
an adapter to the resource's isLoaded state change for that and it could
hook itself up as a adapter to the resource when eSetResource or
eSetDirectResource is called. The root would then be responsible for
traversing all the children...


Felix Dorner wrote:
> Hey,
>
> I´d like to do something weird: I load an EMF model from a single file,
> and immediately after the model deserialization is complete, I´d like my
> model objects to "doSomething()". I could add an EOperation
> "doSomething()" or so to each object, which is then called from a
> central point after I get my model root from the EMF runtime. But I´d
> rather keep the doSomething() method in private and let EMF somehow
> "notify" each object about the completion of the deserialization process.
>
> Is this understandable? Does this even work in theory, and if so, does
> EMF implement something like this?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Notify model objects about completion of their deserialization [message #414268 is a reply to message #414267] Mon, 29 October 2007 11:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Felix,

Another idea is that if you use OPTION_DISABLE_NOTIFY then as objects
are created, eSetDeliver(false) is called, and at the end of the
document loading, eSetDeliver(true) is called, so you could use that as
your queue to do some post load processing. Of course these methods
could be called anytime.


Ed Merks wrote:
> Felix,
>
> I suppose you want this to happen after the entire load process is
> complete not as objects are added during loading? Is there a similar
> need if you were to say copy the contents of the resource, create a
> new resource, and add the copy to it? Using OPTION_DEFER_ATTACHMENT
> might be useful to make the attach happen last, but ID resolution
> still needs to take place as that point. Using
> OPTION_RESOURCE_HANDLER might be useful for getting allowing the root
> object to get callbacks when the resource containing it finishes
> loading. Of course it could listen as an adapter to the resource's
> isLoaded state change for that and it could hook itself up as a
> adapter to the resource when eSetResource or eSetDirectResource is
> called. The root would then be responsible for traversing all the
> children...
>
>
> Felix Dorner wrote:
>> Hey,
>>
>> I´d like to do something weird: I load an EMF model from a single file,
>> and immediately after the model deserialization is complete, I´d like my
>> model objects to "doSomething()". I could add an EOperation
>> "doSomething()" or so to each object, which is then called from a
>> central point after I get my model root from the EMF runtime. But I´d
>> rather keep the doSomething() method in private and let EMF somehow
>> "notify" each object about the completion of the deserialization
>> process.
>>
>> Is this understandable? Does this even work in theory, and if so, does
>> EMF implement something like this?
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Notify model objects about completion of their deserialization [message #414269 is a reply to message #414267] Mon, 29 October 2007 11:52 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed Merks wrote:
> Felix,
>
> I suppose you want this to happen after the entire load process is
> complete not as objects are added during loading?
Yes. Uoh, your proposal sounds complicated :-) For now I´ll stick with
dirtying the models EClasses with a "loadCompleted" attribute that is
set manually after obtaining the root. The Implementation observes that
attribute and on change removes itself from the adapter list and does
the stuff it needs to do - not a very clean solution, but time is running...
Previous Topic:Use of setTarget in Adapters
Next Topic:How to best handle an "import" action
Goto Forum:
  


Current Time: Fri Mar 29 11:39:10 GMT 2024

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

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

Back to the top