Author: objectiser
Date: 2009-01-29 15:55:30 -0500 (Thu, 29 Jan 2009)
New Revision: 472
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
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/ConversationInteractionModelChangeRule.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:
Ensure stateless description is built by locating the main 'switch' action that
acts as the root action for the session type.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -445,8 +445,8 @@
public boolean isGateway() {
boolean ret=false;
- for (int i=0; ret == false && i < m_actions.size(); i++) {
- ret = m_actions.get(i).isGateway();
+ if (m_actions.size() == 1) {
+ ret = m_actions.get(0).isGateway();
}
return(ret);
@@ -479,9 +479,9 @@
public boolean isStateless() {
boolean ret=false;
- for (int i=0; i < m_actions.size(); i++) {
- if (m_actions.get(i).isGateway()) {
- ret = m_actions.get(i).isGateway();
+ for (int i=0; ret == false && i < m_actions.size(); i++) {
+ if (m_actions.get(i).isStateless()) {
+ ret = true;
}
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
/**
* The abstract model component for the 'ReceiveMessageAction'
@@ -26,7 +25,7 @@
*
* @author gary
*/
-public abstract class AbstractInteractionMessageAction extends AbstractESBAction {
+public abstract class AbstractInteractionMessageAction extends AbstractStatelessESBAction
{
private static final long serialVersionUID = 3272234577154434603L;
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -0,0 +1,66 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.actions.stateless;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.AbstractESBAction;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ProblemDefinitions;
+
+/**
+ * This is the generic ESB action class.
+ *
+ * @author gary
+ */
+public abstract class AbstractStatelessESBAction extends AbstractESBAction {
+
+ private static final long serialVersionUID = -4436864250793029006L;
+
+ /**
+ * The constructor for initializing the action based on
+ * an existing DOM element.
+ */
+ protected AbstractStatelessESBAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
+ * The contructor for initializing a new action.
+ */
+ protected AbstractStatelessESBAction(ESBService service,
+ String actionClass) {
+ super(service, actionClass);
+ }
+
+ /**
+ * This method determines whether the gateway service is
+ * related to a stateless session.
+ *
+ * @return Whether the gateway service is stateless
+ */
+ @Override
+ public boolean isStateless() {
+ return(true);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
import org.scribble.model.*;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
@@ -29,7 +28,7 @@
*
* @author gary
*/
-public class IfAction extends AbstractESBAction {
+public class IfAction extends AbstractStatelessESBAction {
private static final long serialVersionUID = 9005791673502330699L;
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -1,366 +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.cdl.runtime.jbossesb.model.actions.stateless;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.conversation.model.ConditionalBlock;
-import org.scribble.conversation.model.If;
-import org.scribble.model.*;
-import org.scribble.model.admin.ModelIssue;
-import org.scribble.model.admin.ModelListener;
-
-/**
- * The model component for the 'MessageRouterAction'. Although
- * not an integral part of the behaviour of a service, it provides
- * a behavioural gateway to ensure that messages sent to a
- * specific endpoint reference are routed to the appropriate
- * ESB service descriptor. Therefore the routing configuration
- * needs to be synchronized with the definition of the service
- * descriptors representing the various behavioural states associated
- * with a service.
- *
- * @author gary
- */
-public class MessageRouterAction extends AbstractESBAction {
-
- private static final long serialVersionUID = 2920316907680509410L;
-
- public static final String INITIATE = "initiate";
- public static final String SERVICE_NAME = "service-name";
- public static final String SERVICE_CATEGORY = "service-category";
- public static final String ROUTE = "route";
- public static final String PATHS = "paths";
- public static final String MESSAGE_ELEMENT="message";
- public static final String TYPE_ATTR="type";
- public static final String CONVERSATION_TYPE = "conversationType";
-
- /**
- * The constructor for the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param action The XML configuration details for the action
- */
- public MessageRouterAction(ESBService service,
- org.w3c.dom.Element action) {
- super(service, action);
- }
-
- /**
- * This constructor initializes the DOM element for
- * the action.
- *
- * @param service The reference to the service in which
- * the action will be contained
- */
- public MessageRouterAction(ESBService service) {
- super(service, ESBActionFactory.getConversationAction(
- MessageRouterAction.class));
- }
-
- /**
- * This method determines whether the action is a gateway
- * for inbound requests.
- *
- * @return Whether the action is a gateway
- */
- @Override
- public boolean isGateway() {
- return(true);
- }
-
- /**
- * This method determines whether the ESB action represents
- * a new session type.
- *
- * @return Whether the action represents a new session type
- */
- @Override
- public boolean isSessionType() {
- return(true);
- }
-
- /**
- * This method adds a route to the message router action.
- *
- * @param category The service category
- * @param name The service name
- * @param initiate Whether the route initiates the service
- * @param messageTypes The list of message types
- */
- public void addRoute(String category, String name, boolean initiate,
- java.util.List<MessageSignature> messageTypes) {
-
- org.w3c.dom.Element paths=getPropertyElement(PATHS);
-
- org.w3c.dom.Element path=
- getAction().getOwnerDocument().createElement(ROUTE);
- path.setAttribute(SERVICE_CATEGORY, category);
- path.setAttribute(SERVICE_NAME, name);
-
- if (initiate) {
- path.setAttribute(INITIATE, Boolean.toString(initiate));
- }
-
- for (int i=0; i < messageTypes.size(); i++) {
- org.w3c.dom.Element mt=
- getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
-
- if (messageTypes.get(i).getTypes().size() == 1) {
- TypeReference ref=messageTypes.get(i).getTypes().get(0);
-
- mt.setAttribute(TYPE_ATTR, InteractionUtil.getTypeString(ref));
-
- path.appendChild(mt);
- } else {
- logger.warning("Can only handle single type message signatures");
- }
- }
-
- paths.appendChild(path);
- }
-
- /**
- * This method returns the number of routes associated with
- * the message router.
- *
- * @return The number of routes
- */
- public int getNumberOfRoutes() {
- int ret=0;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- ret = nl.getLength();
-
- return(ret);
- }
-
- /**
- * This method returns the DOM element associated with the
- * specified route.
- *
- * @param index The index of the required route
- * @return The route element, or null if not found
- */
- public org.w3c.dom.Element getRouteElement(int index) {
- org.w3c.dom.Element ret=null;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- if (index >= 0 && index < nl.getLength() &&
- nl.item(index) instanceof org.w3c.dom.Element) {
- ret = (org.w3c.dom.Element)nl.item(index);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the DOM element associated with the
- * specified service category and name.
- *
- * @param category The service category
- * @param name The service name
- * @return The route element, or null if not found
- */
- public org.w3c.dom.Element getRouteElement(String category,
- String name) {
- org.w3c.dom.Element ret=null;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- ret = (org.w3c.dom.Element)nl.item(i);
-
- if (ret.getAttribute(SERVICE_CATEGORY).equals(category) == false ||
- ret.getAttribute(SERVICE_NAME).equals(name) == false) {
- ret = null;
- }
- }
- }
-
- return(ret);
- }
-
-
- /**
- * 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 returns the mandatory property names.
- *
- * @return The mandatory property names
- */
- @Override
- protected java.util.List<String> getMandatoryProperties() {
- java.util.List<String> ret=super.getMandatoryProperties();
- ret.add(CONVERSATION_TYPE);
- ret.add(PATHS);
- return(ret);
- }
-
- /**
- * This method validates the ESB action and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- @Override
- public void validate(ModelListener l) {
- super.validate(l);
-
- // Check that message router has no other session based
- // ESB actions in the same service descriptor
- if (getService().isSessionBased()) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER",
- new String[]{})));
- }
-
- // Check that 'initate' services have a 'CreateSessionAction' and
- // represent the root behaviour
- for (int i=0; i < m_initiateServices.size(); i++) {
- ESBService service=m_initiateServices.get(i);
-
- if (service.isRoot() == false) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_CANNOT_INITIATE_NON_ROOT",
- new String[]{service.getCategory(),
- service.getName()})));
- }
- }
-
- // Check that non-'initate' services don't have a
'CreateSessionAction' and
- // represent the root behaviour
- for (int i=0; i < m_services.size(); i++) {
- ESBService service=m_services.get(i);
-
- if (service.isRoot()) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_MUST_INITIATE_ROOT",
- new String[]{service.getCategory(),
- service.getName()})));
- }
- }
-
- org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
- boolean f_serviceDetailsMissing=false;
- int routeCount=0;
-
- for (int i=0; nl != null && i < nl.getLength(); i++) {
-
- org.w3c.dom.Node n=nl.item(i);
-
- if (n instanceof org.w3c.dom.Element) {
- if (n.getNodeName().equals(ROUTE)) {
- routeCount++;
-
- if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
- ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
- f_serviceDetailsMissing = true;
- }
- }
- }
- }
-
- // Report any errors
- if (nl != null && routeCount < 1) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_ROUTER_ONE_OR_MORE_PATHS",
- new String[]{})));
- }
-
- if (f_serviceDetailsMissing) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_PATH_SERVICE_DETAILS_MISSING",
- new String[]{})));
- }
- }
-
- /**
- * This method converts the ESB action into an equivalent
- * behavioural description for conformance checking.
- *
- * @param activities The list of activities that will contain
- * the converted action(s)
- * @param context The conversion context
- */
- @Override
- public void convert(java.util.List<Activity> activities,
- ConversionContext context) {
- org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
-
- If choice=new If();
- activities.add(choice);
-
- for (int i=0; i < nl.getLength(); i++) {
-
- org.w3c.dom.Node n=nl.item(i);
-
- if (n instanceof org.w3c.dom.Element) {
- if (n.getNodeName().equals(ROUTE)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // TODO: Convert the conditional expression if defined
-
- ConditionalBlock cond=new ConditionalBlock();
- choice.getConditionalBlocks().add(cond);
-
- ESBService service=getService().getModel().getService(category, name);
-
- if (service != null) {
- service.convert(cond.getContents(), context);
- }
- }
- }
- }
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless");
-
- private java.util.List<ESBService> m_initiateServices=new
java.util.Vector<ESBService>();
- private java.util.List<ESBService> m_services=new
java.util.Vector<ESBService>();
-}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties 2009-01-29
20:55:30 UTC (rev 472)
@@ -18,6 +18,6 @@
_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more
'elseif' paths and ending with an optional 'else' path
_NOT_SPECIFIED_SERVICE_DETAILS=Send does not provide service category and name
-_NOT_SPECIFIED_SERVICE_OR_CLIENT_EPR=Send does not contain request service category/name
or response client EPR
+_NOT_SPECIFIED_SERVICE_OR_CLIENT_ROLE=Send does not contain request service category/name
or response client role
_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or
name
_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
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-27
22:55:48 UTC (rev 471)
+++
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-29
20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.admin.ModelIssue;
@@ -30,7 +29,7 @@
*
* @author gary
*/
-public class SwitchAction extends AbstractESBAction {
+public class SwitchAction extends AbstractStatelessESBAction {
private static final long serialVersionUID = 3765702614644769281L;
@@ -99,6 +98,28 @@
}
/**
+ * This method determines whether the action is a gateway
+ * for inbound requests.
+ *
+ * @return Whether the action is a gateway
+ */
+ @Override
+ public boolean isGateway() {
+ return(isStateless());
+ }
+
+ /**
+ * This method determines whether the ESB action represents
+ * a new session type.
+ *
+ * @return Whether the action represents a new session type
+ */
+ @Override
+ public boolean isSessionType() {
+ return(isStateless());
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
@@ -267,4 +288,68 @@
paths.appendChild(path);
}
+
+ /**
+ * This method returns the number of cases associated with
+ * the switch.
+ *
+ * @return The number of cases
+ */
+ public int getNumberOfCases() {
+ int ret=0;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ ret = nl.getLength();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the DOM element associated with the
+ * specified case.
+ *
+ * @param index The index of the required route
+ * @return The case element, or null if not found
+ */
+ public org.w3c.dom.Element getCaseElement(int index) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ if (index >= 0 && index < nl.getLength() &&
+ nl.item(index) instanceof org.w3c.dom.Element) {
+ ret = (org.w3c.dom.Element)nl.item(index);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the DOM element associated with the
+ * specified service category and name.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @return The case element, or null if not found
+ */
+ public org.w3c.dom.Element getCaseElement(String category,
+ String name) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ ret = (org.w3c.dom.Element)nl.item(i);
+
+ if (ret.getAttribute(SERVICE_CATEGORY).equals(category) == false ||
+ ret.getAttribute(SERVICE_NAME).equals(name) == false) {
+ ret = null;
+ }
+ }
+ }
+
+ return(ret);
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-27
22:55:48 UTC (rev 471)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-29
20:55:30 UTC (rev 472)
@@ -20,7 +20,6 @@
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
@@ -498,26 +497,26 @@
if (gwService != null) {
ESBAction gwAction=gwService.getGatewayAction();
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
+ if (gwAction instanceof SwitchAction) {
+ SwitchAction mra=(SwitchAction)
gwAction;
org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
+ mra.getCaseElement(service.getCategory(),
service.getName());
if (route != null) {
org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+ route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
for (int i=0; i < nl.getLength(); i++) {
if (nl.item(i) instanceof org.w3c.dom.Element) {
org.w3c.dom.Element mesg=
(org.w3c.dom.Element)nl.item(i);
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ if (mesg.getAttribute(SwitchAction.TYPE_ATTR).
equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ mesg.setAttribute(SwitchAction.TYPE_ATTR,
ma.getMessageType());
}
}
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-27
22:55:48 UTC (rev 471)
+++
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-29
20:55:30 UTC (rev 472)
@@ -332,8 +332,8 @@
service.addAction(switchAction, pos);
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
+ //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);
@@ -456,6 +456,7 @@
// 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=
@@ -464,16 +465,17 @@
if (gwService != null) {
ESBAction gwAction=gwService.getGatewayAction();
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
+ if (gwAction instanceof SwitchAction) {
+ SwitchAction mra=(SwitchAction)
gwAction;
- mra.addRoute(service.getCategory(),
+ mra.addCase(service.getCategory(),
service.getName(),
- false, messageTypes);
+ messageTypes, 0);
}
}
}
+ */
/*
if (service.getFirstSessionBasedAction() == switchAction &&