Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] injection problem in a programmatic launch
[ATL] injection problem in a programmatic launch [message #633176] Fri, 15 October 2010 14:54 Go to next message
valerio c. is currently offline valerio c.Friend
Messages: 5
Registered: October 2010
Junior Member
Hi,
before i got the the xmi file

url = new URL("file:/C:/MyFolder/Samples/mymodel.xmi");
ASMModel model_mymodel = modelLoader.loadModel("IN", metamodel_mymodel, url.openStream());
models.put("IN", model_mymodel);


now i'm trying to use an injector but i don't know how modelLoader.inject method works

any suggestions?

File f = new File("C:/MyFolder/Syntax/mymodel-parser.jar");
modelLoader.addInjector("ebnf", f.getClass());
	    	
url = new URL("file:/C:/MyFolder/Samples/mymodel.myextension");
ASMModel model_mymodel = null;
ASMModelElement asme = modelLoader.inject(model_mymodel, "ebnf", "METAMODEL", "file:/C:/MyFolder/Syntax/mymodel-parser.jar", url.openStream());
models.put("IN", asme.getModel()); 


the error is:

java.lang.InstantiationException: java.io.File
	at java.lang.J9VMInternals.newInstanceImpl(Native Method)
	at java.lang.Class.newInstance(Class.java:1325)
	at org.eclipse.m2m.atl.engine.vm.ModelLoader.inject(ModelLoader.java:122)


Valerio
Re: [ATL] injection problem in a programmatic launch [message #633855 is a reply to message #633176] Tue, 19 October 2010 15:41 Go to previous messageGo to next message
valerio c. is currently offline valerio c.Friend
Messages: 5
Registered: October 2010
Junior Member
i changed a little bit my code..but it's still not working

ASMModel ret = ml.newModel(name_model, model, metamodel);
TCSInjector inj = new TCSInjector();
	    	
Map params = new HashMap();
params.put("name", "INJ");
			
ClassLoader c = ClassLoader.getSystemClassLoader();
params.put("lexerClass", c.loadClass("org.eclipse.gmt.tcs.injector.INJ_ANTLR3Lexer"));
params.put("parserClass", c.loadClass("org.eclipse.gmt.tcs.injector.INJ_ANTLR3Parser"));
			
url = new URL(path);
inj.inject(ret, url.openStream(), params);


i get this error

Exception in thread "main" java.lang.NoClassDefFoundError: org.eclipse.gmt.tcs.injector.TCSInjector
	at java.lang.Class.getFieldImpl(Native Method)
	at java.lang.Class.getField(Class.java:726)
	at org.eclipse.m2m.atl.dsls.tcs.injector.wrappers.antlr3.ParserWrapper.parse(ParserWrapper.java:108)
	at org.eclipse.m2m.atl.dsls.tcs.injector.ParserLauncher.parse(ParserLauncher.java:79)
	at org.eclipse.m2m.atl.drivers.emf4atl.tcs.injector.TCSInjector.inject(TCSInjector.java:69)
	at RIF2IRLProgrammaticLaunch_basic.main(ProgrammaticLaunch_basic.java:118)
Caused by: java.lang.ClassNotFoundException: org.eclipse.gmt.tcs.injector.TCSInjector
	at java.net.URLClassLoader.findClass(URLClassLoader.java:421)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:652)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:346)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
	... 6 more



in which jar can i find TCSInjector ?

Valerio
Re: [ATL] injection problem in a programmatic launch [message #634322 is a reply to message #633176] Thu, 21 October 2010 09:26 Go to previous message
valerio c. is currently offline valerio c.Friend
Messages: 5
Registered: October 2010
Junior Member
it's working now..i needed to import the correct library
org.eclipse.gmt.tcs.injector.TCSInjector
before i was importing another one:
org.eclipse.m2m.atl.drivers.emf4atl.tcs.injector.TCSInjector

an example of using injectors and extractors could be:
...
			import org.eclipse.gmt.tcs.extractor.TCSExtractor;
			import org.eclipse.gmt.tcs.injector.TCSInjector;
			import org.eclipse.m2m.atl.drivers.emf4atl; 
			import org.eclipse.m2m.atl.engine.extractors.Extractor;
			import org.eclipse.m2m.atl.engine.vm.AtlLauncher;
			import org.eclipse.m2m.atl.engine.vm.AtlModelHandler;
			import org.eclipse.m2m.atl.engine.vm.ModelLoader;
			import org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel;
		
...	
			
	    	AtlModelHandler.registerDefaultHandler("EMF", new AtlEMFModelHandler());   		
	    	AtlModelHandler amh = AtlModelHandler.getDefault("EMF");
	    	ModelLoader ml = amh.createModelLoader();
	    	
	    	//Injection
	    	//input METAMODEL
	    	url = new URL("file:/C:/Metamodel/MyMetaModel.ecore");
	    	ASMModel metamodel_input = ml.loadModel("MyMetaModel", ml.getMOF(), url.openStream());
	    	models.put("MyMetaModel", metamodel_input);
	    	
	    	ASMModel model_input = ml.newModel("IN", "file:/C:/Model/sample.mymetamodel.xmi" , metamodel_input);
			inj = new TCSInjector();
	
	    	params = new HashMap();
			params.put("name", "MyMetaModel");
			
			ClassLoader c = ClassLoader.getSystemClassLoader();
			params.put("lexerClass", org.eclipse.gmt.tcs.injector.MyMetaModel_ANTLR3Lexer.class);
			params.put("parserClass", org.eclipse.gmt.tcs.injector.MyMetaModel_ANTLR3Parser.class);
			
			url = new URL("file:/C:/Model/sample.mymetamodel");
			inj.inject(model_input, url.openStream(), params);
			
			models.put("IN", model_input);
	    			
			//Extraction
			//TCS METAMODEL
	    	url = new URL("file:/C:/Metamodel/TCS.ecore");
	    	ASMModel metamodel_tcs = ml.loadModel("TCS", ml.getMOF(), url.openStream());
	    	
	    	//TCS MM METAMODEL
	    	url = new URL("file:/C:/Metamodel/MM-TCS.ecore");
	    	ASMModel metamodel_mm_tcs = ml.loadModel("MM.tcs", metamodel_tcs, url.openStream());
			
			ext = new TCSExtractor();
	    	params = new HashMap();
	    	params.put("format", metamodel_mm_tcs);
	    	params.put("identEsc", "");
	    	params.put("stringDelim", "\"");
	    	out = new FileOutputStream(output_filename);
			
			ext.extract(outputModel, out, params);
...


anyway i'm not sure about this line
ASMModel model_input = ml.newModel("IN", [COLOR=red]"file:/C:/Model/sample.mymetamodel.xmi"[/COLOR] , metamodel_input);


Valerio
Previous Topic:[QVTo] Failed to resolve meta model during standalone execution
Next Topic:[ATL] Use Java method in ATL
Goto Forum:
  


Current Time: Tue Jun 25 04:31:53 GMT 2019

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

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

Back to the top