[savara-commits] savara SVN: r566 - in branches/experimental/2.0.x: bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change and 15 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jan 12 08:42:48 EST 2011


Author: objectiser
Date: 2011-01-12 08:42:44 -0500 (Wed, 12 Jan 2011)
New Revision: 566

Added:
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/rules/
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtilTest.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/cdm/ESBBroker.cdm
Modified:
   branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/generator/GeneratorTest.java
   branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/parser/ParserTest.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/ProtocolToBPELModelGenerator.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELProtocolParser.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ConversionContext.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/DefaultConversionContext.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/InvokeParserRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/PickParserRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReceiveParserRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReplyParserRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELInteractionUtil.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/AbstractModelChangeContext.java
   branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/ModelChangeContext.java
   branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGenerator.java
   branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/ContractGeneratorImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/CDMProtocolParser.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolModelConverterRuleImpl.java
   branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
Log:
Update to use changes in the scribble apis primarily related to 'run' parameters and protocol parameter definitions, and passing in a context to enable external resources to be located.

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/ProtocolToBPELModelGenerator.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/ProtocolToBPELModelGenerator.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/ProtocolToBPELModelGenerator.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -24,6 +24,7 @@
 import org.savara.bpel.model.change.BPELModelChangeContext;
 import org.savara.common.model.generator.ModelGenerator;
 import org.scribble.common.resource.ResourceLocator;
+import org.scribble.common.logging.CachedJournal;
 import org.scribble.common.logging.Journal;
 import org.scribble.protocol.ProtocolDefinitions;
 import org.scribble.protocol.model.*;
@@ -41,7 +42,7 @@
 
 	public Object generate(Object source, Journal journal, ResourceLocator locator) {
 		BPELModelChangeContext context=
-			new BPELModelChangeContext();
+			new BPELModelChangeContext(null, new CachedJournal());
 		ProtocolModel pm=(ProtocolModel)source;
 		
 		// Create BPEL model

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -21,6 +21,8 @@
 
 import org.savara.common.model.change.AbstractModelChangeContext;
 import org.savara.common.model.change.ModelChangeRule;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 
 /**
  * This class provides a default implementation for the model
@@ -42,9 +44,11 @@
 	/**
 	 * This is the constructor for the model change context.
 	 * 
-	 * @param role The role associated with the model
+	 * @param context The protocol context
+	 * @param journal The journal
 	 */
-	public BPELModelChangeContext() {
+	public BPELModelChangeContext(ProtocolContext context, Journal journal) {
+		super(context, journal);
 	}
 	
 	/**

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -19,7 +19,9 @@
 
 import org.savara.common.model.change.ModelChangeContext;
 import org.savara.contract.model.Contract;
+import org.scribble.common.logging.Journal;
 import org.scribble.protocol.model.*;
+import org.scribble.protocol.util.ProtocolModelUtil;
 
 /**
  * Model change utilities.
@@ -173,7 +175,7 @@
 	 */
 	@SuppressWarnings("unchecked")
 	public static void pushRoleContractMapping(ModelChangeContext context,
-							Run run) {
+							Run run, Journal journal) {
 
 		if (context.getProperties().containsKey(Contract.class.getName())) {
 			java.util.Map<String,Contract> contracts=
@@ -189,16 +191,50 @@
 				}
 			}
 		
-			/* TODO: NEED TO CONSIDER HOW ROLES/CONTRACTS WILL BE BOUND USING
-			 * POSITIONAL INFO.
-			 */
-			for (Parameter p : run.getParameters()) {
-				Contract c=contracts.remove(p.getName());
+			// Store protocol against mapped role
+			Protocol defn=run.getProtocol();
+			
+			if (defn == null) {
+				// Check if protocol import defined for protocol
+				ProtocolImport pi=ProtocolModelUtil.getProtocolImport(run.getModel(),
+								run.getProtocolReference());
 				
-				if (c != null) {
-					contracts.put(p.getBoundName(), c);
+				if (pi == null) {
+					journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+								"' not found within model or in import statements", run.getProperties());
+				} else {
+					ProtocolModel pm=context.getProtocolContext().getProtocolModel(pi, journal);
+					
+					if (pm != null) {
+						defn = pm.getProtocol();
+					} else {
+						journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+								"' could not be loaded from location '"+pi.getLocation()+"'",
+								run.getProperties());
+					}
 				}
 			}
+
+			if (defn != null) {
+				
+				if (defn.getParameterDefinitions().size() ==
+							run.getParameters().size()) {
+					for (int i=0; i < run.getParameters().size(); i++) {
+						Parameter p=run.getParameters().get(i);
+						ParameterDefinition pd=defn.getParameterDefinitions().get(i);
+						
+						Contract c=contracts.remove(p.getName());
+						
+						if (c != null) {
+							contracts.put(pd.getName(), c);
+						}
+					}
+				} else {
+					journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+							"' is expecting a different number of parameters",
+							run.getProperties());
+				}
+			}
 		}
 	}
 
@@ -211,7 +247,7 @@
 	 */
 	@SuppressWarnings("unchecked")
 	public static void popRoleContractMapping(ModelChangeContext context,
-									Run run) {
+									Run run, Journal journal) {
 
 		if (context.getProperties().containsKey(Contract.class.getName())) {
 			java.util.Map<String,Contract> contracts=
@@ -227,16 +263,50 @@
 				}
 			}
 			
-			/* TODO: NEED TO CONSIDER HOW ROLES/CONTRACTS WILL BE BOUND USING
-			 * POSITIONAL INFO.
-			 */
-			for (Parameter db : run.getParameters()) {
-				Contract c=contracts.remove(db.getBoundName());
+			// Store protocol against mapped role
+			Protocol defn=run.getProtocol();
+			
+			if (defn == null) {
+				// Check if protocol import defined for protocol
+				ProtocolImport pi=ProtocolModelUtil.getProtocolImport(run.getModel(),
+								run.getProtocolReference());
 				
-				if (c != null) {
-					contracts.put(db.getName(), c);
+				if (pi == null) {
+					journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+								"' not found within model or in import statements", run.getProperties());
+				} else {
+					ProtocolModel pm=context.getProtocolContext().getProtocolModel(pi, journal);
+					
+					if (pm != null) {
+						defn = pm.getProtocol();
+					} else {
+						journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+								"' could not be loaded from location '"+pi.getLocation()+"'",
+								run.getProperties());
+					}
 				}
 			}
+
+			if (defn != null) {
+				
+				if (defn.getParameterDefinitions().size() ==
+							run.getParameters().size()) {
+					for (int i=0; i < run.getParameters().size(); i++) {
+						Parameter p=run.getParameters().get(i);
+						ParameterDefinition pd=defn.getParameterDefinitions().get(i);
+						
+						Contract c=contracts.remove(pd.getName());
+						
+						if (c != null) {
+							contracts.put(p.getName(), c);
+						}
+					}
+				} else {
+					journal.error("Referenced protocol '"+run.getProtocolReference().getName()+
+							"' is expecting a different number of parameters",
+							run.getProperties());
+				}
+			}
 		}
 	}
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -86,7 +86,7 @@
 		if (elem.getProtocol() != null) {
 			
 			// Push details related to sub-choreo
-			ModelChangeUtils.pushRoleContractMapping(context, elem);
+			ModelChangeUtils.pushRoleContractMapping(context, elem, context.getJournal());
 			
 			ModelChangeUtils.addContracts(context, elem.getProtocol(), false);
 			
@@ -116,9 +116,7 @@
 			context.setParent(seq);
 			
 			for (int i=0; i < acts.size(); i++) {
-				//if ((acts.get(i) instanceof Definition) == false) {
-					context.insert(model, acts.get(i), null);
-				//}
+				context.insert(model, acts.get(i), null);
 			}
 			
 			// Reset old parent
@@ -127,7 +125,7 @@
 			// Pop details related to sub-choreo
 			ModelChangeUtils.removeContracts(context, elem.getProtocol(), false);
 			
-			ModelChangeUtils.popRoleContractMapping(context, elem);
+			ModelChangeUtils.popRoleContractMapping(context, elem, context.getJournal());
 		}
 		
 		return(true);

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELProtocolParser.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELProtocolParser.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELProtocolParser.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -24,8 +24,8 @@
 import org.savara.bpel.model.TProcess;
 import org.savara.bpel.parser.rules.DefaultConversionContext;
 import org.savara.bpel.util.BPELModelUtil;
-import org.scribble.common.resource.ResourceLocator;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.*;
 import org.scribble.protocol.parser.ProtocolParser;
 
@@ -39,7 +39,7 @@
 		return(sourceType.equals(BPELDefinitions.BPEL_TYPE));
 	}
 
-	public ProtocolModel parse(java.io.InputStream is, Journal journal, ResourceLocator locator)
+	public ProtocolModel parse(java.io.InputStream is, Journal journal, ProtocolContext context)
 									throws java.io.IOException {
 		ProtocolModel ret=new ProtocolModel();
 		
@@ -72,9 +72,9 @@
 		}
 		
 		// Convert the process contents
-		DefaultConversionContext context=new DefaultConversionContext(role, process, locator);
+		DefaultConversionContext convContext=new DefaultConversionContext(role, process, context);
 		
-		context.convert(process, protocol.getBlock().getContents(), journal);
+		convContext.convert(process, protocol.getBlock().getContents(), journal);
 		
 		return(ret);
 	}

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ConversionContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ConversionContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ConversionContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -21,7 +21,7 @@
 import org.savara.bpel.model.TScope;
 import org.savara.bpel.model.TVariable;
 import org.scribble.common.logging.Journal;
-import org.scribble.common.resource.ResourceLocator;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.Activity;
 
 public interface ConversionContext {
@@ -35,11 +35,11 @@
 	public void convert(Object component, java.util.List<Activity> activities, Journal journal);
 	
 	/**
-	 * This method returns a reference to the resource locator.
+	 * This method returns a reference to the protocol context.
 	 * 
-	 * @return The resource locator
+	 * @return The protocol context
 	 */
-	public ResourceLocator getResourceLocator();
+	public ProtocolContext getProtocolContext();
 	
 	/**
 	 * This method returns the process.

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/DefaultConversionContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/DefaultConversionContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/DefaultConversionContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -21,7 +21,7 @@
 import org.savara.bpel.model.TScope;
 import org.savara.bpel.model.TVariable;
 import org.scribble.common.logging.Journal;
-import org.scribble.common.resource.ResourceLocator;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.Activity;
 
 /**
@@ -32,7 +32,7 @@
 	
 	private String m_role=null;
 	private TProcess m_process=null;
-	private ResourceLocator m_resourceLocator=null;
+	private ProtocolContext m_context=null;
 	private java.util.Map<String,TVariable> m_variables=
 					new java.util.HashMap<String,TVariable>();
 	private java.util.Stack<TScope> m_scopeStack=new java.util.Stack<TScope>();
@@ -62,12 +62,12 @@
 	 * 
 	 * @param role The role
 	 * @param proc The process
-	 * @param locator The resource locator
+	 * @param context The protocol context
 	 */
-	public DefaultConversionContext(String role, TProcess proc, ResourceLocator locator) {
+	public DefaultConversionContext(String role, TProcess proc, ProtocolContext context) {
 		m_role = role;
 		m_process = proc;
-		m_resourceLocator = locator;
+		m_context = context;
 	}
 	
 	/**
@@ -91,12 +91,12 @@
 	}
 	
 	/**
-	 * This method returns a reference to the environment context.
+	 * This method returns a reference to the protocol context.
 	 * 
-	 * @return The environment context
+	 * @return The protocol context
 	 */
-	public ResourceLocator getResourceLocator() {
-		return(m_resourceLocator);
+	public ProtocolContext getProtocolContext() {
+		return(m_context);
 	}
 	
 	/**

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/InvokeParserRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/InvokeParserRule.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/InvokeParserRule.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -127,7 +127,7 @@
 		TVariable var=context.getVariable(invoke.getInputVariable());
 		
 		String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-				context.getResourceLocator());
+				context.getProtocolContext().getResourceLocator());
 
 		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
 				
@@ -160,7 +160,7 @@
 		TVariable var=context.getVariable(invoke.getOutputVariable());
 		
 		String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-				context.getResourceLocator());
+				context.getProtocolContext().getResourceLocator());
 
 		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
 		
@@ -201,7 +201,7 @@
 		
 		if (var != null) {
 			String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-					context.getResourceLocator());
+					context.getProtocolContext().getResourceLocator());
 
 			tref = TypeReferenceUtil.createTypeReference(xmlType, context);
 			//tref.setLocalpart(var.getMessageType());

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/PickParserRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/PickParserRule.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/PickParserRule.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -82,7 +82,7 @@
 			TVariable var=context.getVariable(onMessageElem.getVariable());
 			
 			String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-					context.getResourceLocator());
+					context.getProtocolContext().getResourceLocator());
 
 			TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
 			

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReceiveParserRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReceiveParserRule.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReceiveParserRule.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -51,7 +51,7 @@
 		TVariable var=context.getVariable(elem.getVariable());
 		
 		String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-								context.getResourceLocator());
+								context.getProtocolContext().getResourceLocator());
 		
 		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
 		

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReplyParserRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReplyParserRule.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/rules/ReplyParserRule.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -50,7 +50,7 @@
 		TVariable var=context.getVariable(reply.getVariable());
 		
 		String xmlType=BPELInteractionUtil.getXMLType(context.getProcess(), var.getMessageType(),
-							context.getResourceLocator());
+							context.getProtocolContext().getResourceLocator());
 
 		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
 		

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELInteractionUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELInteractionUtil.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELInteractionUtil.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -160,15 +160,19 @@
 					imp.getLocation() != null &&
 					imp.getLocation().endsWith(".wsdl")) {
 				
-				java.net.URI uri=
-						locator.getResourceURI(imp.getLocation());
-
-				if (uri != null) {
-					ret = getXMLType(wsdlMessageType, uri);
-					
-					if (ret != null) {
-						break;
+				try {
+					java.net.URI uri=
+							locator.getResourceURI(imp.getLocation());
+	
+					if (uri != null) {
+						ret = getXMLType(wsdlMessageType, uri);
+						
+						if (ret != null) {
+							break;
+						}
 					}
+				} catch(Exception e) {
+					e.printStackTrace();
 				}
 			}
 		}

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -20,6 +20,7 @@
 import org.savara.bpel.model.change.ModelChangeUtils;
 import org.savara.common.model.change.ModelChangeContext;
 import org.savara.contract.model.*;
+import org.scribble.common.logging.CachedJournal;
 import org.scribble.protocol.model.*;
 
 import junit.framework.TestCase;
@@ -33,7 +34,7 @@
 	private static final String MY_OTHER_LOCATED_ROLE = "MyOtherLocatedRole";
 
 	public void testInitialiseContracts() {
-		ModelChangeContext context=new BPELModelChangeContext();
+		ModelChangeContext context=new BPELModelChangeContext(null, new CachedJournal());
 		
 		Protocol conv=new Protocol();
 		Role r=new Role();
@@ -58,7 +59,7 @@
 	}
 
 	public void testInitialiseContractsTwice() {
-		ModelChangeContext context=new BPELModelChangeContext();
+		ModelChangeContext context=new BPELModelChangeContext(null, new CachedJournal());
 		
 		Protocol conv=new Protocol();
 		Role r=new Role();
@@ -104,7 +105,7 @@
 	}
 	
 	public void testPushRoleContractMapping() {
-		ModelChangeContext context=new BPELModelChangeContext();
+		ModelChangeContext context=new BPELModelChangeContext(null, new CachedJournal());
 		
 		Protocol conv=new Protocol();
 		Role r1=new Role();
@@ -129,6 +130,10 @@
 		Protocol subconv=new Protocol();
 		subconv.setName(SUB_PROTOCOL);
 		
+		ParameterDefinition pd=new ParameterDefinition();
+		pd.setName(MY_OTHER_ROLE);
+		subconv.getParameterDefinitions().add(pd);
+
 		Role subr1=new Role();
 		subr1.setName(MY_OTHER_LOCATED_ROLE);
 		subconv.setRole(subr1);
@@ -144,12 +149,12 @@
 		
 		Parameter db=new Parameter();
 		db.setName(r2.getName());
-		db.setBoundName(MY_OTHER_ROLE);
+		//db.setBoundName(MY_OTHER_ROLE);
 		run.getParameters().add(db);
 		
 		conv.getBlock().add(subconv);
 		
-		ModelChangeUtils.pushRoleContractMapping(context, run);
+		ModelChangeUtils.pushRoleContractMapping(context, run, null);
 		
 		Contract c3=ModelChangeUtils.getContract(context, new Role(MY_ROLE));
 		Contract c4=ModelChangeUtils.getContract(context, new Role(MY_OTHER_ROLE));
@@ -183,7 +188,7 @@
 	}
 	
 	public void testPopRoleContractMapping() {
-		ModelChangeContext context=new BPELModelChangeContext();
+		ModelChangeContext context=new BPELModelChangeContext(null, new CachedJournal());
 		
 		Protocol conv=new Protocol();
 		Role r1=new Role();
@@ -200,6 +205,10 @@
 		
 		Protocol subconv=new Protocol();
 		subconv.setName(SUB_PROTOCOL);
+		
+		ParameterDefinition pd=new ParameterDefinition();
+		pd.setName(MY_OTHER_ROLE);
+		subconv.getParameterDefinitions().add(pd);
 
 		Role subr1=new Role();
 		subr1.setName(MY_OTHER_LOCATED_ROLE);
@@ -235,12 +244,12 @@
 		
 		Parameter db=new Parameter();
 		db.setName(r2.getName());
-		db.setBoundName(MY_OTHER_ROLE);
+		//db.setBoundName(MY_OTHER_ROLE);
 		run.getParameters().add(db);
 		
 		conv.getBlock().add(subconv);
 		
-		ModelChangeUtils.popRoleContractMapping(context, run);
+		ModelChangeUtils.popRoleContractMapping(context, run, null);
 		
 		Contract c3=ModelChangeUtils.getContract(context, new Role(MY_ROLE));
 		Contract c4=ModelChangeUtils.getContract(context, new Role(MY_OTHER_ROLE));

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/generator/GeneratorTest.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/generator/GeneratorTest.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -36,10 +36,10 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("Choreography->BPEL Generator Tests");
 
+        suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Broker"));
         suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Buyer"));     
         suite.addTest(new ChoreographyToBPELTester("ESBBroker", "SupplierTxnProcessor"));
         suite.addTest(new ChoreographyToBPELTester("ESBBroker", "CreditAgency"));
-        suite.addTest(new ChoreographyToBPELTester("ESBBroker", "Broker"));
         suite.addTest(new ChoreographyToBPELTester("ESBBroker", "SupplierQuoteEngine"));
         
         suite.addTest(new ChoreographyToBPELTester("PurchaseGoods", "Buyer"));
@@ -48,7 +48,7 @@
         
         suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Buyer"));
         suite.addTest(new ChoreographyToBPELTester("ReqRespFault", "Seller"));
-
+        
         return suite;
     }
     
@@ -112,9 +112,9 @@
     			
     			org.scribble.protocol.model.ProtocolModel model=null;
     			
+				CDMProtocolParser parser=new CDMProtocolParser();
+				
     			try {
-    				CDMProtocolParser parser=new CDMProtocolParser();
-    				
     				model = parser.parse(is, journal, null);
     			} catch(Exception e) {
     				result.addError(this, new Throwable("Parsing choreography failed"));
@@ -155,7 +155,7 @@
     						new org.scribble.protocol.projection.impl.ProtocolProjectorImpl();
     					
     					org.scribble.protocol.model.ProtocolModel projected=
-    									projector.project(model, role, journal);
+    									projector.project(model, role, journal, null);
     					
     					/* Currently if a 'fail' is performed in Tycho build, it
     					 * hangs the build.

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/parser/ParserTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/parser/ParserTest.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel.tests/src/test/java/org/savara/bpel/parser/ParserTest.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -21,6 +21,7 @@
 
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.common.resource.ResourceLocator;
+import org.scribble.protocol.DefaultProtocolContext;
 import org.scribble.protocol.model.ProtocolModel;
 
 import junit.framework.TestCase;
@@ -98,7 +99,8 @@
     			try {
     				BPELProtocolParser parser=new BPELProtocolParser();
     				
-    				model = parser.parse(is, journal, new ResourceLoaderImpl());
+    				model = parser.parse(is, journal, new DefaultProtocolContext(null,
+    									new ResourceLoaderImpl()));
     			} catch(Exception e) {
     				e.printStackTrace();
     				result.addError(this, new Throwable("Parsing BPEL failed"));

Modified: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/AbstractModelChangeContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/AbstractModelChangeContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/AbstractModelChangeContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -19,6 +19,8 @@
  */
 package org.savara.common.model.change;
 
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.*;
 
 /**
@@ -28,17 +30,40 @@
 public abstract class AbstractModelChangeContext implements ModelChangeContext {
 	
 	private Object m_parent=null;
+	private ProtocolContext m_context=null;
+	private Journal m_journal=null;
 	private java.util.Map<String,Object> m_properties=new java.util.HashMap<String,Object>();
 
 	/**
 	 * This is the constructor for the model change context.
 	 * 
-	 * @param role The role associated with the model
+	 * @param context The protocol context
+	 * @param journal The journal
 	 */
-	public AbstractModelChangeContext() {		
+	public AbstractModelChangeContext(ProtocolContext context, Journal journal) {
+		m_context = context;
+		m_journal = journal;
 	}
 	
 	/**
+	 * This method returns the protocol context.
+	 * 
+	 * @return The protocol context
+	 */
+	public ProtocolContext getProtocolContext() {
+		return(m_context);
+	}
+	
+	/**
+	 * This method returns the journal.
+	 * 
+	 * @return The journal
+	 */
+	public Journal getJournal() {
+		return(m_journal);
+	}
+	
+	/**
 	 * This method returns a list of model change rules appropriate
 	 * for the notation being changed.
 	 * 

Modified: branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/ModelChangeContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/ModelChangeContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.common/src/main/java/org/savara/common/model/change/ModelChangeContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -19,6 +19,8 @@
  */
 package org.savara.common.model.change;
 
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.*;
 
 /**
@@ -28,6 +30,20 @@
 public interface ModelChangeContext {
 
 	/**
+	 * This method returns the protocol context.
+	 * 
+	 * @return The protocol context
+	 */
+	public ProtocolContext getProtocolContext();
+	
+	/**
+	 * This method returns the protocol context.
+	 * 
+	 * @return The protocol context
+	 */
+	public Journal getJournal();
+	
+	/**
 	 * This method returns the current parent component.
 	 * 
 	 * @return The parent

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGenerator.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGenerator.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGenerator.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -19,6 +19,7 @@
 
 import org.savara.contract.model.Contract;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.Protocol;
 import org.scribble.protocol.model.ProtocolModel;
 
@@ -36,9 +37,10 @@
 	 * 
 	 * @param pm The protocol model
 	 * @param journal The journal
+	 * @param context The protocol context
 	 * @throws IllegalArgumentException
 	 */
-	public void generate(ProtocolModel pm, Journal journal) throws IllegalArgumentException;
+	public void generate(ProtocolModel pm, Journal journal, ProtocolContext context) throws IllegalArgumentException;
 	
 	/**
 	 * This method generates a contract associated with a supplied located

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/ContractGeneratorImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/ContractGeneratorImpl.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/ContractGeneratorImpl.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -22,12 +22,11 @@
 import org.savara.common.util.ScribbleServices;
 import org.savara.contract.model.Contract;
 import org.savara.contract.generator.ContractGenerator;
-import org.scribble.common.logging.CachedJournal;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.Protocol;
 import org.scribble.protocol.model.ProtocolModel;
 import org.scribble.protocol.model.Role;
-import org.scribble.protocol.model.RoleList;
 
 /**
  * This class generates a contract from a protocol defining the behaviour of
@@ -43,13 +42,14 @@
 	 * 
 	 * @param pm The protocol model
 	 * @param journal The journal
+	 * @param context The protocol context
 	 * @throws IllegalArgumentException
 	 */
-	public void generate(ProtocolModel pm, Journal journal) throws IllegalArgumentException {
+	public void generate(ProtocolModel pm, Journal journal, ProtocolContext context) throws IllegalArgumentException {
 		java.util.List<Role> roles=pm.getRoles();
 		
 		for (Role r : roles) {
-			ProtocolModel lm=ScribbleServices.getProtocolProjector().project(pm, r, journal);
+			ProtocolModel lm=ScribbleServices.getProtocolProjector().project(pm, r, journal, context);
 			
 			if (lm != null) {
 				Contract c=generate(lm.getProtocol(), journal);

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/CDMProtocolParser.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/CDMProtocolParser.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/CDMProtocolParser.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -27,9 +27,9 @@
 import org.savara.pi4soa.cdm.parser.rules.ConverterRuleFactory;
 import org.savara.pi4soa.cdm.parser.rules.DefaultConverterContext;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.ProtocolModel;
 import org.scribble.protocol.parser.ProtocolParser;
-import org.scribble.common.resource.ResourceLocator;
 
 /**
  * This class provides the model parser for the CDM notation.
@@ -47,7 +47,7 @@
 		return("cdm".equals(sourceType));
 	}
 	
-	public ProtocolModel parse(java.io.InputStream is, Journal journal, ResourceLocator locator)
+	public ProtocolModel parse(java.io.InputStream is, Journal journal, ProtocolContext context)
 							throws java.io.IOException {
 		ProtocolModel ret=null;
 		
@@ -61,7 +61,7 @@
 			
 				if (rule != null) {
 					ConverterContext cctxt=
-						new DefaultConverterContext(journal);
+						new DefaultConverterContext(journal, context);
 					
 					ret = (ProtocolModel)rule.convert(cctxt,
 							ProtocolModel.class, cdlpack);

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -22,11 +22,19 @@
 import org.pi4soa.cdl.Choreography;
 import org.pi4soa.cdl.ExchangeDetails;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.*;
 
 public interface ConverterContext {
 
 	/**
+	 * This method returns the protocol context.
+	 * 
+	 * @return The protocol context
+	 */
+	public ProtocolContext getProtocolContext();
+	
+	/**
 	 * This method returns the journal for reporting issues.
 	 * 
 	 * @return The journal

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -21,7 +21,14 @@
 
 import javax.xml.namespace.QName;
 
+import org.pi4soa.cdl.Choreography;
+import org.pi4soa.cdl.DefaultCDLVisitor;
 import org.pi4soa.cdl.ExchangeDetails;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.Participant;
+import org.pi4soa.cdl.ParticipantType;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.common.xml.XMLUtils;
 import org.savara.common.model.util.PropertyName;
 import org.savara.common.model.util.TypeSystem;
 import org.scribble.protocol.model.*;
@@ -31,8 +38,6 @@
  */
 public class ConverterUtil {
 
-	private static final String QNAME = "QName";
-
 	/**
 	 * This method converts the supplied information type into a
 	 * type reference.
@@ -93,4 +98,180 @@
 		return(ret);
 	}
 	
+	public static java.util.List<Role> getRoleParameters(final Choreography choreo) {
+		java.util.List<Role> ret=new java.util.Vector<Role>();
+		
+		// If root choreo, then no parameters
+		if (choreo.getRoot() == Boolean.TRUE) {
+			return(ret);
+		}
+		
+		final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+		final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+		
+		choreo.visit(new DefaultCDLVisitor() {
+			
+			// TODO: SAVARA-161 May also need to handle 'perform' (and take care of recursion),
+			// as a participant type may not be used in an intermediate sub-choreo,
+			// but still would need to be passed through it to any child sub-choreos.
+			// Sub-choreos should not process participant instances, so need to ignore these
+			// if not the primary choreo being visited.
+			
+			public void interaction(Interaction interaction) {
+				
+				if (interaction.getEnclosingChoreography() != choreo) {
+					return;
+				}
+				
+				if (interaction.getFromParticipant() != null) {
+					if (partInstances.contains(interaction.getFromParticipant()) == false) {
+						partInstances.add(interaction.getFromParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getFromRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+				
+				if (interaction.getToParticipant() != null) {
+					if (partInstances.contains(interaction.getToParticipant()) == false) {
+						partInstances.add(interaction.getToParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getToRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+			}
+		});
+		
+		// Define roles
+		java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+		while (ptiter.hasNext()) {
+			ParticipantType ptype=ptiter.next();
+
+			Role role=new Role();
+			role.setName(XMLUtils.getLocalname(ptype.getName()));
+			role.getProperties().put(PropertyName.NAMESPACE,
+						CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
+			
+			ret.add(role);
+		}
+		
+		java.util.Iterator<Participant> piter=partInstances.iterator();
+		
+		while (piter.hasNext()) {
+			Participant pinst=piter.next();
+			
+			// Only include 'free' participant instances, as these are bound by
+			// a calling protocol.
+			if (pinst.getFree() == Boolean.TRUE) {
+				Role role=new Role();
+				role.setName(XMLUtils.getLocalname(pinst.getName()));
+				role.getProperties().put(PropertyName.NAMESPACE,
+							CDLTypeUtil.getNamespace(pinst.getName(), pinst, true));
+				
+				ret.add(role);
+			}
+		}
+
+		return(ret);
+	}
+
+	public static java.util.List<Role> getRoleDeclarations(final Choreography choreo) {
+		java.util.List<Role> ret=new java.util.Vector<Role>();
+		
+		final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+		final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+		
+		choreo.visit(new DefaultCDLVisitor() {
+			
+			public void interaction(Interaction interaction) {
+				
+				if (interaction.getEnclosingChoreography() != choreo) {
+					return;
+				}
+				
+				if (interaction.getFromParticipant() != null) {
+					if (partInstances.contains(interaction.getFromParticipant()) == false) {
+						partInstances.add(interaction.getFromParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getFromRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+				
+				if (interaction.getToParticipant() != null) {
+					if (partInstances.contains(interaction.getToParticipant()) == false) {
+						partInstances.add(interaction.getToParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getToRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+			}
+		});
+		
+		// Define roles
+		
+		if (choreo.getRoot() == Boolean.TRUE) {
+			// Use complete list for now - when SAVARA-161 being fixed, then could use
+			// the participant type list returned from scanning the full choreo
+			java.util.Iterator<ParticipantType> ptiter=// partTypes.iterator();
+					choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+	
+			while (ptiter.hasNext()) {
+				ParticipantType ptype=ptiter.next();
+
+				Role role=new Role();
+				role.setName(XMLUtils.getLocalname(ptype.getName()));
+				role.getProperties().put(PropertyName.NAMESPACE,
+							CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
+				
+				ret.add(role);
+			}
+		}
+		
+		java.util.Iterator<Participant> piter=partInstances.iterator();
+		
+		while (piter.hasNext()) {
+			Participant pinst=piter.next();
+
+			// Check that not a 'free' participant instance - i.e. is not bound
+			// from outer choreo
+			if (pinst.getFree() == Boolean.FALSE) {
+				Role role=new Role();
+				role.setName(XMLUtils.getLocalname(pinst.getName()));
+				role.getProperties().put(PropertyName.NAMESPACE,
+							CDLTypeUtil.getNamespace(pinst.getName(), pinst, true));
+				
+				ret.add(role);
+			}			
+		}
+	
+		return(ret);
+	}
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -24,6 +24,7 @@
 import org.pi4soa.cdl.Choreography;
 import org.pi4soa.cdl.ExchangeDetails;
 import org.scribble.common.logging.Journal;
+import org.scribble.protocol.ProtocolContext;
 import org.scribble.protocol.model.*;
 
 /**
@@ -32,12 +33,14 @@
 public class DefaultConverterContext implements ConverterContext {
 
 	private Journal m_journal=null;
+	private ProtocolContext m_context=null;
 	
 	/**
 	 * Default constructor.
 	 */
-	public DefaultConverterContext(Journal journal) {
+	public DefaultConverterContext(Journal journal, ProtocolContext context) {
 		m_journal = journal;
+		m_context = context;
 	}
 	
 	/**
@@ -64,6 +67,15 @@
 	*/
 	
 	/**
+	 * This method returns the protocol context.
+	 * 
+	 * @return The protocol context
+	 */
+	public ProtocolContext getProtocolContext() {
+		return(m_context);
+	}
+	
+	/**
 	 * This method returns the journal for reporting issues.
 	 * 
 	 * @return The journal

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -65,8 +65,25 @@
 			context.pushScope();
 			
 			// Define roles
-			ProtocolConverterRuleImpl.defineRoles(context, cdl.getChoreography(), (Block)ret);
+			//ProtocolConverterRuleImpl.defineRoles(context, cdl.getChoreography(), (Block)ret);
+			java.util.List<Role> roles=ConverterUtil.getRoleParameters(cdl.getChoreography());
 			
+			for (Role r : roles) {
+				context.setState(r.getName(), r);
+			}
+			
+			roles = ConverterUtil.getRoleDeclarations(cdl.getChoreography());
+			
+			if (roles.size() > 0) {
+				RoleList rl=new RoleList();
+				for (Role r : roles) {
+					rl.getRoles().add(r);
+					context.setState(r.getName(), r);
+				}
+				((Block)ret).add(rl);
+			}
+			
+			// Convert sub-activities
 			ProtocolConverterRuleImpl.convertActivities(context, cdl.getChoreography().getActivities(), (Block)ret);
 		
 			context.popScope();
@@ -88,6 +105,15 @@
 			
 			run.setProtocolReference(ref);
 			
+			// Generate roles
+			java.util.List<Role> roles=ConverterUtil.getRoleParameters(cdl.getChoreography());
+			
+			for (Role r : roles) {
+				Parameter p=new Parameter();
+				p.setName(r.getName());
+				run.getParameters().add(p);
+			}
+			
 			// Convert binding parameters
 			java.util.List<BindDetails> bds=cdl.getBindDetails();
 			
@@ -95,6 +121,11 @@
 				
 				// Only convert if a variable, not a channel
 				// TODO: Need to also convert explicit channels
+				
+				/* TODO SAVARA-160 Don't convert variables for now, as protocol does not
+				 * use them. However when assertions are defined, they may be
+				 * useful, and also if participants are bound. 
+				 *
 				if (bds.get(i).getThisVariable() instanceof org.pi4soa.cdl.Variable) {
 					Parameter db=new Parameter();
 					
@@ -102,13 +133,14 @@
 					
 					if (state instanceof Role) {
 						db.setName(((Role)state).getName());
-						db.setBoundName(bds.get(i).getFreeVariable().getName());
+						//db.setBoundName(bds.get(i).getFreeVariable().getName());
 					
 						run.getParameters().add(db);
 					} else {
 						logger.finer("State not found for '"+bds.get(i).getThisVariable().getName()+"'");
 					}
 				}
+				*/
 			}
 			
 			ret = run;
@@ -117,5 +149,5 @@
 		return(ret);
 	}
 	
-	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+	private static Logger logger = Logger.getLogger("org.savara.pi4soa.cdm.parser.rules");
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolConverterRuleImpl.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolConverterRuleImpl.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -82,8 +82,31 @@
 		ret.setName(choreo.getName());
 		
 		// Define roles
-		defineRoles(context, choreo, ret.getBlock());
+		//defineRoles(context, choreo, ret.getBlock());
+		java.util.List<Role> roles=ConverterUtil.getRoleParameters(choreo);
 		
+		for (Role r : roles) {
+			ParameterDefinition pd=new ParameterDefinition();
+			pd.setName(r.getName());
+			ret.getParameterDefinitions().add(pd);
+			
+			context.setState(r.getName(), r);
+		}
+
+		roles = ConverterUtil.getRoleDeclarations(choreo);
+		
+		if (roles.size() > 0) {
+			RoleList rl=new RoleList();
+			
+			for (Role r : roles) {
+				rl.getRoles().add(r);
+				
+				context.setState(r.getName(), r);
+			}
+			
+			ret.getBlock().add(rl);
+		}
+		
 		// Check if root, then need to project other sibling choreos
 		if (choreo.getRoot() == Boolean.TRUE) {
 			
@@ -250,7 +273,7 @@
 		return(ret);
 	}
 
-	
+	/*
 	protected static void defineRoles(ConverterContext context,
 			final Choreography choreo, Block block) {
 	
@@ -320,61 +343,6 @@
 			roleList.getRoles().add(role);
 			
 			context.setState(role.getName(), role);
-
-			// TODO: registerRole seems to only deal with ConversationType
-			// which is not required when using TAP
-			//registerRole(context, choreo, conv, roleList, role, pinst);
-			
-			// Setup interfaces
-			/*
-			for (int i=0; i < pinst.getRoleTypes().size(); i++) {
-				Contract contract=null;
-				
-				if (role.getProperties().containsKey(Contract.class.getName())) {
-					contract = (Contract)role.getProperties().get(
-								Contract.class.getName());
-				} else {
-					contract = new Contract();
-					
-					java.util.List<?> ptypes=
-							PackageUtil.getParticipantsForRoleTypes(choreo.getPackage(),
-									pinst.getRoleTypes());
-					
-					if (ptypes.size() == 1) {
-						ParticipantType pt=(ParticipantType)ptypes.get(0);
-						
-						contract.setName(XMLUtils.getLocalname(pt.getName()));
-						contract.setNamespace(CDLTypeUtil.getNamespace(pt.getName(), pt));
-					} else {
-						
-						logger.warning("Could not find single participant type for participant instance '"+
-								pinst.getName()+"'");
-						contract.setName(XMLUtils.getLocalname(pinst.getName()));
-						contract.setNamespace(CDLTypeUtil.getNamespace(pinst.getName(), pinst));
-					}
-					
-					// Setup namespace to prefix mappings
-					java.util.List<NameSpace> nspaces=pinst.getPackage().getTypeDefinitions().getNameSpaces();
-					
-					for (int j=0; j < nspaces.size(); j++) {
-						org.savara.contract.model.Namespace ns=
-									new org.savara.contract.model.Namespace();
-						
-						ns.setPrefix(nspaces.get(j).getPrefix());
-						ns.setURI(nspaces.get(j).getURI());
-						ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
-						
-						contract.getNamespaces().add(ns);
-					}
-					
-					role.getProperties().put(Contract.class.getName(),
-												contract);
-				}
-				
-				setupInterfaces((org.pi4soa.cdl.RoleType)pinst.getRoleTypes().get(i),
-								contract, intfDeriver);
-			}
-			*/
 		}
 
 		java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
@@ -403,51 +371,9 @@
 			roleList.getRoles().add(role);
 			
 			context.setState(role.getName(), role);
-
-			if (choreo.getRoot() == Boolean.TRUE) {
-				// TODO: registerRole seems to only deal with ConversationType
-				// which is not required when using TAP
-				//registerRole(context, choreo, conv, roleList, role, ptype);
-				
-				// Setup interfaces
-				/*
-				for (int i=0; i < ptype.getRoleTypes().size(); i++) {
-					Contract contract=null;
-					
-					if (role.getProperties().containsKey(Contract.class.getName())) {
-						contract = (Contract)role.getProperties().get(
-									Contract.class.getName());
-					} else {
-						contract = new Contract();
-						
-						contract.setName(XMLUtils.getLocalname(ptype.getName()));
-						contract.setNamespace(CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
-						
-						// Setup namespace to prefix mappings
-						java.util.List<NameSpace> nspaces=ptype.getPackage().getTypeDefinitions().getNameSpaces();
-						
-						for (int j=0; j < nspaces.size(); j++) {
-							org.savara.contract.model.Namespace ns=
-										new org.savara.contract.model.Namespace();
-							
-							ns.setPrefix(nspaces.get(j).getPrefix());
-							ns.setURI(nspaces.get(j).getURI());
-							ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
-							
-							contract.getNamespaces().add(ns);
-						}
-						
-						role.getProperties().put(Contract.class.getName(),
-													contract);
-					}
-
-					setupInterfaces((org.pi4soa.cdl.RoleType)ptype.getRoleTypes().get(i),
-									contract, intfDeriver);
-				}
-				*/
-			}
 		}
 	}
+	*/
 	
 	/*
 	protected static void setupInterfaces(org.pi4soa.cdl.RoleType roleType, Contract contract,
@@ -694,6 +620,7 @@
 
 	private static Logger logger = Logger.getLogger(ProtocolConverterRuleImpl.class.getPackage().getName());
 	
+	/*
 	public static class InterfaceVisitorImpl implements InterfaceVisitor,
 							java.io.Serializable {
 		
@@ -764,12 +691,6 @@
 			if (defn.getElement() != null && defn.getElement().trim().length() > 0) {
 				td.setName(defn.getElement());
 				
-				/*
-				if (defn.getElementNamespace() != null) {
-					td.setNamespace(defn.getElementNamespace());
-				}
-				*/
-				
 				QName qname=new QName(defn.getElementNamespace(), defn.getElement());
 				td.setDataType(qname.toString());
 				
@@ -777,13 +698,7 @@
 
 			} else if (defn.getType() != null && defn.getType().trim().length() > 0) {
 				td.setName(defn.getType());
-				
-				/*
-				if (defn.getTypeNamespace() != null) {
-					td.setNamespace(defn.getTypeNamespace());
-				}
-				*/
-				
+								
 				QName qname=new QName(defn.getTypeNamespace(), defn.getType());
 				td.setDataType(qname.toString());
 				
@@ -827,4 +742,5 @@
 			
 		}	
 	}
+	*/
 }

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolModelConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolModelConverterRuleImpl.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolModelConverterRuleImpl.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -150,7 +150,7 @@
 		// Derive contracts associated with the protocol model
 		ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
 		if (cg != null) {
-			cg.generate(ret, context.getJournal());
+			cg.generate(ret, context.getJournal(), context.getProtocolContext());
 		}
 		
 		return(ret);

Added: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtilTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtilTest.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/rules/ConverterUtilTest.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -0,0 +1,234 @@
+/*
+ * 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.savara.pi4soa.cdm.parser.rules;
+
+import static org.junit.Assert.*;
+
+import org.pi4soa.cdl.CDLManager;
+import org.savara.common.util.ScribbleServices;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.ProtocolModel;
+import org.scribble.protocol.model.Role;
+
+public class ConverterUtilTest {
+
+	@org.junit.Test
+	public void testGetRoleDeclarationsTopChoreo() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleDeclarations(cdlpack.getChoreographies().get(0));
+		
+		if (roles.size() != 4) {
+			fail("Was expecting 4 roles");
+		}
+		
+		if (roles.contains(new Role("Broker")) == false) {
+			fail("Broker not found");
+		}
+		
+		if (roles.contains(new Role("Buyer")) == false) {
+			fail("Buyer not found");
+		}
+		
+		if (roles.contains(new Role("CreditAgency")) == false) {
+			fail("CreditAgency not found");
+		}
+		
+		// Maybe only until the search is refined to used participant types
+		if (roles.contains(new Role("Supplier")) == false) {
+			fail("Supplier not found");
+		}
+	}
+
+	@org.junit.Test
+	public void testGetRoleDeclarationsSubChoreo1() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		org.pi4soa.cdl.Choreography top=cdlpack.getChoreographies().get(0);
+		
+		org.pi4soa.cdl.Choreography sub=top.getEnclosedChoreography("RequestForQuote");
+		
+		if (sub == null) {
+			fail("Failed to get 'RequestForQuote' sub-choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleDeclarations(sub);
+		
+		if (roles.size() != 1) {
+			fail("Was expecting 1 roles");
+		}
+		
+		if (roles.contains(new Role("SupplierQuoteEngine")) == false) {
+			fail("SupplierQuoteEngine not found");
+		}
+	}
+
+	@org.junit.Test
+	public void testGetRoleDeclarationsSubChoreo2() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		org.pi4soa.cdl.Choreography top=cdlpack.getChoreographies().get(0);
+		
+		org.pi4soa.cdl.Choreography sub=top.getEnclosedChoreography("CompleteTransaction");
+		
+		if (sub == null) {
+			fail("Failed to get 'CompleteTransaction' sub-choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleDeclarations(sub);
+		
+		if (roles.size() != 1) {
+			fail("Was expecting 1 roles");
+		}
+		
+		if (roles.contains(new Role("SupplierTxnProcessor")) == false) {
+			fail("SupplierTxnProcessor not found");
+		}
+	}
+
+	@org.junit.Test
+	public void testGetRoleParametersTopChoreo() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleParameters(cdlpack.getChoreographies().get(0));
+		
+		if (roles.size() != 0) {
+			fail("Was expecting 0 roles");
+		}
+	}
+
+	@org.junit.Test
+	public void testGetRoleParametersSubChoreo1() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		org.pi4soa.cdl.Choreography top=cdlpack.getChoreographies().get(0);
+		
+		org.pi4soa.cdl.Choreography sub=top.getEnclosedChoreography("RequestForQuote");
+		
+		if (sub == null) {
+			fail("Failed to get 'RequestForQuote' sub-choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleParameters(sub);
+		
+		if (roles.size() != 1) {
+			fail("Was expecting 1 roles");
+		}
+		
+		if (roles.contains(new Role("Broker")) == false) {
+			fail("Broker not found");
+		}
+	}
+
+	@org.junit.Test
+	public void testGetRoleParametersSubChoreo2() {
+		org.pi4soa.cdl.Package cdlpack=null;
+		
+		try {
+			cdlpack = CDLManager.load("cdm/ESBBroker.cdm");			
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to load choreography: "+e);
+		}
+		
+		if (cdlpack.getChoreographies().size() != 1) {
+			fail("Expecting only one top level choreo");
+		}
+		
+		org.pi4soa.cdl.Choreography top=cdlpack.getChoreographies().get(0);
+		
+		org.pi4soa.cdl.Choreography sub=top.getEnclosedChoreography("CompleteTransaction");
+		
+		if (sub == null) {
+			fail("Failed to get 'CompleteTransaction' sub-choreo");
+		}
+		
+		java.util.List<Role> roles=ConverterUtil.getRoleParameters(sub);
+		
+		if (roles.size() != 3) {
+			fail("Was expecting 3 roles");
+		}
+		
+		if (roles.contains(new Role("Broker")) == false) {
+			fail("Broker not found");
+		}
+		
+		if (roles.contains(new Role("Buyer")) == false) {
+			fail("Buyer not found");
+		}
+		
+		if (roles.contains(new Role("CreditAgency")) == false) {
+			fail("CreditAgency not found");
+		}
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/cdm/ESBBroker.cdm
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/cdm/ESBBroker.cdm	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/cdm/ESBBroker.cdm	2011-01-12 13:42:44 UTC (rev 566)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for ESBBroker" name="ESBBroker" author="gary" version="0.2" targetNamespace="http://www.pi4soa.org/ESBBroker">
+  <typeDefinitions>
+    <nameSpaces description="Target Namespace for ESBBroker" prefix="tns" uRI="http://www.pi4soa.org/ESBBroker"/>
+    <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+    <nameSpaces description="Target Namespace for ESBBroker" prefix="brk" uRI="http://www.pi4soa.org/ESBBroker/Broker"/>
+    <nameSpaces description="Target Namespace for ESBBroker" prefix="byr" uRI="http://www.pi4soa.org/ESBBroker/Buyer"/>
+    <nameSpaces description="Target Namespace for ESBBroker" prefix="cay" uRI="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+    <nameSpaces description="Target Namespace for ESBBroker" prefix="spr" uRI="http://www.pi4soa.org/ESBBroker/Supplier"/>
+    <informationTypes description="This is the information type BookingReference" name="BookingReference" elementName="bookingReference"/>
+    <informationTypes description="This is the information type Buy" name="Buy" elementName="buy"/>
+    <informationTypes description="This is the information type Cancel" name="Cancel" elementName="cancel"/>
+    <informationTypes description="This is the information type CreditInformation" name="CreditInformation" elementName="CreditCheckRequest"/>
+    <informationTypes description="This is the information type CreditInvalid" name="CreditInvalid" elementName="CreditCheckInvalid"/>
+    <informationTypes description="This is the information type CreditValid" name="CreditValid" elementName="CreditCheckOk"/>
+    <informationTypes description="This is the information type Enquiry" name="Enquiry" typeName="" elementName="enquiry"/>
+    <informationTypes description="This is the information type OrderConfirmed" name="OrderConfirmed" elementName="orderConfirmed"/>
+    <informationTypes description="This is the information type OrderRejected" name="OrderRejected" elementName="orderRejected"/>
+    <informationTypes description="This is the information type Quote" name="Quote" elementName="quote"/>
+    <informationTypes description="This is the information type QuoteList" name="QuoteList" elementName="quoteList"/>
+    <informationTypes description="This is the information type RequestForQuote" name="RequestForQuote" elementName="requestForQuote"/>
+    <informationTypes description="This is the information type URIType" name="URIType"/>
+    <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.12"/>
+    <roleTypes description="This is the role type Broker" name="Broker">
+      <behaviors description="This is the behavior BrokerBehavior" name="BrokerBehavior"/>
+    </roleTypes>
+    <roleTypes description="This is the role type Buyer" name="Buyer">
+      <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+    </roleTypes>
+    <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+      <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior"/>
+    </roleTypes>
+    <roleTypes description="This is the role type Supplier" name="Supplier">
+      <behaviors description="This is the behavior SupplierBehavior" name="SupplierBehavior"/>
+    </roleTypes>
+    <relationshipTypes description="Relationship between Broker and CreditAgency" name="BrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.2"/>
+    <relationshipTypes description="Relationship between Broker and Supplier" name="BrokerToSupplierRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.3"/>
+    <relationshipTypes description="Relationship between Buyer and Broker" name="BuyerToBrokerRel" firstRoleType="//@typeDefinitions/@roleTypes.1" secondRoleType="//@typeDefinitions/@roleTypes.0"/>
+    <participantTypes description="This is the participant type brk:Broker" name="brk:Broker" roleTypes="//@typeDefinitions/@roleTypes.0">
+      <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Broker" name="conversationType"/>
+    </participantTypes>
+    <participantTypes description="This is the participant type byr:Buyer" name="byr:Buyer" roleTypes="//@typeDefinitions/@roleTypes.1">
+      <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Buyer" name="conversationType"/>
+    </participantTypes>
+    <participantTypes description="This is the participant type cay:CreditAgency" name="cay:CreditAgency" roleTypes="//@typeDefinitions/@roleTypes.2">
+      <semanticAnnotations annotation="overlord.cdl.samples.Common at CreditAgency" name="conversationType"/>
+    </participantTypes>
+    <participantTypes description="This is the participant type spr:Supplier" name="spr:Supplier" roleTypes="//@typeDefinitions/@roleTypes.3">
+      <semanticAnnotations annotation="" name="conversationType"/>
+    </participantTypes>
+    <channelTypes description="This is the channel type BrokerChannelType" name="BrokerChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.0"/>
+    <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.2"/>
+    <channelTypes description="This is the channel type SupplierChannelType" name="SupplierChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.3"/>
+  </typeDefinitions>
+  <choreographies description="Choreography flow for the ESBBroker process" name="ESBBrokerProcess" root="true">
+    <enclosedChoreographies name="CompleteTransaction">
+      <participantDefinitions name="spr:SupplierTxnProcessor" roleTypes="//@typeDefinitions/@roleTypes.3">
+        <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at SupplierTxnProcessor" name="conversationType"/>
+      </participantDefinitions>
+      <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" free="true" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.1"/>
+      <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/@channelTypes.1"/>
+      <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.2"/>
+      <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+        <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Buy" name="BuyRequestExchange" type="//@typeDefinitions/@informationTypes.1"/>
+      </activities>
+      <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCredit" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+        <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CheckCredit" name="CheckCreditRequestExchange" type="//@typeDefinitions/@informationTypes.3"/>
+      </activities>
+      <activities xsi:type="org.pi4soa.cdl:Choice" description="Evaluate Credit Check Result">
+        <activities xsi:type="org.pi4soa.cdl:Sequence" description="Sufficient Credit">
+          <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCreditResponse" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+            <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CheckCreditResponse" name="CheckCreditResponseRespondExchange" type="//@typeDefinitions/@informationTypes.5" action="Respond"/>
+          </activities>
+          <activities xsi:type="org.pi4soa.cdl:Interaction" name="ConfirmBooking" operation="confirm" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.2" relationship="//@typeDefinitions/@relationshipTypes.1" toParticipant="//@choreographies.0/@enclosedChoreographies.0/@participantDefinitions.0">
+            <exchangeDetails description="This is the exchange details for the request exchange associated with interaction ConfirmBooking" name="ConfirmBookingRequestExchange" type="//@typeDefinitions/@informationTypes.7"/>
+            <exchangeDetails description="This is the exchange details for the request exchange associated with interaction ConfirmBooking" name="ConfirmBookingRequestExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond"/>
+          </activities>
+          <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+            <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Buy" name="BuyRespondExchange" type="//@typeDefinitions/@informationTypes.0" action="Respond" faultName=""/>
+          </activities>
+        </activities>
+        <activities xsi:type="org.pi4soa.cdl:Sequence" description="Insufficient Credit">
+          <activities xsi:type="org.pi4soa.cdl:Interaction" name="CheckCreditFailed" operation="checkCredit" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.1" relationship="//@typeDefinitions/@relationshipTypes.0">
+            <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CheckCreditFailed" name="CheckCreditFailedRespondExchange" type="//@typeDefinitions/@informationTypes.4" action="Respond" faultName="invalidCredit"/>
+          </activities>
+          <activities xsi:type="org.pi4soa.cdl:Interaction" name="Buy" operation="buy" channelVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+            <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Buy" name="BuyRespondExchange" type="//@typeDefinitions/@informationTypes.8" action="Respond" faultName="rejected"/>
+          </activities>
+        </activities>
+      </activities>
+    </enclosedChoreographies>
+    <enclosedChoreographies name="RequestForQuote">
+      <participantDefinitions name="spr:SupplierQuoteEngine" roleTypes="//@typeDefinitions/@roleTypes.3">
+        <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at SupplierQuoteEngine" name="conversationType"/>
+      </participantDefinitions>
+      <variableDefinitions description="Channel to facilitate interaction to Supplier" name="SupplierChannel" type="//@typeDefinitions/@channelTypes.2"/>
+      <activities xsi:type="org.pi4soa.cdl:Interaction" name="RFQ" operation="getQuote" channelVariable="//@choreographies.0/@enclosedChoreographies.1/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.1" toParticipant="//@choreographies.0/@enclosedChoreographies.1/@participantDefinitions.0">
+        <exchangeDetails description="This is the exchange details for the request exchange associated with interaction RFQ" name="RFQRequestExchange" type="//@typeDefinitions/@informationTypes.11"/>
+        <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction RFQ" name="RFQRespondExchange" type="//@typeDefinitions/@informationTypes.9" action="Respond"/>
+      </activities>
+    </enclosedChoreographies>
+    <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.0 //@typeDefinitions/@roleTypes.1"/>
+    <activities xsi:type="org.pi4soa.cdl:Interaction" name="Enquiry" operation="makeEnquiry" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+      <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Enquiry" name="EnquiryRequestExchange" type="//@typeDefinitions/@informationTypes.6"/>
+    </activities>
+    <activities xsi:type="org.pi4soa.cdl:While" name="SendRFQToSuppliers">
+      <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.1"/>
+    </activities>
+    <activities xsi:type="org.pi4soa.cdl:When" name="WhenQuotesReceivedOrTimeout">
+      <activities xsi:type="org.pi4soa.cdl:Interaction" name="Enquiry" operation="makeEnquiry" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+        <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction Enquiry" name="EnquiryRespondExchange" type="//@typeDefinitions/@informationTypes.10" action="Respond"/>
+      </activities>
+    </activities>
+    <activities xsi:type="org.pi4soa.cdl:Choice">
+      <activities xsi:type="org.pi4soa.cdl:Sequence">
+        <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/@enclosedChoreographies.0" waitForCompletion="false">
+          <bindDetails name="BindBrokerChannel" thisVariable="//@choreographies.0/@variableDefinitions.0" thisRole="//@typeDefinitions/@roleTypes.1" freeVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" freeRole="//@typeDefinitions/@roleTypes.1"/>
+          <bindDetails name="BindBrokerChannel" thisVariable="//@choreographies.0/@variableDefinitions.0" thisRole="//@typeDefinitions/@roleTypes.0" freeVariable="//@choreographies.0/@enclosedChoreographies.0/@variableDefinitions.0" freeRole="//@typeDefinitions/@roleTypes.0"/>
+        </activities>
+      </activities>
+      <activities xsi:type="org.pi4soa.cdl:Sequence">
+        <activities xsi:type="org.pi4soa.cdl:Interaction" name="Cancel" operation="cancel" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.2">
+          <exchangeDetails description="This is the exchange details for the request exchange associated with interaction Cancel" name="CancelRequestExchange" type="//@typeDefinitions/@informationTypes.2"/>
+        </activities>
+      </activities>
+    </activities>
+  </choreographies>
+</org.pi4soa.cdl:Package>

Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java	2011-01-10 19:42:04 UTC (rev 565)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java	2011-01-12 13:42:44 UTC (rev 566)
@@ -45,6 +45,8 @@
 import org.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.common.logging.Journal;
+import org.scribble.common.resource.DefaultResourceLocator;
+import org.scribble.protocol.DefaultProtocolContext;
 import org.scribble.protocol.model.*;
 import org.eclipse.core.runtime.*;
 import org.eclipse.jst.common.project.facet.WtpUtils;
@@ -218,8 +220,11 @@
 		
 		CachedJournal journal=new CachedJournal();
 		
+		DefaultProtocolContext context=new DefaultProtocolContext(ScribbleServices.getParserManager(),
+						new DefaultResourceLocator(cdmResource.getParent().getFullPath().toFile()));
+		
 		ProtocolModel local=ScribbleServices.getProtocolProjector().project(m_protocolModel,
-								localRole, journal);
+								localRole, journal, context);
 		
 		if (local != null) {
 			// TODO: Obtain model generator from manager class (SAVARA-156)



More information about the savara-commits mailing list