Bug 450535 - SessionManagerListener.notifyAddSession(Session) gets called with an already loaded resourceSet
Summary: SessionManagerListener.notifyAddSession(Session) gets called with an already ...
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.0.0M7   Edit
Assignee: Laurent Fasani CLA
QA Contact: Belqassim Djafer CLA
URL:
Whiteboard:
Keywords: triaged
Depends on: 427017
Blocks:
  Show dependency tree
 
Reported: 2014-11-07 09:21 EST by Cedric Brun CLA
Modified: 2015-06-24 11:13 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2014-11-07 09:21:04 EST
EcoreTools needs to "setup" a ResourceSet when it is getting used by :
- specifying URI Mappings
- add default options to hook into the EPackage resolution while loading

All these customizations should be in place before any semantic resource (ecore, xcore or genmodel in my case) is getting loaded.

Right now we are using a SessionManagerListener and preparing the resourceset when the session got attached to the sessionmanager, which is quite early (one of the first statements in DAS.open())

I noticed that in some cases, like when an already existing modeling project is getting opened my listener is called with a pre-populated resourceset. 
My initialization then have no effect as all the "loads" have been done already.

While debugging I realized the culprit is the (in)famous AirDCrossReferenceAdapterImpl which triggers the loading of all the linked resources as soon as SessionFactoryImpl.loadSessionModelResource(URI, TransactionalEditingDomain, IProgressMonitor)

hence leading to my logic being useless in this case.

I would need one of those two options :
1°) a confirmation that I'm being using the API as intended and then I would expect Sirius to call me before any loading is done - that would mean fixing Bug 427017
2°) another API which would be more explicit and dedicated to this : preparing a resourceset before the resource loading for a given set of Viewpoints.

UML Designer has the same needs (to declare URI maps and such) and uses the same solution as EcoreTools (the SessionManagerListener) right now.
Comment 1 Cedric Brun CLA 2014-11-07 09:21:41 EST
(Adding the depdency to 427017, but if another dedicated API is provided then it will no more be the case)
Comment 2 Esteban DUGUEPEROUX CLA 2014-11-13 04:25:19 EST
SessionManagerListener.notifyAddSession() does not guarantee that added Session has its ResourceSet loaded in its contract. To initialize ResourceSet with needed customizations you could use ResourceSetFactory or EditingDomainFactory extension point, this last is more usable as it allow override a default one used while with ResourceSetFactory only the last registered is used.

Otherwise, indeed it will be better to have Session loaded only in Session.open() call and as you said this will be done once 427017 will be resolve.
Comment 3 Cedric Brun CLA 2014-11-14 05:07:04 EST
I'm not sure IEdtingDomainFactory is suitable.
If I plug this mechanism here (registering URI mappings and default load options) then what happes for other tools which needs to do this too ? I have a concrete example, UML Designer have the exact same need, but If EcoreTools and UML Designer are both doing it, who wins ? It looks like I can only "override" a specific one, but there is no reason UML Designer would "override" the EcoreTools one nor the other way around and we definitely don't want to introduce a dependency (even if its just a string identifier) in between those)
Comment 4 Cedric Brun CLA 2015-03-10 12:17:51 EDT
Just tested in debug after 

commit 6c460621f0c2207053d2e9b94ebd922fb593b17a
Author: Mickael LANOE <mickael.lanoe@obeo.fr>
Date:   Mon Mar 9 17:29:26 2015 +0100

got integrated.

My session listener ends up being called through "notififyAddSession()" with a session which have a resourceset not completely loaded yet.

That makes the session listener API suitable for such needs, agreed to close once we add a few tests in the suites ?
Comment 5 Pierre-Charles David CLA 2015-03-16 05:13:06 EDT
(In reply to Cedric Brun from comment #4)
> Just tested in debug after 
> 
> commit 6c460621f0c2207053d2e9b94ebd922fb593b17a
> Author: Mickael LANOE <mickael.lanoe@obeo.fr>
> Date:   Mon Mar 9 17:29:26 2015 +0100
> 
> got integrated.
> 
> My session listener ends up being called through "notififyAddSession()" with
> a session which have a resourceset not completely loaded yet.
> 
> That makes the session listener API suitable for such needs, agreed to close
> once we add a few tests in the suites ?

Agreed, moving to M7 (it's not blocking for M6).
Comment 7 Laurent Fasani CLA 2015-04-30 03:43:17 EDT
The test OpenSessionTest.testResourceLoadingAtOpenSession has been added
Comment 8 Belqassim Djafer CLA 2015-05-26 10:23:12 EDT
Verified with Sirius 3.0.0 RC1
Comment 9 Pierre-Charles David CLA 2015-06-24 11:13:42 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.