You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/03/22 20:51:51 UTC

svn commit: r521423 - in /incubator/ode/trunk: bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ bpel-obj/src/main/java/org/apache/ode/bpel/o/ bpel-runtime/src/main/java/org/apache/o...

Author: mszefler
Date: Thu Mar 22 12:51:50 2007
New Revision: 521423

URL: http://svn.apache.org/viewvc?view=rev&rev=521423
Log:
Added repeatUntil activity

Added:
    incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORepeatUntil.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPEATUNTIL.java
Modified:
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Bpel20QNames.java
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ActivityTemplateFactory.java

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java?view=diff&rev=521423&r1=521422&r2=521423
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler20.java Thu Mar 22 12:51:50 2007
@@ -41,6 +41,7 @@
         registerActivityCompiler(AssignActivity.class, new AssignGenerator());
         registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
         registerActivityCompiler(WhileActivity.class, new WhileGenerator());
+        registerActivityCompiler(RepeatUntilActivity.class, new RepeatUntilGenerator());
         registerActivityCompiler(IfActivity.class, new IfGenerator());
         registerActivityCompiler(PickActivity.class, new PickGenerator());
         registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Bpel20QNames.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Bpel20QNames.java?view=diff&rev=521423&r1=521422&r2=521423
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Bpel20QNames.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Bpel20QNames.java Thu Mar 22 12:51:50 2007
@@ -153,6 +153,9 @@
     public static final QName FOREACH = newQName("forEach");
 
     public static final QName ITERATOR = newQName("iterator");
+    
+    public static final QName REPEATUNTIL = newQName("repeatUntil");
+
 
     public static final QName START_COUNTER_VALUE = newQName("startCounterValue");
 
@@ -174,7 +177,8 @@
     
     /** Not part of BPEL, but handy to have. */
     public static final QName RDF_LABEL = new QName(NS_RDF, "label");
-    
+
+        
 
     private static QName newQName(String localname) {
         return new QName(NS_WSBPEL2_0, localname);

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java?view=diff&rev=521423&r1=521422&r2=521423
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java Thu Mar 22 12:51:50 2007
@@ -69,6 +69,7 @@
         _mappings.put(Bpel20QNames.SWITCH, IfActivity.class);
         _mappings.put(Bpel20QNames.IF, IfActivity.class);
         _mappings.put(Bpel20QNames.WHILE, WhileActivity.class);
+        _mappings.put(Bpel20QNames.REPEATUNTIL,RepeatUntilActivity.class);
         _mappings.put(Bpel20QNames.SEQUENCE, SequenceActivity.class);
         _mappings.put(Bpel20QNames.PICK, PickActivity.class);
         _mappings.put(Bpel20QNames.SCOPE, ScopeActivity.class);

Added: incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORepeatUntil.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORepeatUntil.java?view=auto&rev=521423
==============================================================================
--- incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORepeatUntil.java (added)
+++ incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/ORepeatUntil.java Thu Mar 22 12:51:50 2007
@@ -0,0 +1,22 @@
+package org.apache.ode.bpel.o;
+
+
+/**
+ * Compiled representation of a <code>&lt;repeatUntil&gt;</code> activity.
+ * 
+ * @author Maciej Szefler ( m s z e f l e r @ g m a i l . c o m )
+ */
+public class ORepeatUntil extends OActivity {
+
+    static final long serialVersionUID = -1L  ;
+    
+    /** The repeat until condition. */
+    public OExpression untilCondition;
+
+    public OActivity activity;
+
+    public ORepeatUntil(OProcess owner, OActivity parent) {
+        super(owner, parent);
+    }
+}
+

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ActivityTemplateFactory.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ActivityTemplateFactory.java?view=diff&rev=521423&r1=521422&r2=521423
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ActivityTemplateFactory.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ActivityTemplateFactory.java Thu Mar 22 12:51:50 2007
@@ -42,6 +42,7 @@
     if (type instanceof OWait) return new WAIT(ai, scopeFrame, linkFrame);
     if (type instanceof OWhile) return new WHILE(ai, scopeFrame, linkFrame);
     if (type instanceof OForEach) return new FOREACH(ai, scopeFrame, linkFrame);
+    if (type instancoef ORepeatUntil) return new REPEATUNTIL(ai,scopeFrame,linkFrame);
 
     throw new IllegalArgumentException("Unknown type: " + type);
   }

Added: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPEATUNTIL.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPEATUNTIL.java?view=auto&rev=521423
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPEATUNTIL.java (added)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPEATUNTIL.java Thu Mar 22 12:51:50 2007
@@ -0,0 +1,124 @@
+package org.apache.ode.bpel.runtime;
+
+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.explang.EvaluationException;
+import org.apache.ode.bpel.o.ORepeatUntil;
+import org.apache.ode.bpel.o.OScope;
+import org.apache.ode.bpel.runtime.channels.FaultData;
+import org.apache.ode.bpel.runtime.channels.ParentScopeChannel;
+import org.apache.ode.bpel.runtime.channels.ParentScopeChannelListener;
+import org.apache.ode.bpel.runtime.channels.TerminationChannel;
+import org.apache.ode.bpel.runtime.channels.TerminationChannelListener;
+import org.apache.ode.jacob.SynchChannel;
+import org.w3c.dom.Element;
+
+public class REPEATUNTIL 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 REPEATUNTIL(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+        super(self, scopeFrame, linkFrame);
+    }
+
+    public void run() {
+        ActivityInfo child = new ActivityInfo(genMonotonic(),
+                getORepeatUntil().activity,
+                newChannel(TerminationChannel.class), newChannel(ParentScopeChannel.class));
+        instance(createChild(child, _scopeFrame, _linkFrame));  
+        instance(new WAITER(child));
+    }
+
+    /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
+    public String toString() {
+        return "<T:Act:RepeatUntil:" + _self.o + ">";
+    }
+
+    protected Log log() {
+        return __log;
+    }
+
+    private ORepeatUntil getORepeatUntil() {
+        return (ORepeatUntil)_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 {
+        try {
+            return getBpelRuntimeContext().getExpLangRuntime().evaluateAsBoolean(getORepeatUntil().untilCondition,getEvaluationContext());
+        } catch (EvaluationException e) {
+            String msg = "Unexpected expression evaluation error checking repeatUntil condition.";
+            __log.error(msg, e);
+            throw new InvalidProcessException(msg,e);
+        }
+    }
+
+    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, _compHandlers);
+                    else {
+
+                        boolean condResult = false;
+
+                        try {
+                            condResult = checkCondition();
+                        } catch (FaultException fe) {
+                            __log.error(fe);
+                            _self.parent.completed(createFault(fe.getQName(), _self.o),_compHandlers);
+                            return;
+                        }
+                        if (!condResult)
+                            instance(REPEATUNTIL.this);
+                        else
+                            _self.parent.completed(null,_compHandlers);
+                    }
+                }
+
+                public void cancelled() { completed(null, CompensationHandler.emptySet()); }
+                public void failure(String reason, Element data) { completed(null, CompensationHandler.emptySet()); }
+            }));
+        }
+    }
+
+}