You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/09/10 21:07:05 UTC
svn commit: r693931 [10/12] - in /ode/trunk:
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath10/
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/
runtimes...
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Selector.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Selector.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Selector.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Selector.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.rapi.PartnerLink;
+import org.apache.ode.utils.ObjectPrinter;
+
+import java.io.Serializable;
+
+public class Selector implements Serializable, org.apache.ode.bpel.rapi.Selector {
+ private static final long serialVersionUID = 1L;
+
+ public final PartnerLinkInstance plinkInstance;
+ public final CorrelationKey correlationKey;
+ public final String opName;
+ public final String messageExchangeId;
+ public final int idx;
+ public final boolean oneWay;
+
+ Selector(int idx, PartnerLinkInstance plinkInstance, String opName, boolean oneWay, String mexId, CorrelationKey ckey) {
+ this.idx = idx;
+ this.plinkInstance = plinkInstance;
+ this.correlationKey = ckey;
+ this.opName = opName;
+ this.messageExchangeId = mexId;
+ this.oneWay = oneWay;
+ }
+
+ public String toString() {
+ return ObjectPrinter.toString(this, new Object[] {
+ "plinkInstnace", plinkInstance,
+ "ckey", correlationKey,
+ "opName" ,opName,
+ "oneWay", oneWay ? "yes" : "no",
+ "mexId", messageExchangeId,
+ "idx", Integer.valueOf(idx)
+ });
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ return correlationKey;
+ }
+
+ public String getMesageExchangeId() {
+ return messageExchangeId;
+ }
+
+ public String getOperation() {
+ return opName;
+ }
+
+ public PartnerLink getPartnerLink() {
+ return plinkInstance;
+ }
+
+ public boolean isOneWay() {
+ return oneWay;
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Serializer.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Serializer.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Serializer.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/Serializer.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.util.Arrays;
+
+/**
+ * Header written at the beginning of every compiled BPEL object file.
+ */
+public class Serializer {
+
+ public static final byte[] MAGIC_NUMBER_OFH_20040908 =
+ new byte[] { 0x55, '5', 'S', 0x00, 'O', 'F', 'H', 0x20, 0x04, 0x09, 0x08 };
+
+ public static final byte[] MAGIC_NUMBER_OFH_20061101 =
+ new byte[] { 0x55, '5', 'S', 0x00, 'O', 'F', 'H', 0x20, 0x06, 0x11, 0x01 };
+
+ public static final byte[] MAGIC_NUMBER = MAGIC_NUMBER_OFH_20061101;
+
+ public static final short FORMAT_SERIALIZED_JAVA14 = 0x01;
+
+ // START PERSISTED FIELDS
+ public final byte[] magic = new byte[MAGIC_NUMBER.length];
+
+ /** Compiled Process representation format. */
+ public short format;
+
+ /** Time of compilation (system local time). */
+ public long compileTime;
+
+ /** Deprecated, only one process per file. */
+ public final int numProcesses = 1;
+
+ public InputStream _inputStream;
+
+ public String guid;
+
+ public QName type;
+
+
+ // END PERSISTED FIELDS
+
+ public Serializer(long compileTime) {
+ System.arraycopy(MAGIC_NUMBER, 0, magic, 0, MAGIC_NUMBER.length);
+ this.format = FORMAT_SERIALIZED_JAVA14;
+ this.compileTime = compileTime;
+ }
+
+ public Serializer() {}
+
+ public Serializer(InputStream inputStream) throws IOException {
+ _inputStream = inputStream;
+ read(inputStream);
+ }
+
+
+ public void read(InputStream is) throws IOException {
+ DataInputStream oin = new DataInputStream(is);
+ byte[] magic = new byte[MAGIC_NUMBER.length];
+ oin.read(magic, 0, magic.length);
+
+ if (Arrays.equals(MAGIC_NUMBER_OFH_20040908, magic)) {
+ // Old format requires us to read the OModel to get the type and guid.
+ this.format = oin.readShort();
+ this.compileTime = oin.readLong();
+ oin.readInt();
+ ObjectInputStream ois = new CustomObjectInputStream(_inputStream);
+ OProcess oprocess;
+ try {
+ oprocess = (OProcess) ois.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new IOException("DataStream Error");
+ }
+ this.type = new QName(oprocess.targetNamespace, oprocess.processName);
+ this.guid = "OLD-FORMAT-NO-GUID";
+
+ return;
+ }
+ // The current (most recent) scheme
+ if (Arrays.equals(MAGIC_NUMBER, magic)) {
+ this.format = oin.readShort();
+ this.compileTime = oin.readLong();
+ this.guid = oin.readUTF();
+ String tns = oin.readUTF();
+ String name = oin.readUTF();
+ this.type = new QName(tns, name);
+ return;
+ }
+
+ throw new IOException("Unrecognized file format (bad magic number).");
+ }
+
+ public void writeOProcess(OProcess process, OutputStream os) throws IOException {
+ DataOutputStream out = new DataOutputStream(os);
+
+ out.write(MAGIC_NUMBER);
+ out.writeShort(format);
+ out.writeLong(compileTime);
+ out.writeUTF(process.guid);
+ out.writeUTF(process.targetNamespace);
+ out.writeUTF(process.processName);
+ out.flush();
+ ObjectOutputStream oos = new CustomObjectOutputStream(os);
+ oos.writeObject(process);
+ oos.flush();
+ }
+
+ public OProcess readOProcess() throws IOException, ClassNotFoundException {
+// if (_oprocess != null)
+// return _oprocess;
+
+ ObjectInputStream ois = new CustomObjectInputStream(_inputStream);
+ OProcess oprocess;
+ try {
+ oprocess = (OProcess) ois.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new IOException("DataStream Error");
+ }
+
+ return oprocess;
+ }
+
+ static class CustomObjectOutputStream extends ObjectOutputStream {
+
+ /**
+ * @param out
+ * @throws IOException
+ */
+ public CustomObjectOutputStream(OutputStream out) throws IOException {
+ super(out);
+ enableReplaceObject(true);
+ }
+
+ protected Object replaceObject(Object obj) throws IOException{
+ if(obj instanceof QName){
+ QName q = (QName)obj;
+ return new OQName(q.getNamespaceURI(), q.getLocalPart(), q.getPrefix());
+ }
+ return super.replaceObject(obj);
+ }
+
+ }
+
+ static class CustomObjectInputStream extends ObjectInputStream {
+
+ /**
+ * @param in
+ * @throws IOException
+ */
+ public CustomObjectInputStream(InputStream in) throws IOException {
+ super(in);
+ enableResolveObject(true);
+ }
+
+ protected Object resolveObject(Object obj) throws IOException {
+ if(obj instanceof OQName){
+ OQName q = (OQName)obj;
+ return new QName(q.uri, q.local, q.prefix);
+ }
+ return super.resolveObject(obj);
+ }
+
+ /**
+ * Override coverts old class names into new class names to preserve compatibility with
+ * pre-Apache namespaces.
+ */
+ @Override
+ protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
+ ObjectStreamClass read = super.readClassDescriptor();
+ if (read.getName().startsWith("com.fs.pxe.")) {
+ return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.pxe.", "org.apache.ode.")));
+ }
+ if (read.getName().startsWith("com.fs.utils.")) {
+ return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.utils.", "org.apache.ode.utils.")));
+ }
+ return read;
+ }
+
+ }
+
+ static class OQName implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ final String local;
+ final String uri;
+ final String prefix;
+
+ OQName(String uri, String local, String prefix){
+ this.uri = uri;
+ this.local = local;
+ this.prefix = prefix;
+ }
+ }
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/SystemException.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/SystemException.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/SystemException.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/SystemException.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+/**
+ * Run-time exception indicating an infrastructure problem.
+ */
+class SystemException extends RuntimeException {
+ private static final long serialVersionUID = 3194250610255026706L;
+
+ SystemException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TERMINATE.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TERMINATE.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TERMINATE.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TERMINATE.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+/**
+ * JacobRunnable that performs the work of the <code>empty</code> activity.
+ */
+class TERMINATE extends ACTIVITY {
+
+ private static final long serialVersionUID = 1L;
+
+ public TERMINATE(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+ super(self, scopeFrame, linkFrame);
+ }
+
+ public final void run() {
+ getBpelRuntime().terminate();
+ _self.parent.completed(null, CompensationHandler.emptySet());
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/THROW.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/THROW.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/THROW.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/THROW.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.rtrep.v1.channels.FaultData;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Throw BPEL fault activity.
+ */
+class THROW extends ACTIVITY {
+ private static final long serialVersionUID = 1L;
+ private static final Log __log = LogFactory.getLog(ACTIVITY.class);
+
+ private OThrow _othrow;
+
+ public THROW(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+ super(self, scopeFrame, linkFrame);
+ _othrow = (OThrow) self.o;
+ }
+
+ public void run() {
+ FaultData fault = null;
+ if(_othrow.faultVariable != null){
+ try {
+ sendVariableReadEvent(_scopeFrame.resolve(_othrow.faultVariable));
+ 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)
+ __log.error(e);
+ fault = createFault(e.getQName(), _othrow);
+ }
+ }else{
+ fault = createFault(_othrow.faultName, _othrow);
+ }
+
+ _self.parent.completed(fault, CompensationHandler.emptySet());
+ }
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TimerWork.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TimerWork.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TimerWork.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/TimerWork.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import org.apache.ode.utils.ObjectPrinter;
+
+import java.io.Serializable;
+
+/**
+ * Work object representating a timer event.
+ */
+class TimerWork implements Serializable {
+ static final long serialVersionUID = 1;
+
+ private Long _pid;
+ private String _timerChannel;
+
+ /** Constructor. */
+ TimerWork(Long pid, String timerChannel) {
+ _pid = pid;
+ _timerChannel = timerChannel;
+ }
+
+ /** Get the Process Instance ID (PIID). */
+ public Long getPID() {
+ return _pid;
+ }
+
+ /** Get the exported for of the timer response channel. */
+ public String getTimerChannel(){
+ return _timerChannel;
+ }
+
+ public String toString() {
+ return ObjectPrinter.toString(this, new Object[] {
+ "pid", _pid,
+ "timerChannel", _timerChannel
+ });
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/VariableInstance.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/VariableInstance.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/VariableInstance.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/VariableInstance.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import org.apache.ode.bpel.rapi.Variable;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * Variable instance identifier.
+ */
+public class VariableInstance implements Serializable, Variable {
+ private static final long serialVersionUID = 1L;
+
+ public final OScope.Variable declaration;
+ public final Long scopeInstance;
+
+ VariableInstance(Long scopeInstance, OScope.Variable variable) {
+ this.scopeInstance = scopeInstance;
+ this.declaration = variable;
+ }
+
+ public boolean equals(Object obj) {
+ VariableInstance other = (VariableInstance) obj;
+ return other.declaration.equals(declaration) && other.scopeInstance.equals(scopeInstance);
+ }
+
+ public String getName() {
+ return declaration.name;
+ }
+
+ public long getScopeId() {
+ return scopeInstance;
+ }
+
+ public String getExternalId() {
+ if (declaration.extVar == null) return null;
+ return declaration.extVar.externalVariableId;
+ }
+
+ public QName getElementType() {
+ if (!(declaration.type instanceof OElementVarType)) return null;
+ else return ((OElementVarType)declaration.type).elementType;
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WAIT.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WAIT.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WAIT.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WAIT.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.rtrep.v1.channels.TerminationChannelListener;
+import org.apache.ode.bpel.rtrep.v1.channels.TimerResponseChannel;
+import org.apache.ode.bpel.rtrep.v1.channels.TimerResponseChannelListener;
+import org.apache.ode.utils.xsd.Duration;
+
+import java.util.Calendar;
+import java.util.Date;
+
+
+/**
+ * JacobRunnable that performs the work of the <code><wait></code> activity.
+ */
+class WAIT extends ACTIVITY {
+ private static final long serialVersionUID = 1L;
+ private static final Log __log = LogFactory.getLog(WAIT.class);
+
+ WAIT(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+ super(self, scopeFrame, linkFrame);
+ }
+
+ public final void run() {
+ Date dueDate = null;
+ try{
+ dueDate = getDueDate();
+ } catch(FaultException e){
+ __log.error("Fault while calculating due date: "
+ + e.getQName()
+ + "; Reason: " + e.getMessage());
+ _self.parent.completed(createFault(e.getQName(), _self.o), CompensationHandler.emptySet());
+ return;
+ }
+
+
+ if(dueDate.getTime() > System.currentTimeMillis()){
+ final TimerResponseChannel timerChannel = newChannel(TimerResponseChannel.class);
+ getBpelRuntime().registerTimer(timerChannel, dueDate);
+
+ object(false, new TimerResponseChannelListener(timerChannel){
+ private static final long serialVersionUID = 3120518305645437327L;
+
+ public void onTimeout() {
+ _self.parent.completed(null, CompensationHandler.emptySet());
+ }
+
+ public void onCancel() {
+ _self.parent.completed(null, CompensationHandler.emptySet());
+ }
+ }.or(new TerminationChannelListener(_self.self) {
+ private static final long serialVersionUID = -2791243270691333946L;
+
+ public void terminate() {
+ _self.parent.completed(null, CompensationHandler.emptySet());
+ object(new TimerResponseChannelListener(timerChannel) {
+ private static final long serialVersionUID = 677746737897792929L;
+
+ public void onTimeout() {
+ //ignore
+ }
+
+ public void onCancel() {
+ //ingore
+ }
+ });
+ }
+ }));
+ }else{
+ _self.parent.completed(null, CompensationHandler.emptySet());
+ }
+ }
+
+
+ protected Date getDueDate() throws FaultException {
+ OWait wait = (OWait)_self.o;
+
+ // Assume the data was well formed (we have a deadline or a duration)
+ assert wait.hasFor() || wait.hasUntil();
+
+ EvaluationContext evalCtx = getEvaluationContext();
+
+ Date dueDate = null;
+ if (wait.hasFor()) {
+ Calendar cal = Calendar.getInstance();
+ Duration duration = getBpelRuntime().getExpLangRuntime().evaluateAsDuration(wait.forExpression, evalCtx);
+ duration.addTo(cal);
+ dueDate = cal.getTime();
+ } else if (wait.hasUntil()) {
+ Calendar cal = getBpelRuntime().getExpLangRuntime().evaluateAsDate(wait.untilExpression, evalCtx);
+ dueDate = cal.getTime();
+ } else {
+ throw new AssertionError("Static checks failed to find bad WaitActivity!");
+ }
+
+ // For now if we cannot evaluate a due date, we assume it is due now.
+ // TODO: BPEL-ISSUE: verify BPEL spec for proper handling of these errors
+ if (dueDate == null)
+ dueDate = new Date();
+
+ return dueDate;
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WHILE.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WHILE.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WHILE.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/WHILE.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.rtrep.v1.channels.FaultData;
+import org.apache.ode.bpel.rtrep.v1.channels.ParentScopeChannel;
+import org.apache.ode.bpel.rtrep.v1.channels.ParentScopeChannelListener;
+import org.apache.ode.bpel.rtrep.v1.channels.TerminationChannel;
+import org.apache.ode.bpel.rtrep.v1.channels.TerminationChannelListener;
+import org.apache.ode.jacob.SynchChannel;
+import org.w3c.dom.Element;
+
+/**
+ * BPEL <while> activity
+ */
+class WHILE extends ACTIVITY {
+ private static final long serialVersionUID = 1L;
+
+ private static final Log __log = LogFactory.getLog(WHILE.class);
+
+ private Set<CompensationHandler> _compHandlers = new HashSet<CompensationHandler>();
+
+ public WHILE(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+ super(self, scopeFrame, linkFrame);
+ }
+
+ public void run() {
+
+ boolean condResult = false;
+
+ try {
+ condResult = checkCondition();
+ } catch (FaultException fe) {
+ __log.error(fe);
+ _self.parent.completed(createFault(fe.getQName(), _self.o),_compHandlers);
+ return;
+ }
+
+ if (condResult) {
+ ActivityInfo child = new ActivityInfo(genMonotonic(),
+ getOWhile().activity,
+ newChannel(TerminationChannel.class), newChannel(ParentScopeChannel.class));
+ instance(createChild(child, _scopeFrame, _linkFrame));
+ instance(new WAITER(child));
+ } else /* stop. */ {
+ _self.parent.completed(null, _compHandlers);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "<T:Act:While:" + _self.o + ">";
+ }
+
+ protected Log log() {
+ return __log;
+ }
+
+ private OWhile getOWhile() {
+ return (OWhile)_self.o;
+ }
+
+ /**
+ * Evaluates the while condition.
+ *
+ * @return <code>true</code> if the while condition is satisfied, <code>false</code> otherwise.
+ * @throws FaultException in case of standard expression fault (e.g. selection failure)
+ */
+ private boolean checkCondition() throws FaultException {
+ return getBpelRuntime().getExpLangRuntime().evaluateAsBoolean(getOWhile().whileCondition,getEvaluationContext());
+ }
+
+ private class WAITER extends BpelJacobRunnable {
+ private static final long serialVersionUID = -7645042174027252066L;
+ private ActivityInfo _child;
+ private boolean _terminated;
+
+ WAITER(ActivityInfo child) {
+ _child = child;
+ }
+
+ public void run() {
+ object(false, new TerminationChannelListener(_self.self) {
+ private static final long serialVersionUID = -5471984635653784051L;
+
+ public void terminate() {
+ _terminated = true;
+ replication(_child.self).terminate();
+ instance(WAITER.this);
+ }
+ }.or(new ParentScopeChannelListener(_child.parent) {
+ private static final long serialVersionUID = 3907167240907524405L;
+
+ public void compensate(OScope scope, SynchChannel ret) {
+ _self.parent.compensate(scope,ret);
+ instance(WAITER.this);
+ }
+
+ public void completed(FaultData faultData, Set<CompensationHandler> compensations) {
+ _compHandlers.addAll(compensations);
+ if (_terminated || faultData != null)
+ _self.parent.completed(faultData, compensations);
+ else
+ instance(WHILE.this);
+ }
+
+ public void cancelled() { completed(null, CompensationHandler.emptySet()); }
+ public void failure(String reason, Element data) { completed(null, CompensationHandler.emptySet()); }
+ }));
+ }
+ }
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ActivityRecovery.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ActivityRecovery.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ActivityRecovery.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ActivityRecovery.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+
+/**
+ */
+@ChannelType
+public interface ActivityRecovery {
+
+ /**
+ * Retry the activity.
+ */
+ void retry();
+
+ /**
+ * Cancel the activity (unsuccessful completion).
+ */
+ void cancel();
+
+ /**
+ * Fault the activity. Fault data is optional.
+ */
+ void fault(FaultData faultData);
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Compensation.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Compensation.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Compensation.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Compensation.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.SynchChannel;
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ */
+@ChannelType
+public interface Compensation {
+
+ public void forget();
+
+ public void compensate(SynchChannel ret);
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/EventHandlerControl.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/EventHandlerControl.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/EventHandlerControl.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/EventHandlerControl.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Channel used to control processing of event handler activities.
+ */
+@ChannelType
+public interface EventHandlerControl {
+
+ /**
+ * Finish up active events but stop processing any more.
+ */
+ void stop();
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/FaultData.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/FaultData.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/FaultData.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/FaultData.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.bpel.rtrep.v1.OBase;
+import org.apache.ode.bpel.rtrep.v1.OElementVarType;
+import org.apache.ode.bpel.rtrep.v1.OMessageVarType;
+import org.apache.ode.bpel.rtrep.v1.OVarType;
+import org.apache.ode.bpel.rapi.FaultInfo;
+import org.apache.ode.utils.SerializableElement;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+
+/**
+ * Information about a BPEL fault.
+ */
+public class FaultData implements Serializable, FaultInfo {
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the fault. */
+ private QName _faultName;
+
+ /** MessageType of the fault. */
+ private OVarType _faultVarType;
+
+ private SerializableElement _faultMsg;
+
+ private OBase _location;
+
+ private final String _explanation;
+
+ public FaultData(QName fault, OBase location, String explanation) {
+ _faultName = fault;
+ _location = location;
+ _explanation = explanation;
+ }
+
+ public FaultData(QName fault, Element faultMsg, OVarType faultVarType, OBase location) {
+ this(fault, location, null);
+ assert faultMsg != null;
+ assert faultVarType != null;
+ assert faultVarType instanceof OMessageVarType || faultVarType instanceof OElementVarType;
+ _faultMsg = new SerializableElement(faultMsg);
+ _faultVarType = faultVarType;
+ }
+
+ /**
+ * Return potential message associated with fault.
+ * Null if no fault data.
+ * @return fault message Element
+ */
+ public Element getFaultMessage() {
+ return (_faultMsg == null)
+ ? null
+ : _faultMsg.getElement();
+ }
+
+ /**
+ * The message type of the fault message data. Null if no fault data.
+ * @return fault type
+ */
+ public OVarType getFaultType(){
+ return _faultVarType;
+ }
+
+ /**
+ * Get the fault name.
+ *
+ * @return qualified fault name.
+ */
+ public QName getFaultName() {
+ return _faultName;
+ }
+
+ public int getFaultLineNo(){
+ return findLineNo(_location);
+ }
+
+ public String getExplanation() {
+ return _explanation;
+ }
+
+ public int getActivityId() {
+ return _location.getId();
+ }
+
+ /**
+ * Find the best line number for the given location.
+ * @param location
+ * @return line number
+ */
+ protected int findLineNo(OBase location) {
+ if (location == null)
+ return -1;
+ if (location.debugInfo == null)
+ return -1;
+ return location.debugInfo.startLine;
+ }
+
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString(){
+ StringBuilder sb = new StringBuilder("FaultData: [faultName=");
+ sb.append(_faultName);
+ sb.append(", faulType=");
+ sb.append(_faultVarType);
+ if (_explanation != null) {
+ sb.append(" (");
+ sb.append(_explanation);
+ sb.append(")");
+ }
+
+ sb.append("] @");
+ sb.append(findLineNo(_location));
+ return sb.toString();
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/InvokeResponse.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/InvokeResponse.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/InvokeResponse.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/InvokeResponse.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Response channel for pick requests.
+ */
+@ChannelType
+public interface InvokeResponse {
+
+ public void onResponse();
+
+ void onFault();
+
+ void onFailure();
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/LinkStatus.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/LinkStatus.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/LinkStatus.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/LinkStatus.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ */
+@ChannelType
+public interface LinkStatus {
+
+ void linkStatus(boolean value);
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ParentScope.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ParentScope.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ParentScope.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/ParentScope.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.SynchChannel;
+import org.apache.ode.bpel.rtrep.v1.CompensationHandler;
+import org.apache.ode.bpel.rtrep.v1.OScope;
+
+import org.w3c.dom.Element;
+import java.util.Set;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Channel used for child-to-parent scope communication.
+ */
+@ChannelType
+public interface ParentScope {
+
+ void compensate(OScope scope, SynchChannel ret);
+
+ void completed(FaultData faultData, Set<CompensationHandler> compensations);
+
+ void cancelled();
+
+ void failure(String reason, Element data);
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/PickResponse.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/PickResponse.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/PickResponse.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/PickResponse.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Response channel for pick requests.
+ * @jacob.kind
+ * @jacob.parent TimerResponseChannel
+ */
+@ChannelType
+public interface PickResponse extends TimerResponse {
+
+ public void onRequestRcvd(int selectorIdx, String mexId);
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Termination.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Termination.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Termination.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/Termination.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Channel used for parent-to-child scope communication.
+ */
+@ChannelType
+public interface Termination {
+
+ /**
+ * Stop processing immediately.
+ */
+ void terminate();
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/TimerResponse.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/TimerResponse.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/TimerResponse.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/channels/TimerResponse.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.channels;
+
+import org.apache.ode.jacob.ap.ChannelType;
+
+/**
+ * Channel for timer notification.
+ */
+@ChannelType
+public interface TimerResponse {
+ /** timer event has occurred */
+ public void onTimeout();
+
+ /** timer was cancelled. */
+ public void onCancel();
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/BpelDocumentNavigator.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/BpelDocumentNavigator.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/BpelDocumentNavigator.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/BpelDocumentNavigator.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.jaxen.dom.DocumentNavigator;
+import org.w3c.dom.Node;
+
+class BpelDocumentNavigator extends DocumentNavigator {
+
+ private static final long serialVersionUID = 6819182571668269841L;
+
+ private Node _documentRoot;
+
+ BpelDocumentNavigator(Node docRoot) {
+ _documentRoot = docRoot;
+ }
+
+ public Object getDocumentNode(Object contextNode) {
+ return _documentRoot;
+ }
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenContexts.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenContexts.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenContexts.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenContexts.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.rtrep.v1.*;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.xsd.XSTypes;
+import org.apache.ode.utils.xsl.XslTransformHandler;
+import org.jaxen.Context;
+import org.jaxen.Function;
+import org.jaxen.FunctionCallException;
+import org.jaxen.FunctionContext;
+import org.jaxen.UnresolvableException;
+import org.jaxen.VariableContext;
+import org.jaxen.XPathFunctionContext;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.saxon.dom.NodeWrapper;
+
+
+/**
+ * Implementation of the various JAXEN evaluation contexts in terms of the
+ * {@link EvaluationContext}.
+ */
+class JaxenContexts implements FunctionContext, VariableContext {
+ private static final Log __log = LogFactory.getLog(JaxenContexts.class);
+
+ /** Static, thread-safe singleton implementing default XPath functions */
+ private static final FunctionContext __defaultXPathFunctions = XPathFunctionContext.getInstance();
+
+ private OXPath10Expression _oxpath;
+ private EvaluationContext _xpathEvalCtx;
+ private Function _getVariableProperty;
+ private Function _getVariableData;
+ private Function _getLinkStatus;
+ private Function _doXslTransform;
+ private Map _extensionFunctions;
+
+ public JaxenContexts(OXPath10Expression oxpath,
+ Map extensionFunctions,
+ EvaluationContext xpathEvalCtx) {
+ _oxpath = oxpath;
+ _xpathEvalCtx = xpathEvalCtx;
+ _extensionFunctions = extensionFunctions;
+ _getVariableProperty = new BpelVariablePropertyFunction();
+ _getVariableData = new BpelVariableDataFunction();
+ _getLinkStatus = new GetLinkStatusFunction();
+ _doXslTransform = new DoXslTransformFunction();
+ }
+
+ /**
+ * @see org.jaxen.FunctionContext#getFunction(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ public Function getFunction(String namespaceURI, String prefix,
+ String localName)
+ throws UnresolvableException {
+ if (__log.isDebugEnabled()) {
+ __log.debug("getFunction(" + namespaceURI + "," + prefix + ","
+ + localName);
+ }
+
+ if ((namespaceURI != null)) {
+ QName fnQName = new QName(namespaceURI, localName);
+
+ if (fnQName.equals(_oxpath.qname_getVariableProperty))
+ return _getVariableProperty;
+ if (fnQName.equals(_oxpath.qname_getVariableData))
+ return _getVariableData;
+ if (fnQName.equals(_oxpath.qname_getLinkStatus))
+ return _getLinkStatus;
+ if (_oxpath instanceof OXPath10ExpressionBPEL20) {
+ OXPath10ExpressionBPEL20 oxpath20 = (OXPath10ExpressionBPEL20) _oxpath;
+ if (fnQName.equals(oxpath20.qname_doXslTransform)) {
+ return _doXslTransform;
+ }
+ }
+ Function f = (Function)_extensionFunctions.get(localName);
+
+ if (f != null) {
+ return f;
+ }
+ }
+
+ // Defer to the default XPath context.
+ return __defaultXPathFunctions.getFunction(null, prefix, localName);
+ }
+
+ /**
+ * @see org.jaxen.VariableContext#getVariableValue(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ public Object getVariableValue(String namespaceURI, String prefix,
+ String localName)
+ throws UnresolvableException {
+ if(!(_oxpath instanceof OXPath10ExpressionBPEL20)){
+ throw new IllegalStateException("XPath variables not supported for bpel 1.1");
+ }
+
+ // Custom variables
+ if ("ode".equals(prefix)) {
+ if ("pid".equals(localName)) {
+ return _xpathEvalCtx.getProcessId();
+ }
+ }
+
+ OXPath10ExpressionBPEL20 expr = (OXPath10ExpressionBPEL20)_oxpath;
+ if(expr.isJoinExpression){
+ OLink olink = _oxpath.links.get(localName);
+
+ try {
+ return _xpathEvalCtx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
+ } catch (FaultException e) {
+ throw new WrappedFaultException.JaxenUnresolvableException(e);
+ }
+ }else{
+ String varName;
+ String partName;
+ int dotloc = localName.indexOf('.');
+ if (dotloc == -1) {
+ varName = localName;
+ partName = null;
+ } else {
+ varName = localName.substring(0, dotloc);
+ partName = localName.substring(dotloc + 1);
+ }
+ OScope.Variable variable = _oxpath.vars.get(varName);
+ OMessageVarType.Part part = partName == null ? null : ((OMessageVarType)variable.type).parts.get(partName);
+
+ try{
+ Node variableNode = _xpathEvalCtx.readVariable(variable, part);
+ if (variableNode == null)
+ throw new WrappedFaultException.JaxenUnresolvableException(
+ new FaultException(variable.getOwner().constants.qnSelectionFailure,
+ "Unknown variable " + localName));
+ OVarType type = variable.type;
+ if (type instanceof OMessageVarType) {
+ OMessageVarType.Part typePart = ((OMessageVarType)type).parts.get(partName);
+ if (typePart == null) {
+ throw new WrappedFaultException.JaxenUnresolvableException(
+ new FaultException(variable.getOwner().constants.qnSelectionFailure,
+ "Unknown part " + partName + " for variable " + localName));
+ }
+ type = typePart.type;
+ }
+
+ if (_xpathEvalCtx.narrowTypes() && type instanceof OXsdTypeVarType && ((OXsdTypeVarType)type).simple) {
+ String text = variableNode.getTextContent();
+ try {
+ return XSTypes.toJavaObject(((OXsdTypeVarType)variable.type).xsdType,
+ text);
+ } catch (Exception e) { }
+ // Elegant way failed, trying brute force
+ try {
+ return Integer.valueOf(text);
+ } catch (NumberFormatException e) { }
+ try {
+ return Double.valueOf(text);
+ } catch (NumberFormatException e) { }
+ return text;
+ } else {
+ return variableNode;
+ }
+ }catch(FaultException e){
+ __log.error("bpws:getVariableValue threw FaultException", e);
+ throw new WrappedFaultException.JaxenUnresolvableException(e);
+ }
+ }
+ }
+
+ /**
+ * bpws:getVariableData()
+ */
+ class BpelVariableDataFunction implements Function {
+ public Object call(Context context, List args)
+ throws FunctionCallException {
+ if (__log.isDebugEnabled()) {
+ __log.debug("call(context=" + context + " args=" + args + ")");
+ }
+
+ String varname = (String) args.get(0);
+ String partname = args.size() > 1 ? (String) args.get(1) : null;
+ String xpathStr = args.size() > 2 ? (String)args.get(2) : null;
+
+ OXPath10Expression.OSigGetVariableData sig = _oxpath.resolveGetVariableDataSig(varname,partname,xpathStr);
+ if (sig == null) {
+ String msg = "InternalError: Attempt to use an unknown getVariableData signature: " + args;
+ if (__log.isFatalEnabled())
+ __log.fatal(msg);
+ throw new FunctionCallException(msg);
+ }
+
+ try {
+ Node ret = _xpathEvalCtx.readVariable(sig.variable, sig.part);
+ if (sig.location != null)
+ ret = _xpathEvalCtx.evaluateQuery(ret, sig.location);
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("bpws:getVariableData(" + args + ")' = " + ret);
+ }
+
+ return ret;
+ } catch (FaultException e) {
+ __log.error("bpws:getVariableData(" + args + ") threw FaultException", e);
+ throw new WrappedFaultException.JaxenFunctionException(e);
+ }
+ }
+ }
+
+ /**
+ * bpws:getVariableProperty()
+ */
+ class BpelVariablePropertyFunction implements Function {
+ public Object call(Context context, List args)
+ throws FunctionCallException {
+ if (args.size() != 2) {
+ throw new FunctionCallException("missing required arguments");
+ }
+
+ OScope.Variable var = _oxpath.vars.get(args.get(0));
+ OProcess.OProperty property = _oxpath.properties.get(args.get(1));
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("function call:'bpws:getVariableProperty(" + var + ","
+ + property + ")'");
+ }
+
+ try {
+ return _xpathEvalCtx.readMessageProperty(var, property);
+ } catch (FaultException e) {
+ __log.error("bpws:getVariableProperty(" + args + ") threw FaultException", e);
+ throw new WrappedFaultException.JaxenFunctionException(e);
+ }
+ }
+ }
+
+ class GetLinkStatusFunction implements Function {
+ public Object call(Context context, List args)
+ throws FunctionCallException {
+ assert args.size() == 1;
+
+ OLink olink = _oxpath.links.get(args.get(0));
+
+ try {
+ return _xpathEvalCtx.isLinkActive(olink) ? Boolean.TRUE : Boolean.FALSE;
+ } catch (FaultException e) {
+ __log.error("bpws:getLinkStatus(" + args + ") threw FaultException", e);
+ throw new WrappedFaultException.JaxenFunctionException(e);
+ }
+ }
+ }
+
+ class DoXslTransformFunction implements Function {
+ public Object call(Context context, List args) throws FunctionCallException {
+ assert args.size() >= 2;
+ assert args.size() % 2 == 0;
+ if (__log.isDebugEnabled()) {
+ __log.debug("call(context=" + context + " args=" + args + ")");
+ }
+ if(!(_oxpath instanceof OXPath10ExpressionBPEL20)) {
+ throw new IllegalStateException("XPath function bpws:doXslTransform not supported in " +
+ "BPEL 1.1!");
+ }
+
+ Element varElmt;
+ try {
+ if (args.get(1) instanceof List) {
+ List elmts = (List)args.get(1);
+ if (elmts.size() != 1) throw new WrappedFaultException.JaxenFunctionException(
+ new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
+ "Second parameter of the bpws:doXslTransform function MUST point to a single " +
+ "element node."));
+ varElmt = (Element) elmts.get(0);
+ } else {
+ if (args.get(1) instanceof NodeWrapper)
+ varElmt = (Element) ((NodeWrapper)args.get(1)).getUnderlyingNode();
+ else varElmt = (Element) args.get(1);
+
+// varElmt = (Element) args.get(1);
+ }
+ } catch (ClassCastException e) {
+ throw new WrappedFaultException.JaxenFunctionException(
+ new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
+ "Second parameter of the bpws:doXslTransform function MUST point to a single " +
+ "element node."));
+ }
+
+ URI xslUri;
+ try {
+ xslUri = new URI((String) args.get(0));
+ } catch (URISyntaxException use) {
+ // Shouldn't happen, checked at compilation time
+ throw new FunctionCallException("First parameter of the bpws:doXslTransform isn't a valid URI!", use);
+ }
+ OXslSheet xslSheet = _oxpath.xslSheets.get(xslUri);
+ // Shouldn't happen, checked at compilation time
+ if (xslSheet == null) throw new FunctionCallException("Couldn't find the XSL sheet " + args.get(0)
+ + ", process compilation or deployment was probably incomplete!");
+
+ if (!(varElmt instanceof Element)) {
+ throw new WrappedFaultException.JaxenFunctionException(
+ new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
+ "Second parameter of the bpws:doXslTransform function MUST point to a single " +
+ "element node."));
+ }
+
+ HashMap<QName, Object> parametersMap = null;
+ if (args.size() > 2) {
+ parametersMap = new HashMap<QName, Object>();
+ for (int idx = 2; idx < args.size(); idx+=2) {
+ QName keyQName = _oxpath.namespaceCtx.derefQName((String) args.get(idx));
+ parametersMap.put(keyQName, args.get(idx + 1));
+ }
+ }
+
+ Document varDoc = DOMUtils.newDocument();
+ varDoc.appendChild(varDoc.importNode(varElmt, true));
+
+ DOMSource source = new DOMSource(varDoc);
+ // Using a StreamResult as a DOMResult doesn't behaves properly when the result
+ // of the transformation is just a string.
+ StringWriter writerResult = new StringWriter();
+ StreamResult result = new StreamResult(writerResult);
+ XslRuntimeUriResolver resolver = new XslRuntimeUriResolver(_oxpath, _xpathEvalCtx.getBaseResourceURI());
+ XslTransformHandler.getInstance().cacheXSLSheet(xslUri, xslSheet.sheetBody, resolver);
+ try {
+ XslTransformHandler.getInstance().transform(xslUri, source, result, parametersMap, resolver);
+ } catch (Exception e) {
+ throw new WrappedFaultException.JaxenFunctionException(
+ new FaultException(_oxpath.getOwner().constants.qnSubLanguageExecutionFault,
+ e.toString()));
+ }
+ writerResult.flush();
+
+ String output = writerResult.toString();
+ // I'm not really proud of that but hey, it does the job and I don't think there's
+ // any other easy way.
+ if (output.startsWith("<?xml")) {
+ try {
+ return DOMUtils.stringToDOM(writerResult.toString());
+ } catch (SAXException e) {
+ throw new FunctionCallException(e);
+ } catch (IOException e) {
+ throw new FunctionCallException(e);
+ }
+ } else {
+ return output;
+ }
+ }
+ }
+
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenNamespaceContextAdapter.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenNamespaceContextAdapter.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenNamespaceContextAdapter.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/JaxenNamespaceContextAdapter.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jaxen.NamespaceContext;
+
+/**
+ * Class adapting the {@link javax.xml.namespace.NamespaceContext} interface to the
+ * JAXEN {@link NamespaceContext} interface.
+ * @pattern Adapter
+ */
+class JaxenNamespaceContextAdapter implements NamespaceContext {
+ private static final Log __log = LogFactory.getLog(JaxenNamespaceContextAdapter.class);
+
+ private javax.xml.namespace.NamespaceContext _namespaceContext;
+
+ JaxenNamespaceContextAdapter(javax.xml.namespace.NamespaceContext ctx) {
+ _namespaceContext = ctx;
+ }
+
+ public String translateNamespacePrefixToUri(String prefix) {
+ String namespaceURI = _namespaceContext.getNamespaceURI(prefix);
+ if (__log.isDebugEnabled()) {
+ __log.debug("translateNamespacePrefixToUri(" + prefix + ")=" + namespaceURI);
+ }
+ return namespaceURI;
+ }
+}
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10Expression.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10Expression.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10Expression.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10Expression.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.apache.ode.bpel.rtrep.v1.OBase;
+import org.apache.ode.bpel.rtrep.v1.OExpression;
+import org.apache.ode.bpel.rtrep.v1.OLValueExpression;
+import org.apache.ode.bpel.rtrep.v1.OLink;
+import org.apache.ode.bpel.rtrep.v1.OMessageVarType;
+import org.apache.ode.bpel.rtrep.v1.OProcess;
+import org.apache.ode.bpel.rtrep.v1.OScope;
+import org.apache.ode.bpel.rtrep.v1.OScope.Variable;
+import org.apache.ode.bpel.rtrep.v1.OXslSheet;
+import org.apache.ode.utils.NSContext;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.HashMap;
+
+
+/**
+ * Jaxen-based compiled-xpath representation for XPATH 1.0 expression language.
+ */
+public class OXPath10Expression extends OLValueExpression implements Serializable {
+ private static final long serialVersionUID = -1L;
+
+ /** Map from query name to variable declaration. */
+ public HashMap<String, OScope.Variable> vars =
+ new HashMap<String, OScope.Variable>();
+
+ public final HashMap<String, OProcess.OProperty> properties =
+ new HashMap<String, OProcess.OProperty>();
+
+ public final HashMap<String, OLink> links = new HashMap<String,OLink>();
+
+ public final HashMap<URI,OXslSheet> xslSheets = new HashMap<URI, OXslSheet>();
+
+ /** Map getVariableData invocation signature to compiled objects. */
+ private final HashMap<SigGetVariableData,OSigGetVariableData> _getVariableDataSigs =
+ new HashMap<SigGetVariableData,OSigGetVariableData>();
+
+ public String xpath;
+ public NSContext namespaceCtx;
+
+ /** QName of the <code>bpws:getVariableData</code> function. */
+ public final QName qname_getVariableData;
+
+ /** QName of the <code>bpws:getVariableData</code> function. */
+ public final QName qname_getVariableProperty;
+
+ /** QName of the <code>bpws:getVariableData</code> function. */
+ public final QName qname_getLinkStatus;
+
+
+ public OXPath10Expression(OProcess owner,
+ QName qname_getVariableData,
+ QName qname_getVariableProperty,
+ QName qname_getLinkStatus) {
+ super(owner);
+ this.qname_getLinkStatus = qname_getLinkStatus;
+ this.qname_getVariableData = qname_getVariableData;
+ this.qname_getVariableProperty = qname_getVariableProperty;
+ }
+
+ /**
+ * Get the compiled representation of a certain <code>bpws:getVariableData(...)</code> call.
+ * @param varname variable name
+ * @param partname part name
+ * @param location location query
+ * @return compiled representation, or <code>null</code> if none found
+ */
+ public OSigGetVariableData resolveGetVariableDataSig(String varname, String partname, String location) {
+ SigGetVariableData key = new SigGetVariableData(varname, partname, location);
+ return _getVariableDataSigs.get(key);
+ }
+
+ /**
+ * Add a compiled representation for a certain <code>bpws:getVariableData(...)</code> call.
+ * @param varname variable name
+ * @param partname part name
+ * @param location location query
+ * @param compiled compiled representation
+ */
+ public void addGetVariableDataSig(String varname, String partname, String location, OSigGetVariableData compiled) {
+ _getVariableDataSigs.put(new SigGetVariableData(varname, partname, location), compiled);
+ }
+
+ public String toString() {
+ return "{OXPath10Expression " + xpath + "}";
+ }
+
+ /**
+ * Data structure representing the signature of a <code>bpws:getVariableData</code>
+ * invocation.
+ */
+ private static final class SigGetVariableData implements Serializable {
+ private static final long serialVersionUID = -1L;
+
+ private final String varname;
+ private final String partname;
+ private final String location;
+
+ private SigGetVariableData(String varname, String partname, String location) {
+ this.varname = varname;
+ this.partname = partname;
+ this.location = location;
+ }
+
+ public boolean equals(Object obj) {
+ SigGetVariableData other = (SigGetVariableData) obj;
+ if (varname != null && (other.varname == null || !varname.equals(other.varname)))
+ return false;
+ if (partname != null && (other.partname == null || !partname.equals(other.partname)))
+ return false;
+ if (location != null && (other.location == null || !location.equals(other.location)))
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int hashCode = 0;
+ if (varname != null) hashCode ^= varname.hashCode();
+ if (partname != null) hashCode ^= partname.hashCode();
+ if (location != null) hashCode ^= location.hashCode();
+ return hashCode;
+ }
+ }
+
+ /**
+ * Data structure representing the compiled signature of a <code>bpws:getVariableData</code>
+ * invocation.
+ */
+ public static final class OSigGetVariableData extends OBase {
+ private static final long serialVersionUID = -1L;
+ public final OScope.Variable variable;
+ public final OMessageVarType.Part part;
+ public final OExpression location;
+
+ public OSigGetVariableData(OProcess owner, OScope.Variable variable, OMessageVarType.Part part, OExpression location) {
+ super(owner);
+ this.variable = variable;
+ this.part = part;
+ this.location = location;
+ }
+ }
+
+ /**
+ * @see org.apache.ode.bpel.rtrep.v1.OLValueExpression#getVariable()
+ */
+ public Variable getVariable() {
+ if(vars.size() == 0)
+ throw new IllegalStateException("LValue must have one variable reference.");
+ // We're interested in the first variable referenced by the LValue
+ for (String varName : vars.keySet()) {
+ if (xpath.substring(1, xpath.length()).startsWith(varName))
+ return vars.get(varName);
+ }
+ throw new IllegalStateException("Either the expression doesn't start with a variable reference or " +
+ "the reference is unknow.");
+ }
+
+}
+
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10ExpressionBPEL20.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10ExpressionBPEL20.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10ExpressionBPEL20.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/OXPath10ExpressionBPEL20.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.apache.ode.bpel.rtrep.v1.OProcess;
+
+import java.io.Serializable;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Jaxen-based compiled-xpath representation for XPATH 1.0 expression language.
+ */
+public class OXPath10ExpressionBPEL20 extends OXPath10Expression
+ implements Serializable {
+ private static final long serialVersionUID = -1L;
+
+ /** QName of the <code>bpws:getVariableData</code> function. */
+ public final QName qname_doXslTransform;
+
+ /** Flags this expression as a joinCondition */
+ public final boolean isJoinExpression;
+
+ public OXPath10ExpressionBPEL20(OProcess owner,
+ QName qname_getVariableData,
+ QName qname_getVariableProperty,
+ QName qname_getLinkStatus,
+ QName qname_doXslTransform,
+ boolean isJoinExpression) {
+ super(owner, qname_getVariableData, qname_getVariableProperty, qname_getLinkStatus);
+ this.qname_doXslTransform = qname_doXslTransform;
+ this.isJoinExpression = isJoinExpression;
+ }
+
+ public String toString() {
+ return "{OXPath10Expression " + xpath + "}";
+ }
+}
+
Added: ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/WrappedFaultException.java
URL: http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/WrappedFaultException.java?rev=693931&view=auto
==============================================================================
--- ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/WrappedFaultException.java (added)
+++ ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v1/xpath10/WrappedFaultException.java Wed Sep 10 12:06:59 2008
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bpel.rtrep.v1.xpath10;
+
+import org.apache.ode.bpel.common.FaultException;
+
+import org.jaxen.FunctionCallException;
+import org.jaxen.UnresolvableException;
+
+/**
+ * Wrap a fault in a jaxen exception
+ */
+public interface WrappedFaultException {
+ public FaultException getFaultException();
+
+ /**
+ * Jaxenized {@link FaultException}; Jaxen requires us to throw only exceptions
+ * extending its {@link UnresolvableVariableException} so we comply.
+ */
+ static class JaxenUnresolvableException extends UnresolvableException implements WrappedFaultException{
+ private static final long serialVersionUID = 6266231885976155458L;
+
+ FaultException _cause;
+ public JaxenUnresolvableException(FaultException e) {
+ super("var");
+ assert e != null;
+ _cause = e;
+ }
+
+ public FaultException getFaultException() {
+ return _cause;
+ }
+ }
+
+ /**
+ * Jaxenized {@link FaultException}; Jaxen requires us to throw only exceptions
+ * extending its {@link FunctionCallException} so we comply.
+ */
+ static class JaxenFunctionException extends FunctionCallException implements WrappedFaultException{
+ private static final long serialVersionUID = -1915683768194623625L;
+ FaultException _cause;
+
+ public JaxenFunctionException(FaultException e) {
+ super(e);
+ assert e != null;
+ _cause = e;
+ }
+
+ public FaultException getFaultException() {
+ return _cause;
+ }
+ }
+}