Commit d4757d8b authored by Faezeh KHORRAM's avatar Faezeh KHORRAM 💬
Browse files

add eventManagerLauncher

parent bc9ef8c3
......@@ -88,7 +88,7 @@ class GateInstanceAspect {
if (_self.name.equals('oclMUTGate')){
MUTResource = _self.gateLauncher.MUTResource//the MUT objects are the received output
}
else if (arg.dataInstance.dataType.isExposedEvent(_self.DSLPath)){//an execution rule is the received output
if (arg.dataInstance.dataType.isExposedEvent(_self.DSLPath)){//an execution rule is the received output
//TODO: what should be set here??
}
var String status = null
......
package org.imt.tdl.eventManager;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.LinkedTransferQueue;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.execution.sequential.javaengine.PlainK3ExecutionEngine;
import org.eclipse.gemoc.executionframework.engine.commons.EngineContextException;
import org.eclipse.gemoc.executionframework.event.manager.GenericEventManager;
import org.eclipse.gemoc.executionframework.event.manager.IImplementationRelationship;
import org.eclipse.gemoc.executionframework.event.manager.ISubtypingRelationship;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
import org.imt.tdl.executionEngine.ALEEngineLauncher;
import org.imt.tdl.executionEngine.IExecutionEngine;
import org.imt.tdl.executionEngine.JavaEngineLauncher;
public class K3EventManagerLauncher {
private String DSLPath;
private String MUTPath;
private final String implemRelId = "org.eclipse.gemoc.executionframework.event.implementationrelationship";
private final String subtypeRelId = "org.eclipse.gemoc.executionframework.event.subtypingrelationship";
private List<IImplementationRelationship> implementationRelationships;
private List<ISubtypingRelationship> subtypingRelationships;
public void setUp(String DSLPath, String MUTPath, Set<String> implRelIds, Set<String> subRelIds) {
this.DSLPath = DSLPath;
this.MUTPath = MUTPath;
extractInformation(implRelIds, subRelIds);
}
//find all the implementation classes
protected void extractInformation(Set<String> implRelIds, Set<String> subRelIds) {
implementationRelationships = implRelIds.stream()
.map(id -> getRelationshipInstance(id, implemRelId, IImplementationRelationship.class))
.filter(r -> r != null).collect(Collectors.toList());
subtypingRelationships = subRelIds.stream()
.map(id -> getRelationshipInstance(id, subtypeRelId, ISubtypingRelationship.class))
.filter(r -> r != null).collect(Collectors.toList());
}
@SuppressWarnings("unchecked")
private <T> T getRelationshipInstance(String relationshipId, String extensionPointId, Class<T> asType) {
IConfigurationElement[] relationships = Platform.getExtensionRegistry()
.getConfigurationElementsFor(extensionPointId);
for (IConfigurationElement relationship : relationships) {
if (relationship.getAttribute("id").equals(relationshipId)) {
try {
return (T) relationship.createExecutableExtension("class");
} catch (IllegalArgumentException | CoreException e) {
e.printStackTrace();
}
}
}
return null;
}
//launch the event manager
public void launch() {
JavaEngineLauncher engineLauncher = new JavaEngineLauncher();
engineLauncher.setUp(this.MUTPath, this.DSLPath);
PlainK3ExecutionEngine engine = null;
try {
engine = engineLauncher.createExecutionEngine();
} catch (EngineContextException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String languageName = engineLauncher.getDslName(this.DSLPath);
Resource MUTResource = engineLauncher.getModelResource();
GenericEventManager eventManager = new GenericEventManager(
languageName, MUTResource, implementationRelationships, subtypingRelationships);
engine.getExecutionContext().getExecutionPlatform().addEngineAddon(eventManager);
LinkedTransferQueue<EventOccurrence> eventOccurrences = new LinkedTransferQueue<>();
}
public List<IImplementationRelationship> getImplementationRelationships() {
return implementationRelationships;
}
public List<ISubtypingRelationship> getSubtypingRelationships() {
return subtypingRelationships;
}
public void setDSLPath (String DSLPath) {
this.DSLPath = DSLPath;
}
public void setMUTPath (String MUTPath) {
this.MUTPath = MUTPath;
}
}
......@@ -2,6 +2,7 @@ package org.imt.tdl.executionEngine;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
......@@ -31,7 +32,6 @@ import org.eclipse.gemoc.ale.interpreted.engine.sirius.ALESiriusInterpreterProvi
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.dsl.debug.ide.launch.AbstractDSLLaunchConfigurationDelegate;
import org.eclipse.gemoc.dsl.debug.ide.sirius.ui.launch.AbstractDSLLaunchConfigurationDelegateSiriusUI;
import org.eclipse.gemoc.execution.sequential.javaengine.PlainK3ExecutionEngine;
import org.eclipse.gemoc.executionframework.engine.commons.DslHelper;
import org.eclipse.gemoc.executionframework.engine.commons.EngineContextException;
import org.eclipse.gemoc.executionframework.engine.commons.GenericModelExecutionContext;
......@@ -131,8 +131,6 @@ public class ALEEngineLauncher extends AbstractEngine{
IEngineAddon aleRTDInterpreter = new ALESiriusInterpreterProviderAddon();
Activator.getDefault().getMessaggingSystem().debug("Enabled implicit addon: "+ aleRTDInterpreter.getAddonID(), Activator.PLUGIN_ID);
engine.getExecutionContext().getExecutionPlatform().addEngineAddon(aleRTDInterpreter);
//add testEngineAddon to use it for running dsl-specific commands
engine.getExecutionContext().getExecutionPlatform().addEngineAddon(this.testEngineAddon);
return engine;
}
private String getDslName(String dslFilePath) {
......
package org.imt.tdl.executionEngine;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gemoc.executionframework.engine.commons.DslHelper;
import org.eclipse.gemoc.executionframework.engine.commons.K3DslHelper;
import org.eclipse.gemoc.xdsmlframework.api.engine_addon.IEngineAddon;
import org.osgi.framework.Bundle;
public abstract class AbstractEngine implements IExecutionEngine{
private Resource MUTResource = null;
public IEngineAddon testEngineAddon = new TestEngineAddon();
@Override
public void setUp(String MUTPath, String DSLPath) {
......
package org.imt.tdl.executionEngine;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Set;
......@@ -14,10 +15,10 @@ import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gemoc.execution.sequential.javaengine.PlainK3ExecutionEngine;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.dsl.debug.ide.launch.AbstractDSLLaunchConfigurationDelegate;
import org.eclipse.gemoc.dsl.debug.ide.sirius.ui.launch.AbstractDSLLaunchConfigurationDelegateSiriusUI;
import org.eclipse.gemoc.execution.sequential.javaengine.PlainK3ExecutionEngine;
import org.eclipse.gemoc.executionframework.engine.commons.DslHelper;
import org.eclipse.gemoc.executionframework.engine.commons.EngineContextException;
import org.eclipse.gemoc.executionframework.engine.commons.GenericModelExecutionContext;
......@@ -102,7 +103,7 @@ public class JavaEngineLauncher extends AbstractEngine{
this.setModelResource(javaEngine.getExecutionContext().getResourceModel());
return "PASS: The model under test executed successfully";
}
private PlainK3ExecutionEngine createExecutionEngine() throws EngineContextException{
public PlainK3ExecutionEngine createExecutionEngine() throws EngineContextException{
// create and initialize engine
PlainK3ExecutionEngine engine = new PlainK3ExecutionEngine();
CustomModelExecutionContext executioncontext = null;
......@@ -114,11 +115,9 @@ public class JavaEngineLauncher extends AbstractEngine{
}
executioncontext.setResourceModel(this.getModelResource());
engine.initialize(executioncontext);
//add testEngineAddon to use it for running dsl-specific commands
engine.getExecutionContext().getExecutionPlatform().addEngineAddon(this.testEngineAddon);
return engine;
}
private String getDslName(String dslFilePath) {
public String getDslName(String dslFilePath) {
Resource dslRes = (new ResourceSetImpl()).getResource(URI.createURI(dslFilePath), true);
Dsl dsl = (Dsl)dslRes.getContents().get(0);
return dsl.getEntry("name").getValue().toString();
......
package org.imt.tdl.executionEngine;
import org.eclipse.gemoc.trace.commons.model.trace.Step;
import org.eclipse.gemoc.xdsmlframework.api.core.IExecutionEngine;
import org.eclipse.gemoc.xdsmlframework.api.engine_addon.IEngineAddon;
public class TestEngineAddon implements IEngineAddon{
@Override
public void aboutToExecuteStep(IExecutionEngine<?> engine, Step<?> stepToExecute) {
// TODO Auto-generated method stub
IEngineAddon.super.aboutToExecuteStep(engine, stepToExecute);
}
@Override
public void stepExecuted(IExecutionEngine<?> engine, Step<?> stepExecuted) {
// TODO Auto-generated method stub
IEngineAddon.super.stepExecuted(engine, stepExecuted);
}
}
......@@ -13,7 +13,6 @@ Require-Bundle: org.eclipse.gemoc.execution.sequential.javaengine.ui,
org.eclipse.gemoc.dsl.debug.ide;bundle-version="3.0.1",
org.eclipse.gemoc.dsl.debug.ide.sirius.ui;bundle-version="3.0.1",
org.eclipse.gemoc.executionframework.engine.ui;bundle-version="4.0.0",
org.eclipse.gemoc.execution.sequential.javaengine,
fr.inria.diverse.k3.al.annotationprocessor.plugin;bundle-version="3.2.3",
org.etsi.mts.tdl.model;bundle-version="1.4.0",
org.imt.k3tdl.tdlInterpreter;bundle-version="1.0.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment