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 [10/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/action/bpel/RegisterAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/RegisterAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/RegisterAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/RegisterAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,287 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.correlation.CorrelationService;
+import org.apache.ode.correlation.CorrelationServiceException;
+import org.apache.ode.correlation.PartQuery;
+import org.apache.ode.correlation.Registration;
+import org.apache.ode.correlation.keys.CorrelationKeysUtil;
+import org.apache.ode.definition.IPMDCorrelation;
+import org.apache.ode.definition.IPMDCorrelationSet;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.event.BPELStaticKey;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.scope.service.IScopeService;
+import org.apache.ode.util.BPException;
+/**
+ * @author charper
+ *
+ * Register a DynamicRegistration. This Action wil return true if the
+ * DynamicRegistration exists; false if it creates the DynamicRegistration.
+ */
+public class RegisterAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(RegisterAction.class.getName());
+
+ private Properties props;
+ public static final String OPERATIONS = "operations";
+ public static final String BLOCK = "block";
+ public static final String DEP_OPERATIONS = "dependent_operations";
+ public static final String CORRELATION_NOT_INITALIZED = "correlationSetNotInitalized";
+
+ private ArrayList operations;
+// private ArrayList depOperations;
+ private Boolean blocking;
+
+
+ public RegisterAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+ operations = (ArrayList)props.get(OPERATIONS);
+ //depOperations = (ArrayList)props.get(DEP_OPERATIONS);
+ blocking = (Boolean)properties.get(BLOCK);
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+
+
+ CorrelationService cs = pcb.getCorrelationService();
+
+ // loop over all the registrations
+ Iterator it1 = operations.iterator();
+
+ boolean matched = false;
+ boolean removeProc = false;
+ while (it1.hasNext()) {
+ IPMDOperation op = (IPMDOperation)it1.next();
+ IStaticKey staticKeyValue = op.getKey();
+ IPMDCorrelation correlation = op.getCorrelation();
+ String opId = op.getOperationId();
+
+
+ // look for the static registration
+ Registration reg = cs.getRegistration(staticKeyValue,opId,processInstance.getRootKey());
+
+ // if static reg does not exist and there is no dyn key meta data
+ if ( reg == null && correlation == null ) {
+ //register the static registration
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(
+ "Creating Static Registration for "
+ + staticKeyValue.toString());
+ }
+
+ removeProc = createRegistration(cs,resolver,op,processInstance,processDefinition,null);
+
+
+ // else static reg does not exist and there is dyn key meta data
+ } else if ( reg == null && correlation != null ){
+
+ // for each correlation set, if there is one that is instantiating and
+ // the key value has not been initialized do it, else we just need to
+ // make the static registration
+ Iterator csIt = correlation.getCorrelationSets().iterator();
+ // flag to see if any correlation sets are initialized
+ boolean init = false;
+ String dynamicKeyValue = "";
+ while ( csIt.hasNext() ) {
+ IPMDCorrelationSet corrls = (IPMDCorrelationSet)csIt.next();
+
+
+ Iterator pqit = corrls.getPartQueries().iterator();
+ // loop over the part queries build the keys
+ while (pqit.hasNext()) {
+ PartQuery pq = (PartQuery) pqit.next();
+ Object obj =
+ resolver
+ .resolveBPContext(pq.getLocatorName())
+ .getValue();
+ if (obj == null && ! corrls.isInstantiating()) {
+ // oops un initialized correlation set
+ throw new BPException(CORRELATION_NOT_INITALIZED,null);
+ } else if ( obj == null ){
+ // the correlation set is uninitailized
+ break;
+ } else {
+ // build our key value
+ dynamicKeyValue += obj.toString();
+ init = true;
+ }
+ }
+ }
+
+ // if initialized register with dynamic key else register with out
+ if ( init ) {
+ removeProc = createRegistration(cs,resolver,op,processInstance,processDefinition,dynamicKeyValue);
+ } else {
+ removeProc = createRegistration(cs,resolver,op,processInstance,processDefinition,null);
+ }
+
+ // else if the static registration exists and there is no dyn key meta data
+ } else if ( reg != null && correlation == null ) {
+ // nothing to do; a static registration has been fullfilled
+ matched = true;
+
+ // else if the static registrion exists and there is dyn key meta data
+ } else if ( reg != null && correlation != null ) {
+ matched = true;
+ ArrayList ops = new ArrayList();
+ ops.add(op);
+ if ( CorrelationKeysUtil.setCorrelationKeys(resolver,
+ pcb.getMessageEvent().getParts(),ops,null) ) {
+
+ removeRegistration(reg,cs,processInstance,resolver);
+
+ Iterator csIt = correlation.getCorrelationSets().iterator();
+ String dynamicKeyValue = "";
+ while ( csIt.hasNext() ) {
+ IPMDCorrelationSet corrls = (IPMDCorrelationSet)csIt.next();
+ Iterator pqit = corrls.getPartQueries().iterator();
+ // loop over the part queries build the keys
+ while (pqit.hasNext()) {
+ PartQuery pq = (PartQuery) pqit.next();
+ Object obj =
+ resolver
+ .resolveBPContext(pq.getLocatorName())
+ .getValue();
+ if ( obj == null ){
+ // the correlation set is uninitailized, this should probably be a warning
+ break;
+ } else {
+ // build our key value
+ dynamicKeyValue += obj.toString();
+ }
+ }
+ }
+
+ removeProc = createRegistration(cs,resolver,op,processInstance,processDefinition,dynamicKeyValue);
+ }
+ }
+
+ }
+
+ // mark the process as potentialy dead
+ if ( removeProc ) {
+ ec.setDeadProcess(true);
+ }
+ // if a def id was not specified this is not an instance creating registration
+ // so we need to block
+ if ( matched ) {
+ if ( blocking != null && blocking.booleanValue() ) return false;
+ return true;
+ // else block
+ } else {
+ if ( blocking != null && !blocking.booleanValue() ) return true;
+ return false;
+ }
+
+
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+ protected static void removeRegistration(Registration reg, CorrelationService cs,
+ IPMIProcess proc, ContextResolver resolver) throws BPException {
+ IScopeService ss = resolver.getScopeService();
+ IFCScopeInstance scope = ss.getScope(proc.getScopePath());
+ scope.removeRegistration(reg);
+ if ( reg != null ) {
+ cs.removeRegistration(reg);
+ }
+
+ }
+
+ private boolean createRegistration ( CorrelationService cs, ContextResolver resolver,
+ IPMDOperation op, IPMIProcess proc, IPMDProcess def, String keyValue)
+ throws BPException {
+
+ // if this is BPEL compliant make sure that identical registrations
+ // are not made
+ if ( cs.isBPELCompliant() ) {
+ Collection c;
+ if ( keyValue == null ) {
+ c = cs.getRegistrations(op.getKey());
+ } else {
+ ArrayList al = new ArrayList();
+ al.add(keyValue);
+ c = cs.getRegistrations(op.getKey(),al);
+ }
+ if ( c.size() > 0 ) {
+ BPELStaticKey key = (BPELStaticKey)op.getKey();
+ CorrelationServiceException cse =
+ new CorrelationServiceException("ACT_REG_BPEL_COMP",
+ new Object[] {key.getTargetNamespace(),
+ key.getPortType(), key.getOperation(), keyValue });
+ logger.log(Level.SEVERE,"",cse);
+ throw cse;
+ }
+
+ }
+
+ Registration reg = new Registration(op.getKey().toString(), op.getOperationId(),
+ def.getRootKey().getValue(), op.getDefId(), proc.getRootKey(),
+ proc.getKey(), keyValue);
+ cs.createRegistration(reg);
+ // add registration to scope
+ IScopeService ss = resolver.getScopeService();
+ IFCScopeInstance scope = ss.getScope(proc.getScopePath());
+ scope.addRegistration(reg);
+
+ // registering "onMessage" type so we don't need this proc anymore
+ if ( op.getDefId() != null ) {
+ scope.addProcess(proc);
+ return true;
+ }
+ return false;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ReplyAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ReplyAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ReplyAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ReplyAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,240 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.bpel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.bped.EventDirector;
+import org.apache.ode.context.resolver.ContextResolvedObject;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.context.resolver.IResolvedObject;
+import org.apache.ode.context.test.SerializationContext;
+import org.apache.ode.correlation.keys.CorrelationKeysUtil;
+import org.apache.ode.definition.IPMDCorrelation;
+import org.apache.ode.definition.IPMDCorrelationSet;
+import org.apache.ode.definition.IPMDLocator;
+import org.apache.ode.definition.IPMDLocatorHolder;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ReturnMessageLocatorHolder;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.interaction.IInteraction;
+import org.apache.ode.interaction.InteractionFactory;
+import org.apache.ode.util.BPException;
+
+/**
+ * @author charper
+ *
+ *
+ *
+ */
+public class ReplyAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(ReplyAction.class.getName());
+ public static final String REPLY_FAULT_NAME = "REPLY_FAULT_NAME";
+ public static final String REPLY_NAMESPACE = "REPLY_NAMESPACE";
+
+ private Properties props;
+ private String faultName;
+ private String faultNS;
+ private ArrayList operations;
+
+ public ReplyAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+ operations = (ArrayList) properties.get(RegisterAction.OPERATIONS);
+ faultName = props.getProperty(REPLY_FAULT_NAME);
+ faultNS = props.getProperty(REPLY_NAMESPACE);
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+
+ try
+ {
+// Some debugging code that dumps the
+ // process context.
+ SerializationContext sc = new SerializationContext( System.out );
+ sc.printComment( "Reply Action Context:");
+ sc.serialize( resolver.getContextService() );
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if ( logger.isLoggable(Level.FINE)) {
+ Enumeration e = props.elements();
+ StringBuffer sb = new StringBuffer();
+ while (e.hasMoreElements()) {
+ Object o = e.nextElement();
+ if ( o instanceof String ) {
+ sb.append((String)o);
+ sb.append(" ");
+ }
+ }
+ logger.fine("Reply Props:"+sb.toString());
+ }
+
+ // create the return message data
+ ReturnMessageLocatorHolder rmlh = new ReturnMessageLocatorHolder();
+ rmlh.setProcessID(processInstance.getKey());
+ rmlh.setRootProcessID(processInstance.getRootKey());
+ // we have to capture the scope at the time this reply happens
+ // the resolver may not be used in the correct scope context
+ rmlh.setScopePath(processInstance.getScopePath());
+
+ if ( faultName != null ) {
+ rmlh.setFaultName(faultName);
+ rmlh.setFaultNS(faultNS);
+ }
+
+ Iterator it = resolver.getLocatorHolder().getLocators();
+
+ while ( it.hasNext() ){
+ IPMDLocator loc = (IPMDLocator)it.next();
+ rmlh.addLocator(loc.getName(),loc);
+ if ( logger.isLoggable(Level.FINE)){
+ logger.fine("Adding locator to event directory reply:" +loc.getName());
+ }
+ // Need to see if the response variable is null
+ ContextResolvedObject var = (ContextResolvedObject) resolver.resolveBPContext( loc.getName() );
+ if (var.getValue() == null)
+ {
+ // Need to make sure this is not a correlation
+ String name = loc.getName();
+ String[] name_split = name.split(":");
+
+ if (! isCorrelationLocator(name_split[0],operations))
+ {
+ // Need to throw an exception here.
+ throw new BPException("REPLY_ERROR",
+ new Object[] {
+ processDefinition.getRoot().getLabel(),
+ processDefinition.getRoot().getKey().getValue(),
+ processDefinition.getLabel(),
+ loc.getName()});
+ }
+ }
+ }
+ pcb.setReturnMessageMetadata(rmlh);
+
+ // set output correlation keys
+ if (operations != null && CorrelationKeysUtil.hasCorrelationSets(operations)) {
+ Map parts = getCorrelationParts(resolver, rmlh, operations,rmlh);
+ CorrelationKeysUtil.setCorrelationKeys(resolver,parts,operations,null);
+ }
+
+
+ return true;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+ private Map getCorrelationParts(ContextResolver resolver,
+ IPMDLocatorHolder lh,
+ Collection operations,
+ ReturnMessageLocatorHolder rmlh) throws BPException {
+
+ HashMap parts = new HashMap();
+ ArrayList corrlsets = new ArrayList();
+
+ Iterator it = lh.getLocators();
+
+ while (it.hasNext()) {
+
+ IPMDLocator loc = (IPMDLocator) it.next();
+
+ String name = loc.getName();
+ String[] name_split = name.split(":");
+
+ if (! isCorrelationLocator(name_split[0],operations)) {
+ IResolvedObject ro = resolver.resolveBPContext(loc.getName());
+ // get the part
+ Object obj = ro.getValue();
+ IInteraction interaction = null;
+ if (obj instanceof IInteraction) {
+ interaction = (IInteraction) ro.getValue();
+ } else if (obj instanceof String) {
+ // create a new interaction
+ interaction = InteractionFactory.newInstance()
+ .createXMLInteraction(
+ ((String) ro.getValue()).getBytes());
+ }
+
+ parts.put(name_split[1], interaction);
+ } else {
+ corrlsets.add(name_split[0]);
+ }
+
+ }
+
+ rmlh.setCorrlSets(corrlsets);
+
+ return parts;
+ }
+
+ private static boolean isCorrelationLocator(String corrlName, Collection operations) {
+ boolean ret = false;
+ for (Iterator opIter = operations.iterator(); opIter.hasNext();) {
+ IPMDOperation op = (IPMDOperation) opIter.next();
+ IPMDCorrelation correlation = op.getCorrelation();
+ if ( correlation != null ) {
+ for (Iterator corrlIter = correlation.getCorrelationSets().iterator();
+ corrlIter.hasNext();) {
+ IPMDCorrelationSet cs = (IPMDCorrelationSet) corrlIter.next();
+ String[] name = cs.getName().split(":");
+ if ( name.length > 1 && corrlName.equals(name[1]) ) {
+ ret = true;
+ break;
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SequenceAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SequenceAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SequenceAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SequenceAction.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.
+*/
+package org.apache.ode.action.bpel;
+
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessInstance;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.util.BPException;
+/**
+ * @author waterman
+ *
+ * Implements the Sequence Pattern [REQ BP-PAT-1.1]
+ *
+ * To implement a sequence add this Action to a processes precondition.
+ * This will link the process to it's parent process in a sequence pattern. This
+ * action creates an instance of the subprocess and starts it.
+ *
+ */
+public class SequenceAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(SequenceAction.class.getName());
+
+ private Properties props;
+
+ public SequenceAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(ContextResolver resovler,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ if ( logger.isLoggable(Level.FINE)) {
+ Enumeration e = props.elements();
+ StringBuffer sb = new StringBuffer();
+ while (e.hasMoreElements()) {
+ sb.append((String) e.nextElement());
+ sb.append(" ");
+ }
+ logger.fine("Sequence Props:" + sb.toString());
+ }
+
+
+
+ // From the processDefinition create a new process instance
+ // Note: a parent process instance creates a child process instance
+ ProcessInstance pi = ec.getProcessService().createSubProcess(
+ processInstance,processDefinition);
+
+ // Send a Start event to the process instance
+ //pi.processEvent(
+ // new StateEvent(pi.getRootKey(),pi.getKey(), StateEnum.STARTED),
+ // ec, pcb);
+
+ ec.addProcessInstance(pi);
+
+
+ return true;
+
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SimpleUpdateAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SimpleUpdateAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SimpleUpdateAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/SimpleUpdateAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,86 @@
+/*
+ * 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.
+*/
+
+package org.apache.ode.action.bpel;
+
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolvedObject;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.interaction.IInteraction;
+import org.apache.ode.interaction.IInvocation;
+import org.apache.ode.util.BPException;
+
+
+public class SimpleUpdateAction implements IInternalAction
+{
+ public static final String TARGET_VARIABLE_KEY = "target_variable";
+ public static final String INVOCATION_KEY = "invocation";
+ protected static Logger logger =
+ Logger.getLogger(CopyAction.class.getName());
+ private String targetVar;
+ private IInvocation invocation;
+
+ public void init(Properties properties) throws BPException
+ {
+ targetVar = properties.getProperty(TARGET_VARIABLE_KEY);
+ invocation = (IInvocation)properties.get(INVOCATION_KEY);
+ }
+
+ public boolean execute(ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance,
+ IPMDProcess processDefinition) throws BPException
+ {
+ try
+ {
+ ContextResolvedObject target =
+ (ContextResolvedObject)
+ resolver.resolveForUpdateBPContext(targetVar);
+
+ IInteraction interaction = ( IInteraction )target.getObjectForUpdate();
+ interaction.invoke(invocation);
+ }
+
+ catch(Exception e)
+ {
+ logger.log(Level.SEVERE,e.getLocalizedMessage(),e);
+ throw new BPException("PRUNE_ERROR", new Object[] {
+ processDefinition.getRoot().getLabel(),
+ processDefinition.getRoot().getKey().getValue(),
+ processDefinition.getLabel(),
+ targetVar}, e);
+
+ }
+
+ return true;
+ }
+
+ public void release()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartCatchAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartCatchAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartCatchAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartCatchAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,127 @@
+/*
+ * 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: Feb 11, 2004
+ * Project: BPEELocal
+ * Package: org.apache.ode.action.bpel
+ * Author: waterman
+ */
+package org.apache.ode.action.bpel;
+
+//import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.IContainer;
+import org.apache.ode.context.INode;
+import org.apache.ode.context.IPart;
+import org.apache.ode.context.resolver.ContextResolvedObject;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.util.BPException;
+//import org.apache.ode.wsdl.extensions.BPEFault;
+
+/**
+ *
+ *
+ * @author waterman
+ */
+public class StartCatchAction implements IInternalAction {
+
+ public static String TO_VARIABLE_KEY = "to_variable_key";
+ public static String FAULT_PART_TYPES = "fault_part_types";
+
+// private static String DEFAULT_TYPE = "obj";
+
+ private Properties props;
+// private HashMap faultTypes;
+
+ /**
+ *
+ */
+ public StartCatchAction() {
+ super();
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(java.util.Properties)
+ */
+ public void init(Properties properties) throws BPException {
+ props = properties;
+// faultTypes = (props.get(FAULT_PART_TYPES)== null ) ? new HashMap() : (HashMap)props.get(FAULT_PART_TYPES);
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(org.apache.ode.context.resolver.ContextResolver, org.apache.ode.engine.IEvaluationContext, org.apache.ode.engine.IProcessCallBack, org.apache.ode.instance.IPMIProcess, org.apache.ode.definition.IPMDProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance,
+ IPMDProcess processDefinition)
+ throws BPException {
+
+ if ( props.getProperty(StartCatchAction.TO_VARIABLE_KEY) != null ) {
+
+ // The engine will place the fault message in a well known location
+ // get the fault message from the context
+ IContainer rootCont = resolver.getContextService().getRoot();
+ IContainer pCont =
+ (IContainer)rootCont.findChild(processInstance.getRootKey());
+ INode faultNode = pCont.findChild(IFCScopeInstance.CURRENT_FAULT);
+
+ if ( faultNode instanceof IContainer ) {
+ for (Iterator itr = ((IContainer)faultNode).getChildren().iterator(); itr.hasNext(); ) {
+ Object part = itr.next();
+ if ( part instanceof IPart ) {
+ // Copy the fault message into a variable location that
+ // is relative to the catch statement. When the variable
+ // is copied it is also wrapped in a data container.
+ Object data = ((IPart)part).getObjectForRead();
+ ContextResolvedObject to =
+ (ContextResolvedObject) resolver.resolveForUpdateBPContext(
+ props.getProperty(StartCatchAction.TO_VARIABLE_KEY)+":"+((IPart)part).getName());
+
+ //IInteraction interaction = to.getInteractionFactory().createInteraction();
+
+ //BPEFault faultType = (BPEFault)faultTypes.get(((IPart)part).getName());
+ //IActionParam param = ActionParamFactory.createActionParam(null,(faultType == null) ? DEFAULT_TYPE : faultType.getType());
+ //param.setParam(data,interaction);
+
+ //to.setObject(interaction);
+ to.setObject(data);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartScopeAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartScopeAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartScopeAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartScopeAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,144 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.bpel;
+
+//import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.bped.EventDirector;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.scope.service.IScopeService;
+import org.apache.ode.scope.service.ScopePath;
+import org.apache.ode.util.BPException;
+
+/**
+ * @author charper
+ * Nees a "name" property for the scope name
+ * FaultHandler1, FaultHandler2, .... where the prop is faultId#defId
+ */
+public class StartScopeAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(StartScopeAction.class.getName());
+
+ public static final String SCOPE_NAME = "name";
+ public static final String FAULT_OBSERVER = "observer";
+ public static final String FAULT_HANDLERS = "faultHandlers";
+
+ private Properties props;
+// private ArrayList registrations;
+
+
+ public StartScopeAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ if ( logger.isLoggable(Level.FINE)) {
+ Enumeration e = props.elements();
+ StringBuffer sb = new StringBuffer();
+ while (e.hasMoreElements()) {
+ sb.append(e.nextElement().toString());
+ sb.append(" ");
+ }
+ logger.fine("StartScope Props:"+sb.toString());
+ }
+
+ // get scope service
+ IScopeService ss = resolver.getScopeService();
+
+ // get current scope
+ ScopePath sp = processInstance.getScopePath();
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Current scope: " +
+ sp);
+ }
+
+ // get the current scope instance
+ IFCScopeInstance scope = ss.getScope(sp);
+ // create the new scope
+ IFCScopeInstance newScope = scope.createScope(
+ props.getProperty(SCOPE_NAME),
+ processInstance.getKey(),
+ processInstance.getContextContainerId());
+
+ // make sure the execution context is process
+ // if a scope is create in a fault handler
+ // we will not be running in a faulted context
+ processInstance.setExecutionContext(IFCScopeInstance.PROCESS);
+
+ // change the scope
+ processInstance.setScopePath(newScope.getScopePath());
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("New scope: " +
+ newScope.getScopePath());
+ }
+
+ // install the fault handlers
+ HashMap faultHandlers = (HashMap)props.get(FAULT_HANDLERS);
+ if (faultHandlers != null) {
+ Iterator it = faultHandlers.keySet().iterator();
+ while (it.hasNext()) {
+ String name = (String) it.next();
+ newScope.addFaultHandler(
+ name, "",
+ (String) faultHandlers.get(name));
+ }
+ }
+
+ // add the observer to the scope
+ newScope.setFaultHandlerObserver(props.getProperty(FAULT_OBSERVER));
+
+ return true;
+
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartSequenceAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartSequenceAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartSequenceAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/StartSequenceAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,136 @@
+/*
+ * 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.action.bpel;
+
+import java.util.Properties;
+
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.bped.EventDirectorException;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.engine.ProcessInstance;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.util.BPException;
+
+/**
+ * @author waterman
+ *
+ */
+public class StartSequenceAction implements IInternalAction {
+
+ public static final String START_DEF_KEY = "START_DEF_KEY";
+ public static final String END_DEF_KEY = "END_DEF_KEY";
+ public static final String JOIN_EXPRESSION_KEY="JoinExpression";
+ public static final String SUPPRESS_KEY = "SuppressJoinFault";
+
+ // The Jaxen resolver throws a runtime exception when an expression
+ // variable can not be resolved. The namespace of the variable
+ // locator language is used to identify a potential runtime exception.
+ // ( i.e. bpws:getVariable("foo","foor") may throw a
+ // bpws:unitializedVariable ) - bpws: requires a uri.
+ public static final String UNINITVAR_KEY="UNINITVAR";
+
+ private ProcessDefinitionKey startKey;
+ private ProcessDefinitionKey endKey;
+ private UnInitVariableMetaData varExcept;
+
+ private XPathJaxenExpression m_joinExpression;
+ private Boolean m_suppressJoinFault;
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(java.util.Properties)
+ */
+ public void init(Properties properties) throws BPException {
+ startKey = (ProcessDefinitionKey)properties.get(START_DEF_KEY);
+ endKey = (ProcessDefinitionKey)properties.get(END_DEF_KEY);
+
+ if ( properties != null && properties.get(JOIN_EXPRESSION_KEY) != null ) {
+ m_joinExpression = (XPathJaxenExpression)(properties.get(JOIN_EXPRESSION_KEY));
+ m_suppressJoinFault = (Boolean)properties.get(SUPPRESS_KEY);
+ m_joinExpression.getExpressionTree();
+ }
+
+ if ( properties.get(UNINITVAR_KEY) == null ) {
+ //throw new ConditionException("NULL_PROP",new Object[] {UNINITVAR_KEY,XPathJoinConditional.class.getName()},null);
+ } else {
+ varExcept = (UnInitVariableMetaData)properties.get(UNINITVAR_KEY);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#execute(org.apache.ode.context.resolver.ContextResolver, org.apache.ode.bped.EventDirector, org.apache.ode.instance.service.IPMIProcess, org.apache.ode.definition.service.IPMDProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ boolean joinResult = true;
+
+ // evaluate the joinCondition, if non exists the default is true
+ if ( m_joinExpression != null ) {
+ joinResult = JaxenUtil.evalBool(resolver,m_joinExpression,varExcept);
+
+ if ( !joinResult && !m_suppressJoinFault.booleanValue() ) {
+ // join faults have not been suppressed
+ // TODO: Lance - throw bpws:joinFailure exception
+ }
+ }
+
+ if (joinResult) {
+ startProcess(startKey,ec,pcb,processDefinition,processInstance);
+ } else {
+ startProcess(endKey,ec,pcb,processDefinition,processInstance);
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#release()
+ */
+ public void release() {
+ }
+
+ private void startProcess(ProcessDefinitionKey key, IEvaluationContext ec,
+ IProcessCallBack pcb, IPMDProcess pd, IPMIProcess pi ) throws EventDirectorException, BPException {
+
+ // get the definition service
+ DefinitionService ds = ec.getProcessService().getInstanceService().getDefinitionService();
+
+ //IPMDProcess startProcDef = null;
+ IPMDProcess startProcDef = ds.getProcessDefintion(key,pd.getRootKey());
+
+ // From the processDefinition create a new process instance
+ ProcessInstance startProcInst = ec.getProcessService().createSubProcess(
+ pi,startProcDef);
+
+ ec.addProcessInstance(startProcInst);
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TerminateAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TerminateAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TerminateAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TerminateAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.
+*/
+
+package org.apache.ode.action.bpel;
+
+import java.util.Properties;
+
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.IScopeService;
+import org.apache.ode.util.BPException;
+
+/**
+ * Terminate process
+ */
+public class TerminateAction implements IInternalAction {
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#init(java.util.Properties)
+ */
+ public void init(Properties properties) throws BPException {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#execute(org.apache.ode.context.resolver.ContextResolver, org.apache.ode.engine.IEvaluationContext, org.apache.ode.engine.IProcessCallBack, org.apache.ode.instance.service.IPMIProcess, org.apache.ode.definition.service.IPMDProcess)
+ */
+ public boolean execute(ContextResolver resolver, IEvaluationContext ec,
+ IProcessCallBack pcb, IPMIProcess processInstance,
+ IPMDProcess processDefinition) throws BPException {
+
+ IScopeService ss = resolver.getScopeService();
+ ss.getRootScope().terminate(processInstance,ec,pcb);
+ ec.getProcessService().getInstanceService().getInstance(processInstance.getRootKey(),processInstance.getRootKey()).setMarkedForCleanUp(true);
+
+
+ // return false to halt process
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#release()
+ */
+ public void release() {
+
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ThrowAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ThrowAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ThrowAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/ThrowAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.bpel;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.bped.EventDirector;
+import org.apache.ode.context.IContainer;
+import org.apache.ode.context.IContextService;
+import org.apache.ode.context.IPart;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.BPRuntimeException;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.util.BPException;
+
+/**
+ * @author charper
+ *
+ *This action will throw a BPRuntimException with message name set to
+ * "ExceptionName", if no ExceptionName is supplied the current exception is rethrown
+ */
+public class ThrowAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(ThrowAction.class.getName());
+
+ private Properties props;
+
+ public static final String EXCEPTION_NAME = "ExceptionName";
+ public static final String EXCEPTION_NS = "NameSpace";
+
+
+ public ThrowAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ if ( logger.isLoggable(Level.FINE)) {
+ Enumeration e = props.elements();
+ StringBuffer sb = new StringBuffer();
+ while (e.hasMoreElements()) {
+ sb.append((String) e.nextElement());
+ sb.append(" ");
+ }
+ logger.fine("ThrowAction Props:"+sb.toString());
+ }
+
+
+
+
+ if ( props.getProperty(EXCEPTION_NAME) != null) {
+ BPRuntimeException bpr = new BPRuntimeException(props.getProperty(EXCEPTION_NAME),null,null);
+ bpr.setNameSpace(props.getProperty(EXCEPTION_NS));
+ throw bpr;
+ }
+
+ IContextService cs = resolver.getContextService();
+ IContainer rootCont = cs.getRoot();
+ // get the global container for the process
+ IContainer globalCont =
+ (IContainer)rootCont.findChild(processInstance.getRootKey());
+ IPart part = (IPart)globalCont.findChild(IFCScopeInstance.CURRENT_EXCEPTION);
+ if ( part == null ) {
+ part = globalCont.createPart(IFCScopeInstance.CURRENT_EXCEPTION);
+ }
+ String err = (String)part.getObjectForRead();
+
+ if ( err == null ) {
+ throw new ActionException("bpe:no_rethrow_exception",null);
+ } else {
+ if ( logger.isLoggable(Level.FINE)){
+ logger.fine("Re-throwing:"+err);
+ }
+ throw new BPRuntimeException(err,null,null);
+ }
+
+
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TimerAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TimerAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TimerAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/TimerAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,251 @@
+/*
+ * 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.
+*/
+
+package org.apache.ode.action.bpel;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.axis.types.Duration;
+import org.relaxng.datatype.DatatypeException;
+
+import com.sun.msv.datatype.xsd.DatatypeFactory;
+import com.sun.msv.datatype.xsd.XSDatatype;
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolvedObject;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.event.ITimerEvent;
+import org.apache.ode.event.TimerEvent;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.scope.service.IScopeService;
+import org.apache.ode.scope.service.ScopePath;
+import org.apache.ode.timerservice.BPETimerServiceFactory;
+import org.apache.ode.timerservice.IBPETimer;
+import org.apache.ode.timerservice.IBPETimerService;
+import org.apache.ode.util.BPException;
+
+/**
+ *
+ */
+public class TimerAction implements IInternalAction {
+
+ public static final String DEADLINE = "deadline";
+ public static final String DURATION = "duration";
+ public static final String BLOCK = "block";
+ public static final String DEFINITION = "definition";
+
+ public static final String TIMER_ACTION_LOCATOR_KEY = "timerActionLocatorKey";
+
+ private static Logger logger =
+ Logger.getLogger(TimerAction.class.getName());
+
+ private XPathJaxenExpression deadlineExp;
+ private XPathJaxenExpression durationExp;
+ private UnInitVariableMetaData varMetadata;
+ private boolean block = true;
+ private boolean notSupported = false;
+// private Properties properties = null;
+ private IBPETimerService ts;
+ private String defId;
+
+
+ public TimerAction() {
+ }
+ public void init(Properties properties) throws ActionException {
+// this.properties = properties;
+
+ if (properties.containsKey(DEADLINE)) {
+ deadlineExp = (XPathJaxenExpression)(properties.get(DEADLINE));
+ } else if (properties.containsKey(DURATION)) {
+ durationExp = (XPathJaxenExpression)(properties.get(DURATION));
+ }
+ varMetadata = (UnInitVariableMetaData)properties.get(CopyAction.UNINITVAR_KEY);
+ if ( varMetadata == null ) {
+ throw new ActionException("NULL_PROP",new Object[] {CopyAction.UNINITVAR_KEY,TimerAction.class.getName()},null);
+ }
+ if (properties.containsKey(BLOCK)) {
+ block = ((Boolean)(properties.get(BLOCK))).booleanValue();
+ }
+ if (properties.containsKey(DEFINITION)) {
+ defId = properties.getProperty(DEFINITION);
+ }
+ try {
+ ts = BPETimerServiceFactory.getBPETimerService();
+ if ( ts == null ) {
+ notSupported = true;
+ }
+ } catch (BPException e) {
+ ActionException bpx = new ActionException("NATIVE_EXCEPTION",new Object[] {"BPException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ }
+ public boolean execute(ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance,
+ IPMDProcess processDefinition) throws BPException {
+ boolean retValue = false;
+
+
+ if ( notSupported ) {
+ // TODO - Cory In memory impl for timer?
+ logger.severe("TIMER NOT SUPPORTED");
+ return true;
+ }
+
+ // get timer started flag
+ ContextResolvedObject timerStarted = (ContextResolvedObject) resolver.resolveBPContext(
+ TIMER_ACTION_LOCATOR_KEY);
+
+ if (timerStarted.getValue() != null) {
+
+ // timer has fired return
+ retValue = true;
+
+ } else {
+
+ // get the scope service so we can register timer with it
+ IScopeService ss = resolver.getScopeService();
+ IFCScopeInstance scope = ss.getScope(processInstance.getScopePath());
+
+ // get the deadline or duration
+ String deadline = null;
+ String duration = null;
+ try {
+ if (deadlineExp != null) {
+ deadline = JaxenUtil.evalString(resolver, deadlineExp,
+ varMetadata);
+ }
+ if (durationExp != null) {
+ duration = JaxenUtil.evalString(resolver, durationExp,
+ varMetadata);
+ }
+ // special case, if an onAlarm is registered at the root scope
+ // and references data from the incoming message we will catch
+ // the error and save this action for the recieve to execute
+ } catch (BPException e) {
+ // only do this if this is the root scope
+ if ( scope.getScopePath().getEnclosingScopePath().toString().
+ equals(ScopePath.DELIMITER)) {
+ scope.setTimerAction(this,resolver);
+ return true;
+ } else {
+ throw e;
+ }
+ }
+
+
+ // TODO - Cory replace all the time date code when jdk 1.5 is used
+
+ // start time to register
+ Date startTime = null;
+
+ // get a start time for a deadline timer
+ if ( deadline != null ) {
+ Calendar calendar;
+ try {
+ XSDatatype dt = DatatypeFactory.getTypeByName("dateTime");
+ if (dt.isValid(deadline, null)) {
+ calendar = (Calendar)(dt.createJavaObject(deadline, null));
+ } else {
+ dt = DatatypeFactory.getTypeByName("date");
+ if (dt.isValid(deadline, null)) {
+ calendar = (Calendar)(dt.createJavaObject(deadline, null));
+ } else {
+ throw new ActionException("TIME_PARSE",new Object[] {deadline});
+ }
+ }
+ } catch (DatatypeException e) {
+ ActionException bpx = new ActionException("NATIVE_EXCEPTION",new Object[] {"DatatypeException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ startTime = calendar.getTime();
+ }
+
+ // get a startime for a duration timer
+ if ( duration != null ) {
+ Duration dur = new Duration(duration);
+ Calendar currentCalendar = new GregorianCalendar();
+ // axis RC2 to RC3 changed getAsCalendar to "set" the duration
+ // to the calendar which is wrong, RC2 added the duration to
+ // the current time
+ //startTime = dur.getAsCalendar(currentCalendar).getTime();
+
+ // we'll just do it ourself
+ currentCalendar.add(Calendar.YEAR, dur.getYears());
+ currentCalendar.add(Calendar.MONTH, dur.getMonths());
+ currentCalendar.add(Calendar.DATE, dur.getDays());
+ currentCalendar.add(Calendar.HOUR, dur.getHours());
+ currentCalendar.add(Calendar.MINUTE, dur.getMinutes());
+ currentCalendar.add(Calendar.SECOND, (int)dur.getSeconds());
+ startTime = currentCalendar.getTime();
+ }
+
+ if ( startTime == null ) {
+ throw new ActionException("TIME_NOT_SET");
+ } else {
+ // create timer event
+ ITimerEvent timerEvent = new TimerEvent(
+ processInstance.getRootKey().toString(),processInstance.getKey(),
+ processDefinition.getRootKey().getValue(),defId);
+
+ // register the timer
+ IBPETimer timer = ts.createTimer(startTime,timerEvent);
+
+ // set the flag to indicate that timer has been started
+ timerStarted.setObject(new Boolean(true));
+
+ // add timer to current scope
+ scope.addTimer(timer);
+
+ // if need to block(wait) at the timer registration
+ if (block) {
+ // set retValue to false to block
+ retValue = false;
+ } else {
+ // not to block(onAlarm) at the timer registration, in this
+ // case, action will only be called once
+ ec.setDeadProcess(true);
+ scope.addProcess(processInstance);
+ retValue = true;
+ }
+
+ }
+
+ }
+
+ return retValue;
+ }
+
+ public void release() {
+ deadlineExp = null;
+ durationExp = null;
+ varMetadata = null;
+ defId = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnInitVariableMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnInitVariableMetaData.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnInitVariableMetaData.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnInitVariableMetaData.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,85 @@
+/*
+ * 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: Jan 23, 2004
+ * Project: BPEELocal
+ * Package: org.apache.ode.action.bpel
+ * Author: waterman
+ */
+package org.apache.ode.action.bpel;
+
+import java.io.Serializable;
+
+/**
+ * The class holds metadata that is used to throw a runtime exception
+ * in the event a process context variable has not been initialized.
+ * For example: an XPATH expression may contain something that looks like
+ * ( getVariableData("foo","foo") = 'true' ). If the resolver can't find
+ * getVariableData("foo","foo") in the process context then an
+ * exception is thrown. The business process language may have elements
+ * that allow the business process designer to catch this type of execption.
+ * This class holds the data required by the business process language to
+ * catch the exception.
+ *
+ * @author waterman
+ */
+public class UnInitVariableMetaData implements Serializable {
+
+ static final long serialVersionUID = 4713469433467517391L;
+
+ private String m_nameSpace;
+ private String m_exceptionName;
+
+ public UnInitVariableMetaData() {
+ }
+
+ /**
+ *
+ */
+ public UnInitVariableMetaData(String nameSpace, String exceptionName) {
+ m_nameSpace = nameSpace;
+ m_exceptionName = exceptionName;
+ }
+
+ /**
+ * @return
+ */
+ public String getExceptionName() {
+ return m_exceptionName;
+ }
+
+ /**
+ * @return
+ */
+ public String getNameSpace() {
+ return m_nameSpace;
+ }
+
+ /**
+ * @param string
+ */
+ public void setExceptionName(String string) {
+ m_exceptionName = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setNameSpace(String string) {
+ m_nameSpace = string;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnRegisterAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnRegisterAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnRegisterAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/UnRegisterAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,99 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.bpel;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.apache.ode.action.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.correlation.CorrelationService;
+import org.apache.ode.correlation.Registration;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.util.BPException;
+/**
+ * @author charper
+ *
+ * Register a DynamicRegistration. This Action wil return true if the
+ * DynamicRegistration exists; false if it creates the DynamicRegistration.
+ */
+public class UnRegisterAction implements IInternalAction {
+
+ private static Logger logger =
+ Logger.getLogger(UnRegisterAction.class.getName());
+
+ private Properties props;
+ private ArrayList operations;
+
+
+ public UnRegisterAction() {
+
+ }
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(Properties)
+ */
+ public void init(Properties properties) throws ActionException {
+ props = properties;
+ operations = (ArrayList)props.get(RegisterAction.OPERATIONS);
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#execute(Iterator, Iterator, EventDirector, IPMIProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ CorrelationService cs = pcb.getCorrelationService();
+
+ logger.fine("Unregister Action");
+
+ // loop over all the registrations
+ Iterator it1 = operations.iterator();
+ while (it1.hasNext()) {
+ IPMDOperation op = (IPMDOperation)it1.next();
+ IStaticKey staticKeyValue = op.getKey();
+ String opId = op.getOperationId();
+
+ // look for the static registration
+ Registration reg = cs.getRegistration(staticKeyValue,opId,processInstance.getRootKey());
+ RegisterAction.removeRegistration(reg,cs,processInstance,resolver);
+
+
+ }
+
+ return true;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#release()
+ */
+ public void release() {
+ props = null;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathJaxenExpression.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathJaxenExpression.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathJaxenExpression.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathJaxenExpression.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,126 @@
+/*
+ * 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.action.bpel;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jaxen.JaxenException;
+import org.jaxen.XPathFunctionContext;
+import org.jaxen.dom.DOMXPath;
+
+import org.apache.ode.util.BPException;
+
+/**
+ * @author waterman
+ *
+ * A very simple data structure that holds an XPATH expression.
+ *
+ */
+public class XPathJaxenExpression implements Serializable {
+
+ static final long serialVersionUID = 1467149098294725540L;
+
+ private static Logger logger =
+ Logger.getLogger(XPathJaxenExpression.class.getName());
+
+ private String m_sourceExpression;
+ private String m_variableExpression;
+ private HashMap m_variableMap;
+ private transient Map DOMXPathHM;
+
+ public XPathJaxenExpression() {
+ }
+
+ public XPathJaxenExpression(String expression, String sourceExpression) {
+ m_variableExpression = expression;
+ m_sourceExpression = sourceExpression;
+ }
+
+ /**
+ * @return
+ */
+ public String getExpression() {
+ return m_variableExpression;
+ }
+ public String getSourceExpression() {
+ return m_sourceExpression;
+ }
+
+
+ /**
+ * @param string
+ */
+ public void setExpression(String expression) {
+ m_variableExpression = expression;
+ }
+ public void setSourceExpression(String expression) {
+ m_sourceExpression = expression;
+ }
+
+ public HashMap getVariableMap() {
+ return m_variableMap;
+ }
+ public void setVariableMap(HashMap varMap) {
+ m_variableMap = varMap;
+ }
+
+ public void addVariableMap(String var, String expression) {
+ if ( m_variableMap == null ) m_variableMap = new HashMap();
+ m_variableMap.put(var,expression);
+ }
+
+ public String getVariableExpression(String var) {
+ return (String)m_variableMap.get(var);
+ }
+
+ private DOMXPath setExpressionTree() throws BPException {
+ DOMXPath expressionTree = null;
+ if ( m_variableExpression != null ) {
+ try {
+ expressionTree = new DOMXPath(m_variableExpression);
+ expressionTree.setFunctionContext(new XPathFunctionContext());
+ } catch (JaxenException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"JaxenException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ return expressionTree;
+ }
+
+ public DOMXPath getExpressionTree() throws BPException {
+ if ( DOMXPathHM == null ) {
+ DOMXPathHM = Collections.synchronizedMap(new HashMap());
+ }
+ DOMXPath locator = (DOMXPath)DOMXPathHM.get(Thread.currentThread());
+ if ( locator == null ) {
+ locator = setExpressionTree();
+ DOMXPathHM.put(Thread.currentThread(),locator);
+ }
+ return locator;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,187 @@
+/*
+ * 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.action.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.internal.ActionException;
+import org.apache.ode.action.internal.IInternalAction;
+import org.apache.ode.bped.IInternalEventDirector;
+import org.apache.ode.bped.EventDirectorException;
+import org.apache.ode.context.resolver.ContextResolver;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.engine.ProcessInstance;
+import org.apache.ode.engine.StateEnum;
+import org.apache.ode.event.StateEvent;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.util.BPException;
+import org.apache.ode.scope.service.BPRuntimeException;
+
+/**
+ * @author waterman
+ *
+ */
+public class XPathSwitchAction implements IInternalAction {
+
+ public static final String CASES_KEY = "CASES";
+ public static final String THREAD_KEY = "WithNewThread";
+ public static final String DEFAULT_KEY = "DEFAULT";
+
+ // The Jaxen resolver throws a runtime exception when an expression
+ // variable can not be resolved. The namespace of the variable
+ // locator language is used to identify a potential runtime exception.
+ // ( i.e. bpws:getVariable("foo","foor") may throw a
+ // bpws:unitializedVariable ) - bpws: requires a uri.
+ public static final String UNINITVAR_KEY="UNINITVAR";
+
+ private Vector cases;
+ private ProcessDefinitionKey defaultKey;
+ private boolean newThread = false;
+ private UnInitVariableMetaData varExcept;
+
+ protected static Logger logger =
+ Logger.getLogger(XPathSwitchAction.class.getName());
+
+ /**
+ * @see org.apache.ode.action.bpel.internal.IInternalAction#init(java.util.Properties)
+ */
+ public void init(Properties properties) throws BPException {
+ cases = (Vector)properties.get(CASES_KEY);
+ defaultKey = (ProcessDefinitionKey)properties.get(DEFAULT_KEY);
+
+ if ( properties.getProperty(THREAD_KEY) != null ) newThread = true;
+
+ // Create the Jaxen expression tree
+ if ( cases != null ) {
+ for ( Iterator itr = cases.iterator(); itr.hasNext();) {
+ ((XPathSwitchTuple)itr.next()).getExpression().getExpressionTree();
+ }
+ }
+
+ if ( properties.get(UNINITVAR_KEY) == null ) {
+ throw new ActionException("NULL_PROP",new Object[] {UNINITVAR_KEY,XPathSwitchAction.class.getName()},null);
+ } else {
+ varExcept = (UnInitVariableMetaData)properties.get(UNINITVAR_KEY);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#execute(org.apache.ode.context.resolver.ContextResolver, org.apache.ode.bped.EventDirector, org.apache.ode.instance.service.IPMIProcess, org.apache.ode.definition.service.IPMDProcess)
+ */
+ public boolean execute(
+ ContextResolver resolver,
+ IEvaluationContext ec,
+ IProcessCallBack pcb,
+ IPMIProcess processInstance, IPMDProcess processDefinition)
+ throws BPException {
+
+ // iterate over the switch cases, if the xpath expression evaluates
+ // to true start the associated process
+
+
+ boolean defaultFlag = ( defaultKey != null ) ? true : false;
+
+ try
+ {
+
+ for ( Iterator i = cases.iterator(); i.hasNext(); ) {
+ XPathSwitchTuple st = (XPathSwitchTuple)i.next();
+
+ if (JaxenUtil.evalBool(resolver,st.getExpression(),varExcept)) {
+ startProcess(st.getKey(),ec,pcb,processDefinition,processInstance);
+ defaultFlag = false;
+ break;
+ }
+ }
+ }
+ catch(BPRuntimeException bpe)
+ {
+ logger.log(Level.SEVERE,bpe.getLocalizedMessage(),bpe);
+ BPRuntimeException bpe1 = new BPRuntimeException(bpe.getName(),"SINGLE_RULE_ERROR", new Object[] {
+ processDefinition.getRoot().getLabel(),
+ processDefinition.getRoot().getKey().getValue(),
+ processDefinition.getLabel()}
+ );
+ bpe1.setNameSpace(bpe.getNameSpace());
+ throw bpe1;
+
+ }
+ catch(Exception e)
+ {
+ logger.log(Level.SEVERE,e.getLocalizedMessage(),e);
+ throw new BPException("SINGLE_RULE_ERROR", new Object[] {
+ processDefinition.getRoot().getLabel(),
+ processDefinition.getRoot().getKey().getValue(),
+ processDefinition.getLabel()},
+ e);
+ }
+
+ if ( defaultFlag ) {
+ startProcess(defaultKey,ec,pcb,processDefinition,processInstance);
+ }
+
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.action.bpel.Action#release()
+ */
+ public void release() {
+ }
+
+ private void startProcess(ProcessDefinitionKey key, IEvaluationContext ec,
+ IProcessCallBack pcb, IPMDProcess pd, IPMIProcess pi ) throws EventDirectorException, BPException {
+
+ // get the definition service
+ DefinitionService ds = ec.getProcessService().getInstanceService().getDefinitionService();
+
+ //IPMDProcess startProcDef = null;
+ IPMDProcess startProcDef = ds.getProcessDefintion(key,pd.getRootKey());
+
+ // From the processDefinition create a new process instance
+ ProcessInstance startProcInst = ec.getProcessService().createSubProcess(
+ pi,startProcDef);
+
+ if ( newThread ) {
+ // Send a Start event to the process instance via an
+ // asyncronous call to the event director, the event director
+ // is responsible for creating a new thread
+ ((IInternalEventDirector)pcb).sendEvent(
+ new StateEvent(startProcInst.getRootKey(),startProcInst.getKey(), StateEnum.STARTED),false);
+ } else {
+ // Send a Start event to the process instance
+ //startProcInst.processEvent(new StateEvent(startProcInst.getRootKey(),startProcInst.getKey(), StateEnum.STARTED),
+ // ec, pcb);
+ ec.addProcessInstance(startProcInst);
+ }
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchTuple.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchTuple.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchTuple.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/bpel/XPathSwitchTuple.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,84 @@
+/*
+ * 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.action.bpel;
+
+import java.io.Serializable;
+//import java.util.logging.Logger;
+
+import org.apache.ode.engine.ProcessDefinitionKey;
+
+/**
+ * @author waterman
+ *
+ * A very simple data structure that maps a XPATH expression to a process
+ * definition key. An instance of this class is passed as a initializing
+ * property to the XPathSwitchAction. The switch action evaluates the
+ * XPATH expression, if true it creates and starts a process instance from
+ * the mapped process definition key
+ *
+ * @see XPathSwitchAction
+ */
+public class XPathSwitchTuple implements Serializable {
+
+ static final long serialVersionUID = -7569628771802551196L;
+
+// private static Logger logger =
+// Logger.getLogger(XPathSwitchTuple.class.getName());
+
+ private ProcessDefinitionKey key;
+ private XPathJaxenExpression expression;
+
+ public XPathSwitchTuple() {
+ }
+
+ public XPathSwitchTuple(XPathJaxenExpression expression, ProcessDefinitionKey key) {
+ this.key = key;
+ this.expression = expression;
+ }
+
+ /**
+ * @return
+ */
+ public XPathJaxenExpression getExpression() {
+ return expression;
+ }
+
+ /**
+ * @return
+ */
+ public ProcessDefinitionKey getKey() {
+ return key;
+ }
+
+ /**
+ * @param string
+ */
+ public void setExpression(XPathJaxenExpression expression) {
+ this.expression = expression;
+ }
+
+ /**
+ * @param key
+ */
+ public void setKey(ProcessDefinitionKey key) {
+ this.key = key;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/ActionSystemException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/ActionSystemException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/ActionSystemException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/ActionSystemException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,61 @@
+/*
+ * 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 10, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.apache.ode.action.external;
+
+import org.apache.ode.action.internal.ActionException;
+
+import java.util.Properties;
+
+/**
+ * An exception which can not reasonably be caught within
+ * the business process flow or interpretted as a WSDL fault
+ * by the client.
+ */
+public class ActionSystemException extends ActionException
+{
+
+ static final long serialVersionUID = 5796400891797885837L;
+
+ private Properties m_props;
+
+ public ActionSystemException(String detailMessage)
+ {
+ super(detailMessage);
+ }
+
+ public ActionSystemException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ActionSystemException(Throwable cause, Properties props)
+ {
+ super(cause);
+ m_props = props;
+ }
+
+ public Properties getProperties()
+ {
+ return m_props;
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/BusinessProcessInvocationAction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/BusinessProcessInvocationAction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/BusinessProcessInvocationAction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/action/external/BusinessProcessInvocationAction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,181 @@
+/*
+ * 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.
+*/
+package org.apache.ode.action.external;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.apache.ode.client.BPEClient;
+import org.apache.ode.client.IBPEClient;
+import org.apache.ode.client.IBPEMessage;
+import org.apache.ode.client.IBPEMessagePart;
+import org.apache.ode.client.IDescribedValue;
+import org.apache.ode.client.IFormattableValue;
+import org.apache.ode.client.IOperation;
+import org.apache.ode.client.result.IFaultResult;
+import org.apache.ode.client.result.IResult;
+import org.apache.ode.client.result.ISuccessWithResponse;
+import org.apache.ode.context.base.ContextUtil;
+import org.apache.ode.interaction.spiadapter.SPIAdapterInteraction;
+import org.apache.ode.scope.service.BPRuntimeException;
+
+
+public class BusinessProcessInvocationAction implements IExternalAction
+{
+
+ static final long serialVersionUID = 8880364530453321427L;
+
+ private static Logger logger =
+ Logger.getLogger(BusinessProcessInvocationAction.class.getName());
+
+ public static final String FAULT_NAME="InvocationFault";
+ private Properties operationProps;
+// private Properties props;
+
+ public void init(Properties props) throws BPRuntimeException
+ {
+// this.props = props;
+ operationProps = new Properties();
+ operationProps.setProperty(IOperation.PORT_TYPE,
+ props.getProperty("PortTypeName"));
+ operationProps.setProperty(IOperation.PORT_TYPE_NAMESPACE,
+ props.getProperty("PortTypeNameSpace"));
+ operationProps.setProperty(IOperation.OPERATION,
+ props.getProperty("OperationName"));
+ }
+
+ public void execute(HashMap input, HashMap output, IURIResolver resolver)
+ throws BPRuntimeException
+ {
+ try
+ {
+ Properties props = new Properties();
+ IBPEClient client = new BPEClient(props);
+
+ IBPEMessage msg = client.createMessage();
+
+ Iterator inputIterator = input.entrySet().iterator();
+ while( inputIterator.hasNext() )
+ {
+ Map.Entry entry = ( Map.Entry )(inputIterator.next());
+ String key = ( String ) entry.getKey();
+ Object object = entry.getValue();
+
+ if ( ! (object instanceof IFormattableValue) ) {
+ // testBPChain uses old binding, so this will be a
+ // SPIAdapterInteraction
+ object = ContextUtil.cloneObject( object );
+ } else {
+ object = seralizeClone(object,key);
+ }
+
+ IDescribedValue dv = null;
+ if ( object instanceof SPIAdapterInteraction ) {
+ SPIAdapterInteraction inter = (SPIAdapterInteraction) object;
+ dv = inter.getUserValue().getDescribedValue();
+ } else if ( object instanceof IFormattableValue ) {
+ dv = ((IFormattableValue)object).getDescribedValue();
+ }
+
+
+ IBPEMessagePart part =
+ client.createPart(key,dv);
+
+ msg.addPart(part);
+
+ }
+
+ IOperation op = client.createOperation(operationProps);
+
+ IResult rslt = op.invoke(msg);
+ IBPEMessage rsp = null;
+ if ( rslt instanceof ISuccessWithResponse ) {
+ rsp = ((ISuccessWithResponse)rslt).getResponse();
+ } else if ( rslt instanceof IFaultResult ) {
+ IFaultResult fault = (IFaultResult)rslt;
+ // strip of the ns alias
+ String name = fault.getFaultName().substring(fault.getFaultName().indexOf(":")+1);
+ BPRuntimeException bpr = new BPRuntimeException(name,null,null);
+ bpr.setNameSpace(fault.getFaultNamespace());
+ throw bpr;
+ }
+
+ rsp.getParts();
+
+ Collection responseParts = rsp.getParts();
+ Iterator outputIterator = responseParts.iterator();
+ while( outputIterator.hasNext() )
+ {
+ IBPEMessagePart part = ( IBPEMessagePart)( outputIterator.next() );
+ Object object = part.getFormattableValue();
+ if ( ! (object instanceof IFormattableValue) ) {
+ // testBPChain uses old binding, so this will be a
+ // SPIAdapterInteraction
+ object = ContextUtil.cloneObject( object );
+ } else {
+ object = seralizeClone(object,part.getName());
+ }
+ output.put(part.getName(),object);
+ }
+
+ }
+ catch ( Exception e)
+ {
+ if ( e instanceof BPRuntimeException ) {
+ throw (BPRuntimeException)e;
+ } else {
+ BPRuntimeException bp =
+ new BPRuntimeException(FAULT_NAME, "NATIVE_EXCEPTION", new Object[]
+ {"BusinessProcessInvocationActionError"}, e);
+ throw bp;
+ }
+ }
+ }
+
+ private Object seralizeClone(Object obj, String key) throws ClassNotFoundException, IOException {
+ Object ret = obj;
+ if ( obj instanceof Serializable ) {
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+
+ ret = ois.readObject();
+
+
+ } else {
+ logger.warning("Input part "+key+" not serializable; the part will not be cloned.");
+ }
+ return ret;
+ }
+
+ public void release()
+ {
+ }
+}