Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Resolution problem with EMF proxy
Resolution problem with EMF proxy [message #175949] Tue, 24 October 2006 07:42
Le Zhang is currently offline Le ZhangFriend
Messages: 6
Registered: July 2009
Junior Member
I have an ecore model containing 3 classes: TestParent, TestChild and
GrandChild. TestParent has a non-containment reference to TestChild, its
name
is children and its multiplicity is 1 to n. TestChild has a
non-containment reference to GrandChild, its name is son and multiplicity
is also 1 to n.

Then I create an instance of TestParent, let's say, parent, add 2
references to instances of TestChild to parent. They are child_1 and
child_2,
while child_1 has referenced 2 instances of GrandChild, they are gld_son_1
and gld_son_2. I saved each instance in one xml file, use the
EMF resource technology.
I have the instance parent saved in parent.xml, and child_1 saved in
child_1.xml and so as others.

The contents of parent.xml are as follow:
<?xml version="1.0" encoding="UTF-8"?>
<proxytest.model:TestParent xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:proxytest.model="http:///proxytest/model/proxy.ecore">
<children href="/test/child_1.xml#/"/>
<children href="/test/child_2.xml#/"/>
</proxytest.model:TestParent>

and this is child_1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<proxytest.model:TestChild xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:proxytest.model="http:///proxytest/model/proxy.ecore" name="child_1"
age="30">
<son href="/test/gld_son_1.xml#/"/>
<son href="/test/gld_son_2.xml#/"/>
</proxytest.model:TestChild>

gld_son_1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<proxytest.model:GrandChild xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:proxytest.model="http:///proxytest/model/proxy.ecore"
name="grand_son_1" age="5"/>

others are similar.

I use the following operations to load the model in my application(let's
call it Scenario_1):
1. Load the resource from parent.xml. The first element of its contents is
parent;
2. Invoke parent.getChildren() to get an EList containing child_1 and
child_2, and extract child_1 from the list;
3. Invoke child_1.getSon() to get the EList containing gld_son_1 and
gld_son_2, and extract gld_son_1;
4. Invoke gld_son_1.getName() to get the name of gld_son_1, and print it
out.
the console print out:
grand_son_1

Scenario_1 works fine until I restart the application and execute
Scenario_2:
1. Load the resource from child_1.xml. The first element of the resource's
contents is child_1;
2. Do nothing to child_1, and load the resource from gld_son_1.xml
immediately. The first element of its contents is gld_son_1;
3. Invoke child_.getSon() to get the EList containing gld_son_1 and
gld_son_2;
4. Extract gld_son_1 from the EList got from the 3rd step. This gld_son_1
is exactly the same as what I got from the 2nd step;
5. Do nothing else and re-save the resource containing child_1.

I know that the operations in Scenario_2 make no sense to my application.
But it has sufficiently meaning to the file child_1.xml.
After Scenario_2, child_1.xml is changed as follow:
<?xml version="1.0" encoding="UTF-8"?>
<proxytest.model:TestChild xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:proxytest.model="http:///proxytest/model/proxy.ecore" name="child_1"
age="30">
<son href="gld_son_1.xml#/"/>
<son href="/test/gld_son_2.xml#/"/>
</proxytest.model:TestChild>
Pay attention to the line: <son href="gld_son_1.xml#/"/>, the URI of this
element is changed from "/test/gld_son_1.xml#/" to "gld_son_1.xml#/";

I did nothing to the model but EMF changed my resource file. It's fine, I
can bear. What is worse is that when I restart the application again
and re-execute Scenario_1, the console won't print out "grand_son_1", but
print out "null" instead.

The real situation is much more complicated than Scenario_1 and 2, I
worked for days to figure out the key steps that can produce the
problem repeatedly. And, I worked for another days to trace the code line
by line, and finally noticed that it has something ralated to the
EMF's proxy mechanism. As I am not familiar with the proxy technology, I
wish someone can tell me whether it is a bug of EMF or it is a
bug of my application? And Why?
Previous Topic:eclipse source build within eclipse
Next Topic:how to add action(button) near Minimaze, Maximize buttons
Goto Forum:
  


Current Time: Fri Apr 26 04:38:08 GMT 2024

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

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

Back to the top