简体   繁体   中英

Cannot read module from ATL EMFTVM transformation in Java standalone project

According to the ATL/EMFTVM wiki , ATL/EMFTVM can be run standalone by using

ResourceSet moduleRS = new ResourceSetImpl();
moduleRS.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());

DefaultModuleResolver mr = new DefaultModuleResolver("pathToModuleDirectory", moduleRS);
TimingData td = new TimingData();
env.loadModule(mr, "ModuleName");
td.finishLoading();
env.run(td);
td.finish();

However, this always yields an exception saying Module not found . I debugged the code into great detail. Internally, a SaxParseException is thrown, which is weird since my .emftvm file is not a XML file . Any ideas how I can load the file properly? Thanks in advance!

I got the old version of EMFTVM, and have the same problem as you. I pull the latest version from github, and it is fine now.

Updates: @dwagelaar, aha, yes, I used EMFTVMResourceFactoryImpl; Here is the code I used btw:

    ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
    ResourceSet rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emftvm", new EMFTVMResourceFactoryImpl());

Also, instead of passing a new ResourceSetImpl(as indicated in Wiki),

// Don't do this! 
ModuleResolver mr = new DefaultModuleResolver("platform:/plugin/my.plugin.id/transformations/", new ResourceSetImpl());

I passed in the rs object initialized above.

This (still) does not work, because you would have to tell EMF that *.emftvm files are not XMI, and require the EMFTVMResourceFactoryImpl. The ATL/EMFTVM wiki page has been updated with improved code; see: https://wiki.eclipse.org/ATL/EMFTVM#Standalone_use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM