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/04/09 21:46:41 UTC
svn commit: r526890 - in
/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler:
AssignGenerator.java bom/ToFrom.java
Author: mszefler
Date: Mon Apr 9 12:46:39 2007
New Revision: 526890
URL: http://svn.apache.org/viewvc?view=rev&rev=526890
Log:
Compiler support for DirectRef assignment.
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ToFrom.java
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java?view=diff&rev=526890&r1=526889&r2=526890
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/AssignGenerator.java Mon Apr 9 12:46:39 2007
@@ -24,6 +24,7 @@
import org.apache.ode.bpel.compiler.bom.Activity;
import org.apache.ode.bpel.compiler.bom.AssignActivity;
import org.apache.ode.bpel.compiler.bom.Copy;
+import org.apache.ode.bpel.compiler.bom.ExtensionVal;
import org.apache.ode.bpel.compiler.bom.From;
import org.apache.ode.bpel.compiler.bom.LiteralVal;
import org.apache.ode.bpel.compiler.bom.PartnerLinkVal;
@@ -35,6 +36,7 @@
import org.apache.ode.bpel.o.OActivity;
import org.apache.ode.bpel.o.OAssign;
import org.apache.ode.bpel.o.OMessageVarType;
+import org.apache.ode.bpel.o.OAssign.RValue;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.msg.MessageBundle;
import org.w3c.dom.Document;
@@ -43,9 +45,9 @@
import javax.xml.namespace.QName;
/**
- * Generates code for <code><assign></code> activities. This class
- * simply extends {@link DefaultActivityGenerator} as the default implentation
- * suffices.
+ * Generates code for <code><assign></code> activities.
+ *
+ * @author Maciej Szefler ( m s z e f l e r @ g m a i l . c o m )
*/
class AssignGenerator extends DefaultActivityGenerator {
private static final Log __log = LogFactory.getLog(AssignGenerator.class);
@@ -149,7 +151,9 @@
private OAssign.RValue compileFrom(From from) {
assert from != null;
try {
- if (from.isLiteralVal()) {
+ if (from.isExtensionVal()) {
+ return compileExtensionVal(from.getAsExtensionVal());
+ } else if (from.isLiteralVal()) {
return compileLiteral(from.getAsLiteralVal());
} else if (from.isPropertyVal()) {
OAssign.PropertyRef pref = new OAssign.PropertyRef(_context.getOProcess());
@@ -187,6 +191,20 @@
ce.getCompilationMessage().source = from;
throw ce;
}
+ }
+
+ /**
+ * Compile an extension to/from-spec. Extension to/from-specs are compiled into
+ * "DirectRef"s.
+ *
+ * @param extVal source representation
+ * @return compiled representation
+ */
+ private RValue compileExtensionVal(ExtensionVal extVal) {
+ OAssign.DirectRef dref = new OAssign.DirectRef(_context.getOProcess());
+ dref.variable = _context.resolveVariable(extVal.getVariable());
+ dref.elName = extVal.getExtension();
+ return dref;
}
private OAssign.RValue compileLiteral(LiteralVal from) {
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ToFrom.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ToFrom.java?view=diff&rev=526890&r1=526889&r2=526890
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ToFrom.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ToFrom.java Mon Apr 9 12:46:39 2007
@@ -33,6 +33,29 @@
return null;
}
+ /**
+ * Cast this tofrom to an "extension" to/from. This is NOT part of the BPEL spec, and
+ * is used to provide access to custom extensions (for example reading/writing SOAP
+ * message headers)... Yes. it's evil.
+ *
+ * @author mszefler
+ * @return the object cast to {@link ExtensionVal} if appropriate, null otherwise.
+ */
+ public ExtensionVal getAsExtensionVal() {
+ if (getAttribute("extension",null) != null)
+ return new ExtensionVal(getElement());
+ return null;
+ }
+
+ /**
+ * Test whether this to/from is an "extension" to-from (i.e. does it have the "extension"
+ * attribute).
+ * @return
+ */
+ public boolean isExtensionVal() {
+ return getAsExtensionVal() != null;
+ }
+
public boolean isVariableVal() {
return getAsVariableVal() != null;
}