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/02/16 01:18:00 UTC
svn commit: r628212 - in /ode/sandbox/simpel: ./
src/main/antlr/org/apache/ode/simpel/antlr/ src/main/java/org/apache/ode/
src/main/java/org/apache/ode/embed/ src/main/java/org/apache/ode/simpel/
src/main/java/org/apache/ode/simpel/omodel/ src/main/jav...
Author: mriou
Date: Fri Feb 15 16:17:59 2008
New Revision: 628212
URL: http://svn.apache.org/viewvc?rev=628212&view=rev
Log:
Lots of TODOs with a bit of code in the middle. An OModel gets built properly as long as there's only receives, assigns and replies in a process. Execution seems to work for these except for the assign that needs much more firm massaging.
Added:
ode/sandbox/simpel/src/main/java/org/apache/ode/EmbeddedServer.java
ode/sandbox/simpel/src/main/java/org/apache/ode/Options.java
ode/sandbox/simpel/src/main/java/org/apache/ode/embed/
ode/sandbox/simpel/src/main/java/org/apache/ode/embed/BindingContextImpl.java
ode/sandbox/simpel/src/main/java/org/apache/ode/embed/EmbeddedStore.java
ode/sandbox/simpel/src/main/java/org/apache/ode/embed/GeronimoTxFactory.java
ode/sandbox/simpel/src/main/java/org/apache/ode/embed/ServerResources.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/CompilationException.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/SimPELExpression.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELInput.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELMessage.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOperation.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOutput.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPart.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPortType.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELWSDLElement.java
ode/sandbox/simpel/src/test/resources/log4j.properties
Modified:
ode/sandbox/simpel/Rakefile
ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/SimPELCompiler.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/OBuilder.java
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/util/DefaultErrorListener.java
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELCompilerTest.java
Modified: ode/sandbox/simpel/Rakefile
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/Rakefile?rev=628212&r1=628211&r2=628212&view=diff
==============================================================================
--- ode/sandbox/simpel/Rakefile (original)
+++ ode/sandbox/simpel/Rakefile Fri Feb 15 16:17:59 2008
@@ -24,11 +24,32 @@
NEXT_VERSION = "1.2"
ANTLR = "org.antlr:antlr:jar:3.0.1"
-ODE = ["org.apache.ode:ode-bpel-compiler:jar:1.2-SNAPSHOT",
- "org.apache.ode:ode-bpel-obj:jar:1.2-SNAPSHOT",
- "org.apache.ode:ode-utils:jar:1.2-SNAPSHOT"]
-WSDL4J = "wsdl4j:wsdl4j:jar:1.6.2"
+COMMONS = struct(
+ :logging =>"commons-logging:commons-logging:jar:1.1",
+ :lang =>"commons-lang:commons-lang:jar:2.1"
+)
+GERONIMO = struct(
+ :kernel =>"org.apache.geronimo.modules:geronimo-kernel:jar:2.0.1",
+ :transaction =>"org.apache.geronimo.components:geronimo-transaction:jar:2.0.1",
+ :connector =>"org.apache.geronimo.components:geronimo-connector:jar:2.0.1"
+)
+HSQLDB = "hsqldb:hsqldb:jar:1.8.0.7"
+JAVAX = struct(
+ :transaction =>"org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1",
+ :resource =>"org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:jar:1.0"
+)
LOG4J = "log4j:log4j:jar:1.2.15"
+ODE = ["org.apache.ode:ode-bpel-api:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-bpel-compiler:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-bpel-dao:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-bpel-obj:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-bpel-runtime:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-il-common:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-jacob:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-scheduler-simple:jar:1.2-SNAPSHOT",
+ "org.apache.ode:ode-utils:jar:1.2-SNAPSHOT"]
+WSDL4J = "wsdl4j:wsdl4j:jar:1.6.2"
+XERCES = "xerces:xercesImpl:jar:2.9.0"
repositories.remote << "http://repo1.maven.org/maven2"
@@ -44,6 +65,8 @@
pkg_name = "org.apache.ode.simpel.antlr"
compile.from antlr(_("src/main/antlr"), {:in_package=>pkg_name, :token=>pkg_name})
- compile.with ODE, LOG4J, WSDL4J, file(_("lib/e4x-grammar-0.1.jar")), file(_("lib/antlr-20071220.jar"))
+ compile.with HSQLDB, JAVAX.resource, JAVAX.transaction, COMMONS.lang, COMMONS.logging, ODE, LOG4J,
+ WSDL4J, GERONIMO.transaction, XERCES,
+ file(_("lib/e4x-grammar-0.1.jar")), file(_("lib/antlr-20071220.jar"))
package :jar
end
Modified: ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g?rev=628212&r1=628211&r2=628212&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g (original)
+++ ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g Fri Feb 15 16:17:59 2008
@@ -138,7 +138,10 @@
// Simple activities
invoke : 'invoke' '(' p=ID ',' o=ID (',' in=ID)? ')' -> ^(INVOKE $p $o $in?);
-receive : receive_base (param_block | SEMI) -> ^(RECEIVE receive_base param_block?);
+receive
+options {backtrack=true;}
+ : receive_base SEMI -> ^(RECEIVE receive_base) |
+ receive_base param_block -> ^(RECEIVE receive_base) param_block;
receive_base
: 'receive' '(' p=ID ',' o=ID (',' correlation)? ')' -> ^($p $o correlation?);
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=628212&r1=628211&r2=628212&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 Fri Feb 15 16:17:59 2008
@@ -8,8 +8,8 @@
XML_ELEMENT; XML_ATTRIBUTE; XML_NAME; XML_ATTRIBUTE_VALUE; XML_TEXT; XML_WS; XML_COMMENT; XML_CDATA; XML_PI;
}
scope BPELScope { OScope oscope; }
-scope Block { OActivity blockActivity; }
-scope Parent { OActivity activity; }
+scope Parent { OBuilder.StructuredActivity activity; }
+scope ReceiveBlock { OPickReceive receive; }
@header {
package org.apache.ode.simpel.antlr;
@@ -73,11 +73,12 @@
// Process
process
scope BPELScope Parent;
- : ^(PROCESS ^(NS pr=ID? nm=ID) body)
- { OScope scope = builder.buildProcess(text($pr), text($nm));
- $BPELScope::oscope = scope;
+ : ^(PROCESS ^(NS pr=ID? nm=ID)
+ { OBuilder.StructuredActivity<OScope> scope = builder.buildProcess(text($pr), text($nm));
+ $BPELScope::oscope = scope.getOActivity();
$Parent::activity = scope;
- };
+ }
+ body);
proc_stmt
: pick | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex | scope_ex | with_ex
@@ -85,59 +86,54 @@
| variable | partner_link;
block
scope Parent;
- : ^(SEQUENCE proc_stmt+)
- { OSequence seq = builder.buildSequence($Parent[-1]::activity);
+ : ^(SEQUENCE
+ { OBuilder.StructuredActivity seq = builder.build(OSequence.class, $BPELScope::oscope, $Parent[-1]::activity);
$Parent::activity = seq;
- };
+ }
+ proc_stmt+);
param_block
scope Parent;
- : ^(SEQUENCE ID+ proc_stmt+)
- { OSequence seq = builder.buildSequence($Parent[-1]::activity);
+ : ^(SEQUENCE ID+
+ { OBuilder.StructuredActivity seq = builder.build(OSequence.class, $BPELScope::oscope, $Parent[-1]::activity);
$Parent::activity = seq;
- builder.setBlockParam($Block::blockActivity, $ID.text);
- };
+ builder.setBlockParam($BPELScope::oscope, (OActivity) $Parent[-1]::activity.getOActivity(), $ID.text);
+ }
+ proc_stmt+);
body : block | proc_stmt;
// Structured activities
pick
-scope Parent;
: ^(PICK receive* timeout*);
timeout : ^(TIMEOUT expr block);
// TODO links
flow
-scope Parent;
: ^(FLOW body*);
signal : ^(SIGNAL ID expr?);
join : ^(JOIN ID* expr?);
if_ex
-scope Parent;
: ^(IF expr body (^(ELSE body))?);
while_ex
-scope Parent;
: ^(WHILE expr body);
until_ex
-scope Parent;
: ^(UNTIL expr body);
foreach
-scope Parent;
: ^(FOREACH ID init=expr cond=expr assign body);
forall
-scope Parent;
: ^(FORALL ID from=expr to=expr body);
try_ex
-scope BPELScope Parent;
+scope BPELScope;
: ^(TRY body catch_ex*);
catch_ex: ^(CATCH ^(NS ID ID?) param_block);
scope_ex
-scope BPELScope Parent;
+scope BPELScope;
: ^(SCOPE ID? body scope_stmt*);
scope_stmt
: event | alarm | compensation;
@@ -148,7 +144,6 @@
: ^(COMPENSATION body);
with_ex
-scope Parent;
: ^(WITH with_map* body);
with_map: ^(MAP ID path_expr);
@@ -156,20 +151,21 @@
invoke : ^(INVOKE p=ID o=ID in=ID?);
-reply : ^(REPLY ID (ID ID)?);
+reply : ^(REPLY msg=ID (pl=ID var=ID)?)
+ { builder.build(OReply.class, $BPELScope::oscope, $Parent::activity,
+ $ReceiveBlock::receive, text($msg), text($pl), text($var)); };
receive
-scope Block;
-scope Parent;
- : ^(RECEIVE ^(p=ID o=ID correlation?) (prb=(param_block))?)
- { OPickReceive rec = builder.buildReceive($Parent[-1]::activity, text($p), text($o));
- if ($prb != null) {
- $Parent::activity = rec;
- $Block::blockActivity = rec;
- }
- };
+scope ReceiveBlock;
+ : ^(RECEIVE ^(p=ID o=ID correlation?))
+ {
+ OBuilder.StructuredActivity<OPickReceive> rec = builder.build(OPickReceive.class, $BPELScope::oscope,
+ $Parent::activity, text($p), text($o));
+ $ReceiveBlock::receive = rec.getOActivity();
+ }
+ (prb=(param_block))?;
-assign : ^(ASSIGN ID rvalue);
+assign : ^(ASSIGN ID rv=(rvalue)) { builder.build(OAssign.class, $BPELScope::oscope, $Parent::activity, text($ID), text($rv)); };
rvalue
: receive | invoke | expr | xmlElement;
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/EmbeddedServer.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/EmbeddedServer.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/EmbeddedServer.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/EmbeddedServer.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,101 @@
+/*
+ * 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;
+
+import org.apache.log4j.Logger;
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.embed.ServerResources;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.GUID;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.concurrent.Future;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class EmbeddedServer {
+ private static final Logger __log = Logger.getLogger(EmbeddedServer.class);
+
+ protected Options _options;
+ protected ServerResources _resources;
+
+ public void start() {
+ start(new Options());
+ }
+
+ public void start(Options options) {
+ _options = options;
+ _resources = new ServerResources(options);
+ }
+
+ public void stop() {
+ }
+
+ public Collection<QName> deploy(String process) {
+ return _resources.getStore().deploy(process);
+ }
+
+ public void undeploy(String dir) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Element sendMessage(String partnerLink, String operation, Element message) {
+ String messageId = new GUID().toString();
+ MyRoleMessageExchange odeMex = _resources.getServer().createMessageExchange(InvocationStyle.UNRELIABLE,
+ new QName("http://ode.apache.org/simpel/1.0/endpoint", partnerLink), operation, "" + messageId);
+ // TODO see what kind of exceptions we should throw from here
+ if (odeMex.getOperation() == null)
+ throw new RuntimeException("Call to " + partnerLink + "." + operation + " was not routable.");
+
+ Document doc = DOMUtils.newDocument();
+ Element msgEl = doc.createElementNS(null, "message");
+ doc.appendChild(msgEl);
+ Element part = doc.createElement("payload"); // default part
+ msgEl.appendChild(part);
+ part.appendChild(doc.importNode(message, true));
+
+ Message odeRequest = odeMex.createMessage(null);
+ odeRequest.setMessage(msgEl);
+
+ odeMex.setRequest(odeRequest);
+ try {
+ odeMex.invokeBlocking();
+ } catch (java.util.concurrent.TimeoutException te) {
+ throw new RuntimeException("Call to " + partnerLink + "." + operation + " timed out!", te);
+ }
+
+ if (odeMex.getAckType() == MessageExchange.AckType.FAILURE)
+ throw new RuntimeException("Failure:" + odeMex.getFailureType() + ": " + odeMex.getFaultExplanation());
+
+ if (odeMex.getOperation().getOutput() != null) {
+ return DOMUtils.getFirstChildElement(DOMUtils.getFirstChildElement(odeMex.getResponse().getMessage()));
+ }
+ return null;
+ }
+
+ public Future sendMessageAsync(String processName, Element message) {
+ throw new UnsupportedOperationException();
+ }
+
+
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/Options.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/Options.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/Options.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/Options.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.bpel.iapi.BpelEventListener;
+
+import java.io.File;
+import java.util.Properties;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class Options {
+
+ private OdeConfigProperties _odeProps;
+ private Properties _backingProps;
+ private List<BpelEventListener> _eventListeners;
+
+ public Options() {
+ _backingProps = new Properties();
+ _odeProps = new OdeConfigProperties(_backingProps, "embed");
+ }
+
+ /** @return the maximum amoubt of threads used by ODE to process messages */
+ public int getThreadPoolMaxSize() {
+ return _odeProps.getThreadPoolMaxSize();
+ }
+ /** @param maxSize the maximum number of threads ODE will be allowed to use to process messages */
+ public void setThreadPoolMaxSize(int maxSize) {
+ _backingProps.setProperty(OdeConfigProperties.PROP_THREAD_POOL_SIZE, ""+maxSize);
+ }
+
+ /** @return whether dehydration is enabled. Dehydration allows processe descriptions to be lazy loaded in
+ * memory to save some space if you have a lot of them. */
+ public boolean isDehydrationEnabled() {
+ return _odeProps.isDehydrationEnabled();
+ }
+ /** @param enable dehydration */
+ public void setDehydrationEnabled(boolean enable) {
+ _backingProps.setProperty(OdeConfigProperties.PROP_PROCESS_DEHYDRATION, ""+enable);
+ }
+
+ public String getDatabasePath() {
+ return _backingProps.getProperty("database-path");
+ }
+ public void setDatabasePath(String path) {
+ _backingProps.setProperty("database-path", path);
+ }
+
+ public List<BpelEventListener> getBpelEventListeners() {
+ return _eventListeners;
+ }
+ public void getBpelEventListeners(List<BpelEventListener> listeners) {
+ _eventListeners = listeners;
+ }
+
+ public Properties getProperties() {
+ return _backingProps;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/embed/BindingContextImpl.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/embed/BindingContextImpl.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/embed/BindingContextImpl.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/embed/BindingContextImpl.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,41 @@
+package org.apache.ode.embed;
+
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.il.epr.WSDL11Endpoint;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.Namespaces;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class BindingContextImpl implements BindingContext {
+
+ public EndpointReference activateMyRoleEndpoint(QName qName, Endpoint endpoint) {
+ Document doc = DOMUtils.newDocument();
+ Element serviceElmt = doc.createElementNS(Namespaces.WSDL_11, "service");
+ serviceElmt.setAttribute("name", endpoint.serviceName.getLocalPart());
+ serviceElmt.setAttribute("targetNamespace", endpoint.serviceName.getNamespaceURI());
+ Element portElmt = doc.createElementNS(Namespaces.WSDL_11, "port");
+ portElmt.setAttribute("name", endpoint.portName);
+ portElmt.setAttribute("xmlns:bindns", "http://ode.apache.org/simpel/1.0/endpoint");
+ portElmt.setAttribute("binding", "bindns:simpelUnknownBinding");
+ doc.adoptNode(serviceElmt);
+ serviceElmt.appendChild(portElmt);
+ WSDL11Endpoint epr = new WSDL11Endpoint();
+ epr.set(serviceElmt);
+ return epr;
+ }
+
+ public void deactivateMyRoleEndpoint(Endpoint endpoint) {
+ // Nothing needed here
+ }
+
+ public PartnerRoleChannel createPartnerRoleChannel(QName qName, PortType portType, Endpoint endpoint) {
+ throw new UnsupportedOperationException();
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/embed/EmbeddedStore.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/embed/EmbeddedStore.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/embed/EmbeddedStore.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/embed/EmbeddedStore.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,209 @@
+/*
+ * 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.embed;
+
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.bpel.o.Serializer;
+import org.apache.ode.bpel.o.OPartnerLink;
+import org.apache.ode.simpel.SimPELCompiler;
+import org.w3c.dom.Node;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.net.URI;
+import java.util.*;
+
+/**
+ * TODO In the ProcessStore and the ProcessConf interfaces, some methods are part of the contract
+ * TODO with the runtime, others with the IL or the management API. Put some order in that mess.
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class EmbeddedStore implements ProcessStore {
+
+ private static final String SIMPEL_ENDPOINT_NS = "http://ode.apache.org/simpel/1.0/endpoint";
+
+ private HashMap<QName, OProcess> _processes = new HashMap<QName,OProcess>();
+ private SimPELCompiler _compiler = new SimPELCompiler();
+ private ArrayList<ProcessStoreListener> _listeners = new ArrayList<ProcessStoreListener>();
+
+ public Collection<QName> deploy(String processStr) {
+ OProcess op = _compiler.compileProcess(processStr);
+ _processes.put(op.getQName(), op);
+
+ fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.DEPLOYED, op.getQName(), null));
+ fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.ACTIVATED, op.getQName(), null));
+
+ LinkedList<QName> ll = new LinkedList<QName>();
+ ll.add(op.getQName());
+ return ll;
+ }
+
+ public Collection<QName> deploy(File bpelFile) {
+ // TODO come up with some sort of common deployment model
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<QName> undeploy(File file) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<String> getPackages() {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<QName> listProcesses(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<QName> getProcesses() {
+ return new LinkedList<QName>(_processes.keySet());
+ }
+
+ public ProcessConf getProcessConfiguration(QName processId) {
+ return new EmbeddedProcessConf(_processes.get(processId));
+ }
+
+ public void registerListener(ProcessStoreListener psl) {
+ _listeners.add(psl);
+ }
+
+ public void unregisterListener(ProcessStoreListener psl) {
+ _listeners.remove(psl);
+ }
+
+ public void setProperty(QName pid, QName propName, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setProperty(QName pid, QName propName, Node value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setState(QName pid, ProcessState state) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setRetiredPackage(String packageName, boolean retired) {
+ // TODO Implement process retirement
+ throw new UnsupportedOperationException();
+ }
+
+ public long getCurrentVersion() {
+ return 0;
+ }
+
+ protected void fireEvent(ProcessStoreEvent pse) {
+ for (ProcessStoreListener psl : _listeners) psl.onProcessStoreEvent(pse);
+ }
+
+ public class EmbeddedProcessConf implements ProcessConf {
+ private OProcess _oprocess;
+
+ public EmbeddedProcessConf(OProcess _oprocess) {
+ this._oprocess = _oprocess;
+ }
+
+ public QName getProcessId() {
+ return new QName(_oprocess.getQName().getNamespaceURI(),
+ _oprocess.getQName().getLocalPart()+"-"+getVersion());
+ }
+
+ public QName getType() {
+ return _oprocess.getQName();
+ }
+
+ public long getVersion() {
+ // TODO implement versioning
+ return 0;
+ }
+
+ public boolean isTransient() {
+ return true;
+ }
+
+ public InputStream getCBPInputStream() {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Serializer fileHeader = new Serializer(System.currentTimeMillis());
+ try {
+ fileHeader.writeOProcess(_oprocess, baos);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to serialize compiled OProcess!", e);
+ }
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+
+ public String getBpelDocument() {
+ throw new UnsupportedOperationException();
+ }
+
+ public URI getBaseURI() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getDeployDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProcessState getState() {
+ return ProcessState.ACTIVE;
+ }
+
+ public List<File> getFiles() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<QName, Node> getProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPackage() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Definition getDefinitionForService(QName qName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<String, Endpoint> getProvideEndpoints() {
+ return defaultEndpoints(true);
+ }
+
+ public Map<String, Endpoint> getInvokeEndpoints() {
+ return defaultEndpoints(false);
+ }
+
+ public boolean isEventEnabled(List<String> strings, BpelEvent.TYPE type) {
+ return false;
+ }
+
+ private Map<String, Endpoint> defaultEndpoints(boolean myrole) {
+ Map<String, Endpoint> res = new HashMap<String, Endpoint>();
+ for (OPartnerLink partnerLink : _oprocess.getAllPartnerLinks()) {
+ if (partnerLink.hasMyRole() && myrole || partnerLink.hasPartnerRole() && !myrole)
+ res.put(partnerLink.getName(), new Endpoint(
+ new QName(SIMPEL_ENDPOINT_NS, partnerLink.getName()), "SimPELPort"));
+ }
+ return res;
+ }
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/embed/GeronimoTxFactory.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/embed/GeronimoTxFactory.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/embed/GeronimoTxFactory.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/embed/GeronimoTxFactory.java Fri Feb 15 16:17: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.embed;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class GeronimoTxFactory {
+ private static final Log __log = LogFactory.getLog(GeronimoTxFactory.class);
+
+ /* Public no-arg contructor is required */
+ public GeronimoTxFactory() {
+ }
+
+ public TransactionManager getTransactionManager() {
+ __log.info("Using embedded Geronimo transaction manager");
+ try {
+ Object obj = new org.apache.geronimo.transaction.manager.GeronimoTransactionManager();
+ return (TransactionManager) obj;
+ } catch (Exception except) {
+ throw new IllegalStateException("Unable to instantiate Geronimo Transaction Manager", except);
+ }
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/embed/ServerResources.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/embed/ServerResources.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/embed/ServerResources.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/embed/ServerResources.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,246 @@
+package org.apache.ode.embed;
+
+import org.apache.log4j.Logger;
+import org.apache.ode.EmbeddedServer;
+import org.apache.ode.Options;
+import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
+import org.apache.ode.bpel.engine.BpelServerImpl;
+import org.apache.ode.bpel.engine.CountLRUDehydrationPolicy;
+import org.apache.ode.bpel.evtproc.DebugBpelEventListener;
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
+import org.apache.ode.il.dbutil.Database;
+import org.apache.ode.scheduler.simple.JdbcDelegate;
+import org.apache.ode.scheduler.simple.SimpleScheduler;
+import org.apache.ode.utils.GUID;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class ServerResources {
+ private static final Logger __log = Logger.getLogger(EmbeddedServer.class);
+
+ protected Options _options;
+ protected TransactionManager _txMgr;
+ protected BpelServerImpl _server;
+ protected Database _db;
+ protected DataSource _ds;
+ protected BpelDAOConnectionFactory _daoCF;
+ protected ExecutorService _executorService;
+ protected Scheduler _scheduler;
+ protected EmbeddedStore _store;
+
+ public ServerResources(Options options) {
+ _options = options;
+ if (_options.getThreadPoolMaxSize() <= 0) _executorService = Executors.newCachedThreadPool();
+ else _executorService = Executors.newFixedThreadPool(_options.getThreadPoolMaxSize());
+
+ __log.debug("Initializing transaction manager");
+ initTxMgr();
+ __log.debug("Creating data source.");
+ initDataSource();
+ __log.debug("Starting DAO.");
+ initDAO();
+ __log.debug("Initializing BPEL process store.");
+ initProcessStore();
+ __log.debug("Initializing BPEL server.");
+ initBpelServer();
+
+ // Register BPEL event listeners configured in axis2.properties file.
+ registerEventListeners();
+
+ _server.start();
+ }
+
+ private void initBpelServer() {
+ _server = new BpelServerImpl();
+ _scheduler = createScheduler();
+ _scheduler.setJobProcessor(_server);
+
+ _server.setDaoConnectionFactory(_daoCF);
+// _server.setEndpointReferenceContext(new EndpointReferenceContextImpl(this));
+// _server.setMessageExchangeContext(new MessageExchangeContextImpl(this));
+ _server.setBindingContext(new BindingContextImpl());
+ _server.setScheduler(_scheduler);
+ _server.setTransactionManager(_txMgr);
+ if (_options.isDehydrationEnabled()) {
+ CountLRUDehydrationPolicy dehy = new CountLRUDehydrationPolicy();
+ _server.setDehydrationPolicy(dehy);
+ }
+ _server.setConfigProperties(_options.getProperties());
+ _server.init();
+ }
+
+ private void initDAO() {
+ // TODO supporting only in memory for now, extend to datasource usage
+ _daoCF = new BpelDAOConnectionFactoryImpl(_txMgr);
+ }
+
+ private void initTxMgr() {
+ if(_txMgr == null) {
+ try {
+ GeronimoTxFactory txFactory = new GeronimoTxFactory();
+ _txMgr = txFactory.getTransactionManager();
+ } catch (Exception e) {
+ __log.fatal("Couldn't initialize a transaction manager using Geronimo's transaction factory.", e);
+ throw new RuntimeException("Couldn't initialize a transaction manager using " + "Geronimo's transaction factory.", e);
+ }
+ }
+ }
+
+ private void initDataSource() {
+ jdbcDataSource hsqlds = new jdbcDataSource();
+ hsqlds.setDatabase("jdbc:hsqldb:mem:" + new GUID().toString());
+ hsqlds.setUser("sa");
+ hsqlds.setPassword("");
+ _ds = hsqlds;
+ }
+
+ protected Scheduler createScheduler() {
+ // TODO as long as we're using HSQL that's fine, afterward...
+ Connection conn = null;
+ Statement stmt = null;
+ try {
+ conn = _ds.getConnection();
+ stmt = conn.createStatement();
+ stmt.execute(SCHEDULER_DDL);
+ } catch (SQLException e) {
+ throw new RuntimeException("Couldn't create the scheduler schema!", e);
+ } finally {
+ try {
+ if (stmt != null) stmt.close();
+ if (conn != null) conn.close();
+ } catch (SQLException se) {
+ __log.info(se);
+ }
+ }
+
+ SimpleScheduler scheduler = new SimpleScheduler(new GUID().toString(),new JdbcDelegate(_ds));
+ scheduler.setTransactionManager(_txMgr);
+ _scheduler = scheduler;
+ return scheduler;
+ }
+
+ private void initProcessStore() {
+ // TODO Support persistent store as well
+ _store = new EmbeddedStore();
+ _store.registerListener(new ProcessStoreListenerImpl());
+ }
+
+ /**
+ * Register event listeners configured in the configuration.
+ *
+ */
+ private void registerEventListeners() {
+ // let's always register the debugging listener....
+ _server.registerBpelEventListener(new DebugBpelEventListener());
+
+ // then, whatever else they want.
+ List<BpelEventListener> listeners = _options.getBpelEventListeners();
+ if (listeners != null) {
+ for (BpelEventListener listener : listeners) {
+ _server.registerBpelEventListener(listener);
+ }
+ }
+ }
+
+ private class ProcessStoreListenerImpl implements ProcessStoreListener {
+ public void onProcessStoreEvent(ProcessStoreEvent event) {
+ handleEvent(event);
+ }
+ }
+
+ private void handleEvent(ProcessStoreEvent pse) {
+ __log.debug("Process store event: " + pse);
+ switch (pse.type) {
+ case ACTIVATED:
+ case RETIRED:
+ // bounce the process
+ _server.unregister(pse.pid);
+ ProcessConf pconf = _store.getProcessConfiguration(pse.pid);
+ if (pconf != null) _server.register(pconf);
+ else __log.debug("slighly odd: received event " + pse + " for process not in store!");
+ break;
+ case DISABLED:
+ case UNDEPLOYED:
+ _server.unregister(pse.pid);
+ break;
+ default:
+ __log.debug("Ignoring store event: " + pse);
+ }
+ }
+
+ public EmbeddedStore getStore() {
+ return _store;
+ }
+
+ public BpelServerImpl getServer() {
+ return _server;
+ }
+
+ private static final String SCHEDULER_DDL =
+ "CREATE TABLE ODE_JOB (" +
+ " jobid CHAR(64) DEFAULT '' NOT NULL," +
+ " ts BIGINT DEFAULT 0 NOT NULL ," +
+ " nodeid char(64) NULL," +
+ " scheduled int DEFAULT 0 NOT NULL," +
+ " transacted int DEFAULT 0 NOT NULL," +
+ " details LONGVARBINARY NULL," +
+ " PRIMARY KEY(jobid));" +
+ "CREATE INDEX IDX_ODE_JOB_TS ON ODE_JOB (ts);" +
+ "CREATE INDEX IDX_ODE_JOB_NODEID ON ODE_JOB (nodeid);";
+
+ // TODO MEX interceptors
+// private void registerMexInterceptors() {
+// String listenersStr = _options.getMessageExchangeInterceptors();
+// if (listenersStr != null) {
+// for (StringTokenizer tokenizer = new StringTokenizer(listenersStr, ",;"); tokenizer.hasMoreTokens();) {
+// String interceptorCN = tokenizer.nextToken();
+// try {
+// _server.registerMessageExchangeInterceptor((MessageExchangeInterceptor) Class.forName(interceptorCN).newInstance());
+// __log.info(__msgs.msgMessageExchangeInterceptorRegistered(interceptorCN));
+// } catch (Exception e) {
+// __log.warn("Couldn't register the event listener " + interceptorCN + ", the class couldn't be "
+// + "loaded properly: " + e);
+// }
+// }
+// }
+// }
+//
+ // TODO extension activities
+// private void registerExtensionActivityBundles() {
+// String extensionsStr = _options.getExtensionActivityBundles();
+// if (extensionsStr != null) {
+// Map<QName, ExtensionValidator> validators = new HashMap<QName, ExtensionValidator>();
+// for (StringTokenizer tokenizer = new StringTokenizer(extensionsStr, ",;"); tokenizer.hasMoreTokens();) {
+// String bundleCN = tokenizer.nextToken();
+// try {
+// // instantiate bundle
+// AbstractExtensionBundle bundle = (AbstractExtensionBundle) Class.forName(bundleCN).newInstance();
+//
+// // register extension bundle (BPEL server)
+// _server.registerExtensionBundle(bundle);
+//
+// //add validators
+// validators.putAll(bundle.getExtensionValidators());
+// } catch (Exception e) {
+// __log.warn("Couldn't register the extension bundle " + bundleCN + ", the class couldn't be " +
+// "loaded properly.");
+// }
+// }
+// // register extension bundle (BPEL store)
+// _store.setExtensionValidators(validators);
+// }
+// }
+
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/CompilationException.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/CompilationException.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/CompilationException.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/CompilationException.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,18 @@
+package org.apache.ode.simpel;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class CompilationException extends RuntimeException {
+ public CompilationException(String message) {
+ super(message);
+ }
+
+ public CompilationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CompilationException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/SimPELCompiler.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/SimPELCompiler.java?rev=628212&r1=628211&r2=628212&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/SimPELCompiler.java (original)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/SimPELCompiler.java Fri Feb 15 16:17:59 2008
@@ -1,6 +1,7 @@
package org.apache.ode.simpel;
import org.antlr.runtime.ANTLRReaderStream;
+import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.tree.CommonTreeNodeStream;
import org.antlr.runtime.tree.Tree;
import org.antlr.runtime.tree.TreeParser;
@@ -12,6 +13,7 @@
import uk.co.badgersinfoil.e4x.antlr.*;
import java.io.StringReader;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
@@ -28,8 +30,13 @@
this.el = el;
}
- public OProcess compileProcess(String process) throws Exception {
- ANTLRReaderStream charstream = new ANTLRReaderStream(new StringReader(process));
+ public OProcess compileProcess(String process) {
+ ANTLRReaderStream charstream = null;
+ try {
+ charstream = new ANTLRReaderStream(new StringReader(process));
+ } catch (IOException e) {
+ throw new CompilationException("Unable to read process string.", e);
+ }
ErrorListener errListener = (el == null ? new DefaultErrorListener() : el);
SimPELLexer lexer = new SimPELLexer(charstream);
@@ -42,7 +49,12 @@
parser.setInput(lexer, charstream);
parser.setErrorListener(errListener);
- SimPELParser.program_return result = parser.program();
+ SimPELParser.program_return result = null;
+ try {
+ result = parser.program();
+ } catch (RecognitionException e) {
+ throw new CompilationException(e);
+ }
// pull out the tree and cast it
Tree t = (Tree)result.getTree();
@@ -53,13 +65,16 @@
// Pass the tree to the walker for compilation
CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
SimPELWalker walker = new SimPELWalker(nodes);
- walker.setErrorListener(el);
+ walker.setErrorListener(errListener);
HashMap<Integer, Integer> tokenMapping = buildTokenMap(E4XParser.tokenNames, E4XLexer.class, SimPELWalker.class);
rewriteTokens(tokenMapping, E4XParser.tokenNames, (LinkedListTree) t, walker, false);
nodes.setTokenStream(tokenStream);
- walker.program();
-
+ try {
+ walker.program();
+ } catch (RecognitionException e) {
+ throw new CompilationException(e);
+ }
return walker.getBuilder().getProcess();
}
return null;
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=628212&r1=628211&r2=628212&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 Fri Feb 15 16:17:59 2008
@@ -4,16 +4,18 @@
import org.apache.ode.bpel.compiler.BaseCompiler;
import org.apache.ode.bpel.compiler.bom.Bpel20QNames;
import org.apache.ode.bpel.o.*;
+import org.apache.ode.simpel.wsdl.SimPELInput;
+import org.apache.ode.simpel.wsdl.SimPELOperation;
+import org.apache.ode.simpel.wsdl.SimPELOutput;
+import org.apache.ode.simpel.wsdl.SimPELPortType;
import org.apache.ode.utils.GUID;
-import org.w3c.dom.Element;
-import javax.wsdl.*;
-import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.LinkedList;
/**
* @author Matthieu Riou <mr...@apache.org>
@@ -24,28 +26,72 @@
private HashMap<String,String> namespaces = new HashMap<String,String>();
private HashMap<String,OPartnerLink> partnerLinks = new HashMap<String,OPartnerLink>();
- private boolean firstReceive = false;
+ private HashMap<String,OScope.Variable> variables = new HashMap<String,OScope.Variable>();
+ private boolean firstReceive = true;
- public OScope buildProcess(String prefix, String name) {
+
+ public StructuredActivity build(Class oclass, OScope oscope, StructuredActivity parent, Object... params) {
+ try {
+ OActivity oactivity = (OActivity) oclass
+ .getConstructor(OProcess.class, OActivity.class).newInstance(_oprocess, parent.getOActivity());
+ Method buildMethod = null;
+ for (Method method : OBuilder.class.getMethods())
+ if (method.getName().equals("build" + oclass.getSimpleName().substring(1))) buildMethod = method;
+
+ if (buildMethod == null) throw new RuntimeException("No builder for class " + oclass.getSimpleName());
+
+ Object[] buildParams = new Object[params.length + 2];
+ System.arraycopy(params, 0, buildParams, 2, params.length);
+ buildParams[0] = oactivity;
+ buildParams[1] = oscope;
+ StructuredActivity result = (StructuredActivity) buildMethod.invoke(this, buildParams);
+ parent.run((OActivity) result.getOActivity());
+ return result;
+ } catch (Exception e) {
+ throw new RuntimeException("Couldn't build activity of type " + oclass, e);
+ }
+ }
+
+ public static abstract class StructuredActivity<T> {
+ private T _oact;
+ public StructuredActivity(T oact) {
+ _oact = oact;
+ }
+ public T getOActivity() {
+ return _oact;
+ }
+ public abstract void run(OActivity child);
+ }
+ public static class SimpleActivity<T> extends StructuredActivity<T> {
+ public SimpleActivity(T oact) {
+ super(oact);
+ }
+ public void run(OActivity child) { /* Do nothing */ }
+ }
+
+ public StructuredActivity<OScope> buildProcess(String prefix, String name) {
_oprocess = new OProcess(Bpel20QNames.NS_WSBPEL2_0_FINAL_EXEC);
+ _oprocess.processName = name;
_oprocess.guid = new GUID().toString();
_oprocess.constants = makeConstants();
_oprocess.compileDate = new Date();
if (namespaces.get(prefix) == null) _oprocess.targetNamespace = SIMPEL_NS;
else _oprocess.targetNamespace = namespaces.get(prefix);
- OScope processScope = new OScope(_oprocess, null);
+ final OScope processScope = new OScope(_oprocess, null);
processScope.name = "__PROCESS_SCOPE:" + name;
_oprocess.procesScope = processScope;
- return processScope;
+ return new StructuredActivity<OScope>(processScope) {
+ public void run(OActivity child) {
+ processScope.activity = child;
+ }
+ };
}
- public OPickReceive buildReceive(OActivity parent, String partnerLink, String operation) {
- OPickReceive receive = new OPickReceive(_oprocess, parent);
-
+ public SimpleActivity buildPickReceive(OPickReceive receive, OScope oscope, String partnerLink, String operation) {
OPickReceive.OnMessage onMessage = new OPickReceive.OnMessage(_oprocess);
- onMessage.partnerLink = resolvePartnerLink(partnerLink);
- onMessage.operation = new SimPELOperation(operation);
+ onMessage.partnerLink = buildPartnerLink(oscope, partnerLink, operation, true);
+ onMessage.operation = onMessage.partnerLink.myRolePortType.getOperation(operation, null, null);
if (firstReceive) {
firstReceive = false;
@@ -56,146 +102,110 @@
onMessage.activity = new OEmpty(_oprocess, receive);
receive.onMessages.add(onMessage);
- return receive;
- }
-
- public OSequence buildSequence(OActivity parent) {
- OSequence seq = new OSequence(_oprocess, parent);
- return seq;
+ return new SimpleActivity<OPickReceive>(receive);
}
- public void setBlockParam(OActivity blockActivity, String varName) {
- if (blockActivity == null) {
- __log.warn("Can't set block parameter on activity null.");
+ public StructuredActivity buildSequence(final OSequence seq, OScope oscope) {
+ return new StructuredActivity<OSequence>(seq) {
+ public void run(OActivity child) {
+ seq.sequence.add(child);
+ }
+ };
+ }
+
+ public SimpleActivity buildAssign(OAssign oassign, OScope oscope, String lexpr, String rexpr) {
+ OAssign.Copy ocopy = new OAssign.Copy(_oprocess);
+ oassign.operations.add(ocopy);
+
+ OAssign.VariableRef vref = new OAssign.VariableRef(_oprocess);
+ vref.variable = resolveVariable(oscope, lexpr);
+ ocopy.to = vref;
+
+ ocopy.from = new OAssign.Expression(_oprocess, new SimPELExpression(_oprocess, rexpr));
+ return new SimpleActivity<OAssign>(oassign);
+ }
+
+ public SimpleActivity buildReply(OReply oreply, OScope oscope, OPickReceive oreceive,
+ String var, String partnerLink, String operation) {
+ oreply.variable = resolveVariable(oscope, var);
+ if (partnerLink == null) {
+ if (oreceive == null) throw new RuntimeException("No parent receive but reply with var " + var +
+ " has no partnerLink/operation information.");
+ oreply.partnerLink = oreceive.onMessages.get(0).partnerLink;
+ oreply.operation = oreceive.onMessages.get(0).operation;
+ } else {
+ oreply.partnerLink = buildPartnerLink(oscope, partnerLink, operation, true);
+ oreply.operation = oreply.partnerLink.myRolePortType.getOperation(operation, null, null);
+ }
+ oreply.operation.setOutput(new SimPELOutput("out"));
+ return new SimpleActivity<OReply>(oreply);
+ }
+
+ public void setBlockParam(OScope oscope, OActivity blockActivity, String varName) {
+ // The AST for block activities is something like:
+ // (SEQUENCE (activity) (SEQUENCE varIds otherActivities))
+ // The parent here is the first sequence so we just set the varIds on its first child activity
+ if (blockActivity == null || !(blockActivity instanceof OSequence)) {
+ __log.warn("Can't set block parameter with block parent activity " + blockActivity);
return;
}
- if (blockActivity instanceof OPickReceive) {
- ((OPickReceive)blockActivity).onMessages.get(0).variable = new OScope.Variable(_oprocess, null);
- } else throw new RuntimeException("Can't set block parameter on activity " + blockActivity);
+ OActivity oact = ((OSequence)blockActivity).sequence.get(0);
+ if (oact instanceof OPickReceive) {
+ ((OPickReceive)oact).onMessages.get(0).variable = resolveVariable(oscope, varName);
+ } else __log.warn("Can't set block parameter on activity " + oact);
}
public OProcess getProcess() {
return _oprocess;
}
- private OPartnerLink resolvePartnerLink(String name) {
+ private OPartnerLink buildPartnerLink(OScope oscope, String name, String operation, boolean myRole) {
+ // TODO Handle partnerlinks declared with an associated endpoint
OPartnerLink resolved = partnerLinks.get(name);
+ // TODO this will not work in case of variable name conflicts in different scopes
if (resolved == null) {
resolved = new OPartnerLink(_oprocess);
resolved.name = name;
+ resolved.declaringScope = oscope;
+ partnerLinks.put(name, resolved);
+ _oprocess.allPartnerLinks.add(resolved);
+ }
+ if (myRole) {
+ PortType pt = resolved.myRolePortType;
+ if (pt == null) pt = resolved.myRolePortType = new SimPELPortType();
+ SimPELOperation op = new SimPELOperation(operation);
+ op.setInput(new SimPELInput("in"));
+ pt.addOperation(op);
+ } else {
+ PortType pt = resolved.partnerRolePortType;
+ if (pt == null) pt = resolved.partnerRolePortType = new SimPELPortType();
+ SimPELOperation op = new SimPELOperation(operation);
+ op.setInput(new SimPELInput("in"));
+ pt.addOperation(op);
}
return resolved;
}
- protected String getBpwsNamespace() {
- return "http://ode.apache.org/simpel/1.0";
- }
-
- public class SimPELOperation implements Operation {
- private String name;
-
- public SimPELOperation(String name) {
- this.name = name;
- }
-
- public void setName(String s) {
- this.name = s;
- }
-
- public String getName() {
- return name;
- }
-
- public void setInput(Input input) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Input getInput() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setOutput(Output output) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Output getOutput() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addFault(Fault fault) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Fault getFault(String s) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Fault removeFault(String s) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Map getFaults() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setStyle(OperationType operationType) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public OperationType getStyle() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setParameterOrdering(List list) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public List getParameterOrdering() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setUndefined(boolean b) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public boolean isUndefined() {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setDocumentationElement(Element element) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Element getDocumentationElement() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void setExtensionAttribute(QName qName, Object o) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Object getExtensionAttribute(QName qName) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Map getExtensionAttributes() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public List getNativeAttributeNames() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void addExtensibilityElement(ExtensibilityElement extensibilityElement) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
+ private OScope.Variable resolveVariable(OScope oscope, String name) {
+ OScope.Variable resolved = variables.get(name);
+ // TODO this will not work in case of variable name conflicts in different scopes
+ if (resolved == null) {
+ LinkedList<OMessageVarType.Part> parts = new LinkedList<OMessageVarType.Part>();
- public ExtensibilityElement removeExtensibilityElement(ExtensibilityElement extensibilityElement) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ parts.add(new OMessageVarType.Part(_oprocess, "payload",
+ new OElementVarType(_oprocess, new QName("http://ode.apache.org/simpel/1.0/definition", "simpelWrapper"))));
+ OMessageVarType omsgType = new OMessageVarType(_oprocess,
+ new QName("http://ode.apache.org/simpel/1.0/definition", "simpelMessage"), parts);
+ resolved = new OScope.Variable(_oprocess, omsgType);
+ resolved.name = name;
+ resolved.declaringScope = oscope;
+ variables.put(name, resolved);
}
+ return resolved;
+ }
- public List getExtensibilityElements() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
+ protected String getBpwsNamespace() {
+ return "http://ode.apache.org/simpel/1.0";
}
+
}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/SimPELExpression.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/SimPELExpression.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/SimPELExpression.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/omodel/SimPELExpression.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,20 @@
+package org.apache.ode.simpel.omodel;
+
+import org.apache.ode.bpel.o.OExpression;
+import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.bpel.o.OExpressionLanguage;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELExpression extends OExpression {
+ private String expr;
+
+ public SimPELExpression(OProcess oProcess, String expr) {
+ super(oProcess);
+ this.expr = expr;
+ OExpressionLanguage oelang = new OExpressionLanguage(oProcess, null);
+ oelang.expressionLanguageUri = "http://ode.apache.org/simpel/1.0/expr";
+ expressionLanguage = oelang;
+ }
+}
Modified: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/util/DefaultErrorListener.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/util/DefaultErrorListener.java?rev=628212&r1=628211&r2=628212&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/util/DefaultErrorListener.java (original)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/util/DefaultErrorListener.java Fri Feb 15 16:17:59 2008
@@ -3,12 +3,36 @@
import org.antlr.runtime.RecognitionException;
import org.apache.ode.simpel.ErrorListener;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* @author Matthieu Riou <mr...@apache.org>
*/
public class DefaultErrorListener implements ErrorListener {
+ private LinkedList<Error> _errors = new LinkedList<Error>();
+
+ public List<Error> getErrors() {
+ return _errors;
+ }
+
public void reportRecognitionError(String[] tokens, int line, String message, RecognitionException e) {
+ _errors.add(new Error(tokens, line, message, e));
System.err.println("line " + line + ": " + message);
+ }
+
+ public class Error {
+ public String tokens[];
+ public int line;
+ public String message;
+ public RecognitionException e;
+
+ public Error(String[] tokens, int line, String message, RecognitionException e) {
+ this.tokens = tokens;
+ this.line = line;
+ this.message = message;
+ this.e = e;
+ }
}
}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELInput.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELInput.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELInput.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELInput.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,27 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELInput extends SimPELWSDLElement implements Input {
+ private String name;
+ private SimPELMessage _message = new SimPELMessage();
+
+ public SimPELInput(String name) {
+ this.name = name;
+ }
+ public void setName(String s) {
+ this.name = s;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setMessage(Message message) {
+ }
+ public Message getMessage() {
+ return _message;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELMessage.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELMessage.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELMessage.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELMessage.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,54 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELMessage extends SimPELWSDLElement implements Message {
+ private SimPELPart _part = new SimPELPart();
+ private QName _qname = new QName("http://ode.apache.org/simpel/1.0/definition", "simpelMessage");
+
+ public void setQName(QName qName) {
+ }
+
+ public QName getQName() {
+ return _qname;
+ }
+
+ public void addPart(Part part) {
+ }
+
+ public Part getPart(String s) {
+ return _part;
+ }
+
+ public Part removePart(String s) {
+ return null;
+ }
+
+ public Map getParts() {
+ HashMap m = new HashMap(1);
+ m.put(_part.getName(), _part);
+ return m;
+ }
+
+ public List getOrderedParts(List list) {
+ LinkedList l = new LinkedList();
+ l.add(_part);
+ return l;
+ }
+
+ public void setUndefined(boolean b) {
+ }
+
+ public boolean isUndefined() {
+ return false;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOperation.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOperation.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOperation.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOperation.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,62 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.*;
+import java.util.Map;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELOperation extends SimPELWSDLElement implements Operation {
+ private String name;
+ private Input _input;
+ private Output _output;
+
+ public SimPELOperation(String name) {
+ this.name = name;
+ }
+ public void setName(String s) {
+ this.name = s;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setInput(Input input) {
+ _input = input;
+ }
+ public Input getInput() {
+ return _input;
+ }
+ public void setOutput(Output output) {
+ _output = output;
+ }
+ public Output getOutput() {
+ return _output;
+ }
+ public void addFault(Fault fault) {
+ }
+ public Fault getFault(String s) {
+ return null;
+ }
+ public Fault removeFault(String s) {
+ return null;
+ }
+ public Map getFaults() {
+ return null;
+ }
+ public void setStyle(OperationType operationType) {
+ }
+ public OperationType getStyle() {
+ return null;
+ }
+ public void setParameterOrdering(List list) {
+ }
+ public List getParameterOrdering() {
+ return null;
+ }
+ public void setUndefined(boolean b) {
+ }
+ public boolean isUndefined() {
+ return false;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOutput.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOutput.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOutput.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELOutput.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,25 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.Output;
+import javax.wsdl.Message;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELOutput extends SimPELWSDLElement implements Output {
+ private String name;
+ public SimPELOutput(String name) {
+ this.name = name;
+ }
+ public void setName(String s) {
+ this.name = s;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setMessage(Message message) {
+ }
+ public Message getMessage() {
+ return null;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPart.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPart.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPart.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPart.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,30 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELPart extends SimPELWSDLElement implements Part {
+ public void setName(String s) {
+ }
+
+ public String getName() {
+ return "payload";
+ }
+
+ public void setElementName(QName qName) {
+ }
+
+ public QName getElementName() {
+ return new QName("http://ode.apache.org/simpel/1.0/definition", "simpelWrapper");
+ }
+
+ public void setTypeName(QName qName) {
+ }
+
+ public QName getTypeName() {
+ return null;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPortType.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPortType.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPortType.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELPortType.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,45 @@
+package org.apache.ode.simpel.wsdl;
+
+import javax.wsdl.PortType;
+import javax.wsdl.Operation;
+import javax.xml.namespace.QName;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELPortType extends SimPELWSDLElement implements PortType {
+ private QName _name;
+ private LinkedList<Operation> _operations = new LinkedList<Operation>();
+ public void setQName(QName qName) {
+ _name = qName;
+ }
+ public QName getQName() {
+ return _name;
+ }
+ public void addOperation(Operation operation) {
+ if (getOperation(operation.getName(), null, null) == null)
+ _operations.add(operation);
+ }
+ public Operation getOperation(String name, String inputName, String outputName) {
+ for (Operation op : _operations) {
+ if (op.getName().equals(name)) return op;
+ }
+ return null;
+ }
+ public List getOperations() {
+ return _operations;
+ }
+ public Operation removeOperation(String name, String inputName, String outputName) {
+ Operation op = getOperation(name, inputName, outputName);
+ if (op != null) _operations.remove(op);
+ return op;
+ }
+
+ public void setUndefined(boolean b) {
+ }
+ public boolean isUndefined() {
+ return false;
+ }
+}
Added: ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELWSDLElement.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELWSDLElement.java?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELWSDLElement.java (added)
+++ ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/wsdl/SimPELWSDLElement.java Fri Feb 15 16:17:59 2008
@@ -0,0 +1,39 @@
+package org.apache.ode.simpel.wsdl;
+
+import org.w3c.dom.Element;
+
+import javax.wsdl.WSDLElement;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mr...@apache.org>
+ */
+public class SimPELWSDLElement implements WSDLElement {
+ public void setDocumentationElement(Element element) {
+ }
+ public Element getDocumentationElement() {
+ return null;
+ }
+ public void setExtensionAttribute(QName qName, Object o) {
+ }
+ public Object getExtensionAttribute(QName qName) {
+ return null;
+ }
+ public Map getExtensionAttributes() {
+ return null;
+ }
+ public List getNativeAttributeNames() {
+ return null;
+ }
+ public void addExtensibilityElement(ExtensibilityElement extensibilityElement) {
+ }
+ public ExtensibilityElement removeExtensibilityElement(ExtensibilityElement extensibilityElement) {
+ return null;
+ }
+ public List getExtensibilityElements() {
+ return null;
+ }
+}
Modified: ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELCompilerTest.java
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELCompilerTest.java?rev=628212&r1=628211&r2=628212&view=diff
==============================================================================
--- ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELCompilerTest.java (original)
+++ ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/SimPELCompilerTest.java Fri Feb 15 16:17:59 2008
@@ -2,7 +2,11 @@
import junit.framework.TestCase;
import org.antlr.runtime.RecognitionException;
+import org.apache.ode.EmbeddedServer;
import org.apache.ode.bpel.o.OProcess;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -108,9 +112,16 @@
" reply(msg_out);\n" +
" }\n" +
"}";
- SimPELCompiler c = compiler();
- OProcess oprocess = c.compileProcess(process);
- reportErrors("Hello World", c);
+
+ EmbeddedServer server = new EmbeddedServer();
+ server.start();
+ server.deploy(process);
+
+ Document doc = DOMUtils.newDocument();
+ Element wrapper = doc.createElement("wrapper");
+ wrapper.setTextContent("Hello");
+
+ Element result = server.sendMessage("my_pl", "hello_op", wrapper);
}
private String readProcess(String fileName) throws Exception {
Added: ode/sandbox/simpel/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/test/resources/log4j.properties?rev=628212&view=auto
==============================================================================
--- ode/sandbox/simpel/src/test/resources/log4j.properties (added)
+++ ode/sandbox/simpel/src/test/resources/log4j.properties Fri Feb 15 16:17: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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=WARN, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=ERROR
+log4j.category.org.hibernate.type=WARN
+log4j.category.org.objectweb=ERROR
+log4j.category.org.apache.ode=DEBUG
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n