[overlord-commits] Overlord SVN: r470 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model: change/stateless and 1 other directory.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Sun Jan 25 16:17:54 EST 2009


Author: objectiser
Date: 2009-01-25 16:17:53 -0500 (Sun, 25 Jan 2009)
New Revision: 470

Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
Log:
Change to make 'switch action' the root action, rather than message router action, so it simply reflects the stateless structure. Only difference is that the top level 'switch action' will have the conversation type associated with it.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java	2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java	2009-01-25 21:17:53 UTC (rev 470)
@@ -38,6 +38,7 @@
 	private static final String SERVICE_CATEGORY = "service-category";
 	private static final String CASE = "case";
 	private static final String PATHS = "paths";
+	public static final String CONVERSATION_TYPE = "conversationType";
 
 	/**
 	 * The constructor for the action.
@@ -197,6 +198,20 @@
 	}
 
 	/**
+	 * This method sets the conversation type property.
+	 * 
+	 * @param name The conversation type
+	 */
+	public void setConversationType(String type) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(CONVERSATION_TYPE);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, type);
+		}
+	}	
+
+	/**
 	 * This method adds a path to the switch action.
 	 * 
 	 * @param category The service category

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java	2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java	2009-01-25 21:17:53 UTC (rev 470)
@@ -107,6 +107,9 @@
 			DefaultESBService gateway=new DefaultESBService(esbModel,
 						category, name);
 			
+			esbModel.addService(gateway);
+			
+			/*
 			MessageRouterAction mra=new MessageRouterAction(gateway);
 			
 			// Construct service description name
@@ -147,6 +150,7 @@
 			if (ctype != null) {
 				mra.setConversationType(ctype);
 			}
+			*/
 
 			// Process the activities within the conversation
 			java.util.List<Activity> acts=conv.getBlock().getContents();

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java	2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java	2009-01-25 21:17:53 UTC (rev 470)
@@ -35,6 +35,8 @@
 @RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
 public class IfModelChangeRule extends AbstractStatelessESBModelChangeRule {
 
+	private static final String NAME_SUFFIX = "_main";
+
 	/**
 	 * This method determines whether the rule is appropriate
 	 * for the supplied type of model, parent (in the context) and inserted
@@ -95,26 +97,30 @@
 		
 		int pos=getPosition(service, ref);
 
+		/*
 		ESBService joinService=
 			esbModel.createService(service.getCategory(),
 					esbModel.getUniqueServiceName(service.getCategory(),
 								service.getName()));
 		
 		esbModel.addService(joinService);
+		*/
 		
 		// Check if should be an 'if' or a 'switch' action
+		
 		if (ifElem.getRoles().contains(context.getRole())) {
 			
-			insertIf(context, model, service, ifElem, joinService, pos);
+			insertIf(context, model, service, ifElem, pos);
 		} else {
-			insertSwitch(context, model, service, ifElem, joinService, pos);
+			insertSwitch(context, model, service, ifElem, pos);
 		}
 		
 		
-		context.setParent(joinService);
+		//context.setParent(joinService);
 		
 		// If reference provided, then move subsequent activities
 		// to the 'join service'
+		/*
 		if (pos != -1) {
 			for (int i=pos+1; i < service.getActions().size();) {
 				ESBAction act=service.getActions().get(i);
@@ -123,13 +129,14 @@
 				joinService.addAction(act, -1);
 			}
 		}
+		*/
 
 		return(true);
 	}
 	
 	protected void insertIf(ModelChangeContext context,
 			Model model, ESBService service,
-			If ifElem, ESBService joinService, int pos) {
+			If ifElem, int pos) {
 		ESBLanguageModel esbModel=(ESBLanguageModel)model;
 		
 		// If action, because the role is a decision maker
@@ -221,10 +228,10 @@
 		}
 		*/
 	}
-	
+
 	protected void insertSwitch(ModelChangeContext context,
 			Model model, ESBService service,
-			If ifElem, ESBService joinService, int pos) {
+			If ifElem, int pos) {
 		ESBLanguageModel esbModel=(ESBLanguageModel)model;
 		
 		// Check if 'when' needs to be placed in new service
@@ -264,6 +271,56 @@
 		// Switch action, as role is a decision observer
 		SwitchAction switchAction=new SwitchAction(service);
 		
+		if (ifElem.getParent() != null &&
+				ifElem.getParent().getParent() instanceof Conversation &&
+				((Conversation)ifElem.getParent().getParent()).isStateless()) {
+			Conversation conv=(Conversation)ifElem.getParent().getParent();
+			
+			String namespace=((Model)conv.getModel()).
+						getNamespace().getName();
+
+			String category=ConversationUtil.getServiceCategory(conv);
+
+			String name=ConversationUtil.getServiceName(conv);
+
+			String sdname="";
+	
+			// Construct service description name
+			if (namespace != null) {
+				sdname = "{"+namespace+"}";
+			}
+			
+			sdname += conv.getModelName().getName()+"-"+
+					conv.getModelName().getLocatedRole().getName();
+			
+			switchAction.setServiceDescriptionName(sdname);
+			
+			name += NAME_SUFFIX;
+			
+			String ctype=null;
+			
+			// Check if conversation has a 'conforms to' reference
+			if (conv.getConformsTo().size() > 0) {
+				// Set conversation type based on first 'conforms to'
+				// reference
+				ConformanceReference cref=conv.getConformsTo().get(0);
+				
+				ctype = cref.getNamespace()+"."+
+						cref.getLocalpart()+"@"+
+						cref.getLocatedRole();
+			} else {
+				// Set conversation type based on conversation
+				// namespace and name
+				ctype = namespace+"."+
+						conv.getModelName().getName()+"@"+
+						conv.getModelName().getLocatedRole().getName();
+			}
+			
+			if (ctype != null) {
+				switchAction.setConversationType(ctype);
+			}
+		}
+		
 		// Get lookahead analyser
 		LookaheadAnalyser la=(LookaheadAnalyser)
 				RegistryFactory.getRegistry().getExtension(




More information about the overlord-commits mailing list