Enable to check acceptable source for an execution.

(1) Add capability to provide a root task execution factory
(2) Handle invalid (null or not executable) source

Change-Id: I35cefc4abb518c0d25cd35c705ffc9f9aa4075ec
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/IUMLTaskExecutionFactory.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/IUMLTaskExecutionFactory.java
index 1e87cdf..a1fcc56 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/IUMLTaskExecutionFactory.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/IUMLTaskExecutionFactory.java
@@ -14,12 +14,14 @@
  *****************************************************************************/
 package org.eclipse.papyrus.moka.engine.uml.scheduling;
 
+import org.eclipse.uml2.uml.Element;
+
 public interface IUMLTaskExecutionFactory {
 
 	IUMLEventDispatchLoopExecution createEventDispatchLoopExecution();
 	
 	IUMLEventSendingExecution createEventSendingExecution();
 	
-	IUMLRootExecution createRootExecution();
+	UMLRootExecution<?> createRootExecution(final Element executionRoot);
 	
 }
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootBehaviorTaskExecution.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootBehaviorTaskExecution.java
new file mode 100644
index 0000000..bcf3016
--- /dev/null
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootBehaviorTaskExecution.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   CEA LIST - Initial API and implementation
+ *   
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine.uml.scheduling;
+
+import java.util.List;
+
+import org.eclipse.papyrus.moka.fuml.commonbehavior.IParameterValue;
+import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IValue;
+import org.eclipse.papyrus.moka.kernel.scheduling.control.IExecutionLoop;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.StateMachine;
+
+public class RootBehaviorTaskExecution extends UMLRootExecution<Behavior>{
+
+	public RootBehaviorTaskExecution(IExecutionLoop loop, Behavior executionRoot) {
+		super(loop, executionRoot);
+	}
+	
+	@Override
+	public boolean canExecute() {
+		return root instanceof Activity || root instanceof StateMachine;
+	}
+	
+	@Override
+	public void execute() {
+		List<IParameterValue> outputParameterValues = locus.getExecutor().execute(root, null, parameterValues);
+		for (IParameterValue outputParameterValue : outputParameterValues) {
+			setParameterValue(outputParameterValue);
+		}
+	}
+	
+	@Override
+	public IValue new_() {
+		return new RootBehaviorTaskExecution(executionLoop, root);
+	}
+
+}
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootClassTaskExecution.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootClassTaskExecution.java
new file mode 100644
index 0000000..7bc2bdd
--- /dev/null
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/RootClassTaskExecution.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   CEA LIST - Initial API and implementation
+ *   
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine.uml.scheduling;
+
+import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IValue;
+import org.eclipse.papyrus.moka.kernel.scheduling.control.IExecutionLoop;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.StateMachine;
+
+public class RootClassTaskExecution extends UMLRootExecution<Class>{
+
+	public RootClassTaskExecution(IExecutionLoop loop, Class executionRoot) {
+		super(loop, executionRoot);
+	}
+
+	@Override
+	public boolean canExecute() {
+		return root.isActive() && (root.getClassifierBehavior() instanceof StateMachine || root.getClassifierBehavior() instanceof Activity);
+	}
+	
+	@Override
+	public void execute() {
+		locus.getExecutor().start(root, parameterValues);
+	}
+	
+	@Override
+	public IValue new_() {
+		// TODO Auto-generated method stub
+		return super.new_();
+	}
+	
+}
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLEventDispatchLoopExecution.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLEventDispatchLoopExecution.java
index 20c66ac..245b867 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLEventDispatchLoopExecution.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLEventDispatchLoopExecution.java
@@ -129,7 +129,8 @@
 			DebugAssistantException debugAssistantException) {
 		Suspension suspension = new Suspension(debugAssistantException.getDebugAssistant(),
 				SuspensionReasons.ERROR_DETECTION);
-		if (executionEngineService.shouldContinueInDebugAssistant(debugAssistantException.getDebugAssistant().getAssistantID())) {
+		if (executionEngineService
+				.shouldContinueInDebugAssistant(debugAssistantException.getDebugAssistant().getAssistantID())) {
 			Element node = debugAssistantException.getVisitorNode();
 			ISemanticVisitor visitor = debugAssistantException.getVisitor();
 			if (node != null) {
@@ -202,12 +203,11 @@
 
 	@Override
 	public String toString() {
-		return "EventDispatchLoopExecution(" + dispatchLoop + ")";
+		return "EventDispatchLoopExecution(" + dispatchLoop + ")"; //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Override
 	public void suspend() {
-		System.out.println("Suspend -> " + this);
 		if (!dispatchLoopLock.isHeldByCurrentThread()) {
 			dispatchLoopLock.lock();
 		}
@@ -223,7 +223,6 @@
 
 	@Override
 	public void resume() {
-		System.out.println("Resume -> " + this);
 	}
 
 	@Override
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLRootExecution.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLRootExecution.java
index e28bd63..56d118d 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLRootExecution.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLRootExecution.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST and others.
+ * Copyright (c) 2019, 2020 CEA LIST and others.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -19,65 +19,29 @@
 
 import org.eclipse.papyrus.moka.fuml.commonbehavior.IExecution;
 import org.eclipse.papyrus.moka.fuml.commonbehavior.IParameterValue;
-import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IValue;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.IExecutionLoop;
-import org.eclipse.uml2.uml.Activity;
-import org.eclipse.uml2.uml.Behavior;
-import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.Parameter;
 import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.StateMachine;
 
-public class UMLRootExecution extends UMLTaskExecution implements IUMLRootExecution{
+public abstract class UMLRootExecution<RootElementType extends Element> extends UMLTaskExecution{
 
 	/**
-	 * Model element considered as the root of the execution
+	 * Model element from which the execution starts
 	 */
-	protected Class root;
+	protected RootElementType root;
 
 	/**
 	 * Root execution parameter values
 	 */
 	protected List<IParameterValue> parameterValues;
 
-	public UMLRootExecution(IExecutionLoop loop) {
+	public UMLRootExecution(IExecutionLoop loop, RootElementType executionRoot) {
 		super(loop);
+		root = executionRoot;
 		parameterValues = new ArrayList<IParameterValue>();
 	}
 
-	/**
-	 * 
-	 */
-	@Override
-	public void setRoot(Class r) {
-		root = r;
-	}
-
-	/**
-	 * @see {@linkIExecution#setParameterValue(IParameterValue)}
-	 */
-	@Override
-	public Class getRoot() {
-		return root;
-	}
-
-	@Override
-	public boolean canExecute() {
-		if (root != null) {
-			if (!root.isAbstract()) {
-				if (isBehavior()) {
-					if (root instanceof Activity) {
-						return true;
-					} else
-						return root instanceof StateMachine && root.isActive();
-				}
-			} else if (root instanceof Class) {
-				return root.isActive();
-			}
-		}
-		return false;
-	}
-
 	/***
 	 * @see {@link IExecution#setParameterValue(IParameterValue)}
 	 * 
@@ -166,32 +130,6 @@
 			setParameterValue(inputParameterValue);
 		}
 	}
-
-	private boolean isBehavior() {
-		return root instanceof Behavior;
-	}
-
-	/**
-	 * see {@link IExecution#execute()}
-	 * 
-	 * Execution of the root takes place in two situations: (1) the root is active -
-	 * it is either a behavior or a class (2) the root is a behavior Output
-	 * parameter values may only be returned if (2) occurs.
-	 */
-	@Override
-	public void execute() {
-		if (root != null) {
-			if (root.isActive()) {
-				locus.getExecutor().start(root, parameterValues);
-			} else if (isBehavior()) {
-				List<IParameterValue> outputParameterValues = locus.getExecutor().execute((Behavior) root, null,
-						parameterValues);
-				for (IParameterValue outputParameterValue : outputParameterValues) {
-					setParameterValue(outputParameterValue);
-				}
-			}
-		}
-	}
 	
 	@Override
 	public void suspend() {
@@ -203,15 +141,8 @@
 	}
 
 	@Override
-	public IValue new_() {
-		IUMLRootExecution rootExecution = new UMLRootExecution(executionLoop);
-		rootExecution.setRoot(root);
-		return rootExecution;
-	}
-
-	@Override
 	public String toString() {
-		return "RootExecution()";
+		return "RootExecution()"; //$NON-NLS-1$
 	}
 
 }
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLTaskExecutionFactory.java b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLTaskExecutionFactory.java
index 72028ba..3eed75c 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLTaskExecutionFactory.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.scheduling/src/org/eclipse/papyrus/moka/engine/uml/scheduling/UMLTaskExecutionFactory.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST and others.
+ * Copyright (c) 2019, 2020 CEA LIST and others.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -15,42 +15,59 @@
 package org.eclipse.papyrus.moka.engine.uml.scheduling;
 
 import org.eclipse.papyrus.moka.kernel.scheduling.control.IExecutionLoop;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
 
-public class UMLTaskExecutionFactory implements IUMLTaskExecutionFactory{
+public class UMLTaskExecutionFactory implements IUMLTaskExecutionFactory {
 
-	protected static UMLTaskExecutionFactory FACTORY; 
-	
+	/**
+	 * Factory instance
+	 */
+	private static UMLTaskExecutionFactory FACTORY;
+
 	protected IExecutionLoop executionLoop;
-	
+
 	protected UMLTaskExecutionFactory() {
 		executionLoop = null;
 	}
 
-	public static UMLTaskExecutionFactory getFactory() {
-		if(FACTORY == null) {
+	/**
+	 * Create (if required) and return the factory instance
+	 * 
+	 * @return the task factory
+	 */
+	public static UMLTaskExecutionFactory getInstance() {
+		if (FACTORY == null) {
 			FACTORY = new UMLTaskExecutionFactory();
 		}
 		return FACTORY;
 	}
-	
+
 	public IExecutionLoop getExecutionLoop() {
 		return executionLoop;
 	}
-	
+
 	public void setExecutionLoop(IExecutionLoop loop) {
 		executionLoop = loop;
 	}
-	
+
 	public IUMLEventDispatchLoopExecution createEventDispatchLoopExecution() {
 		return new UMLEventDispatchLoopExecution(executionLoop);
 	}
-	
+
 	public IUMLEventSendingExecution createEventSendingExecution() {
 		return new UMLEventSendingTaskExecution(executionLoop);
 	}
-	
-	public IUMLRootExecution createRootExecution() {
-		return new UMLRootExecution(executionLoop);
+
+	public UMLRootExecution<?> createRootExecution(final Element executionRoot) {
+		UMLRootExecution<?> rootExecution = null;
+		if (executionRoot instanceof Behavior) {
+			rootExecution = new RootBehaviorTaskExecution(executionLoop, (Behavior) executionRoot);
+		} else if (executionRoot instanceof Class) {
+			rootExecution = new RootClassTaskExecution(executionLoop, (Class) executionRoot);
+		}
+		return rootExecution;
 	}
-	
+
 }
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.time/META-INF/MANIFEST.MF b/plugins/org.eclipse.papyrus.moka.engine.uml.time/META-INF/MANIFEST.MF
index 502e928..2583e1d 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.time/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.time/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@
  org.eclipse.papyrus.moka.engine.uml,
  org.eclipse.papyrus.moka.kernel.scheduling,
  org.eclipse.papyrus.moka.engine.uml.scheduling,
- org.eclipse.papyrus.moka.kernel.debug
+ org.eclipse.papyrus.moka.kernel.debug,
+ org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.papyrus.moka.engine.uml.time;
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/Activator.java b/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/Activator.java
index 8a884e1..0d09997 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/Activator.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/Activator.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2016 CEA LIST.
+ * Copyright (c) 2016, 2020 CEA LIST.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -13,53 +13,37 @@
  *****************************************************************************/
 package org.eclipse.papyrus.moka.engine.uml.time;
 
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
-
-	// The plug-in ID
-	public static final String PLUGIN_ID = "org.eclipse.papyrus.moka.timedfuml"; //$NON-NLS-1$
-
-	// The shared instance
-	private static Activator plugin;
+public class Activator implements BundleActivator {
 
 	/**
-	 * The constructor
+	 * Plugin instance
 	 */
-	public Activator() {
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	private static Activator PLUGIN;
+	
+	/**
+	 * Logger used within that plugin
 	 */
+	public static LogHelper LOGGER;
+	
+	@Override
 	public void start(BundleContext context) throws Exception {
-		super.start(context);
-		plugin = this;
+		PLUGIN = this;
+		LOGGER = new LogHelper(context.getBundle());
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
-	 */
+	@Override
 	public void stop(BundleContext context) throws Exception {
-		plugin = null;
-		super.stop(context);
+		LOGGER = null;
+		PLUGIN = null;
 	}
-
-	/**
-	 * Returns the shared instance
-	 *
-	 * @return the shared instance
-	 */
-	public static Activator getDefault() {
-		return plugin;
+	
+	public static Activator getInstance(){
+		return PLUGIN;
 	}
 
 }
+
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/UMLTimedExecutionEngine.java b/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/UMLTimedExecutionEngine.java
index 838c249..5cbe8fe 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/UMLTimedExecutionEngine.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml.time/src/org/eclipse/papyrus/moka/engine/uml/time/UMLTimedExecutionEngine.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2016 CEA LIST.
+ * Copyright (c) 2016, 2020 CEA LIST.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -17,8 +17,7 @@
 
 import org.eclipse.core.runtime.SubMonitor;
 import org.eclipse.papyrus.moka.engine.uml.UMLExecutionEngine;
-import org.eclipse.papyrus.moka.engine.uml.scheduling.IUMLRootExecution;
-import org.eclipse.papyrus.moka.engine.uml.scheduling.UMLTaskExecutionFactory;
+import org.eclipse.papyrus.moka.engine.uml.scheduling.UMLRootExecution;
 import org.eclipse.papyrus.moka.engine.uml.time.scheduling.control.TimedExecutionLoop;
 import org.eclipse.papyrus.moka.engine.uml.time.scheduling.de.DEScheduler;
 import org.eclipse.papyrus.moka.engine.uml.time.scheduling.de.actions.DisplayCurrentTimeAction;
@@ -26,11 +25,12 @@
 import org.eclipse.papyrus.moka.engine.uml.time.semantics.Loci.TimedLocus;
 import org.eclipse.papyrus.moka.fuml.commonbehavior.IParameterValue;
 import org.eclipse.papyrus.moka.fuml.loci.ILocus;
+import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngineException;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.ExecutionController;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.IExecutionController;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.Scheduler;
 import org.eclipse.papyrus.moka.pscs.loci.CS_Executor;
-import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
 
 public class UMLTimedExecutionEngine extends UMLExecutionEngine{
 
@@ -72,21 +72,26 @@
 	}
 	
 	@Override
-	public void start(SubMonitor monitor) {
+	public void start(SubMonitor monitor) throws ExecutionEngineException {
 		// Starts the execution loop
-		Class source = configuration.getExecutionSource();
+		Element source = (Element) configuration.getExecutionSource();
 		if(locus != null && source != null) {
-			initDEScheduler();
-			doPreRunActions();
-			UMLTaskExecutionFactory factory = UMLTaskExecutionFactory.getFactory();
-			factory.setExecutionLoop(controller.getExecutionLoop());
-			IUMLRootExecution rootExecution = factory.createRootExecution();
-			rootExecution.setRoot(source);
-			rootExecution.setLocus(locus);
-			rootExecution.setInputParameterValues(new ArrayList<IParameterValue>());
-			controller.getExecutionLoop().init(rootExecution, new Scheduler());
-			controller.start();
-			doPostRunActions();
+			UMLRootExecution<?> rootExecution = rootTaskFactory.createRootExecution(source);
+			if(rootExecution != null) {
+				rootExecution.setLocus(locus);
+				rootExecution.setInputParameterValues(new ArrayList<IParameterValue>());
+				if(rootExecution.canExecute()) {
+					initDEScheduler();
+					doPreRunActions();
+					controller.getExecutionLoop().init(rootExecution, new Scheduler());
+					controller.start();
+					doPostRunActions();
+				} else {
+					throw new ExecutionEngineException(identifier, status, "Could not start the execution from the specified model element"); //$NON-NLS-1$
+				}
+			} else {
+				throw new ExecutionEngineException(identifier, status, "Could not instantiate an execution from the specified element"); //$NON-NLS-1$
+			}
 		}
 	}
 
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml/META-INF/MANIFEST.MF b/plugins/org.eclipse.papyrus.moka.engine.uml/META-INF/MANIFEST.MF
index 17061f7..e96d9e3 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml/META-INF/MANIFEST.MF
@@ -18,6 +18,10 @@
  org.eclipse.papyrus.moka.engine.uml.scheduling,
  org.eclipse.papyrus.moka.kernel.debug,
  org.eclipse.papyrus.moka.engine.uml.debug,
- org.eclipse.papyrus.moka.kernel.scheduling
+ org.eclipse.papyrus.moka.kernel.scheduling,
+ org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.jface
 Export-Package: org.eclipse.papyrus.moka.engine.uml,
  org.eclipse.papyrus.moka.engine.uml.libraries
+Bundle-Activator: org.eclipse.papyrus.moka.engine.uml.Activator
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/Activator.java b/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/Activator.java
new file mode 100644
index 0000000..ad3523f
--- /dev/null
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/Activator.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   CEA LIST - Initial API and implementation
+ *   
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine.uml;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	/**
+	 * Plugin instance
+	 */
+	private static Activator PLUGIN;
+	
+	/**
+	 * Logger used within that plugin
+	 */
+	public static LogHelper LOGGER;
+	
+	@Override
+	public void start(BundleContext context) throws Exception {
+		PLUGIN = this;
+		LOGGER = new LogHelper(context.getBundle());
+	}
+
+	@Override
+	public void stop(BundleContext context) throws Exception {
+		LOGGER = null;
+		PLUGIN = null;
+	}
+	
+	public static Activator getInstance(){
+		return PLUGIN;
+	}
+
+}
diff --git a/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/UMLExecutionEngine.java b/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/UMLExecutionEngine.java
index 7e078f3..c471614 100644
--- a/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/UMLExecutionEngine.java
+++ b/plugins/org.eclipse.papyrus.moka.engine.uml/src/org/eclipse/papyrus/moka/engine/uml/UMLExecutionEngine.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST and others.
+ * Copyright (c) 2019, 2020 CEA LIST and others.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -21,8 +21,9 @@
 import org.eclipse.papyrus.moka.debug.engine.IDebuggableExecutionEngine;
 import org.eclipse.papyrus.moka.debug.engine.IDebuggableExecutionEngineThread;
 import org.eclipse.papyrus.moka.engine.uml.libraries.LibraryRegistry;
-import org.eclipse.papyrus.moka.engine.uml.scheduling.IUMLRootExecution;
+import org.eclipse.papyrus.moka.engine.uml.scheduling.IUMLTaskExecutionFactory;
 import org.eclipse.papyrus.moka.engine.uml.scheduling.IsTargetThreadCondition;
+import org.eclipse.papyrus.moka.engine.uml.scheduling.UMLRootExecution;
 import org.eclipse.papyrus.moka.engine.uml.scheduling.UMLTaskExecutionFactory;
 import org.eclipse.papyrus.moka.fuml.actions.DefaultCreateObjectActionStrategy;
 import org.eclipse.papyrus.moka.fuml.actions.DefaultGetAssociationStrategy;
@@ -33,6 +34,7 @@
 import org.eclipse.papyrus.moka.fuml.loci.ISemanticVisitor;
 import org.eclipse.papyrus.moka.fuml.structuredclassifiers.IObject_;
 import org.eclipse.papyrus.moka.kernel.engine.EngineConfiguration;
+import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngineException;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.Scheduler;
 import org.eclipse.papyrus.moka.pscs.actions.additions.CS_NotNormativeDefaultConstructStrategy;
 import org.eclipse.papyrus.moka.pscs.loci.CS_Executor;
@@ -42,7 +44,7 @@
 import org.eclipse.papyrus.moka.pssm.loci.SM_ExecutionFactory;
 import org.eclipse.papyrus.moka.pssm.loci.SM_Locus;
 import org.eclipse.papyrus.moka.utils.UMLPrimitiveTypesUtils;
-import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
 
 public class UMLExecutionEngine extends DebuggableExecutionEngine<IObject_, ISemanticVisitor>
 		implements IUMLExecutionEngine {
@@ -53,13 +55,19 @@
 	protected ILocus locus;
 
 	/**
+	 * Factory enabling the creation of the appropriate root task for this engine
+	 */
+	protected IUMLTaskExecutionFactory rootTaskFactory;
+	
+	/**
 	 * Behave as the super class. In addition, instantiate the locus and
 	 * parameterize it with the appropriate execution factory and executor. Finally,
 	 * built in types, libraries and semantic strategies are installed at the locus
 	 */
 	@Override
-	public void init(EngineConfiguration configuration, SubMonitor monitor) {
+	public void init(EngineConfiguration<?> configuration, SubMonitor monitor) {
 		super.init(configuration, monitor);
+		rootTaskFactory = createUMLTaskFactory();
 		locus = createLocus();
 		installBuiltInTypes();
 		installLibraries();
@@ -67,6 +75,17 @@
 	}
 
 	/**
+	 * Create the UML task factory used by this engine
+	 * 
+	 * @return the task factory
+	 */
+	protected IUMLTaskExecutionFactory createUMLTaskFactory() {
+		UMLTaskExecutionFactory factory = UMLTaskExecutionFactory.getInstance();
+		factory.setExecutionLoop(controller.getExecutionLoop());
+		return factory;
+	}
+	
+	/**
 	 * Create and parameterize the locus
 	 */
 	@Override
@@ -82,20 +101,25 @@
 	 * execution to the execution queue controlled by the execution controller
 	 */
 	@Override
-	public void start(SubMonitor monitor) {
-		Class source = configuration.getExecutionSource();
+	public void start(SubMonitor monitor) throws ExecutionEngineException {
+		Element source = (Element) configuration.getExecutionSource();
 		if (locus != null && source != null) {
-			UMLTaskExecutionFactory factory = UMLTaskExecutionFactory.getFactory();
-			factory.setExecutionLoop(controller.getExecutionLoop());
-			IUMLRootExecution rootExecution = factory.createRootExecution();
-			rootExecution.setRoot(source);
-			rootExecution.setLocus(locus);
-			rootExecution.setInputParameterValues(new ArrayList<IParameterValue>());
-			controller.getExecutionLoop().init(rootExecution, new Scheduler());
-			SubMonitor progress = monitor.split(1);
-			progress.subTask("Run model");
-			controller.start();
-			progress.worked(1);
+			UMLRootExecution<?> rootExecution = rootTaskFactory.createRootExecution(source);
+			if(rootExecution != null) {
+				rootExecution.setLocus(locus);
+				rootExecution.setInputParameterValues(new ArrayList<IParameterValue>());
+				if(rootExecution.canExecute()) {
+					controller.getExecutionLoop().init(rootExecution, new Scheduler());
+					SubMonitor progress = monitor.split(1);
+					progress.subTask("Run model"); //$NON-NLS-1$
+					controller.start();
+					progress.worked(1);
+				} else {
+					throw new ExecutionEngineException(identifier, status, "Could not start the execution from the specified model element"); //$NON-NLS-1$
+				}
+			} else {
+				throw new ExecutionEngineException(identifier, status, "Could not instantiate an execution from the specified element"); //$NON-NLS-1$
+			}
 		}
 	}
 
@@ -104,7 +128,7 @@
 	 */
 	@Override
 	public void installBuiltInTypes() {
-		Class source = configuration.getExecutionSource();
+		Element source = (Element) configuration.getExecutionSource();
 		if (locus != null && source != null) {
 			locus.getFactory().addBuiltInType(UMLPrimitiveTypesUtils.getReal(source));
 			locus.getFactory().addBuiltInType(UMLPrimitiveTypesUtils.getInteger(source));
@@ -118,7 +142,7 @@
 	 */
 	@Override
 	public void installLibraries() {
-		Class source = configuration.getExecutionSource();
+		Element source = (Element) configuration.getExecutionSource();
 		if (locus != null && source.eResource() != null && source.eResource().getResourceSet() != null) {
 			LibraryRegistry.getInstance().loadLibraryFactories(source.eResource().getResourceSet());
 			LibraryRegistry.getInstance().installLibraries(locus);
diff --git a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/CallEventExecution.java b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/CallEventExecution.java
index b7650a4..c4be834 100644
--- a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/CallEventExecution.java
+++ b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/CallEventExecution.java
@@ -19,8 +19,6 @@
 import java.util.List;
 
 import org.eclipse.papyrus.moka.engine.uml.scheduling.UMLTaskExecutionFactory;
-import org.eclipse.papyrus.moka.fuml.commonbehavior.ICallEventOccurrence;
-import org.eclipse.papyrus.moka.fuml.commonbehavior.IEventOccurrence;
 import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IValue;
 import org.eclipse.papyrus.moka.fuml.structuredclassifiers.IReference;
 import org.eclipse.papyrus.moka.fuml.structuredclassifiers.Reference;
@@ -145,7 +143,7 @@
 		// Wait for an indeterminate amount of time to allow other concurrent
 		// executions to proceed.
 		// [There is no further formal specification for this operation.]
-		IExecutionLoop executionLoop = UMLTaskExecutionFactory.getFactory().getExecutionLoop();
+		IExecutionLoop executionLoop = UMLTaskExecutionFactory.getInstance().getExecutionLoop();
 		if(executionLoop != null) {
 			executionLoop.step();
 		}
diff --git a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/EventOccurrence.java b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/EventOccurrence.java
index 073b66c..0c2f80b 100644
--- a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/EventOccurrence.java
+++ b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/EventOccurrence.java
@@ -65,7 +65,7 @@
 	public void _startObjectBehavior() {
 		// When the sending behavior starts, the current event
 		// occurrence is is forwarded to the target object.
-		IUMLEventSendingExecution execution = UMLTaskExecutionFactory.getFactory().createEventSendingExecution();
+		IUMLEventSendingExecution execution = UMLTaskExecutionFactory.getInstance().createEventSendingExecution();
 		execution.setEvent(this);
 		execution.schedule();
 	}
diff --git a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/ObjectActivation.java b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/ObjectActivation.java
index 08d035f..51e94bc 100644
--- a/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/ObjectActivation.java
+++ b/plugins/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/commonbehavior/ObjectActivation.java
@@ -197,7 +197,7 @@
 	public void _startObjectBehavior() {
 		// *** This should start the EventDispatchLoop ***
 		if(dispatchLoopExecution == null){
-			dispatchLoopExecution = UMLTaskExecutionFactory.getFactory().createEventDispatchLoopExecution();
+			dispatchLoopExecution = UMLTaskExecutionFactory.getInstance().createEventDispatchLoopExecution();
 			dispatchLoopExecution.setObjectActivation(this);
 		}
 		dispatchLoopExecution.newSignalArrival();
diff --git a/plugins/org.eclipse.papyrus.moka.kernel.debug/src/org/eclipse/papyrus/moka/debug/engine/DebuggableExecutionEngine.java b/plugins/org.eclipse.papyrus.moka.kernel.debug/src/org/eclipse/papyrus/moka/debug/engine/DebuggableExecutionEngine.java
index b6632c2..64c34ab 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel.debug/src/org/eclipse/papyrus/moka/debug/engine/DebuggableExecutionEngine.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel.debug/src/org/eclipse/papyrus/moka/debug/engine/DebuggableExecutionEngine.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST.
+ * Copyright (c) 2019, 2020 CEA LIST.
  *
  *
  * All rights reserved. This program and the accompanying materials
@@ -25,6 +25,7 @@
 import org.eclipse.papyrus.moka.debug.service.IDebugService;
 import org.eclipse.papyrus.moka.kernel.engine.EngineConfiguration;
 import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngine;
+import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngineException;
 import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngineStatus;
 import org.eclipse.papyrus.moka.kernel.engine.IExecutionEngine;
 import org.eclipse.papyrus.moka.kernel.scheduling.control.ExecutionController;
@@ -33,8 +34,8 @@
 import org.eclipse.papyrus.moka.kernel.service.IExecutionEngineService;
 import org.eclipse.papyrus.moka.kernel.service.ServiceRegistry;
 
-public abstract class DebuggableExecutionEngine<T, C> extends ExecutionEngine
-		implements IDebuggableExecutionEngine<T, C> {
+public abstract class DebuggableExecutionEngine<TThreadType, ContextType>extends ExecutionEngine
+		implements IDebuggableExecutionEngine<TThreadType, ContextType> {
 
 	/**
 	 * Controller in charge of the execution task management
@@ -44,7 +45,7 @@
 	/**
 	 * Map of thread for which debugging is enabled;
 	 */
-	protected Map<String, IDebuggableExecutionEngineThread<T, C>> debuggableThread;
+	protected Map<String, IDebuggableExecutionEngineThread<TThreadType, ContextType>> debuggableThread;
 
 	/**
 	 * Enable safe access and modification of the thread map.
@@ -53,25 +54,28 @@
 
 	public DebuggableExecutionEngine() {
 		super();
-		debuggableThread = new HashMap<String, IDebuggableExecutionEngineThread<T, C>>();
+		debuggableThread = new HashMap<String, IDebuggableExecutionEngineThread<TThreadType, ContextType>>();
 		debuggableThreadLock = new ReentrantLock(true);
 	}
 
 	@Override
-	public void init(EngineConfiguration configuration, SubMonitor monitor) {
+	public void init(EngineConfiguration<?> configuration, SubMonitor monitor) {
 		super.init(configuration, monitor);
 		controller = createController();
 	}
 
-	public void run(final EngineConfiguration configuration, SubMonitor monitor) {
+	public void run(final EngineConfiguration<?> configuration, SubMonitor monitor) throws ExecutionEngineException {
 		setStatus(ExecutionEngineStatus.INITIALIZING);
 		init(configuration, monitor);
 		setStatus(ExecutionEngineStatus.RUNNING);
-		start(monitor);
-		fireTerminateExecutionEvent();
-		setStatus(ExecutionEngineStatus.DISPOSING);
-		dispose(monitor);
-		setStatus(ExecutionEngineStatus.TERMINATED);
+		try {
+			start(monitor);
+		} finally {
+			fireTerminateExecutionEvent();
+			setStatus(ExecutionEngineStatus.DISPOSING);
+			dispose(monitor);
+			setStatus(ExecutionEngineStatus.TERMINATED);
+		}
 	}
 
 	/**
@@ -87,7 +91,7 @@
 	/**
 	 *  @see {@link IDebuggableExecutionEngine#addDebugThread(IDebuggableExecutionEngineThread)}
 	 */
-	public boolean addDebugThread(IDebuggableExecutionEngineThread<T, C> t) {
+	public boolean addDebugThread(IDebuggableExecutionEngineThread<TThreadType, ContextType> t) {
 		boolean added = false;
 		if(t != null) {
 			if(!debuggableThreadLock.isHeldByCurrentThread()) {
@@ -105,7 +109,7 @@
 	/**
 	 *  @see {@link IDebuggableExecutionEngine#removeDebugThread(IDebuggableExecutionEngineThread)}
 	 */
-	public boolean removeDebugThread(IDebuggableExecutionEngineThread<T, C> t) {
+	public boolean removeDebugThread(IDebuggableExecutionEngineThread<TThreadType, ContextType> t) {
 		boolean removed = false;
 		if(t != null) {
 			if(!debuggableThreadLock.isHeldByCurrentThread()) {
@@ -198,20 +202,20 @@
 	}
 
 	private void fireTerminateExecutionEvent() {
-		IDebugService<T, C> service = getDebugService();
+		IDebugService<TThreadType, ContextType> service = getDebugService();
 		if (service != null) {
 			service.fireTerminateEngineEvent();
 		}
 	}
 
 	@SuppressWarnings("unchecked")
-	public final IDebugService<T, C> getDebugService() {
+	public final IDebugService<TThreadType, ContextType> getDebugService() {
 		// Note: an execution engine has at most a single debug service
-		IDebugService<T, C> debugService = null;
+		IDebugService<TThreadType, ContextType> debugService = null;
 		Iterator<IExecutionEngineService<IExecutionEngine>> it = ServiceRegistry.getInstance()
 				.getService(IDebugService.class).iterator();
 		if (it.hasNext()) {
-			debugService = (IDebugService<T, C>) it.next();
+			debugService = (IDebugService<TThreadType, ContextType>) it.next();
 		}
 		return debugService;
 	}
diff --git a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/EngineConfiguration.java b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/EngineConfiguration.java
index 27ec591..b012606 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/EngineConfiguration.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/EngineConfiguration.java
@@ -20,10 +20,10 @@
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.papyrus.moka.kernel.service.ServiceOperatingMode;
-import org.eclipse.uml2.uml.Class;
 
-public class EngineConfiguration {
+public class EngineConfiguration<SourceElementType extends EObject> {
 
 	// The project containing the model to be executed
 	protected IProject project;
@@ -35,7 +35,7 @@
 	protected URI modelURI;
 	
 	// The model element that is used as a starting point for the execution
-	protected Class source;
+	protected SourceElementType source;
 
 	// The list of parameter passed to the execution engine
 	protected Map<String, String> parameters;
@@ -53,13 +53,13 @@
 		parameters = new HashMap<String, String>();
 	}
 
-	public EngineConfiguration(Class src, ServiceOperatingMode m) {
+	public EngineConfiguration(SourceElementType src, ServiceOperatingMode m) {
 		source = src;
 		mode = m;
 		parameters = new HashMap<String, String>();
 	}
 	
-	public EngineConfiguration(EngineConfiguration ec) {
+	public EngineConfiguration(EngineConfiguration<SourceElementType> ec) {
 		source = ec.getExecutionSource();
 		mode = ec.getMode();
 		parameters = new HashMap<String, String>();
@@ -74,11 +74,11 @@
 		tracepointMode = ec.isTracepointMode();
 	}
 
-	public void setExecutionSource(final Class src) {
+	public void setExecutionSource(final SourceElementType src) {
 		source = src;
 	}
 
-	public Class getExecutionSource() {
+	public SourceElementType getExecutionSource() {
 		return source;
 	}
 
diff --git a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngine.java b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngine.java
index 4bb581d..2e5dd01 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngine.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngine.java
@@ -30,28 +30,28 @@
 	/**
 	 * Initialization task message
 	 */
-	private static final String INITIALIZATION_TASK = "Initialize execution engine resources";
-	
+	private static final String INITIALIZATION_TASK = "Initialize execution engine resources"; //$NON-NLS-1$
+
 	/**
 	 * Dispose task message
 	 */
-	private static final String DISPOSE_TASK = "Dispose execution engine resources";
-	
+	private static final String DISPOSE_TASK = "Dispose execution engine resources"; //$NON-NLS-1$
+
 	/**
 	 * Engine ID
 	 */
 	protected String identifier;
-	
+
 	/**
 	 * Configuration used to parameterize the engine
 	 */
-	protected EngineConfiguration configuration;
-	
+	protected EngineConfiguration<?> configuration;
+
 	/**
 	 * Status associated with this engine
 	 */
 	protected ExecutionEngineStatus status;
-	
+
 	/**
 	 * Enable safe access and update of the status
 	 */
@@ -61,23 +61,23 @@
 		status = ExecutionEngineStatus.NONE;
 		statusLock = new ReentrantLock(true);
 	}
-	
+
 	@Override
 	public void setID(String id) {
 		identifier = id;
 	}
-	
+
 	@Override
 	public String getID() {
 		return identifier;
 	}
-	
+
 	protected void setStatus(ExecutionEngineStatus s) {
 		statusLock.lock();
 		status = s;
 		statusLock.unlock();
 	}
-	
+
 	protected ExecutionEngineStatus getStatus() {
 		ExecutionEngineStatus s = null;
 		statusLock.lock();
@@ -85,20 +85,20 @@
 		statusLock.unlock();
 		return s;
 	}
-	
-	public EngineConfiguration getConfiguration() {
+
+	public EngineConfiguration<?> getConfiguration() {
 		return configuration;
 	}
 
 	/**
 	 * @see {@link IExecutionEngine#run(EngineConfiguration, SubMonitor)}
 	 * 
-	 * Initialize, start and dispose the execution engine.
+	 *      Initialize, start and dispose the execution engine.
 	 * 
-	 * Clients are not intended to override this operation.
+	 *      Clients are not intended to override this operation.
 	 */
 	@Override
-	public void run(final EngineConfiguration configuration, SubMonitor monitor) {
+	public void run(final EngineConfiguration<?> configuration, SubMonitor monitor) throws ExecutionEngineException {
 		setStatus(ExecutionEngineStatus.INITIALIZING);
 		init(configuration, monitor);
 		setStatus(ExecutionEngineStatus.RUNNING);
@@ -113,9 +113,9 @@
 	 * 
 	 * @param configuration of this engine
 	 * 
-	 * @param monitor to report progress
+	 * @param monitor       to report progress
 	 */
-	protected void init(final EngineConfiguration configuration, SubMonitor monitor) {
+	protected void init(final EngineConfiguration<?> configuration, SubMonitor monitor) {
 		this.configuration = configuration;
 		if (configuration.getMode().equals(ServiceOperatingMode.NORMAL)) {
 			ServiceRegistry registry = ServiceRegistry.getInstance();
@@ -131,7 +131,7 @@
 	}
 
 	/**
-	 * Start the execution engine. 
+	 * Start the execution engine.
 	 * 
 	 * Clients are intended to override this operation.
 	 * 
@@ -139,7 +139,7 @@
 	 * 
 	 * @param monitor to report progress
 	 */
-	protected abstract void start(SubMonitor monitor);
+	protected abstract void start(SubMonitor monitor) throws ExecutionEngineException;
 
 	/**
 	 * Stop the execution engine
@@ -175,7 +175,7 @@
 	public boolean canTerminate() {
 		return false;
 	}
-	
+
 	/**
 	 * see {@link ITerminate#isTerminated()}
 	 */
@@ -183,7 +183,7 @@
 	public boolean isTerminated() {
 		return getStatus().equals(ExecutionEngineStatus.TERMINATED);
 	}
-	
+
 	/**
 	 * see {@link ITerminate#terminate()}
 	 */
diff --git a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngineException.java b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngineException.java
new file mode 100644
index 0000000..1a578f4
--- /dev/null
+++ b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/ExecutionEngineException.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST and others.
+ * 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   CEA LIST - Initial API and implementation
+ *   
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.kernel.engine;
+
+@SuppressWarnings("serial")
+final public class ExecutionEngineException extends Exception {
+
+	/**
+	 * ID of the engine from which this exception was raised
+	 */
+	private String engineID;
+	
+	/**
+	 * Execution engine status at the exception time
+	 */
+	private ExecutionEngineStatus engineStatus; 
+	
+	public ExecutionEngineException(String ID, ExecutionEngineStatus status, String message) {
+		super(message);
+		this.engineID = ID;
+		this.engineStatus = status;
+		
+	}
+	
+	public ExecutionEngineException(String ID, ExecutionEngineStatus status, String message, Throwable cause) {
+		super(message, cause);
+		this.engineID = ID;
+		this.engineStatus = status;
+	}
+	
+	public String getEngineID() {
+		return engineID;
+	}
+	
+	public ExecutionEngineStatus getEngineStatus() {
+		return engineStatus;
+	}
+	
+}
diff --git a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/IExecutionEngine.java b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/IExecutionEngine.java
index b909bfe..7d292a1 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/IExecutionEngine.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/engine/IExecutionEngine.java
@@ -39,7 +39,7 @@
 	 * 
 	 * @return the configuration
 	 */
-	EngineConfiguration getConfiguration();
+	EngineConfiguration<?> getConfiguration();
 	
 	/**
 	 * Run this engine based on the provided configuration
@@ -50,7 +50,9 @@
 	 * 
 	 * @param monitor
 	 *  provide the opportunity to report progress
+	 *  
+	 * @exception ExecutionEngineException
 	 */
-	void run(final EngineConfiguration configuration, SubMonitor monitor);
+	void run(final EngineConfiguration<?> configuration, SubMonitor monitor) throws ExecutionEngineException;
 	
 }
diff --git a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/process/ExecutionEngineJob.java b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/process/ExecutionEngineJob.java
index a7452f8..7ac6f61 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/process/ExecutionEngineJob.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel/src/org/eclipse/papyrus/moka/kernel/process/ExecutionEngineJob.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2019 CEA LIST.
+ * Copyright (c) 2019, 2020 CEA LIST.
  *
  *
  * All rights reserved. This program and the accompanying materials
@@ -21,27 +21,30 @@
 import org.eclipse.core.runtime.SubMonitor;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.papyrus.moka.kernel.engine.EngineConfiguration;
+import org.eclipse.papyrus.moka.kernel.engine.ExecutionEngineException;
 import org.eclipse.papyrus.moka.kernel.engine.IExecutionEngine;
+import org.eclipse.swt.widgets.Display;
 
-public class ExecutionEngineJob extends Job implements IExecutionEngineContainer{
+public class ExecutionEngineJob extends Job implements IExecutionEngineContainer {
 
-	/** 
+	/**
 	 * The execution engine used to realize the model execution
 	 */
 	protected IExecutionEngine engine;
-		
+
 	/**
 	 * The configuration passed to the engine
 	 */
-	protected EngineConfiguration configuration;
-	
+	protected EngineConfiguration<?> configuration;
+
 	/**
 	 * job name
 	 */
-	private final static String EXECUTION_ENGINE_JOB_NAME = "Execution Engine Job";
-	
-	public ExecutionEngineJob(IExecutionEngine e, EngineConfiguration c) {
+	private final static String EXECUTION_ENGINE_JOB_NAME = "Execution Engine Job"; //$NON-NLS-1$
+
+	public ExecutionEngineJob(IExecutionEngine e, EngineConfiguration<?> c) {
 		super(EXECUTION_ENGINE_JOB_NAME);
 		engine = e;
 		configuration = c;
@@ -52,17 +55,21 @@
 		// Run the engine over the provided configuration
 		// Note that the model execution takes place on a
 		// dedicated thread of execution
-		if(engine != null && configuration != null) {
-			monitor.beginTask("Run execution engine", IProgressMonitor.UNKNOWN);
-			engine.run(configuration, SubMonitor.convert(monitor));
+		if (engine != null && configuration != null) {
+			monitor.beginTask("Run execution engine", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+			try {
+				engine.run(configuration, SubMonitor.convert(monitor));
+			} catch (ExecutionEngineException e) {
+				handleEngineException(e);
+			}
 			monitor.done();
 		}
 		return Status.OK_STATUS;
 	}
-	
+
 	@Override
 	protected void canceling() {
-		if(engine.canTerminate()) {
+		if (engine.canTerminate()) {
 			try {
 				engine.terminate();
 			} catch (DebugException e) {
@@ -70,9 +77,22 @@
 			}
 		}
 	}
-	
-	public IExecutionEngine getExecutionEngine(){
+
+	public IExecutionEngine getExecutionEngine() {
 		return engine;
 	}
 
+	private static void handleEngineException(final ExecutionEngineException exception) {
+		Display.getDefault().syncExec(new Runnable() {
+			@Override
+			public void run() {
+				String message = exception.getMessage();
+				message += "\n\n Engine information ---"; //$NON-NLS-1$
+				message += "\n - Status: " + exception.getEngineStatus().toString(); //$NON-NLS-1$
+				message += "\n - ID: " + exception.getEngineID(); //$NON-NLS-1$
+				MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Error", message); //$NON-NLS-1$
+			}
+		});
+	}
+
 }
diff --git a/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/launch/ExecutionEngineLaunchDelegate.java b/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/launch/ExecutionEngineLaunchDelegate.java
index f646f3a..e73f094 100644
--- a/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/launch/ExecutionEngineLaunchDelegate.java
+++ b/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/launch/ExecutionEngineLaunchDelegate.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
  *
  *
  * All rights reserved. This program and the accompanying materials
@@ -30,6 +30,7 @@
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.papyrus.infra.core.resource.ModelSet;
@@ -52,14 +53,22 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.uml2.uml.Class;
 
 public class ExecutionEngineLaunchDelegate extends LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
 
-	// The project containing the model for which
-	// the execution is launched
+	/**
+	 * The project containing the model from which the execution is started
+	 */
 	protected IProject project;
-	private EngineConfiguration engineConfiguration;
+	
+	/**
+	 * The user defined engine configuration
+	 */
+	private EngineConfiguration<?> engineConfiguration;
+	
+	/**
+	 * The model set containing the model that is executed
+	 */
 	private ModelSet modelSet;
 
 	private boolean canOpenProject(final IExecutionEngineLaunchConfigurationReader reader) {
@@ -90,7 +99,7 @@
 		return canRunServer;
 	}
 
-	private boolean isValidationOk(EngineConfiguration engineConfiguration, IProgressMonitor monitor, String engineID) {
+	private boolean isValidationOk(EngineConfiguration<?> engineConfiguration, IProgressMonitor monitor, String engineID) {
 		// If the preference allow to run model validation before the launch, the
 		// validation is run. If there are errors, the system ask the user if he/she
 		// still wants to run the simulation.
@@ -213,10 +222,10 @@
 					engineProcess.run();
 				}
 			} else {
-				MokaUIActivator.getDefault().getLogger().error("Server execution failed", serverProcess.getError());
+				MokaUIActivator.getDefault().getLogger().error("Server execution failed", serverProcess.getError()); //$NON-NLS-1$
 			}
 		} else {
-			MokaUIActivator.getDefault().getLogger().error("Modeling environment could not be initialized", null);
+			MokaUIActivator.getDefault().getLogger().error("Modeling environment could not be initialized", null); //$NON-NLS-1$
 		}
 	}
 
@@ -224,16 +233,15 @@
 		return new ExecutionEngineLaunchConfigurationReader(configuration);
 	}
 
-	protected EngineConfiguration createConfiguration(IExecutionEngineLaunchConfigurationReader cr, ModelSet ms) {
+	protected EngineConfiguration<?> createConfiguration(IExecutionEngineLaunchConfigurationReader cr, ModelSet ms) {
 		// Return a configuration containing the information required by
 		// the engine to perform the execution
-		EngineConfiguration ec = new EngineConfiguration();
+		EngineConfiguration<EObject> ec = new EngineConfiguration<EObject>();
 		ec.setProject(project);
 		ec.setModelURI(cr.getModelURI());
 		Resource resource = ms.getResource(cr.getModelURI(), true);
 		if (resource != null) {
-			Class target = (Class) resource.getEObject(cr.getExecutionSourceURI().toString());
-			ec.setExecutionSource(target);
+			ec.setExecutionSource(resource.getEObject(cr.getExecutionSourceURI().toString()));
 		}
 		ec.setTraceEnabled(cr.isTraceServiceEnabled());
 		ec.setTraceFilePath(cr.getTraceFile());
@@ -268,7 +276,7 @@
 	}
 
 	protected final ExecutionEngineProcess initializeExecutionProcess(ILaunch l,
-			IExecutionEngineLaunchConfigurationReader cr, EngineConfiguration ec) {
+			IExecutionEngineLaunchConfigurationReader cr, EngineConfiguration<?> ec) {
 		ExecutionEngineProcess process = new ExecutionEngineProcess(l, cr.getEngine(), ec);
 		ExecutionEngineDebugTarget debugTarget = new ExecutionEngineDebugTarget(l, process);
 		l.addProcess(process);
diff --git a/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/validation/ValidationUtil.java b/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/validation/ValidationUtil.java
index 3d564ff..a88ee06 100644
--- a/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/validation/ValidationUtil.java
+++ b/plugins/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/validation/ValidationUtil.java
@@ -48,6 +48,8 @@
 import org.eclipse.papyrus.moka.kernel.validation.ValidationDescriptor;
 import org.eclipse.swt.widgets.Display;
 
+import org.eclipse.uml2.uml.Element;
+
 @SuppressWarnings("restriction")
 public class ValidationUtil {
 
@@ -63,7 +65,7 @@
 		ModelValidationService.getInstance().loadXmlConstraintDeclarations();
 	}
 
-	public static boolean validateModel(EngineConfiguration engineConfiguration, IProgressMonitor monitor,
+	public static boolean validateModel(EngineConfiguration<?> engineConfiguration, IProgressMonitor monitor,
 			String engineID) {
 		// This method run the validation and should return true if the simulation
 		// should continue of false otherwise.
@@ -79,7 +81,7 @@
 				.getInstance().getValidationDescriptors(engineID);
 		dialogResult = true;
 		if (validationDescriptors != null) {
-			Diagnostic diagnostic = validate(monitor, engineConfiguration.getExecutionSource().getModel(), engineID,
+			Diagnostic diagnostic = validate(monitor, ((Element)engineConfiguration.getExecutionSource()).getModel(), engineID,
 					validationDescriptors);
 			List<Diagnostic> filteredConstraints = new ArrayList<>(diagnostic.getChildren());
 			filteredConstraints = filteredConstraints.stream().filter(d -> valideRules.contains(d.getSource()))
@@ -93,8 +95,8 @@
 					@Override
 					public void run() {
 						ValidationDiagnosticDialog dialog = new ValidationDiagnosticDialog(
-								Display.getCurrent().getActiveShell(), "Moka Validation",
-								"The moka validation detect errors on the model. Do you still want to launch the simulation ?",
+								Display.getCurrent().getActiveShell(), "Moka Validation", //$NON-NLS-1$
+								"The moka validation detect errors on the model. Do you still want to launch the simulation ?", //$NON-NLS-1$
 								filteredDiagnostics, IStatus.ERROR);
 						if (dialog.open() == Window.OK) {
 							ValidationUtil.dialogResult = true;