You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:35:26 UTC
svn commit: r381694 [24/38] - in /incubator/ode/scratch: bpe/ ode/
ode/bpelTests/ ode/bpelTests/probeService/ ode/bpelTests/test1/
ode/bpelTests/test10/ ode/bpelTests/test12/ ode/bpelTests/test13/
ode/bpelTests/test14/ ode/bpelTests/test15/ ode/bpelTes...
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELExpressionVariable.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELExpressionVariable.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELExpressionVariable.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELExpressionVariable.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,399 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 25, 2003
+ */
+package org.apache.ode.deployment.bpel;
+
+//import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jaxen.JaxenException;
+import org.jaxen.dom.DOMXPath;
+
+import org.apache.ode.action.bpel.XPathJaxenExpression;
+import org.apache.ode.definition.IPMDLocator;
+import org.apache.ode.definition.IPMDLocatorHolder;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.interaction.IInvocationFactory;
+import org.apache.ode.lang.ResourceGetter;
+
+/**
+ *
+ * Parses BPEL expression syntax using pattern matching. Generates BPE process context locators
+ * for BPEL expression variables.
+ *
+ * @author waterman
+ */
+class BPELExpressionVariable extends BPELVariable {
+
+ private static final Logger logger = Logger.getLogger(BPELCopy.class.getName());
+
+
+ // The runtime engine has a locator resolver that expects variables
+ // within XPATH notation to adhear to the following format.
+// private static final MessageFormat bpeFormat = new MessageFormat("\\${0}");
+// private Object bpeVar[] = new Object[1];
+ private static final String LOCATOR_NAME = "var";
+
+ //private static final Pattern variableDataPattern = Pattern.compile("getVariableData\\(.*?\\)");
+ //private static final Pattern variablePropertyPattern = Pattern.compile("getVariableProperty\\(.*?\\)");
+ //private static final Pattern linkStatusPattern = Pattern.compile("getLinkStatus\\(.*?\\)");
+
+ private static final Pattern oneParamPattern = Pattern.compile(".*?\\(\\s*'(.*?)'\\s*\\).*");
+ private static final Pattern twoParamPattern = Pattern.compile(".*?\\(\\s*'(.*?)'\\s*,\\s*'(.*?)'\\s*\\).*");
+ private static final Pattern threeParamPattern = Pattern.compile(".*?\\(\\s*'(.*?)'\\s*,\\s*'(.*?)'\\s*,\\s*'(.*?)'\\s*\\).*");
+
+ private String m_bpelExpression; // The native BPEL Expression
+ private String m_bpeExpression; // The natvie BPEL Expression as a BPE runtime expression
+ private int m_varCounter; // Keeps track of the number of variables within a locator
+
+ private HashMap varMap; // A map of BPE variable to the BEPL expression its used in
+
+ BPELExpressionVariable( String bpelExpression ) {
+ super(new BPELAttributes(),logger);
+ m_bpelExpression = bpelExpression;
+
+ }
+
+ /**
+ * Parses out the BPEL params from a BPEL data access function and generates
+ * a BPE locator name for the BPEL params.
+ *
+ * @param p
+ * @param type
+ */
+// private void extentionMatcher(Pattern p, BPELExpressionType type) {
+//
+// Matcher m = p.matcher(m_bpeExpression);
+//
+// StringBuffer buff = new StringBuffer();
+// while ( m.find() ) {
+//
+// bpeVar[0] = LOCATOR_NAME + m_varCounter;
+// m.appendReplacement(buff,bpeFormat.format(bpeVar));
+// String temp = m_bpeExpression.substring(m.start(),m.end());
+//
+// varMap.put(String.valueOf(m_varCounter),new BPELExpressionTuple(type,m_bpeExpression.substring(m.start(),m.end())));
+//
+// m_varCounter++;
+// }
+// m.appendTail(buff);
+//
+// m_bpeExpression = buff.toString();
+// }
+
+ private void parseBpelFunctionCalls()
+ {
+ int openGetVariableData = m_bpeExpression.lastIndexOf("getVariableData(");
+ int openGetVariableProperty = m_bpeExpression.lastIndexOf("getVariableProperty(");
+ int openGetLinkStatus = m_bpeExpression.lastIndexOf("getLinkStatus(");
+
+
+ while ((openGetVariableData > -1) ||
+ (openGetVariableProperty > -1) ||
+ (openGetLinkStatus > -1))
+ {
+ int open = -1;
+ int endOpen = -1;
+ BPELExpressionType type;
+ if ((openGetVariableData > openGetVariableProperty)&&(openGetVariableData > openGetLinkStatus))
+ {
+ open = openGetVariableData;
+ type = BPELExpressionType.VARIABLE_DATA;
+ endOpen = open + 16;
+ }else if ((openGetVariableProperty > openGetVariableData)&&(openGetVariableProperty > openGetLinkStatus))
+ {
+ open = openGetVariableProperty;
+ type = BPELExpressionType.VARIABLE_PROPERTY;
+ endOpen = open + 20;
+ }else
+ {
+ open = openGetLinkStatus;
+ type = BPELExpressionType.LINK_STATUS;
+ endOpen = open + 14;
+ }
+
+ int close = m_bpeExpression.indexOf(")", open+1);
+ //int nextcall = m_bpeExpression.indexOf("(", open+16);
+ int nextcall = m_bpeExpression.indexOf("(", endOpen);
+ while ((nextcall > -1) && (nextcall < close))
+ {
+ close = m_bpeExpression.indexOf(")", close+1);
+ nextcall= m_bpeExpression.indexOf("(", nextcall+1);
+ }
+ String temp = m_bpeExpression.substring(open,close+1);
+ varMap.put(String.valueOf(m_varCounter),new BPELExpressionTuple(type,
+ temp));
+ m_bpeExpression = m_bpeExpression.substring(0, open) +
+ "$var" + String.valueOf(m_varCounter) +
+ m_bpeExpression.substring(close+1, m_bpeExpression.length());
+
+ m_varCounter++;
+
+ openGetVariableData = m_bpeExpression.lastIndexOf("getVariableData(");
+ openGetVariableProperty = m_bpeExpression.lastIndexOf("getVariableProperty(");
+ openGetLinkStatus = m_bpeExpression.lastIndexOf("getLinkStatus(");
+
+ }
+ }
+
+// private void tomsMatcher(BPELExpressionType type)
+// {
+// String local = m_bpeExpression;
+// String something = "getVariableData('counter')";
+// varMap.put(String.valueOf(m_varCounter),new BPELExpressionTuple(type,something));
+// m_varCounter++;
+// something="getVariableData('operation1Request','newParameter1','/ns1:TibRVMsg/ns1:Fields/ns1:Field[$var1]/ns1:Name')";
+// varMap.put(String.valueOf(m_varCounter),new BPELExpressionTuple(type,something));
+// m_varCounter++;
+//
+// m_bpeExpression = "$var2";
+// }
+
+ /**
+ * Determines how many params have been defined within a BPEL data
+ * access function. Params can be optional for some data access functions.
+ * See BPEL spec on data access for more detail on BPEL data access functions.
+ *
+ * @param expression
+ * @return
+ */
+ private Matcher matchParamPatterns(String expression) {
+ Matcher m = null;
+
+ m = threeParamPattern.matcher(expression);
+ if ( m.matches() ) return m;
+
+ m = twoParamPattern.matcher(expression);
+ if ( m.matches() ) return m;
+
+ m = oneParamPattern.matcher(expression);
+ if ( m.matches() ) return m;
+
+ return null;
+ }
+
+ /**
+ * Generates a BPE locator for the BPEL getVariableData() function
+ *
+ * @param m
+ * @param expression
+ * @param locatorName
+ * @param node
+ * @param locator
+ * @throws DefinitionServiceException
+ */
+ private void handleData(Matcher m, String expression, String locatorName, BPELNode node, BPELNode tagNode, IPMDLocatorHolder locator, BPELInvocationType type) throws DeploymentException {
+
+ String locationPath = null;
+ String processName = node.getProcess().getAttributes().getName();
+ String variableName = null;
+ String partName = null;
+ IInvocationFactory invFactory = null;
+
+ try {
+ variableName = expression.substring(m.start(1),m.end(1));
+ } catch ( Exception e ) {
+ variableName = null;
+ }
+
+ if ( variableName == null ) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_NULLVARPARM",new Object[] {node.getProcess().getAttributes().getName(), expression},null);
+ }
+
+ BPELVariable var = node.getVariable(variableName);
+
+ StringBuffer bpePath = new StringBuffer(var.getScopePath(new BPELScopePath(node.inCompensationHandler())).toString());
+ bpePath.append(BPELScopePath.PATH_DELIMITER + variableName);
+
+ if ( m.groupCount() > 2 ) {
+ locationPath = expression.substring(m.start(3),m.end(3));
+ }
+ try {
+
+ if ( m.groupCount() > 1 ) {
+ // append the partName
+ partName = expression.substring(m.start(2),m.end(2));
+ bpePath.append(BPELScopePath.PATH_DELIMITER + partName);
+ invFactory = var.getInvFactory(processName,partName);
+ } else {
+ invFactory = var.getInvFactory(processName);
+ }
+ } catch ( DeploymentException e) {
+ // User may need a little more information
+ logger.log(Level.SEVERE,ResourceGetter.getFormatted("BPEL_EXP_INVALID", new Object[] {node.getProcess().getAttributes().getName(),expression}));
+ throw e;
+ }
+
+ addUsedInActivity(node);
+
+
+
+ try {
+ IPMDLocator loc =
+ node.createLocator(true,locator,locatorName, bpePath.toString(),
+ getInvocation(locationPath,tagNode,type,invFactory),
+ null, 0, false, false);
+ addUsedInLocator(loc);
+ } catch (Exception e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATELOCATOR",new Object[] {node.getProcess().getAttributes().getName(), locatorName,bpePath.toString(),locationPath},e);
+ }
+ }
+
+ /**
+ * Generates a BPE locator for the BPEL getVariableProperty() function
+ *
+ * @param m
+ * @param expression
+ * @param locatorName
+ * @param node
+ * @param locator
+ */
+ private void handleProperty(Matcher m, String expression, String locatorName, BPELNode node, BPELNode tagNode, IPMDLocatorHolder locator, BPELInvocationType type) throws DeploymentException {
+
+ if ( m.groupCount() != 2 ) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_PROPIVALID",new Object[] {node.getProcess().getAttributes().getName(), expression},null);
+ }
+
+ String processName = node.getProcess().getAttributes().getName();
+ String locationPath = null;
+ String variableName = expression.substring(m.start(1),m.end(1));
+
+ BPELVariable var = node.getVariable(variableName);
+
+ StringBuffer bpePath = new StringBuffer(var.getScopePath(new BPELScopePath(node.inCompensationHandler())).toString());
+ bpePath.append(BPELScopePath.PATH_DELIMITER + variableName);
+
+ BPELAttributes attr = node.getPropertyAttributes(node.getQName(expression.substring(m.start(2),m.end(2))),node.getQName(var.getAttributes().getMessageType()));
+
+ IInvocationFactory invFactory = null;
+ if ( attr.getPart() != null ) {
+ bpePath.append(BPELScopePath.PATH_DELIMITER + attr.getPart());
+ invFactory = var.getInvFactory(processName,attr.getPart());
+ } else {
+ invFactory = var.getInvFactory(processName);
+ }
+ locationPath = attr.getQuery();
+
+ addUsedInActivity(node);
+
+ try {
+ IPMDLocator loc = node.createLocator(true,locator,locatorName,
+ bpePath.toString(),
+ getInvocation(locationPath,tagNode,type,invFactory),
+ null, 0, false, false);
+ addUsedInLocator(loc);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATELOCATOR",new Object[] {node.getProcess().getAttributes().getName(), locatorName,bpePath.toString(),locationPath},e);
+ }
+
+ }
+
+ /**
+ *
+ * Generates a BPE locator for the BPEL bpws:getLinkStatus() function
+ *
+ * @param m
+ * @param expression
+ * @param locatorName
+ * @param node
+ * @param locator
+ * @throws DefinitionServiceException
+ */
+ private void handleLinkStatus(Matcher m, String expression, String locatorName, BPELNode node, IPMDLocatorHolder locator) throws DeploymentException {
+ if ( m.groupCount() != 1 ) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_LINKINVALID",new Object[] {node.getProcess().getAttributes().getName(), expression},null);
+ }
+
+ addUsedInActivity(node);
+
+ try {
+ IPMDLocator loc = node.createLocator(true,locator,locatorName,
+ expression.substring(m.start(1),m.end(1)), null, null,
+ 0, false, false);
+ addUsedInLocator(loc);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATELOCATOR",new Object[] {node.getProcess().getAttributes().getName(), locatorName,expression.substring(m.start(1),m.end(1)),"no query specified"},e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELVariable#createLocator(org.apache.ode.definition.IPMDLocatorHolder, org.apache.ode.deployment.bpel.BPELNode, org.apache.ode.deployment.bpel.BPELAttributes, boolean)
+ */
+ Object createLocator(
+ IPMDLocatorHolder locator,
+ BPELNode node,
+ BPELNode tagNode,
+ BPELAttributes attrs,
+ BPELInvocationType type,
+ boolean forOutPut)
+ throws DeploymentException {
+
+ m_varCounter = locator.getLocatorSize() + 1;
+ m_bpeExpression = m_bpelExpression;
+ XPathJaxenExpression retVal = null;
+ varMap = new HashMap();
+
+ // parse out the BPEL variable locator expression and add in the BPEngine locator expression
+ //extentionMatcher(variableDataPattern, BPELExpressionType.VARIABLE_DATA);
+ //extentionMatcher(variablePropertyPattern, BPELExpressionType.VARIABLE_PROPERTY);
+ //extentionMatcher(linkStatusPattern, BPELExpressionType.LINK_STATUS);
+ parseBpelFunctionCalls();
+
+ // Use Jaxen to validate the expression
+ try {
+ new DOMXPath(m_bpeExpression);
+ } catch (JaxenException je) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_XPATH_INVALID",new Object[] {node.getProcess().getAttributes().getName(), m_bpelExpression, m_bpeExpression},je);
+ }
+
+ // iterate over the expression variables and build the BPE Locator
+ Matcher m = null;
+ retVal = new XPathJaxenExpression(m_bpeExpression,m_bpelExpression);
+ String locatorName = null;
+ for (Iterator mapItr = varMap.entrySet().iterator(); mapItr.hasNext(); ) {
+ Map.Entry me = (Map.Entry)mapItr.next();
+ BPELExpressionTuple et = (BPELExpressionTuple)me.getValue();
+ m = matchParamPatterns(et.getExpression());
+ locatorName = LOCATOR_NAME+(String)me.getKey();
+ retVal.addVariableMap(locatorName,et.getExpression());
+
+ if ( et.getType() == BPELExpressionType.LINK_STATUS ) {
+ handleLinkStatus(m, et.getExpression(), locatorName, node, locator);
+ }
+
+ if ( et.getType() == BPELExpressionType.VARIABLE_DATA ) {
+ handleData(m, et.getExpression(), locatorName, node, tagNode, locator, type);
+ }
+
+ if ( et.getType() == BPELExpressionType.VARIABLE_PROPERTY ) {
+ handleProperty(m, et.getExpression(), locatorName, node, tagNode, locator, type);
+ }
+
+ }
+ return retVal;
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFlow.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFlow.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFlow.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFlow.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,408 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 19, 2003
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.UnInitVariableMetaData;
+import org.apache.ode.condition.XPathJoinConditional;
+import org.apache.ode.condition.XPathTransitionConditional;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+
+/**
+ * Implements the BPEL <i>flow</i> node. The flow construct provides concurrency and synchronization for parallel
+ * activity execution.
+ * <p>
+ * The catch node is held by a <i>scope</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tFlow.
+ *
+ * @author waterman
+ *
+ */
+class BPELFlow extends BPELStructuredActivity {
+ private static final Logger logger = Logger.getLogger(BPELFlow.class.getName());
+
+ private static final MessageFormat linkStatusFormat = new MessageFormat("getLinkStatus({0})");
+ private static final String OR = " or ";
+ private Object m_linkNameVar[] = new Object[1];
+
+ // These vars are used to create the transition and join conditions
+ protected static final String XPATH_JOIN_COND_CLASS = org.apache.ode.condition.XPathJoinConditional.class.getName();
+ private static final String XPATH_TRAN_COND_CLASS = org.apache.ode.condition.XPathTransitionConditional.class.getName();
+ protected static final String UNINITVAR_KEY = XPathJoinConditional.UNINITVAR_KEY;
+ protected static final String JOIN_EXPRESSION_KEY = XPathJoinConditional.JOIN_EXPRESSION_KEY;
+ private static final String TRAN_EXPRESSION_KEY = XPathTransitionConditional.TRAN_EXPRESSION_KEY;
+ protected static final String SUPPRESS_KEY = XPathJoinConditional.SUPPRESS_KEY;
+ private static final String DEFAULT_CONDITION = XPathTransitionConditional.DEFAULT_CONDITION;
+
+ private HashMap m_links = new HashMap(); // BPEL links
+ private HashSet m_activities = new HashSet(); // Activities of the flow
+
+ BPELFlow(BPELNode node, BPELAttributes attrs) throws DeploymentException {
+ super(node,BPELSchema.FLOW,attrs, logger);
+ }
+
+ /**
+ * A flow defines links that are used to synchronize concurrent
+ * activites. Adds a new link into the flows link definition
+ * collection.
+ *
+ * @param link
+ */
+ void addLinkTag(BPELLink link) {
+ m_links.put(link.getName(),link);
+ }
+
+ /**
+ * When a Flow is popped from the BPEL stack the flow's
+ * logical links must be physically set within the process
+ * definition object.
+ * <BR>
+ * The BPEL spec does not do a very good job in defining the full behavior
+ * of links. The following questions are not answered by the spec.
+ * <BR>
+ * The spec states that a link can cross a structured activity however
+ * it is not clear whether a structured link must cross an activity boundry.<BR>
+ * For example if a flow contains a sequence and the sequence contains both
+ * the source and target nodes of a flow link. What is the behavior? What
+ * is the flow supposed to do with this.
+ * <P>
+ * Currently the deploy tool will throw an exception if a link does not cross
+ * an activity boundry.
+ *
+ *
+ */
+ BPELNode pop() throws DeploymentException {
+
+
+ // TODO: Lance - cycle detection.
+
+ validateLinks();
+
+ createLinks();
+
+ setConditionals();
+
+ return super.pop();
+ }
+
+ /**
+ * Called by the Repostitory Handler when a Source or Target tag is found
+ * on a Flow activity.
+ *
+ * @param name
+ * @return
+ * @throws DefinitionServiceException
+ */
+ BPELLink setLink(String name, BPELNode node, BPELLinkType linkType, String tCondition) throws DeploymentException {
+ BPELLink ret = null;
+
+ if ( (ret = (BPELLink)m_links.get(name)) == null ) {
+ // This Flow does not own the Link so pass the request to
+ // the parser stack to see if an enclosing Flow owns the link.
+ ret = m_parserStack.setLink(name, node, linkType, tCondition);
+ } else {
+ if ( node instanceof BPELLinkedActivity) {
+ // Notify all objects that the activity is using a link
+ if ( linkType == BPELLinkType.TARGET ) ret.setTarget((BPELLinkedActivity)node); else ret.setSource((BPELLinkedActivity)node);
+ if ( tCondition != null ) ret.setTransitionCondition(tCondition);
+ ((BPELLinkedActivity)node).addLink(ret,linkType);
+ node.notifyLink(ret,this);
+ }
+ }
+
+ return ret;
+ }
+
+ BPELLink notifyLink(BPELLink link, BPELFlow node) throws DeploymentException {
+ if ( this == node ) return link;
+ if ( m_parserStack != null ) return m_parserStack.notifyLink(link, node);
+ return null;
+ }
+
+
+ void addActivity(BPELNode activity) throws DeploymentException {
+ m_activities.add(activity);
+ }
+
+
+ private void createRTLink(BPELLinkedActivity source, BPELLinkedActivity target, BPELProcessType sourceType) throws DeploymentException {
+
+ createProcessSequence(target.getAttributes(),target.getStartProcess());
+
+ // Link the process into the flow
+ source.linkProcess(sourceType,target,BPELProcessType.START,true);
+ }
+
+ private void createMerge(BPELLinkedActivity la) throws DeploymentException {
+
+ createProcessSync(la.getStartProcess(),la.getAttributes().getName(),String.valueOf(la.getLinkCounter(BPELLinkType.TARGET)));
+ // iterate over the set of target links
+
+
+ for ( Iterator itr = la.getLinks(BPELLinkType.TARGET); itr.hasNext(); ) {
+ BPELLink link = (BPELLink)itr.next();
+ link.consumed(true);
+ BPELLinkedActivity proxySource = (BPELLinkedActivity)link.getSource().getProxy(this,link.getSource());
+
+ proxySource.linkProcess(BPELProcessType.END,la,BPELProcessType.START,true);
+ }
+ }
+
+ private void buildTransitionCondition(BPELLinkedActivity la, BPELExpressionVariable joinExp) throws DeploymentException {
+
+ // condLinks is a map of BPEL link name to transitionCondition expression
+ // the map is passed to the conditional implementation as a property.
+ // Each link name in the condLinks map has an out-bound status associated
+ // with it. By default the out-bound status is set to true, if a transitionCondition
+ // is supplied on the source of the link the transitionCondition is evaluated
+ // and this becomes the out-bound status. The out-bound status is placed into the
+ // process context by the conditional impl.
+ // Note: this is all laid out in the BPEL spec under the
+ // <flow> definition.
+
+ HashMap condLinks = new HashMap();
+ IPMDChangeCondition cc=null;
+ try {
+ cc = la.getEndProcess().createChangeCondition(
+ "BPEL transitionCondition", XPATH_TRAN_COND_CLASS);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+ for ( Iterator linkItr = la.getLinks(BPELLinkType.SOURCE); linkItr.hasNext(); ) {
+ BPELLink link = (BPELLink)linkItr.next();
+
+ if ( link.getTransitionCondition() != null ) {
+ // Add the XPATH expression as a property to the conditional impl
+ condLinks.put(link.getName(),link.getTransitionCondition().createLocator(cc,la,link.getSource(),null,BPELInvocationType.SELECT_VALUE,false));
+ } else {
+ // Let the conditional implementation know it should use the
+ // default transitionCondition for this link. The default will
+ // set the outgoing link status to true;
+ condLinks.put(link.getName(),DEFAULT_CONDITION);
+ }
+
+ // The conditional implementation will add the out-bound link status
+ // into the process context, therefore it needs the locators for
+ // the out-bound link status variable.
+ //addLinkStatusSystemVariable(link,cc,la);
+ link.getTransitionCondVar().createLocator(cc,la,null,null,true);
+ link.consumed(true);
+ }
+
+ Properties md = new Properties();
+ md.put(BPELFlow.UNINITVAR_KEY,new UnInitVariableMetaData(BPELSchema.BPEL_URI,BPELSchema.FAULT_UNINIT_VAR));
+ md.put(TRAN_EXPRESSION_KEY,condLinks);
+
+ // If the activity is also a target it may have a joinCondition
+ if ( joinExp != null ) {
+ md.put(JOIN_EXPRESSION_KEY,joinExp.createLocator(cc,la,null,BPELInvocationType.SELECT_VALUE,false));
+ md.put(SUPPRESS_KEY,(BPELBoolean.NO.equals(la.getAttributes().getSuppressJoin())) ? BPELBoolean.NO.getBooleanValue() : la.getSuppressJoinFailure().getBooleanValue());
+ }
+ cc.setMetadata(md);
+ }
+
+
+ private BPELExpressionVariable buildJoinCondition(BPELLinkedActivity la) throws DeploymentException {
+
+ // All activities of a flow that are the target of a link will have
+ // a joinCondition. The joinCondition may be implicit
+ // ( i.e. getLinkStatus('link1') or getLinkStatus('link2') )
+ // If the joinCondition evaluates to false and the suppressJoinFailure
+ // is set to false the engine will throw a bpws:joinFailure.
+ // If suppressJoinFailure is set to true the joinCondition evaluates to
+ // false the engine will not fire the associated action impl and
+ // if the activity is also a source activity all out-bound link status
+ // are set to false.
+ // Note: this is all laid out in the BPEL spec under the
+ // <flow> definition.
+
+
+ String joinCondition = la.getAttributes().getJoinCondition();
+
+ if ( joinCondition == null ) {
+ // create the implicit joinCondition
+ int cntr = 0;
+ StringBuffer buff = new StringBuffer();
+ for (Iterator linkItr = la.getLinks(BPELLinkType.TARGET); linkItr.hasNext(); cntr++ ) {
+ if ( cntr != 0 ) buff.append(OR);
+ m_linkNameVar[0] = "'"+((BPELLink)linkItr.next()).getName()+"'";
+ buff.append(linkStatusFormat.format(m_linkNameVar));
+ }
+ joinCondition = buff.toString();
+ }
+
+ BPELExpressionVariable expVar = new BPELExpressionVariable(joinCondition);
+
+ // Iterate over the change conditions currently found on the process
+ // and change the conditional implementation to the join conditional.
+ // Note: this is ok to do since the BPEL deployment always creates
+ // a new process with the default change condition.
+
+ la.addJoinCondtion(expVar);
+
+ return expVar;
+
+ }
+
+ void addJoinCondtion(BPELVariable var) throws DeploymentException {
+
+ super.addJoinCondtion(var);
+
+// for ( Iterator itr = m_activities.iterator(); itr.hasNext(); ) {
+// ((BPELNode)itr.next()).addJoinCondtion(var);
+// }
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "The flow activity starts logical threads of execution within a business process. It is a container for executing other activities and thus it does not have an action implementation." ;
+ }
+
+ private void validateLinks() throws DeploymentException {
+ // Validate the Links
+ Iterator linksItr = m_links.values().iterator();
+ while ( linksItr.hasNext() ) {
+ BPELLink link = (BPELLink)linksItr.next();
+ if ( link.getSource() == link.getTarget() ) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_LINKREF",new Object[] {getProcess().getAttributes().getName(), link.getName()},null);
+ }
+ if ( link.getSource() == null || link.getTarget() == null ){
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_NULLLINKREF",new Object[] {getProcess().getAttributes().getName(), link.getName()},null);
+ }
+ }
+
+ }
+
+ private void createLinks() throws DeploymentException {
+
+ Vector mergeNodes = new Vector(); // nodes to be merged on flow end
+
+ // iterate over the activities of the flow and link them together
+ Iterator activitiesItr = m_activities.iterator();
+ while ( activitiesItr.hasNext() ) {
+ BPELLinkedActivity la = (BPELLinkedActivity)activitiesItr.next();
+
+ if ( la.getLinkCounter(BPELLinkType.TARGET) == 0 ) {
+ // This activity node is not the target of a BPEL link
+ createRTLink(this,la,BPELProcessType.START);
+
+ // If this is not a source activity then merge on flow end activity
+ if ( la.getLinkCounter(BPELLinkType.SOURCE) == 0 ) {
+ // The activity is not part of a link
+ mergeNodes.add(la);
+ }
+ } else {
+ // the activity is the target of a link
+ if ( la.getLinkCounter(BPELLinkType.TARGET) == 1 ) {
+ // This is a potential sequence target
+ BPELLink tLink = (BPELLink)la.getLinks(BPELLinkType.TARGET).next();
+ tLink.consumed(true);
+ BPELLinkedActivity proxySource = (BPELLinkedActivity)tLink.getSource().getProxy(this,tLink.getSource());
+ createRTLink(proxySource,la, BPELProcessType.END);
+ } else {
+ // This is a merge target
+ createMerge(la);
+ }
+
+ // merge on flow end
+ if ( la.getLinkCounter(BPELLinkType.SOURCE) == 0 ) {
+ mergeNodes.add(la);
+ }
+
+ }
+
+ }
+
+ // iterate over all the nodes that merge on the end of the flow
+ createProcessSync(getEndProcess(),getAttributes().getName(),String.valueOf(mergeNodes.size()));
+ for (Iterator mergeNodeItr = mergeNodes.iterator(); mergeNodeItr.hasNext(); ) {
+ ((BPELLinkedActivity)mergeNodeItr.next()).linkProcess(BPELProcessType.END,this,BPELProcessType.END,false);
+ }
+
+ }
+
+ private void setConditionals() throws DeploymentException {
+
+
+ // once all the linkages between source and target nodes have been
+ // created, iterate over the flow activites once again to set the
+ // transitionConditions and joinConditions
+ HashMap linkMap = new HashMap();
+
+ for (Iterator condItr = m_activities.iterator(); condItr.hasNext();){
+ BPELLinkedActivity condActivity = (BPELLinkedActivity)condItr.next();
+
+ BPELExpressionVariable joinExp = null;
+
+ if (condActivity.getLinkCounter(BPELLinkType.TARGET) > 0) {
+ joinExp = buildJoinCondition(condActivity);
+ if (condActivity.getLinkCounter(BPELLinkType.SOURCE) > 0){
+ for (Iterator iter = condActivity.getLinks(BPELLinkType.SOURCE); iter.hasNext(); )
+ {
+ BPELLink link = (BPELLink)iter.next();
+ linkMap.put(link.getName(), joinExp);
+ }
+ }
+ }
+
+ }
+
+ // after the conditionals have been set iterate over the links and set links
+ // that have not been set. Note - links may be located on
+ // activities that are not owned by the flow ( i.e. a sequence, switch )
+ for (Iterator linkItr = m_links.values().iterator(); linkItr.hasNext(); ) {
+ BPELLink link = (BPELLink)linkItr.next();
+
+
+ // if the link is within a conditional then proxy the link to the
+ // end of the conditional
+ //buildTransitionCondition(link.getSource(),null);
+ BPELExpressionVariable joinExp = (BPELExpressionVariable) linkMap.get(link.getName());
+ buildTransitionCondition(link.getSource(),joinExp);
+
+
+ // Link source to target
+ if ( !link.isConsumed()) {
+ ((BPELLinkedActivity)link.getSource().getProxy(this,link.getSource())).linkProcess(BPELProcessType.END,link.getTarget(),BPELProcessType.START,true);
+ }
+ }
+ }
+
+ BPELNode getProxy(BPELFlow linkOwner, BPELNode source) {
+ if ( linkOwner == this ) return source;
+ if ( m_parserStack != null ) return m_parserStack.getProxy(linkOwner,source);
+ return source;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFrom.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFrom.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFrom.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELFrom.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jul 10, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.logging.Logger;
+
+
+/**
+ * Implements the BPEL <i>from</i> node. The from node holds a
+ * attributes that define the from values of a <i>copy</i> node
+ * <p>
+ * The from node is held by a <i>copy</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tFrom.
+ *
+ * @author waterman
+ * @see BPELCopy
+ *
+ */
+class BPELFrom extends BPELNode {
+ private static final Logger logger = Logger.getLogger(BPELFrom.class.getName());
+
+ private String literalData;
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ */
+ BPELFrom(BPELNode previous, BPELAttributes attrs) {
+ super(previous, BPELSchema.FROM, attrs, logger);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+ m_parserStack.addActivity(this);
+ return m_parserStack;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addData(java.lang.String)
+ */
+ void addData(String data) {
+ // a from node may contain xml literals
+ literalData = data;
+ }
+
+ String getData() {
+ return literalData;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraft.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraft.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraft.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraft.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Apr 12, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.Properties;
+
+import org.apache.ode.action.bpel.CopyAction;
+import org.apache.ode.definition.IPMDAction;
+
+/**
+ * @author tcampbel
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class BPELGraft extends BPELCopy {
+
+ public BPELGraft(BPELNode node, BPELAttributes attr)
+ {
+ super(node, attr);
+ }
+
+ protected void buildToProperty(Properties md, IPMDAction ccact, BPELInvocationType fromType) throws DeploymentException {
+ BPELVariable var = getVariable(getToAttributes().getVariable());
+ BPELAttributes attr = getPropertyAttributes(getQName(getToAttributes().getBPWSProperty()),getQName(var.getAttributes().getMessageType()));
+
+ //m_hasToQuery = ( attr.getQuery() != null ) ? true : false;
+
+ BPELInvocationType toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+
+ //if ( !m_hasFromQuery && !m_hasToQuery ) {
+ // This is a variable to variable copy
+ // ccact.setActionClass(org.apache.ode.action.bpel.CopyContextNodeAction.class.getName());
+ //}
+
+ //if ( fromType == BPELInvocationType.SELECT_NODE){
+ // toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+ //} else {
+ // if ( attr.getQuery() != null ) {
+ // toType = BPELInvocationType.UPDATE_VALUE;
+ // } else {
+ // toType = BPELInvocationType.UPDATE_OBJECT;
+ // }
+ //}
+
+ md.put(CopyAction.TO_VARIABLE_KEY,var.createLocator(ccact,this,m_to,attr,toType,true));
+ }
+
+ protected void buildToVariable(Properties md, IPMDAction ccact, BPELInvocationType fromType) throws DeploymentException {
+ BPELVariable var = getVariable(getToAttributes().getVariable());
+
+ //m_hasToQuery = ( getToAttributes().getQuery() != null ) ? true : false;
+
+ BPELInvocationType toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+
+ //if ( !m_hasFromQuery && !m_hasToQuery ) {
+ // This is a variable to variable copy
+ // ccact.setActionClass(org.apache.ode.action.bpel.CopyContextNodeAction.class.getName());
+ //}
+
+ //if ( fromType == BPELInvocationType.SELECT_NODE){
+ // toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+ //} else {
+ // if ( getToAttributes().getQuery() != null ) {
+ // toType = BPELInvocationType.UPDATE_VALUE;
+ // } else {
+ // toType = BPELInvocationType.UPDATE_OBJECT;
+ // }
+ //}
+ md.put(CopyAction.TO_VARIABLE_KEY,var.createLocator(ccact,this,m_to,getToAttributes(),toType,true));
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraftChildren.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraftChildren.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraftChildren.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELGraftChildren.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Apr 15, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.Properties;
+
+import org.apache.ode.action.bpel.CopyAction;
+import org.apache.ode.definition.IPMDAction;
+
+/**
+ * @author tcampbel
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class BPELGraftChildren extends BPELCopy
+{
+ public BPELGraftChildren(BPELNode node, BPELAttributes attr)
+ {
+ super(node, attr);
+ }
+
+ protected void buildToProperty(Properties md, IPMDAction ccact, BPELInvocationType fromType) throws DeploymentException {
+ BPELVariable var = getVariable(getToAttributes().getVariable());
+ BPELAttributes attr = getPropertyAttributes(getQName(getToAttributes().getBPWSProperty()),getQName(var.getAttributes().getMessageType()));
+
+ //m_hasToQuery = ( attr.getQuery() != null ) ? true : false;
+
+ BPELInvocationType toType = BPELInvocationType.GRAFT_CHILDREN_BENEATH_NODE;
+
+ //if ( !m_hasFromQuery && !m_hasToQuery ) {
+ // This is a variable to variable copy
+ // ccact.setActionClass(org.apache.ode.action.bpel.CopyContextNodeAction.class.getName());
+ //}
+
+ //if ( fromType == BPELInvocationType.SELECT_NODE){
+ // toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+ //} else {
+ // if ( attr.getQuery() != null ) {
+ // toType = BPELInvocationType.UPDATE_VALUE;
+ // } else {
+ // toType = BPELInvocationType.UPDATE_OBJECT;
+ // }
+ //}
+
+ md.put(CopyAction.TO_VARIABLE_KEY,var.createLocator(ccact,this,m_to,attr,toType,true));
+ }
+
+ protected void buildToVariable(Properties md, IPMDAction ccact, BPELInvocationType fromType) throws DeploymentException {
+ BPELVariable var = getVariable(getToAttributes().getVariable());
+
+ //m_hasToQuery = ( getToAttributes().getQuery() != null ) ? true : false;
+
+ BPELInvocationType toType = BPELInvocationType.GRAFT_CHILDREN_BENEATH_NODE;
+
+ //if ( !m_hasFromQuery && !m_hasToQuery ) {
+ // This is a variable to variable copy
+ // ccact.setActionClass(org.apache.ode.action.bpel.CopyContextNodeAction.class.getName());
+ //}
+
+ //if ( fromType == BPELInvocationType.SELECT_NODE){
+ // toType = BPELInvocationType.GRAFT_BENEATH_NODE;
+ //} else {
+ // if ( getToAttributes().getQuery() != null ) {
+ // toType = BPELInvocationType.UPDATE_VALUE;
+ // } else {
+ // toType = BPELInvocationType.UPDATE_OBJECT;
+ // }
+ //}
+ md.put(CopyAction.TO_VARIABLE_KEY,var.createLocator(ccact,this,m_to,getToAttributes(),toType,true));
+
+ }
+
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELIOActivity.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELIOActivity.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELIOActivity.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELIOActivity.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Aug 16, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.correlation.PartQuery;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDCorrelation;
+import org.apache.ode.definition.IPMDCorrelationSetDef;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.event.BPELStaticKey;
+import org.apache.ode.event.IStaticKey;
+
+/**
+ * @author waterman
+ *
+ */
+abstract class BPELIOActivity extends BPELLinkedActivity {
+
+ protected Vector m_correlations = new Vector();
+
+ /**
+ * @param previous
+ * @param tag
+ * @param attrs
+ * @throws DeploymentException
+ */
+ public BPELIOActivity(
+ BPELNode previous,
+ BPELSchema tag,
+ BPELAttributes attrs,
+ Logger logger)
+ throws DeploymentException {
+ super(previous, tag, attrs, logger);
+ }
+
+
+ /**
+ * A receive action is identified by its PortType the NameSpace of the PortType
+ * and the operation name.
+ *
+ * @return
+ */
+ BPELStaticKey getStaticKey() throws DeploymentException {
+
+ QName ptName = getQName(getAttributes().getPortType());
+
+ if ( ptName == null ) return null;
+
+ BPELStaticKey bsk = new BPELStaticKey();
+ bsk.setTargetNamespace(ptName.getNamespaceURI());
+ bsk.setPortType(ptName.getLocalPart());
+ bsk.setOperation(getAttributes().getOperation());
+
+ return bsk;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addCorrelation(org.apache.ode.deployment.bpel.BPELCorrelation)
+ */
+ void addCorrelation(BPELCorrelation correlation){
+ m_correlations.add(correlation);
+ }
+
+ // Registers OnMessage
+ protected IPMDOperation getOperation(IPMDAction regAct, IPMDChangeCondition ccB) throws DeploymentException {
+
+ String defID = null;
+
+ defID = getStartProcess().getKey().getValue();
+
+ BPELVariable var = ( getAttributes().getVariable() != null ) ? getVariable(getAttributes().getVariable()) : null;
+
+ return getOperation(regAct,null,var,BPELPatternValue.IN,true,defID);
+
+ }
+
+
+ protected IPMDOperation getOperation(IPMDAction regAct, IPMDAction act, BPELVariable var, BPELPatternValue pattern, boolean isInstantiating, String defID) throws DeploymentException {
+ IPMDCorrelation initCorrelation = null;
+
+ ArrayList pqs = null;
+ IPMDRoot defRoot = getProcess().getDefinitionRoot();
+
+ int varCount = 0;
+ if ( m_correlations.size() > 0 ) {
+
+ if ( var == null ) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CORRVAR", new Object[] {getProcess().getAttributes().getName(), getAttributes().getName() }, null);
+ }
+
+ initCorrelation = defRoot.createCorrelation(getStartProcess().getKey().getValue());
+
+ BPELAttributes pProp = null;
+ for ( Iterator itr = m_correlations.iterator(); itr.hasNext(); ) {
+ BPELCorrelation corr = (BPELCorrelation)itr.next();
+
+ if ( corr.getPattern() == null || pattern.equals(corr.getPattern()) || BPELPatternValue.OUTIN.equals(corr.getPattern())) {
+
+ if (isInstantiating && defID == null && !corr.isInitializing()) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CORR_NONINIT",new Object[] {getProcess().getAttributes().getName()},null);
+ }
+
+ pqs = new ArrayList();
+
+ // BPEL defines correlations as a token list of bpws:properties
+ StringTokenizer st = corr.getProperties();
+ while ( st.hasMoreTokens()) {
+ String prop = st.nextToken();
+ pProp = getPropertyAttributes(getQName(prop),getQName(var.getAttributes().getMessageType()));
+ varCount++;
+
+ String corrLoc = corr.getName()+ ":" + prop;
+ pqs.add(new PartQuery(pProp.getPart(),pProp.getQuery(),corrLoc, buildNsHashMap(pProp.getProperty("NSMAP"))));
+ try {
+ if ( act != null ) {
+ createLocator(true,act,
+ corrLoc,corr.getCorrelationSet().
+ getScopePath(new BPELScopePath(
+ inCompensationHandler())).
+ toString()+BPELScopePath.
+ PATH_DELIMITER+corr.getName()+
+ BPELScopePath.PATH_DELIMITER+prop,
+ null,null,0,corr.isInitializing(),false);
+ }
+ if ( regAct != null ) {
+ createLocator(true,regAct,
+ corrLoc,corr.getCorrelationSet().
+ getScopePath(new BPELScopePath(
+ inCompensationHandler())).toString()+
+ BPELScopePath.PATH_DELIMITER+corr.
+ getName()+BPELScopePath.PATH_DELIMITER+
+ prop,
+ null,null,0,corr.isInitializing(),false);
+ }
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATELOCATOR",new Object[] {getProcess().getAttributes().getName(), "dynamicVar:"+String.valueOf(varCount),getScopePath(new BPELScopePath(inCompensationHandler())).toString()+BPELScopePath.PATH_DELIMITER+corr.getName()+BPELScopePath.PATH_DELIMITER+prop,"no query specified"},e);
+ }
+ }
+
+ if ( !pqs.isEmpty() ) {
+ IPMDCorrelationSetDef corrlSetDef = defRoot.createCorrelationSet(getStartProcess().getKey().getValue()+":"+corr.getName(),pqs);
+ initCorrelation.addCorrelationSet(corrlSetDef,corr.isInitializing(),pattern.getValue());
+ }
+
+ }
+ }
+ }
+
+ return createOperation(defRoot,getStartProcess().getKey().getValue()+
+ ":"+getAttributes().getOperation(),getStaticKey(),
+ initCorrelation,isInstantiating,defID);
+
+ }
+
+ protected IPMDOperation createOperation(IPMDRoot defRoot, String operationId,
+ IStaticKey key, IPMDCorrelation corrl,boolean instanceCreating, String defId) {
+ return defRoot.createOperation(operationId,key,corrl,instanceCreating,defId);
+ }
+
+ private HashMap buildNsHashMap(String nsMap)
+ {
+ HashMap rtn = new HashMap();
+ if (nsMap != null)
+ {
+ StringTokenizer st = new StringTokenizer(nsMap, "|");
+ while (st.hasMoreTokens())
+ {
+ String prefix = st.nextToken();
+ String ns = st.nextToken();
+ rtn.put(prefix, ns);
+ }
+ }
+ return rtn;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvocationType.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvocationType.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvocationType.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvocationType.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Sep 2, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+/**
+ * @author waterman
+ *
+ */
+public class BPELInvocationType {
+
+ private static final String S_VALUE = "s_value";
+ private static final String S_NODE = "s_node";
+ private static final String S_OBJECT = "s_object";
+ private static final String U_VALUE = "u_value";
+ private static final String U_NODE = "u_node";
+ private static final String U_CHILDREN_NODE = "u_children_node";
+ private static final String U_OBJECT = "u_object";
+ private static final String NONE = "none";
+
+ private String m_value;
+
+
+ private BPELInvocationType() {
+ }
+
+ private BPELInvocationType(String value) {
+ m_value = value;
+ }
+
+ static final BPELInvocationType SELECT_VALUE = new BPELInvocationType(S_VALUE);
+ static final BPELInvocationType SELECT_NODE = new BPELInvocationType(S_NODE);
+ static final BPELInvocationType SELECT_OBJECT = new BPELInvocationType(S_OBJECT);
+ static final BPELInvocationType UPDATE_VALUE = new BPELInvocationType(U_VALUE);
+ static final BPELInvocationType GRAFT_BENEATH_NODE = new BPELInvocationType(U_NODE);
+ static final BPELInvocationType GRAFT_CHILDREN_BENEATH_NODE = new BPELInvocationType(U_CHILDREN_NODE);
+ static final BPELInvocationType UPDATE_OBJECT = new BPELInvocationType(U_OBJECT);
+ public static final BPELInvocationType NO_INVOCATION = new BPELInvocationType(NONE);
+
+ public boolean equals(Object obj)
+ {
+ if ( obj instanceof BPELInvocationType ) {
+ return m_value.equals(((BPELInvocationType)obj).m_value);
+ }
+ if ( obj instanceof String ) {
+ return m_value.equals((String)obj);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return m_value.hashCode();
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvoke.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvoke.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvoke.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELInvoke.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 21, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//import javax.xml.namespace.QName;
+
+import org.apache.ode.action.bpel.RegisterAction;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.wsdl.extensions.ExtentionConstants;
+
+
+/**
+ * Implements the BPEL <i>invoke</i> node. The invoke node holds
+ * attributes that define the invocation of a WSDL definition.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tInvoke.
+ *
+ * @author waterman
+ * @see BPELCorrelation
+ */
+class BPELInvoke extends BPELIOActivity {
+ private static final Logger logger = Logger.getLogger(BPELCompensate.class.getName());
+
+ private static final String EXT_ACTION_PROPS = "external_action_properties";
+
+// private Vector correlations = new Vector(); // correlations mapped to the invoke
+
+ private ExtensibilityArtifacts m_art;
+
+ /**
+ * @param previous the parent schema node
+ * @param attrs the schema attributes
+ */
+ BPELInvoke(BPELNode previous, BPELAttributes attrs, ExtensibilityArtifacts art)
+ throws DeploymentException {
+ super(previous, BPELSchema.INVOKE, attrs, logger);
+ m_art = art;
+
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#collectThreadBoundries(java.util.HashSet)
+ */
+ HashSet collectThreadBoundries(HashSet hs) {
+
+ hs.add(this);
+
+ return super.collectThreadBoundries(hs);
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#addCorrelation(org.apache.ode.deployment.bpel.BPELCorrelation)
+ */
+// void addCorrelation(BPELCorrelation correlation){
+// correlations.add(correlation);
+// }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+
+// QName port = getQName(getAttributes().getPortType());
+
+ BPELVariable inputVar = ( getAttributes().getInputVariable() != null ) ? getVariable(getAttributes().getInputVariable()) : null;
+ BPELVariable outputVar = ( getAttributes().getOutputVarible() != null ) ? getVariable(getAttributes().getOutputVarible()) : null;
+
+ BPELAction action = m_art.getBindingInvokeAction(getAttributes().getPortType(),getAttributes().getOperation(),getAttributes().getName(),inputVar,outputVar,this);
+
+ createInvokeAction(action,inputVar,outputVar);
+
+ return super.pop();
+ }
+
+ private void createInvokeAction(BPELAction act, BPELVariable inputVar, BPELVariable outputVar) throws DeploymentException {
+ IPMDProcess process = getStartProcess();
+
+ ArrayList ops = new ArrayList();
+ IPMDOperation op = null;
+
+ IPMDAction ccact = null;
+ try {
+ // Create the change condition
+ IPMDChangeCondition cc =
+ process.createChangeCondition("ChangeCondition: " + getAttributes().getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+
+ // Create the invoke action
+ ccact =
+ cc.createAction(
+ "ChangeAction:" + getAttributes().getName(),
+ act.getAction().getBPEImplementation());
+
+
+ if (inputVar != null) {
+ ccact.addMetadata(org.apache.ode.action.internal.IInternalAction.INPUT_LOCATOR,
+ inputVar.createLocator(ccact,this,null,BPELInvocationType.SELECT_NODE,false));
+ if ( !m_correlations.isEmpty() ) {
+ op = getOperation(null,ccact,inputVar,BPELPatternValue.OUT,false,null);
+ if ( op != null ) ops.add(op);
+ }
+ }
+
+ if ( outputVar != null ) {
+ ccact.addMetadata(org.apache.ode.action.internal.IInternalAction.OUTPUT_LOCATOR,
+ outputVar.createLocator(ccact,this,null,BPELInvocationType.SELECT_NODE,true));
+ if ( !m_correlations.isEmpty() ) {
+ op = getOperation(null,ccact,outputVar,BPELPatternValue.IN,false,null);
+ if ( op != null ) ops.add(op);
+ }
+ }
+
+ ccact.addMetadata(ExtentionConstants.ATTR_IMPL,act.getAction().getImplementation());
+ ccact.addMetadata(org.apache.ode.action.bpel.ExternalServiceAction.INPUT_MAP_KEY,act.getInput());
+ ccact.addMetadata(org.apache.ode.action.bpel.ExternalServiceAction.OUTPUT_MAP_KEY,act.getOutput());
+ ccact.addMetadata(org.apache.ode.action.bpel.ExternalServiceAction.OPERATION_KEY,act.getOk());
+ ccact.addMetadata(org.apache.ode.action.bpel.ExternalServiceAction.NAMESPACE,act.getOk().getNameSpace());
+
+ ccact.addMetadata(EXT_ACTION_PROPS,act.getAction().getProps());
+
+ ccact.addMetadata(org.apache.ode.action.bpel.ExternalServiceAction.PARTNER_LINK,getAttributes().getPartnerLink());
+
+ if ( !ops.isEmpty() ) ccact.addMetadata(RegisterAction.OPERATIONS,ops);
+
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELLinkedActivity#getActivityDescription()
+ */
+ String getActivityDescription() {
+ return "invoke external service";
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLink.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLink.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLink.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLink.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 17, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+/**
+ * Implements the BPEL <i>link</i> node. The link node holds
+ * the name of a flow link.
+ * <p>
+ * The link node is held by a <i>flow</i> node.
+ * <p>
+ * See <A HREF="../../../../../BPEL4WS.xsd">BPEL4WS.xsd</A> - complexType = tLink.
+ *
+ * @author waterman
+ * @see BPELFlow
+ *
+ */
+class BPELLink {
+
+ private String m_linkName; // the link name
+
+ private BPELLinkedActivity m_source; // the source of the link
+ private BPELLinkedActivity m_target; // the target of the link
+
+ private boolean isConsumed = false; // identifies when the link has been used to link to processes
+
+ private BPELVariable m_linkStatus; // a system variable that defines the outbound link status
+ private BPELVariable m_tranCond; // a system variable that defines the transition condition
+
+ BPELLink(String name) {
+ m_linkName = name;
+ }
+
+ void setSource(BPELLinkedActivity node) {
+ //TODO: Lance - validation check
+ // if target is set throw exception
+ m_source = node;
+ }
+ BPELLinkedActivity getSource() {
+ // TODO: Lance - validation check
+ // if source is set throw exception
+ return m_source;
+ }
+
+ BPELLinkedActivity getTarget() {
+ return m_target;
+ }
+ void setTarget(BPELLinkedActivity node) {
+ m_target = node;
+ }
+
+ String getName() {
+ return m_linkName;
+ }
+
+ BPELVariable getTransitionCondition() {
+ return m_tranCond;
+ }
+
+ void setTransitionCondition(String tCondition) {
+ if ( tCondition != null ) {
+ m_tranCond = new BPELExpressionVariable(tCondition);
+ }
+ }
+
+ /**
+ * @return Returns the isSet.
+ */
+ boolean isConsumed() {
+ return isConsumed;
+ }
+ /**
+ * @param isSet The isSet to set.
+ */
+ void consumed(boolean isConsumed) {
+ this.isConsumed = isConsumed;
+ }
+
+ BPELVariable getTransitionCondVar() {
+
+ if ( m_linkStatus == null && m_source != null ) {
+ m_linkStatus = new BPELSystemVariable(getName(),getName(),m_source);
+ }
+
+ return m_linkStatus;
+
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkType.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkType.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkType.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkType.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Jun 12, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+/**
+ * An enumeration of the BPEL link type. An activity will be the source or
+ * target of a BPEL link.
+ *
+ * @author waterman
+ */
+class BPELLinkType {
+
+ private String m_value;
+ private static final String SOURCE_VALUE = "SOURCE";
+ private static final String TARGET_VALUE = "TARGET";
+
+ private BPELLinkType() {
+
+ }
+
+ private BPELLinkType ( String type ) {
+ m_value = type;
+ }
+
+ static final BPELLinkType SOURCE = new BPELLinkType(SOURCE_VALUE);
+ static final BPELLinkType TARGET = new BPELLinkType(TARGET_VALUE);
+
+ String getValue()
+ {
+ return m_value;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkedActivity.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkedActivity.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkedActivity.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/bpel/BPELLinkedActivity.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on May 23, 2003
+ *
+ */
+package org.apache.ode.deployment.bpel;
+
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.bpel.StartSequenceAction;
+import org.apache.ode.action.bpel.UnInitVariableMetaData;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.service.DefinitionServiceException;
+
+
+/**
+ *
+ * The linked activity is a BPEL activity node that holds a
+ * runtime metadata process definition object. A linked activity holds
+ * an IPMDProcess definition.
+ *
+ * @author waterman
+ */
+abstract class BPELLinkedActivity extends BPELNode {
+
+ //private static final Logger logger = Logger.getLogger(BPELLinkedActivity.class.getName());
+
+ IPMDProcess m_process; // the definition of a runtime process
+
+ private Vector m_source; // a vector of link names of which this activity is the source
+ private Vector m_target; // a vector of link names of which this activity is the target
+
+
+ // An activity may participate in an implied link. Therefore the activity
+ // may be the target/source of a link that is not in the named linked vectors.
+ // For example, an activity can be in a Sequence as well as being a participant
+ // in a named Flow link ( a source target can cross a structured activity boundry ). In
+ // this case the activity may participate in an implied link that needs to merge on the
+ // target. The totalTargets and totalSources counters are used to build a merge pattern
+ // within the engine. Using the counters the engine can decide when all
+ // parallel threads have completed and the business process can move forward.
+ private int m_totalTargets = 0;
+ private int m_totalSources = 0;
+
+ BPELLinkedActivity(BPELNode previous, BPELSchema tag, BPELAttributes attrs, Logger logger) throws DeploymentException {
+ super(previous, tag, attrs, logger);
+
+ if ( m_attributes.getName() == null ) m_attributes.setName(tag.getValue());
+
+ if ( m_parserStack != null ) {
+ m_process = m_parserStack.createProcess(m_attributes.getName());
+ m_process.setDescription(getActivityDescription());
+ }
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELActivity
+ */
+ void linkProcess(BPELProcessType parent_type, BPELLinkedActivity child, BPELProcessType child_type, boolean linkNodes) throws DeploymentException {
+ try {
+ m_process.addObserverProcessPC(( child_type == BPELProcessType.START ) ? child.getStartProcess() : child.getEndProcess());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_ADDOBSERVER",new Object[] {getProcess().getAttributes().getName()},e);
+ }
+
+ if ( linkNodes ) child.addParent(this);
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELActivity#createProcess(java.lang.String)
+ */
+ IPMDProcess createProcess(String label)
+ throws DeploymentException {
+
+ IPMDProcess ret = null;
+
+ // A new process definition is created within a root definition only. Linking
+ // as an observing process is deferred until a BPELFlow ends.
+ try {
+ ret = m_process.createUnLinkedProcess(label);
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATEUNLINK",new Object[] {getProcess().getAttributes().getName(), label},e);
+ }
+
+ return ret;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getStartProcess()
+ */
+ IPMDProcess getStartProcess() {
+ return m_process;
+ }
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#getEndProcess()
+ */
+ IPMDProcess getEndProcess() {
+ return m_process;
+ }
+
+
+ /**
+ * @see org.apache.ode.deployment.bpel.BPELNode#pop()
+ */
+ BPELNode pop() throws DeploymentException {
+ m_parserStack.addActivity(this);
+ return m_parserStack;
+ }
+
+
+
+ /**
+ * A linked activity can participate as both a source and target in
+ * many flow links. This accessor returns those links.
+ *
+ * @param type the type of link (source or target)
+ * @return an iterator of BPELLink over the requested type
+ */
+ Iterator getLinks(BPELLinkType type) {
+ return ( type == BPELLinkType.SOURCE ) ? m_source.iterator() : m_target.iterator();
+ }
+
+ /**
+ * A linked activity may implicitly participate in a link. (i.e.
+ * an activity participates in a sequence and is also a target within
+ * the flow). The method increments the link ref count for implicit links.
+ * The ref count is used to merge logical/physical threads of execution.
+ *
+ * @param type the type of link (source or target)
+ */
+ void incrementLink(BPELLinkType type) {
+ if ( type == BPELLinkType.TARGET ) m_totalTargets++;
+ if ( type == BPELLinkType.SOURCE ) m_totalSources++;
+ }
+
+ /**
+ * @param type the type of link (source or target)
+ * @return the ref cound of the requested link type
+ */
+ int getLinkCounter(BPELLinkType type) {
+ return ( type == BPELLinkType.SOURCE ) ? m_totalSources : m_totalTargets;
+ }
+
+ /**
+ * Maps a link object into the activity.
+ *
+ * @param linkName the name of the link in which this activity participates
+ * @param type identifies how the activity participates in the link.
+ */
+ void addLink(BPELLink linkName, BPELLinkType type) {
+ if ( type == BPELLinkType.TARGET ) {
+ if ( m_target == null ) m_target = new Vector();
+ m_target.add(linkName);
+ m_totalTargets++;
+ }
+ if ( type == BPELLinkType.SOURCE ) {
+ if ( m_source == null ) m_source = new Vector();
+ m_source.add(linkName);
+ m_totalSources++;
+ }
+ }
+
+ void createProcessSequence(BPELAttributes attr, IPMDProcess process) throws DeploymentException {
+
+ try {
+ IPMDChangeCondition precc = process.createPrecondition("PreCondition: " + attr.getName(),
+ org.apache.ode.condition.DefaultConditional.class.getName());
+ // sequence - create the pre Action
+ IPMDAction preact = precc.createAction("SequenceAction: " + attr.getName(),
+ org.apache.ode.action.bpel.SequenceAction.class.getName());
+ preact.setMetadata(getAttributes());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+
+ }
+
+ IPMDAction createRegisterAction(IPMDChangeCondition cc, String label) throws DeploymentException {
+ IPMDAction ret = null;
+
+ try {
+ ret = cc.createAction("RegisterAction: " + label,
+ org.apache.ode.action.bpel.RegisterAction.class.getName());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), label},e);
+ }
+
+ return ret;
+
+ }
+
+ IPMDAction createUnRegisterAction(IPMDChangeCondition cc, String label) throws DeploymentException {
+ IPMDAction ret = null;
+
+ try {
+ ret = cc.createAction("UnRegisterAction: " + label,
+ org.apache.ode.action.bpel.UnRegisterAction.class.getName());
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), label},e);
+ }
+
+ return ret;
+
+ }
+
+ void addJoinCondtion(BPELVariable var) throws DeploymentException {
+
+ for ( Iterator ccItr = getStartProcess().getChangeConditions(); ccItr.hasNext(); ) {
+
+ IPMDChangeCondition cc = (IPMDChangeCondition)ccItr.next();
+ cc.setConditionalClass(BPELFlow.XPATH_JOIN_COND_CLASS);
+
+ // Add the XPATH expression as a property to the conditional impl
+ Properties md = new Properties();
+ md.put(BPELFlow.UNINITVAR_KEY,new UnInitVariableMetaData(BPELSchema.BPEL_URI,BPELSchema.FAULT_UNINIT_VAR));
+ md.put(BPELFlow.JOIN_EXPRESSION_KEY,var.createLocator(cc,this,null,null,false));
+ md.put(BPELFlow.SUPPRESS_KEY,(BPELBoolean.NO.equals(getAttributes().getSuppressJoin())) ? BPELBoolean.NO.getBooleanValue() : getSuppressJoinFailure().getBooleanValue());
+ cc.setMetadata(md);
+
+ // add a false action to this change condition if this is a structured
+ // activity and it has an end process
+ if ( this instanceof BPELStructuredActivity &&
+ getEndProcess() != null ) {
+ try {
+ // create the action
+ IPMDAction act = cc.createFalseAction("False Join Condition Start Sequence: "+getAttributes().getName(),
+ org.apache.ode.action.bpel.StartSequenceAction.class.getName());
+ // add the start key
+ act.getMetadata().put(StartSequenceAction.START_DEF_KEY,getEndProcess().getKey());
+
+ } catch (DefinitionServiceException e) {
+ BPELUtil.throwNewException(m_logger,Level.SEVERE,"BPEL_CREATEACTION",new Object[] {getProcess().getAttributes().getName(), getAttributes().getName()},e);
+ }
+ }
+ }
+
+ }
+
+ abstract String getActivityDescription();
+
+}