[overlord-commits] Overlord SVN: r489 - 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
Tue Feb 10 17:37:26 EST 2009


Author: objectiser
Date: 2009-02-10 17:37:26 -0500 (Tue, 10 Feb 2009)
New Revision: 489

Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.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
   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:
Use response category/name to derive additional stateless paths. Remove commented out regions.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java	2009-02-10 21:05:51 UTC (rev 488)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java	2009-02-10 22:37:26 UTC (rev 489)
@@ -17,6 +17,8 @@
  */
 package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
 
+import java.util.logging.Logger;
+
 import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
 import org.scribble.conversation.model.*;
 import org.scribble.model.*;
@@ -171,6 +173,80 @@
 		if (context.getRole() != null) {
 			send.setFromRole(new Role(context.getRole()));
 		}
+		
+		// Check if reply destination has been defined
+		if (hasProperty(RESPONSE_SERVICE_CATEGORY) &&
+				hasProperty(RESPONSE_SERVICE_NAME)) {
+			String responseName=getPropertyValue(RESPONSE_SERVICE_NAME);
+			String responseCategory=getPropertyValue(RESPONSE_SERVICE_CATEGORY);
+	
+			ESBService serv=getService().getModel().
+					getService(responseCategory, responseName);
+			
+			Definition defn=send.getEnclosingDefinition().
+							getTopLevelDefinition();
+
+			if (serv == null) {
+				logger.severe("Failed to find response ESB service '"+
+						responseCategory+"/"+responseName+"'");
+				
+			} else if (context.isOnStack(serv)) {
+				
+				// Ignore service as don't want to recursively
+				// process it
+				
+			} else if (defn != null && defn.isStateless()) {
+				If ifelem=null;
+				
+				context.push(serv);
+				
+				for (int i=0; ifelem == null &&
+						i < defn.getBlock().getContents().size(); i++) {
+					if (defn.getBlock().getContents().get(i) instanceof If) {
+						ifelem = (If)defn.getBlock().getContents().get(i);
+					}
+				}
+				
+				if (ifelem != null) {
+					
+					if (serv.getActions().size() == 1 &&
+							serv.getActions().get(0) instanceof SwitchAction) {
+						// Work through case entries and add each
+						// to top level conversation stateless 'if'
+						SwitchAction sw=(SwitchAction)serv.getActions().get(0);
+						
+						for (int i=0; i < sw.getNumberOfCases(); i++) {
+							String name=sw.getCaseServiceName(i);
+							String category=sw.getCaseServiceCategory(i);
+							
+							ESBService subServ=getService().getModel().
+								getService(category, name);
+							
+							if (subServ == null) {
+								logger.severe("Failed to find response sub ESB service '"+
+										category+"/"+name+"'");
+							} else {
+								ConditionalBlock cb=new ConditionalBlock();
+								
+								ifelem.getConditionalBlocks().add(cb);
+								
+								subServ.convert(cb.getContents(), context);
+							}
+						}
+					} else {
+						ConditionalBlock cb=new ConditionalBlock();
+						
+						ifelem.getConditionalBlocks().add(cb);
+						
+						serv.convert(cb.getContents(), context);
+					}
+				} else {
+					logger.severe("Unable to find top level 'stateless' IF activity");
+				}
+
+				context.pop(serv);
+			}
+		}
 	}
 	
 	/**
@@ -214,4 +290,6 @@
 			prop.setAttribute(VALUE_ATTR, name);
 		}
 	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless");
 }

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-02-10 21:05:51 UTC (rev 488)
+++ 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-02-10 22:37:26 UTC (rev 489)
@@ -383,8 +383,44 @@
 
 		return(ret);
 	}
+	
+	/**
+	 * This method returns the service category of the case
+	 * associated with the supplied index.
+	 * 
+	 * @param index The index
+	 * @return The service category
+	 */
+	public String getCaseServiceCategory(int index) {
+		String ret=null;
+		org.w3c.dom.Element caseElem=getCaseElement(index);
+		
+		if (caseElem != null) {
+			ret = caseElem.getAttribute(SERVICE_CATEGORY);
+		}
 
+		return(ret);
+	}
+
 	/**
+	 * This method returns the service name of the case
+	 * associated with the supplied index.
+	 * 
+	 * @param index The index
+	 * @return The service name
+	 */
+	public String getCaseServiceName(int index) {
+		String ret=null;
+		org.w3c.dom.Element caseElem=getCaseElement(index);
+		
+		if (caseElem != null) {
+			ret = caseElem.getAttribute(SERVICE_NAME);
+		}
+		
+		return(ret);
+	}
+
+	/**
 	 * This method returns the DOM element associated with the
 	 * specified service category and name.
 	 * 

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-02-10 21:05:51 UTC (rev 488)
+++ 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-02-10 22:37:26 UTC (rev 489)
@@ -97,15 +97,6 @@
 		
 		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())) {
@@ -114,22 +105,6 @@
 		} else {
 			insertSwitch(context, model, service, ifElem, pos);
 		}
-		
-		
-		//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);
-				service.getActions().remove(i);
-				
-				joinService.addAction(act, -1);
-			}
-		}
-		*/
 
 		return(true);
 	}
@@ -165,21 +140,6 @@
 			ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
 					subService.getCategory(), subService.getName(),
 					immediate, null, i);
-			
-			/* REQUIRED?
-			ScheduleStateAction schedule=
-				new ScheduleStateAction((ESBService)context.getParent());
-			
-			schedule.setDestination(joinService.getCategory(),
-					joinService.getName(), true);
-			((ESBService)context.getParent()).addAction(schedule, -1);
-
-			if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
-					ifElem.getEnclosingDefinition() instanceof Conversation) {
-				schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-						((Conversation)ifElem.getEnclosingDefinition())));
-			}
-			*/
 		}
 		
 		if (ifElem.getElseBlock() != null) {
@@ -203,30 +163,7 @@
 			ifAction.addPath(IfAction.ELSE,
 					subService.getCategory(), subService.getName(),
 					immediate, null, -1);
-			
-			/* REQUIRED?
-			ScheduleStateAction schedule=
-				new ScheduleStateAction((ESBService)context.getParent());
-			
-			schedule.setDestination(joinService.getCategory(),
-					joinService.getName(), true);
-			((ESBService)context.getParent()).addAction(schedule, -1);
-
-			if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
-					ifElem.getEnclosingDefinition() instanceof Conversation) {
-				schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-						((Conversation)ifElem.getEnclosingDefinition())));
-			}
-			*/
 		}
-		
-		/*
-		if (service.getFirstSessionBasedAction() == ifAction &&
-				ifElem.getEnclosingDefinition() instanceof Conversation) {
-			ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-					((Conversation)ifElem.getEnclosingDefinition())));
-		}
-		*/
 	}
 
 	protected void insertSwitch(ModelChangeContext context,
@@ -238,40 +175,6 @@
 		java.util.Map<ESBService,java.util.Set<Interaction>> replyServiceMTypes=
 			new java.util.Hashtable<ESBService,java.util.Set<Interaction>>();
 		
-		// Check if 'when' needs to be placed in new service
-		// descriptor - i.e. if insert at end, but current service
-		// already has service based actions, or reference object
-		// provided, but is not first position
-		
-		/* IS THIS REQUIRED???
-		if (shouldScheduleNewService(service, (pos == -1 ?
-				service.getActions().size() : pos))) {
-			
-			// Already has activities, so need to separate
-			// into another service descriptor
-			ESBService switchService=esbModel.createService(
-					service.getCategory(),
-					esbModel.getUniqueServiceName(service.getCategory(),
-							service.getName()));
-
-			esbModel.addService(switchService);
-			
-			// Add schedule action
-			ScheduleStateAction schedule=
-				new ScheduleStateAction(service);
-			
-			schedule.setDestination(switchService.getCategory(),
-					switchService.getName(), false);
-			
-			service.addAction(schedule, pos);
-
-			context.setParent(switchService);
-			
-			service = switchService;
-			pos = -1;
-		}
-		*/
-
 		// Switch action, as role is a decision observer
 		SwitchAction switchAction=new SwitchAction(service);
 		
@@ -283,8 +186,6 @@
 			String namespace=((Model)conv.getModel()).
 						getNamespace().getName();
 
-			String category=ConversationUtil.getServiceCategory(conv);
-
 			String name=ConversationUtil.getServiceName(conv);
 
 			String sdname="";
@@ -325,6 +226,8 @@
 			}
 		}
 		
+		service.addAction(switchAction, pos);
+		
 		// Get lookahead analyser
 		LookaheadAnalyser la=(LookaheadAnalyser)
 				RegistryFactory.getRegistry().getExtension(
@@ -334,11 +237,6 @@
 			logger.severe("Failed to find lookahead analyser");
 		}
 		
-		service.addAction(switchAction, pos);
-		
-		//java.util.Set<MessageSignature> messageTypes=
-		//				new java.util.HashSet<MessageSignature>();
-
 		for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
 			ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
 			
@@ -379,40 +277,7 @@
 			} else {
 				switchAction.addCase(subService.getCategory(),
 						subService.getName(), interactions, i);
-			}
-			
-			/* REQUIRED?
-			ScheduleStateAction schedule=
-				new ScheduleStateAction((ESBService)context.getParent());
-			
-			schedule.setDestination(joinService.getCategory(),
-					joinService.getName(), true);
-			((ESBService)context.getParent()).addAction(schedule, -1);
-
-			if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
-					ifElem.getEnclosingDefinition() instanceof Conversation) {
-				schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-						((Conversation)ifElem.getEnclosingDefinition())));
-			}
-
-			if (interactions != null) {
-				java.util.Iterator<Interaction> iter=interactions.iterator();
-				
-				while (iter.hasNext()) {
-					Interaction interaction=iter.next();
-					
-					//TODO: Only deals with single type for now
-					// If a receive and not a response, then
-					// add to the gateway
-					if (InteractionUtil.isSend(interaction) == false &&
-							interaction.getReplyToLabel() == null &&
-							interaction.getMessageSignature().getTypes().size()==1) {
-					
-						messageTypes.add(interaction.getMessageSignature());
-					}
-				}
-			}
-			*/
+			}			
 		}
 		
 		if (ifElem.getElseBlock() != null) {
@@ -456,39 +321,6 @@
 				switchAction.addCase(subService.getCategory(),
 						subService.getName(), interactions, -1);
 			}
-
-			/*
-			ScheduleStateAction schedule=
-				new ScheduleStateAction((ESBService)context.getParent());
-			
-			schedule.setDestination(joinService.getCategory(),
-					joinService.getName(), true);
-			((ESBService)context.getParent()).addAction(schedule, -1);
-
-			if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
-					ifElem.getEnclosingDefinition() instanceof Conversation) {
-				schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-						((Conversation)ifElem.getEnclosingDefinition())));
-			}
-
-			if (interactions != null) {
-				java.util.Iterator<Interaction> iter=interactions.iterator();
-				
-				while (iter.hasNext()) {
-					Interaction interaction=iter.next();
-					
-					//TODO: Only deals with single type for now
-					// If a receive and not a response, then
-					// add to the gateway
-					if (InteractionUtil.isSend(interaction) == false &&
-							interaction.getReplyToLabel() == null &&
-							interaction.getMessageSignature().getTypes().size()==1) {
-					
-						messageTypes.add(interaction.getMessageSignature());
-					}
-				}
-			}
-			*/
 		}
 		
 		java.util.Iterator<String> replyLabels=replyServices.keySet().iterator();
@@ -523,38 +355,6 @@
 				}
 			}
 		}
-		
-		// Only record message router 'routes' if the switch
-		// receives request interactions, and it is the first
-		// session based action in the service
-		/*
-		if (messageTypes.size() > 0 &&
-				service.getFirstSessionBasedAction() == switchAction) {
-			ESBService gwService=
-				esbModel.getGatewayService();
-			
-			if (gwService != null) {
-				ESBAction gwAction=gwService.getGatewayAction();
-				
-				if (gwAction instanceof SwitchAction) {
-					SwitchAction mra=(SwitchAction)
-								gwAction;
-					
-					mra.addCase(service.getCategory(),
-							service.getName(),
-							messageTypes, 0);
-				}
-			}					
-		}
-		*/
-		
-		/*
-		if (service.getFirstSessionBasedAction() == switchAction &&
-				ifElem.getEnclosingDefinition() instanceof Conversation) {
-			switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
-					((Conversation)ifElem.getEnclosingDefinition())));
-		}
-		*/
 	}
 	
 	protected String getReplyLabel(java.util.Set<Interaction> interactions) {




More information about the overlord-commits mailing list