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

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Thu Jul 31 08:04:01 EDT 2008


Author: objectiser
Date: 2008-07-31 08:04:01 -0400 (Thu, 31 Jul 2008)
New Revision: 208

Added:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IdentityUtil.java
Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
Log:
Added send message properties for destination category/name using expressions. Also added identity information for send/receive actions.

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java	2008-07-30 15:47:21 UTC (rev 207)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java	2008-07-31 12:04:01 UTC (rev 208)
@@ -364,7 +364,7 @@
 	 * @param property The property
 	 * @return The element
 	 */
-	protected org.w3c.dom.Element getPropertyElement(String property) {
+	public org.w3c.dom.Element getPropertyElement(String property) {
 		org.w3c.dom.Element ret=null;
 		
 		if (m_action != null) {

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java	2008-07-30 15:47:21 UTC (rev 207)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java	2008-07-31 12:04:01 UTC (rev 208)
@@ -28,7 +28,6 @@
  */
 public class SendMessageAction extends AbstractESBAction {
 
-	private static final String IDENTITIES = "identities";
 	private static final String CLIENT_EPR = "clientEPR";
 	private static final String RESPONSE_SERVICE_NAME = "responseServiceName";
 	private static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
@@ -279,6 +278,50 @@
 	}
 
 	/**
+	 * This method sets the destination service descriptor properties.
+	 * 
+	 * @param category The category
+	 * @param name The name
+	 */
+	public void setDestination(String category, String name) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, category);
+		}
+		
+		prop = getPropertyElement(SERVICE_NAME);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, name);
+		}
+	}
+	
+	/**
+	 * This method sets the destination expressions for the
+	 * service descriptor properties.
+	 * 
+	 * @param categoryExpr The category expression
+	 * @param nameExpr The name expression
+	 */
+	public void setDestinationExpression(String categoryExpr,
+							String nameExpr) {
+		
+		org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY_EXPRESSION);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, categoryExpr);
+		}
+		
+		prop = getPropertyElement(SERVICE_NAME_EXPRESSION);
+		
+		if (prop != null) {
+			prop.setAttribute(VALUE_ATTR, nameExpr);
+		}
+	}
+
+	/**
 	 * This method sets the response service descriptor properties.
 	 * 
 	 * @param category The category

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java	2008-07-30 15:47:21 UTC (rev 207)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java	2008-07-31 12:04:01 UTC (rev 208)
@@ -30,6 +30,9 @@
 @RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
 public class ConversationInteractionModelChangeRule extends AbstractModelChangeRule {
 
+	private static final String SERVICE_NAME_ACCESSOR_SUFFIX = "ServiceName";
+	private static final String SERVICE_CATEGORY_ACCESSOR_SUFFIX = "ServiceCategory";
+
 	/**
 	 * This method determines whether the rule is appropriate
 	 * for the supplied type of model, parent (in the context) and
@@ -73,7 +76,6 @@
 	public boolean insert(ModelChangeContext context,
 				Model model, ModelObject mobj, int position) {
 		ESBLanguageModel esbModel=(ESBLanguageModel)model;
-		ESBService service=(ESBService)context.getParent();
 		ConversationInteraction interaction=(ConversationInteraction)mobj;
 		
 		// Check if send or receive
@@ -85,147 +87,215 @@
 						context.getRole()) == false)) {
 			
 			// Send
-			SendMessageAction action=
-					new SendMessageAction(service);
+			insertSend(context, esbModel, interaction, position);		
 			
-			if (interaction.getMessageSignature().getOperation() != null) {
-				action.setOperation(interaction.getMessageSignature().getOperation());
+		} else {
+			// Receive
+			insertReceive(context, esbModel, interaction, position);		
+		}
+		
+		return(true);
+	}
+
+	protected void insertSend(ModelChangeContext context,
+			ESBLanguageModel esbModel, ConversationInteraction interaction,
+						int position) {
+		ESBService service=(ESBService)context.getParent();
+
+		SendMessageAction action=
+				new SendMessageAction(service);
+		
+		if (interaction.getMessageSignature().getOperation() != null) {
+			action.setOperation(interaction.getMessageSignature().getOperation());
+		}
+		
+		if (interaction.getMessageSignature().getTypes().size() == 1) {
+			TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+			
+			// TODO: Search for an implementation associated with
+			// the type reference, so that the type can be
+			// abstract - possibly have the required message type
+			// notation as part of the context, so that if multiple
+			// implementations found, then can select e.g. XML or
+			// Java as message type representation.
+			
+			String mtype=null;
+			
+			if (ref.getNamespace() != null) {
+				mtype = "{"+ref.getNamespace()+"}";
+			} else {
+				mtype = "";
 			}
 			
-			if (interaction.getMessageSignature().getTypes().size() == 1) {
-				TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
-				
-				// TODO: Search for an implementation associated with
-				// the type reference, so that the type can be
-				// abstract - possibly have the required message type
-				// notation as part of the context, so that if multiple
-				// implementations found, then can select e.g. XML or
-				// Java as message type representation.
-				
-				String mtype=null;
-				
-				if (ref.getNamespace() != null) {
-					mtype = "{"+ref.getNamespace()+"}";
-				} else {
-					mtype = "";
-				}
-				
-				if (ref.getLocalpart() != null) {
-					mtype += ref.getLocalpart();
-				}
-				
-				action.setMessageType(mtype);
+			if (ref.getLocalpart() != null) {
+				mtype += ref.getLocalpart();
 			}
 			
-			service.addAction(action, position);
+			action.setMessageType(mtype);
+		}
+		
+		service.addAction(action, position);
+		
+		if (interaction.getRequestLabel() != null) {
 			
-			if (interaction.getRequestLabel() != null) {
-				
-				// Create new ESB service
-				ESBService respService=esbModel.createService(
-								service.getCategory(),
-							esbModel.getUniqueServiceName(service.getCategory(),
-									service.getName()));
+			// Create new ESB service
+			ESBService respService=esbModel.createService(
+							service.getCategory(),
+						esbModel.getUniqueServiceName(service.getCategory(),
+								service.getName()));
 
-				esbModel.addService(respService);
-				
-				action.setResponseDestination(respService.getCategory(),
-						respService.getName());
+			esbModel.addService(respService);
+			
+			action.setResponseDestination(respService.getCategory(),
+					respService.getName());
 
-				context.setParent(respService);
-				
-			} else if (interaction.getReplyToLabel() != null) {
-				
+			context.setParent(respService);
+			
+		} else if (interaction.getReplyToLabel() != null) {
+			
+			if (interaction.getToRole() != null) {
+				action.setClientEPR(interaction.getToRole().getName());
+			} else {
 				action.setClientEPR("client");
 			}
+		}		
+		
+		// If not reply, then include the target service
+		// details
+		if (interaction.getReplyToLabel() == null &&
+				interaction.getToRole() != null &&
+				interaction.getToRole().getName() != null &&
+				interaction.getToRole().getName().length() > 0) {
+			String roleName=Character.toLowerCase(
+					interaction.getToRole().getName().charAt(0))+
+					interaction.getToRole().getName().substring(1);
 			
-		} else {
-			// Receive
+			action.setDestinationExpression(roleName+SERVICE_CATEGORY_ACCESSOR_SUFFIX,
+						roleName+SERVICE_NAME_ACCESSOR_SUFFIX);
+		}
+		
+		if (interaction.getEnclosingDefinition() instanceof Conversation &&
+				interaction.getEnclosingDefinition().getModel()
+						instanceof ConversationModel) {
 			
-			// TODO: Create a new service to receive the
-			// message and add a schedule service to link
-			// to this new service - issue, how do we
-			// deal with request/response
-			if (service.isCreateSession() == false &&
-					service.isSessionBased()) {
-				// Already has activities, so need to separate
-				// into another service descriptor
-				ESBService recvService=esbModel.createService(
-						service.getCategory(),
-						esbModel.getUniqueServiceName(service.getCategory(),
-								service.getName()));
+			java.util.List<Identity> ids=((Conversation)
+					interaction.getEnclosingDefinition()).getIdentities();
 
-				esbModel.addService(recvService);
-				
-				// Add schedule action
-				ScheduleStateAction schedule=
-					new ScheduleStateAction(service);
-				
-				service.addAction(schedule, position);
+			java.util.List<IdentityLocator> locators=
+				((ConversationModel)interaction.getEnclosingDefinition().
+							getModel()).getIdentityLocators();
+			
+			IdentityUtil.defineIdentities(action.getPropertyElement(
+					SendMessageAction.IDENTITIES),
+						interaction.getMessageSignature(), ids, locators);
+		}
+	}
+	
+	protected void insertReceive(ModelChangeContext context,
+			ESBLanguageModel esbModel, ConversationInteraction interaction,
+						int position) {
+		ESBService service=(ESBService)context.getParent();
+		
+		// TODO: Create a new service to receive the
+		// message and add a schedule service to link
+		// to this new service - issue, how do we
+		// deal with request/response
+		if (service.isCreateSession() == false &&
+				service.isSessionBased()) {
+			// Already has activities, so need to separate
+			// into another service descriptor
+			ESBService recvService=esbModel.createService(
+					service.getCategory(),
+					esbModel.getUniqueServiceName(service.getCategory(),
+							service.getName()));
 
-				context.setParent(recvService);
-			}
+			esbModel.addService(recvService);
 			
-			ReceiveMessageAction action=
-					new ReceiveMessageAction((ESBService)context.getParent());
+			// Add schedule action
+			ScheduleStateAction schedule=
+				new ScheduleStateAction(service);
 			
-			if (interaction.getMessageSignature().getOperation() != null) {
-				action.setOperation(interaction.getMessageSignature().getOperation());
-			}
+			service.addAction(schedule, position);
+
+			context.setParent(recvService);
+		}
+		
+		ReceiveMessageAction action=
+				new ReceiveMessageAction((ESBService)context.getParent());
+		
+		if (interaction.getMessageSignature().getOperation() != null) {
+			action.setOperation(interaction.getMessageSignature().getOperation());
+		}
+		
+		String mtype=null;
+		
+		if (interaction.getMessageSignature().getTypes().size() == 1) {
+			TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
 			
-			String mtype=null;
-			
-			if (interaction.getMessageSignature().getTypes().size() == 1) {
-				TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
-				
-				// TODO: Search for an implementation associated with
-				// the type reference, so that the type can be
-				// abstract - possibly have the required message type
-				// notation as part of the context, so that if multiple
-				// implementations found, then can select e.g. XML or
-				// Java as message type representation.
+			// TODO: Search for an implementation associated with
+			// the type reference, so that the type can be
+			// abstract - possibly have the required message type
+			// notation as part of the context, so that if multiple
+			// implementations found, then can select e.g. XML or
+			// Java as message type representation.
 
-				if (ref.getNamespace() != null) {
-					mtype = "{"+ref.getNamespace()+"}";
-				} else {
-					mtype = "";
-				}
-				
-				if (ref.getLocalpart() != null) {
-					mtype += ref.getLocalpart();
-				}
-				
-				action.setMessageType(mtype);
+			if (ref.getNamespace() != null) {
+				mtype = "{"+ref.getNamespace()+"}";
+			} else {
+				mtype = "";
 			}
 			
-			((ESBService)context.getParent()).addAction(action, -1);
+			if (ref.getLocalpart() != null) {
+				mtype += ref.getLocalpart();
+			}
 			
-			// If not a response, then add to the gateway
-			if (interaction.getReplyToLabel() == null) {
-				ESBService gwService=esbModel.getGatewayService();
+			action.setMessageType(mtype);
+		}
+		
+		((ESBService)context.getParent()).addAction(action, -1);
+		
+		// If not a response, then add to the gateway
+		if (interaction.getReplyToLabel() == null) {
+			ESBService gwService=esbModel.getGatewayService();
+			
+			if (gwService != null) {
+				ESBAction gwAction=gwService.getGatewayAction();
 				
-				if (gwService != null) {
-					ESBAction gwAction=gwService.getGatewayAction();
+				if (gwAction instanceof MessageRouterAction) {
+					MessageRouterAction mra=(MessageRouterAction)
+								gwAction;
 					
-					if (gwAction instanceof MessageRouterAction) {
-						MessageRouterAction mra=(MessageRouterAction)
-									gwAction;
-						
-						java.util.List<String> mtypes=new java.util.Vector<String>();
-						mtypes.add(mtype);
-						
-						mra.addRoute(((ESBService)context.getParent()).getCategory(),
-								((ESBService)context.getParent()).getName(),
-								false, mtypes);
-					}
+					java.util.List<String> mtypes=new java.util.Vector<String>();
+					mtypes.add(mtype);
+					
+					mra.addRoute(((ESBService)context.getParent()).getCategory(),
+							((ESBService)context.getParent()).getName(),
+							false, mtypes);
 				}
-				
-				// Set client EPR
+			}
+			
+			// Set client EPR
+			if (interaction.getFromRole() != null) {
+				action.setClientEPR(interaction.getFromRole().getName());
+			} else {
 				action.setClientEPR("client");
 			}
+		}		
+		
+		if (interaction.getEnclosingDefinition() instanceof Conversation &&
+				interaction.getEnclosingDefinition().getModel()
+						instanceof ConversationModel) {
+			
+			java.util.List<Identity> ids=((Conversation)
+					interaction.getEnclosingDefinition()).getIdentities();
+
+			java.util.List<IdentityLocator> locators=
+				((ConversationModel)interaction.getEnclosingDefinition().
+							getModel()).getIdentityLocators();
+			
+			IdentityUtil.defineIdentities(action.getPropertyElement(
+					SendMessageAction.IDENTITIES),
+						interaction.getMessageSignature(), ids, locators);
 		}
-		
-		return(true);
 	}
-	
 }

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IdentityUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IdentityUtil.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IdentityUtil.java	2008-07-31 12:04:01 UTC (rev 208)
@@ -0,0 +1,84 @@
+/*
+ * 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.jboss.tools.overlord.jbossesb.model.change;
+
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class IdentityUtil {
+
+	private static final String LOCATOR_ATTR = "locator";
+	private static final String NAME_ATTR = "name";
+	private static final String TOKEN_ELEMENT = "token";
+	private static final String TYPE_ATTR = "type";
+	private static final String IDENTITY_ELEMENT = "identity";
+
+	public static void defineIdentities(org.w3c.dom.Element identities,
+			MessageSignature message, java.util.List<Identity> ids,
+			java.util.List<IdentityLocator> locators) {
+		
+		// Clear root child nodes
+		while (identities.getFirstChild() != null) {
+			identities.removeChild(identities.getFirstChild());
+		}
+		
+		for (int i=0; i < ids.size(); i++) {
+			org.w3c.dom.Element identity=
+				identities.getOwnerDocument().createElement(IDENTITY_ELEMENT);
+			identity.setAttribute(TYPE_ATTR,
+					ids.get(i).getIdentityType().name().toLowerCase());
+			
+			boolean f_valid=true;
+			
+			for (int j=0; f_valid && j < ids.get(i).getNames().size(); j++) {
+				String token=ids.get(i).getNames().get(j);
+				String locator=null;
+				
+				for (int k=0; locator == null &&
+						k < message.getTypes().size(); k++) {
+					
+					// Find locator for type
+					for (int l=0; locator == null &&
+								l < locators.size(); l++) {
+						IdentityLocator il=locators.get(l);
+						
+						if (il.getType().equals(message.getTypes().get(k))) {
+							locator = il.getLocator(token);
+						}
+					}
+				}
+				
+				if (locator == null) {
+					f_valid = false;
+				} else {
+					org.w3c.dom.Element tokenElem=
+						identities.getOwnerDocument().createElement(TOKEN_ELEMENT);
+					
+					identity.appendChild(tokenElem);
+					
+					tokenElem.setAttribute(NAME_ATTR, token);
+					tokenElem.setAttribute(LOCATOR_ATTR, locator);
+				}
+			}
+			
+			if (f_valid) {
+				identities.appendChild(identity);
+			}
+		}
+	}
+}




More information about the overlord-commits mailing list