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

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 25 19:04:55 EST 2011


Author: objectiser
Date: 2011-01-25 19:04:53 -0500 (Tue, 25 Jan 2011)
New Revision: 622

Added:
   branches/experimental/2.0.x/bundles/org.savara.contract/src/test/resources/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGenerator.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGeneratorFactory.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/change/ModelChangeUtils.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ContractGeneratorTest.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/impl/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/impl/ContractIntrospectorTest.java
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Broker.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Buyer.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at CreditAgency.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierQuoteEngine.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierTxnProcessor.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Buyer.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Buyer.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Seller.contract
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ESBBroker.spr
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PurchaseGoods.spr
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ReqRespFault.spr
Removed:
   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.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/ContractGeneratorFactory.java
   branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/
   branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/ContractGeneratorTest.java
   branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/impl/
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/model/change/ChoiceModelChangeRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.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/test/java/org/savara/bpel/generator/GeneratorTest.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.bpel/src/test/resources/results/bpel/ESBBroker at Broker.bpel
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Buyer.bpel
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at CreditAgency.bpel
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at SupplierTxnProcessor.bpel
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at Buyer.bpel
   branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at CreditAgency.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/java/org/savara/bundles/tests/bpel/generator/GeneratorTest.java
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Broker.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Buyer.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at CreditAgency.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at Buyer.bpel
   branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at CreditAgency.bpel
   branches/experimental/2.0.x/bundles/org.savara.contract/META-INF/MANIFEST.MF
   branches/experimental/2.0.x/bundles/org.savara.contract/pom.xml
   branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java
   branches/experimental/2.0.x/bundles/org.savara.contract/src/main/resources/org/savara/contract/Messages.properties
   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/test/java/org/savara/pi4soa/cdm/parser/CDMProtocolParserTest.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ESBBroker.spr
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/PurchaseGoods.spr
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ReqRespFault.spr
   branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF
   branches/experimental/2.0.x/bundles/org.savara.protocol/pom.xml
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/InteractionUtil.java
   branches/experimental/2.0.x/bundles/org.savara.wsdl/pom.xml
   branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
Log:
SAVARA-168 and SAVARA-169 - contracts provided as part of the context and contracts generated from local and global models.

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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/ProtocolToBPELModelGenerator.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -23,6 +23,10 @@
 import org.savara.bpel.model.TProcess;
 import org.savara.bpel.model.change.BPELModelChangeContext;
 import org.savara.common.model.generator.ModelGenerator;
+import org.savara.contract.model.Contract;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.scribble.common.resource.ResourceLocator;
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.common.logging.Journal;

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -38,6 +38,7 @@
 import org.savara.bpel.util.PartnerLinkUtil;
 import org.savara.bpel.util.VariableUtil;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.savara.protocol.model.util.InteractionUtil;
 import org.savara.contract.model.Contract;
 import org.savara.contract.model.Interface;

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -34,6 +34,7 @@
 import org.savara.bpel.util.PartnerLinkUtil;
 import org.savara.bpel.util.VariableUtil;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.savara.protocol.model.util.InteractionUtil;
 import org.savara.common.model.annotation.Annotation;
 import org.savara.common.model.annotation.AnnotationDefinitions;

Deleted: 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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,312 +0,0 @@
-/*
- * 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.bpel.model.change;
-
-import org.savara.protocol.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.
- */
-public class ModelChangeUtils {
-
-	/**
-	 * This method adds any contracts associated with roles defined in the
-	 * supplied conversation.
-	 * 
-	 * @param context The context
-	 * @param conv The conversation
-	 * @param root Whether this is the root conversation
-	 */
-	@SuppressWarnings("unchecked")
-	public static void addContracts(ModelChangeContext context, Protocol conv, boolean root) {
-		
-		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
-							context.getProperties().get(Contract.class.getName());
-		
-		if (contracts == null) {
-			contracts = new java.util.HashMap<String, Contract>();
-			
-			context.getProperties().put(Contract.class.getName(), contracts);
-		}
-		
-		if (conv.getRole() != null && root) {
-			addRoleContract(conv.getRole(), contracts);
-		}
-		
-		// Get list of roles
-		java.util.List<Role> roles=getRoles(conv);
-		
-		for (Role r : roles) {
-			addRoleContract(r, contracts);
-		}
-	}
-	
-	// NOTE: Return all the roles defined in the scope of this conversation
-	// Would be better to incrementally add contracts for roles, as defined
-	// in their own scope, but need to refactor how blocks are dealt with
-	// first - which is different in some cases, so not straightforward.
-	protected static java.util.List<Role> getRoles(final Protocol conv) {
-		final java.util.List<Role> roles=new java.util.Vector<Role>();
-		
-		conv.visit(new AbstractModelObjectVisitor() {
-
-			public boolean process(ModelObject obj) {
-				boolean ret=true;
-				
-				if (obj instanceof RoleList) {
-					roles.addAll(((RoleList)obj).getRoles());
-				} else if (obj instanceof Protocol &&
-						obj != conv) {
-					ret = false;
-				}
-				
-				return(ret);
-			}
-		});
-		
-		return(roles);
-	}
-	
-	/**
-	 * This method initializes the contract associated with the supplied role.
-	 * 
-	 * @param role The role
-	 * @param contracts The map of roles to contracts
-	 */
-	protected static void addRoleContract(Role role, java.util.Map<String,Contract> contracts) {
-		if (role != null && role.getProperties().containsKey(Contract.class.getName())) {
-			contracts.put(role.getName(),
-					(Contract)role.getProperties().get(Contract.class.getName()));
-		}
-	}
-
-	/**
-	 * This method removes the contract associated with the supplied role.
-	 * 
-	 * @param role The role
-	 * @param contracts The map of roles to contracts
-	 */
-	protected static void removeRoleContract(Role role, java.util.Map<String,Contract> contracts) {
-		if (role != null && role.getProperties().containsKey(Contract.class.getName())) {
-			contracts.remove(role.getName());
-		}
-	}
-
-	/**
-	 * This method removes any contracts associated with roles defined in the
-	 * supplied conversation.
-	 * 
-	 * @param context The context
-	 * @param conv The conversation
-	 * @param root Whether this is the root conversation
-	 */
-	@SuppressWarnings("unchecked")
-	public static void removeContracts(ModelChangeContext context, Protocol conv, boolean root) {
-		
-		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
-							context.getProperties().get(Contract.class.getName());
-		
-		if (contracts != null) {
-		
-			if (conv.getRole() != null && root) {
-				removeRoleContract(conv.getRole(), contracts);
-			}
-		
-			// Get list of roles
-			java.util.List<Role> roles=getRoles(conv);
-			
-			for (Role r : roles) {
-				removeRoleContract(r, contracts);
-			}
-		}
-	}
-	
-	/**
-	 * This method returns the contract associated with the supplied role.
-	 * 
-	 * @param contezt The context
-	 * @param roleName The role name
-	 * @return The contract, or null if not found
-	 */
-	@SuppressWarnings("unchecked")
-	public static Contract getContract(ModelChangeContext context, Role role) {
-		Contract ret=null;
-		
-		if (context.getProperties().containsKey(Contract.class.getName())) {
-			java.util.Map<String,Contract> contracts=
-					(java.util.Map<String,Contract>)
-					context.getProperties().get(Contract.class.getName());
-			
-			ret = contracts.get(role.getName());
-			
-			if (ret == null) {
-				ret = (Contract)role.getProperties().get(Contract.class.getName());
-			}
-		}
-		
-		return(ret);
-	}
-	
-	/**
-	 * This method updates the role mapping based on the supplied list of
-	 * declaration bindings.
-	 * 
-	 * @param context The context
-	 * @param run The run construct
-	 */
-	@SuppressWarnings("unchecked")
-	public static void pushRoleContractMapping(ModelChangeContext context,
-							Run run, Journal journal) {
-
-		if (context.getProperties().containsKey(Contract.class.getName())) {
-			java.util.Map<String,Contract> contracts=
-					(java.util.Map<String,Contract>)
-					context.getProperties().get(Contract.class.getName());
-
-			if (run.enclosingProtocol().getRole() != null &&
-					run.getProtocol().getRole() != null) {
-				Contract c=contracts.remove(run.enclosingProtocol().getRole().getName());
-				
-				if (c != null) {
-					contracts.put(run.getProtocol().getRole().getName(), c);
-				}
-			}
-		
-			// 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 (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());
-				}
-			}
-		}
-	}
-
-	/**
-	 * This method resets the role mapping based on the supplied list of
-	 * declaration bindings.
-	 * 
-	 * @param context The context
-	 * @param run The run construct
-	 */
-	@SuppressWarnings("unchecked")
-	public static void popRoleContractMapping(ModelChangeContext context,
-									Run run, Journal journal) {
-
-		if (context.getProperties().containsKey(Contract.class.getName())) {
-			java.util.Map<String,Contract> contracts=
-					(java.util.Map<String,Contract>)
-					context.getProperties().get(Contract.class.getName());
-
-			if (run.enclosingProtocol().getRole() != null &&
-					run.getProtocol().getRole() != null) {
-				Contract c=contracts.remove(run.getProtocol().getRole().getName());
-				
-				if (c != null) {
-					contracts.put(run.enclosingProtocol().getRole().getName(), c);
-				}
-			}
-			
-			// 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 (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/ProtocolModelChangeRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -24,6 +24,7 @@
 import org.savara.bpel.model.TSequence;
 import org.savara.bpel.util.ImportUtil;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.savara.contract.model.Contract;
 import org.savara.contract.model.Interface;
 import org.scribble.protocol.model.*;
@@ -163,8 +164,12 @@
 	 */
 	protected void addImport(ModelChangeContext context, TProcess bpelModel,
 								Protocol conv, Role role) {
-		if (role.getProperties().containsKey(Contract.class.getName())) {
-			Contract contract=(Contract)role.getProperties().get(Contract.class.getName());
+		
+		Contract contract=ModelChangeUtils.getContract(context, role);
+		
+		if (contract != null) {
+		//if (role.getProperties().containsKey(Contract.class.getName())) {
+			//Contract contract=(Contract)role.getProperties().get(Contract.class.getName());
 
 			boolean gen=false;
 			

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -17,7 +17,11 @@
  */
 package org.savara.bpel.model.change;
 
+import org.savara.contract.model.Contract;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.scribble.protocol.model.*;
 
 /**
@@ -82,11 +86,34 @@
 		ProtocolModel cm=(ProtocolModel)mobj;
 		
 		if (cm.getProtocol() != null) {
-			ModelChangeUtils.addContracts(context, cm.getProtocol(), true);
+			//ModelChangeUtils.addContracts(context, cm.getProtocol(), true);
+			
+			// Derive contracts for roles associated with the protocol model
+			ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
+			
+			if (cg != null) {
+				if (cm.getProtocol().getRole() != null) {
+					Contract c=cg.generate(cm.getProtocol(), null, cm.getProtocol().getRole(), context.getJournal());
+					
+					if (c != null) {
+						ModelChangeUtils.addContract(context, cm.getProtocol().getRole(), c);
+					}					
+				}
+				
+				java.util.List<Role> roles=cm.getRoles();
+				
+				for (Role r : roles) {
+					Contract c=cg.generate(cm.getProtocol(), null, r, context.getJournal());
+					
+					if (c != null) {
+						ModelChangeUtils.addContract(context, r, c);
+					}
+				}
+			}
 
 			context.insert(model, cm.getProtocol(), null);
 
-			ModelChangeUtils.removeContracts(context, cm.getProtocol(), true);
+			//ModelChangeUtils.removeContracts(context, cm.getProtocol(), true);
 		}
 		
 		return(true);

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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -21,6 +21,7 @@
 import org.savara.bpel.model.TScope;
 import org.savara.bpel.model.TSequence;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.scribble.protocol.model.*;
 
 /**
@@ -88,7 +89,7 @@
 			// Push details related to sub-choreo
 			ModelChangeUtils.pushRoleContractMapping(context, elem, context.getJournal());
 			
-			ModelChangeUtils.addContracts(context, elem.getProtocol(), false);
+			//ModelChangeUtils.addContracts(context, elem.getProtocol(), false);
 			
 			//context.insert(model, elem.getProtocol(), ref);
 			
@@ -123,7 +124,7 @@
 			context.setParent(parent);
 
 			// Pop details related to sub-choreo
-			ModelChangeUtils.removeContracts(context, elem.getProtocol(), false);
+			//ModelChangeUtils.removeContracts(context, elem.getProtocol(), false);
 			
 			ModelChangeUtils.popRoleContractMapping(context, elem, context.getJournal());
 		}

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/generator/GeneratorTest.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/generator/GeneratorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -28,11 +28,11 @@
 import org.savara.common.model.annotation.Annotation;
 import org.savara.common.model.annotation.AnnotationDefinitions;
 import org.savara.common.model.generator.ModelGenerator;
-import org.savara.contract.generator.ContractGenerator;
-import org.savara.contract.generator.ContractGeneratorFactory;
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.protocol.model.Role;
 import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
 import org.savara.protocol.util.ProtocolServices;
 
 public class GeneratorTest {
@@ -141,10 +141,12 @@
     					org.scribble.protocol.projection.ProtocolProjector projector=
     						new org.scribble.protocol.projection.impl.ProtocolProjectorImpl();
     					
+    					/* GPB: CONTRACT
    						ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
 						if (cg != null) {
 							cg.generate(model, journal, null);
 						}
+						*/
 						
 						org.scribble.protocol.model.ProtocolModel projected=
     									projector.project(model, role, journal, null);

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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -17,8 +17,8 @@
  */
 package org.savara.bpel.model.change;
 
-import org.savara.bpel.model.change.ModelChangeUtils;
 import org.savara.protocol.model.change.ModelChangeContext;
+import org.savara.protocol.model.change.ModelChangeUtils;
 import org.savara.contract.model.*;
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.protocol.model.*;
@@ -45,7 +45,7 @@
 		
 		conv.setRole(r);
 		
-		ModelChangeUtils.addContracts(context, conv, true);
+		ModelChangeUtils.addContract(context, r, c);
 		
 		Contract c2=ModelChangeUtils.getContract(context, new Role(MY_ROLE));
 		
@@ -70,7 +70,7 @@
 		
 		conv.setRole(r);
 		
-		ModelChangeUtils.addContracts(context, conv, true);
+		ModelChangeUtils.addContract(context, r, c);
 		
 		Protocol conv2=new Protocol();
 		Role r2=new Role();
@@ -81,7 +81,7 @@
 		
 		conv2.setRole(r2);
 		
-		ModelChangeUtils.addContracts(context, conv2, true);
+		ModelChangeUtils.addContract(context, r2, c2);
 		
 		Contract c3=ModelChangeUtils.getContract(context, new Role(MY_ROLE));
 		
@@ -125,7 +125,8 @@
 		rl.getRoles().add(r2);
 		conv.getBlock().getContents().add(rl);
 		
-		ModelChangeUtils.addContracts(context, conv, true);
+		ModelChangeUtils.addContract(context, r1, c1);
+		ModelChangeUtils.addContract(context, r2, c2);
 
 		Protocol subconv=new Protocol();
 		subconv.setName(SUB_PROTOCOL);
@@ -230,7 +231,8 @@
 		// Add contracts for subconv as if root, as normally
 		// this would be done by pushing the contracts, so this
 		// is just being used to setup the appropriate context
-		ModelChangeUtils.addContracts(context, subconv, true);
+		ModelChangeUtils.addContract(context, subr1, c1);
+		ModelChangeUtils.addContract(context, r3, c2);
 
 		Run run=new Run();
 		

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Broker.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Broker.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Broker.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -2,6 +2,7 @@
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker" name="ESBBrokerProcess_Broker">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BrokerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Buyer.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Buyer.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at Buyer.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,8 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Buyer" name="ESBBrokerProcess_Buyer">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
     <partnerLinks>
         <partnerLink partnerRole="BrokerRequester" partnerLinkType="byr:BuyerToBrokerLT" name="BuyerToBroker"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at CreditAgency.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at CreditAgency.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at CreditAgency.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency" name="ESBBrokerProcess_CreditAgency">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgencyArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at SupplierTxnProcessor.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at SupplierTxnProcessor.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/ESBBroker at SupplierTxnProcessor.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" name="ESBBrokerProcess_SupplierTxnProcessor">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessorArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <partnerLinks>
         <partnerLink myRole="SupplierTxnProcessor" partnerLinkType="spr:BrokerToSupplierTxnProcessorServiceLT" name="BrokerToSupplierTxnProcessor"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at Buyer.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at Buyer.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at Buyer.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sto="http://www.jboss.org/examples/store" xmlns:pur="java:org.jboss.savara.examples.purchasing" targetNamespace="http://www.jboss.org/savara/examples" name="PurchaseGoodsProcess_Buyer">
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_BuyerArtifacts.wsdl" namespace="http://www.jboss.org/savara/examples"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at CreditAgency.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at CreditAgency.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/resources/results/bpel/PurchaseGoods at CreditAgency.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sto="http://www.jboss.org/examples/store" xmlns:pur="java:org.jboss.savara.examples.purchasing" targetNamespace="java:org.jboss.savara.examples.purchasing" name="PurchaseGoodsProcess_CreditAgency">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Buyer.wsdl" namespace="http://www.jboss.org/savara/examples"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
     <partnerLinks>
         <partnerLink myRole="CreditAgency" partnerLinkType="pur:StoreToCreditAgencyServiceLT" name="StoreToCreditAgency"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/java/org/savara/bundles/tests/bpel/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/java/org/savara/bundles/tests/bpel/generator/GeneratorTest.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/java/org/savara/bundles/tests/bpel/generator/GeneratorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -28,11 +28,11 @@
 import org.savara.common.model.annotation.Annotation;
 import org.savara.common.model.annotation.AnnotationDefinitions;
 import org.savara.common.model.generator.ModelGenerator;
-import org.savara.contract.generator.ContractGenerator;
-import org.savara.contract.generator.ContractGeneratorFactory;
 import org.scribble.common.logging.CachedJournal;
 import org.scribble.protocol.model.Role;
 import org.savara.pi4soa.cdm.parser.CDMProtocolParser;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
 import org.savara.protocol.util.ProtocolServices;
 
 public class GeneratorTest {
@@ -140,10 +140,12 @@
     					org.scribble.protocol.projection.ProtocolProjector projector=
     						new org.scribble.protocol.projection.impl.ProtocolProjectorImpl();
     					
+    					/* GPB: CONTRACT
    						ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
 						if (cg != null) {
 							cg.generate(model, journal, null);
 						}
+						*/
 						
 						org.scribble.protocol.model.ProtocolModel projected=
     									projector.project(model, role, journal, null);

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Broker.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Broker.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Broker.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -2,6 +2,7 @@
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Broker" name="ESBBrokerProcess_Broker">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BrokerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Buyer.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Buyer.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at Buyer.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,8 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Buyer" name="ESBBrokerProcess_Buyer">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_BuyerArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
     <partnerLinks>
         <partnerLink partnerRole="BrokerRequester" partnerLinkType="byr:BuyerToBrokerLT" name="BuyerToBroker"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at CreditAgency.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at CreditAgency.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at CreditAgency.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/CreditAgency" name="ESBBrokerProcess_CreditAgency">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgencyArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/ESBBroker at SupplierTxnProcessor.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:spr="http://www.pi4soa.org/ESBBroker/Supplier" xmlns:tns="http://www.pi4soa.org/ESBBroker" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cay="http://www.pi4soa.org/ESBBroker/CreditAgency" xmlns:byr="http://www.pi4soa.org/ESBBroker/Buyer" xmlns:brk="http://www.pi4soa.org/ESBBroker/Broker" targetNamespace="http://www.pi4soa.org/ESBBroker/Supplier" name="ESBBrokerProcess_SupplierTxnProcessor">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessor.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Broker.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Broker"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Buyer.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Buyer"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_CreditAgency.wsdl" namespace="http://www.pi4soa.org/ESBBroker/CreditAgency"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_Supplier.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="ESBBrokerProcess_SupplierTxnProcessorArtifacts.wsdl" namespace="http://www.pi4soa.org/ESBBroker/Supplier"/>
     <partnerLinks>
         <partnerLink myRole="SupplierTxnProcessor" partnerLinkType="spr:BrokerToSupplierTxnProcessorServiceLT" name="BrokerToSupplierTxnProcessor"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at Buyer.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at Buyer.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at Buyer.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sto="http://www.jboss.org/examples/store" xmlns:pur="java:org.jboss.savara.examples.purchasing" targetNamespace="http://www.jboss.org/savara/examples" name="PurchaseGoodsProcess_Buyer">
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_BuyerArtifacts.wsdl" namespace="http://www.jboss.org/savara/examples"/>
     <partnerLinks>

Modified: branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at CreditAgency.bpel
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at CreditAgency.bpel	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.bundles.tests/src/test/resources/bpel/generator/results/PurchaseGoods at CreditAgency.bpel	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:tns="http://www.jboss.org/savara/examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sto="http://www.jboss.org/examples/store" xmlns:pur="java:org.jboss.savara.examples.purchasing" targetNamespace="java:org.jboss.savara.examples.purchasing" name="PurchaseGoodsProcess_CreditAgency">
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgency.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
-    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Store.wsdl" namespace="http://www.jboss.org/examples/store"/>
+    <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_Buyer.wsdl" namespace="http://www.jboss.org/savara/examples"/>
     <import importType="http://schemas.xmlsoap.org/wsdl/" location="PurchaseGoodsProcess_CreditAgencyArtifacts.wsdl" namespace="java:org.jboss.savara.examples.purchasing"/>
     <partnerLinks>
         <partnerLink myRole="CreditAgency" partnerLinkType="pur:StoreToCreditAgencyServiceLT" name="StoreToCreditAgency"/>

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/META-INF/MANIFEST.MF	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/META-INF/MANIFEST.MF	2011-01-26 00:04:53 UTC (rev 622)
@@ -9,7 +9,6 @@
 Import-Package: org.junit,
  org.osgi.framework
 Require-Bundle: org.scribble.common,
- org.savara.common,
- org.savara.protocol
+ org.savara.common
 Export-Package: org.savara.contract.generator,
  org.savara.contract.model

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/pom.xml
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/pom.xml	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/pom.xml	2011-01-26 00:04:53 UTC (rev 622)
@@ -29,11 +29,6 @@
 			<artifactId>org.savara.common</artifactId>
 			<version>${savara.version}</version>
 		</dependency>
-		<dependency>
-			<groupId>org.savara.bundles</groupId>
-			<artifactId>org.savara.protocol</artifactId>
-			<version>${savara.version}</version>
-		</dependency>
 	    <dependency>
 	      <groupId>org.apache.felix</groupId>
 	      <artifactId>org.osgi.core</artifactId>

Deleted: 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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGenerator.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,55 +0,0 @@
-/*
- * 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.contract.generator;
-
-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;
-
-/**
- * This interface represents the capability that generates a contract
- * from a protocol associated with a particular interacting role.
- * 
- */
-public interface ContractGenerator {
-
-	/**
-	 * This method creates contracts for the roles associated with the
-	 * supplied protocol model and associates them with the relevant
-	 * roles.
-	 * 
-	 * @param pm The protocol model
-	 * @param journal The journal
-	 * @param context The protocol context
-	 * @throws IllegalArgumentException
-	 */
-	public void generate(ProtocolModel pm, Journal journal, ProtocolContext context) throws IllegalArgumentException;
-	
-	/**
-	 * This method generates a contract associated with a supplied located
-	 * protocol.
-	 * 
-	 * @param cm The protocol
-	 * @param journal The journal
-	 * @return The contract
-	 */
-	public Contract generate(Protocol cm, Journal journal) throws IllegalArgumentException;
-	
-}

Deleted: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGeneratorFactory.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGeneratorFactory.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGeneratorFactory.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,38 +0,0 @@
-/*
- * 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.contract.generator;
-
-import org.savara.contract.generator.impl.ContractGeneratorImpl;
-
-/**
- * This class provides access to a contract generator.
- * 
- */
-public class ContractGeneratorFactory {
-
-	/**
-	 * This method returns an instance of the ContractGenerator
-	 * interface.
-	 * 
-	 * @return The contract generator
-	 */
-	public static ContractGenerator getContractGenerator() {
-		return(new ContractGeneratorImpl());
-	}
-	
-}

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -17,6 +17,11 @@
  */
 package org.savara.contract.model;
 
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Vector;
+
 /**
  * This class represents the contract.
  */
@@ -154,11 +159,31 @@
 		
 		buf.append("Contract {"+m_namespace+"}"+m_name+" {\r\n");
 		
-		for (TypeDefinition td : getTypeDefinitions()) {
+		// Sort type definitions, so output is consistent
+		java.util.List<TypeDefinition> tdlist=new Vector<TypeDefinition>(getTypeDefinitions());
+		
+		Collections.sort(tdlist, new Comparator<TypeDefinition>() {
+
+			public int compare(TypeDefinition arg0, TypeDefinition arg1) {
+				return(arg0.getName().compareTo(arg1.getName()));
+			}
+		});
+		
+		for (TypeDefinition td : tdlist) {
 			buf.append(td.toString());
 		}
 		
-		for (Interface intf : getInterfaces()) {
+		// Sort type definitions, so output is consistent
+		java.util.List<Interface> intflist=new Vector<Interface>(getInterfaces());
+		
+		Collections.sort(intflist, new Comparator<Interface>() {
+
+			public int compare(Interface arg0, Interface arg1) {
+				return(arg0.getName().compareTo(arg1.getName()));
+			}
+		});
+		
+		for (Interface intf : intflist) {
 			buf.append(intf.toString());
 		}
 		

Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/resources/org/savara/contract/Messages.properties
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/resources/org/savara/contract/Messages.properties	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/resources/org/savara/contract/Messages.properties	2011-01-26 00:04:53 UTC (rev 622)
@@ -18,3 +18,4 @@
 
 SAVARAPC-00001=Protocol must be supplied
 SAVARAPC-00002=Contract generation requires a protocol that represents the local behaviour associated with a particular role
+SAVARAPC-00003=Contract generation requires a server role

Deleted: branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/ContractGeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/ContractGeneratorTest.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/ContractGeneratorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,124 +0,0 @@
-package org.savara.contract.generator;
-
-import static org.junit.Assert.*;
-
-import org.savara.contract.generator.ContractGenerator;
-import org.savara.contract.generator.ContractGeneratorFactory;
-import org.savara.contract.model.Contract;
-import org.scribble.common.logging.CachedJournal;
-import org.scribble.common.logging.Journal;
-import org.scribble.protocol.model.Interaction;
-import org.scribble.protocol.model.MessageSignature;
-import org.scribble.protocol.model.Protocol;
-import org.scribble.protocol.model.Role;
-import org.scribble.protocol.model.TypeReference;
-
-public class ContractGeneratorTest {
-
-	@org.junit.Test
-	public void testGenerateProtocolNull() {
-		
-		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
-		
-		try {
-			Protocol conv=null;
-			
-			Journal journal=new CachedJournal();
-			
-			generator.generate(conv, journal);
-			
-			fail("Should have thrown IllegalArgumentException");
-			
-		} catch(IllegalArgumentException iae) {
-			// Test worked
-		}
-	}
-
-	@org.junit.Test
-	public void testGenerateProtocolNotLocated() {
-		
-		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
-		
-		try {
-			Protocol conv=new Protocol();
-			conv.setName("NonLocatedProtocol");
-			
-			Journal journal=new CachedJournal();
-			
-			generator.generate(conv, journal);
-			
-			fail("Should have thrown IllegalArgumentException");
-			
-		} catch(IllegalArgumentException iae) {
-			// Test worked
-		}
-	}
-
-	@org.junit.Test
-	public void testGenerateConversationAndRoleNotNull2() {
-		
-		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
-		
-		try {
-			Protocol conv=new Protocol();
-			conv.setRole(new Role());
-			conv.setName("LocatedProtocol");
-			
-			Journal journal=new CachedJournal();
-			
-			generator.generate(conv, journal);
-			
-		} catch(IllegalArgumentException iae) {			
-			fail("Should NOT have thrown IllegalArgumentException");
-		}
-	}
-
-	@org.junit.Test
-	public void testGenerateOneWayRequestSend() {
-		
-		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
-		
-		try {
-			Role fromRole=new Role();
-			fromRole.setName("from");
-			
-			Role toRole=new Role();
-			toRole.setName("to");
-			
-			Protocol conv=new Protocol();
-			conv.setRole(fromRole);
-			conv.setName("LocatedProtocol");
-			
-			Interaction interaction=new Interaction();
-			interaction.getToRoles().add(toRole);
-			
-			MessageSignature ms=new MessageSignature();			
-			ms.setOperation("op");
-			
-			interaction.setMessageSignature(ms);
-			
-			TypeReference tref1=new TypeReference();
-			tref1.setName("type");
-			ms.getTypeReferences().add(tref1);
-			
-			conv.getBlock().add(interaction);
-			
-			Journal journal=new CachedJournal();
-			
-			Contract c=generator.generate(conv, journal);
-					
-			if (c == null) {
-				fail("Contract is null");
-			}
-			
-			if (c.getInterfaces().size() != 1) {
-				fail("Only one interface expected");
-			}
-			
-			
-			
-		} catch(IllegalArgumentException iae) {			
-			fail("Should NOT have thrown IllegalArgumentException");
-		}
-	}
-}

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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ProtocolModelConverterRuleImpl.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -68,10 +68,39 @@
 				CDLTypeUtil.getURIFragment(cdlpack));
 		
 		// Convert information types into type imports
-		//for (org.pi4soa.cdl.InformationType itype : cdlpack.getTypeDefinitions().getInformationTypes()) {
+		for (org.pi4soa.cdl.InformationType itype : cdlpack.getTypeDefinitions().getInformationTypes()) {
+			setupTypeImport(itype, ret);
+			/*
+			// TODO: Create type import for the info type
+			TypeImportList til=new TypeImportList();
 			
-			// TODO: Create type import for the info type
-		//}
+			TypeImport ti=new TypeImport();
+			ti.setName(itype.getName());
+			
+			DataType dt=new DataType();
+			
+			if (itype.getElementName() != null && itype.getElementName().trim().length() > 0) {
+				String namespace=XMLUtils.getNamespace(itype.getElementName(), resolver, targetNamespace)
+				dt.setDetails(itype.getElementName());
+				
+				AnnotationDefinitions.createAnnotation(til.getProperties(),
+								AnnotationDefinitions.XSD_ELEMENT);
+			} else if (itype.getTypeName() != null && itype.getTypeName().trim().length() > 0) {
+				dt.setDetails(itype.getTypeName());
+				
+				AnnotationDefinitions.createAnnotation(til.getProperties(),
+								AnnotationDefinitions.XSD_TYPE);
+			}
+			
+			ti.setDataType(dt);
+			til.setFormat(TypeSystem.XSD);
+			til.getTypeImports().add(ti);
+			
+			// Check for schema location
+			
+			ret.getImports().add(til);
+			*/
+		}
 		
 		// Convert root choreography
 		java.util.Iterator<org.pi4soa.cdl.Choreography> iter=

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/CDMProtocolParserTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/CDMProtocolParserTest.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/CDMProtocolParserTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -44,7 +44,7 @@
 			
 			String spr=new String(os.toByteArray());
 			
-			spr = spr.replaceAll("\r\n", "\n");
+			//spr = spr.replaceAll("\r\n", "\n");
 			
 			java.io.InputStream is=
 				ClassLoader.getSystemResourceAsStream(sprFile);

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ESBBroker.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ESBBroker.spr	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ESBBroker.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,3 +1,4 @@
+import xsd "bookingReference" as BookingReference, "buy" as Buy, "cancel" as Cancel, "CreditCheckRequest" as CreditInformation, "CreditCheckInvalid" as CreditInvalid, "CreditCheckOk" as CreditValid, "enquiry" as Enquiry, "orderConfirmed" as OrderConfirmed, "orderRejected" as OrderRejected, "quote" as Quote, "quoteList" as QuoteList, "requestForQuote" as RequestForQuote;
 [[ Namespace(name=http://www.pi4soa.org/ESBBroker/Broker,role=Broker) ]]
 [[ Namespace(name=http://www.pi4soa.org/ESBBroker/Buyer,role=Buyer) ]]
 [[ Namespace(name=http://www.pi4soa.org/ESBBroker/CreditAgency,role=CreditAgency) ]]

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/PurchaseGoods.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/PurchaseGoods.spr	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/PurchaseGoods.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,3 +1,6 @@
+import xsd "{http://www.jboss.org/examples/store}BuyConfirmed" as BuyConfirmed, "{http://www.jboss.org/examples/store}BuyFailed" as BuyFailed, "{http://www.jboss.org/examples/store}BuyRequest" as BuyRequest from "http://www.jboss.org/examples/store";
+import xsd "{java:org.jboss.savara.examples.purchasing}CreditCheckInvalid" as CreditCheckInvalid, "{java:org.jboss.savara.examples.purchasing}CreditCheckOk" as CreditCheckOk, "{java:org.jboss.savara.examples.purchasing}CreditCheckRequest" as CreditCheckRequest from "java:org.jboss.savara.examples.purchasing";
+import xsd "{http://www.w3.org/2001/XMLSchema}string" as IDType, "{http://www.w3.org/2001/XMLSchema}anyURI" as URITokenType from "http://www.w3.org/2001/XMLSchema";
 [[ Namespace(name=http://www.jboss.org/savara/examples,role=Buyer) ]]
 [[ Namespace(name=java:org.jboss.savara.examples.purchasing,role=CreditAgency) ]]
 [[ Namespace(name=http://www.jboss.org/examples/store,role=Store) ]]

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ReqRespFault.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ReqRespFault.spr	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ReqRespFault.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -1,3 +1,4 @@
+import xsd "CreditCheckRequest" as CreditInformation, "CreditCheckInvalid" as CreditInvalid, "CreditCheckOk" as CreditValid;
 [[ Namespace(name=http://www.pi4soa.org/ReqRespFault/Buyer,role=Buyer) ]]
 [[ Namespace(name=http://www.pi4soa.org/ReqRespFault/Seller,role=Seller) ]]
 [[ Type(prefix=tns,namespace=http://www.pi4soa.org/ReqRespFault) ]]

Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF	2011-01-26 00:04:53 UTC (rev 622)
@@ -10,7 +10,9 @@
 Require-Bundle: org.scribble.common,
  org.scribble.protocol,
  org.savara.common,
- org.scribble.protocol.parser
-Export-Package: org.savara.protocol.model.annotation,
+ org.scribble.protocol.parser,
+ org.savara.contract
+Export-Package: org.savara.protocol.contract.generator,
+ org.savara.protocol.model.annotation,
  org.savara.protocol.model.change,
  org.savara.protocol.model.util

Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/pom.xml
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/pom.xml	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/pom.xml	2011-01-26 00:04:53 UTC (rev 622)
@@ -34,6 +34,11 @@
 			<artifactId>org.savara.common</artifactId>
 			<version>${savara.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.contract</artifactId>
+			<version>${savara.version}</version>
+		</dependency>
 	    <dependency>
 	      <groupId>org.apache.felix</groupId>
 	      <artifactId>org.osgi.core</artifactId>

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGenerator.java (from rev 617, 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.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGenerator.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGenerator.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,71 @@
+/*
+ * 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.protocol.contract.generator;
+
+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;
+import org.scribble.protocol.model.Role;
+
+/**
+ * This interface represents the capability that generates a contract
+ * from a protocol associated with a particular interacting role.
+ * 
+ */
+public interface ContractGenerator {
+
+	/**
+	 * This method creates contracts for the roles associated with the
+	 * supplied protocol model and associates them with the relevant
+	 * roles.
+	 * 
+	 * @param pm The protocol model
+	 * @param journal The journal
+	 * @param context The protocol context
+	 * @throws IllegalArgumentException
+	 */
+	//public void generate(ProtocolModel pm, Journal journal, ProtocolContext context) throws IllegalArgumentException;
+	
+	/**
+	 * This method generates a contract associated with a supplied located
+	 * protocol.
+	 * 
+	 * @param cm The located protocol
+	 * @param journal The journal
+	 * @return The contract
+	 */
+	public Contract generate(Protocol cm, Journal journal) throws IllegalArgumentException;
+	
+	/**
+	 * This method generates a contract, derived from the supplied protocol model,
+	 * associated with a supplied server role, optionally constrained by the supplied
+	 * client roles. If the client role is not specified, then the contract associated with
+	 * all relevant client roles will be generated.
+	 * 
+	 * @param cm The global or local (located) protocol
+	 * @param clients The optional client roles
+	 * @param server The server role
+	 * @param journal The journal
+	 * @return The contract
+	 */
+	public Contract generate(Protocol cm, java.util.Set<Role> clients, Role server, Journal journal)
+								throws IllegalArgumentException;
+	
+}

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGeneratorFactory.java (from rev 617, branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/ContractGeneratorFactory.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGeneratorFactory.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/ContractGeneratorFactory.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,38 @@
+/*
+ * 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.protocol.contract.generator;
+
+import org.savara.protocol.contract.generator.impl.ContractGeneratorImpl;
+
+/**
+ * This class provides access to a contract generator.
+ * 
+ */
+public class ContractGeneratorFactory {
+
+	/**
+	 * This method returns an instance of the ContractGenerator
+	 * interface.
+	 * 
+	 * @return The contract generator
+	 */
+	public static ContractGenerator getContractGenerator() {
+		return(new ContractGeneratorImpl());
+	}
+	
+}

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java (from rev 617, 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.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,98 @@
+/*
+ * 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.protocol.contract.generator.impl;
+
+import java.text.MessageFormat;
+
+import org.savara.contract.model.Contract;
+import org.savara.protocol.contract.generator.ContractGenerator;
+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;
+
+/**
+ * This class generates a contract from a protocol defining the behaviour of
+ * multiple interacting roles.
+ * 
+ */
+public class ContractGeneratorImpl implements ContractGenerator {
+
+	/**
+	 * This method generates a contract associated with a supplied located
+	 * protocol.
+	 * 
+	 * @param cm The protocol
+	 * @param journal The journal
+	 * @return The contract
+	 */
+	public Contract generate(Protocol cm, Journal journal) throws IllegalArgumentException {
+		if (cm == null) {
+			throw new IllegalArgumentException(MessageFormat.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.savara.contract.Messages").
+							getString("SAVARAPC-00001"), (Object)null));
+			
+		} else if (cm.getRole() == null) {
+			throw new IllegalArgumentException(MessageFormat.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.savara.contract.Messages").
+							getString("SAVARAPC-00002"), (Object)null));
+		}
+
+		return(generate(cm, null, cm.getRole(), journal));
+	}
+
+	/**
+	 * This method generates a contract, derived from the supplied protocol model,
+	 * associated with a supplied server role, optionally constrained by the supplied
+	 * client roles. If the client role is not specified, then the contract associated with
+	 * all relevant client roles will be generated.
+	 * 
+	 * @param cm The global or local (located) protocol
+	 * @param clients The optional client roles
+	 * @param server The server role
+	 * @param journal The journal
+	 * @return The contract
+	 */
+	public Contract generate(Protocol cm, java.util.Set<Role> clients, Role server, Journal journal)
+								throws IllegalArgumentException {
+		// Check parameters
+		if (cm == null) {
+			throw new IllegalArgumentException(MessageFormat.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.savara.contract.Messages").
+							getString("SAVARAPC-00001"), (Object)null));
+			
+		} else if (server == null) {
+			throw new IllegalArgumentException(MessageFormat.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.savara.contract.Messages").
+							getString("SAVARAPC-00003"), (Object)null));
+		}
+		
+		ContractIntrospector introspector=new ContractIntrospector(cm, clients, server, journal);
+		
+		introspector.process();
+		
+		return(introspector.getContract());
+	}
+	
+	
+}

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java (from rev 617, branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/generator/impl/ContractIntrospector.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,534 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.savara.protocol.contract.generator.impl;
+
+import java.text.MessageFormat;
+import java.util.logging.Logger;
+
+import org.savara.protocol.model.util.InteractionUtil;
+import org.savara.protocol.model.util.PropertyName;
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.annotation.AnnotationDefinitions;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.FaultDetails;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.MessageExchangePattern;
+import org.savara.contract.model.OneWayRequestMEP;
+import org.savara.contract.model.RequestResponseMEP;
+import org.savara.contract.model.Type;
+import org.savara.contract.model.TypeDefinition;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.AbstractModelObjectVisitor;
+import org.scribble.protocol.model.Choice;
+import org.scribble.protocol.model.DefaultVisitor;
+import org.scribble.protocol.model.Protocol;
+import org.scribble.protocol.model.Interaction;
+import org.scribble.protocol.model.Run;
+import org.scribble.protocol.model.ModelObject;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.model.TypeImport;
+import org.scribble.protocol.model.TypeImportList;
+import org.scribble.protocol.model.TypeReference;
+import org.scribble.protocol.model.When;
+import org.scribble.protocol.util.TypesUtil;
+
+/**
+ * This class examines a protocol to determine the contract that represents
+ * the static functional interface to the role's behaviour.
+ *
+ */
+public class ContractIntrospector extends DefaultVisitor {
+
+	private Contract m_contract=new Contract();
+	private java.util.Set<Protocol> m_processedProtocols=null;
+	private Role m_serverRole=null;
+	private java.util.Set<Role> m_clientRoles=null;
+	private Protocol m_protocol=null;
+	private Journal m_journal=null;
+	
+	private static Logger logger = Logger.getLogger(ContractIntrospector.class.getName());	
+	
+	/**
+	 * Constructor for the contract introspector.
+	 * 
+	 * @param protocol The protocol to introspect
+	 * @param clients The optional set of client roles
+	 * @param server The server role
+	 * @param journal The journal
+	 */
+	public ContractIntrospector(Protocol protocol, java.util.Set<Role> clients,
+					Role server, Journal journal) {
+		this(protocol, clients, server, null, null, journal);
+	}
+	
+	/**
+	 * Constructor for the contract introspector.
+	 * 
+	 * @param protocol The protocol being introspected
+	 * @param clients The optional set of client roles
+	 * @param server The server role
+	 * @param contract The optional contract being derived
+	 * @param processed The optional set of protocols currently processed
+	 */
+	public ContractIntrospector(Protocol protocol, java.util.Set<Role> clients,
+			Role server, Contract contract,	java.util.Set<Protocol> processed, Journal journal) {
+		m_contract = contract;
+		
+		m_clientRoles = clients;
+		m_serverRole = server;
+		
+		if (m_contract == null) {
+			m_contract = new Contract();
+			
+			m_contract.setName(m_serverRole.getName());
+					
+			java.util.List<Annotation> annotations=AnnotationDefinitions.getAnnotations(protocol.getProperties(),
+								AnnotationDefinitions.NAMESPACE);
+			if (annotations != null) {
+				for (Annotation annotation : annotations) {
+					String namespace=(String)annotation.getProperties().get(AnnotationDefinitions.NAME_PROPERTY);
+					String role=(String)annotation.getProperties().get(AnnotationDefinitions.ROLE_PROPERTY);
+				
+					if (namespace != null && role != null && role.equals(m_serverRole.getName())) {
+						m_contract.setNamespace(namespace);
+						break;
+					}	
+				}
+			}
+		}
+		
+		if (processed != null) {
+			m_processedProtocols = processed;
+		} else {
+			m_processedProtocols = new java.util.HashSet<Protocol>();
+		}
+		
+		m_protocol = protocol;
+	}
+	
+	/**
+	 * This method returns the contract being derived.
+	 * 
+	 * @return The contract
+	 */
+	public Contract getContract() {
+		return(m_contract);
+	}
+	
+	/**
+	 * This method returns the journal.
+	 * 
+	 * @return The journal
+	 */
+	public Journal getJournal() {
+		return(m_journal);
+	}
+	
+	/**
+	 * This method returns the interface.
+	 * 
+	 * @return The interface
+	 */
+	public Interface getInterface() {
+		Interface ret=getContract().getInterface(m_serverRole.getName());
+		
+		if (ret == null) {
+			// Create interface for the role
+			ret = new Interface();
+			ret.setName(m_serverRole.getName());
+			
+			// TODO: Need to consider how to manage different interfaces,
+			// in case the choreography has multiple interfaces. Each
+			// interaction could have an 'INTERFACE_NAME' property which
+			// could determine the interface - and if not defined default
+			// to using an interface named after the role
+			
+			/*
+			Annotation annotation=AnnotationDefinitions.getAnnotation(m_role.getProperties(),
+								AnnotationDefinitions.NAMESPACE);
+			if (annotation != null) {
+				String namespace=(String)annotation.getProperties().get(AnnotationDefinitions.NAME_PROPERTY);
+				
+				if (namespace != null) {
+					ret.setNamespace(namespace);
+				}
+			}
+			*/
+			ret.setNamespace(m_contract.getNamespace());
+			
+			getContract().getInterfaces().add(ret);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the set of processed protocols.
+	 * 
+	 * @return The processed protocols
+	 */
+	public java.util.Set<Protocol> getProcessedProtocols() {
+		return(m_processedProtocols);
+	}
+	
+	/**
+	 * This method introspects the supplied protocol to derive information
+	 * that can be used to define the functional contract for the role
+	 * associated with the protocol.
+	 * 
+	 * @param conv The located protocol
+	 */
+	public void process() throws IllegalStateException {
+		
+		if (m_protocol == null) {
+			throw new IllegalStateException(MessageFormat.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.savara.contract.Messages").
+							getString("SAVARAPC-00001"), (Object)null));
+		}
+		
+		m_protocol.visit(this);
+	}
+	
+
+	public boolean start(Protocol elem) {
+		// Only visit children if same protocol that is being visited
+		return(elem == m_protocol);
+	}
+
+	public boolean start(Run elem) {
+		Protocol toProtocol=elem.getProtocol();
+		
+		if (toProtocol != null) {
+			// Check if protocol already processed to avoid stack overflow
+			if (m_processedProtocols.contains(toProtocol) == false) {
+				m_processedProtocols.add(toProtocol);
+
+				// TODO: Need to map roles
+				Role mappedServerRole=m_serverRole;
+				java.util.Set<Role> mappedClientRoles=m_clientRoles;
+				
+				ContractIntrospector ci=new ContractIntrospector(toProtocol,
+							mappedClientRoles, mappedServerRole,
+							getContract(), getProcessedProtocols(), getJournal());
+					
+				ci.process();
+			} else {
+				logger.fine("Invoked definition not found for "+elem.getProtocolReference());
+			}
+		} else {
+			logger.fine("Run protocol not returned - possibly external");
+		}
+		
+		return(true);
+	}
+	
+	/*
+	public boolean process(ModelObject obj) {
+		boolean f_visitChildren=true;
+		
+		if (obj.getClass() == Protocol.class) {
+			
+			// Only visit children if same protocol that is being visited
+			f_visitChildren = (obj == m_protocol);
+			
+		} else if (obj.getClass() == Run.class) {
+			Run run=(Run)obj;
+			
+			Protocol toProtocol=run.getProtocol();
+			
+			if (toProtocol != null) {
+				// Check if protocol already processed to avoid stack overflow
+				if (m_processedProtocols.contains(toProtocol) == false) {
+					m_processedProtocols.add(toProtocol);
+	
+					// TODO: Need to map roles
+					Role mappedServerRole=m_serverRole;
+					java.util.Set<Role> mappedClientRoles=m_clientRoles;
+					
+					ContractIntrospector ci=new ContractIntrospector(toProtocol,
+								mappedClientRoles, mappedServerRole,
+								getContract(), getProcessedProtocols(), getJournal());
+						
+					ci.process();
+				} else {
+					logger.fine("Invoked definition not found for "+run.getProtocolReference());
+				}
+			} else {
+				logger.fine("Run protocol not returned - possibly external");
+			}
+		} else if (obj.getClass() == Interaction.class) {
+			accept((Interaction)obj);
+		}
+		
+		return(f_visitChildren);
+	}
+	*/
+
+	public void accept(Interaction interaction) {
+		
+		// Receiving a request - so record this in the contract
+		Interface intf=getInterface();
+
+		/*
+		// Check if the interacton is being received
+		if (interaction.getFromRole() != null &&
+				interaction.getFromRole().equals(m_role) == false) {
+			
+			// Received by the role, but need to check if its replyTo
+			// has been set, indicating it is receiving a response
+			if (InteractionUtil.getReplyToLabel(interaction) == null ||
+					InteractionUtil.getReplyToLabel(interaction).trim().length() == 0) {
+		*/
+		
+		// Check if receiving a request
+		if (InteractionUtil.isRequest(interaction) && !InteractionUtil.isSend(interaction, m_serverRole)) {
+				
+				if (interaction.getMessageSignature().getOperation() != null) {
+					
+					// Check if message exchange pattern exists for operation
+					MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+								interaction.getMessageSignature().getOperation());
+					
+					if (mep == null) {
+						// Create new MEP
+						if (InteractionUtil.getRequestLabel(interaction) != null) {
+							mep = new RequestResponseMEP();
+						} else {
+							mep = new OneWayRequestMEP();
+						}
+						
+						mep.setOperation(interaction.getMessageSignature().getOperation());
+						
+						for (int i=0; i < interaction.getMessageSignature().getTypeReferences().size(); i++) {
+							mep.getTypes().add(convertType(interaction.getMessageSignature().getTypeReferences().get(i)));
+						}
+						
+						intf.getMessageExchangePatterns().add(mep);
+					}
+				}
+
+			//} else {
+				
+			//}
+				
+		} else if (InteractionUtil.isResponse(interaction) && InteractionUtil.isSend(interaction, m_serverRole)) {
+			
+			if (interaction.getMessageSignature().getOperation() != null) {
+				
+				// Check if message exchange pattern exists for operation
+				MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+							interaction.getMessageSignature().getOperation());
+				
+				if (mep instanceof RequestResponseMEP) {
+					RequestResponseMEP rrmep=(RequestResponseMEP)mep;
+					
+					if (InteractionUtil.isFaultResponse(interaction)) {
+						String faultName=InteractionUtil.getFaultName(interaction);
+												
+						if (rrmep.getFaultDetails(faultName) == null) {
+							FaultDetails fd=new FaultDetails();
+							fd.setName(faultName);
+							
+							for (int i=0; i < interaction.getMessageSignature().getTypeReferences().size(); i++) {
+								fd.getTypes().add(convertType(interaction.getMessageSignature().getTypeReferences().get(i)));
+							}
+							
+							rrmep.getFaultDetails().add(fd);
+						}
+						
+					} else if (rrmep.getResponseTypes().size() == 0) {
+						
+						if (interaction.getMessageSignature().getTypeReferences().size() > 1) {
+							getJournal().error("Response has more than one type", null);
+						} else if (interaction.getMessageSignature().getTypeReferences().size() == 1) {
+							rrmep.getResponseTypes().add(convertType(
+									interaction.getMessageSignature().getTypeReferences().get(0)));
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method introspects the supplied interaction to generate Message Exchange
+	 * Patterns on the contract interface.
+	 * 
+	 * @param interaction The interaction
+	 */
+	public boolean start(When when) {	
+		
+		// Receiving a request - so record this in the contract
+		Interface intf=getInterface();
+
+		// Check if receiving a request
+		if (InteractionUtil.isRequest(when) && !InteractionUtil.isSend(when, m_serverRole)) {
+				
+			if (when.getMessageSignature().getOperation() != null) {
+				
+				// Check if message exchange pattern exists for operation
+				MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+						when.getMessageSignature().getOperation());
+				
+				if (mep == null) {
+					// Create new MEP
+					if (InteractionUtil.getRequestLabel(when) != null) {
+						mep = new RequestResponseMEP();
+					} else {
+						mep = new OneWayRequestMEP();
+					}
+					
+					mep.setOperation(when.getMessageSignature().getOperation());
+					
+					for (int i=0; i < when.getMessageSignature().getTypeReferences().size(); i++) {
+						mep.getTypes().add(convertType(when.getMessageSignature().getTypeReferences().get(i)));
+					}
+					
+					intf.getMessageExchangePatterns().add(mep);
+				}
+			}
+		} else if (InteractionUtil.isResponse(when) && InteractionUtil.isSend(when, m_serverRole)) {
+			
+			if (when.getMessageSignature().getOperation() != null) {
+				
+				// Check if message exchange pattern exists for operation
+				MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+						when.getMessageSignature().getOperation());
+				
+				if (mep instanceof RequestResponseMEP) {
+					RequestResponseMEP rrmep=(RequestResponseMEP)mep;
+					
+					if (InteractionUtil.isFaultResponse(when)) {
+						String faultName=InteractionUtil.getFaultName(when);
+												
+						if (rrmep.getFaultDetails(faultName) == null) {
+							FaultDetails fd=new FaultDetails();
+							fd.setName(faultName);
+							
+							for (int i=0; i < when.getMessageSignature().getTypeReferences().size(); i++) {
+								fd.getTypes().add(convertType(when.getMessageSignature().getTypeReferences().get(i)));
+							}
+							
+							rrmep.getFaultDetails().add(fd);
+						}
+						
+					} else if (rrmep.getResponseTypes().size() == 0) {
+						
+						if (when.getMessageSignature().getTypeReferences().size() > 1) {
+							getJournal().error("Response has more than one type", null);
+						} else if (when.getMessageSignature().getTypeReferences().size() == 1) {
+							rrmep.getResponseTypes().add(convertType(
+									when.getMessageSignature().getTypeReferences().get(0)));
+						}
+					}
+				}
+			}
+		}
+
+		/*
+		Choice choice=(Choice)when.getParent();
+		
+		// Check if the interacton is being received
+		if (choice.getFromRole() != null &&
+				choice.getFromRole().equals(m_role) == false) {
+			
+			// Received by the role, but need to check if its replyTo
+			// has been set, indicating it is receiving a response
+			if (InteractionUtil.getReplyToLabel(when) == null ||
+					InteractionUtil.getReplyToLabel(when).trim().length() == 0) {
+				
+				// Receiving a request - so record this in the contract
+				Interface intf=getInterface();
+				
+				if (when.getMessageSignature().getOperation() != null) {
+					
+					// Check if message exchange pattern exists for operation
+					MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(
+							when.getMessageSignature().getOperation());
+					
+					if (mep == null) {
+						// Create new MEP
+						if (InteractionUtil.getRequestLabel(when) != null) {
+							mep = new RequestResponseMEP();
+						} else {
+							mep = new OneWayRequestMEP();
+						}
+						
+						mep.setOperation(when.getMessageSignature().getOperation());
+						
+						for (int i=0; i < when.getMessageSignature().getTypeReferences().size(); i++) {
+							mep.getTypes().add(convertType(when.getMessageSignature().getTypeReferences().get(i)));
+						}
+						
+						intf.getMessageExchangePatterns().add(mep);
+					}
+				}
+
+			} else {
+				
+			}
+		}
+		*/
+		
+		return(true);
+	}
+	
+	/**
+	 * This method converts a protocol type reference into a contract model type.
+	 * 
+	 * @param tref The protocol type reference
+	 * @return The type
+	 */
+	public Type convertType(TypeReference tref) {
+		Type ret=new Type();
+		
+		if (getContract().getTypeDefinition(tref.getName()) == null) {
+			TypeDefinition td=new TypeDefinition();
+			td.setName(tref.getName());
+			
+			TypeImport ti=TypesUtil.getTypeImport(tref);
+			if (ti != null) {
+				TypeImportList til=(TypeImportList)ti.getParent();
+				
+				td.setDataType(ti.getDataType().getDetails());
+				
+				if (til != null) {
+					td.setTypeSystem(til.getFormat());
+				}
+			}
+			
+			//td.setDataType((String)tref.getProperties().get(PropertyName.DATA_TYPE));
+			
+			// Copy properties that may provide additional information about the type
+			td.getProperties().putAll(tref.getProperties());
+			
+			//td.setTypeSystem((String)tref.getProperties().get(PropertyName.TYPE_SYSTEM));
+			
+			getContract().getTypeDefinitions().add(td);
+		}
+		
+		ret.setName(tref.getName());
+		
+		return(ret);
+	}
+}

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/change/ModelChangeUtils.java (from rev 617, 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.protocol/src/main/java/org/savara/protocol/model/change/ModelChangeUtils.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/change/ModelChangeUtils.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,307 @@
+/*
+ * 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.protocol.model.change;
+
+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.
+ */
+public class ModelChangeUtils {
+
+	/**
+	 * This method adds any contracts associated with roles defined in the
+	 * supplied conversation.
+	 * 
+	 * @param context The context
+	 * @param conv The conversation
+	 * @param root Whether this is the root conversation
+	 */
+	//@SuppressWarnings("unchecked")
+	//public static void addContracts(ModelChangeContext context, Protocol conv, boolean root) {
+	public static void addContract(ModelChangeContext context, Role role, Contract contract) {
+		
+		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+							context.getProperties().get(Contract.class.getName());
+		
+		if (contracts == null) {
+			contracts = new java.util.HashMap<String, Contract>();
+			
+			context.getProperties().put(Contract.class.getName(), contracts);
+		}
+		
+		if (role != null && contract != null) {
+			addRoleContract(role, contract, contracts);
+		}
+	}
+	
+	// NOTE: Return all the roles defined in the scope of this conversation
+	// Would be better to incrementally add contracts for roles, as defined
+	// in their own scope, but need to refactor how blocks are dealt with
+	// first - which is different in some cases, so not straightforward.
+	protected static java.util.List<Role> getRoles(final Protocol conv) {
+		final java.util.List<Role> roles=new java.util.Vector<Role>();
+		
+		conv.visit(new AbstractModelObjectVisitor() {
+
+			public boolean process(ModelObject obj) {
+				boolean ret=true;
+				
+				if (obj instanceof RoleList) {
+					roles.addAll(((RoleList)obj).getRoles());
+				} else if (obj instanceof Protocol &&
+						obj != conv) {
+					ret = false;
+				}
+				
+				return(ret);
+			}
+		});
+		
+		return(roles);
+	}
+	
+	/**
+	 * This method initializes the contract associated with the supplied role.
+	 * 
+	 * @param role The role
+	 * @param contract The contract
+	 * @param contracts The map of roles to contracts
+	 */
+	protected static void addRoleContract(Role role, Contract contract, java.util.Map<String,Contract> contracts) {
+		if (role != null && contract != null) {
+			contracts.put(role.getName(), contract);
+		}
+	}
+
+	/**
+	 * This method removes the contract associated with the supplied role.
+	 * 
+	 * @param role The role
+	 * @param contracts The map of roles to contracts
+	 */
+	protected static void removeRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+		if (role != null) {
+			contracts.remove(role.getName());
+		}
+	}
+
+	/**
+	 * This method removes any contracts associated with roles defined in the
+	 * supplied conversation.
+	 * 
+	 * @param context The context
+	 * @param conv The conversation
+	 * @param root Whether this is the root conversation
+	 */
+	@SuppressWarnings("unchecked")
+	public static void removeContracts(ModelChangeContext context, Protocol conv, boolean root) {
+		
+		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+							context.getProperties().get(Contract.class.getName());
+		
+		if (contracts != null) {
+		
+			if (conv.getRole() != null && root) {
+				removeRoleContract(conv.getRole(), contracts);
+			}
+		
+			// Get list of roles
+			java.util.List<Role> roles=getRoles(conv);
+			
+			for (Role r : roles) {
+				removeRoleContract(r, contracts);
+			}
+		}
+	}
+	
+	/**
+	 * This method returns the contract associated with the supplied role.
+	 * 
+	 * @param contezt The context
+	 * @param roleName The role name
+	 * @return The contract, or null if not found
+	 */
+	@SuppressWarnings("unchecked")
+	public static Contract getContract(ModelChangeContext context, Role role) {
+		Contract ret=null;
+		
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+			
+			ret = contracts.get(role.getName());
+			
+			/*
+			if (ret == null) {
+				ret = (Contract)role.getProperties().get(Contract.class.getName());
+			}
+			*/
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method updates the role mapping based on the supplied list of
+	 * declaration bindings.
+	 * 
+	 * @param context The context
+	 * @param run The run construct
+	 */
+	@SuppressWarnings("unchecked")
+	public static void pushRoleContractMapping(ModelChangeContext context,
+							Run run, Journal journal) {
+
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+
+			if (run.enclosingProtocol().getRole() != null &&
+					run.getProtocol().getRole() != null) {
+				Contract c=contracts.remove(run.enclosingProtocol().getRole().getName());
+				
+				if (c != null) {
+					contracts.put(run.getProtocol().getRole().getName(), c);
+				}
+			}
+		
+			// 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 (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());
+				}
+			}
+		}
+	}
+
+	/**
+	 * This method resets the role mapping based on the supplied list of
+	 * declaration bindings.
+	 * 
+	 * @param context The context
+	 * @param run The run construct
+	 */
+	@SuppressWarnings("unchecked")
+	public static void popRoleContractMapping(ModelChangeContext context,
+									Run run, Journal journal) {
+
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+
+			if (run.enclosingProtocol().getRole() != null &&
+					run.getProtocol().getRole() != null) {
+				Contract c=contracts.remove(run.getProtocol().getRole().getName());
+				
+				if (c != null) {
+					contracts.put(run.enclosingProtocol().getRole().getName(), c);
+				}
+			}
+			
+			// 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 (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.protocol/src/main/java/org/savara/protocol/model/util/InteractionUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/InteractionUtil.java	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/InteractionUtil.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -71,20 +71,33 @@
 	}
 	
 	/**
-	 * This method determines whether the supplied interaction
-	 * is a send.
+	 * This method determines whether the supplied interaction,
+	 * within a located protocol, is a send.
 	 * 
 	 * @param interaction The interaction
 	 * @return Whether the interaction is a send
 	 */
 	public static boolean isSend(Interaction interaction) {
-		boolean ret=false;
 		Role role=null;
 		
 		if (interaction.enclosingProtocol() != null) {
 			role = interaction.enclosingProtocol().getRole();
 		}
 		
+		return(isSend(interaction, role));
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is a send.
+	 * 
+	 * @param interaction The interaction
+	 * @param role The located role
+	 * @return Whether the interaction is a send
+	 */
+	public static boolean isSend(Interaction interaction, Role role) {
+		boolean ret=false;
+		
 		if (role != null && ((interaction.getFromRole() != null &&
 				interaction.getFromRole().equals(
 						role)) ||
@@ -104,14 +117,27 @@
 	 * @param interaction The interaction
 	 * @return Whether the interaction is a send
 	 */
-	public static boolean isSend(When when) {
-		boolean ret=false;
+	public static boolean isSend(When when) {		
 		Role role=null;
 		
 		if (((Choice)when.getParent()).enclosingProtocol() != null) {
 			role = ((Choice)when.getParent()).enclosingProtocol().getRole();
 		}
 		
+		return(isSend(when, role));
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is a send.
+	 * 
+	 * @param interaction The interaction
+	 * @param role The located role
+	 * @return Whether the interaction is a send
+	 */
+	public static boolean isSend(When when, Role role) {
+		boolean ret=false;
+		
 		if (role != null && ((((Choice)when.getParent()).getFromRole() != null &&
 				((Choice)when.getParent()).getFromRole().equals(
 						role)) ||

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ContractGeneratorTest.java (from rev 617, branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/ContractGeneratorTest.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ContractGeneratorTest.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ContractGeneratorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,124 @@
+package org.savara.protocol.contract.generator;
+
+import static org.junit.Assert.*;
+
+import org.savara.contract.model.Contract;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.Interaction;
+import org.scribble.protocol.model.MessageSignature;
+import org.scribble.protocol.model.Protocol;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.model.TypeReference;
+
+public class ContractGeneratorTest {
+
+	@org.junit.Test
+	public void testGenerateProtocolNull() {
+		
+		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+		
+		try {
+			Protocol conv=null;
+			
+			Journal journal=new CachedJournal();
+			
+			generator.generate(conv, journal);
+			
+			fail("Should have thrown IllegalArgumentException");
+			
+		} catch(IllegalArgumentException iae) {
+			// Test worked
+		}
+	}
+
+	@org.junit.Test
+	public void testGenerateProtocolNotLocated() {
+		
+		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+		
+		try {
+			Protocol conv=new Protocol();
+			conv.setName("NonLocatedProtocol");
+			
+			Journal journal=new CachedJournal();
+			
+			generator.generate(conv, journal);
+			
+			fail("Should have thrown IllegalArgumentException");
+			
+		} catch(IllegalArgumentException iae) {
+			// Test worked
+		}
+	}
+
+	@org.junit.Test
+	public void testGenerateConversationAndRoleNotNull2() {
+		
+		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+		
+		try {
+			Protocol conv=new Protocol();
+			conv.setRole(new Role());
+			conv.setName("LocatedProtocol");
+			
+			Journal journal=new CachedJournal();
+			
+			generator.generate(conv, journal);
+			
+		} catch(IllegalArgumentException iae) {			
+			fail("Should NOT have thrown IllegalArgumentException");
+		}
+	}
+
+	@org.junit.Test
+	public void testGenerateOneWayRequestSend() {
+		
+		ContractGenerator generator=ContractGeneratorFactory.getContractGenerator();
+		
+		try {
+			Role fromRole=new Role();
+			fromRole.setName("from");
+			
+			Role toRole=new Role();
+			toRole.setName("to");
+			
+			Protocol conv=new Protocol();
+			conv.setRole(fromRole);
+			conv.setName("LocatedProtocol");
+			
+			Interaction interaction=new Interaction();
+			interaction.getToRoles().add(toRole);
+			
+			MessageSignature ms=new MessageSignature();			
+			ms.setOperation("op");
+			
+			interaction.setMessageSignature(ms);
+			
+			TypeReference tref1=new TypeReference();
+			tref1.setName("type");
+			ms.getTypeReferences().add(tref1);
+			
+			conv.getBlock().add(interaction);
+			
+			Journal journal=new CachedJournal();
+			
+			Contract c=generator.generate(conv, journal);
+					
+			if (c == null) {
+				fail("Contract is null");
+			}
+			
+			if (c.getInterfaces().size() != 1) {
+				fail("Only one interface expected");
+			}
+			
+			
+			
+		} catch(IllegalArgumentException iae) {			
+			fail("Should NOT have thrown IllegalArgumentException");
+		}
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,237 @@
+/*
+ * 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.protocol.contract.generator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.annotation.AnnotationDefinitions;
+import org.savara.common.model.generator.ModelGenerator;
+import org.savara.contract.model.Contract;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
+import org.savara.protocol.util.ProtocolServices;
+
+public class GeneratorTest {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Protocol->Contract Generator Tests");
+
+        suite.addTest(new ProtocolToContractTester("ESBBroker", "Broker"));
+        suite.addTest(new ProtocolToContractTester("ESBBroker", "Buyer"));     
+        suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierTxnProcessor"));
+        suite.addTest(new ProtocolToContractTester("ESBBroker", "CreditAgency"));
+        suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierQuoteEngine"));
+        
+        suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Buyer"));
+        suite.addTest(new ProtocolToContractTester("PurchaseGoods", "CreditAgency"));
+        suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Store"));
+        
+        suite.addTest(new ProtocolToContractTester("ReqRespFault", "Buyer"));
+        suite.addTest(new ProtocolToContractTester("ReqRespFault", "Seller"));
+        
+        return suite;
+    }
+    
+    protected static class ProtocolToContractTester extends TestCase {
+
+    	/**
+    	 * This constructor is initialized with the test
+    	 * name.
+    	 * 
+    	 * @param name The test name
+    	 * @param role The role
+    	 */
+    	public ProtocolToContractTester(String name,
+    						String role) {
+    		super(name+"@"+role);
+    		m_name = name;
+    		m_role = role;
+    	}
+    	
+    	/**
+    	 * This method runs the test.
+    	 * 
+    	 * @param result The test result
+    	 */
+    	public void run(TestResult result) {
+    		
+    		// Run test
+    		result.startTest(this);
+    		
+    		String filename="testmodels/protocol/"+m_name+".spr";
+    		
+    		java.io.InputStream is=
+    			ClassLoader.getSystemResourceAsStream(filename);
+    		
+    		if (is == null) {
+    			result.addError(this,
+    					new Throwable("Unable to locate resource: "+filename));
+    		} else {			
+    			CachedJournal journal=new CachedJournal();
+    			
+    			org.scribble.protocol.model.ProtocolModel model=null;
+    			
+				ANTLRProtocolParser parser=new ANTLRProtocolParser();
+				parser.addAnnotationProcessor(new org.savara.protocol.parser.AnnotationProcessor());
+				
+    			try {
+    				model = parser.parse(is, journal, null);
+    			} catch(Exception e) {
+    				result.addError(this, new Throwable("Parsing choreography failed"));
+    			}
+    			
+    			if (model == null) {
+    				result.addError(this, new Throwable("Model is null"));
+    			} else {
+   					ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
+					if (cg != null) {
+						Contract contract=cg.generate(model.getProtocol(), null, new Role(m_role), journal);
+						
+						if (contract != null) {
+							checkResults(result, contract.toString());
+						} else {
+							result.addError(this, new Throwable("No contract"));
+						}
+					}
+    			}
+    		}
+    		
+    		result.endTest(this);
+    	}
+    	
+    	/**
+    	 * This method checks the generated BPEL against a
+    	 * previously stored correct version.
+    	 * 
+    	 * @param result The test result
+    	 * @param bpel The BPEL
+    	 */
+    	protected void checkResults(TestResult result, String bpel) {
+    		boolean f_valid=false;
+
+    		String filename="results/contract/"+m_name+"@"+m_role+".contract";
+    		
+    		java.io.InputStream is=
+    			//ChoreographyToBPELTester.class.getResourceAsStream(filename);
+    				ClassLoader.getSystemResourceAsStream(filename);
+    		
+    		if (is != null) {
+    			
+    			try {
+    				byte[] b=new byte[is.available()];
+    			
+    				is.read(b);
+    				
+    				is.close();
+    				
+    				String orig=new String(b);
+    				
+    				if (orig.equals(bpel) == false) {
+    					result.addError(this,
+    							new Throwable("Generated Contract does not match stored version"));
+    				} else {
+    					f_valid = true;
+    				}
+    			} catch(Exception e) {
+    				result.addError(this, e);
+    			}
+    		} else {
+    			result.addError(this,
+    					new Throwable("Resulting Contract '"+filename+
+    							"' not found for comparison"));
+    		}
+    		
+    		if (f_valid == false) {
+    			String srcfile="testmodels/protocol/"+m_name+".spr";
+    			
+    			java.net.URL url=ClassLoader.getSystemResource(srcfile);
+    			
+    			/*
+    			try {
+    				url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
+    			} catch(Exception e) {
+    				e.printStackTrace();
+    			}
+    			*/
+    			
+    			if (url != null) {
+    				// URL will point to copy of test models in the classes folder, so need
+    				// to obtain reference back to source version
+    				java.io.File f=null;
+    				
+    				if (url.getFile().indexOf("target/test-classes") != -1) {
+    					f = new java.io.File(url.getFile().replaceFirst("target/test-classes","src/test/resources"));
+    				} if (url.getFile().indexOf("target/classes") != -1) {
+    					f = new java.io.File(url.getFile().replaceFirst("target/classes","src/test/resources"));
+    				} else if (url.getFile().indexOf("classes") != -1) {
+        				f = new java.io.File(url.getFile().replaceFirst("classes","src/test/resources"));
+    				} else if (url.getFile().indexOf("bin") != -1) {						
+    					f = new java.io.File(url.getFile().replaceFirst("bin","src/test/resources"));
+    				} else {
+    					result.addError(this, new Exception("Could not locate results folder to record expected result"));
+    				}
+    				
+    				if (f != null && f.exists()) {
+    					f = f.getParentFile().getParentFile().getParentFile();
+    					
+    					java.io.File resultsDir=new java.io.File(f, "results/contract");
+    					
+    					if (resultsDir.exists() == false) {
+    						resultsDir.mkdirs();
+    					}
+    					
+    					java.io.File resultFile=new java.io.File(resultsDir,
+    										m_name+"@"+m_role+".generated");
+    					
+    					//if (resultFile.exists() == false) {
+    						try {
+    							java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+    							
+    							fos.write(bpel.getBytes());
+    							
+    							fos.flush();
+    							fos.close();
+    							
+    						} catch(Exception e){
+    							result.addError(this, e);
+    						}
+    						/*
+    					} else {
+    						System.err.println("NOTE: Generated output '"+resultFile+
+    									"' already exists - not being overwritten");
+    					}
+    					*/
+    				} else {
+    					result.addError(this, new Throwable("Unable to obtain URL for model source '"+
+    							m_name+"': "+url));
+    				}
+    			}
+    		}
+    	}
+
+    	private String m_name=null;
+    	private String m_role=null;
+    }
+}

Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/impl/ContractIntrospectorTest.java (from rev 617, branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/impl/ContractIntrospectorTest.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/impl/ContractIntrospectorTest.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/impl/ContractIntrospectorTest.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,300 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.savara.protocol.contract.generator.impl;
+
+import org.savara.protocol.contract.generator.impl.ContractIntrospector;
+import org.savara.protocol.model.util.PropertyName;
+import org.savara.common.model.annotation.Annotation;
+import org.savara.common.model.annotation.AnnotationDefinitions;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.MessageExchangePattern;
+import org.savara.contract.model.OneWayRequestMEP;
+import org.savara.contract.model.RequestResponseMEP;
+import org.savara.contract.model.Type;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.Protocol;
+import org.scribble.protocol.model.Interaction;
+import org.scribble.protocol.model.ProtocolReference;
+import org.scribble.protocol.model.Run;
+import org.scribble.protocol.model.MessageSignature;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.model.TypeReference;
+import org.scribble.protocol.util.InteractionUtil;
+
+import static org.junit.Assert.*;
+
+public class ContractIntrospectorTest {
+
+	private static final String MY_ROLE = "myRole";
+	private static final String TYPE_NS = "typeNS";
+	private static final String TYPE_LP = "typeLP";
+	private static final String OP_NAME = "opName";
+
+	@org.junit.Test
+	public void testNoSubProtocolWithoutRun() {
+		Role r=new Role();
+		r.setName("role");
+		
+		Protocol top=new Protocol();
+		top.setName("top");
+		top.setRole(r);
+		
+		Protocol mid=new Protocol();
+		mid.setName("mid");
+		mid.setRole(r);
+		
+		Protocol sub=new Protocol();
+		sub.setName("sub");
+		sub.setRole(r);
+		
+		ProtocolReference ref=new ProtocolReference();
+		ref.setName("sub");
+		ref.setRole(r);
+		
+		Run run=new Run();
+		run.setProtocolReference(ref);
+		
+		top.getBlock().getContents().add(mid);
+		
+		mid.getBlock().getContents().add(run);
+		mid.getBlock().getContents().add(sub);
+		
+		Journal journal=new CachedJournal();
+		
+		ContractIntrospector introspector=new ContractIntrospector(top, null, r, journal);
+		
+		introspector.process();
+		
+		if (introspector.getProcessedProtocols().size() != 0) {
+			fail("Expecting 0 processed protocol, but got: "+introspector.getProcessedProtocols().size());
+		}
+	}
+	
+	@org.junit.Test
+	public void testSubProtocolWithRun() {
+		Role r=new Role();
+		r.setName("role");
+		
+		Protocol top=new Protocol();
+		top.setName("top");
+		top.setRole(r);
+		
+		Protocol mid=new Protocol();
+		mid.setName("mid");
+		mid.setRole(r);
+		
+		Protocol sub=new Protocol();
+		sub.setName("sub");
+		sub.setRole(r);
+		
+		ProtocolReference ref1=new ProtocolReference();
+		ref1.setName("mid");
+		ref1.setRole(r);
+		
+		Run run1=new Run();
+		run1.setProtocolReference(ref1);
+		
+		top.getBlock().getContents().add(run1);
+		top.getBlock().getContents().add(mid);
+		
+		ProtocolReference ref2=new ProtocolReference();
+		ref2.setName("sub");
+		ref2.setRole(r);
+		
+		Run run2=new Run();
+		run2.setProtocolReference(ref2);
+		
+		mid.getBlock().getContents().add(run2);
+		mid.getBlock().getContents().add(sub);
+		
+		Journal journal=new CachedJournal();
+		
+		ContractIntrospector introspector=new ContractIntrospector(top, null, r, journal);
+		
+		introspector.process();
+		
+		if (introspector.getProcessedProtocols().size() != 2) {
+			fail("Expecting 2 processed protocol, but got: "+introspector.getProcessedProtocols().size());
+		}
+		
+		if (introspector.getProcessedProtocols().contains(mid) == false) {
+			fail("Should contain mid");
+		}
+		
+		if (introspector.getProcessedProtocols().contains(sub) == false) {
+			fail("Should contain sub");
+		}
+	}
+	
+	@org.junit.Test
+	public void testCreateSingleInterface() {
+		Protocol protocol=new Protocol();
+		Role role=new Role();
+		role.setName(MY_ROLE);
+		protocol.setRole(role);
+		
+		Journal journal=new CachedJournal();
+		
+		ContractIntrospector introspector=new ContractIntrospector(protocol, null, role, journal);
+		
+		if (introspector.getContract().getInterfaces().size() != 0) {
+			fail("Should be 0 interfaces: "+introspector.getContract().getInterfaces().size());
+		}
+		
+		Interface intf=introspector.getInterface();
+		
+		if (intf == null) {
+			fail("Interface not created");
+		}
+		
+		if (introspector.getContract().getInterfaces().size() != 1) {
+			fail("Should be 1 interface: "+introspector.getContract().getInterfaces().size());
+		}
+		
+		Interface intf2=introspector.getInterface();
+		
+		if (intf2 != intf) {
+			fail("Interfaces are different");
+		}
+		
+		if (introspector.getContract().getInterfaces().size() != 1) {
+			fail("Should still only be 1 interface: "+introspector.getContract().getInterfaces().size());
+		}
+	}
+	
+	@org.junit.Test
+	public void testVisitInteractionOneWayRequestRPC() {
+		Protocol protocol=new Protocol();
+		Role role=new Role();
+		role.setName(MY_ROLE);
+		protocol.setRole(role);
+		
+		Journal journal=new CachedJournal();
+		
+		ContractIntrospector introspector=new ContractIntrospector(protocol, null, role, journal);
+		
+		Interaction interaction=new Interaction();
+		
+		MessageSignature msig=new MessageSignature();
+		msig.setOperation(OP_NAME);
+		
+		TypeReference tref=new TypeReference();
+		tref.setName(TYPE_LP);
+		//tref.setNamespace(TYPE_NS);
+		msig.getTypeReferences().add(tref);
+		
+		interaction.setMessageSignature(msig);
+		interaction.setFromRole(new Role());
+		
+		introspector.accept(interaction);
+		
+		Contract contract=introspector.getContract();
+		
+		Interface intf=contract.getInterface(role.getName());
+		
+		if (intf == null) {
+			fail("Interface '"+role.getName()+"' not found");
+		}
+		
+		MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(OP_NAME);
+		
+		if (mep == null) {
+			fail("Operation '"+OP_NAME+"' not found");
+		}
+		
+		if ((mep instanceof OneWayRequestMEP) == false) {
+			fail("Not a oneway request");
+		}
+		
+		if (mep.getTypes().size() != 1) {
+			fail("One type expected, but got: "+mep.getTypes().size());
+		}
+		
+		Type t=mep.getTypes().get(0);
+		
+		if (t.getName().equals(TYPE_LP) == false) {
+			fail("Type name not correct: "+t.getName());
+		}
+	}
+	
+	
+	@org.junit.Test
+	public void testVisitInteractionRequestResponseRPCOnlyRequest() {
+		Protocol protocol=new Protocol();
+		Role role=new Role();
+		role.setName(MY_ROLE);
+		protocol.setRole(role);
+		
+		Journal journal=new CachedJournal();
+		
+		ContractIntrospector introspector=new ContractIntrospector(protocol, null, role, journal);
+		
+		Interaction interaction=new Interaction();
+		
+		MessageSignature msig=new MessageSignature();
+		msig.setOperation(OP_NAME);
+		
+		TypeReference tref=new TypeReference();
+		tref.setName(TYPE_LP);
+		//tref.setNamespace(TYPE_NS);
+		msig.getTypeReferences().add(tref);
+		
+		interaction.setMessageSignature(msig);
+		interaction.setFromRole(new Role());
+		
+		Annotation annotation=AnnotationDefinitions.createAnnotation(interaction.getProperties(),
+				AnnotationDefinitions.CORRELATION);
+		annotation.getProperties().put(AnnotationDefinitions.REQUEST_PROPERTY, "label");
+		
+		introspector.accept(interaction);
+		
+		Contract contract=introspector.getContract();
+		
+		Interface intf=contract.getInterface(role.getName());
+		
+		if (intf == null) {
+			fail("Interface '"+role.getName()+"' not found");
+		}
+		
+		MessageExchangePattern mep=intf.getMessageExchangePatternForOperation(OP_NAME);
+		
+		if (mep == null) {
+			fail("Operation '"+OP_NAME+"' not found");
+		}
+		
+		if ((mep instanceof RequestResponseMEP) == false) {
+			fail("Not a request/response MEP");
+		}
+		
+		if (mep.getTypes().size() != 1) {
+			fail("One type expected, but got: "+mep.getTypes().size());
+		}
+		
+		Type t=mep.getTypes().get(0);
+		
+		if (t.getName().equals(TYPE_LP) == false) {
+			fail("Type name not correct: "+t.getName());
+		}
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Broker.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Broker.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Broker.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,13 @@
+Contract {http://www.pi4soa.org/ESBBroker/Broker}Broker {
+	TypeDef BookingReference type=bookingReference location=null typeSystem=xsd
+	TypeDef Buy type=buy location=null typeSystem=xsd
+	TypeDef Cancel type=cancel location=null typeSystem=xsd
+	TypeDef Enquiry type=enquiry location=null typeSystem=xsd
+	TypeDef OrderRejected type=orderRejected location=null typeSystem=xsd
+	TypeDef QuoteList type=quoteList location=null typeSystem=xsd
+	Interface {http://www.pi4soa.org/ESBBroker/Broker}Broker {
+		RequestResponseMEP makeEnquiry( Enquiry ) : QuoteList 
+		RequestResponseMEP buy( Buy ) : BookingReference Fault rejected( OrderRejected ) 
+		OneWayRequestMEP cancel( Cancel )
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Buyer.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Buyer.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at Buyer.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,4 @@
+Contract {http://www.pi4soa.org/ESBBroker/Buyer}Buyer {
+	Interface {http://www.pi4soa.org/ESBBroker/Buyer}Buyer {
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at CreditAgency.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at CreditAgency.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at CreditAgency.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,8 @@
+Contract {http://www.pi4soa.org/ESBBroker/CreditAgency}CreditAgency {
+	TypeDef CreditInformation type=CreditCheckRequest location=null typeSystem=xsd
+	TypeDef CreditInvalid type=CreditCheckInvalid location=null typeSystem=xsd
+	TypeDef CreditValid type=CreditCheckOk location=null typeSystem=xsd
+	Interface {http://www.pi4soa.org/ESBBroker/CreditAgency}CreditAgency {
+		RequestResponseMEP checkCredit( CreditInformation ) : CreditValid Fault invalidCredit( CreditInvalid ) 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierQuoteEngine.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierQuoteEngine.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierQuoteEngine.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,7 @@
+Contract {http://www.pi4soa.org/ESBBroker/Supplier}SupplierQuoteEngine {
+	TypeDef Quote type=quote location=null typeSystem=xsd
+	TypeDef RequestForQuote type=requestForQuote location=null typeSystem=xsd
+	Interface {http://www.pi4soa.org/ESBBroker/Supplier}SupplierQuoteEngine {
+		RequestResponseMEP getQuote( RequestForQuote ) : Quote 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierTxnProcessor.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierTxnProcessor.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ESBBroker at SupplierTxnProcessor.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,7 @@
+Contract {http://www.pi4soa.org/ESBBroker/Supplier}SupplierTxnProcessor {
+	TypeDef BookingReference type=bookingReference location=null typeSystem=xsd
+	TypeDef OrderConfirmed type=orderConfirmed location=null typeSystem=xsd
+	Interface {http://www.pi4soa.org/ESBBroker/Supplier}SupplierTxnProcessor {
+		RequestResponseMEP confirm( OrderConfirmed ) : BookingReference 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Buyer.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Buyer.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Buyer.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,4 @@
+Contract {http://www.jboss.org/savara/examples}Buyer {
+	Interface {http://www.jboss.org/savara/examples}Buyer {
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,8 @@
+Contract {java:org.jboss.savara.examples.purchasing}CreditAgency {
+	TypeDef CreditCheckInvalid type={java:org.jboss.savara.examples.purchasing}CreditCheckInvalid location=null typeSystem=xsd
+	TypeDef CreditCheckOk type={java:org.jboss.savara.examples.purchasing}CreditCheckOk location=null typeSystem=xsd
+	TypeDef CreditCheckRequest type={java:org.jboss.savara.examples.purchasing}CreditCheckRequest location=null typeSystem=xsd
+	Interface {java:org.jboss.savara.examples.purchasing}CreditAgency {
+		RequestResponseMEP checkCredit( CreditCheckRequest ) : CreditCheckOk Fault CreditCheckFailed( CreditCheckInvalid ) 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,8 @@
+Contract {http://www.jboss.org/examples/store}Store {
+	TypeDef BuyConfirmed type={http://www.jboss.org/examples/store}BuyConfirmed location=null typeSystem=xsd
+	TypeDef BuyFailed type={http://www.jboss.org/examples/store}BuyFailed location=null typeSystem=xsd
+	TypeDef BuyRequest type={http://www.jboss.org/examples/store}BuyRequest location=null typeSystem=xsd
+	Interface {http://www.jboss.org/examples/store}Store {
+		RequestResponseMEP buy( BuyRequest ) : BuyConfirmed Fault BuyFailed( BuyFailed ) 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Buyer.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Buyer.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Buyer.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,4 @@
+Contract {http://www.pi4soa.org/ReqRespFault/Buyer}Buyer {
+	Interface {http://www.pi4soa.org/ReqRespFault/Buyer}Buyer {
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Seller.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Seller.contract	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/ReqRespFault at Seller.contract	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,8 @@
+Contract {http://www.pi4soa.org/ReqRespFault/Seller}Seller {
+	TypeDef CreditInformation type=CreditCheckRequest location=null typeSystem=xsd
+	TypeDef CreditInvalid type=CreditCheckInvalid location=null typeSystem=xsd
+	TypeDef CreditValid type=CreditCheckOk location=null typeSystem=xsd
+	Interface {http://www.pi4soa.org/ReqRespFault/Seller}Seller {
+		RequestResponseMEP checkCredit( CreditInformation ) : CreditValid Fault insufficientCredit( CreditInvalid ) 
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ESBBroker.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ESBBroker.spr	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ESBBroker.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,100 @@
+import xsd "bookingReference" as BookingReference, "buy" as Buy, "cancel" as Cancel, "CreditCheckRequest" as CreditInformation, "CreditCheckInvalid" as CreditInvalid, "CreditCheckOk" as CreditValid, "enquiry" as Enquiry, "orderConfirmed" as OrderConfirmed, "orderRejected" as OrderRejected, "quote" as Quote, "quoteList" as QuoteList, "requestForQuote" as RequestForQuote;
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Broker,role=Broker) ]]
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Buyer,role=Buyer) ]]
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/CreditAgency,role=CreditAgency) ]]
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Supplier,role=Supplier) ]]
+[[ Type(prefix=tns,namespace=http://www.pi4soa.org/ESBBroker) ]]
+[[ Type(prefix=xsd,namespace=http://www.w3.org/2001/XMLSchema) ]]
+[[ Type(prefix=brk,namespace=http://www.pi4soa.org/ESBBroker/Broker) ]]
+[[ Type(prefix=byr,namespace=http://www.pi4soa.org/ESBBroker/Buyer) ]]
+[[ Type(prefix=cay,namespace=http://www.pi4soa.org/ESBBroker/CreditAgency) ]]
+[[ Type(prefix=spr,namespace=http://www.pi4soa.org/ESBBroker/Supplier) ]]
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Supplier,role=SupplierTxnProcessor) ]]
+[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Supplier,role=SupplierQuoteEngine) ]]
+protocol ESBBrokerProcess {
+	role Broker, Buyer, CreditAgency, Supplier;
+	[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+	[[ Correlation(request=makeEnquiry) ]]
+	makeEnquiry(Enquiry) from Buyer to Broker;
+	repeat {
+		run RequestForQuote(Broker);
+	}
+	[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+	[[ Correlation(replyTo=makeEnquiry) ]]
+	makeEnquiry(QuoteList) from Broker to Buyer;
+	choice from Buyer to Broker {
+		[[ Correlation(request=buy) ]]
+		buy(Buy):
+			role SupplierTxnProcessor;
+			[[ Interface(name={http://www.pi4soa.org/ESBBroker}CreditAgencyBehavior) ]]
+			[[ Correlation(request=checkCredit) ]]
+			checkCredit(CreditInformation) from Broker to CreditAgency;
+			choice from CreditAgency to Broker {
+				[[ Correlation(replyTo=checkCredit) ]]
+				checkCredit(CreditValid):
+					[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+					[[ Correlation(request=confirm) ]]
+					confirm(OrderConfirmed) from Broker to SupplierTxnProcessor;
+					[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+					[[ Correlation(replyTo=confirm) ]]
+					confirm(BookingReference) from SupplierTxnProcessor to Broker;
+					[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+					[[ Correlation(replyTo=buy) ]]
+					buy(BookingReference) from Broker to Buyer;
+
+				[[ Fault(name=invalidCredit) ]]
+				[[ Correlation(replyTo=checkCredit) ]]
+				checkCredit(CreditInvalid):
+					[[ Fault(name=rejected) ]]
+					[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+					[[ Correlation(replyTo=buy) ]]
+					buy(OrderRejected) from Broker to Buyer;
+
+			}
+
+		cancel(Cancel):
+
+	}
+	[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Supplier,role=SupplierTxnProcessor) ]]
+	protocol CompleteTransaction(role Buyer, role Broker, role CreditAgency) {
+		role SupplierTxnProcessor;
+		[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+		[[ Correlation(request=buy) ]]
+		buy(Buy) from Buyer to Broker;
+		[[ Interface(name={http://www.pi4soa.org/ESBBroker}CreditAgencyBehavior) ]]
+		[[ Correlation(request=checkCredit) ]]
+		checkCredit(CreditInformation) from Broker to CreditAgency;
+		choice from CreditAgency to Broker {
+			[[ Correlation(replyTo=checkCredit) ]]
+			checkCredit(CreditValid):
+				[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+				[[ Correlation(request=confirm) ]]
+				confirm(OrderConfirmed) from Broker to SupplierTxnProcessor;
+				[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+				[[ Correlation(replyTo=confirm) ]]
+				confirm(BookingReference) from SupplierTxnProcessor to Broker;
+				[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+				[[ Correlation(replyTo=buy) ]]
+				buy(BookingReference) from Broker to Buyer;
+
+			[[ Fault(name=invalidCredit) ]]
+			[[ Correlation(replyTo=checkCredit) ]]
+			checkCredit(CreditInvalid):
+				[[ Fault(name=rejected) ]]
+				[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+				[[ Correlation(replyTo=buy) ]]
+				buy(OrderRejected) from Broker to Buyer;
+
+		}
+	}
+	[[ Namespace(name=http://www.pi4soa.org/ESBBroker/Supplier,role=SupplierQuoteEngine) ]]
+	protocol RequestForQuote(role Broker) {
+		role SupplierQuoteEngine;
+		[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+		[[ Correlation(request=getQuote) ]]
+		getQuote(RequestForQuote) from Broker to SupplierQuoteEngine;
+		[[ Interface(name={http://www.pi4soa.org/ESBBroker}SupplierBehavior) ]]
+		[[ Correlation(replyTo=getQuote) ]]
+		getQuote(Quote) from SupplierQuoteEngine to Broker;
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PurchaseGoods.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PurchaseGoods.spr	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PurchaseGoods.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,35 @@
+import xsd "{http://www.jboss.org/examples/store}BuyConfirmed" as BuyConfirmed, "{http://www.jboss.org/examples/store}BuyFailed" as BuyFailed, "{http://www.jboss.org/examples/store}BuyRequest" as BuyRequest from "http://www.jboss.org/examples/store";
+import xsd "{java:org.jboss.savara.examples.purchasing}CreditCheckInvalid" as CreditCheckInvalid, "{java:org.jboss.savara.examples.purchasing}CreditCheckOk" as CreditCheckOk, "{java:org.jboss.savara.examples.purchasing}CreditCheckRequest" as CreditCheckRequest from "java:org.jboss.savara.examples.purchasing";
+import xsd "{http://www.w3.org/2001/XMLSchema}string" as IDType, "{http://www.w3.org/2001/XMLSchema}anyURI" as URITokenType from "http://www.w3.org/2001/XMLSchema";
+[[ Namespace(name=http://www.jboss.org/savara/examples,role=Buyer) ]]
+[[ Namespace(name=java:org.jboss.savara.examples.purchasing,role=CreditAgency) ]]
+[[ Namespace(name=http://www.jboss.org/examples/store,role=Store) ]]
+[[ Type(prefix=tns,namespace=http://www.jboss.org/savara/examples) ]]
+[[ Type(prefix=xsd,namespace=http://www.w3.org/2001/XMLSchema) ]]
+[[ Type(prefix=pur,namespace=java:org.jboss.savara.examples.purchasing) ]]
+[[ Type(prefix=sto,namespace=http://www.jboss.org/examples/store) ]]
+protocol PurchaseGoodsProcess {
+	role Buyer, CreditAgency, Store;
+	[[ Interface(name={http://www.jboss.org/examples/store}StoreInterface) ]]
+	[[ Correlation(request=buy) ]]
+	buy(BuyRequest) from Buyer to Store;
+	[[ Interface(name={java:org.jboss.savara.examples.purchasing}CreditAgencyInterface) ]]
+	[[ Correlation(request=checkCredit) ]]
+	checkCredit(CreditCheckRequest) from Store to CreditAgency;
+	choice from CreditAgency to Store {
+		[[ Correlation(replyTo=checkCredit) ]]
+		checkCredit(CreditCheckOk):
+			[[ Interface(name={http://www.jboss.org/examples/store}StoreInterface) ]]
+			[[ Correlation(replyTo=buy) ]]
+			buy(BuyConfirmed) from Store to Buyer;
+
+		[[ Fault(name=CreditCheckFailed) ]]
+		[[ Correlation(replyTo=checkCredit) ]]
+		checkCredit(CreditCheckInvalid):
+			[[ Fault(name=BuyFailed) ]]
+			[[ Interface(name={http://www.jboss.org/examples/store}StoreInterface) ]]
+			[[ Correlation(replyTo=buy) ]]
+			buy(BuyFailed) from Store to Buyer;
+
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ReqRespFault.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ReqRespFault.spr	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/ReqRespFault.spr	2011-01-26 00:04:53 UTC (rev 622)
@@ -0,0 +1,22 @@
+import xsd "CreditCheckRequest" as CreditInformation, "CreditCheckInvalid" as CreditInvalid, "CreditCheckOk" as CreditValid;
+[[ Namespace(name=http://www.pi4soa.org/ReqRespFault/Buyer,role=Buyer) ]]
+[[ Namespace(name=http://www.pi4soa.org/ReqRespFault/Seller,role=Seller) ]]
+[[ Type(prefix=tns,namespace=http://www.pi4soa.org/ReqRespFault) ]]
+[[ Type(prefix=xsd,namespace=http://www.w3.org/2001/XMLSchema) ]]
+[[ Type(prefix=byr,namespace=http://www.pi4soa.org/ReqRespFault/Buyer) ]]
+[[ Type(prefix=slr,namespace=http://www.pi4soa.org/ReqRespFault/Seller) ]]
+protocol ReqRespFaultProcess {
+	role Buyer, Seller;
+	[[ Interface(name={http://www.pi4soa.org/ReqRespFault}SellerBehavior) ]]
+	[[ Correlation(request=checkCredit) ]]
+	checkCredit(CreditInformation) from Buyer to Seller;
+	choice from Seller to Buyer {
+		[[ Correlation(replyTo=checkCredit) ]]
+		checkCredit(CreditValid):
+
+		[[ Fault(name=insufficientCredit) ]]
+		[[ Correlation(replyTo=checkCredit) ]]
+		checkCredit(CreditInvalid):
+
+	}
+}

Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/pom.xml
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/pom.xml	2011-01-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/pom.xml	2011-01-26 00:04:53 UTC (rev 622)
@@ -26,10 +26,20 @@
 		</dependency>
 		<dependency>
 			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.common</artifactId>
+			<version>${savara.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
 			<artifactId>org.savara.contract</artifactId>
 			<version>${savara.version}</version>
 		</dependency>
 		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.protocol</artifactId>
+			<version>${savara.version}</version>
+		</dependency>
+		<dependency>
 		    <groupId>commons-logging</groupId>
 		    <artifactId>commons-logging</artifactId>
 		    <version>1.1.1</version>

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-25 16:45:38 UTC (rev 621)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java	2011-01-26 00:04:53 UTC (rev 622)
@@ -35,12 +35,9 @@
 import org.savara.bpel.generator.ProtocolToBPELModelGenerator;
 import org.savara.bpel.model.*;
 import org.savara.bpel.util.BPELModelUtil;
-import org.savara.protocol.model.util.PropertyName;
 import org.savara.common.model.annotation.Annotation;
 import org.savara.common.model.annotation.AnnotationDefinitions;
 import org.savara.common.util.XMLUtils;
-import org.savara.contract.generator.ContractGenerator;
-import org.savara.contract.generator.ContractGeneratorFactory;
 import org.savara.contract.model.Contract;
 import org.savara.contract.model.Interface;
 import org.savara.contract.model.Namespace;
@@ -227,10 +224,12 @@
 		// TODO: SAVARA-169 (and related to SAVARA-168)
 		// Currently necessary to generate contracts from global model and
 		// associate with model
+		/* GPB: CONTRACT
 		ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
 		if (cg != null) {
-			cg.generate(m_protocolModel, journal, null);
+			cg.generate(m_protocolModel.getProtocol(), journal, null);
 		}
+		*/
 		
 		DefaultProtocolContext context=new DefaultProtocolContext(ScribbleServices.getParserManager(),
 						new DefaultResourceLocator(cdmResource.getParent().getFullPath().toFile()));



More information about the savara-commits mailing list