|
Re: EditingDomain disposing [message #417627 is a reply to message #417626] |
Tue, 18 March 2008 22:11 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Giulio,
Thanks.
Giulio Seregni wrote:
> Firt of all my congraturation to Ed for his re-election.
Thanks. It's an honor to be able to serve the committer community in
this way. I have a pretty good sense of the kinds of issues that are
near and dear to the hearts of committers.
>
> Now, I have a question : )
>
> I have a custom editor that on its init() create a new EditingDomain
> and load the resource specified in his IEditorInput, in this way :
>
> URI uri = EditUIUtil.getURI(input);
>
> resource = editingDomain.getResourceSet().createResource(uri);
> resource.load(Collections.EMPTY_MAP);
>
>
> when my editor is disposed i would like to dispose the editing domain
> and the resource too.
Neither of them need disposing though. They'll just be garbage collected.
>
> so i tryed something like this:
>
>
> public void dispose() {
> super.dispose();
> editingDomain.dispose();
> resource.unload();
> }
>
>
> i cant't figure out how to let my adaptes understand that the
> container resource of my notifier has been unload.
When a resource is unloaded, the adapters are all removed and as that
happens, they'll get a REMOVING_ADAPTER notification. There will also
be an unsetTarget callback.
>
> I expected that the unset() method was called unloading the resource,
> but it does not happens.
By default, unloading a resource only turns the objects into proxies, it
doesn't decompose containment structure nor unset any other references
or attributes. You could specialize the ResourceImpl.unloaded method to
do more work.
>
>
> how can i inform all my adapters that their notifier does not longer
> exists ?
I suspect that none of this is actually necessary since the model
instance will just be garbage collected when the editor closes...
>
> thx,
>
> giulio
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EditingDomain disposing [message #417641 is a reply to message #417634] |
Wed, 19 March 2008 15:29 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080907000705080506080902
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Giulio,
Is the adapter actually being removed? Step through this code in
ResourceImpl which should get invoked when you call unload to see what's
happening
protected void unloaded(InternalEObject internalEObject)
{
internalEObject.eSetProxyURI(uri.appendFragment(getURIFragme nt(internalEObject)));
* internalEObject.eAdapters().clear();*
}
Giulio Seregni wrote:
> Ed Merks wrote:
>
>> Giulio,
>
>> Thanks.
>
>> Giulio Seregni wrote:
>>> Firt of all my congraturation to Ed for his re-election.
>> Thanks. It's an honor to be able to serve the committer community in
>> this way. I have a pretty good sense of the kinds of issues that are
>> near and dear to the hearts of committers.
>>>
>>> Now, I have a question : )
>>>
>>> I have a custom editor that on its init() create a new EditingDomain
>>> and load the resource specified in his IEditorInput, in this way :
>>>
>>> URI uri = EditUIUtil.getURI(input);
>>>
>>> resource = editingDomain.getResourceSet().createResource(uri);
>>> resource.load(Collections.EMPTY_MAP);
>>>
>>>
>>> when my editor is disposed i would like to dispose the editing
>>> domain and the resource too.
>
>> Neither of them need disposing though. They'll just be garbage
>> collected.
>>>
>>> so i tryed something like this:
>>>
>>>
>>> public void dispose() {
>>> super.dispose();
>>> editingDomain.dispose();
>>> resource.unload();
>>> }
>>>
>>>
>>> i cant't figure out how to let my adaptes understand that the
>>> container resource of my notifier has been unload.
>> When a resource is unloaded, the adapters are all removed and as that
>> happens, they'll get a REMOVING_ADAPTER notification. There will
>> also be an unsetTarget callback.
>>>
>>> I expected that the unset() method was called unloading the
>>> resource, but it does not happens.
>> By default, unloading a resource only turns the objects into proxies,
>> it doesn't decompose containment structure nor unset any other
>> references or attributes. You could specialize the
>> ResourceImpl.unloaded method to do more work.
>>>
>>>
>>> how can i inform all my adapters that their notifier does not longer
>>> exists ?
>> I suspect that none of this is actually necessary since the model
>> instance will just be garbage collected when the editor closes...
>>>
>
> In my case i can't see the REMOVING_ADAPTER notification. My adapter
> extends AdapterImpl and launch a Thread that does it works. But i have
> to stop the thread when the notifier does not longer exists.
>
> any idea ?
>
> thx
>
--------------080907000705080506080902
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Giulio,<br>
<br>
Is the adapter actually being removed?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04851 seconds