[savara-commits] savara SVN: r612 - in branches/experimental/2.0.x/bundles: org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Jan 22 15:52:43 EST 2011


Author: objectiser
Date: 2011-01-22 15:52:42 -0500 (Sat, 22 Jan 2011)
New Revision: 612

Added:
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/text/
   branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/text/TextProtocolExporter.java
Modified:
   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.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ChoiceConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConditionalConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java
   branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/ParserTest.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/src/main/java/org/savara/protocol/model/util/AnnotationDefinitions.java
   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/PropertyName.java
Log:
Added support for exporting text representation of annotations, to initially support the CDL to protocol conversion tests.

Modified: 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.contract/src/test/java/org/savara/contract/generator/impl/ContractIntrospectorTest.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/test/java/org/savara/contract/generator/impl/ContractIntrospectorTest.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -21,6 +21,8 @@
  */
 package org.savara.contract.generator.impl;
 
+import org.savara.protocol.model.annotation.Annotation;
+import org.savara.protocol.model.util.AnnotationDefinitions;
 import org.savara.protocol.model.util.PropertyName;
 import org.savara.contract.model.Contract;
 import org.savara.contract.model.Interface;
@@ -261,7 +263,9 @@
 		interaction.setMessageSignature(msig);
 		interaction.setFromRole(new Role());
 		
-		interaction.getProperties().put(PropertyName.REQUEST_LABEL, "label");
+		Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+		annotation.getProperties().put(AnnotationDefinitions.REQUEST, "label");
+		interaction.getProperties().put(annotation.getName(), annotation);
 		
 		introspector.accept(interaction);
 		

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ChoiceConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ChoiceConverterRuleImpl.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ChoiceConverterRuleImpl.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -25,6 +25,8 @@
 import org.pi4soa.cdl.Parallel;
 import org.pi4soa.cdl.util.CDLTypeUtil;
 import org.pi4soa.cdl.util.InteractionUtil;
+import org.savara.protocol.model.annotation.Annotation;
+import org.savara.protocol.model.util.AnnotationDefinitions;
 import org.savara.protocol.model.util.PropertyName;
 import org.scribble.protocol.model.*;
 import org.scribble.protocol.model.Choice;
@@ -130,15 +132,20 @@
 								}
 								
 								if (ed.getAction() == ExchangeActionType.RESPOND) {
-									block.getProperties().put(PropertyName.REPLY_TO_LABEL, ConverterUtil.getLabel(ed));
+									Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+									annotation.getProperties().put(AnnotationDefinitions.REPLY_TO,
+												ConverterUtil.getLabel(ed));
+									block.getProperties().put(annotation.getName(), annotation);
 								} else {
 									// Check if request has response/fault exchanges
 									java.util.List<ExchangeDetails> resps=
 											InteractionUtil.getResponseExchangeDetails(ed);
 									
 									if (resps != null && resps.size() > 0) {
-										block.getProperties().put(PropertyName.REQUEST_LABEL,
-														ConverterUtil.getLabel(ed));
+										Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+										annotation.getProperties().put(AnnotationDefinitions.REQUEST,
+													ConverterUtil.getLabel(ed));
+										block.getProperties().put(annotation.getName(), annotation);
 									}
 								}
 							}

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConditionalConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConditionalConverterRuleImpl.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/ConditionalConverterRuleImpl.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -22,6 +22,8 @@
 import org.pi4soa.cdl.*;
 import org.pi4soa.cdl.util.CDLTypeUtil;
 import org.pi4soa.cdl.util.InteractionUtil;
+import org.savara.protocol.model.annotation.Annotation;
+import org.savara.protocol.model.util.AnnotationDefinitions;
 import org.savara.protocol.model.util.PropertyName;
 import org.savara.pi4soa.cdm.parser.rules.ChoiceConverterRuleImpl.InteractionLocator;
 import org.scribble.protocol.model.*;
@@ -99,15 +101,20 @@
 											ed)));
 				
 				if (ed.getAction() == ExchangeActionType.RESPOND) {
-					block.getProperties().put(PropertyName.REPLY_TO_LABEL, ConverterUtil.getLabel(ed));
+					Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+					annotation.getProperties().put(AnnotationDefinitions.REPLY_TO,
+								ConverterUtil.getLabel(ed));
+					block.getProperties().put(annotation.getName(), annotation);
 				} else {
 					// Check if request has response/fault exchanges
 					java.util.List<ExchangeDetails> resps=
 							InteractionUtil.getResponseExchangeDetails(ed);
 					
 					if (resps != null && resps.size() > 0) {
-						block.getProperties().put(PropertyName.REQUEST_LABEL,
-										ConverterUtil.getLabel(ed));
+						Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+						annotation.getProperties().put(AnnotationDefinitions.REQUEST,
+									ConverterUtil.getLabel(ed));
+						block.getProperties().put(annotation.getName(), annotation);
 					}
 				}
 			}

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/main/java/org/savara/pi4soa/cdm/parser/rules/InteractionConverterRuleImpl.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -379,7 +379,10 @@
 						InteractionUtil.getResponseExchangeDetails(details);
 				
 				if (resps != null && resps.size() > 0) {
-					interaction.getProperties().put(PropertyName.REQUEST_LABEL, ConverterUtil.getLabel(details));
+					Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+					annotation.getProperties().put(AnnotationDefinitions.REQUEST,
+								ConverterUtil.getLabel(details));
+					interaction.getProperties().put(annotation.getName(), annotation);
 				}
 				
 				// Check if fault thrown
@@ -435,7 +438,10 @@
 				}
 				
 				if (details.getAction() == ExchangeActionType.RESPOND) {
-					interaction.getProperties().put(PropertyName.REPLY_TO_LABEL, ConverterUtil.getLabel(details));
+					Annotation annotation=new Annotation(AnnotationDefinitions.CORRELATION);
+					annotation.getProperties().put(AnnotationDefinitions.REPLY_TO,
+								ConverterUtil.getLabel(details));
+					interaction.getProperties().put(annotation.getName(), annotation);
 				}
 
 				// Check if fault thrown

Modified: branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/ParserTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/ParserTest.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/java/org/savara/pi4soa/cdm/parser/ParserTest.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -23,6 +23,8 @@
 import junit.framework.TestSuite;
 
 import org.scribble.common.logging.CachedJournal;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.export.text.TextProtocolExporterVisitor;
 import org.savara.pi4soa.cdm.parser.CDMProtocolParser;
 import org.savara.protocol.util.ProtocolServices;
 
@@ -40,6 +42,8 @@
     
     protected static class ChoreographyToProtocolTester extends TestCase {
 
+    	private String m_name=null;
+
     	/**
     	 * This constructor is initialized with the test
     	 * name.
@@ -90,7 +94,7 @@
     			} else {
     				
     				org.scribble.protocol.export.text.TextProtocolExporter exporter=
-    					new org.scribble.protocol.export.text.TextProtocolExporter();
+    					new org.savara.protocol.export.text.TextProtocolExporter();
     				
     				java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
     				
@@ -207,8 +211,5 @@
     			}
     		}
     	}
-
-    	private String m_name=null;
-    	private String m_role=null;
     }
 }

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-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ESBBroker.spr	2011-01-22 20:52:42 UTC (rev 612)
@@ -1,21 +1,38 @@
 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;
 
+				[[ Correlation(replyTo=checkCredit) ]]
 				checkCredit(CreditInvalid):
+					[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+					[[ Correlation(replyTo=buy) ]]
 					buy(OrderRejected) from Broker to Buyer;
 
 			}
@@ -25,22 +42,40 @@
 	}
 	protocol CompleteTransaction {
 		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;
 
+			[[ Correlation(replyTo=checkCredit) ]]
 			checkCredit(CreditInvalid):
+				[[ Interface(name={http://www.pi4soa.org/ESBBroker}BrokerBehavior) ]]
+				[[ Correlation(replyTo=buy) ]]
 				buy(OrderRejected) from Broker to Buyer;
 
 		}
 	}
 	protocol RequestForQuote {
 		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;
 	}
 }

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-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/PurchaseGoods.spr	2011-01-22 20:52:42 UTC (rev 612)
@@ -1,12 +1,22 @@
 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;
 
+		[[ Correlation(replyTo=checkCredit) ]]
 		checkCredit(CreditCheckInvalid):
+			[[ Interface(name={http://www.jboss.org/examples/store}StoreInterface) ]]
+			[[ Correlation(replyTo=buy) ]]
 			buy(BuyFailed) from Store to Buyer;
 
 	}

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-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.pi4soa.cdm/src/test/resources/results/protocol/ReqRespFault.spr	2011-01-22 20:52:42 UTC (rev 612)
@@ -1,9 +1,13 @@
 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):
 
+		[[ Correlation(replyTo=checkCredit) ]]
 		checkCredit(CreditInvalid):
 
 	}

Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/text/TextProtocolExporter.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/text/TextProtocolExporter.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/export/text/TextProtocolExporter.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -0,0 +1,328 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008-11, 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.export.text;
+
+import org.savara.protocol.model.annotation.Annotation;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.export.text.TextProtocolExporterVisitor;
+import org.scribble.protocol.model.Catch;
+import org.scribble.protocol.model.Choice;
+import org.scribble.protocol.model.Include;
+import org.scribble.protocol.model.Interaction;
+import org.scribble.protocol.model.Optional;
+import org.scribble.protocol.model.Parallel;
+import org.scribble.protocol.model.Protocol;
+import org.scribble.protocol.model.ProtocolImport;
+import org.scribble.protocol.model.ProtocolImportList;
+import org.scribble.protocol.model.Raise;
+import org.scribble.protocol.model.RecBlock;
+import org.scribble.protocol.model.Recursion;
+import org.scribble.protocol.model.Repeat;
+import org.scribble.protocol.model.RoleList;
+import org.scribble.protocol.model.Run;
+import org.scribble.protocol.model.Try;
+import org.scribble.protocol.model.TypeImport;
+import org.scribble.protocol.model.TypeImportList;
+import org.scribble.protocol.model.Unordered;
+import org.scribble.protocol.model.When;
+
+public class TextProtocolExporter extends org.scribble.protocol.export.text.TextProtocolExporter {
+
+	/**
+	 * This method creates the text protocol export visitor.
+	 * 
+	 * @param journal The journal
+	 * @param os The output stream
+	 * @return The visitor
+	 */
+	@Override
+	protected TextProtocolExporterVisitor createVisitor(Journal journal, java.io.OutputStream os) {
+		return(new TextWithAnnotationVisitor(journal, os));
+	}
+	
+	public class TextWithAnnotationVisitor extends TextProtocolExporterVisitor {
+		
+		public TextWithAnnotationVisitor(Journal journal, java.io.OutputStream os) {
+			super(journal, os);
+		}
+
+		@Override
+		public void accept(Interaction elem) {
+			
+			if ((elem.getParent() instanceof Catch) == false) {
+				
+				for (Object prop : elem.getProperties().values()) {
+					
+					if (prop instanceof Annotation) {
+						outputAnnotation((Annotation)prop);
+					}
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(TypeImportList elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(ProtocolImportList elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(Include elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		/**
+		 * This method visits a recursion component.
+		 * 
+		 * @param elem The recursion
+		 */
+		public void accept(Recursion elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(RoleList elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(TypeImport elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public void accept(ProtocolImport elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			super.accept(elem);
+		}
+		
+		@Override
+		public boolean start(Protocol elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Choice elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(When elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+
+		@Override
+		public boolean start(Parallel elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Repeat elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(RecBlock elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+
+		@Override
+		public boolean start(Optional elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Unordered elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Try elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Catch elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		@Override
+		public boolean start(Run elem) {
+			for (Object prop : elem.getProperties().values()) {
+				
+				if (prop instanceof Annotation) {
+					outputAnnotation((Annotation)prop);
+				}
+			}
+			
+			return(super.start(elem));
+		}
+		
+		protected void outputAnnotation(Annotation annotation) {
+			indent();
+			output("[[ ");
+			
+			output(annotation.getName());
+			
+			if (annotation.getProperties().size() > 0) {
+				output("(");
+				
+				java.util.Set<String> props=annotation.getProperties().keySet();
+				boolean f_first=true;
+				for (String prop : props) {
+					
+					if (!f_first) {
+						output(",");
+					}
+					output(prop);
+					output("=");
+					output(annotation.getProperties().get(prop).toString());
+					f_first = false;
+				}
+				
+				output(")");
+			}
+			
+			output(" ]]\r\n");
+		}
+	}
+}

Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/AnnotationDefinitions.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/AnnotationDefinitions.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/AnnotationDefinitions.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -28,8 +28,13 @@
 	public static final String XSD_ELEMENT = "XSDElement";
 	public static final String XSD_TYPE = "XSDType";
 	
+	public static final String CORRELATION = "Correlation";
 	
+	
 	// Annotation property names
 	public static final String NAME="name";
 	
+	public static final String REQUEST = "request";
+	public static final String REPLY_TO = "replyTo";
+
 }

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-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/InteractionUtil.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -124,19 +124,39 @@
 	}
 	
 	public static String getRequestLabel(Interaction interaction) {
-		return((String)interaction.getProperties().get(PropertyName.REQUEST_LABEL));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.getProperties().get(AnnotationDefinitions.CORRELATION);
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.REQUEST);
+		}
+		return(ret);
 	}
 	
 	public static String getReplyToLabel(Interaction interaction) {
-		return((String)interaction.getProperties().get(PropertyName.REPLY_TO_LABEL));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.getProperties().get(AnnotationDefinitions.CORRELATION);
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.REPLY_TO);
+		}
+		return(ret);
 	}
 	
 	public static String getRequestLabel(When interaction) {
-		return((String)interaction.getProperties().get(PropertyName.REQUEST_LABEL));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.getProperties().get(AnnotationDefinitions.CORRELATION);
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.REQUEST);
+		}
+		return(ret);
 	}
 	
 	public static String getReplyToLabel(When interaction) {
-		return((String)interaction.getProperties().get(PropertyName.REPLY_TO_LABEL));
+		String ret=null;
+		Annotation annotation=(Annotation)interaction.getProperties().get(AnnotationDefinitions.CORRELATION);
+		if (annotation != null) {
+			ret = (String)annotation.getProperties().get(AnnotationDefinitions.REPLY_TO);
+		}
+		return(ret);
 	}
 
 	/**

Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/PropertyName.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/PropertyName.java	2011-01-21 23:25:27 UTC (rev 611)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/model/util/PropertyName.java	2011-01-22 20:52:42 UTC (rev 612)
@@ -25,7 +25,4 @@
 	
 	public static final String NAMESPACE = "Namespace";
 	
-	public static final String REQUEST_LABEL = "RequestLabel";
-	public static final String REPLY_TO_LABEL = "ReplyToLabel";
-
 }



More information about the savara-commits mailing list