Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/REPLY.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/REPLY.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/REPLY.java (original) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/REPLY.java Tue May 12 15:23:30 2009 @@ -56,9 +56,18 @@ for (OScope.CorrelationSet cset : oreply.initCorrelations) initializeCorrelation(_scopeFrame.resolve(cset), _scopeFrame.resolve(oreply.variable)); - // send reply - getBpelRuntime().reply(_scopeFrame.resolve(oreply.partnerLink), oreply.operation.getName(), - oreply.messageExchangeId, (Element)msg, oreply.fault); + // If this reply matches an event, we have to know which scope it fits in + ScopeFrame eventFrame = _scopeFrame.findEventScope(); + String eventFrameId = eventFrame == null ? "" : eventFrame.scopeInstanceId.toString(); + + // send reply + String mid = oreply.messageExchangeId == null ? "" : oreply.messageExchangeId; + if (oreply.resource != null) + getBpelRuntime().reply(_scopeFrame.resolve(oreply.resource), + mid+eventFrameId, (Element)msg, oreply.fault); + else + getBpelRuntime().reply(_scopeFrame.resolve(oreply.partnerLink), oreply.operation.getName(), + mid+eventFrameId, (Element)msg, oreply.fault); } catch (FaultException e) { __log.error(e); fault = createFault(e.getQName(), oreply);
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ResourceInstance.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ResourceInstance.java?rev=773939&view=auto ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ResourceInstance.java (added) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ResourceInstance.java Tue May 12 15:23:30 2009 @@ -0,0 +1,50 @@ +package org.apache.ode.bpel.rtrep.v2; + +import org.apache.ode.bpel.rapi.ResourceModel; +import org.apache.ode.bpel.rapi.Resource; +import org.apache.ode.utils.ObjectPrinter; + +import java.io.Serializable; + +/** + * Serializable reference to a resource instance. + */ +public class ResourceInstance implements Serializable, Resource { + + private Long scopeInstanceId; + private OResource resource; + + public ResourceInstance(Long scopeInstanceId, OResource resource) { + this.scopeInstanceId = scopeInstanceId; + this.resource = resource; + } + + public String getName() { + return resource.getName(); + } + + public Long getScopeInstanceId() { + return scopeInstanceId; + } + + public ResourceModel getModel() { + return resource; + } + + @Override + public int hashCode() { + return this.scopeInstanceId.hashCode() ^ this.resource.hashCode(); + } + + @Override + public boolean equals(Object obj) { + ResourceInstance other = (ResourceInstance) obj; + return scopeInstanceId.equals(other.getScopeInstanceId()) && resource.equals(other.getModel()); + } + + @Override + public String toString() { + return ObjectPrinter.toString(this, new Object[] { "resourceDecl", resource, "scopeInstanceId", + scopeInstanceId }); + } +} Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeImpl.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeImpl.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeImpl.java (original) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeImpl.java Tue May 12 15:23:30 2009 @@ -133,6 +133,18 @@ return null; } + public String extractAddress(ResourceModel resourceModel) throws FaultException { + OResource resource = (OResource) resourceModel; + String rootPath = ""; + if (resource.getReference() != null) + rootPath = extractAddress(resource.getReference()) + "/"; + + BoundVariableEvaluationContext ctx = new BoundVariableEvaluationContext(); + String subpath = ((Text)_expLangRuntimeRegistry.evaluateNode(resource.getSubpath(), ctx)).getWholeText(); + + return rootPath + subpath; + } + public String extractMatch(Element msgData, PropertyExtractor extractor) throws FaultException { OExpression expr = (OExpression) extractor; BoundVariableEvaluationContext ctx = new BoundVariableEvaluationContext(); Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeInstanceImpl.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeInstanceImpl.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeInstanceImpl.java (original) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/RuntimeInstanceImpl.java Tue May 12 15:23:30 2009 @@ -4,6 +4,7 @@ import java.io.OutputStream; import java.util.Collection; import java.util.Date; +import java.util.Map; import java.net.URI; import javax.wsdl.Operation; @@ -107,6 +108,18 @@ _brc.initializePartnerLinks(parentScopeId, partnerLinks); } + public void initializeResource(Long scopeInstanceId, OResource resource, String url) { + _brc.initializeResource(scopeInstanceId, resource, url); + } + + public void initializeInstantiatingUrl(String url) { + _brc.initializeInstantiatingUrl(url); + } + + public String getInstantiatingUrl() { + return _brc.getInstantiatingUrl(); + } + public void cancelOutstandingRequests(String channelId) { getORM().cancel(channelId); } @@ -125,6 +138,13 @@ _brc.select(pickResponseChannelStr, timeout, selectors); } + public void checkResourceRoute(ResourceInstance resourceInstance, String mexRef, + PickResponseChannel pickResponseChannel, int selectorIdx) { + final String pickResponseChannelStr = pickResponseChannel.export(); + getORM().register(pickResponseChannelStr, resourceInstance, resourceInstance.getModel().getMethod(), mexRef); + _brc.checkResourceRoute(resourceInstance, pickResponseChannelStr, selectorIdx); + } + public CorrelationKey readCorrelation(CorrelationSetInstance cset) { return _brc.readCorrelation(cset); } @@ -356,6 +376,14 @@ return _brc.getMyRequest(mexId); } + public Map<String,String> getProperties(String mexId) { + return _brc.getProperties(mexId); + } + + public void setInstantiatingMex(String mexId) { + _brc.setInstantiatingMex(mexId); + } + /** * Proxy to {...@link BpelRuntimeContext# }. */ @@ -391,8 +419,8 @@ /** * Proxy to {...@link ProcessControlContext# }. */ - public Long getPid() { - return _brc.getPid(); + public Long getInstanceId() { + return _brc.getInstanceId(); } /** @@ -437,9 +465,14 @@ _brc.sendEvent(evt); } - /** - * Proxy to {...@link IOContext#reply(PartnerLink, String, String, Element, QName) }. - */ + public void associateEvent(PartnerLinkInstance plinkInstance, String opName, String mexRef, String scopeIid) { + getORM().associateEvent(plinkInstance, opName, mexRef, scopeIid); + } + + public void associateEvent(ResourceInstance resourceInstance, String mexRef, String scopeIid) { + getORM().associateEvent(resourceInstance, resourceInstance.getModel().getMethod(), mexRef, scopeIid); + } + public void reply(PartnerLinkInstance plink, String opName, String bpelmex, Element element, QName fault) throws FaultException { String mexid = getORM().release(plink, opName, bpelmex); if (mexid == null) @@ -454,6 +487,20 @@ } } + public void reply(ResourceInstance resource, String bpelmex, Element element, QName fault) throws FaultException { + String mexid = getORM().release(resource, resource.getModel().getMethod(), bpelmex); + if (mexid == null) + throw new FaultException(_runtime._oprocess.constants.qnMissingRequest); + + try { + _brc.reply(mexid, resource, element, fault); + } catch (NoSuchOperationException e) { + // reply to operation that is either not defined or one-way. Perhaps this should be detected at compile time? + throw new FaultException(_runtime._oprocess.constants.qnMissingRequest, + "Undefined two-way operation \"" + resource + "\"."); + } + } + /** * Proxy to {...@link ProcessControlContext#forceFlush() }. */ @@ -551,8 +598,7 @@ // borrowed from ASSIGN.evalQuery() Node ret = DOMUtils.findChildByName(message, new QName(null, part.name)); if (part.type instanceof OElementVarType) { - QName elName = ((OElementVarType) part.type).elementType; - ret = DOMUtils.findChildByName((Element) ret, elName); + ret = DOMUtils.getFirstChildElement((Element) ret); } else if (part.type == null) { // Special case of header parts never referenced in the WSDL def if (ret != null && ret.getNodeType() == Node.ELEMENT_NODE @@ -585,6 +631,11 @@ } } + public String invoke(String requestId, org.apache.ode.bpel.iapi.Resource resource, Element outgoingMessage) + throws FaultException { + return _brc.invoke(requestId, resource, outgoingMessage); + } + /** * @return */ Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/SCOPE.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/SCOPE.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/SCOPE.java (original) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/SCOPE.java Tue May 12 15:23:30 2009 @@ -19,12 +19,7 @@ package org.apache.ode.bpel.rtrep.v2; 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 java.util.*; import javax.xml.namespace.QName; @@ -44,8 +39,11 @@ import org.apache.ode.bpel.rtrep.v2.channels.ParentScopeChannelListener; import org.apache.ode.bpel.rtrep.v2.channels.TerminationChannel; import org.apache.ode.bpel.rtrep.v2.channels.TerminationChannelListener; +import org.apache.ode.bpel.rapi.InvalidProcessException; +import org.apache.ode.bpel.common.FaultException; import org.apache.ode.jacob.ChannelListener; import org.apache.ode.jacob.SynchChannel; +import org.apache.ode.utils.GUID; import org.apache.ode.utils.DOMUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -86,8 +84,7 @@ public void run() { // Start the child activity. - _child = new ActivityInfo(genMonotonic(), - _oscope.activity, + _child = new ActivityInfo(genMonotonic(), _oscope.activity, newChannel(TerminationChannel.class), newChannel(ParentScopeChannel.class)); instance(createChild(_child, _scopeFrame, _linkFrame)); @@ -114,10 +111,49 @@ getBpelRuntime().initializePartnerLinks(_scopeFrame.scopeInstanceId, _oscope.partnerLinks.values()); + initializeResources(); + sendEvent(new ScopeStartEvent()); instance(new ACTIVE()); } + private void initializeResources() { + // Filter instantiating resource to handle it first + ArrayList<OResource> resources = new ArrayList<OResource>(); + OResource instantiating = null; + for (OResource resource : _oscope.resource.values()) { + if (resource.isInstantiateResource()) instantiating = resource; + else resources.add(resource); + } + + if (instantiating != null) { + try { + String url = getBpelRuntime().getExpLangRuntime().evaluateAsString( + instantiating.getSubpath(), getEvaluationContext()); + url = url + "/" + getBpelRuntime().getInstanceId(); + getBpelRuntime().initializeInstantiatingUrl(url); + getBpelRuntime().initializeResource(_scopeFrame.scopeInstanceId, instantiating, url); + } catch (FaultException e) { + _self.parent.completed(new FaultData(e.getQName(), instantiating, + "Error in resource evaluation: " + e.toString()), CompensationHandler.emptySet()); + } + } + + for (OResource resource : resources) { + try { + String url = getBpelRuntime().getExpLangRuntime().evaluateAsString( + resource.getSubpath(), getEvaluationContext()); + if (url.endsWith("/")) url = url.substring(0, url.length() - 1); + url = getBpelRuntime().getInstantiatingUrl() + url; + + getBpelRuntime().initializeResource(_scopeFrame.scopeInstanceId, resource, url); + } catch (FaultException e) { + _self.parent.completed(new FaultData(e.getQName(), resource, + "Error in resource evaluation: " + e.toString()), CompensationHandler.emptySet()); + } + } + } + private List<CompensationHandler> findCompensationData(OScope scope) { List<CompensationHandler> out = new ArrayList<CompensationHandler>(); for (CompensationHandler ch : _scopeFrame.availableCompensations) { Modified: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ScopeFrame.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ScopeFrame.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ScopeFrame.java (original) +++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/ScopeFrame.java Tue May 12 15:23:30 2009 @@ -50,6 +50,8 @@ final InstanceGlobals globals; + boolean eventScope = false; + /** Constructor used to create "fault" scopes. */ ScopeFrame( OScope scopeDef, Long scopeInstanceId, @@ -85,23 +87,40 @@ return (parent != null) ? parent.find(scope) : null; } + public ScopeFrame findEventScope() { + if (eventScope) return this; + else if (parent == null) return null; + else return parent.findEventScope(); + } + public VariableInstance resolve(OScope.Variable variable) { ScopeFrame scopeFrame = find(variable.declaringScope); if (scopeFrame == null) return null; return new VariableInstance(scopeFrame.scopeInstanceId, variable); } + public VariableInstance resolveVariable(String variableName) { + OScope.Variable cset = oscope.getLocalVariable(variableName); + if (cset != null) return new VariableInstance(scopeInstanceId, cset); + else if (parent != null) return parent.resolveVariable(variableName); + else return null; + } + public CorrelationSetInstance resolve(OScope.CorrelationSet cset) { return new CorrelationSetInstance(find(cset.declaringScope).scopeInstanceId, cset); } - public CorrelationSetInstance resolve(String correlationName) { + public CorrelationSetInstance resolveCorrelation(String correlationName) { OScope.CorrelationSet cset = oscope.getCorrelationSet(correlationName); if (cset != null) return new CorrelationSetInstance(scopeInstanceId, cset); - else if (parent != null) return parent.resolve(correlationName); + else if (parent != null) return parent.resolveCorrelation(correlationName); else return null; } + public ResourceInstance resolve(OResource resource) { + return new ResourceInstance(find(resource.getDeclaringScope()).scopeInstanceId, resource); + } + public PartnerLinkInstance resolve(OPartnerLink partnerLink) { return new PartnerLinkInstance(find(partnerLink.declaringScope).scopeInstanceId, partnerLink); } Modified: ode/trunk/runtimes/src/test/java/org/apache/ode/bpel/rtrep/v2/CoreBpelTest.java URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/test/java/org/apache/ode/bpel/rtrep/v2/CoreBpelTest.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/runtimes/src/test/java/org/apache/ode/bpel/rtrep/v2/CoreBpelTest.java (original) +++ ode/trunk/runtimes/src/test/java/org/apache/ode/bpel/rtrep/v2/CoreBpelTest.java Tue May 12 15:23:30 2009 @@ -24,6 +24,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Collection; +import java.util.Map; import javax.wsdl.Operation; import javax.xml.namespace.QName; @@ -40,6 +41,8 @@ import org.apache.ode.bpel.rapi.*; import org.apache.ode.bpel.rtrep.v2.channels.*; import org.apache.ode.bpel.extension.ExtensionOperation; +import org.apache.ode.bpel.iapi.*; +import org.apache.ode.bpel.iapi.Resource; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.junit.Assert; @@ -72,7 +75,7 @@ _pid = (long) 19355; } - public Long getPid() { + public Long getInstanceId() { return _pid; } @@ -112,6 +115,38 @@ return null; //To change body of implemented methods use File | Settings | File Templates. } + public Map<String, String> getProperties(String mexId) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void initializeResource(Long parentScopeId, OResource resource, String url) { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void checkResourceRoute(ResourceInstance resourceInstance, String mexRef, PickResponseChannel pickResponseChannel, int selectorIdx) { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void initializeInstantiatingUrl(String url) { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getInstantiatingUrl() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void associateEvent(PartnerLinkInstance plinkInstance, String opName, String mexRef, String scopeIid) { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void associateEvent(ResourceInstance resourceInstance, String mexRef, String scopeIid) { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void reply(ResourceInstance resource, String bpelmex, Element element, QName fault) throws FaultException { + //To change body of implemented methods use File | Settings | File Templates. + } + public void initializePartnerLinks(Long parentScopeId, Collection<OPartnerLink> partnerLinks) { //To change body of implemented methods use File | Settings | File Templates. } @@ -123,6 +158,10 @@ return null; //To change body of implemented methods use File | Settings | File Templates. } + public String invoke(String requestId, Resource resource, Element outgoingMessage) throws FaultException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + public void registerTimer(TimerResponseChannel timerChannel, Date future) { //To change body of implemented methods use File | Settings | File Templates. } @@ -131,6 +170,10 @@ //To change body of implemented methods use File | Settings | File Templates. } + public void checkResourceRoute(String url, String method, String mexRef, PickResponseChannel pickResponseChannel, int selectorIdx) { + //To change body of implemented methods use File | Settings | File Templates. + } + public CorrelationKey readCorrelation(CorrelationSetInstance cset) { return null; //To change body of implemented methods use File | Settings | File Templates. } @@ -339,6 +382,9 @@ return null; } + public void setInstantiatingMex(String mexId) { + } + public QName getPartnerFault(String mexId) { // TODO Auto-generated method stub return null; Modified: ode/trunk/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java URL: http://svn.apache.org/viewvc/ode/trunk/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java (original) +++ ode/trunk/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java Tue May 12 15:23:30 2009 @@ -317,7 +317,7 @@ } finally { close(con); } - __log.info("Using database dialect: " + d); + __log.debug("Using database dialect: " + d); return d; } Modified: ode/trunk/scheduler-simple/src/test/java/org/apache/ode/scheduler/simple/SimpleSchedulerTest.java URL: http://svn.apache.org/viewvc/ode/trunk/scheduler-simple/src/test/java/org/apache/ode/scheduler/simple/SimpleSchedulerTest.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/scheduler-simple/src/test/java/org/apache/ode/scheduler/simple/SimpleSchedulerTest.java (original) +++ ode/trunk/scheduler-simple/src/test/java/org/apache/ode/scheduler/simple/SimpleSchedulerTest.java Tue May 12 15:23:30 2009 @@ -218,4 +218,4 @@ return scheduler; } -} +} \ No newline at end of file Modified: ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java URL: http://svn.apache.org/viewvc/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java?rev=773939&r1=773938&r2=773939&view=diff ============================================================================== --- ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java (original) +++ ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java Tue May 12 15:23:30 2009 @@ -98,19 +98,11 @@ private static class SchemaErrorHandler implements DOMErrorHandler { public boolean handleError(DOMError error) { - boolean isWarning = (error.getSeverity() == DOMError.SEVERITY_WARNING); - if (isWarning) { - __log.warn("Schema error", ((Exception)error.getRelatedException())); - __log.warn(error.getLocation().getUri() + ":" + error.getLocation().getLineNumber()); - __log.warn(error.getRelatedData()); - __log.warn(error.getRelatedException()); - } else { - __log.error("Schema error", ((Exception)error.getRelatedException())); - __log.error(error.getLocation().getUri() + ":" + error.getLocation().getLineNumber()); - __log.error(error.getRelatedData()); - __log.error(error.getRelatedException()); - } - return isWarning; + __log.warn("Schema error", ((Exception)error.getRelatedException())); + __log.warn(error.getLocation().getUri() + ":" + error.getLocation().getLineNumber()); + __log.warn(error.getRelatedData()); + __log.warn(error.getRelatedException()); + return true; } }
