[overlord-commits] Overlord SVN: r794 - in cdl/trunk/tools/eclipse/plugins: org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component and 17 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Fri Aug 21 17:09:22 EDT 2009


Author: objectiser
Date: 2009-08-21 17:09:21 -0400 (Fri, 21 Aug 2009)
New Revision: 794

Added:
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractInteractionMessageAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractStatelessESBAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/IfAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SendMessageAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SwitchAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/UnsupportedAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/AbstractStatelessESBModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/LanguageToConversationModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/TypeReferenceModelChangeRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/IfActionTest.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageActionTest.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SendMessageActionTest.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SwitchActionTest.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRuleTest.java
Removed:
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateful/
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateful/actions/
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/stateful/
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/stateful/actions/
Modified:
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/eclipse/Activator.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElementFactory.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/META-INF/MANIFEST.MF
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/actions/GenerateAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/dialogs/GenerateDialog.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/eclipse/Activator.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/BusinessObjectTypeGenerator.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/DeploymentFileGenerator.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/Generator.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBMMessagingSystem.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBossMQMessagingSystem.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultConversionContext.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBLanguageModel.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBService.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/ESBActionFactory.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractESBAction.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/Messages.properties
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/util/PropertyUtil.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/parser/JBossESBModelParserRule.java
   cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/DefaultESBServiceTest.java
Log:
Changed package name and removed the stateful ESB actions - and renamed the stateless actions to be the default. Need to improve the unit tests for the stateless actions, as stateful ones were more advanced but have been removed. Also need to remove 'stateless' checkbox from generator dialog window.

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/eclipse/Activator.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/eclipse/Activator.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/eclipse/Activator.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -12,7 +12,7 @@
 public class Activator extends AbstractUIPlugin {
 
 	// The plug-in ID
-	public static final String PLUGIN_ID = "org.jboss.tools.overlord.cdl.bpel";
+	public static final String PLUGIN_ID = "org.jboss.savara.tools.bpel";
 
 	// The shared instance
 	private static Activator plugin;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElementFactory.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElementFactory.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/BPELElementFactory.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -23,7 +23,7 @@
 public class BPELElementFactory {
 
 	public static final String MODEL_COMPONENTS_PACKAGE =
-			"org.jboss.tools.overlord.cdl.bpel.model.component";
+			"org.jboss.savara.tools.bpel.model.component";
 	
 	/**
 	* This method creates a BPELElement instance relevant to the

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -107,5 +107,5 @@
 		return(ret);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.parser");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.bpel.parser");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/META-INF/MANIFEST.MF	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/META-INF/MANIFEST.MF	2009-08-21 21:09:21 UTC (rev 794)
@@ -27,20 +27,9 @@
   org.jboss.savara.tools.jbossesb.editor.JBossESBConfigEditorManager,
   org.jboss.savara.tools.jbossesb.validation.ESBLanguageModelValidationRule,
   org.jboss.savara.tools.jbossesb.export.ESBLanguageModelStreamExportRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateless.LanguageToConversationModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateless.ConversationModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateless.ConversationInteractionModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateless.IfModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateless.TypeReferenceModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.LanguageToConversationModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.ConversationModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.MessageSignatureModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.TypeReferenceModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.IfModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.ParallelModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.RunModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.SpawnModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.WhenModelChangeRule,
-  org.jboss.savara.tools.jbossesb.model.change.stateful.WhileModelChangeRule
+  org.jboss.savara.tools.jbossesb.model.change.LanguageToConversationModelChangeRule,
+  org.jboss.savara.tools.jbossesb.model.change.ConversationModelChangeRule,
+  org.jboss.savara.tools.jbossesb.model.change.ConversationInteractionModelChangeRule,
+  org.jboss.savara.tools.jbossesb.model.change.IfModelChangeRule,
+  org.jboss.savara.tools.jbossesb.model.change.TypeReferenceModelChangeRule
 Bundle-ActivationPolicy: lazy

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/actions/GenerateAction.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/actions/GenerateAction.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/actions/GenerateAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -109,7 +109,7 @@
 		mbox.open();
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.actions");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.actions");
 	
 	private ISelection m_selection=null;
     private IWorkbenchPart m_targetPart=null;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/dialogs/GenerateDialog.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/dialogs/GenerateDialog.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -421,7 +421,7 @@
 		logger.log(java.util.logging.Level.SEVERE, mesg, ex);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.dialogs");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.dialogs");
 
 	private IFile m_file=null;
 	private ConversationModel m_conversationModel=null;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/eclipse/Activator.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/eclipse/Activator.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/eclipse/Activator.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -88,5 +88,5 @@
 				(t == null ? "" : ": "+t));
 	}
 	
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.eclipse");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.eclipse");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/BusinessObjectTypeGenerator.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/BusinessObjectTypeGenerator.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/BusinessObjectTypeGenerator.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -57,7 +57,7 @@
  */
 public class BusinessObjectTypeGenerator implements ConversationBasedGenerator {
 
-	private static final String GENERATOR_MESSAGES = "org.jboss.tools.overlord.cdl.runtime.jbossesb.generator.Messages";
+	private static final String GENERATOR_MESSAGES = "org.jboss.savara.tools.jbossesb.generator.Messages";
 
 	/**
 	 * This method generates the relevant artefacts based on

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/DeploymentFileGenerator.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/DeploymentFileGenerator.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/DeploymentFileGenerator.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -84,5 +84,5 @@
 		}
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.generator");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.generator");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/Generator.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/Generator.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -506,7 +506,7 @@
 		return(m_context);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.generator");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.generator");
 
 	private IFile m_file=null;
 	private java.util.List<ModelReference> m_localModelRefs=null;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBMMessagingSystem.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBMMessagingSystem.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBMMessagingSystem.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -78,5 +78,5 @@
 		return(buf.toString());
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.generator");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.generator");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBossMQMessagingSystem.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBossMQMessagingSystem.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/generator/JBossMQMessagingSystem.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -80,5 +80,5 @@
 		return(buf.toString());
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.generator");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.generator");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultConversionContext.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultConversionContext.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultConversionContext.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -119,7 +119,7 @@
 		return(m_joins.contains(service));
 	}
 	
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
 	
 	private java.util.List<ESBService> m_serviceStack=new java.util.Vector<ESBService>();
 	private java.util.List<ESBService> m_joins=new java.util.Vector<ESBService>();

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBLanguageModel.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBLanguageModel.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -638,7 +638,7 @@
 	}
 	
 	
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
 
 	private ModelReference m_source=null;
 	private org.w3c.dom.Element m_esbConfig=null;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBService.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBService.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/DefaultESBService.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -46,9 +46,9 @@
 	public static final String BUSINESS_OBJECT_TYPE_PROPERTY = "session";
 	public static final String CONVERSATION_TYPE_PROPERTY = "conversationType";
 	public static final String SERVICE_DESCRIPTION_NAME_PROPERTY = "serviceDescriptionName";
-	public static final String SERVICE_ANNOTATION = "org.jboss.soa.overlord.jbossesb.stateful.actions.Service";
+	public static final String SERVICE_ANNOTATION = "org.jboss.soa.overlord.jbossesb.actions.Service";
 	public static final String SERVICE_ELEMENT = "service";
-	public static final String RETRIEVE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.stateful.actions.RetrieveSessionAction";
+	public static final String RETRIEVE_SESSION_ACTION_CLASS = "org.jboss.soa.overlord.jbossesb.actions.RetrieveSessionAction";
 	public static final String ACTION_ELEMENT = "action";
 	public static final String ACTIONS_ELEMENT = "actions";
 	
@@ -199,7 +199,7 @@
 			
 			l.error(new ModelIssue(src, org.scribble.util.MessageUtil.format(
 					java.util.PropertyResourceBundle.getBundle(
-					"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.Messages"),
+					"org.jboss.savara.tools.jbossesb.model.Messages"),
 						"_NOT_SPECIFIED_SESSION_CLASS",
 						new String[]{})));
 		}
@@ -913,7 +913,7 @@
 		return("ESBService: "+getCategory()+"/"+getName()+"["+getSource()+"]");
 	}
 	
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
 
 	private ESBLanguageModel m_model=null;
 	private org.w3c.dom.Element m_service=null;

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/ESBActionFactory.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/ESBActionFactory.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/ESBActionFactory.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -19,7 +19,7 @@
 
 import java.util.logging.Logger;
 
-import org.jboss.savara.tools.jbossesb.model.stateful.actions.UnsupportedAction;
+import org.jboss.savara.tools.jbossesb.model.actions.UnsupportedAction;
 
 /**
  * This class provides a factory for ESBAction instances.
@@ -29,12 +29,10 @@
 public class ESBActionFactory {
 
 	public static final String MODEL_ACTION_PACKAGE =
-						"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.";
+						"org.jboss.savara.tools.jbossesb.model.actions.";
 	public static final String CLASS_ATTR = "class";
 	public static final String CONVERSATION_ACTION_PACKAGE = 
-						"org.jboss.soa.overlord.jbossesb.";
-	public static final String STATELESS="stateless.actions.";
-	public static final String STATEFUL="stateful.actions.";
+						"org.jboss.savara.jbossesb.actions.";
 
 	/**
 	 * This method creates an ESBAction instance relevant to the
@@ -54,35 +52,20 @@
 		if (actionType.startsWith(CONVERSATION_ACTION_PACKAGE)) {
 			actionType = actionType.substring(CONVERSATION_ACTION_PACKAGE.length());
 
-			String stateValue=null;
-			
-			if (actionType.startsWith(STATEFUL)) {
-				actionType = actionType.substring(STATEFUL.length());
-				stateValue = STATEFUL;
-			} else if (actionType.startsWith(STATELESS)) {
-				actionType = actionType.substring(STATELESS.length());
-				stateValue = STATELESS;
-			}
-			
-			if (stateValue != null) {
+			try {
+				Class<?> cls=(Class<?>)
+						Class.forName(MODEL_ACTION_PACKAGE+actionType);
 				
-				try {
-					Class<?> cls=(Class<?>)
-							Class.forName(MODEL_ACTION_PACKAGE+
-									stateValue+actionType);
-					
-					java.lang.reflect.Constructor<?> con=
-						cls.getConstructor(new Class<?>[]{ESBService.class,
-							org.w3c.dom.Element.class});
-					
-					ret = (ESBAction)con.newInstance(new Object[]{service, action});
-					
-				} catch(Exception e) {
-					logger.log(java.util.logging.Level.SEVERE,
-							"Unable to find action class '"+
-							MODEL_ACTION_PACKAGE+stateValue+
-								actionType+"'", e);
-				}
+				java.lang.reflect.Constructor<?> con=
+					cls.getConstructor(new Class<?>[]{ESBService.class,
+						org.w3c.dom.Element.class});
+				
+				ret = (ESBAction)con.newInstance(new Object[]{service, action});
+				
+			} catch(Exception e) {
+				logger.log(java.util.logging.Level.SEVERE,
+						"Unable to find action class '"+
+						MODEL_ACTION_PACKAGE+actionType+"'", e);
 			}
 		}
 		
@@ -109,24 +92,11 @@
 		if (actionType.startsWith(MODEL_ACTION_PACKAGE)) {
 			actionType = actionType.substring(MODEL_ACTION_PACKAGE.length());
 
-			String stateValue=null;
-			
-			if (actionType.startsWith(STATEFUL)) {
-				actionType = actionType.substring(STATEFUL.length());
-				stateValue = STATEFUL;
-			} else if (actionType.startsWith(STATELESS)) {
-				actionType = actionType.substring(STATELESS.length());
-				stateValue = STATELESS;
-			}
-			
-			if (stateValue != null) {
-				ret = CONVERSATION_ACTION_PACKAGE+
-							stateValue+actionType;
-			}
+			ret = CONVERSATION_ACTION_PACKAGE+actionType;
 		}
 		
 		return(ret);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractESBAction.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractESBAction.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractESBAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -188,7 +188,7 @@
 								mandatory.get(i));
 				l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
 						java.util.PropertyResourceBundle.getBundle(
-						"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.stateful.actions.Messages"),
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
 							"_NOT_SPECIFIED_PROPERTY",
 							new String[]{mandatory.get(i)}), props));
 			}
@@ -203,7 +203,7 @@
 					getMandatoryProperties().contains(propName) == false) {
 				l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
 						java.util.PropertyResourceBundle.getBundle(
-						"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.stateful.actions.Messages"),
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
 							"_UNKNOWN_PROPERTY",
 							new String[]{propName})));				
 			}
@@ -220,7 +220,7 @@
 				if (link.isRemote() == false) {
 					l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
 						java.util.PropertyResourceBundle.getBundle(
-						"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.Messages"),
+						"org.jboss.savara.tools.jbossesb.model.Messages"),
 							"_NOT_FOUND_SERVICE_DESCRIPTOR",
 							new String[]{link.getCategory(),link.getName()})));
 				}
@@ -594,7 +594,7 @@
 		return(m_links);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
 
 	private ESBService m_service=null;
 	private org.w3c.dom.Element m_action=null;

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractInteractionMessageAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/AbstractInteractionMessageAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractInteractionMessageAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractInteractionMessageAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+
+/**
+ * The abstract model component for the 'ReceiveMessageAction'
+ * and 'SendMessageAction'.
+ *  
+ * @author gary
+ */
+public abstract class AbstractInteractionMessageAction extends AbstractStatelessESBAction {
+
+	private static final long serialVersionUID = 3272234577154434603L;
+
+	public static final String MESSAGE_TYPE = "messageType";
+	public static final String OPERATION = "operation";
+	public static final String CLIENT_ROLE = "clientRole";
+	public static final String EPR_STORE = "eprStore";
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public AbstractInteractionMessageAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+	
+	/**
+	 * The contructor for initializing a new action.
+	 */
+	protected AbstractInteractionMessageAction(ESBService service,
+						String actionClass) {
+		super(service, actionClass);
+	}
+
+	/**
+	 * This method returns the mandatory property names.
+	 * 
+	 * @return The mandatory property names
+	 */
+	@Override
+	protected java.util.List<String> getMandatoryProperties() {
+		java.util.List<String> ret=super.getMandatoryProperties();
+		ret.add(MESSAGE_TYPE);
+		return(ret);
+	}	
+
+	/**
+	 * This method returns the optional property names.
+	 * 
+	 * @return The optional property names
+	 */
+	@Override
+	protected java.util.List<String> getOptionalProperties() {
+		java.util.List<String> ret=super.getOptionalProperties();
+		ret.add(OPERATION);
+		ret.add(CLIENT_ROLE);
+		ret.add(EPR_STORE);
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the operation property.
+	 * 
+	 * @param operation The operation
+	 */
+	public void setOperation(String operation) {
+		
+		if (operation != null) {
+			org.w3c.dom.Element prop=getPropertyElement(OPERATION);
+			
+			if (prop != null) {
+				prop.setAttribute(VALUE_ATTR, operation);
+			}
+		} else {
+			removePropertyElement(OPERATION);
+		}
+	}
+	
+	/**
+	 * This method sets the message type.
+	 * 
+	 * @param type The message type
+	 */
+	public void setMessageType(String type) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(MESSAGE_TYPE);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, type);
+		}
+	}
+	
+	/**
+	 * This method returns the message type.
+	 * 
+	 * @return The message type
+	 */
+	public String getMessageType() {
+		String ret=null;
+		
+		org.w3c.dom.Element prop=getPropertyElement(MESSAGE_TYPE);
+		
+		if (prop != null && prop.hasAttribute(VALUE_ATTR)) {
+			ret = prop.getAttribute(VALUE_ATTR);
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the client's EPR label property.
+	 * 
+	 * @param epr The client EPR label
+	 */
+	public void setClientEPR(String epr) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(CLIENT_ROLE);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, epr);
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractStatelessESBAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/AbstractStatelessESBAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractStatelessESBAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/AbstractStatelessESBAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.util.ProblemDefinitions;
+
+/**
+ * This is the generic ESB action class.
+ *  
+ * @author gary
+ */
+public abstract class AbstractStatelessESBAction extends AbstractESBAction {
+
+	private static final long serialVersionUID = -4436864250793029006L;
+
+	/**
+	 * The constructor for initializing the action based on
+	 * an existing DOM element.
+	 */
+	protected AbstractStatelessESBAction(ESBService service,
+			org.w3c.dom.Element action) {
+		super(service, action);
+	}
+	
+	/**
+	 * The contructor for initializing a new action.
+	 */
+	protected AbstractStatelessESBAction(ESBService service,
+			String actionClass) {
+		super(service, actionClass);
+	}
+	
+	/**
+	 * This method determines whether the gateway service is
+	 * related to a stateless session.
+	 * 
+	 * @return Whether the gateway service is stateless
+	 */
+	@Override
+	public boolean isStateless() {
+		return(true);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model");
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/IfAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/IfAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/IfAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/IfAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * The model component for the 'IfAction'.
+ *  
+ * @author gary
+ */
+public class IfAction extends AbstractStatelessESBAction {
+
+	private static final long serialVersionUID = 9005791673502330699L;
+
+	public static final String SERVICE_NAME = "service-name";
+	public static final String SERVICE_CATEGORY = "service-category";
+	public static final String EXPRESSION = "expression"; // ???
+	public static final String ELSE = "else";
+	public static final String ELSEIF = "elseif";
+	public static final String IF = "if";
+	public static final String PATHS = "paths";
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public IfAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+
+	/**
+	 * This constructor initializes the DOM element for
+	 * the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action will be contained
+	 */
+	public IfAction(ESBService service) {
+		super(service, ESBActionFactory.getConversationAction(
+				IfAction.class));
+	}
+
+	/**
+	 * This method initializes the links with the ESB service descriptors
+	 * identified in each path of the action.
+	 */
+	@Override
+	public void initializeLinks() {
+		super.initializeLinks();
+		
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+		
+		for (int i=0; i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element &&
+					(n.getNodeName().equals(IF) ||
+					n.getNodeName().equals(ELSEIF) ||
+					n.getNodeName().equals(ELSE))) {
+				if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+						((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+					String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+					String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+					
+					// Lookup service associated with category and name
+					ESBService service=getService().getModel().getService(category, name);
+					
+					// Initialize link, even if service is null - this will be
+					// reported as a validation error later
+					getLinks().add(new ESBLink(category, name, service, true));
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method returns the mandatory property names.
+	 * 
+	 * @return The mandatory property names
+	 */
+	@Override
+	protected java.util.List<String> getMandatoryProperties() {
+		java.util.List<String> ret=super.getMandatoryProperties();
+		ret.add(PATHS);
+		return(ret);
+	}	
+
+	/**
+	 * This method validates the ESB action and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		super.validate(l);
+		
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+		boolean f_if=false;
+		boolean f_else=false;
+		boolean f_orderWrong=false;
+		boolean f_serviceDetailsMissing=false;
+		
+		for (int i=0; nl != null && i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element) {
+				if (n.getNodeName().equals(IF)) {
+					if (f_if) {
+						f_orderWrong = true;
+					}
+					
+					f_if = true;
+					
+					if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+							((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+						f_serviceDetailsMissing = true;
+					}
+					
+				} else if (n.getNodeName().equals(ELSEIF)) {
+					
+					if (f_if == false || f_else) {
+						f_orderWrong = true;
+					}
+					
+					if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+							((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+						f_serviceDetailsMissing = true;
+					}
+
+				} else if (n.getNodeName().equals(ELSE)) {
+					
+					if (f_if == false || f_else) {
+						f_orderWrong = true;
+					}
+					
+					f_else = true;
+					
+					if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+							((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+						f_serviceDetailsMissing = true;
+					}
+				}
+			}
+		}
+		
+		// Report any errors
+		if (nl != null && (f_if == false || f_orderWrong)) {
+			l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+						"_IF_ORDER_WRONG",
+						new String[]{})));								
+		}
+		
+		if (f_serviceDetailsMissing) {
+			l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+						"_PATH_SERVICE_DETAILS_MISSING",
+						new String[]{})));								
+		}
+	}
+
+	/**
+	 * This method converts the ESB action into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	@Override
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+
+		If choice=new If();
+		activities.add(choice);
+		
+		for (int i=0; i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element) {
+				if (n.getNodeName().equals(IF) ||
+						n.getNodeName().equals(ELSEIF)) {
+					String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+					String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+					
+					// TODO: Convert the conditional expression if defined
+					
+					ConditionalBlock cond=new ConditionalBlock();
+					choice.getConditionalBlocks().add(cond);
+					
+					ESBService service=getService().getModel().getService(category, name);
+					
+					if (service != null) {
+						service.convert(cond.getContents(), context);
+					}
+				} else if (n.getNodeName().equals(ELSE)) {
+					String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+					String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+					
+					Block block=new Block();
+					choice.setElseBlock(block);
+					
+					ESBService service=getService().getModel().getService(category, name);
+					
+					if (service != null) {
+						service.convert(block.getContents(), context);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * This method adds a path to the if action.
+	 * 
+	 * @param type The type of path (IF, ELSEIF or ELSE)
+	 * @param category The service category
+	 * @param name The service name
+	 * @param immediate Whether invocation should be immediate
+	 * @param expr The expression, if type is IF or ELSEIF
+	 * @param position The position, if type is ELSEIF
+	 */
+	public void addPath(String type, String category, String name,
+			boolean immediate, String expr, int position) {
+		
+		org.w3c.dom.NodeList nl=
+			getAction().getElementsByTagName(PROPERTY_ELEMENT);
+		
+		org.w3c.dom.Element paths=null;
+		
+		for (int i=0; paths == null && i < nl.getLength(); i++) {
+			if (nl.item(i) instanceof org.w3c.dom.Element) {
+				String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+				
+				if (propName != null && propName.equals(PATHS)) {
+					paths = (org.w3c.dom.Element)nl.item(i);
+				}
+			}
+		}
+		
+		if (paths == null) {
+			paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+			paths.setAttribute(NAME_ATTR, PATHS);
+			
+			getAction().appendChild(paths);
+		}
+		
+		org.w3c.dom.Element path=getAction().getOwnerDocument().createElement(type);
+		path.setAttribute(SERVICE_CATEGORY, category);
+		path.setAttribute(SERVICE_NAME, name);
+		
+		if (expr != null && (type == IF || type == ELSEIF)) {
+			path.setAttribute(EXPRESSION, expr);
+		}
+		
+		paths.appendChild(path);
+	}
+}

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/Messages.properties
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/Messages.properties	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/Messages.properties	2009-08-21 21:09:21 UTC (rev 794)
@@ -15,3 +15,9 @@
 #  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 #  * MA  02110-1301, USA.
 #  */
+
+_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
+_NOT_SPECIFIED_SERVICE_DETAILS=Send does not provide service category and name
+_NOT_SPECIFIED_SERVICE_OR_CLIENT_ROLE=Send does not contain request service category/name or response client role
+_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
+_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/ReceiveMessageAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+/**
+ * The model component for the 'ReceiveMessageAction'.
+ *  
+ * @author gary
+ */
+public class ReceiveMessageAction extends AbstractInteractionMessageAction {
+
+	private static final long serialVersionUID = -4957103938232460319L;
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public ReceiveMessageAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+	
+	/**
+	 * This constructor initializes the DOM element for
+	 * the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action will be contained
+	 */
+	public ReceiveMessageAction(ESBService service) {
+		super(service, ESBActionFactory.getConversationAction(
+				ReceiveMessageAction.class));
+	}
+
+	/**
+	 * This method converts the ESB action into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	@Override
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		ConversationInteraction recv=new ConversationInteraction();	
+		activities.add(recv);
+		
+		recv.derivedFrom(this);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.derivedFrom(this);
+		
+		recv.setMessageSignature(ms);
+		
+		ms.setOperation(getPropertyValue(OPERATION));
+		
+		String type=getPropertyValue(MESSAGE_TYPE);
+		if (type != null && type.length() > 0) {
+			String ns=null;
+			String local=type;
+			
+			if (type.charAt(0) == '{') {
+				int endindex=type.indexOf('}');
+				
+				if (endindex != -1) {
+					ns = type.substring(1, endindex);
+					local = type.substring(endindex+1);
+				}
+			}
+			
+			TypeReference ref=new TypeReference();
+			ref.setLocalpart(local);
+			ref.setNamespace(ns);
+			
+			ref.derivedFrom(this);
+			
+			ms.getTypes().add(ref);
+		}
+		
+		// Initialize the 'to' role to be this participant
+		if (context.getRole() != null) {
+			recv.setToRole(new Role(context.getRole()));
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SendMessageAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/SendMessageAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SendMessageAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SendMessageAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,295 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import java.util.logging.Logger;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * The model component for the 'SendMessageAction'.
+ *  
+ * @author gary
+ */
+public class SendMessageAction extends AbstractInteractionMessageAction {
+
+	private static final long serialVersionUID = 2714230118722655345L;
+
+	public static final String SERVICE_NAME = "serviceName";
+	public static final String SERVICE_CATEGORY = "serviceCategory";
+	public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
+	public static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public SendMessageAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+
+	/**
+	 * This constructor initializes the DOM element for
+	 * the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action will be contained
+	 */
+	public SendMessageAction(ESBService service) {
+		super(service, ESBActionFactory.getConversationAction(
+				SendMessageAction.class));
+	}
+
+	/**
+	 * This method returns the optional property names.
+	 * 
+	 * @return The optional property names
+	 */
+	@Override
+	protected java.util.List<String> getOptionalProperties() {
+		java.util.List<String> ret=super.getOptionalProperties();
+
+		ret.add(SERVICE_NAME);
+		ret.add(SERVICE_CATEGORY);
+		ret.add(RESPONSE_SERVICE_NAME);
+		ret.add(RESPONSE_SERVICE_CATEGORY);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method validates the ESB action and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		super.validate(l);
+		
+		// If sending request, then category/name must be specified,
+		// else a response requires the 'client epr'. Validate that
+		// either case is true.
+		if (getPropertyValue(SERVICE_CATEGORY) != null &&
+				getPropertyValue(SERVICE_NAME) != null) {
+			// Sending a request
+			
+			// Check if values have been provided
+			if (getPropertyValue(SERVICE_CATEGORY).trim().length() == 0 ||
+					getPropertyValue(SERVICE_NAME).trim().length() == 0) {
+				l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_NOT_SPECIFIED_SERVICE_DETAILS",
+							new String[]{})));
+			}
+			
+		} else if (getPropertyValue(CLIENT_ROLE) != null) {
+			// Sending a response
+			
+			// TODO: Validate that the client EPR has been sent on
+			// a preceding received request
+		} else {
+			l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+						"_NOT_SPECIFIED_SERVICE_OR_CLIENT_ROLE",
+						new String[]{})));
+		}
+	}
+	
+	/**
+	 * This method converts the ESB action into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	@Override
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		ConversationInteraction send=new ConversationInteraction();
+		activities.add(send);
+		
+		send.derivedFrom(this);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.derivedFrom(this);
+		
+		send.setMessageSignature(ms);
+		
+		ms.setOperation(getPropertyValue(OPERATION));
+		
+		String type=getPropertyValue(MESSAGE_TYPE);
+		if (type != null && type.length() > 0) {
+			String ns=null;
+			String local=type;
+			
+			if (type.charAt(0) == '{') {
+				int endindex=type.indexOf('}');
+				
+				if (endindex != -1) {
+					ns = type.substring(1, endindex);
+					local = type.substring(endindex+1);
+				}
+			}
+			
+			TypeReference ref=new TypeReference();
+			ref.setLocalpart(local);
+			ref.setNamespace(ns);
+			
+			ref.derivedFrom(this);
+			
+			ms.getTypes().add(ref);
+		}
+		
+		// Initialize the 'from' role to be this participant
+		// (for now until 'to' role can be set)
+		if (context.getRole() != null) {
+			send.setFromRole(new Role(context.getRole()));
+		}
+		
+		// Check if reply destination has been defined
+		if (hasProperty(RESPONSE_SERVICE_CATEGORY) &&
+				hasProperty(RESPONSE_SERVICE_NAME)) {
+			String responseName=getPropertyValue(RESPONSE_SERVICE_NAME);
+			String responseCategory=getPropertyValue(RESPONSE_SERVICE_CATEGORY);
+	
+			ESBService serv=getService().getModel().
+					getService(responseCategory, responseName);
+			
+			Definition defn=send.getEnclosingDefinition().
+							getTopLevelDefinition();
+
+			if (serv == null) {
+				logger.severe("Failed to find response ESB service '"+
+						responseCategory+"/"+responseName+"'");
+				
+			} else if (context.isOnStack(serv)) {
+				
+				// Ignore service as don't want to recursively
+				// process it
+				
+			} else if (defn != null && defn.isStateless()) {
+				If ifelem=null;
+				
+				context.push(serv);
+				
+				for (int i=0; ifelem == null &&
+						i < defn.getBlock().getContents().size(); i++) {
+					if (defn.getBlock().getContents().get(i) instanceof If) {
+						ifelem = (If)defn.getBlock().getContents().get(i);
+					}
+				}
+				
+				if (ifelem != null) {
+					
+					if (serv.getActions().size() == 1 &&
+							serv.getActions().get(0) instanceof SwitchAction) {
+						// Work through case entries and add each
+						// to top level conversation stateless 'if'
+						SwitchAction sw=(SwitchAction)serv.getActions().get(0);
+						
+						for (int i=0; i < sw.getNumberOfCases(); i++) {
+							String name=sw.getCaseServiceName(i);
+							String category=sw.getCaseServiceCategory(i);
+							
+							ESBService subServ=getService().getModel().
+								getService(category, name);
+							
+							if (subServ == null) {
+								logger.severe("Failed to find response sub ESB service '"+
+										category+"/"+name+"'");
+							} else {
+								ConditionalBlock cb=new ConditionalBlock();
+								
+								ifelem.getConditionalBlocks().add(cb);
+								
+								subServ.convert(cb.getContents(), context);
+							}
+						}
+					} else {
+						ConditionalBlock cb=new ConditionalBlock();
+						
+						ifelem.getConditionalBlocks().add(cb);
+						
+						serv.convert(cb.getContents(), context);
+					}
+				} else {
+					logger.severe("Unable to find top level 'stateless' IF activity");
+				}
+
+				context.pop(serv);
+			}
+		}
+	}
+	
+	/**
+	 * This method sets the destination service descriptor properties.
+	 * 
+	 * @param category The category
+	 * @param name The name
+	 */
+	public void setDestination(String category, String name) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, category);
+		}
+		
+		prop = getPropertyElement(SERVICE_NAME);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, name);
+		}
+	}
+	
+	/**
+	 * This method sets the response service descriptor properties.
+	 * 
+	 * @param category The category
+	 * @param name The name
+	 */
+	public void setResponseDestination(String category, String name) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(RESPONSE_SERVICE_CATEGORY);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, category);
+		}
+		
+		prop = getPropertyElement(RESPONSE_SERVICE_NAME);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, name);
+		}
+	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model.actions");
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SwitchAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateless/actions/SwitchAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SwitchAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/SwitchAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,450 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * The model component for the 'SwitchAction'.
+ *  
+ * @author gary
+ */
+public class SwitchAction extends AbstractStatelessESBAction {
+
+	private static final long serialVersionUID = 3765702614644769281L;
+
+	public static final String TYPE_ATTR = "type";
+	public static final String DESCRIPTION_ATTR = "description";
+	public static final String MESSAGE_ELEMENT = "message";
+	public static final String EVENT_ELEMENT = "event";
+	private static final String SERVICE_NAME = "service-name";
+	private static final String SERVICE_CATEGORY = "service-category";
+	private static final String CASE = "case";
+	private static final String PATHS = "paths";
+	public static final String CONVERSATION_TYPE = "conversationType";
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public SwitchAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+
+	/**
+	 * This constructor initializes the DOM element for
+	 * the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action will be contained
+	 */
+	public SwitchAction(ESBService service) {
+		super(service, ESBActionFactory.getConversationAction(
+				SwitchAction.class));
+	}
+
+	/**
+	 * This method initializes the links with the ESB service descriptors
+	 * identified in each path of the action.
+	 */
+	@Override
+	public void initializeLinks() {
+		super.initializeLinks();
+
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+		
+		for (int i=0; i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element &&
+					n.getNodeName().equals(CASE)) {
+				if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) &&
+						((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME)) {
+					String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+					String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+					
+					// Lookup service associated with category and name
+					ESBService service=getService().getModel().getService(category, name);
+					
+					// Initialize link, even if service is null - this will be
+					// reported as a validation error later
+					getLinks().add(new ESBLink(category, name, service, true));
+				}
+			}
+		}
+	}
+
+	/**
+	 * This method determines whether the action is a gateway
+	 * for inbound requests.
+	 * 
+	 * @return Whether the action is a gateway
+	 */
+	@Override
+	public boolean isGateway() {
+		return(isStateless());
+	}
+
+	/**
+	 * This method determines whether the ESB action represents
+	 * a new session type.
+	 * 
+	 * @return Whether the action represents a new session type
+	 */
+	@Override
+	public boolean isSessionType() {
+		return(isStateless());
+	}
+	
+	/**
+	 * This method returns the mandatory property names.
+	 * 
+	 * @return The mandatory property names
+	 */
+	@Override
+	protected java.util.List<String> getMandatoryProperties() {
+		java.util.List<String> ret=super.getMandatoryProperties();
+		ret.add(PATHS);
+		return(ret);
+	}	
+
+	/**
+	 * This method returns the optional property names.
+	 * 
+	 * @return The optional property names
+	 */
+	@Override
+	protected java.util.List<String> getOptionalProperties() {
+		java.util.List<String> ret=super.getOptionalProperties();
+		ret.add(CONVERSATION_TYPE);
+		return(ret);
+	}
+	
+	/**
+	 * This method validates the ESB action and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		super.validate(l);
+
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+		int pathCount=0;
+		boolean f_serviceDetailsMissing=false;
+		
+		for (int i=0; nl != null && i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element) {
+				if (n.getNodeName().equals(CASE)) {
+					pathCount++;
+					
+					if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
+							((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
+						f_serviceDetailsMissing = true;
+					}
+				}
+			}
+		}
+		
+		// Report any errors
+		if (nl != null && pathCount < 1) {
+			l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+						"_SWITCH_ONE_OR_MORE_PATHS",
+						new String[]{})));					
+		}
+		
+		if (f_serviceDetailsMissing) {
+			l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+						"_PATH_SERVICE_DETAILS_MISSING",
+						new String[]{})));								
+		}
+	}
+		
+	/**
+	 * This method converts the ESB action into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	@Override
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
+		
+		If choice=new If();
+		activities.add(choice);
+		
+		for (int i=0; i < nl.getLength(); i++) {
+			
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element &&
+					n.getNodeName().equals(CASE)) {
+				String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
+				String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
+				
+				// Conditional block with no expression - i.e. the
+				// expression is non-observable, as the path will be
+				// selected based on the next message that arrives
+				ConditionalBlock block=new ConditionalBlock();
+				choice.getConditionalBlocks().add(block);
+				
+				ESBService service=getService().getModel().getService(category, name);
+				
+				if (service != null) {
+					service.convert(block.getContents(), context);
+				}
+			}
+		}
+	}
+
+	/**
+	 * This method sets the conversation type property.
+	 * 
+	 * @param name The conversation type
+	 */
+	public void setConversationType(String type) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(CONVERSATION_TYPE);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, type);
+		}
+	}	
+
+	/**
+	 * This method adds a path to the switch action.
+	 * 
+	 * @param category The service category
+	 * @param name The service name
+	 * @param messageTypes The set of interactions
+	 * @param position The position
+	 * @return Whether the path is added
+	 */
+	public void addCase(String category, String name,
+			java.util.Set<Interaction> messageTypes, int position) {
+		boolean f_associatePath=false;
+		boolean f_eventBased=false;
+		String eventDescription="TODO: Path triggered by internal event";
+		org.w3c.dom.Element paths=getPropertyElement(PATHS);
+		
+		org.w3c.dom.Element path=
+			getAction().getOwnerDocument().createElement(CASE);
+		path.setAttribute(SERVICE_CATEGORY, category);
+		path.setAttribute(SERVICE_NAME, name);
+		
+		if (messageTypes != null && messageTypes.size() > 0) {
+			java.util.Iterator<Interaction> iter=messageTypes.iterator();
+			boolean f_onlySend=true;
+			String sendEventTypes=null;
+			
+			while (iter.hasNext()) {
+				Interaction interaction=iter.next();
+				
+				if (InteractionUtil.isSend(interaction) == false) {
+					f_onlySend = false;
+				
+					//TODO: Only deals with single type for now
+					
+					// Only associate message type for requests
+					if (//interaction.getReplyToLabel() == null &&
+							interaction.getMessageSignature().getTypes().size()==1) {
+						org.w3c.dom.Element mt=
+							getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
+							
+						mt.setAttribute(TYPE_ATTR,
+									InteractionUtil.getTypeString(
+										interaction.getMessageSignature().
+										getTypes().get(0)));
+						
+						path.appendChild(mt);
+						
+						f_associatePath = true;
+					}
+				} else if (interaction.getMessageSignature().getTypes().size()==1) {
+					if (sendEventTypes == null) {
+						sendEventTypes = InteractionUtil.getTypeString(
+								interaction.getMessageSignature().
+								getTypes().get(0));
+					} else {
+						sendEventTypes += ", "+InteractionUtil.getTypeString(
+								interaction.getMessageSignature().
+								getTypes().get(0));
+					}
+				}
+			}
+			
+			if (f_onlySend) {
+				// Associate the path, even though it has no associated
+				// receive interactions, as it represents a path triggered by
+				// a different stimulus. Need this to enable the
+				// conformance checking to understand that it is a
+				// valid path, that needs to be handled.
+				f_associatePath = true;
+				
+				f_eventBased = true;
+				
+				eventDescription="Event trigger to send "+
+						sendEventTypes+" message type(s)";
+			}
+		} else {
+			// Associate the path, even though it has no associated
+			// interactions, as it represents a path triggered by
+			// a different stimulus. Need this to enable the
+			// conformance checking to understand that it is a
+			// valid path, that needs to be handled.
+			f_associatePath = true;
+			
+			f_eventBased = true;
+		}
+		
+		if (f_eventBased) {
+			org.w3c.dom.Element mt=
+				getAction().getOwnerDocument().createElement(EVENT_ELEMENT);
+				
+			mt.setAttribute(DESCRIPTION_ATTR, eventDescription);
+			
+			path.appendChild(mt);						
+		}
+		
+		//if (f_associatePath) {
+			paths.appendChild(path);
+		//}
+	}
+	
+	/**
+	 * This method returns the number of cases associated with
+	 * the switch.
+	 * 
+	 * @return The number of cases
+	 */
+	public int getNumberOfCases() {
+		int ret=0;
+		
+		org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+		
+		ret = nl.getLength();
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the DOM element associated with the
+	 * specified case.
+	 * 
+	 * @param index The index of the required route
+	 * @return The case element, or null if not found
+	 */
+	public org.w3c.dom.Element getCaseElement(int index) {
+		org.w3c.dom.Element ret=null;
+		
+		org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+		
+		if (index >= 0 && index < nl.getLength() &&
+				nl.item(index) instanceof org.w3c.dom.Element) {
+			ret = (org.w3c.dom.Element)nl.item(index);
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the service category of the case
+	 * associated with the supplied index.
+	 * 
+	 * @param index The index
+	 * @return The service category
+	 */
+	public String getCaseServiceCategory(int index) {
+		String ret=null;
+		org.w3c.dom.Element caseElem=getCaseElement(index);
+		
+		if (caseElem != null) {
+			ret = caseElem.getAttribute(SERVICE_CATEGORY);
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method returns the service name of the case
+	 * associated with the supplied index.
+	 * 
+	 * @param index The index
+	 * @return The service name
+	 */
+	public String getCaseServiceName(int index) {
+		String ret=null;
+		org.w3c.dom.Element caseElem=getCaseElement(index);
+		
+		if (caseElem != null) {
+			ret = caseElem.getAttribute(SERVICE_NAME);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the DOM element associated with the
+	 * specified service category and name.
+	 * 
+	 * @param category The service category
+	 * @param name The service name
+	 * @return The case element, or null if not found
+	 */
+	public org.w3c.dom.Element getCaseElement(String category,
+					String name) {
+		org.w3c.dom.Element ret=null;
+		
+		org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+		
+		for (int i=0; ret == null && i < nl.getLength(); i++) {
+			if (nl.item(i) instanceof org.w3c.dom.Element) {
+				ret = (org.w3c.dom.Element)nl.item(i);
+				
+				if (ret.getAttribute(SERVICE_CATEGORY).equals(category) == false ||
+						ret.getAttribute(SERVICE_NAME).equals(name) == false) {
+					ret = null;
+				}
+			}
+		}
+
+		return(ret);
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/UnsupportedAction.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/stateful/actions/UnsupportedAction.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/UnsupportedAction.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/actions/UnsupportedAction.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *  
+ * @author gary
+ */
+public class UnsupportedAction extends AbstractESBAction {
+
+	private static final long serialVersionUID = 61328489127442228L;
+
+	/**
+	 * The constructor for the action.
+	 * 
+	 * @param service The reference to the service in which
+	 * 				the action is contained
+	 * @param action The XML configuration details for the action
+	 */
+	public UnsupportedAction(ESBService service,
+					org.w3c.dom.Element action) {
+		super(service, action);
+	}
+
+	/**
+	 * This method determines whether the action is related to a behavioural
+	 * session.
+	 * 
+	 * @return Whether the action is session based
+	 */
+	public boolean isSessionBased() {
+		return(false);
+	}
+	
+	/**
+	 * This method validates the ESB action and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method converts the ESB action into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+	}
+
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/AbstractStatelessESBModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/AbstractStatelessESBModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/AbstractStatelessESBModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/AbstractStatelessESBModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract stateless ESB model change rule.
+ */
+public abstract class AbstractStatelessESBModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if ((context.getParent() instanceof ESBService ||
+				(ref != null && ref.getSource().getObject()
+						instanceof AbstractESBAction &&
+				((AbstractESBAction)ref.getSource().getObject()).getService() != null)) &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless()) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the ESB service associated with the
+	 * optional model object reference or the context.
+	 * 
+	 * @param context The context
+	 * @param ref The optional model object
+	 * @return The ESB service, or null if not found
+	 */
+	protected ESBService getESBService(ModelChangeContext context,
+							ModelObject ref) {
+		ESBService ret=(ESBService)context.getParent();
+		
+		if (ref != null && ref.getSource().getObject() instanceof AbstractESBAction) {
+			ret = ((AbstractESBAction)ref.getSource().getObject()).getService();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines the position of the supplied
+	 * model object within the supplied service.
+	 * 
+	 * @param service The service
+	 * @param ref The optional model object
+	 * @return The position, or -1 if not found
+	 */
+	protected int getPosition(ESBService service, ModelObject ref) {
+		int ret=-1;
+		
+		// Check if reference model object provided, and if so,
+		// if it has a position within the service
+		if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+			ret = service.getActions().indexOf((ESBAction)
+					ref.getSource().getObject());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 * 
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isDeleteSupported(ModelChangeContext context,
+						Model model, ModelObject mobj) {
+		boolean ret=false;
+		
+		if (mobj.getSource().getObject() instanceof AbstractESBAction &&
+				(context.getParent() instanceof ESBService ||
+				((AbstractESBAction)mobj.getSource().getObject()).getService() != null) &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless()) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method removes the supplied model object from the
+	 * supplied model. The model object representation must
+	 * contain the necessary model specific to remove the 
+	 * object from the underlying model representation.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object to be deleted
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean delete(ModelChangeContext context,
+				Model model, ModelObject mobj) {
+		boolean ret=false;
+		ESBService service=getESBService(context, mobj);
+		ESBAction action=(ESBAction)mobj.getSource().getObject();
+		
+		if (action != null && service != null) {
+			ret = service.getActions().remove(action);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		
+		if (context.getParent() instanceof ESBService &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless()) {
+			ret = true;
+		}
+		
+		return(ret);
+	}	
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,579 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.actions.AbstractInteractionMessageAction;
+import org.jboss.savara.tools.jbossesb.model.actions.ReceiveMessageAction;
+import org.jboss.savara.tools.jbossesb.model.actions.SendMessageAction;
+import org.jboss.savara.tools.jbossesb.model.actions.SwitchAction;
+import org.jboss.savara.tools.jbossesb.model.util.ConversationUtil;
+import org.jboss.savara.tools.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation Interaction.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=JBossESBNotation.NOTATION_CODE)
+public class ConversationInteractionModelChangeRule extends AbstractStatelessESBModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+					Model model, ModelObject mobj,
+					ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationInteraction &&
+				super.isInsertSupported(context, model, mobj, ref)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		ConversationInteraction interaction=(ConversationInteraction)mobj;
+		
+		// Check if send or receive
+		if (InteractionUtil.isSend(interaction)) {
+			
+			// Send
+			insertSend(context, esbModel, interaction, ref);		
+			
+		} else {
+			// Receive
+			insertReceive(context, esbModel, interaction, ref);		
+		}
+		
+		return(true);
+	}
+
+	protected void insertSend(ModelChangeContext context,
+			ESBLanguageModel esbModel, ConversationInteraction interaction,
+						ModelObject ref) {
+		ESBService service=getESBService(context, ref);
+
+		SendMessageAction action=
+				new SendMessageAction(service);
+		
+		if (interaction.getMessageSignature().getOperation() != null) {
+			action.setOperation(interaction.getMessageSignature().getOperation());
+		}
+		
+		setMessageType(action, interaction);
+		
+		boolean f_subsequentInitiator=false;
+		boolean f_moveActions=false;
+		
+		// Check if reference model object provided, and if so,
+		// if it has a position within the service
+		int pos=getPosition(service, ref);
+		
+		// Check if subsequent action(s) are initiators
+		if (pos != -1) {
+			for (int i=pos; f_subsequentInitiator == false &&
+					i < service.getActions().size(); i++) {
+				f_subsequentInitiator =
+					service.getActions().get(i).isInitiator();
+			}
+		}
+		
+		// Move actions if a subsequent initiator has been found
+		f_moveActions = f_subsequentInitiator;
+		
+		service.addAction(action, pos);
+		
+		if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
+				interaction.getEnclosingDefinition() instanceof Conversation) {
+			action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+					((Conversation)interaction.getEnclosingDefinition())));
+		}
+		
+		if (interaction.getReplyToLabel() != null) {
+			
+			if (interaction.getToRole() != null) {
+				action.setClientEPR(interaction.getToRole().getName());
+			} else {
+				action.setClientEPR("client");
+			}
+		} else {
+			action.setDestination("", "");			
+		}
+
+		if (interaction.getRequestLabel() != null) {
+			ESBService gw=esbModel.getGatewayService();
+
+			action.setResponseDestination(gw.getCategory(),
+					interaction.getRequestLabel());
+		}
+		
+		/* IS REQUIRED??
+		if (interaction.getRequestLabel() != null) {
+			
+			// Create new ESB service
+			ESBService respService=esbModel.createService(
+							service.getCategory(),
+						esbModel.getUniqueServiceName(service.getCategory(),
+								service.getName()));
+
+			esbModel.addService(respService);
+			
+			action.setResponseDestination(respService.getCategory(),
+					respService.getName());
+
+			context.setParent(respService);
+			
+			// Clear the sub-sequent initiator flag, as
+			// subsequent actions will be moved to new service
+			// anyway
+			f_subsequentInitiator = false;
+			
+		} else if (interaction.getReplyToLabel() != null) {
+			
+			if (interaction.getToRole() != null) {
+				action.setClientEPR(interaction.getToRole().getName());
+			} else {
+				action.setClientEPR("client");
+			}
+		}	
+
+		// Check if subsequent initiator found, requiring
+		// a new service
+		if (f_subsequentInitiator) {
+			
+			ESBService extraService=esbModel.createService(
+					service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
+
+			esbModel.addService(extraService);
+			
+			// Add schedule action
+			ScheduleStateAction schedule=
+				new ScheduleStateAction(service);
+			
+			schedule.setDestination(extraService.getCategory(),
+					extraService.getName(), false);
+			
+			service.addAction(schedule, pos+1);
+			
+			// Move pointer on, as now additional 'schedule' action
+			pos++;
+
+			context.setParent(extraService);
+		}
+		
+		// Check if existing actions need to be moved
+		if (f_moveActions) {
+			for (int i=pos+1; i < service.getActions().size();) {
+				ESBService extraService=(ESBService)context.getParent();
+				
+				ESBAction act=service.getActions().get(i);
+				service.getActions().remove(i);
+				
+				extraService.addAction(act, -1);
+			}
+		}
+		
+		// If not reply, then include the target service
+		// details
+		if (interaction.getReplyToLabel() == null &&
+				interaction.getToRole() != null &&
+				interaction.getToRole().getName() != null &&
+				interaction.getToRole().getName().length() > 0) {
+			String roleName=Character.toLowerCase(
+					interaction.getToRole().getName().charAt(0))+
+					interaction.getToRole().getName().substring(1);
+			
+			action.setDestinationExpression(
+					InteractionUtil.getRoleServiceCategoryProperty(roleName),
+					InteractionUtil.getRoleServiceNameProperty(roleName));
+		}
+		
+		if (interaction.getEnclosingDefinition() instanceof Conversation &&
+				interaction.getEnclosingDefinition().getModel()
+						instanceof ConversationModel) {
+			
+			java.util.List<Identity> ids=((Conversation)
+					interaction.getEnclosingDefinition()).getIdentities();
+
+			java.util.List<IdentityLocator> locators=
+				((ConversationModel)interaction.getEnclosingDefinition().
+							getModel()).getIdentityLocators();
+			
+			IdentityUtil.defineIdentities(action.getPropertyElement(
+					SendMessageAction.IDENTITIES),
+						interaction.getMessageSignature(), ids, locators);
+		}
+		*/
+	}
+
+	protected void insertReceive(ModelChangeContext context,
+			ESBLanguageModel esbModel, ConversationInteraction interaction,
+						ModelObject ref) {
+		ESBService service=getESBService(context, ref);
+		ESBService endService=service;
+		
+		int endPos=-1;
+		boolean f_subsequentInitiator=false;
+		
+		// Check if reference model object provided, and if so,
+		// if it has a position within the service
+		int pos=getPosition(service, ref);
+			
+		// Check if subsequent action(s) are initiators
+		if (pos != -1) {
+			for (int i=pos; f_subsequentInitiator == false &&
+					i < service.getActions().size(); i++) {
+				f_subsequentInitiator =
+					service.getActions().get(i).isInitiator();
+			}
+		}
+		
+		endPos = pos;
+		
+		// Check if receive needs to be placed in new service
+		// descriptor - i.e. if insert at end, but current service
+		// already has service based actions, or reference object
+		// provided, but is not first position
+		
+		/* IS THIS REQUIRED??
+		if (shouldScheduleNewService(service, (pos == -1 ?
+				service.getActions().size() : pos))) {
+			
+			// Already has activities, so need to separate
+			// into another service descriptor
+			ESBService recvService=esbModel.createService(
+					service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
+
+			esbModel.addService(recvService);
+			
+			// Add schedule action
+			ScheduleStateAction schedule=
+				new ScheduleStateAction(service);
+			
+			schedule.setDestination(recvService.getCategory(),
+					recvService.getName(), false);
+			
+			service.addAction(schedule, pos);
+
+			context.setParent(recvService);
+			
+			endService = recvService;
+			endPos = 0;
+		}
+		*/
+		
+		ReceiveMessageAction action=
+				new ReceiveMessageAction(endService);
+	
+		if (interaction.getMessageSignature().getOperation() != null) {
+			action.setOperation(interaction.getMessageSignature().getOperation());
+		}
+		
+		setMessageType(action, interaction);
+			
+		endService.addAction(action, endPos);
+		
+		if (endService.getFirstSessionBasedAction() == action &&
+				interaction.getEnclosingDefinition() instanceof Conversation) {
+			action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+					((Conversation)interaction.getEnclosingDefinition())));
+		}
+		
+		// Check if subsequent initiator found, requiring
+		// a new service
+		/* IS STILL REQUIRED?
+		if (f_subsequentInitiator) {
+			
+			ESBService extraService=esbModel.createService(
+					service.getCategory(),
+					esbModel.getUniqueServiceName(endService.getCategory(),
+							endService.getName()));
+
+			esbModel.addService(extraService);
+			
+			// Add schedule action
+			ScheduleStateAction schedule=
+				new ScheduleStateAction(endService);
+			
+			schedule.setDestination(extraService.getCategory(),
+					extraService.getName(), false);
+			
+			endService.addAction(schedule, endPos+1);
+			
+			// Move pointer on, as now additional 'schedule' action
+			pos++;
+
+			context.setParent(extraService);
+			
+			endService = extraService;
+			endPos = -1;
+		}
+		
+		// Check if existing actions need to be moved
+		if (pos != -1 && service != endService) {
+			for (int i=pos+1; i < service.getActions().size();) {
+				ESBAction act=service.getActions().get(i);
+				service.getActions().remove(i);
+				
+				endService.addAction(act, -1);
+			}
+		}
+
+		// If not a response, then add to the gateway
+		if (interaction.getReplyToLabel() == null) {
+			ESBService gwService=esbModel.getGatewayService();
+			
+			if (gwService != null) {
+				ESBAction gwAction=gwService.getGatewayAction();
+				
+				if (gwAction instanceof MessageRouterAction) {
+					MessageRouterAction mra=(MessageRouterAction)
+								gwAction;
+					
+					java.util.List<MessageSignature> mtypes=
+							new java.util.Vector<MessageSignature>();
+					mtypes.add(interaction.getMessageSignature());
+					
+					mra.addRoute(endService.getCategory(),
+							endService.getName(),
+							service.isRoot(), mtypes);
+				}
+			}
+			
+			// Set client EPR
+			if (interaction.getFromRole() != null) {
+				action.setClientEPR(interaction.getFromRole().getName());
+			} else {
+				action.setClientEPR("client");
+			}
+		}		
+		
+		if (interaction.getEnclosingDefinition() instanceof Conversation &&
+				interaction.getEnclosingDefinition().getModel()
+						instanceof ConversationModel) {
+			
+			java.util.List<Identity> ids=((Conversation)
+					interaction.getEnclosingDefinition()).getIdentities();
+
+			java.util.List<IdentityLocator> locators=
+				((ConversationModel)interaction.getEnclosingDefinition().
+							getModel()).getIdentityLocators();
+			
+			IdentityUtil.defineIdentities(action.getPropertyElement(
+					SendMessageAction.IDENTITIES),
+						interaction.getMessageSignature(), ids, locators);
+		}
+		*/
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		
+		if (fromObj instanceof ConversationInteraction &&
+				toObj instanceof ConversationInteraction &&
+				super.isUpdateSupported(context, model, fromObj, toObj)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean update(ModelChangeContext context,
+				Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+		ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+		ESBService service=(ESBService)context.getParent();
+		
+		// Get action from 'toInteraction'
+		if (toInteraction.getSource().getObject() instanceof
+							AbstractInteractionMessageAction) {
+			AbstractInteractionMessageAction ma=
+					(AbstractInteractionMessageAction)
+						toInteraction.getSource().getObject();
+				
+			String origMesgType=ma.getMessageType();
+			
+			// Set message type
+			setMessageType(ma, fromInteraction);
+			
+			// Update message type in router if appropriate
+			if (InteractionUtil.isSend(fromInteraction) == false &&
+					fromInteraction.getReplyToLabel() == null) {
+				updateRouterMessageType(esbModel, service,
+						origMesgType, ma);
+			}
+			
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	protected void updateRouterMessageType(ESBLanguageModel esbModel,
+					ESBService service, String origMesgType,
+					AbstractInteractionMessageAction ma) {
+		ESBService gwService=esbModel.getGatewayService();
+		
+		if (gwService != null) {
+			ESBAction gwAction=gwService.getGatewayAction();
+			
+			if (gwAction instanceof SwitchAction) {
+				SwitchAction mra=(SwitchAction)
+							gwAction;
+				
+				org.w3c.dom.Element route=
+						mra.getCaseElement(service.getCategory(),
+								service.getName());
+				
+				if (route != null) {
+					org.w3c.dom.NodeList nl=
+						route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
+					
+					for (int i=0; i < nl.getLength(); i++) {
+						if (nl.item(i) instanceof org.w3c.dom.Element) {
+							org.w3c.dom.Element mesg=
+								(org.w3c.dom.Element)nl.item(i);
+							
+							if (mesg.getAttribute(SwitchAction.TYPE_ATTR).
+												equals(origMesgType)) {
+								mesg.setAttribute(SwitchAction.TYPE_ATTR,
+												ma.getMessageType());
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	protected void setMessageType(AbstractInteractionMessageAction action,
+						ConversationInteraction interaction) {
+		
+		if (interaction.getMessageSignature().getTypes().size() == 1) {
+			TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+			
+			// TODO: Search for an implementation associated with
+			// the type reference, so that the type can be
+			// abstract - possibly have the required message type
+			// notation as part of the context, so that if multiple
+			// implementations found, then can select e.g. XML or
+			// Java as message type representation.
+			String mtype=InteractionUtil.getTypeString(ref);
+			
+			action.setMessageType(mtype);
+		}
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 * 
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isDeleteSupported(ModelChangeContext context,
+						Model model, ModelObject mobj) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationInteraction &&
+				super.isDeleteSupported(context, model, mobj)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/ConversationModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/ConversationModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.util.ConversationUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=JBossESBNotation.NOTATION_CODE)
+public class ConversationModelChangeRule extends AbstractModelChangeRule {
+
+	private static final String NAME_SUFFIX = "_main";
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof Conversation &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless()) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		Conversation conv=(Conversation)mobj;
+		
+		String namespace=((Model)conv.getModel()).
+					getNamespace().getName();
+		
+		String category=ConversationUtil.getServiceCategory(conv);
+		
+		String name=ConversationUtil.getServiceName(conv);
+
+		String sdname="";
+			
+		// Check if root conversation
+		if (conv.getParent() instanceof Model) {
+			
+			// Register gateway service
+			DefaultESBService gateway=new DefaultESBService(esbModel,
+						category, name);
+			
+			esbModel.addService(gateway);
+			
+			/*
+			MessageRouterAction mra=new MessageRouterAction(gateway);
+			
+			// Construct service description name
+			if (namespace != null) {
+				sdname = "{"+namespace+"}";
+			}
+			
+			sdname += conv.getModelName().getName()+"-"+
+					conv.getModelName().getLocatedRole().getName();
+			
+			mra.setServiceDescriptionName(sdname);
+			
+			gateway.addAction(mra, -1);
+			
+			esbModel.addService(gateway);
+			
+			name += NAME_SUFFIX;
+			
+			String ctype=null;
+			
+			// Check if conversation has a 'conforms to' reference
+			if (conv.getConformsTo().size() > 0) {
+				// Set conversation type based on first 'conforms to'
+				// reference
+				ConformanceReference cref=conv.getConformsTo().get(0);
+				
+				ctype = cref.getNamespace()+"."+
+						cref.getLocalpart()+"@"+
+						cref.getLocatedRole();
+			} else {
+				// Set conversation type based on conversation
+				// namespace and name
+				ctype = namespace+"."+
+						conv.getModelName().getName()+"@"+
+						conv.getModelName().getLocatedRole().getName();
+			}
+			
+			if (ctype != null) {
+				mra.setConversationType(ctype);
+			}
+			*/
+
+			// Process the activities within the conversation
+			java.util.List<Activity> acts=conv.getBlock().getContents();
+			
+			context.setParent(gateway);
+			
+			for (int i=0; i < acts.size(); i++) {
+				context.insert(model, acts.get(i), null);
+			}
+		}
+		
+		/*
+		// Create new ESB service
+		ESBService service=esbModel.createService(category, name);
+
+		esbModel.addService(service);
+		
+		// Create 'CreateSession' activity
+		// Process the activities within the conversation
+		java.util.List<Activity> acts=conv.getBlock().getContents();
+		
+		context.setParent(service);
+		
+		for (int i=0; i < acts.size(); i++) {
+			context.insert(model, acts.get(i), null);
+		}
+		*/
+		
+		return(true);
+	}
+	
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/IfModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,381 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import java.util.logging.Logger;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.actions.IfAction;
+import org.jboss.savara.tools.jbossesb.model.actions.SwitchAction;
+import org.jboss.savara.tools.jbossesb.model.util.ConversationUtil;
+import org.jboss.savara.tools.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the If grouping construct.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=JBossESBNotation.NOTATION_CODE)
+public class IfModelChangeRule extends AbstractStatelessESBModelChangeRule {
+
+	private static final String NAME_SUFFIX = "_main";
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof If &&
+				super.isInsertSupported(context, model, mobj, ref)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		ESBService service=getESBService(context, ref);
+		If ifElem=(If)mobj;
+		
+		int pos=getPosition(service, ref);
+
+		// Check if should be an 'if' or a 'switch' action
+		
+		if (ifElem.getRoles().contains(context.getRole())) {
+			
+			insertIf(context, model, service, ifElem, pos);
+		} else {
+			insertSwitch(context, model, service, ifElem, pos);
+		}
+
+		return(true);
+	}
+	
+	protected void insertIf(ModelChangeContext context,
+			Model model, ESBService service,
+			If ifElem, int pos) {
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		
+		// If action, because the role is a decision maker
+		IfAction ifAction=new IfAction(service);
+		
+		service.addAction(ifAction, pos);
+		
+		for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+			ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+			
+			ESBService subService=
+				esbModel.createService(service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
+			
+			esbModel.addService(subService);
+
+			context.setParent(subService);
+			
+			for (int j=0; j < cb.getContents().size(); j++) {
+				context.insert(model, cb.getContents().get(j), null);
+			}
+
+			boolean immediate=false;
+			
+			ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+					subService.getCategory(), subService.getName(),
+					immediate, null, i);
+		}
+		
+		if (ifElem.getElseBlock() != null) {
+			
+			ESBService subService=
+				esbModel.createService(service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
+
+			esbModel.addService(subService);
+
+			context.setParent(subService);
+			
+			for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+				context.insert(model,
+						ifElem.getElseBlock().getContents().get(j), null);
+			}
+			
+			boolean immediate=false;
+
+			ifAction.addPath(IfAction.ELSE,
+					subService.getCategory(), subService.getName(),
+					immediate, null, -1);
+		}
+	}
+
+	protected void insertSwitch(ModelChangeContext context,
+			Model model, ESBService service,
+			If ifElem, int pos) {
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		java.util.Map<String,java.util.List<ESBService>> replyServices=
+				new java.util.Hashtable<String,java.util.List<ESBService>>();
+		java.util.Map<ESBService,java.util.Set<Interaction>> replyServiceMTypes=
+			new java.util.Hashtable<ESBService,java.util.Set<Interaction>>();
+		
+		// Switch action, as role is a decision observer
+		SwitchAction switchAction=new SwitchAction(service);
+		
+		if (ifElem.getParent() != null &&
+				ifElem.getParent().getParent() instanceof Conversation &&
+				((Conversation)ifElem.getParent().getParent()).isStateless()) {
+			Conversation conv=(Conversation)ifElem.getParent().getParent();
+			
+			String namespace=((Model)conv.getModel()).
+						getNamespace().getName();
+
+			String name=ConversationUtil.getServiceName(conv);
+
+			String sdname="";
+	
+			// Construct service description name
+			if (namespace != null) {
+				sdname = "{"+namespace+"}";
+			}
+			
+			sdname += conv.getLocatedName().getName()+"-"+
+					conv.getLocatedName().getRole().getName();
+			
+			switchAction.setServiceDescriptionName(sdname);
+			
+			name += NAME_SUFFIX;
+			
+			String ctype=null;
+			
+			// Check if conversation has a 'conforms to' reference
+			if (conv.getConformsTo().size() > 0) {
+				// Set conversation type based on first 'conforms to'
+				// reference
+				ConformanceReference cref=conv.getConformsTo().get(0);
+				
+				ctype = cref.getNamespace()+"."+
+						cref.getLocalpart()+"@"+
+						cref.getLocatedRole();
+			} else {
+				// Set conversation type based on conversation
+				// namespace and name
+				ctype = namespace+"."+
+						conv.getLocatedName().getName()+"@"+
+						conv.getLocatedName().getRole().getName();
+			}
+			
+			if (ctype != null) {
+				switchAction.setConversationType(ctype);
+			}
+		}
+		
+		service.addAction(switchAction, pos);
+		
+		// Get lookahead analyser
+		LookaheadAnalyser la=(LookaheadAnalyser)
+				RegistryFactory.getRegistry().getExtension(
+						LookaheadAnalyser.class, null);
+		
+		if (la == null) {
+			logger.severe("Failed to find lookahead analyser");
+		}
+		
+		for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+			ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+			
+			java.util.Set<Interaction> interactions=null;
+			String replyLabel=null;
+			
+			if (la != null) {
+				interactions = la.getInteractions(cb);
+
+				replyLabel = getReplyLabel(interactions);
+			}
+			
+			ESBService subService=
+				esbModel.createService(service.getCategory(),
+						esbModel.getUniqueServiceName(service.getCategory(),
+								service.getName()));
+
+			esbModel.addService(subService);
+
+			context.setParent(subService);
+			
+			for (int j=0; j < cb.getContents().size(); j++) {
+				context.insert(model, cb.getContents().get(j), null);
+			}
+
+			if (replyLabel != null) {
+				java.util.List<ESBService> services=
+					replyServices.get(replyLabel);
+				
+				if (services == null) {
+					services = new java.util.Vector<ESBService>();
+					replyServices.put(replyLabel, services);
+				}
+				
+				services.add(subService);
+				
+				replyServiceMTypes.put(subService, interactions);
+			} else {
+				switchAction.addCase(subService.getCategory(),
+						subService.getName(), interactions, i);
+			}			
+		}
+		
+		if (ifElem.getElseBlock() != null) {
+			
+			ESBService subService=
+				esbModel.createService(service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
+
+			esbModel.addService(subService);
+
+			context.setParent(subService);
+			
+			for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+				context.insert(model,
+						ifElem.getElseBlock().getContents().get(j), null);
+			}
+				
+			java.util.Set<Interaction> interactions=null;
+			String replyLabel=null;
+			
+			if (la != null) {
+				interactions = la.getInteractions(ifElem.getElseBlock());
+
+				replyLabel = getReplyLabel(interactions);
+			}
+			
+			if (replyLabel != null) {
+				java.util.List<ESBService> services=
+					replyServices.get(replyLabel);
+				
+				if (services == null) {
+					services = new java.util.Vector<ESBService>();
+					replyServices.put(replyLabel, services);
+				}
+				
+				services.add(subService);
+				
+				replyServiceMTypes.put(subService, interactions);
+			} else {
+				switchAction.addCase(subService.getCategory(),
+						subService.getName(), interactions, -1);
+			}
+		}
+		
+		java.util.Iterator<String> replyLabels=replyServices.keySet().iterator();
+		
+		while (replyLabels.hasNext()) {
+			String replyLabel=replyLabels.next();
+			
+			java.util.List<ESBService> services=replyServices.get(replyLabel);
+			
+			if (services.size() == 1) {
+				ESBService serv=services.get(0);
+				
+				serv.setName(replyLabel);
+			} else {
+				ESBService subService=
+					esbModel.createService(service.getCategory(),
+								replyLabel);
+
+				esbModel.addService(subService);				
+				
+				SwitchAction subSwitchAction=
+							new SwitchAction(subService);
+
+				subService.addAction(subSwitchAction, -1);
+
+				for (int i=0; i < services.size(); i++) {
+					ESBService serv=services.get(i);
+					
+					subSwitchAction.addCase(serv.getCategory(),
+							serv.getName(),
+							replyServiceMTypes.get(serv), -1);
+				}
+			}
+		}
+	}
+	
+	protected String getReplyLabel(java.util.Set<Interaction> interactions) {
+		String ret=null;
+		
+		if (interactions != null) {
+			java.util.Iterator<Interaction> iter=
+					interactions.iterator();
+			
+			while (ret == null && iter.hasNext()) {
+				Interaction interaction=iter.next();
+
+				if (InteractionUtil.isSend(interaction) == false) {
+					ret = interaction.getReplyToLabel();
+				}
+			}
+		}
+
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model.change");
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/LanguageToConversationModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/LanguageToConversationModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/LanguageToConversationModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/LanguageToConversationModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=JBossESBNotation.NOTATION_CODE)
+public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationModel &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless()) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		ConversationModel cm=(ConversationModel)mobj;
+		
+		if (cm.getConversation() != null) {
+			context.insert(model, cm.getConversation(), null);
+		}
+		
+		return(true);
+	}
+	
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/TypeReferenceModelChangeRule.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/stateless/TypeReferenceModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/TypeReferenceModelChangeRule.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/change/TypeReferenceModelChangeRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.actions.AbstractInteractionMessageAction;
+import org.jboss.savara.tools.jbossesb.model.actions.SwitchAction;
+import org.jboss.savara.tools.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Type Reference.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=JBossESBNotation.NOTATION_CODE)
+public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		
+		if (fromObj instanceof TypeReference &&
+				toObj instanceof TypeReference &&
+				model instanceof ESBLanguageModel &&
+				((ESBLanguageModel)model).isStateless() == true) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean update(ModelChangeContext context,
+				Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		ESBLanguageModel esbModel=(ESBLanguageModel)model;
+		TypeReference fromTypeRef=(TypeReference)fromObj;
+		TypeReference toTypeRef=(TypeReference)toObj;
+		ConversationInteraction toInteraction=null;
+		ConversationInteraction fromInteraction=null;
+		
+		if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature &&
+						toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+			toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
+		}
+		
+		if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature &&
+						fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+			fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
+		}
+		
+		// Get action from 'toInteraction'
+		if (toInteraction != null &&
+				toInteraction.getSource().getObject() instanceof
+							AbstractInteractionMessageAction) {
+			AbstractInteractionMessageAction ma=
+					(AbstractInteractionMessageAction)
+						toInteraction.getSource().getObject();
+			
+			ESBService service = ma.getService();
+				
+			String origMesgType=ma.getMessageType();
+			
+			// Set message type
+			setMessageType(ma, fromInteraction);
+			
+			// Update message type in router if appropriate
+			if (InteractionUtil.isSend(fromInteraction) == false &&
+					fromInteraction.getReplyToLabel() == null) {
+				updateRouterMessageType(esbModel, service,
+						origMesgType, ma);
+			}
+			
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	protected void updateRouterMessageType(ESBLanguageModel esbModel,
+					ESBService service, String origMesgType,
+					AbstractInteractionMessageAction ma) {
+		ESBService gwService=esbModel.getGatewayService();
+		
+		if (gwService != null) {
+			ESBAction gwAction=gwService.getGatewayAction();
+			
+			if (gwAction instanceof SwitchAction) {
+				SwitchAction mra=(SwitchAction)
+							gwAction;
+				
+				org.w3c.dom.Element route=
+						mra.getCaseElement(service.getCategory(),
+								service.getName());
+				
+				if (route != null) {
+					org.w3c.dom.NodeList nl=
+						route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
+					
+					for (int i=0; i < nl.getLength(); i++) {
+						if (nl.item(i) instanceof org.w3c.dom.Element) {
+							org.w3c.dom.Element mesg=
+								(org.w3c.dom.Element)nl.item(i);
+							
+							if (mesg.getAttribute(SwitchAction.TYPE_ATTR).
+												equals(origMesgType)) {
+								mesg.setAttribute(SwitchAction.TYPE_ATTR,
+												ma.getMessageType());
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	protected void setMessageType(AbstractInteractionMessageAction action,
+						ConversationInteraction interaction) {
+		
+		if (interaction.getMessageSignature().getTypes().size() == 1) {
+			TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+			
+			// TODO: Search for an implementation associated with
+			// the type reference, so that the type can be
+			// abstract - possibly have the required message type
+			// notation as part of the context, so that if multiple
+			// implementations found, then can select e.g. XML or
+			// Java as message type representation.
+			String mtype=InteractionUtil.getTypeString(ref);
+			
+			action.setMessageType(mtype);
+		}
+	}
+}

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/util/PropertyUtil.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/util/PropertyUtil.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/model/util/PropertyUtil.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -131,5 +131,5 @@
 		return(ret);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.model.util");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/parser/JBossESBModelParserRule.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/parser/JBossESBModelParserRule.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/java/org/jboss/savara/tools/jbossesb/parser/JBossESBModelParserRule.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -107,5 +107,5 @@
 		return(ret);
 	}
 
-	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.parser");
+	private static Logger logger = Logger.getLogger("org.jboss.savara.tools.jbossesb.parser");
 }

Modified: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/DefaultESBServiceTest.java
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/DefaultESBServiceTest.java	2009-08-21 10:10:51 UTC (rev 793)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/DefaultESBServiceTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -21,7 +21,6 @@
 
 import org.jboss.savara.tools.jbossesb.model.DefaultESBLanguageModel;
 import org.jboss.savara.tools.jbossesb.model.DefaultESBService;
-import org.jboss.savara.tools.jbossesb.model.stateful.actions.*;
 
 public class DefaultESBServiceTest extends TestCase {
 
@@ -37,7 +36,7 @@
 		
 		l.addExpectedError(org.scribble.util.MessageUtil.format(
 						java.util.PropertyResourceBundle.getBundle(
-						"org.jboss.tools.overlord.cdl.runtime.jbossesb.model.Messages"),
+						"org.jboss.savara.tools.jbossesb.model.Messages"),
 							"_NOT_SPECIFIED_SESSION_CLASS",
 							new String[]{}));
 		

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/IfActionTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/stateful/actions/IfActionTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/IfActionTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/IfActionTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,632 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import junit.framework.TestCase;
+
+import org.jboss.savara.tools.jbossesb.model.TestESBLanguageModel;
+import org.jboss.savara.tools.jbossesb.model.TestESBService;
+import org.jboss.savara.tools.jbossesb.model.TestModelListener;
+import org.jboss.savara.tools.jbossesb.model.actions.IfAction;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class IfActionTest extends TestCase {
+
+	public void testValidatePathsSpecified() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		IfAction action=new IfAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_NOT_SPECIFIED_PROPERTY",
+							new String[]{"paths"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateServiceNotFound() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat1","name1"}));
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat2","name2"}));
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat3","name3"}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateNoPathsContent() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat3");
+		other2.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_IF_ORDER_WRONG",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateOnlyOneIf() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><if service-category=\"cat3\" " +
+				"service-name=\"name3\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_IF_ORDER_WRONG",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateOutOfOrderElse() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_IF_ORDER_WRONG",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateMissingServiceDetails() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_PATH_SERVICE_DETAILS_MISSING",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	/*
+	public void testValidateImmediateIf() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" immediate=\"fred\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.stateful.actions.Messages"),
+							"_BOOLEAN",
+							new String[]{IfAction.IMMEDIATE}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateImmediateElseIf() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" immediate=\"fred\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.stateful.actions.Messages"),
+							"_BOOLEAN",
+							new String[]{IfAction.IMMEDIATE}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateImmediateElse() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" immediate=\"fred\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.stateful.actions.Messages"),
+							"_BOOLEAN",
+							new String[]{IfAction.IMMEDIATE}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	*/
+	
+	public void testConvert() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestActivity act1=new TestActivity();
+		other1.getContents().add(act1);
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestActivity act2=new TestActivity();
+		other2.getContents().add(act2);
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestActivity act3=new TestActivity();
+		other3.getContents().add(act3);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, null);
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof If) == false) {
+			fail("Expecting an 'If' activity");
+		}
+		
+		If ifAction=(If)act;
+		
+		if (ifAction.getConditionalBlocks().size() != 2) {
+			fail("Expecting two conditional blocks: "+ifAction.getConditionalBlocks().size());
+		}
+		
+		if (ifAction.getConditionalBlocks().get(0).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(0).getContents().get(0) != act1) {
+			fail("First conditional block should have 1 activity = act1");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(1).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(1).getContents().get(0) != act2) {
+			fail("Second conditional block should have 1 activity = act2");
+		}
+		
+		if (ifAction.getElseBlock() == null) {
+			fail("Else block not defined");
+		}
+		
+		if (ifAction.getElseBlock().getContents().size() != 1 ||
+				ifAction.getElseBlock().getContents().get(0) != act3) {
+			fail("Else block should have 1 activity = act3");
+		}
+	}
+	
+	public void testConvertNotExcludingEmptyPaths() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><if service-category=\"cat1\" " +
+				"service-name=\"name1\" /><elseif service-category=\"cat2\" " +
+				"service-name=\"name2\" /><else service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		IfAction action=new IfAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, null);
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof If) == false) {
+			fail("Expecting an 'If' activity");
+		}
+		
+		If ifAction=(If)act;
+		
+		if (ifAction.getConditionalBlocks().size() != 2) {
+			fail("Expecting two conditional blocks: "+ifAction.getConditionalBlocks().size());
+		}
+		
+		if (ifAction.getConditionalBlocks().get(0).getContents().size() != 0) {
+			fail("First conditional block should be empty");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(1).getContents().size() != 0) {
+			fail("Second conditional block should be empty");
+		}
+		
+		if (ifAction.getElseBlock() == null) {
+			fail("Else block not defined");
+		}
+		
+		if (ifAction.getElseBlock().getContents().size() != 0) {
+			fail("Else block should have be empty");
+		}
+	}
+	
+	public void testIsCreateSession() {
+		TestESBService service=new TestESBService();
+		
+		IfAction action=new IfAction(service, null);
+		
+		if (action.isSessionType() == true) {
+			fail("Action is flagged as a 'CreateSession'");
+		}
+	}
+	
+	public void testIsSessionBased() {
+		TestESBService service=new TestESBService();
+		
+		IfAction action=new IfAction(service, null);
+		
+		if (action.isSessionBased() == false) {
+			fail("Action is not flagged as a 'SessionBased'");
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageActionTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/stateful/actions/ReceiveMessageActionTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageActionTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/ReceiveMessageActionTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.scribble.model.*;
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.actions.ReceiveMessageAction;
+
+import junit.framework.TestCase;
+
+public class ReceiveMessageActionTest extends TestCase {
+
+	public void testValidateNoMessageType() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("identities", "");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+					"_NOT_SPECIFIED_PROPERTY",
+					new String[]{"messageType"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateNoIdentities() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+					"_NOT_SPECIFIED_PROPERTY",
+					new String[]{"identities"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testConvertRoles() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getToRole() == null) {
+			fail("'To' role is null");
+		}
+		
+		if (interaction.getToRole().getName().equals(role) == false) {
+			fail("'To' role should be '"+role+"', but found: "+interaction.getToRole().getName());
+		}
+		
+		if (interaction.getFromRole() != null) {
+			fail("'From' role should be null");
+		}
+	}
+	
+	public void testConvertMessageBased() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getMessageSignature() == null) {
+			fail("Message signature is null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation() != null) {
+			fail("Operation should be null");
+		}
+		
+		if (interaction.getMessageSignature().getTypes().size() != 1) {
+			fail("Only one type expected, but got: "+interaction.getMessageSignature().getTypes().size());
+		}
+		
+		TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+		
+		if (ref.getNamespace() == null ||
+				ref.getNamespace().equals(ns) == false) {
+			fail("Namespace should be '"+ns+"', but found: "+ref.getNamespace());
+		}
+		
+		if (ref.getLocalpart() == null ||
+				ref.getLocalpart().equals(lp) == false) {
+			fail("Local type should be '"+lp+"', but found: "+ref.getLocalpart());
+		}
+	}
+	
+	public void testConvertRPCBased() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String opname="op";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("operation", opname);
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getMessageSignature() == null) {
+			fail("Message signature is null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation() == null) {
+			fail("Operation should not be null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation().equals(opname) == false) {
+			fail("Operation expected '"+opname+"', but got: "+
+							interaction.getMessageSignature().getOperation());
+		}
+		
+		if (interaction.getMessageSignature().getTypes().size() != 1) {
+			fail("Only one type expected, but got: "+interaction.getMessageSignature().getTypes().size());
+		}
+		
+		TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+		
+		if (ref.getNamespace() == null ||
+				ref.getNamespace().equals(ns) == false) {
+			fail("Namespace should be '"+ns+"', but found: "+ref.getNamespace());
+		}
+		
+		if (ref.getLocalpart() == null ||
+				ref.getLocalpart().equals(lp) == false) {
+			fail("Local type should be '"+lp+"', but found: "+ref.getLocalpart());
+		}
+	}
+	
+	public void testIsCreateSession() {
+		TestESBService service=new TestESBService();
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, null);
+		
+		if (action.isSessionType() == true) {
+			fail("Action is flagged as a 'CreateSession'");
+		}
+	}
+	
+	public void testIsSessionBased() {
+		TestESBService service=new TestESBService();
+		
+		ReceiveMessageAction action=new ReceiveMessageAction(service, null);
+		
+		if (action.isSessionBased() == false) {
+			fail("Action is not flagged as a 'SessionBased'");
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SendMessageActionTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/stateful/actions/SendMessageActionTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SendMessageActionTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SendMessageActionTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,363 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.DefaultConversionContext;
+import org.jboss.savara.tools.jbossesb.model.TestESBLanguageModel;
+import org.jboss.savara.tools.jbossesb.model.TestESBService;
+import org.jboss.savara.tools.jbossesb.model.TestModelListener;
+import org.jboss.savara.tools.jbossesb.model.actions.SendMessageAction;
+import org.scribble.model.Activity;
+import org.scribble.model.Interaction;
+import org.scribble.model.TypeReference;
+
+import junit.framework.TestCase;
+
+public class SendMessageActionTest extends TestCase {
+
+	public void testValidateNoMessageType() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("identities", "");
+		props.put("serviceCategory", "");
+		props.put("serviceName", "");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+					"_NOT_SPECIFIED_PROPERTY",
+					new String[]{"messageType"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateNoIdentities() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "");
+		props.put("clientRole", "");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+					"_NOT_SPECIFIED_PROPERTY",
+					new String[]{"identities"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateNoDestination() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "");
+		props.put("identities", "");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+					"_NOT_SPECIFIED_REQ_RESP_EPR",
+					new String[]{}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateResponseService() {
+		TestESBService service=new TestESBService();
+		service.setRoot(true);
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "");
+		props.put("identities", "");
+		props.put("serviceCategory", "cat1");
+		props.put("serviceName", "name1");
+		props.put("responseServiceCategory", "cat2");
+		props.put("responseServiceName", "name2");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat2", "name2"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testConvertRoles() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getFromRole() == null) {
+			fail("'From' role is null");
+		}
+		
+		if (interaction.getFromRole().getName().equals(role) == false) {
+			fail("'From' role should be '"+role+"', but found: "+interaction.getFromRole().getName());
+		}
+		
+		if (interaction.getToRole() != null) {
+			fail("'To' role should be null");
+		}
+	}
+	
+	public void testConvertMessageBased() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getMessageSignature() == null) {
+			fail("Message signature is null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation() != null) {
+			fail("Operation should be null");
+		}
+		
+		if (interaction.getMessageSignature().getTypes().size() != 1) {
+			fail("Only one type expected, but got: "+interaction.getMessageSignature().getTypes().size());
+		}
+		
+		TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+		
+		if (ref.getNamespace() == null ||
+				ref.getNamespace().equals(ns) == false) {
+			fail("Namespace should be '"+ns+"', but found: "+ref.getNamespace());
+		}
+		
+		if (ref.getLocalpart() == null ||
+				ref.getLocalpart().equals(lp) == false) {
+			fail("Local type should be '"+lp+"', but found: "+ref.getLocalpart());
+		}
+	}
+	
+	public void testConvertRPCBased() {
+		TestESBService service=new TestESBService();
+		
+		String ns="MessageTypeNS";
+		String lp="MessageType";
+		String opname="op";
+		String role="Buyer";
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("operation", opname);
+		props.put("messageType", "{"+ns+"}"+lp);
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SendMessageAction action=new SendMessageAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, new DefaultConversionContext(role));
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof Interaction) == false) {
+			fail("Expecting an 'Interaction' activity");
+		}
+		
+		Interaction interaction=(Interaction)act;
+		
+		if (interaction.getMessageSignature() == null) {
+			fail("Message signature is null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation() == null) {
+			fail("Operation should not be null");
+		}
+		
+		if (interaction.getMessageSignature().getOperation().equals(opname) == false) {
+			fail("Operation expected '"+opname+"', but got: "+
+							interaction.getMessageSignature().getOperation());
+		}
+		
+		if (interaction.getMessageSignature().getTypes().size() != 1) {
+			fail("Only one type expected, but got: "+interaction.getMessageSignature().getTypes().size());
+		}
+		
+		TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+		
+		if (ref.getNamespace() == null ||
+				ref.getNamespace().equals(ns) == false) {
+			fail("Namespace should be '"+ns+"', but found: "+ref.getNamespace());
+		}
+		
+		if (ref.getLocalpart() == null ||
+				ref.getLocalpart().equals(lp) == false) {
+			fail("Local type should be '"+lp+"', but found: "+ref.getLocalpart());
+		}
+	}
+	
+	public void testIsCreateSession() {
+		TestESBService service=new TestESBService();
+		
+		SendMessageAction action=new SendMessageAction(service, null);
+		
+		if (action.isSessionType() == true) {
+			fail("Action is flagged as a 'CreateSession'");
+		}
+	}
+	
+	public void testIsSessionBased() {
+		TestESBService service=new TestESBService();
+		
+		SendMessageAction action=new SendMessageAction(service, null);
+		
+		if (action.isSessionBased() == false) {
+			fail("Action is not flagged as a 'SessionBased'");
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SwitchActionTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/stateful/actions/SwitchActionTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SwitchActionTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/actions/SwitchActionTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,382 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.actions;
+
+import org.jboss.savara.tools.jbossesb.model.TestESBLanguageModel;
+import org.jboss.savara.tools.jbossesb.model.TestESBService;
+import org.jboss.savara.tools.jbossesb.model.TestModelListener;
+import org.jboss.savara.tools.jbossesb.model.actions.SwitchAction;
+import org.scribble.conversation.model.If;
+import org.scribble.model.Activity;
+
+import junit.framework.TestCase;
+
+public class SwitchActionTest extends TestCase {
+
+	public void testValidatePathsSpecified() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_NOT_SPECIFIED_PROPERTY",
+							new String[]{"paths"}));
+		
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateServiceNotFound() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><case service-category=\"cat1\" " +
+				"service-name=\"name1\" /><case service-category=\"cat2\" " +
+				"service-name=\"name2\" /><case service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat1","name1"}));
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat2","name2"}));
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.jboss.savara.tools.jbossesb.model.Messages"),
+					"_NOT_FOUND_SERVICE_DESCRIPTOR",
+					new String[]{"cat3","name3"}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testValidateLessThanOnePath() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat3");
+		other2.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.actions.Messages"),
+							"_SWITCH_ONE_OR_MORE_PATHS",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testValidateMissingServiceDetails() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><case service-category=\"cat1\" " +
+				"service-name=\"name1\" /><case " +
+				"service-name=\"name2\" /><case service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+		
+		TestModelListener l=new TestModelListener();
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.jboss.savara.tools.jbossesb.model.stateful.actions.Messages"),
+							"_PATH_SERVICE_DETAILS_MISSING",
+							new String[]{}));
+				
+		action.validate(l);
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testConvert() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><case service-category=\"cat1\" " +
+				"service-name=\"name1\" /><case service-category=\"cat2\" " +
+				"service-name=\"name2\" /><case service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestActivity act1=new TestActivity();
+		other1.getContents().add(act1);
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestActivity act2=new TestActivity();
+		other2.getContents().add(act2);
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestActivity act3=new TestActivity();
+		other3.getContents().add(act3);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, null);
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof If) == false) {
+			fail("Expecting an 'If' activity");
+		}
+		
+		If ifAction=(If)act;
+		
+		if (ifAction.getConditionalBlocks().size() != 3) {
+			fail("Expecting three conditional blocks: "+ifAction.getConditionalBlocks().size());
+		}
+		
+		if (ifAction.getConditionalBlocks().get(0).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(0).getContents().get(0) != act1) {
+			fail("First conditional block should have 1 activity = act1");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(1).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(1).getContents().get(0) != act2) {
+			fail("Second conditional block should have 1 activity = act2");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(2).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(2).getContents().get(0) != act3) {
+			fail("Third conditional block should have 1 activity = act3");
+		}
+		
+		if (ifAction.getElseBlock() != null) {
+			fail("Else block should not be defined");
+		}
+	}
+	
+	public void testConvertNotExcludingEmptyPaths() {
+		TestESBService service=new TestESBService();
+
+		java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
+		props.put("paths", "<property><case service-category=\"cat1\" " +
+				"service-name=\"name1\" /><case service-category=\"cat2\" " +
+				"service-name=\"name2\" /><case service-category=\"cat3\" " +
+				"service-name=\"name3\" /></property>");
+		
+		org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, null, props);
+		
+		TestESBService other1=new TestESBService();
+		other1.setCategory("cat1");
+		other1.setName("name1");
+		
+		TestActivity act1=new TestActivity();
+		other1.getContents().add(act1);
+		
+		TestESBService other2=new TestESBService();
+		other2.setCategory("cat2");
+		other2.setName("name2");
+		
+		TestESBService other3=new TestESBService();
+		other3.setCategory("cat3");
+		other3.setName("name3");
+		
+		TestActivity act3=new TestActivity();
+		other3.getContents().add(act3);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		model.addService(other1);
+		model.addService(other2);
+		model.addService(other3);
+		model.addService(service);
+		
+		service.setModel(model);
+		
+		SwitchAction action=new SwitchAction(service, elem);
+		action.initializeLinks();
+		
+		service.getActions().add(action);
+
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		
+		action.convert(activities, null);
+		
+		if (activities.size() != 1) {
+			fail("Expecting one activity, but got: "+activities.size());
+		}
+		
+		Activity act=activities.get(0);
+		
+		if ((act instanceof If) == false) {
+			fail("Expecting an 'If' activity");
+		}
+		
+		If ifAction=(If)act;
+		
+		if (ifAction.getConditionalBlocks().size() != 3) {
+			fail("Expecting three conditional blocks: "+ifAction.getConditionalBlocks().size());
+		}
+		
+		if (ifAction.getConditionalBlocks().get(0).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(0).getContents().get(0) != act1) {
+			fail("First conditional block should have 1 activity = act1");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(1).getContents().size() != 0) {
+			fail("Second conditional block should be empty");
+		}
+		
+		if (ifAction.getConditionalBlocks().get(2).getContents().size() != 1 ||
+				ifAction.getConditionalBlocks().get(2).getContents().get(0) != act3) {
+			fail("Third conditional block should have 1 activity = act3");
+		}
+		
+		if (ifAction.getElseBlock() != null) {
+			fail("Else block should not be defined");
+		}
+	}
+	
+	public void testIsCreateSession() {
+		TestESBService service=new TestESBService();
+		
+		SwitchAction action=new SwitchAction(service, null);
+		
+		if (action.isSessionType() == true) {
+			fail("Action is flagged as a 'CreateSession'");
+		}
+	}
+	
+	public void testIsSessionBased() {
+		TestESBService service=new TestESBService();
+		
+		SwitchAction action=new SwitchAction(service, null);
+		
+		if (action.isSessionBased() == false) {
+			fail("Action is not flagged as a 'SessionBased'");
+		}
+	}
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,1850 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.change.ConversationInteractionModelChangeRule;
+import org.jboss.savara.tools.jbossesb.model.actions.*;
+import org.jboss.savara.tools.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationInteractionModelChangeRuleTest extends TestCase {
+
+	/*
+	public void testInsertFirstReceiveAction() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setToRole(role);
+		conv.getBlock().getContents().add(mobj);
+		
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+		
+		String mtype=InteractionUtil.getTypeString(ref);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		if (mra.getNumberOfCases() != 1) {
+			fail("One route expected: "+mra.getNumberOfCases());
+		}
+	}		
+
+	public void testInsertFirstReceiveAfterCreateSessionAction() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add 'create session' action
+		TestESBAction act=new TestESBAction();
+		act.setCreateSession(true);
+		service.addAction(act, -1);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setToRole(role);
+		conv.getBlock().getContents().add(mobj);
+		
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof TestESBAction) == false) {
+			fail("Action was not TestESBAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
+			fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
+		
+		String mtype=InteractionUtil.getTypeString(ref);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		if (mra.getNumberOfCases() != 1) {
+			fail("One route expected: "+mra.getNumberOfCases());
+		}
+	}		
+
+	public void testInsertSecondReceiveAction() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setToRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		ConversationInteraction mobj2=new ConversationInteraction();
+		mobj2.setToRole(role);
+		conv.getBlock().getContents().add(mobj2);
+		
+		MessageSignature msig2=new MessageSignature();
+		mobj2.setMessageSignature(msig2);
+		
+		TypeReference ref2=new TypeReference();
+		ref2.setNamespace("ns");
+		ref2.setLocalpart("lp2");
+		
+		msig2.getTypes().add(ref2);
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+		
+		if (rule.insert(context, model, mobj2, null) == false) {
+			fail("Failed to insert 2");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		if (newService == null) {
+			fail("Other service not found");
+		}
+		
+		// Check schedule details
+		ScheduleStateAction schedule=(ScheduleStateAction)
+							service.getActions().get(1);
+		
+		if (newService.getCategory().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_CATEGORY)+
+							"' invalid, expecting: "+
+							service.getCategory());
+		}
+
+		if (newService.getName().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME)+
+							"' invalid, expecting: "+
+							service.getName());
+		}
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
+			fail("Schedule should not be immediate");
+		}
+
+		if (newService.getActions().size() != 1) {
+			fail("Expecting 1 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
+		
+		String mtype=InteractionUtil.getTypeString(ref2);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		if (mra.getNumberOfCases() != 2) {
+			fail("Two routes expected: "+mra.getNumberOfCases());
+		}
+	}		
+	
+
+	public void testInsertMiddleReceiveBetweenTwoReceives() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setToRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		ConversationInteraction mobj2=new ConversationInteraction();
+		mobj2.setToRole(role);
+		conv.getBlock().getContents().add(mobj2);
+		
+		MessageSignature msig2=new MessageSignature();
+		mobj2.setMessageSignature(msig2);
+		
+		TypeReference ref2=new TypeReference();
+		ref2.setNamespace("ns");
+		ref2.setLocalpart("lp2");
+		
+		msig2.getTypes().add(ref2);
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+		
+		if (rule.insert(context, model, mobj2, null) == false) {
+			fail("Failed to insert 2");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		if (newService == null) {
+			fail("Other service not found");
+		}
+		
+		((TestESBService)newService).setSessionBased(true);
+		
+		// Check schedule details
+		ScheduleStateAction schedule=(ScheduleStateAction)
+							service.getActions().get(1);
+		
+		if (newService.getCategory().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_CATEGORY)+
+							"' invalid, expecting: "+
+							service.getCategory());
+		}
+
+		if (newService.getName().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME)+
+							"' invalid, expecting: "+
+							service.getName());
+		}
+			
+		// Check actions
+		if (newService.getActions().size() != 1) {
+			fail("Expecting 1 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		ReceiveMessageAction recv2=(ReceiveMessageAction)
+						newService.getActions().get(0);
+		
+
+		String mtype=InteractionUtil.getTypeString(ref2);
+
+		if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+recv2.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		java.util.List<Activity> acts=new java.util.Vector<Activity>();
+		
+		DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+		recv2.convert(acts, convContext);
+		
+		if (acts.size() != 1) {
+			fail("Expecting 1 activity: "+acts.size());
+		}
+		
+		// Now second service identified, add new receive
+		// action to ensure that third service inserted in the
+		// middle
+		ConversationInteraction mobj3=new ConversationInteraction();
+		mobj3.setToRole(role);
+		conv.getBlock().getContents().add(mobj3);
+		
+		MessageSignature msig3=new MessageSignature();
+		mobj3.setMessageSignature(msig3);
+		
+		TypeReference ref3=new TypeReference();
+		ref3.setNamespace("ns");
+		ref3.setLocalpart("lp3");
+		
+		msig3.getTypes().add(ref3);
+		
+		// Insert into position 1, which should be after first
+		// receive
+		
+		// TODO: Need to pass representation of last interaction
+		if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+			fail("Failed to insert 3");
+		}
+		
+		// Re-Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		// TODO: Need to check if new service has been inserted
+		// in the middle of the previously inserted interactions
+
+		// Check actions
+		if (newService.getActions().size() != 2) {
+			fail("Now Expecting 2 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
+		}
+		
+		ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+		
+		ESBService newService2=model.getService(ssa.getPropertyValue(
+					ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME));
+		
+		if (newService2 == null) {
+			fail("Failed to find final service");
+		}
+		
+		if (newService2.getActions().size() != 1) {
+			fail("Only expecting one action: "+newService2.getActions().size());
+		}
+
+		ReceiveMessageAction recv4=(ReceiveMessageAction)
+					newService2.getActions().get(0);
+
+		String mtype4=InteractionUtil.getTypeString(ref2);
+
+		if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+			fail("Message type '"+recv4.getPropertyValue("messageType")+
+						"' invalid, expecting: "+mtype4);
+		}
+
+
+		ReceiveMessageAction recv3=(ReceiveMessageAction)
+					newService.getActions().get(0);
+
+		String mtype3=InteractionUtil.getTypeString(ref3);
+
+		if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+			fail("Message type '"+recv3.getPropertyValue("messageType")+
+						"' invalid, expecting: "+mtype3);
+		}
+	}		
+	
+	public void testInsertMiddleSendBetweenTwoReceives() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setToRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		ConversationInteraction mobj2=new ConversationInteraction();
+		mobj2.setToRole(role);
+		conv.getBlock().getContents().add(mobj2);
+		
+		MessageSignature msig2=new MessageSignature();
+		mobj2.setMessageSignature(msig2);
+		
+		TypeReference ref2=new TypeReference();
+		ref2.setNamespace("ns");
+		ref2.setLocalpart("lp2");
+		
+		msig2.getTypes().add(ref2);
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+		
+		if (rule.insert(context, model, mobj2, null) == false) {
+			fail("Failed to insert 2");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		if (newService == null) {
+			fail("Other service not found");
+		}
+		
+		((TestESBService)newService).setSessionBased(true);
+		
+		// Check schedule details
+		ScheduleStateAction schedule=(ScheduleStateAction)
+							service.getActions().get(1);
+		
+		if (newService.getCategory().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_CATEGORY)+
+							"' invalid, expecting: "+
+							service.getCategory());
+		}
+
+		if (newService.getName().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME)+
+							"' invalid, expecting: "+
+							service.getName());
+		}
+			
+		// Check actions
+		if (newService.getActions().size() != 1) {
+			fail("Expecting 1 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		ReceiveMessageAction recv2=(ReceiveMessageAction)
+						newService.getActions().get(0);
+		
+
+		String mtype=InteractionUtil.getTypeString(ref2);
+
+		if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+recv2.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		java.util.List<Activity> acts=new java.util.Vector<Activity>();
+		
+		DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+		recv2.convert(acts, convContext);
+		
+		if (acts.size() != 1) {
+			fail("Expecting 1 activity: "+acts.size());
+		}
+		
+		// Now second service identified, add new receive
+		// action to ensure that third service inserted in the
+		// middle
+		ConversationInteraction mobj3=new ConversationInteraction();
+		mobj3.setFromRole(role);
+		conv.getBlock().getContents().add(mobj3);
+		
+		MessageSignature msig3=new MessageSignature();
+		mobj3.setMessageSignature(msig3);
+		
+		TypeReference ref3=new TypeReference();
+		ref3.setNamespace("ns");
+		ref3.setLocalpart("lp3");
+		
+		msig3.getTypes().add(ref3);
+		
+		// Insert into position 1, which should be after first
+		// receive
+		
+		// TODO: Need to pass representation of last interaction
+		if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+			fail("Failed to insert 3");
+		}
+		
+		// Re-Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		// TODO: Need to check if new service has been inserted
+		// in the middle of the previously inserted interactions
+
+		// Check actions
+		if (newService.getActions().size() != 2) {
+			fail("Now Expecting 2 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action 1 was not SendMessageAction: "+newService.getActions().get(0));
+		}
+		
+		if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
+		}
+		
+		ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+		
+		ESBService newService2=model.getService(ssa.getPropertyValue(
+					ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME));
+		
+		if (newService2 == null) {
+			fail("Failed to find final service");
+		}
+		
+		if (newService2.getActions().size() != 1) {
+			fail("Only expecting one action: "+newService2.getActions().size());
+		}
+		
+		if ((newService2.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Expecting ReceiveMessageAction, but got: "+newService2.getActions().get(0));
+		}
+
+		ReceiveMessageAction recv4=(ReceiveMessageAction)
+					newService2.getActions().get(0);
+
+		String mtype4=InteractionUtil.getTypeString(ref2);
+
+		if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+			fail("Message type '"+recv4.getPropertyValue("messageType")+
+						"' invalid, expecting: "+mtype4);
+		}
+
+
+		SendMessageAction send3=(SendMessageAction)
+					newService.getActions().get(0);
+
+		String mtype3=InteractionUtil.getTypeString(ref3);
+
+		if (send3.getPropertyValue("messageType").equals(mtype3)==false) {
+			fail("Message type '"+send3.getPropertyValue("messageType")+
+						"' invalid, expecting: "+mtype3);
+		}
+	}		
+
+	public void testInsertMiddleReceiveBetweenTwoSends() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setFromRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		ConversationInteraction mobj2=new ConversationInteraction();
+		mobj2.setFromRole(role);
+		conv.getBlock().getContents().add(mobj2);
+		
+		MessageSignature msig2=new MessageSignature();
+		mobj2.setMessageSignature(msig2);
+		
+		TypeReference ref2=new TypeReference();
+		ref2.setNamespace("ns");
+		ref2.setLocalpart("lp2");
+		
+		msig2.getTypes().add(ref2);
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+		
+		if (rule.insert(context, model, mobj2, null) == false) {
+			fail("Failed to insert 2");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+			fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		SendMessageAction send2=(SendMessageAction)
+						service.getActions().get(1);
+		
+
+		String mtype=InteractionUtil.getTypeString(ref2);
+
+		if (send2.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+send2.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		java.util.List<Activity> acts=new java.util.Vector<Activity>();
+		
+		DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+		send2.convert(acts, convContext);
+		
+		if (acts.size() != 1) {
+			fail("Expecting 1 activity: "+acts.size());
+		}
+		
+		// Now second service identified, add new receive
+		// action to ensure that third service inserted in the
+		// middle
+		ConversationInteraction mobj3=new ConversationInteraction();
+		mobj3.setToRole(role);
+		conv.getBlock().getContents().add(mobj3);
+		
+		MessageSignature msig3=new MessageSignature();
+		mobj3.setMessageSignature(msig3);
+		
+		TypeReference ref3=new TypeReference();
+		ref3.setNamespace("ns");
+		ref3.setLocalpart("lp3");
+		
+		msig3.getTypes().add(ref3);
+		
+		// Insert into position 1, which should be after first
+		// send
+		
+		// TODO: Need to pass representation of last interaction
+		if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+			fail("Failed to insert 3");
+		}
+		
+		// Re-Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		// Check actions
+		if (newService.getActions().size() != 2) {
+			fail("Now Expecting 2 action: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
+			fail("Action 2 was not SendMessageAction: "+newService.getActions().get(1));
+		}
+		
+		ScheduleStateAction schedule=(ScheduleStateAction)
+				service.getActions().get(1);
+
+		if (newService.getCategory().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					schedule.getPropertyValue(
+					ScheduleStateAction.SERVICE_CATEGORY)+
+					"' invalid, expecting: "+
+					service.getCategory());
+		}
+		
+		if (newService.getName().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					schedule.getPropertyValue(
+					ScheduleStateAction.SERVICE_NAME)+
+					"' invalid, expecting: "+
+					service.getName());
+		}
+
+		ReceiveMessageAction recv3=(ReceiveMessageAction)
+					newService.getActions().get(0);
+
+		String mtype3=InteractionUtil.getTypeString(ref3);
+
+		if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+			fail("Message type '"+recv3.getPropertyValue("messageType")+
+						"' invalid, expecting: "+mtype3);
+		}
+	}		
+
+	public void testInsertReceiveRequestAction() {
+		String fromRoleName="role1";
+		String toRoleName="role2";
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role fromRole=new Role();
+		fromRole.setName(fromRoleName);
+		
+		Role toRole=new Role();
+		toRole.setName(toRoleName);
+		
+		context.setRole(toRole);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(toRole);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setFromRole(fromRole);
+		mobj.setToRole(toRole);
+		conv.getBlock().getContents().add(mobj);
+		
+		mobj.setRequestLabel("reqLabel");
+		
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+		
+		if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) == false) {
+			fail("Client EPR '"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
+					"' invalid, expecting: "+fromRoleName);
+		}
+	}		
+
+	public void testInsertFirstSendAction() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setFromRole(role);
+		conv.getBlock().getContents().add(mobj);
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+		
+		String mtype=InteractionUtil.getTypeString(ref);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+	}		
+	
+	public void testInsertSendRequestAction() {
+		String roleName="role1";
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName(roleName);
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setFromRole(role);
+		conv.getBlock().getContents().add(mobj);
+		
+		mobj.setRequestLabel("reqLabel");
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two service expected: "+model.getServices().size());
+		}
+		
+		SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		if (newService == null) {
+			fail("Other service not found");
+		}
+		
+		if (newService.getCategory().equals(action.getPropertyValue(
+				SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					action.getPropertyValue(
+							SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
+							"' invalid, expecting: "+
+							newService.getCategory());
+		}
+
+		if (newService.getName().equals(action.getPropertyValue(
+				SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					action.getPropertyValue(
+							SendMessageAction.RESPONSE_SERVICE_NAME)+
+							"' invalid, expecting: "+
+							newService.getName());
+		}
+	}		
+	
+	public void testInsertSendNotReplyAction() {
+		String fromRoleName="role1";
+		String toRoleName="role2";
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role fromRole=new Role();
+		fromRole.setName(fromRoleName);
+		
+		Role toRole=new Role();
+		toRole.setName(toRoleName);
+		
+		context.setRole(fromRole);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(fromRole);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setFromRole(fromRole);
+		mobj.setToRole(toRole);
+		conv.getBlock().getContents().add(mobj);
+		
+		mobj.setRequestLabel("reqLabel");
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two service expected: "+model.getServices().size());
+		}
+		
+		SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+		
+		if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
+						equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
+			fail("Service category expression '"+
+					action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
+					"' invalid, expecting: "+
+					InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
+		}
+		
+		if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
+						equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
+			fail("Service name expression '"+
+					action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
+					"' invalid, expecting: "+
+					InteractionUtil.getRoleServiceNameProperty(toRoleName));
+		}
+	}		
+	
+	public void testInsertSendReplyAction() {
+		String fromRoleName="role1";
+		String toRoleName="role2";
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role fromRole=new Role();
+		fromRole.setName(fromRoleName);
+		
+		Role toRole=new Role();
+		toRole.setName(toRoleName);
+		
+		context.setRole(fromRole);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(fromRole);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setFromRole(fromRole);
+		mobj.setToRole(toRole);
+		conv.getBlock().getContents().add(mobj);
+		
+		mobj.setReplyToLabel("replyLabel");
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp");
+		
+		msig.getTypes().add(ref);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+			fail("Action was not SendMessageAction: "+service.getActions().get(0));
+		}
+		
+		SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+		if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false) {
+			fail("Client EPR '"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
+					"' invalid, expecting: "+toRoleName);
+		}
+	}		
+	
+	public void testChangeFirstReceiveAction() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj=new ConversationInteraction();
+		mobj.setToRole(role);
+		conv.getBlock().getContents().add(mobj);
+		
+		
+		MessageSignature msig=new MessageSignature();
+		mobj.setMessageSignature(msig);
+		
+		TypeReference ref=new TypeReference();
+		ref.setNamespace("ns");
+		ref.setLocalpart("lp1");
+		
+		msig.getTypes().add(ref);
+		
+		// Create ReceiveMessageAction
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+		
+		ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+		
+		java.util.List<Activity> activities=new java.util.Vector<Activity>();
+		action.convert(activities, new DefaultConversionContext(null));
+		
+		if (activities.size() != 1) {
+			fail("Expecting single interaction activity from ReceiveMessageAction: "+activities.size());
+		}
+		
+		if ((activities.get(0) instanceof ConversationInteraction) == false) {
+			fail("Not conversation interaction");
+		}
+		
+		ConversationInteraction recvci=(ConversationInteraction)activities.get(0);		
+		
+		String mtype=InteractionUtil.getTypeString(ref);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		// Change local part
+		ref.setLocalpart("lp2");
+		
+		if (rule.update(context, model, mobj, recvci) == false) {
+			fail("Failed to update");
+		}
+
+		// Re-check the message type, to make sure has been updated
+		mtype = InteractionUtil.getTypeString(ref);
+
+		if (action.getPropertyValue("messageType").equals(mtype)==false) {
+			fail("Message type '"+action.getPropertyValue("messageType")+
+					"' invalid, expecting: "+mtype);
+		}
+		
+		if (mra.getNumberOfCases() != 1) {
+			fail("One route expected: "+mra.getNumberOfCases());
+		}
+		
+		org.w3c.dom.Element route=mra.getRouteElement(0);
+		
+		org.w3c.dom.NodeList mesgs=route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
+		
+		if (mesgs.getLength() != 1) {
+			fail("Too many route message elements: "+mesgs.getLength());
+		}
+		
+		org.w3c.dom.Element mesg=(org.w3c.dom.Element)mesgs.item(0);
+		
+		if (mesg.getAttribute(SwitchAction.TYPE_ATTR).equals(mtype) == false) {
+			fail("Route message type has not been updated");
+		}
+	}		
+	
+	public void testDeleteMiddleReceiveBetweenTwoActions() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		act1.setInitiator(true);
+		act1.setSessionBased(true);
+		service.addAction(act1, -1);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setToRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+
+		TestESBAction act2=new TestESBAction();
+		((ESBService)context.getParent()).addAction(act2, -1);
+			
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		ESBService newService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		while (newService == null && iter.hasNext()) {
+			ESBService s=iter.next();
+			
+			if (s != service) {
+				newService = s;
+			}
+		}
+		
+		if (newService == null) {
+			fail("Other service not found");
+		}
+		
+		((TestESBService)newService).setSessionBased(true);
+		
+		// Check schedule details
+		ScheduleStateAction schedule=(ScheduleStateAction)
+							service.getActions().get(1);
+		
+		if (newService.getCategory().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+			fail("Schedule service category '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_CATEGORY)+
+							"' invalid, expecting: "+
+							service.getCategory());
+		}
+
+		if (newService.getName().equals(schedule.getPropertyValue(
+				ScheduleStateAction.SERVICE_NAME)) == false) {
+			fail("Schedule service name '"+
+					schedule.getPropertyValue(
+							ScheduleStateAction.SERVICE_NAME)+
+							"' invalid, expecting: "+
+							service.getName());
+		}
+			
+		// Check actions
+		if (newService.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+newService.getActions().size());
+		}
+		
+		if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+			fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+		}
+		
+		if (newService.getActions().get(1) != act2) {
+			fail("Action 2 was not 2nd test ESB action: "+newService.getActions().get(1));
+		}
+		
+		ReceiveMessageAction recv=(ReceiveMessageAction)
+						newService.getActions().get(0);
+		
+
+		java.util.List<Activity> acts=new java.util.Vector<Activity>();
+		
+		DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+		recv.convert(acts, convContext);
+		
+		if (acts.size() != 1) {
+			fail("Expecting 1 activity: "+acts.size());
+		}
+		
+		// TODO: Need to pass representation of last interaction
+		if (rule.delete(context, model, acts.get(0)) == false) {
+			fail("Failed to delete receive");
+		}
+		
+		// Re-Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		if (model.getServices().size() != 2) {
+			fail("Two services expected: "+model.getServices().size());
+		}
+		
+		// TODO: Need to check if new service has been inserted
+		// in the middle of the previously inserted interactions
+
+		// Check actions
+		if (newService.getActions().size() != 1) {
+			fail("Now Expecting 1 action: "+newService.getActions().size());
+		}
+		
+		if (newService.getActions().get(0) != act2) {
+			fail("Action 1 was not 2nd test ESB action: "+newService.getActions().get(0));
+		}
+	}		
+	
+	public void testDeleteMiddleSendBetweenTwoActions() {
+		ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		act1.setInitiator(true);
+		act1.setSessionBased(true);
+		service.addAction(act1, -1);
+		
+		// Add gateway service
+		TestESBService gwservice=(TestESBService)
+			model.createService("testcategory", "gateway");
+		gwservice.setGateway(true);
+		
+		SwitchAction mra=new SwitchAction(gwservice);
+		gwservice.setGatewayAction(mra);
+		
+		model.setGatewayService(gwservice);
+		
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		Conversation conv=new Conversation();
+		LocatedName mname=new LocatedName();
+		mname.setRole(role);
+		conv.setLocatedName(mname);
+		
+		ConversationInteraction mobj1=new ConversationInteraction();
+		mobj1.setFromRole(role);
+		conv.getBlock().getContents().add(mobj1);
+		
+		MessageSignature msig1=new MessageSignature();
+		mobj1.setMessageSignature(msig1);
+		
+		TypeReference ref1=new TypeReference();
+		ref1.setNamespace("ns");
+		ref1.setLocalpart("lp1");
+		
+		msig1.getTypes().add(ref1);
+		
+		if (rule.insert(context, model, mobj1, null) == false) {
+			fail("Failed to insert 1");
+		}
+		
+		// Once first interaction associated with service it
+		// will become session based
+		service.setSessionBased(true);
+
+		TestESBAction act2=new TestESBAction();
+		((ESBService)context.getParent()).addAction(act2, -1);
+			
+		// Check actions
+		if (service.getActions().size() != 3) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+		}
+		
+		if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+			fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+		}
+		
+		if (service.getActions().get(2) != act2) {
+			fail("Action 3 was not 2nd test ESB action: "+service.getActions().get(2));
+		}
+		
+		if (model.getServices().size() != 1) {
+			fail("One service expected: "+model.getServices().size());
+		}
+					
+		
+		SendMessageAction send=(SendMessageAction)
+						service.getActions().get(1);
+		
+		java.util.List<Activity> acts=new java.util.Vector<Activity>();
+		
+		DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+		send.convert(acts, convContext);
+		
+		if (acts.size() != 1) {
+			fail("Expecting 1 activity: "+acts.size());
+		}
+		
+		// TODO: Need to pass representation of last interaction
+		if (rule.delete(context, model, acts.get(0)) == false) {
+			fail("Failed to delete send");
+		}
+		
+		// Re-Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+		}
+		
+		if (service.getActions().get(1) != act2) {
+			fail("Action 2 was not 2nd test ESB action: "+service.getActions().get(1));
+		}
+	}		
+	
+	*/
+}

Copied: cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRuleTest.java (from rev 784, cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/stateful/IfModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRuleTest.java	                        (rev 0)
+++ cdl/trunk/tools/eclipse/plugins/org.jboss.savara.tools.jbossesb/src/test/org/jboss/savara/tools/jbossesb/model/change/IfModelChangeRuleTest.java	2009-08-21 21:09:21 UTC (rev 794)
@@ -0,0 +1,1071 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.savara.tools.jbossesb.model.change;
+
+import junit.framework.TestCase;
+
+import org.jboss.savara.tools.jbossesb.model.*;
+import org.jboss.savara.tools.jbossesb.model.change.IfModelChangeRule;
+import org.jboss.savara.tools.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class IfModelChangeRuleTest extends TestCase {
+
+	public void testInsertIfAction() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		If mobj=new If();
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		mobj.getRoles().add(role);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof IfAction) == false) {
+			fail("Action was not IfAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		ESBService ifService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while (ifService == null && iter.hasNext()) {
+			ifService = iter.next();
+			if (ifService == service) {
+				ifService = null;
+			}
+		}
+		
+		IfAction action=(IfAction)service.getActions().get(0);
+		
+		org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+		
+		if (paths.getLength() != 1) {
+			fail("Only one path child expected: "+paths.getLength());
+		}
+		
+		org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+		
+		if (elem.getNodeName().equals("if") == false) {
+			fail("If expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+ifService.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+ifService.getName());
+		}
+	}
+
+	public void testInsertIfActionWithSubsequentActions() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		service.addAction(act1, -1);
+		
+		ModelObject ref=new ModelObject() {};
+		ref.getSource().setObject(act1);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		If mobj=new If();
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		mobj.getRoles().add(role);
+		
+		if (rule.insert(context, model, mobj, ref) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof IfAction) == false) {
+			fail("Action was not IfAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		ESBService ifService=null;
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((ifService == null || join == null) && iter.hasNext()) {
+			ESBService s = iter.next();
+			if (s != service) {
+				if (ifService == null) {
+					ifService = s;
+				} else if (join == null) {
+					join = s;
+				}
+			}
+		}
+		
+		if (join.getActions().size() != 1) {
+			fail("Join service does not have 1 action: "+join.getActions().size());
+		}
+		
+		if (join.getActions().get(0) != act1) {
+			fail("Join action is not test ESB action");
+		}
+	}
+
+	public void testInsertIfActionWithPrecedingActions() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		service.addAction(act1, -1);
+		
+		TestESBAction act2=new TestESBAction();
+		service.addAction(act2, -1);
+		
+		ModelObject ref=new ModelObject() {};
+		ref.getSource().setObject(act2);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		If mobj=new If();
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		mobj.getRoles().add(role);
+		
+		if (rule.insert(context, model, mobj, ref) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 actions: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("Action 1 was not test ESB action");
+		}
+		
+		if ((service.getActions().get(1) instanceof IfAction) == false) {
+			fail("Action 2 was not IfAction: "+service.getActions().get(1));
+		}
+
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		ESBService ifService=null;
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((ifService == null || join == null) && iter.hasNext()) {
+			ESBService s = iter.next();
+			if (s != service) {
+				if (ifService == null) {
+					ifService = s;
+				} else if (join == null) {
+					join = s;
+				}
+			}
+		}
+		
+		if (join.getActions().size() != 1) {
+			fail("Join service does not have 1 action: "+join.getActions().size());
+		}
+		
+		if (join.getActions().get(0) != act2) {
+			fail("Join action is not test ESB action");
+		}
+	}
+
+/*
+	public void testInsertIfElseIfAction() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		If mobj=new If();
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		ConditionalBlock cb2=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb2);
+		
+		ConditionalBlock cb3=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb3);
+		
+		mobj.getRoles().add(role);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof IfAction) == false) {
+			fail("Action was not IfAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 5) {
+			fail("Five services expected: "+model.getServices().size());
+		}
+		
+		ESBService ifService=null;
+		ESBService elseIfService1=null;
+		ESBService elseIfService2=null;
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((ifService == null || elseIfService1 == null ||
+					elseIfService2 == null || join==null) && iter.hasNext()) {
+			ESBService serv = iter.next();
+			if (serv.getName().endsWith("__0")) {
+				join = serv;
+			}
+			if (serv.getName().endsWith("__1")) {
+				ifService = serv;
+			}
+			if (serv.getName().endsWith("__2")) {
+				elseIfService1 = serv;
+			}
+			if (serv.getName().endsWith("__3")) {
+				elseIfService2 = serv;
+			}
+		}
+		
+		IfAction action=(IfAction)service.getActions().get(0);
+		
+		org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+		
+		if (paths.getLength() != 3) {
+			fail("Three path children expected: "+paths.getLength());
+		}
+		
+		org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+		
+		if (elem.getNodeName().equals("if") == false) {
+			fail("If expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+ifService.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+ifService.getName());
+		}
+		
+		if (ifService.getActions().size() != 1) {
+			fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+		}
+		
+		if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+ifService.getActions().get(0));
+		}
+		
+		ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+		elem=(org.w3c.dom.Element)paths.item(1);
+		
+		if (elem.getNodeName().equals("elseif") == false) {
+			fail("ElseIf expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(elseIfService1.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+elseIfService1.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(elseIfService1.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+elseIfService1.getName());
+		}
+		
+		if (elseIfService1.getActions().size() != 1) {
+			fail("Path(2) does not have 1 action: "+elseIfService1.getActions().size());
+		}
+		
+		if ((elseIfService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+elseIfService1.getActions().get(0));
+		}
+		
+		schedule=(ScheduleStateAction)elseIfService1.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+		elem=(org.w3c.dom.Element)paths.item(2);
+		
+		if (elem.getNodeName().equals("elseif") == false) {
+			fail("ElseIf(2) expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(elseIfService2.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+elseIfService2.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(elseIfService2.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+elseIfService2.getName());
+		}
+		
+		if (elseIfService2.getActions().size() != 1) {
+			fail("Path(3) does not have 1 action: "+elseIfService2.getActions().size());
+		}
+		
+		if ((elseIfService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+elseIfService2.getActions().get(0));
+		}
+		
+		schedule=(ScheduleStateAction)elseIfService2.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+	}
+
+	public void testInsertIfElseAction() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role=new Role();
+		role.setName("role1");
+		
+		context.setRole(role);
+		
+		If mobj=new If();
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		Block b1=new Block();
+		mobj.setElseBlock(b1);
+		
+		mobj.getRoles().add(role);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof IfAction) == false) {
+			fail("Action was not IfAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 4) {
+			fail("Four services expected: "+model.getServices().size());
+		}
+		
+		ESBService ifService=null;
+		ESBService elseService=null;
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((ifService == null || elseService == null ||
+				join == null) && iter.hasNext()) {
+			ESBService serv = iter.next();
+			if (serv.getName().endsWith("__0")) {
+				join = serv;
+			}
+			if (serv.getName().endsWith("__1")) {
+				ifService = serv;
+			}
+			if (serv.getName().endsWith("__2")) {
+				elseService = serv;
+			}
+		}
+		
+		IfAction action=(IfAction)service.getActions().get(0);
+		
+		org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+		
+		if (paths.getLength() != 2) {
+			fail("Three path children expected: "+paths.getLength());
+		}
+		
+		org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+		
+		if (elem.getNodeName().equals("if") == false) {
+			fail("If expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+ifService.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+ifService.getName());
+		}
+		
+		if (ifService.getActions().size() != 1) {
+			fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+		}
+		
+		if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+ifService.getActions().get(0));
+		}
+		
+		ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+		elem=(org.w3c.dom.Element)paths.item(1);
+		
+		if (elem.getNodeName().equals("else") == false) {
+			fail("Else expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(elseService.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+elseService.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(elseService.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+elseService.getName());
+		}
+		
+		if (elseService.getActions().size() != 1) {
+			fail("Path(2) does not have 1 action: "+elseService.getActions().size());
+		}
+		
+		if ((elseService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+elseService.getActions().get(0));
+		}
+		
+		schedule=(ScheduleStateAction)ifService.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+	}
+
+	public void testInsertSwitchAction() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		org.scribble.extensions.TestSingleExtensionRegistry reg=
+			new org.scribble.extensions.TestSingleExtensionRegistry(null);
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role1=new Role();
+		role1.setName("role1");
+		
+		Role role2=new Role();
+		role2.setName("role2");
+		
+		context.setRole(role1);
+		
+		If mobj=new If();
+		
+		mobj.getRoles().add(role2);
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+			fail("Action was not SwitchAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		ESBService switchService=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while (switchService == null && iter.hasNext()) {
+			switchService = iter.next();
+			if (switchService == service) {
+				switchService = null;
+			}
+		}
+		
+		SwitchAction action=(SwitchAction)service.getActions().get(0);
+		
+		org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+		
+		if (paths.getLength() != 1) {
+			fail("Only one path child expected: "+paths.getLength());
+		}
+		
+		org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+		
+		if (elem.getNodeName().equals("case") == false) {
+			fail("Switch expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+switchService.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+switchService.getName());
+		}
+	}
+
+	public void testInsertSwitchMultipleCaseAction() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		org.scribble.extensions.TestSingleExtensionRegistry reg=
+			new org.scribble.extensions.TestSingleExtensionRegistry(null);
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role1=new Role();
+		role1.setName("role1");
+		
+		Role role2=new Role();
+		role2.setName("role2");
+		
+		context.setRole(role1);
+		
+		If mobj=new If();
+		
+		mobj.getRoles().add(role2);
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		ConditionalBlock cb2=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb2);
+		
+		Block b1=new Block();
+		mobj.setElseBlock(b1);
+		
+		if (rule.insert(context, model, mobj, null) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+			fail("Action was not SwitchAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 5) {
+			fail("Five services expected: "+model.getServices().size());
+		}
+		
+		ESBService join=null;
+		ESBService caseService1=null;
+		ESBService caseService2=null;
+		ESBService caseService3=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((caseService1 == null || caseService2 == null ||
+				caseService3 == null || join == null) && iter.hasNext()) {
+			ESBService serv = iter.next();
+			if (serv.getName().endsWith("__0")) {
+				join = serv;
+			}
+			if (serv.getName().endsWith("__1")) {
+				caseService1 = serv;
+			}
+			if (serv.getName().endsWith("__2")) {
+				caseService2 = serv;
+			}
+			if (serv.getName().endsWith("__3")) {
+				caseService3 = serv;
+			}
+		}
+		
+		SwitchAction action=(SwitchAction)service.getActions().get(0);
+		
+		org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+		
+		if (paths.getLength() != 3) {
+			fail("Three path children expected: "+paths.getLength());
+		}
+		
+		org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+		
+		if (elem.getNodeName().equals("case") == false) {
+			fail("If expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+caseService1.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+caseService1.getName());
+		}
+		
+		if (caseService1.getActions().size() != 1) {
+			fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
+		}
+		
+		if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+caseService1.getActions().get(0));
+		}
+		
+		ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+		elem=(org.w3c.dom.Element)paths.item(1);
+		
+		if (elem.getNodeName().equals("case") == false) {
+			fail("Else expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+caseService2.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+caseService2.getName());
+		}
+		
+		if (caseService2.getActions().size() != 1) {
+			fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
+		}
+		
+		if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+caseService2.getActions().get(0));
+		}
+		
+		schedule=(ScheduleStateAction)caseService2.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+
+		elem=(org.w3c.dom.Element)paths.item(2);
+		
+		if (elem.getNodeName().equals("case") == false) {
+			fail("Else expected but got: "+elem.getNodeName());
+		}
+		
+		if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
+			fail("Service category '"+elem.getAttribute("service-category")+
+					"' not expected: "+caseService3.getCategory());
+		}
+		
+		if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
+			fail("Service name '"+elem.getAttribute("service-name")+
+					"' not expected: "+caseService3.getName());
+		}
+		
+		if (caseService3.getActions().size() != 1) {
+			fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
+		}
+		
+		if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+			fail("Action not schedule state: "+caseService3.getActions().get(0));
+		}
+		
+		schedule=(ScheduleStateAction)caseService3.getActions().get(0);
+		
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+				equals(join.getCategory()) == false) {
+			fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+		}
+	
+		if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+				equals(join.getName()) == false) {
+			fail("Schedule name is not join '"+join.getName()+"': "+
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+		}
+	}
+
+	public void testInsertSwitchActionWithSubsequentActions() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		org.scribble.extensions.TestSingleExtensionRegistry reg=
+			new org.scribble.extensions.TestSingleExtensionRegistry(null);
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		service.addAction(act1, -1);
+		
+		ModelObject ref=new ModelObject() {};
+		ref.getSource().setObject(act1);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role1=new Role();
+		role1.setName("role1");
+		
+		Role role2=new Role();
+		role2.setName("role2");
+		
+		context.setRole(role1);
+		
+		If mobj=new If();
+		
+		mobj.getRoles().add(role2);
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		if (rule.insert(context, model, mobj, ref) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+			fail("Action was not SwitchAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 3) {
+			fail("Three services expected: "+model.getServices().size());
+		}
+		
+		ESBService switchService=null;
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while ((switchService == null || join == null) && iter.hasNext()) {
+			ESBService s = iter.next();
+			if (s != service) {
+				if (switchService == null) {
+					switchService = s;
+				} else if (join == null) {
+					join = s;
+				}
+			}
+		}
+		
+		if (join.getActions().size() != 1) {
+			fail("Join service does not have 1 action: "+join.getActions().size());
+		}
+		
+		if (join.getActions().get(0) != act1) {
+			fail("Join action is not test ESB action");
+		}
+	}
+	
+	public void testInsertSwitchActionWithPrecedingActions() {
+		IfModelChangeRule rule=new IfModelChangeRule();
+		
+		org.scribble.extensions.TestSingleExtensionRegistry reg=
+			new org.scribble.extensions.TestSingleExtensionRegistry(null);
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+		
+		TestESBLanguageModel model=new TestESBLanguageModel();
+		
+		TestESBService service=(TestESBService)
+			model.createService("testcategory", "testname");
+		
+		model.addService(service);
+		
+		TestESBAction act1=new TestESBAction();
+		act1.setInitiator(true);
+		act1.setSessionBased(true);
+		service.addAction(act1, -1);
+		
+		TestESBAction act2=new TestESBAction();
+		service.addAction(act2, -1);
+		
+		ModelObject ref=new ModelObject() {};
+		ref.getSource().setObject(act2);
+		
+		TestModelChangeContext context=new TestModelChangeContext();
+		context.setParent(service);
+		
+		Role role1=new Role();
+		role1.setName("role1");
+		
+		Role role2=new Role();
+		role2.setName("role2");
+		
+		context.setRole(role1);
+		
+		If mobj=new If();
+		
+		mobj.getRoles().add(role2);
+		
+		ConditionalBlock cb1=new ConditionalBlock();
+		mobj.getConditionalBlocks().add(cb1);
+		
+		if (rule.insert(context, model, mobj, ref) == false) {
+			fail("Failed to insert");
+		}
+		
+		// Check actions
+		if (service.getActions().size() != 2) {
+			fail("Expecting 2 action: "+service.getActions().size());
+		}
+		
+		if (service.getActions().get(0) != act1) {
+			fail("First action not test ESB action");
+		}
+		
+		if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+			fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+		}
+		
+		ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+		
+		ESBService addedService=model.getService(
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+				schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+		if (addedService == null) {
+			fail("Failed to find service '"+
+					schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
+					schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+		}
+		
+		if (addedService.getActions().size() != 1) {
+			fail("Expecting 1 action: "+service.getActions().size());
+		}
+		
+		if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+			fail("Action was not SwitchAction: "+service.getActions().get(0));
+		}
+		
+		if (model.getServices().size() != 4) {
+			fail("Four services expected: "+model.getServices().size());
+		}
+		
+		ESBService join=null;
+		java.util.Iterator<ESBService> iter=model.getServices().iterator();
+		
+		while (join == null && iter.hasNext()) {
+			ESBService serv = iter.next();
+			if (serv.getName().endsWith("__0")) {
+				join = serv;
+			}
+		}
+		
+		if (join.getActions().size() != 1) {
+			fail("Join service does not have 1 action: "+join.getActions().size());
+		}
+		
+		if (join.getActions().get(0) != act2) {
+			fail("Join action is not test ESB action");
+		}
+	}
+*/
+}



More information about the overlord-commits mailing list