[ATL] Launching ATL from Java [message #528621] |
Wed, 21 April 2010 10:13 |
dany Messages: 3 Registered: April 2010 |
Junior Member |
|
|
hello everyone
i 'm trying to launch an ATL transformation from java code but it doesn't work and i don't understand why
this my program :
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IExtractor;
import org.eclipse.m2m.atl.core.IInjector;
import org.eclipse.m2m.atl.core.IModel;
import org.eclipse.m2m.atl.core.IReferenceModel;
import org.eclipse.m2m.atl.core.ModelFactory;
import org.eclipse.m2m.atl.core.emf.EMFExtractor;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFReferenceModel;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.core.service.CoreService;
import org.eclipse.m2m.atl.core.ui.vm.asm.ASMFactory;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;
import org.eclipse.m2m.atl.common.*;
public class TransformTest {
private static URL asmURL;
public static final String IN_META = "file:/Users/me/Desktop/ProjetBi/impl proj/Families2persons/Families2Persons/Families.ecore";
public static final String OUT_META = "file:/Users/me/Desktop/ProjetBi/impl proj/Families2persons/Families2Persons/Persons.ecore";
public static final String IN_MODEL = "file:/Users/me/Desktop/ProjetBi/impl proj/Families2persons/Families2Persons/sample-Families.xmi";
public static final String OUT_MODEL = "file:/Users/me/Desktop/ProjetBi/impl proj/Families2persons/Families2Persons/WorkPlease.xmi";
public TransformTest() throws Exception {
System.out.println("c");
EMFVMLauncher launcher = new EMFVMLauncher();
Map<String, Object> launcherOptions = new HashMap<String,Object>();
launcherOptions.put("allowInterModelReferences", "true");
launcher.initialize(launcherOptions);
CoreService.registerLauncher(launcher);
CoreService.registerFactory("EMF", EMFModelFactory.class);
ModelFactory factory = CoreService.createModelFactory("EMF");
CoreService.registerExtractor("EMF", new EMFExtractor());
CoreService.registerInjector("EMF", new EMFInjector());
System.out.println("d");
EMFInjector injector = new EMFInjector();
IExtractor extractor = CoreService.getExtractor(factory.getDefaultExtractorName());
// Metamodels && models
System.out.println("e");
EMFReferenceModel Metamodel1 = (EMFReferenceModel)factory.newReferenceModel();
System.out.println("e0");
//System.out.println(""+IN_META);
injector.inject(Metamodel1,IN_META);
System.out.println("e1");
IModel model1 = factory.newModel(Metamodel1);
injector.inject(model1, IN_MODEL);
System.out.println("f");
EMFReferenceModel Metamodel2 = (EMFReferenceModel)factory.newReferenceModel();
System.out.println("g");
injector.inject(Metamodel2,OUT_META);
System.out.println("h");
IModel model2 = factory.newModel(Metamodel2);
System.out.println("i");
// Launching
launcher.addInModel(model1, IN_MODEL, IN_META); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("j");
launcher.addOutModel(model2, OUT_MODEL, OUT_META); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("k");
URL asmURL = new URL("file:/Users/me/Desktop/ProjetBi/impl proj/Families2persons/Families2Persons/Families2Persons.asm");
System.out.println("l");
InputStream asmInputStream = asmURL.openStream();
System.out.println("l1");
InputStream[] modules = new InputStream[1];
System.out.println("l2");
modules[0] = asmInputStream;
System.out.println("l3");
launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), Collections.<String, Object> emptyMap(),(Object[])modules);
System.out.println("l4");
}
}
i put some system.out.println to know where the problem com from
and this the result i have so far
a
c
d
e
e0
e1
f
g
h
i
j
k
l
l1
l2
l3
any help is welcome
[Updated on: Wed, 21 April 2010 10:15] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02389 seconds