Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Containment proxies and resolving ELists
Containment proxies and resolving ELists [message #1715707] Wed, 25 November 2015 11:21 Go to next message
Markus Scheidgen is currently offline Markus ScheidgenFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

following situation: I have two resources, each contains an object. Containment proxies are enabled in the corresponding .genmodel. One object references the other via a containment reference and additionally via a non containment (regular cross) reference.

When I navigate from one object to the other via the containment reference, the referenced object is resolved correctly and its container (eContainer) is set properly. When I navigate from one object to the other via the cross reference, it is also resolved, but its container is not set.

A look in the implementation (EcoreEList::resolve(EObject proxy)) reveals that EMF only sets the container of the resolved object, if the EList represents a containment reference (via ECoreEList::isContainment).

I would expect the implementation to use the proxy's eContainingFeature and eContainer to determine and set the resolved object's container, no matter if the resolving EList represents containment or not.

Is this intentional? Is this a bug? Do I understand the implementation wrong?

Re: Containment proxies and resolving ELists [message #1715713 is a reply to message #1715707] Wed, 25 November 2015 12:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Markus,

Comments below.

On 25/11/2015 12:21 PM, Markus Scheidgen wrote:
> Hi,
>
> following situation: I have two resources, each contains an object.
> Containment proxies are enabled in the corresponding .genmodel. One
> object references the other via a containment reference and
> additionally via a non containment (regular cross) reference.
Is the containment reference bidirectional? I.e., do you have a
container reference involved?
> When I navigate from one object to the other via the containment
> reference, the referenced object is resolved correctly and its
> container (eContainer) is set properly.
Yes, the containment proxy resolution mechanism is designed to support
the case of a unidirectional containment reference that, when resolved,
also sets the opposite, i.e., the eContainer.
> When I navigate from one object to the other via the cross reference,
> it is also resolved, but its container is not set.
Yes, unless there is a proxy for the container, there is no way to know
where it is contained. Only the container knows this information, i.e.,
vi the proxy, in which case the contained object's eContainer is not
set, or via a resolved reference, in which case the process of resolving
sets the eContainer.
> A look in the implementation (EcoreEList::resolve(EObject proxy))
> reveals that EMF only sets the container of the resolved object, if
> the EList represents a containment reference (via
> ECoreEList::isContainment).
Indeed.
> I would expect the implementation to use the proxy's
> eContainingFeature and eContainer to determine and set the resolved
> object's container, no matter if the resolving EList represents
> containment or not.
There are typically two proxies involved. One held by the containment
reference and one by the container reference. The one used for the
non-containment reference has no eContainer set.
>
> Is this intentional?
One can't generally know this from the proxy held by the non-containment
reference.
> Is this a bug?
No.
> Do I understand the implementation wrong?
You're just observing the expected behavior. The only way to get around
this problem is to ensure that the cross-resource-contained object has a
proxy that references its container. That's only possible if you
define a container reference for it and set it to be non-transient so
that the serialization contains a proxy. Then you can always start with
that object and know where it is contained, without having navigated to
it from its container.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Containment proxies and resolving ELists [message #1715783 is a reply to message #1715713] Thu, 26 November 2015 08:48 Go to previous message
Markus Scheidgen is currently offline Markus ScheidgenFriend
Messages: 7
Registered: July 2009
Junior Member
Thanks Ed,

you are right, I haven't thought this through. Of course generally speaking the root element of an resource cannot know its container by itself. Thanks for the tip with the opposite reference, I'll try this to solve my problem.

LG,
Markus
Previous Topic:[CDO] Feature Map Commit
Next Topic:Invalid names when reverse engineering XML schema
Goto Forum:
  


Current Time: Sat Apr 27 00:46:38 GMT 2024

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

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

Back to the top