Newbie question: Saving resources using factories. [message #207764] |
Tue, 09 March 2004 05:32  |
Eclipse User |
|
|
|
Originally posted by: stoyle0905.hotmail.com
I apologize for this very basic question, but I've searched the news groups
and the faqs, and I cannot find the solution.
I've created a model, and want to save it using the recommended method (in
the book Eclipse Modelling Framework) by creating a resource set and use its
factory mehods to create resources.
The code is very similar to the examples in the book (e.g. on page 30):
Ramproject proj = ...
ResourceSet set = new ResourceSetImpl();
URI uri = URI.createFileURI(new File("ramproject.xmi").getAbsolutePath());
Resource resource = set.createResource(uri);
resource.getContents().add(proj);
try {
resource.save(Collections.EMPTY_MAP);
}
catch (IOException e) {
...
}
Well, it doesn't work. The resource is null. I've tried everything I can
come up with, debugging, changing name/extensions and so on, but the
reference turns out null every time. I've also tried to use the same code
for the tutorial models, and the same thing happens.
It woks if I don't use the factory method, but create "resource" by:
Resource resource = new XMIResourceImpl(uri);
Does anyone know why this happens, and what I can do to correct it? Since I
am using several models, which are referencing each other, I understand that
I should use the factory method approach.
Thanks a lot!
Alf Kristian
|
|
|
|
Powered by
FUDForum. Page generated in 0.28918 seconds