Enable execution of active classes

Change-Id: Ie1251d550dbcf0f3fa398a888f067d4cc09885a9
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
diff --git a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
index 2240335..e65daa7 100644
--- a/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
+++ b/bundles/core/engines/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/control/execution/RootExecution.java
@@ -24,37 +24,40 @@
 import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Classifier;
 
-public class RootExecution extends Execution{
+public class RootExecution extends Execution {
 
-	// The model element executed in the context of the
-	// root execution.
-	protected Class classifier;
-	
-	public RootExecution(){
+	// Class to be executed
+	protected Class executedClass;
+
+	public RootExecution() {
 	}
-	
-	public RootExecution(Class classifier, List<IParameterValue> inputParameterValues, ILocus locus){
-		this.classifier = classifier;
+
+	public RootExecution(Class executedClass, List<IParameterValue> inputParameterValues, ILocus locus) {
+		this.executedClass = executedClass;
 		this.setInputParameterValues(inputParameterValues);
 		this.locus = locus;
 	}
-	
-	public void setInputParameterValues(List<IParameterValue> inputParameterValues){
+
+	public void setInputParameterValues(List<IParameterValue> inputParameterValues) {
 		// Set input parameter values of the root execution
-		for(IParameterValue inputParameterValue : inputParameterValues){
+		for (IParameterValue inputParameterValue : inputParameterValues) {
 			this.setParameterValue(inputParameterValue);
 		}
 	}
-	
+
 	@Override
 	public void execute() {
-		// If the model element is a behavior then it gets executed through the locus executor.
-		// Outputs of this execution are made available through the parameter values of the
-		// root execution.
-		// [TODO: handle the case were the model element is an active class]
-		if(this.classifier instanceof Behavior){
-			List<IParameterValue> outputParameterValues = this.locus.getExecutor().execute((Behavior)this.classifier, null, this.parameterValues);
-			for(IParameterValue parameterValue : outputParameterValues){
+		// If the class is active then it is instantiated and
+		// started on its own thread of execution. Conversely,
+		// if it is not active then it shall be a behavior. In
+		// such situation the behavior gets executed otherwise
+		// this operation has no effect.
+		if (this.executedClass.isActive()) {
+			this.locus.getExecutor().start(executedClass, this.parameterValues);
+		} else if (this.executedClass instanceof Behavior) {
+			List<IParameterValue> outputParameterValues = this.locus.getExecutor()
+					.execute((Behavior) this.executedClass, null, this.parameterValues);
+			for (IParameterValue parameterValue : outputParameterValues) {
 				this.setParameterValue(parameterValue);
 			}
 		}
@@ -64,15 +67,14 @@
 	public IValue new_() {
 		return new RootExecution();
 	}
-	
+
 	@Override
 	public List<Classifier> getTypes() {
 		List<Classifier> types = new ArrayList<Classifier>();
-		types.add(this.classifier);
+		types.add(this.executedClass);
 		return types;
 	}
-	
-	
+
 	@Override
 	public String toString() {
 		return "RootExecution()";