RMF Standalone [message #997246] |
Fri, 04 January 2013 11:43  |
Eclipse User |
|
|
|
Hi all,
I want to create a standalone app, which uses *only* the RMF core to create a Model (programmatically) and to save it in an appropriate reqif-file.
My code so far looks like this:
//Register ReqIF in EMF
Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put("reqif", new ReqIF10FactoryImpl());
EPackage.Registry.INSTANCE.put(ReqIF10Package.eNS_URI, ReqIF10Package.eINSTANCE);
//create ReqIF Model
ReqIF reqif = createReqIF(...);
ResourceSet set = new ResourceSetImpl();
Resource res =set.createResource(URI.createFileURI("C:\\dummy.reqif"));
res.getContents().add(reqif);
try {
res.save(null);
} catch (IOException e) {e.printStackTrace();}
Actually a valid reqif file should be written, but I get instead a serialized xmi-file of the created model (which is indeed reqif). Somehow it seems that the appropriate Serializer does not get invoked. Could somebody help me?
Regards, Peter
|
|
|
|
|
Re: RMF Standalone [message #997448 is a reply to message #997348] |
Mon, 07 January 2013 09:51  |
Eclipse User |
|
|
|
OK some findings I found out during testing:
In order to serialize a ReqIF model in a standalone app, you have to use the ReqIFResourceSetImpl. That is NOT enough though: you have to register as well the appropriate ResourceFactory to the ResourceSet:
ResourceSet set = new ReqIFResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new ReqIFResourceFactoryImpl());
Using an eclipse-plugin project environment, everything is well initilialized and works transparently if the plugin depends on the pror.editor plugin.
There you can use the simple ResourcSetImpl without any factory registrations.
It would be interesting to know what the pror.editor does in order to enable this transparent use of the resourceset, I haven't figured it out yet...
Cheers,
Peter
[Updated on: Tue, 08 January 2013 08:38] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05363 seconds