Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333327

Summary: Repo import doesn't work with cross-packageUnit dependencies
Product: [Modeling] EMF Reporter: Caspar D. <caspar_d>
Component: cdo.coreAssignee: Caspar D. <caspar_d>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: saulius.tvarijonas
Version: 4.0Flags: stepper: review+
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch v1
none
Patch v2 - ready to be committed none

Description Caspar D. CLA 2010-12-30 02:55:46 EST
When importing a set of packageUnits that contain packages
that have dependencies across the packageUnit boundaries,
the import encounters problems during the package import.

The (first) problem seems to be that the packageLoader constructed
in FlushHandler.handleModels calls EMFUtil.createEPackage with
argument lookForResource == true. This causes a lookup of the
resource in the resourceSet, which in turn delegates to the
cdoPackageRegistry, which in turn calls *another* packageLoader
(the repo), which in turn calls loadPackageUnit on the 
MEMStoreAccessor, which throws an UnsupportedOperationException.

Apparent solution: use lookForResource = false. But this might
cause the creation of Resource duds (resources that appear loaded,
but are actually empty), because of the subsequent call to 
packageUnit.load(..) invokes ECoreUtil.resolveAll(*) on every
ePackage obtained from the packageUnit. This also doesn't seem
quite right to me. I think no resolution should be requested until
all packageUnits have been processed...
Comment 1 Caspar D. CLA 2010-12-30 03:05:03 EST
Actually I've changed my mind: calling #createEPackage with 
lookForResource == true, makes sense. (In fact I can't think
of a scenario when calling it with 'false' would make sense.)

The problem is just that we have to keep the resourceSet from
delegating to some other object, which may attempt a demandLoad
or whatever. So, in the patch that I'll upload shortly, I'm
introducing a derivative of ResourceSetImpl that allows the
lookup delegation to be disabled/enabled as needed.

Also, I'll add a boolean arg 'resolve' to the packageUnit.load(*)
call, because I do still believe the resolution should be
postponed until the resourceSet is known to contain the contents
of ALL the packageUnits being imported.
Comment 2 Caspar D. CLA 2010-12-30 04:12:33 EST
Created attachment 185901 [details]
Patch v1
Comment 3 Eike Stepper CLA 2011-01-02 05:29:16 EST
Created attachment 185933 [details]
Patch v2 - ready to be committed

Reformatted slightly
Comment 4 Caspar D. CLA 2011-01-03 22:03:32 EST
Committed to HEAD
Comment 5 Eike Stepper CLA 2011-06-23 03:40:14 EDT
Available in R20110608-1407