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 2006/12/21 02:55:46 UTC

svn commit: r489244 - in /incubator/ode/trunk/bpel-compiler/src/main/java: ./ org/apache/ode/bpel/compiler/ org/apache/ode/bpel/compiler/bom/

Author: mszefler
Date: Wed Dec 20 17:55:45 2006
New Revision: 489244

URL: http://svn.apache.org/viewvc?view=rev&rev=489244
Log:
Fixed BPEL1.1 <switch> actiivty which diseappeared in the BOM refactor.

Added:
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java   (with props)
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java   (with props)
Removed:
    incubator/ode/trunk/bpel-compiler/src/main/java/Foo.java
Modified:
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/BpelObjectFactory.java

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java?view=diff&rev=489244&r1=489243&r2=489244
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler11.java Wed Dec 20 17:55:45 2006
@@ -29,6 +29,7 @@
 import org.apache.ode.bpel.compiler.bom.ReceiveActivity;
 import org.apache.ode.bpel.compiler.bom.ReplyActivity;
 import org.apache.ode.bpel.compiler.bom.SequenceActivity;
+import org.apache.ode.bpel.compiler.bom.SwitchActivity;
 import org.apache.ode.bpel.compiler.bom.TerminateActivity;
 import org.apache.ode.bpel.compiler.bom.ThrowActivity;
 import org.apache.ode.bpel.compiler.bom.WaitActivity;
@@ -54,7 +55,7 @@
         registerActivityCompiler(AssignActivity.class, new AssignGenerator());
         registerActivityCompiler(ThrowActivity.class, new ThrowGenerator());
         registerActivityCompiler(WhileActivity.class, new WhileGenerator());
-        registerActivityCompiler(IfActivity.class, new IfGenerator());
+        registerActivityCompiler(SwitchActivity.class, new SwitchGenerator());
         registerActivityCompiler(PickActivity.class, new PickGenerator());
         registerActivityCompiler(ReplyActivity.class, new ReplyGenerator());
         registerActivityCompiler(ReceiveActivity.class, new ReceiveGenerator());

Added: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java?view=auto&rev=489244
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java (added)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java Wed Dec 20 17:55:45 2006
@@ -0,0 +1,29 @@
+package org.apache.ode.bpel.compiler;
+
+import org.apache.ode.bpel.compiler.bom.Activity;
+import org.apache.ode.bpel.compiler.bom.SwitchActivity;
+import org.apache.ode.bpel.o.OActivity;
+import org.apache.ode.bpel.o.OSwitch;
+
+/**
+ * Generator for legacy BPEL 1.1 <code>&lt;switch&gt;</code> actiivty.
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
+public class SwitchGenerator extends DefaultActivityGenerator {
+  public OActivity newInstance(Activity src) {
+        return new OSwitch(_context.getOProcess(), _context.getCurrent());
+  }
+
+  public void compile(OActivity output, Activity src) {
+    OSwitch oswitch = (OSwitch) output;
+    SwitchActivity switchDef = (SwitchActivity)src;
+
+    for (SwitchActivity.Case ccase : switchDef.getCases()) {
+      OSwitch.OCase ocase = new OSwitch.OCase(_context.getOProcess());
+      ocase.activity = _context.compile(ccase.getActivity());
+      ocase.expression = (ccase.getCondition() == null ? _context.constantExpr(true) : _context.compileExpr(ccase.getCondition()));
+      oswitch.addCase(ocase);
+    }
+  }
+}
\ No newline at end of file

Propchange: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/SwitchGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=489244&r1=489243&r2=489244
==============================================================================
--- 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 Wed Dec 20 17:55:45 2006
@@ -137,7 +137,7 @@
         _mappings.put(Bpel11QNames.COMPENSATE, CompensateActivity.class);
         _mappings.put(Bpel11QNames.TERMINATE, TerminateActivity.class);
         _mappings.put(Bpel11QNames.FLOW, FlowActivity.class);
-        _mappings.put(Bpel11QNames.SWITCH, IfActivity.class);
+        _mappings.put(Bpel11QNames.SWITCH, SwitchActivity.class);
         _mappings.put(Bpel11QNames.WHILE, WhileActivity11.class);
         _mappings.put(Bpel11QNames.SEQUENCE, SequenceActivity.class);
         _mappings.put(Bpel11QNames.PICK, PickActivity.class);
@@ -152,7 +152,8 @@
         _mappings.put(Bpel11QNames.COMPENSATE, CompensateActivity.class);
         _mappings.put(Bpel11QNames.COMPENSATIONHANDLER, CompensationHandler.class);
         _mappings.put(Bpel11QNames.FAULTHANDLERS, FaultHandler.class);
-        _mappings.put(Bpel11QNames.CASE, IfActivity.Case.class);
+        _mappings.put(Bpel11QNames.CASE, SwitchActivity.Case.class);
+        _mappings.put(Bpel11QNames.OTHERWISE, SwitchActivity.Case.class);
         _mappings.put(Bpel11QNames.ONALARM, OnAlarm.class);
         _mappings.put(Bpel11QNames.ONMESSAGE, OnMessage.class);
         _mappings.put(Bpel11QNames.PLINKTYPE, PartnerLinkType.class);

Added: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java?view=auto&rev=489244
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java (added)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java Wed Dec 20 17:55:45 2006
@@ -0,0 +1,61 @@
+package org.apache.ode.bpel.compiler.bom;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+/**
+ * Legacy (BPEL 1.1) representation of a <code>&lt;switch&gt;</code> activity.
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
+ */
+public class SwitchActivity extends Activity {
+
+    public SwitchActivity(Element el) {
+        super(el);
+    }
+
+    /**
+     * Get the cases for this switch.
+     * 
+     * @return the cases
+     */
+    public List<Case> getCases() {
+        return getChildren(Case.class);
+    }
+
+    /**
+     * BPEL object model representation of <code>&lt;case&gt;</code> and 
+     * <code>&lt;otherwise&gt;</code> elements. Note that the 
+     * <code>&lt;otherwise&gt;</code> elements simply return null for
+     * the {@link #getCondition()}.
+     */
+    public static class Case extends BpelObject {
+
+        public Case(Element el) {
+            super(el);
+        }
+
+        /**
+         * Get the activity for this case.
+         * 
+         * @return activity enabled when case is satisfied
+         */
+        public Activity getActivity() {
+            return getFirstChild(Activity.class);
+        }
+
+        /**
+         * Get the condition associated with this case.
+         * 
+         * @return the condition
+         */
+        public Expression getCondition() {
+            return isAttributeSet("condition") 
+                ? new Expression11(getElement(),getElement().getAttributeNode("condition")) 
+                    : null;
+        }
+
+    }
+    
+}

Propchange: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/SwitchActivity.java
------------------------------------------------------------------------------
    svn:eol-style = native