Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ExprEvaluationContextImpl.java Fri Jan 4 06:19:42 2008 @@ -18,10 +18,11 @@ */ package org.apache.ode.bpel.runtime; +import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ode.bpel.common.FaultException; -import org.apache.ode.bpel.evt.ProcessEvent; import org.apache.ode.bpel.evt.ScopeEvent; import org.apache.ode.bpel.evt.VariableReadEvent; import org.apache.ode.bpel.explang.EvaluationContext; @@ -29,114 +30,116 @@ import org.apache.ode.bpel.o.OExpression; import org.apache.ode.bpel.o.OLink; import org.apache.ode.bpel.o.OMessageVarType; -import org.apache.ode.bpel.o.OMessageVarType.Part; import org.apache.ode.bpel.o.OProcess; import org.apache.ode.bpel.o.OScope; +import org.apache.ode.bpel.o.OMessageVarType.Part; import org.w3c.dom.Element; import org.w3c.dom.Node; -import java.util.Map; - /** * The context in which BPEL expressions are evaluated. This class is handed of * the [EMAIL PROTECTED] org.apache.ode.bpel.o.OExpression} instances to provide access to * variables, link statuses, and the like. */ public class ExprEvaluationContextImpl implements EvaluationContext { - private static final Log __log = LogFactory - .getLog(ExprEvaluationContextImpl.class); + private static final Log __log = LogFactory + .getLog(ExprEvaluationContextImpl.class); - private BpelRuntimeContext _native; + private BpelRuntimeContext _native; - private ScopeFrame _scopeInstance; + private ScopeFrame _scopeInstance; - private Map<OLink, Boolean> _linkVals; + private Map<OLink, Boolean> _linkVals; - private Node _root; - - public ExprEvaluationContextImpl(ScopeFrame scopeInstace, - BpelRuntimeContext ntv) { - _native = ntv; - _scopeInstance = scopeInstace; - } - - public ExprEvaluationContextImpl(ScopeFrame scopeInstace, - BpelRuntimeContext ntv, Node root) { - this(scopeInstace, ntv); - _root = root; - } - - public ExprEvaluationContextImpl(ScopeFrame scopeInstnce, - BpelRuntimeContext ntv, Map<OLink, Boolean> linkVals) { - this(scopeInstnce, ntv); - _linkVals = linkVals; - } - - public Node readVariable(OScope.Variable variable, OMessageVarType.Part part) - throws FaultException { - if (__log.isTraceEnabled()) - __log.trace("readVariable(" + variable + "," + part + ")"); - - // TODO: check for null _scopeInstance - - Node ret; - if (variable.type instanceof OConstantVarType) { - ret = ((OConstantVarType)variable.type).getValue(); - } else { - VariableInstance varInstance = _scopeInstance.resolve(variable); - if (varInstance == null) return null; - VariableReadEvent vre = new VariableReadEvent(); - vre.setVarName(varInstance.declaration.name); - sendEvent(vre); - ret = _native.fetchVariableData(varInstance, part, false); - } - return ret; - } - - - public Node evaluateQuery(Node root, OExpression expr) throws FaultException { - try { - return _native.getExpLangRuntime().evaluateNode(expr, - new ExprEvaluationContextImpl(_scopeInstance, _native, root)); - } catch (org.apache.ode.bpel.explang.EvaluationException e) { - throw new InvalidProcessException("Expression Failed: " + expr, e); - } - } - - public String readMessageProperty(OScope.Variable variable, - OProcess.OProperty property) throws FaultException { - VariableInstance varInstance = _scopeInstance.resolve(variable); - return _native.readProperty(varInstance, property); - } - - public boolean isLinkActive(OLink olink) throws FaultException { - return _linkVals.get(olink); - } - - public String toString() { - return "{ExprEvaluationContextImpl scopeInstance=" + _scopeInstance - + ", activeLinks=" + _linkVals + "}"; - } - - public Node getRootNode() { - return _root; - } - - public Node getPartData(Element message, Part part) throws FaultException { - return _native.getPartData(message, part); - } - - public Long getProcessId() { - return _native.getPid(); - } - - public boolean narrowTypes() { - return true; - } - - private void sendEvent(ScopeEvent se) { - _scopeInstance.fillEventInfo(se); - _native.sendEvent(se); + private Node _root; + + public ExprEvaluationContextImpl(ScopeFrame scopeInstace, + BpelRuntimeContext ntv) { + _native = ntv; + _scopeInstance = scopeInstace; + } + + public ExprEvaluationContextImpl(ScopeFrame scopeInstace, + BpelRuntimeContext ntv, Node root) { + this(scopeInstace, ntv); + _root = root; + } + + public ExprEvaluationContextImpl(ScopeFrame scopeInstnce, + BpelRuntimeContext ntv, Map<OLink, Boolean> linkVals) { + this(scopeInstnce, ntv); + _linkVals = linkVals; + } + + public Node readVariable(OScope.Variable variable, OMessageVarType.Part part) + throws FaultException { + if (__log.isTraceEnabled()) + __log.trace("readVariable(" + variable + "," + part + ")"); + + // TODO: check for null _scopeInstance + + Node ret; + if (variable.type instanceof OConstantVarType) { + ret = ((OConstantVarType) variable.type).getValue(); + } else { + VariableInstance varInstance = _scopeInstance.resolve(variable); + if (varInstance == null) + return null; + VariableReadEvent vre = new VariableReadEvent(); + vre.setVarName(varInstance.declaration.name); + sendEvent(vre); + ret = _scopeInstance.fetchVariableData(_native,varInstance, part, false); + } + return ret; + } + + public Node evaluateQuery(Node root, OExpression expr) + throws FaultException { + try { + return _native.getExpLangRuntime() + .evaluateNode( + expr, + new ExprEvaluationContextImpl(_scopeInstance, + _native, root)); + } catch (org.apache.ode.bpel.explang.EvaluationException e) { + throw new InvalidProcessException("Expression Failed: " + expr, e); + } + } + + public String readMessageProperty(OScope.Variable variable, + OProcess.OProperty property) throws FaultException { + VariableInstance varInstance = _scopeInstance.resolve(variable); + return _native.readProperty(varInstance, property); + } + + public boolean isLinkActive(OLink olink) throws FaultException { + return _linkVals.get(olink); + } + + public String toString() { + return "{ExprEvaluationContextImpl scopeInstance=" + _scopeInstance + + ", activeLinks=" + _linkVals + "}"; + } + + public Node getRootNode() { + return _root; + } + + public Node getPartData(Element message, Part part) throws FaultException { + return _scopeInstance.getPartData(message, part); + } + + public Long getProcessId() { + return _native.getPid(); + } + + public boolean narrowTypes() { + return true; + } + + private void sendEvent(ScopeEvent se) { + _scopeInstance.fillEventInfo(se); + _native.sendEvent(se); } }
Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java Fri Jan 4 06:19:42 2008 @@ -211,7 +211,7 @@ _oforEach.innerScope, getBpelRuntimeContext().createScopeInstance(_scopeFrame.scopeInstanceId, _oforEach.innerScope), _scopeFrame, null); VariableInstance vinst = newFrame.resolve(_oforEach.counterVariable); - getBpelRuntimeContext().initializeVariable(vinst, counterNode); + initializeVariable(vinst, counterNode); // Generating event VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name); Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/INVOKE.java Fri Jan 4 06:19:42 2008 @@ -114,7 +114,7 @@ throw new RuntimeException(e); } - getBpelRuntimeContext().initializeVariable(outputVar, response); + initializeVariable(outputVar, response); // Generating event VariableModificationEvent se = new VariableModificationEvent(outputVar.declaration.name); se.setNewValue(response); @@ -198,7 +198,7 @@ if (oinvoke.operation.getInput().getMessage().getParts().size() > 0) { sendVariableReadEvent(_scopeFrame.resolve(oinvoke.inputVar)); - Node outboundMsg = getBpelRuntimeContext().fetchVariableData( + Node outboundMsg = fetchVariableData( _scopeFrame.resolve(oinvoke.inputVar), false); // TODO outbound message should be updated with non-initiate correlation sets assert outboundMsg instanceof Element; Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java Fri Jan 4 06:19:42 2008 @@ -210,7 +210,7 @@ } VariableInstance vinst = _scopeFrame.resolve(onMessage.variable); - getBpelRuntimeContext().initializeVariable(vinst, msgEl); + initializeVariable(vinst, msgEl); // Generating event VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name); se.setNewValue(msgEl); Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java Fri Jan 4 06:19:42 2008 @@ -50,8 +50,7 @@ try { sendVariableReadEvent(_scopeFrame.resolve(oreply.variable)); - Node msg = getBpelRuntimeContext() - .fetchVariableData(_scopeFrame.resolve(oreply.variable), false); + Node msg = fetchVariableData(_scopeFrame.resolve(oreply.variable), false); assert msg instanceof Element; Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java Fri Jan 4 06:19:42 2008 @@ -18,23 +18,40 @@ */ package org.apache.ode.bpel.runtime; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javax.xml.namespace.QName; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.ode.bpel.common.FaultException; import org.apache.ode.bpel.evt.ScopeFaultEvent; import org.apache.ode.bpel.evt.ScopeStartEvent; -import org.apache.ode.bpel.evt.ScopeEvent; import org.apache.ode.bpel.evt.VariableModificationEvent; -import org.apache.ode.bpel.explang.EvaluationContext; -import org.apache.ode.bpel.explang.EvaluationException; -import org.apache.ode.bpel.o.*; -import org.apache.ode.bpel.runtime.channels.*; +import org.apache.ode.bpel.o.OBase; +import org.apache.ode.bpel.o.OCatch; +import org.apache.ode.bpel.o.OElementVarType; +import org.apache.ode.bpel.o.OEventHandler; +import org.apache.ode.bpel.o.OFailureHandling; +import org.apache.ode.bpel.o.OFaultHandler; +import org.apache.ode.bpel.o.OLink; +import org.apache.ode.bpel.o.OMessageVarType; +import org.apache.ode.bpel.o.OScope; +import org.apache.ode.bpel.o.OVarType; +import org.apache.ode.bpel.runtime.channels.CompensationChannel; +import org.apache.ode.bpel.runtime.channels.EventHandlerControlChannel; +import org.apache.ode.bpel.runtime.channels.FaultData; +import org.apache.ode.bpel.runtime.channels.ParentScopeChannel; +import org.apache.ode.bpel.runtime.channels.ParentScopeChannelListener; +import org.apache.ode.bpel.runtime.channels.TerminationChannel; +import org.apache.ode.bpel.runtime.channels.TerminationChannelListener; import org.apache.ode.jacob.ChannelListener; import org.apache.ode.jacob.SynchChannel; - -import javax.xml.namespace.QName; -import java.io.Serializable; -import java.util.*; import org.w3c.dom.Element; /** @@ -57,34 +74,6 @@ } public void run() { - - - for (OScope.Variable var : _oscope.variables.values()) { - if (var.extVar == null) - continue; - - HashMap<String,String> keymap = new HashMap<String,String>(); - for (Map.Entry<String, OExpression> mapping : var.extVar.keyDeclaration.entrySet()) { - String val; - try { - val = getBpelRuntimeContext().getExpLangRuntime().evaluateAsString(mapping.getValue(), getEvaluationContext()); - } catch (FaultException e) { - __log.error("Unable to initialize external variable key.", e); - FaultData fd = createFault(e.getQName(), var.extVar, "Unable to initialize external variable key: " + e.getMessage()); - _self.parent.completed(fd,null); - return; - } catch (EvaluationException ee) { - __log.error("Unable to initialize external variable key.", ee); - FaultData fd = createFault(var.getOwner().constants.qnSubLanguageExecutionFault, var.extVar, "Unable to initialize external variable key: " + ee.getMessage()); - _self.parent.completed(fd,null); - return; - } - keymap.put(mapping.getKey(),val); - } - - getBpelRuntimeContext().initializeExternalVariable(_scopeFrame.resolve(var), keymap); - } - // Start the child activity. _child = new ActivityInfo(genMonotonic(), @@ -326,7 +315,7 @@ if (catchBlock.faultVariable != null) { try { VariableInstance vinst = faultHandlerScopeFrame.resolve(catchBlock.faultVariable); - ntive.initializeVariable(vinst, _fault.getFaultMessage()); + initializeVariable(vinst, _fault.getFaultMessage()); // Generating event VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name); Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java Fri Jan 4 06:19:42 2008 @@ -18,21 +18,38 @@ */ package org.apache.ode.bpel.runtime; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ode.bpel.common.FaultException; import org.apache.ode.bpel.evt.ScopeEvent; +import org.apache.ode.bpel.iapi.BpelEngineException; +import org.apache.ode.bpel.o.OElementVarType; +import org.apache.ode.bpel.o.OMessageVarType; import org.apache.ode.bpel.o.OPartnerLink; import org.apache.ode.bpel.o.OScope; +import org.apache.ode.bpel.o.OMessageVarType.Part; +import org.apache.ode.bpel.runtime.BpelRuntimeContext.ValueReferencePair; import org.apache.ode.bpel.runtime.channels.FaultData; +import org.apache.ode.utils.DOMUtils; +import org.apche.ode.bpel.evar.ExternalVariableModuleException; +import org.apche.ode.bpel.evar.IncompleteKeyException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; import java.io.Serializable; import java.util.ArrayList; import java.util.Set; +import javax.xml.namespace.QName; + /** * N-tuple representing a scope "frame" (as in stack frame). */ class ScopeFrame implements Serializable { private static final long serialVersionUID = 1L; + private static final Log __log = LogFactory.getLog(ScopeFrame.class); /** The compiled scope representation. */ final OScope oscope; @@ -135,5 +152,127 @@ if (event.getLineNo() == -1 && oscope.debugInfo != null) event.setLineNo(oscope.debugInfo.startLine); } + + + // + // Move all the external variable stuff in here so that it can be used by the expr-lang evaluation + // context. + // + + Node fetchVariableData(BpelRuntimeContext brc, VariableInstance variable, boolean forWriting) throws FaultException { + + // Special case of messageType variables with no part + if (variable.declaration.type instanceof OMessageVarType) { + OMessageVarType msgType = (OMessageVarType) variable.declaration.type; + if (msgType.parts.size() == 0) { + Document doc = DOMUtils.newDocument(); + Element root = doc.createElement("message"); + doc.appendChild(root); + return root; + } + } + + + if (variable.declaration.extVar != null) { + // Note, that when using external variables, the database will not contain the value of the + // variable, instead we need to go the external variable subsystems. + + Element reference = (Element) fetchVariableData(brc, resolve(variable.declaration.extVar.related), false); + try { + Node ret = brc.readExtVar(variable.declaration.extVar.externalVariableId, reference ); + if (ret == null) { + throw new FaultException(oscope.getOwner().constants.qnUninitializedVariable, + "The external variable \"" + variable.declaration.name + "\" has not been initialized."); + + } + return ret; + } catch (IncompleteKeyException ike) { + // This indicates that the external variable needed to be written do, put has not been. + __log.error("External variable could not be read due to incomplete key; the following key " + + "components were missing: " + ike.getMissing()); + throw new FaultException(oscope.getOwner().constants.qnUninitializedVariable, + "The extenral variable \"" + variable.declaration.name + "\" has not been properly initialized;" + + "the following key compoenents were missing:" + ike.getMissing()); + } catch (ExternalVariableModuleException e) { + __log.error("Unexpected EVM error.", e); + throw new BpelEngineException(e); + } + + } else /* not external */ { + Node data = brc.readVariable(variable.scopeInstance,variable.declaration.name, forWriting); + + if (data == null) { + throw new FaultException(oscope.getOwner().constants.qnUninitializedVariable, + "The variable " + variable.declaration.name + " isn't properly initialized."); + } + + return data; + } + + } + + + Node fetchVariableData(BpelRuntimeContext brc, VariableInstance var, OMessageVarType.Part part, boolean forWriting) + throws FaultException { + Node container = fetchVariableData(brc, var, forWriting); + + // If we want a specific part, we will need to navigate through the + // message/part structure + if (var.declaration.type instanceof OMessageVarType && part != null) { + container = getPartData((Element) container, part); + } + return container; + } + + + + Node initializeVariable(BpelRuntimeContext brc, VariableInstance lvar, Node val) { + + if (lvar.declaration.extVar != null) /*external variable */ { + try { + VariableInstance related = resolve(lvar.declaration.extVar.related); + + Node reference = null; + try { + reference = fetchVariableData(brc, related, true); + } catch (FaultException fe) { + // In this context this is not necessarily a problem, since the assignment may re-init the related var + } + + ValueReferencePair vrp = brc.writeExtVar(lvar.declaration.extVar.externalVariableId, reference, val); + commitChanges(brc,related, vrp.reference); + return vrp.value; + } catch (ExternalVariableModuleException e) { + __log.error("External variable initialization error.", e); + // TODO: need to report this + throw new BpelEngineException("External varaible initialization error", e); + } + + } else /* normal variable */ { + return brc.writeVariable(lvar,val); + } + + + + } + + Node commitChanges(BpelRuntimeContext context, VariableInstance lval, Node lvalue) { + return initializeVariable(context, lval, lvalue); + + } + + + Node getPartData(Element message, Part part) { + // borrowed from ASSIGN.evalQuery() + QName partName = new QName(null, part.name); + Node ret = DOMUtils.findChildByName((Element) message, partName); + if (part.type instanceof OElementVarType) { + QName elName = ((OElementVarType) part.type).elementType; + ret = DOMUtils.findChildByName((Element) ret, elName); + } + + return ret; + } + } Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/THROW.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/THROW.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/THROW.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/THROW.java Fri Jan 4 06:19:42 2008 @@ -47,7 +47,7 @@ if(_othrow.faultVariable != null){ try { sendVariableReadEvent(_scopeFrame.resolve(_othrow.faultVariable)); - Node faultVariable = getBpelRuntimeContext().fetchVariableData(_scopeFrame.resolve(_othrow.faultVariable), false); + Node faultVariable = fetchVariableData(_scopeFrame.resolve(_othrow.faultVariable), false); fault = createFault(_othrow.faultName, (Element)faultVariable,_othrow.faultVariable.type,_othrow); } catch (FaultException e) { // deal with this as a fault (just not the one we hoped for) Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/extvar/jdbc/JdbcExternalVariableEngineTest.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/extvar/jdbc/JdbcExternalVariableEngineTest.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/extvar/jdbc/JdbcExternalVariableEngineTest.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/extvar/jdbc/JdbcExternalVariableEngineTest.java Fri Jan 4 06:19:42 2008 @@ -28,7 +28,6 @@ import org.apache.ode.bpel.engine.extvar.ExternalVariableConf; import org.apache.ode.bpel.engine.extvar.ExternalVariableConf.Variable; -import org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule; import org.apache.ode.utils.DOMUtils; import org.apache.ode.utils.GUID; import org.apche.ode.bpel.evar.ExternalVariableModule.Locator; @@ -37,6 +36,7 @@ import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -114,8 +114,9 @@ value = _engine.writeValue(value); assertNotNull(value); assertNotNull(value.locator); - assertTrue(value.locator.containsKey("id1")); - assertTrue(value.locator.containsKey("id2")); + System.out.println(DOMUtils.domToString(value.locator.reference)); + assertTrue(DOMUtils.domToString((Element)value.locator.reference).indexOf("id1")!=-1); + assertTrue(DOMUtils.domToString((Element)value.locator.reference).indexOf("id2")!=-1); } @Test @@ -146,11 +147,9 @@ assertEquals(_iid,readVal.locator.iid); assertEquals(_pid,readVal.locator.pid); - assertEquals(2, readVal.locator.size()); - assertTrue(readVal.locator.containsKey("id1")); - assertTrue(readVal.locator.containsKey("id2")); - assertEquals(value.locator.get("id1"), readVal.locator.get("id1")); - assertEquals(value.locator.get("id2"), readVal.locator.get("id2")); + assertEquals(2, DOMUtils.countKids((Element)readVal.locator.reference, Node.ELEMENT_NODE)); + assertEquals(DOMUtils.domToString(value.locator.reference), DOMUtils.domToString(readVal.locator.reference)); + } } Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java (original) +++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java Fri Jan 4 06:19:42 2008 @@ -40,6 +40,7 @@ import org.apache.ode.bpel.runtime.channels.ActivityRecoveryChannel; import org.apache.ode.jacob.vpu.ExecutionQueueImpl; import org.apache.ode.jacob.vpu.JacobVPU; +import org.apche.ode.bpel.evar.ExternalVariableModuleException; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -414,5 +415,25 @@ // TODO Auto-generated method stub } + + public Node readExtVar(String externalVariableId, Node reference) throws ExternalVariableModuleException { + // TODO Auto-generated method stub + return null; + } + + public Node readVariable(Long scopeInstanceId, String varname, boolean forWriting) throws FaultException { + // TODO Auto-generated method stub + return null; + } + + public ValueReferencePair writeExtVar(String externalVariableId, Node reference, Node value) throws ExternalVariableModuleException { + // TODO Auto-generated method stub + return null; + } + + public Node writeVariable(VariableInstance var, Node changes) { + // TODO Auto-generated method stub + return null; + } } Added: ode/branches/APACHE_ODE_1.1/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java?rev=608847&view=auto ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java (added) +++ ode/branches/APACHE_ODE_1.1/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java Fri Jan 4 06:19:42 2008 @@ -0,0 +1,52 @@ +package org.apache.ode.test; + +import java.sql.Connection; +import java.sql.Statement; + +import javax.xml.namespace.QName; + +import org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule; +import org.apache.ode.utils.GUID; +import org.hsqldb.jdbc.jdbcDataSource; +import org.junit.Test; + +/** + * Simple test of external variables. + * + * @author Maciej Szefler <mszefler at gmail dot com> + * + */ +public class ExternalVariableTest extends BPELTestAbstract { + + private JdbcExternalVariableModule _jdbcext; + + private jdbcDataSource _ds; + + public void setUp() throws Exception { + super.setUp(); + _ds = new org.hsqldb.jdbc.jdbcDataSource(); + _ds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString()); + _ds.setUser("sa"); + + _jdbcext = new JdbcExternalVariableModule(); + _jdbcext.registerDataSource("testds", _ds); + _server.registerExternalVariableEngine(_jdbcext); + + Connection conn = _ds.getConnection(); + Statement s = conn.createStatement(); + s.execute("create table extvartable1 (" + "id1 VARCHAR PRIMARY KEY," + "_id2_ VARCHAR," + "pid VARCHAR, " + "iid INT," + + "cts DATETIME," + "uts DATETIME," + "foo VARCHAR," + "bar VARCHAR );"); + + s.execute("insert into extvartable1(id1,pid,foo) values ('123','" + + new QName("http://ode/bpel/unit-test","HelloWorld2-1").toString() + + "','thefoo');"); + conn.close(); + + } + + @Test + public void testHelloWorld2() throws Throwable { + go("/bpel/2.0/ExtVar"); + } + +} Propchange: ode/branches/APACHE_ODE_1.1/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ode/branches/APACHE_ODE_1.1/bpel-test/src/test/resources/bpel/2.0/ExtVar/HelloWorld2.bpel URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-test/src/test/resources/bpel/2.0/ExtVar/HelloWorld2.bpel?rev=608847&r1=608846&r2=608847&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.1/bpel-test/src/test/resources/bpel/2.0/ExtVar/HelloWorld2.bpel (original) +++ ode/branches/APACHE_ODE_1.1/bpel-test/src/test/resources/bpel/2.0/ExtVar/HelloWorld2.bpel Fri Jan 4 06:19:42 2008 @@ -48,7 +48,8 @@ <variable name="myVar" messageType="test:HelloMessage"/> <variable name="tmpVar" type="xsd:string"/> <variable name="tmpDate" type="xsd:dateTime"/> - <variable name="external" element="foo:row" xvar:id="evar1" /> + <variable name="idx" type="xsd:string" /> + <variable name="external" element="foo:row" xvar:id="evar1" xvar:related-to="idx"/> </variables> <sequence> @@ -60,13 +61,19 @@ variable="myVar" createInstance="yes"/> + <assign> + <copy> + <from>''</from> + <to variable="idx" /> + </copy> + </assign> <assign name="assign1"> <copy> <from variable="myVar" part="TestPart"/> <to variable="tmpVar"/> </copy> <copy> - <bpws:from xmlns="">concat($tmpVar, $external/row/pid)</bpws:from> + <bpws:from xmlns="">concat($tmpVar, $external/pid)</bpws:from> <to variable="myVar" part="TestPart"/> </copy> </assign>
