Author: objectiser
Date: 2009-01-12 16:17:01 -0500 (Mon, 12 Jan 2009)
New Revision: 460
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/Messages.properties
Log:
Initial work on defining a set of 'stateless' conversational actions, along side
the previous 'stateful' equivalents.
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-12
21:15:25 UTC (rev 459)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-12
21:17:01 UTC (rev 460)
@@ -1,626 +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;
-
-import java.util.logging.Logger;
-
-import org.scribble.model.*;
-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.util.ESBModelUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ProblemDefinitions;
-
-/**
- * This is the generic ESB action class.
- *
- * @author gary
- */
-public abstract class AbstractESBAction extends ModelObject
- implements ESBAction {
-
- public static final String IDENTITIES = "identities";
- public static final String ACTION_ELEMENT = "action";
- public static final String VALUE_ATTR = "value";
- public static final String NAME_ATTR = "name";
- public static final String PROPERTY_ELEMENT = "property";
- public static final String CLASS_PROPERTY = "class";
-
- /**
- * The constructor for initializing the action based on
- * an existing DOM element.
- */
- protected AbstractESBAction(ESBService service,
- org.w3c.dom.Element action) {
- initExistingAction(service, action);
- }
-
- /**
- * The contructor for initializing a new action.
- */
- protected AbstractESBAction(ESBService service,
- String actionClass) {
- initNewAction(service, actionClass);
- }
-
- /**
- * This method initializes the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param actionClass The action class
- */
- protected void initNewAction(ESBService service,
- String actionClass) {
- m_service = service;
-
- m_action = service.getService().
- getOwnerDocument().createElement(ACTION_ELEMENT);
-
- m_action.setAttribute(CLASS_PROPERTY, actionClass);
-
- getSource().setObject(this);
- }
-
- /**
- * This method initializes the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param action The XML configuration details for the action
- */
- protected void initExistingAction(ESBService service,
- org.w3c.dom.Element action) {
- m_service = service;
- m_action = action;
-
- int servicesStartPos=-1;
-
- if (m_service.getModel() != null &&
- m_service.getModel().getOriginalContents() != null &&
- (servicesStartPos=m_service.getModel().
- getOriginalContents().indexOf("<services>")) != -1) {
-
- // Find positional information
- int servCount=m_service.getServicePosition();
- int actionCount=getActionPosition();
-
- String str=m_service.getModel().getOriginalContents();
-
- int startPosition=str.indexOf("<service", servicesStartPos+2);
- int endPosition=-1;
- int loggedEndPosition=-1;
-
- while (startPosition != -1 && servCount > 0) {
- servCount--;
-
- endPosition = str.indexOf("</service>", startPosition);
-
- if (servCount > 0) {
- startPosition=str.indexOf("<service", endPosition);
- }
- }
-
- int actionsStartPos=-1;
-
- if (actionCount > 0 &&
- startPosition != -1 && endPosition != -1 &&
- (actionsStartPos=str.indexOf("<actions",
- startPosition)) != -1 &&
- actionsStartPos < endPosition) {
- startPosition=str.indexOf("<action", actionsStartPos+2);
- endPosition=-1;
-
- while (startPosition != -1 && actionCount > 0) {
- actionCount--;
-
- loggedEndPosition = str.indexOf('>', startPosition);
-
- endPosition = str.indexOf("</action>", startPosition);
-
- if (actionCount > 0) {
- startPosition=str.indexOf("<action", endPosition);
- }
- }
-
- // Check whether single line element
- int inlineEndPos=str.indexOf("/>", startPosition);
- int nextStartPos=str.indexOf("<", startPosition+1);
-
- if (inlineEndPos != -1 && inlineEndPos < nextStartPos) {
- endPosition = inlineEndPos;
- }
- }
-
- getSource().setStartPosition(startPosition);
- getSource().setEndPosition(loggedEndPosition);
-
- getSource().getProperties().put("path",
- ESBModelUtil.getPath(m_action));
-
- getSource().setObject(this);
- }
- }
-
- /**
- * This method initializes the links with the ESB service descriptors
- * identified in each path of the action.
- */
- public void initializeLinks() {
- }
-
- /**
- * This method validates the ESB action and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- public void validate(ModelListener l) {
-
- java.util.List<String> mandatory=getMandatoryProperties();
-
- for (int i=0; i < mandatory.size(); i++) {
- if (getPropertyValue(mandatory.get(i)) == null) {
- java.util.Map<String,Object> props=new
java.util.HashMap<String,Object>();
- props.put(ProblemDefinitions.PROBLEM_PROPERTY,
- mandatory.get(i));
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.Messages"),
- "_NOT_SPECIFIED_PROPERTY",
- new String[]{mandatory.get(i)}), props));
- }
- }
-
- java.util.List<String> propNames=getPropertyNames();
-
- for (int i=0; i < propNames.size(); i++) {
- String propName=propNames.get(i);
-
- if (getOptionalProperties().contains(propName) == false &&
- getMandatoryProperties().contains(propName) == false) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.Messages"),
- "_UNKNOWN_PROPERTY",
- new String[]{propName})));
- }
- }
-
- String session=getPropertyValue(DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
-
- if (session != null) {
- // Validate that the business object type exists
- try {
- ClassLoader cl=
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ClasspathUtil.getClassLoader(getService().getModel());
-
- try {
- Class.forName(session, true, cl);
- } catch(ClassNotFoundException cfne) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.Messages"),
- "_NOT_FOUND_BUSINESS_OBJECT_TYPE",
- new String[]{session})));
- }
-
- } catch(Exception e) {
- logger.log(java.util.logging.Level.SEVERE,
- "Failed to load business class '"+session+"'", e);
- }
- }
-
- // Validate links
- for (int i=0; i < m_links.size(); i++) {
- ESBLink link=(ESBLink)m_links.get(i);
-
- if (link.getService() == null) {
- // If target service not found, then report error
- // unless it is a remote service, so defined in a
- // different file
- if (link.isRemote() == false) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.Messages"),
- "_NOT_FOUND_SERVICE_DESCRIPTOR",
- new String[]{link.getCategory(),link.getName()})));
- }
- } else if (getService().getSessionName() != null &&
- isPerform() == false && link.isRemote() == false &&
- link.getService().getSessionName() != null &&
- getService().getSessionName().equals(
- link.getService().getSessionName()) == false) {
-
- java.util.Map<String,Object> props=new
java.util.HashMap<String,Object>();
- props.put(ProblemDefinitions.PROBLEM_PROPERTY,
- DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
-
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.Messages"),
- "_MISMATCH_SESSION_CLASS",
- new String[]{link.getCategory(),link.getName()}), props));
- }
- }
- }
-
- /**
- * This method determines if the action represents a loop construct.
- *
- * @return Whether the action represents a loop construct
- */
- public boolean isLoop() {
- return(false);
- }
-
- /**
- * This method determines whether the action is related to a behavioural
- * session.
- *
- * @return Whether the action is session based
- */
- public boolean isSessionBased() {
- return(true);
- }
-
- /**
- * This method determines whether the ESB action represents
- * a CreateSessionAction.
- *
- * @return Whether the action is a CreateSessionAction
- */
- public boolean isCreateSession() {
- return(false);
- }
-
- /**
- * This method determines whether the action is a gateway
- * for inbound requests.
- *
- * @return Whether the action is a gateway
- */
- public boolean isGateway() {
- return(false);
- }
-
- /**
- * This method indicates whether this action performs another
- * sub-conversation.
- *
- * @return Whether the action is a 'perform'
- */
- public boolean isPerform() {
- return(false);
- }
-
- /**
- * This method indicates whether the action is an initiator.
- * Initiator actions must precede any other session based
- * action, within an ESB service.
- *
- * @return Whether the action is an initiator
- */
- public boolean isInitiator() {
- return(false);
- }
-
- /**
- * This method returns the mandatory property names.
- *
- * @return The mandatory property names
- */
- protected java.util.List<String> getMandatoryProperties() {
- java.util.List<String> ret=new java.util.Vector<String>();
- return(ret);
- }
-
- /**
- * This method returns the optional property names.
- *
- * @return The optional property names
- */
- protected java.util.List<String> getOptionalProperties() {
- java.util.List<String> ret=new java.util.Vector<String>();
- ret.add(DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
- ret.add(IDENTITIES);
- ret.add(DefaultESBService.SERVICE_DESCRIPTION_NAME_PROPERTY);
- return(ret);
- }
-
- /**
- * This method returns the action's class name.
- *
- * @return The action's class name
- */
- public String getActionClass() {
- String ret=null;
-
- if (m_action != null) {
- ret = m_action.getAttribute(CLASS_PROPERTY);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the property value associated
- * with the supplied name.
- *
- * @param property The property name
- * @return The property value, or null if not found
- */
- public String getPropertyValue(String property) {
- String ret=null;
-
- if (m_action != null) {
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getAttribute(VALUE_ATTR);
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method determines the property value, associated
- * with the supplied name, is defined.
- *
- * @param property The property name
- * @return Whether the property has been defined
- */
- public boolean hasProperty(String property) {
- boolean ret=false;
-
- if (m_action != null) {
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == false && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = true;
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the element associated with the
- * requested property. If the property does not exist, then
- * it will be created.
- *
- * @param property The property
- * @return The element
- */
- public org.w3c.dom.Element getPropertyElement(String property) {
- org.w3c.dom.Element ret=null;
-
- if (m_action != null) {
- org.w3c.dom.NodeList nl=
- getAction().getElementsByTagName(PROPERTY_ELEMENT);
-
- for (int i=0; ret == 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(property)) {
- ret = (org.w3c.dom.Element)nl.item(i);
- }
- }
- }
-
- if (ret == null) {
- ret = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
- ret.setAttribute(NAME_ATTR, property);
-
- m_action.appendChild(ret);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method removes the named property from the action.
- *
- * @param property The property name
- */
- public void removePropertyElement(String property) {
-
- if (m_action != null) {
- org.w3c.dom.Node prop=null;
- org.w3c.dom.NodeList nl=
- getAction().getElementsByTagName(PROPERTY_ELEMENT);
-
- for (int i=0; prop == 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(property)) {
- prop = nl.item(i);
- }
- }
- }
-
- if (prop != null) {
- m_action.removeChild(prop);
- }
- }
- }
-
- /**
- * This method returns the list of property names defined for
- * this action.
- *
- * @return The list of property names
- */
- public java.util.List<String> getPropertyNames() {
- java.util.List<String> ret=new java.util.Vector<String>();
-
- if (m_action != null) {
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT)) {
- ret.add(((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR));
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the 'property' child nodes, associated with the
- * supplied property name, within the action configuration.
- *
- * @param property The property name
- * @return The list of child nodes
- */
- public org.w3c.dom.NodeList getPropertyChildNodes(String property) {
- org.w3c.dom.NodeList ret=null;
-
- org.w3c.dom.NodeList nl=m_action.getChildNodes();
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element &&
- nl.item(i).getNodeName().equals(PROPERTY_ELEMENT) &&
- ((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR).
- equals(property)) {
- ret = ((org.w3c.dom.Element)nl.item(i)).getChildNodes();
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns the reference to the service that contains the
- * action.
- *
- * @return The service
- */
- public ESBService getService() {
- return(m_service);
- }
-
- /**
- * This method sets the service description name property.
- *
- * @param name The service description name
- */
- public void setServiceDescriptionName(String name) {
-
- org.w3c.dom.Element prop=getPropertyElement(
- DefaultESBService.SERVICE_DESCRIPTION_NAME_PROPERTY);
-
- if (prop != null) {
- prop.setAttribute(VALUE_ATTR, name);
- }
- }
-
- /**
- * This method sets the business object type property.
- *
- * @param name The business object type
- */
- public void setBusinessObjectType(String type) {
-
- org.w3c.dom.Element prop=getPropertyElement(
- DefaultESBService.BUSINESS_OBJECT_TYPE_PROPERTY);
-
- if (prop != null) {
- prop.setAttribute(VALUE_ATTR, type);
- }
- }
-
- /**
- * This method returns the XML configuration representation of the action.
- *
- * @return The XML configuration for the action
- */
- public org.w3c.dom.Element getAction() {
- return(m_action);
- }
-
- /**
- * This method returns the list of links established by this action.
- *
- * @return The list of links
- */
- protected java.util.List<ESBLink> getLinks() {
- return(m_links);
- }
-
- /**
- * 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
- */
- public abstract void convert(java.util.List<Activity> activities,
- ConversionContext context);
-
- /**
- * This method returns the node position of the action configuration
- * within the service descriptor.
- *
- * @return The action position
- */
- protected int getActionPosition() {
- org.w3c.dom.Element service=(org.w3c.dom.Element)
- getAction().getParentNode().getParentNode();
-
- int actionCount=0;
- boolean f_end=false;
-
- org.w3c.dom.NodeList acts=service.getElementsByTagName(ACTION_ELEMENT);
-
- for (int i=0; f_end == false &&
- i < acts.getLength(); i++) {
- org.w3c.dom.Node act=acts.item(i);
-
- actionCount++;
- if (act == getAction()) {
- f_end = true;
- }
- }
-
- return(actionCount);
- }
-
- private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
-
- private ESBService m_service=null;
- private org.w3c.dom.Element m_action=null;
- private java.util.List<ESBLink> m_links=new java.util.Vector<ESBLink>();
-}
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/Messages.properties
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/Messages.properties 2009-01-12
21:15:25 UTC (rev 459)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/Messages.properties 2009-01-12
21:17:01 UTC (rev 460)
@@ -1,47 +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.
-# */
-
-_BOOLEAN=Boolean property '{0}' can only have a 'true' or 'false'
value
-_CANNOT_INITIATE_NON_ROOT=Cannot 'initiate' non-root service descriptor for
category '{0}' and name '{1}'
-_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER=Cannot define MessageRouterAction with session
based actions in service descriptor
-_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more
'elseif' paths and ending with an optional 'else' path
-_INVALID_PROPERTY_TYPE=Property '{0}' on class '{1}' must be of type
'{2}'
-_MISMATCH_SESSION_CLASS=Session class mismatch with service descriptor for category
'{0}' and name '{1}'
-_MULTIPLE_JOINS=Action has multiple joins
-_MUST_DEFINE_SINGLE_WHILE_PATH=While action must have a single 'while' path
-_MUST_DEFINE_SINGLE_WHILE_EXIT=While action must have a single 'exit' path
-_MUST_INITIATE_ROOT=Must 'initiate' root service descriptor for category
'{0}' and name '{1}'
-_NOT_FOUND_VARIABLE=Variable '{0}' could not be found on class '{1}'
-_NOT_FOUND_VARIABLE_PROPERTY=Variable '{0}' contains property '{1}' that
could not be found on class '{2}'
-_NOT_FOUND_PERFORM_CREATE_SESSION=Perform action can only invoke a service descriptor
that starts with a CreateSessionAction
-_NOT_READABLE_PROPERTY=Property '{0}' on class '{1}' is not readable
-_NOT_SPECIFIED_CONVERSATION_TYPE=Conversation type must be specified on root service
descriptor
-_NOT_SPECIFIED_CONVERSATION_TYPE_ROLE=Conversation type '{0}' must specify a role
name following the '@' symbol
-_NOT_SPECIFIED_PROPERTY=Property '{0}' must be specified
-_NOT_SPECIFIED_REQ_RESP_EPR=Send does not contain request service category/name or
response client EPR
-_NOT_WRITABLE_PROPERTY=Property '{0}' on class '{1}' is not writable
-_MUST_BE_FIRST_ACTION='{0}' action must be first in the service descriptor
-_MUST_SPECIFY_STATE_OR_MESSAGE_EXPRESSION=Must specify either a State OR Message based
expression
-_PARALLEL_MORE_THAN_TWO_PATHS=Parallel action must specify two or more paths
-_PARALLEL_PATH_AFTER_JOIN=Parallel path must not be defined after a join
-_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or
name
-_ROUTER_ONE_OR_MORE_PATHS=MessageRouter action must specify one or more routes
-_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
-_UNKNOWN_PROPERTY=Property '{0}' is unknown for this action
-_WHEN_ONE_OR_MORE_PATHS=When action must specify atleast one entry
-_WHILE_PATH_AFTER_EXIT=While path must not be defined after an exit