Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Proxy Resolution among Resources
Proxy Resolution among Resources [message #1008731] Wed, 13 February 2013 18:31 Go to next message
Markus Riedl is currently offline Markus Riedl
Messages: 14
Registered: November 2012
Junior Member
Hi,

I'm sorry if this was asked somewhere before (and I'm pretty sure it was) but I searched and didn't find a good answer.

Following situation:
Two resources A and B, the modelelement of resource A contains a reference to the modelelement defined in resource B. But both are in the same ResourceSet.

Loading them leads to a proxy-reference in A to the element in B. Normally it should be the case ('Resolve Proxies = true' for this reference) that the proxy is resolved at the time I access the reference or at least if I force it with EcoreUtil.resolve(..)

Neither one works.

The modelelement B is loaded and in the same resource set, even if I make sure that the "correct" order is executed (B before A) it can't be resolved...

What do I miss any ideas, hints which could help me?

Greetings Markus
Re: Proxy Resolution among Resources [message #1008756 is a reply to message #1008731] Wed, 13 February 2013 19:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26037
Registered: July 2009
Senior Member
Markus,

A common reason for proxies failing to resolve is loading a resource
with a URI that's not absolute. What URI did you use to load these
resources? What do the URIs look like in the serialized XML?

On 13/02/2013 7:31 PM, Markus Riedl wrote:
> Hi,
>
> I'm sorry if this was asked somewhere before (and I'm pretty sure it
> was) but I searched and didn't find a good answer.
>
> Following situation: Two resources A and B, the modelelement of
> resource A contains a reference to the modelelement defined in
> resource B. But both are in the same ResourceSet.
>
> Loading them leads to a proxy-reference in A to the element in B.
> Normally it should be the case ('Resolve Proxies = true' for this
> reference) that the proxy is resolved at the time I access the
> reference or at least if I force it with EcoreUtil.resolve(..)
>
> Neither one works.
> The modelelement B is loaded and in the same resource set, even if I
> make sure that the "correct" order is executed (B before A) it can't
> be resolved...
>
> What do I miss any ideas, hints which could help me?
>
> Greetings Markus
>
Re: Proxy Resolution among Resources [message #1008783 is a reply to message #1008756] Wed, 13 February 2013 20:58 Go to previous messageGo to next message
Markus Riedl is currently offline Markus Riedl
Messages: 14
Registered: November 2012
Junior Member
The URI's are absolute and the URI - kind is fileURI.
In my case there is no XML, "I" parse a file into ECore-Representation, nonetheless the proxies should resolve ...
the proxy - uri looks like: [abspathtoresourceA]#EMFTEXT_INTERNAL_URI_FRAGMENT_0_A, if this gives you some hint
Re: Proxy Resolution among Resources [message #1008901 is a reply to message #1008783] Thu, 14 February 2013 05:04 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26037
Registered: July 2009
Senior Member
Markus,

Note that even an absolute file URI could be problematic if the
underlying file path itself isn't an absolute file system path.

When an attempt to resolve a proxy occurs, ResourceSet.getEObject will
be called with the proxy's URI. This will call ResourceSet.getResource
with the URI with the fragment trimmed. So your resource set will
definitely contain a resource with the URI [abspathtoresourceA], if
proxy resolution is attempted. That could fail to load for some reason,
but the cause of the failure will be recorded in Resource.getErrors.
Assuming it loads properly, Resource.getEObject will be called with the
fragment. If the resource is able to find the object with that
fragment, it will be returned and all will work well; if it returns
null, the proxy will fail to resolve. So, somewhere along this path,
something is failing for you. Setting breakpoints in
ResourceSetImpl.getResource and ResourceImpl.getEObject should help you
track down what's going wrong in your scenario.


On 13/02/2013 9:58 PM, Markus Riedl wrote:
> The URI's are absolute and the URI - kind is fileURI. In my case there
> is no XML, "I" parse a file into ECore-Representation, nonetheless the
> proxies should resolve ... the proxy - uri looks like:
> [abspathtoresourceA]#EMFTEXT_INTERNAL_URI_FRAGMENT_0_A, if this gives
> you some hint
Previous Topic:[CDO] Event to notify object has become dirty
Next Topic:Is it worth using EMF for a complex RCP application?
Goto Forum:
  


Current Time: Mon Sep 15 04:16:53 GMT 2014

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

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