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/11/27 03:02:32 UTC
svn commit: r721068 - in /ode/sandbox/simpel/src:
main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
main/java/org/apache/ode/simpel/omodel/OBuilder.java
test/java/org/apache/ode/simpel/SimPELRuntimeTest.java
Author: mriou
Date: Wed Nov 26 18:02:32 2008
New Revision: 721068
URL: http://svn.apache.org/viewvc?rev=721068&view=rev
Log:
Single line receives (instead of block style): foo = receive(...)
Modified:
ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELRuntimeTest.java
Modified: ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g?rev=721068&r1=721067&r2=721068&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g (original)
+++ ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g Wed Nov 26 18:02:32 2008
@@ -218,8 +218,10 @@
receive
scope ReceiveBlock;
: ^(RECEIVE ^(p=ID o=ID? correlation?) {
+ // The receive input is the lvalue of the assignment expression in which this receive is enclosed (if it is)
OBuilder.StructuredActivity<OPickReceive> rec = builder.build(OPickReceive.class, $BPELScope::oscope,
- $Parent::activity, text($p), text($o));
+ $Parent::activity, text($p), text($o), $ExprContext::expr);
+
$ReceiveBlock::activity = rec.getOActivity();
// TODO support for multiple "correlations"
if ($correlation.corr != null) builder.addCorrelationMatch($ReceiveBlock::activity, $correlation.corr);
@@ -236,7 +238,7 @@
}
rv=(rvalue)) {
$ExprContext::expr.setExpr(deepText($rv));
- if (!"RESOURCE".equals($rv.getText())) {
+ if (!"RESOURCE".equals($rv.getText()) && !"RECEIVE".equals($rv.getText())) {
OBuilder.StructuredActivity<OAssign> assign =
builder.build(OAssign.class, $BPELScope::oscope, $Parent::activity, $ExprContext::expr);
// The long, winding road of abstraction
Modified: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java?rev=721068&r1=721067&r2=721068&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java (original)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java Wed Nov 26 18:02:32 2008
@@ -161,7 +161,8 @@
};
}
- public SimpleActivity buildPickReceive(OPickReceive receive, OScope oscope, String partnerLinkOrResource, String operation) {
+ public SimpleActivity buildPickReceive(OPickReceive receive, OScope oscope, String partnerLinkOrResource,
+ String operation, SimPELExpr expr) {
OPickReceive.OnMessage onMessage = new OPickReceive.OnMessage(_oprocess);
if (operation == null) {
onMessage.resource = webResources.get(partnerLinkOrResource);
@@ -181,6 +182,12 @@
if (onMessage.resource != null) onMessage.resource.setInstantiateResource(true);
}
+ // Is this receive part of an assignment? In this case the input var is the lvalue.
+ if (expr != null) {
+ onMessage.variable = resolveVariable(oscope, expr.getLValue(),
+ onMessage.operation != null ? onMessage.operation.getName() : null, true);
+ }
+
onMessage.activity = new OEmpty(_oprocess, receive);
receive.onMessages.add(onMessage);
Modified: ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELRuntimeTest.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELRuntimeTest.java?rev=721068&r1=721067&r2=721068&view=diff
==============================================================================
--- ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELRuntimeTest.java (original)
+++ ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELRuntimeTest.java Wed Nov 26 18:02:32 2008
@@ -289,4 +289,23 @@
assertTrue(DOMUtils.domToString(result).indexOf("Hello") > 0);
}
+ private static final String RECEIVE_ASSIGN =
+ "process ReceiveAssign {\n" +
+ " msgIn = receive(myPl, helloOp); \n" +
+ " msgOut = msgIn + \" World\";\n" +
+ " reply(msgOut, myPl, helloOp);\n" +
+ "}";
+
+ public void testReceiveAssign() throws Exception {
+ server.start();
+ server.deploy(RECEIVE_ASSIGN);
+
+ Document doc = DOMUtils.newDocument();
+ Element wrapper = doc.createElementNS("http://ode.apache.org/simpel/1.0/definition/ReceiveAssign", "helloOpRequest");
+ wrapper.setTextContent("Hello");
+
+ Element result = server.sendMessage("myPl", "helloOp", wrapper);
+ assertTrue(DOMUtils.domToString(result).indexOf("Hello World") > 0);
+ }
+
}