Author: objectiser
Date: 2008-07-31 12:26:56 -0400 (Thu, 31 Jul 2008)
New Revision: 210
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/IdentityUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
Removed:
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/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
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/IfModelChangeRule.java
Log:
Added lookahead analysis to determine message types for SwitchAction, and used the same
information to then link relevant SwitchAction's to the MessageRouter.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-31
15:14:10 UTC (rev 209)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -23,6 +23,7 @@
import org.scribble.conversation.model.*;
import org.scribble.model.*;
import org.jboss.tools.overlord.jbossesb.model.change.*;
+import org.jboss.tools.overlord.jbossesb.model.util.IdentityUtil;
/**
* The model component for the 'MessageRouterAction'. Although
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-31
15:14:10 UTC (rev 209)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -18,6 +18,7 @@
package org.jboss.tools.overlord.jbossesb.model.actions;
import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.conversation.model.*;
@@ -197,48 +198,39 @@
*
* @param category The service category
* @param name The service name
- * @param messageTypes The list of message types
+ * @param messageTypes The set of interactions
* @param position The position
*/
public void addCase(String category, String name,
- java.util.List<String> messageTypes, int position) {
+ java.util.Set<Interaction> messageTypes, int position) {
org.w3c.dom.Element paths=getPropertyElement(PATHS);
- /*
- org.w3c.dom.NodeList nl=
- getAction().getElementsByTagName(PROPERTY_ELEMENT);
-
- for (int i=0; paths == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
-
- if (propName != null && propName.equals(PATHS)) {
- paths = (org.w3c.dom.Element)nl.item(i);
- }
- }
- }
-
- if (paths == null) {
- paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
- paths.setAttribute(NAME_ATTR, PATHS);
-
- getAction().appendChild(paths);
- }
- */
-
org.w3c.dom.Element path=
getAction().getOwnerDocument().createElement(CASE);
path.setAttribute(SERVICE_CATEGORY, category);
path.setAttribute(SERVICE_NAME, name);
- for (int i=0; i < messageTypes.size(); i++) {
- org.w3c.dom.Element mt=
- getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
-
- mt.setAttribute(TYPE_ATTR, messageTypes.get(i));
+ if (messageTypes != null) {
+ java.util.Iterator<Interaction> iter=messageTypes.iterator();
- path.appendChild(mt);
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+ org.w3c.dom.Element mt=
+ getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
+
+ mt.setAttribute(TYPE_ATTR,
+ InteractionUtil.getTypeString(
+ interaction.getMessageSignature().
+ getTypes().get(0)));
+
+ path.appendChild(mt);
+ }
+ }
}
paths.appendChild(path);
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-31
15:14:10 UTC (rev 209)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -19,6 +19,8 @@
import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.IdentityUtil;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.scribble.conversation.model.*;
@@ -79,12 +81,7 @@
ConversationInteraction interaction=(ConversationInteraction)mobj;
// Check if send or receive
- if ((interaction.getFromRole() != null &&
- interaction.getFromRole().equals(
- context.getRole())) ||
- (interaction.getToRole() != null &&
- interaction.getToRole().equals(
- context.getRole()) == false)) {
+ if (InteractionUtil.isSend(interaction)) {
// Send
insertSend(context, esbModel, interaction, position);
Deleted:
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 2008-07-31
15:14:10 UTC (rev 209)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IdentityUtil.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -1,84 +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.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);
- }
- }
- }
-}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-07-31
15:14:10 UTC (rev 209)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -17,12 +17,16 @@
*/
package org.jboss.tools.overlord.jbossesb.model.change;
+import java.util.logging.Logger;
+
import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
import org.scribble.conversation.model.*;
-import org.scribble.extensions.RegistryInfo;
+import org.scribble.extensions.*;
/**
* This is the model change rule for the If grouping construct.
@@ -134,7 +138,19 @@
// Switch action, as role is a decision observer
SwitchAction switchAction=new SwitchAction(service);
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
service.addAction(switchAction, position);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
@@ -152,11 +168,30 @@
context.insert(model, cb.getContents().get(j), j);
}
- java.util.List<String> messageTypes=new java.util.Vector<String>();
- messageTypes.add("testType");
+ java.util.Set<Interaction> interactions=null;
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
switchAction.addCase(subService.getCategory(),
- subService.getName(), messageTypes, i);
+ subService.getName(), interactions, i);
+
+ 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) {
@@ -174,16 +209,54 @@
context.insert(model,
ifElem.getElseBlock().getContents().get(j), j);
}
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(ifElem.getElseBlock());
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, -1);
- java.util.List<String> messageTypes=new java.util.Vector<String>();
- messageTypes.add("testType");
+ java.util.Iterator<Interaction> iter=interactions.iterator();
- switchAction.addCase(subService.getCategory(),
- subService.getName(), messageTypes, -1);
+ 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 (messageTypes.size() > 0) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
}
return(true);
}
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.jbossesb.model.change");
}
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/IdentityUtil.java
(from rev 208,
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/util/IdentityUtil.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/IdentityUtil.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -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.util;
+
+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);
+ }
+ }
+ }
+}
Property changes on:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/IdentityUtil.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java 2008-07-31
16:26:56 UTC (rev 210)
@@ -0,0 +1,73 @@
+/*
+ * 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.util;
+
+import org.scribble.model.*;
+
+/**
+ * This class contains utility functions for dealing with Interactions.
+ */
+public class InteractionUtil {
+
+ /**
+ * This method returns the text representation of the
+ * supplied type reference.
+ *
+ * @param ref The type reference
+ * @return The text for the type
+ */
+ public static String getTypeString(TypeReference ref) {
+ String ret="";
+
+ if (ref.getNamespace() != null) {
+ ret = "{"+ref.getNamespace()+"}";
+ }
+
+ ret += ref.getLocalpart();
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied interaction
+ * 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.getEnclosingDefinition() != null) {
+ role = interaction.getEnclosingDefinition().
+ getModelName().getLocatedRole();
+ }
+
+ if (role != null && ((interaction.getFromRole() != null &&
+ interaction.getFromRole().equals(
+ role)) ||
+ (interaction.getToRole() != null &&
+ interaction.getToRole().equals(
+ role) == false))) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}