[jbpm-commits] JBoss JBPM SVN: r5416 - in jbpm4/trunk/modules/bpmn: src/main and 7 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 3 20:10:58 EDT 2009


Author: kukeltje
Date: 2009-08-03 20:10:58 -0400 (Mon, 03 Aug 2009)
New Revision: 5416

Added:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java
   jbpm4/trunk/modules/bpmn/src/main/lib/
   jbpm4/trunk/modules/bpmn/src/main/lib/bsh-engine.jar
   jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java
   jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml
Removed:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java
Modified:
   jbpm4/trunk/modules/bpmn/pom.xml
   jbpm4/trunk/modules/bpmn/src/main/java/com/sun/script/xpath/XPathScriptEngine.java
   jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
   jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java
   jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/exclusiveGatewayXPath.bpmn.xml
Log:
Initial ScriptTask, extended xpath expression

Modified: jbpm4/trunk/modules/bpmn/pom.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/pom.xml	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/pom.xml	2009-08-04 00:10:58 UTC (rev 5416)
@@ -49,6 +49,11 @@
       <artifactId>jbpm-test-base</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+    	<groupId>org.beanshell</groupId>
+    	<artifactId>bsh</artifactId>
+    	<version>2.0b4</version>
+    </dependency>
   </dependencies>
 
 </project>
\ No newline at end of file

Modified: jbpm4/trunk/modules/bpmn/src/main/java/com/sun/script/xpath/XPathScriptEngine.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/com/sun/script/xpath/XPathScriptEngine.java	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/main/java/com/sun/script/xpath/XPathScriptEngine.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -56,385 +56,385 @@
 
 import com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput;
 
-public class XPathScriptEngine extends AbstractScriptEngine 
-        implements Compilable {
-    // my factory, may be null
-    private ScriptEngineFactory factory;
-    private XPathFactory xpathFactory;
+public class XPathScriptEngine extends AbstractScriptEngine implements Compilable {
 
-    // special context variables for XPath result type and input
-    public static final String XPATH_RESULT_TYPE = "com.sun.script.xpath.resultType";
-    public static final String XPATH_INPUT_SRC = "com.sun.script.xpath.inputSource";
+  // my factory, may be null
+  private ScriptEngineFactory factory;
+  private XPathFactory xpathFactory;
 
-    // XML namespace prefixes and URIs.
-    public static final String XMLNS_COLON = "xmlns:";
-    public static final String XPATH_CONTEXT_PREFIX = "context";
-    public static final String XPATH_CONTEXT_URI = "http://www.sun.com/java/jsr223/xpath/context";
-    
-    private Document objectData;
+  // special context variables for XPath result type and input
+  public static final String XPATH_RESULT_TYPE = "com.sun.script.xpath.resultType";
+  public static final String XPATH_INPUT_SRC = "com.sun.script.xpath.inputSource";
 
-    public XPathScriptEngine() {
-        xpathFactory = XPathFactory.newInstance();
-    }
+  // XML namespace prefixes and URIs.
+  public static final String XMLNS_COLON = "xmlns:";
+  public static final String XPATH_CONTEXT_PREFIX = "context";
+  public static final String XPATH_CONTEXT_URI = "http://www.sun.com/java/jsr223/xpath/context";
 
-    // my implementation for CompiledScript
-    private class XPathCompiledScript extends CompiledScript {
-        private XPathExpression expr;
+  private Document objectData;
 
-        XPathCompiledScript (XPathExpression expr) {
-            this.expr = expr;
-        }
+  public XPathScriptEngine() {
+    xpathFactory = XPathFactory.newInstance();
+  }
 
-        public ScriptEngine getEngine() {
-            return XPathScriptEngine.this;
-        }
+  // my implementation for CompiledScript
+  private class XPathCompiledScript extends CompiledScript {
 
-        public Object eval(ScriptContext ctx) throws ScriptException {
-            return evalXPath(expr, ctx);
-        }
+    private XPathExpression expr;
+
+    XPathCompiledScript(XPathExpression expr) {
+      this.expr = expr;
     }
 
-    public CompiledScript compile (String script) throws ScriptException {
-        XPathExpression expr = compileXPath(script, context);
-        return new XPathCompiledScript(expr);
+    public ScriptEngine getEngine() {
+      return XPathScriptEngine.this;
     }
 
-    public CompiledScript compile (Reader reader) throws ScriptException {
-        return compile(readFully(reader));
+    public Object eval(ScriptContext ctx) throws ScriptException {
+      return evalXPath(expr, ctx);
     }
+  }
 
-    public Object eval(String str, ScriptContext ctx) 
-                       throws ScriptException { 
-        XPathExpression expr = compileXPath(str, ctx);
-        return evalXPath(expr, ctx);
+  public CompiledScript compile(String script) throws ScriptException {
+    XPathExpression expr = compileXPath(script, context);
+    return new XPathCompiledScript(expr);
+  }
+
+  public CompiledScript compile(Reader reader) throws ScriptException {
+    return compile(readFully(reader));
+  }
+
+  public Object eval(String str, ScriptContext ctx) throws ScriptException {
+    XPathExpression expr = compileXPath(str, ctx);
+    return evalXPath(expr, ctx);
+  }
+
+  public Object eval(Reader reader, ScriptContext ctx) throws ScriptException {
+    return eval(readFully(reader), ctx);
+  }
+
+  public ScriptEngineFactory getFactory() {
+    synchronized (this) {
+      if (factory == null) {
+        factory = new XPathScriptEngineFactory();
+      }
     }
+    return factory;
+  }
 
-    public Object eval(Reader reader, ScriptContext ctx)
-                       throws ScriptException {
-        return eval(readFully(reader), ctx);
+  public Bindings createBindings() {
+    return new SimpleBindings();
+  }
+
+  void setFactory(ScriptEngineFactory factory) {
+    this.factory = factory;
+  }
+
+  // Internals only below this point
+
+  // find a variable of given qname in given context
+  private static Object findVariable(QName qname, ScriptContext ctx) {
+    String name;
+    int scope;
+
+    if (XPATH_CONTEXT_URI.equals(qname.getNamespaceURI())) {
+      name = qname.getLocalPart();
+      synchronized (ctx) {
+        scope = ctx.getAttributesScope(name);
+        if (scope != -1) {
+          return ctx.getAttribute(name, scope);
+        } // else fallthru
+      }
     }
+    if (qname.getPrefix() == null || "".equals(qname.getPrefix())) {
+      name = qname.getLocalPart();
+    } else {
+      name = qname.getPrefix() + ":" + qname.getLocalPart();
+    }
+    synchronized (ctx) {
+      scope = ctx.getAttributesScope(name);
+      if (scope != -1) {
+        return ctx.getAttribute(name, scope);
+      } // else fallthru
+    }
+    return null;
+  }
 
-    public ScriptEngineFactory getFactory() {
-    synchronized (this) {
-        if (factory == null) {
-            factory = new XPathScriptEngineFactory();
+  private static void collectNamespaces(Map<String, String> map, Bindings scope) {
+    for (String key : scope.keySet()) {
+      if (key.startsWith(XMLNS_COLON)) {
+        Object uri = scope.get(key);
+        // collect all variables starting with "xmlns:" and
+        // collect the prefix to URI mappings.
+        String prefix = key.substring(XMLNS_COLON.length());
+        if (uri instanceof String) {
+          String tmp = (String) uri;
+          if (tmp.length() != 0) {
+            map.put(prefix, tmp);
+          }
         }
-        }
-    return factory;
+      }
     }
+  }
 
-    public Bindings createBindings() {
-        return new SimpleBindings();
+  private static NamespaceContext makeNamespaceContext(ScriptContext ctx) {
+    // namespace prefix-to-URI mappings
+    final Map<String, String> namespaces = new HashMap<String, String>();
+    for (int scope : ctx.getScopes()) {
+      Bindings bind = ctx.getBindings(scope);
+      if (bind != null) {
+        // TODO: See what needs to be done....
+        // collectNamespaces(namespaces, bind);
+      }
     }
 
-
-    void setFactory(ScriptEngineFactory factory) {
-        this.factory = factory;
+    // look for mapping for default XML namespace
+    Object def = ctx.getAttribute(XMLConstants.XMLNS_ATTRIBUTE);
+    if (def instanceof String) {
+      namespaces.put(XMLConstants.DEFAULT_NS_PREFIX, (String) def);
     }
 
-  
-    // Internals only below this point
+    // standard required mappings by XPath standard
+    namespaces.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
+    namespaces.put(XMLConstants.XMLNS_ATTRIBUTE, XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
 
-    // find a variable of given qname in given context  
-    private static Object findVariable(QName qname, ScriptContext ctx) {
-        String name;
-        int scope;
+    // add prefix mapping for XPATH_CONTEXT_PREFIX
+    namespaces.put(XPATH_CONTEXT_PREFIX, XPATH_CONTEXT_URI);
 
-        if (XPATH_CONTEXT_URI.equals(qname.getNamespaceURI())) {
-            name = qname.getLocalPart();
-            synchronized (ctx) {
-                scope = ctx.getAttributesScope(name);
-                if (scope != -1) {
-                    return ctx.getAttribute(name, scope);
-                } // else fallthru
-            }
-        } 
-        name = qname.getPrefix() + ":" + qname.getLocalPart();
-        synchronized (ctx) {
-            scope = ctx.getAttributesScope(name);
-            if (scope != -1) {
-                return ctx.getAttribute(name, scope);
-            } // else fallthru
+    return new NamespaceContext() {
+
+      public String getNamespaceURI(String prefix) {
+        if (prefix == null) {
+          throw new IllegalArgumentException();
         }
-        return null;        
-    }
-   
-    private static void collectNamespaces(Map<String, String> map, Bindings scope) {   
-        for (String key : scope.keySet()) {
-            if (key.startsWith(XMLNS_COLON)) {
-                Object uri = scope.get(key); 
-                // collect all variables starting with "xmlns:" and
-                // collect the prefix to URI mappings.               
-                String prefix = key.substring(XMLNS_COLON.length());
-                if (uri instanceof String) {
-                    String tmp = (String) uri;
-                    if (tmp.length() != 0) {
-                        map.put(prefix, tmp);
-                    }
-                }
-            }
+        String uri = namespaces.get(prefix);
+        if (uri == null) {
+          return XMLConstants.NULL_NS_URI;
+        } else {
+          return uri;
         }
-    }
+      }
 
-    private static NamespaceContext makeNamespaceContext(ScriptContext ctx) {
-        // namespace prefix-to-URI mappings
-        final Map<String, String> namespaces = new HashMap<String, String>();
-        for (int scope : ctx.getScopes()) {
-            Bindings bind = ctx.getBindings(scope);
-            if (bind != null) {                
-              // TODO: See what needs to be done.... 
-              //collectNamespaces(namespaces, bind);                 
-            }
+      public String getPrefix(String namespaceURI) {
+        if (namespaceURI == null) {
+          throw new IllegalArgumentException();
         }
+        for (String prefix : namespaces.keySet()) {
+          String uri = namespaces.get(prefix);
+          if (namespaceURI.equals(uri)) {
+            return prefix;
+          }
+        }
+        return null;
+      }
 
-        // look for mapping for default XML namespace
-        Object def = ctx.getAttribute(XMLConstants.XMLNS_ATTRIBUTE);
-        if (def instanceof String) {
-            namespaces.put(XMLConstants.DEFAULT_NS_PREFIX, (String)def);            
+      public Iterator getPrefixes(String namespaceURI) {
+        if (namespaceURI == null) {
+          throw new IllegalArgumentException();
         }
-        
-        // standard required mappings by XPath standard
-        namespaces.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
-        namespaces.put(XMLConstants.XMLNS_ATTRIBUTE, XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
+        List list = new ArrayList();
+        for (String prefix : namespaces.keySet()) {
+          String uri = namespaces.get(prefix);
+          if (namespaceURI.equals(uri)) {
+            list.add(prefix);
+          }
+        }
+        return Collections.unmodifiableList(list).iterator();
+      }
+    };
+  }
 
-        // add prefix mapping for XPATH_CONTEXT_PREFIX
-        namespaces.put(XPATH_CONTEXT_PREFIX, XPATH_CONTEXT_URI);
+  private static XPathFunction makeXPathFunction(final Constructor ctr, int arity) {
+    if (ctr.getParameterTypes().length != arity) {
+      return null;
+    }
+    return new XPathFunction() {
 
-        return new NamespaceContext() {
-            public String getNamespaceURI(String prefix) {
-                if (prefix == null) {
-                    throw new IllegalArgumentException();
-                }
-                String uri = namespaces.get(prefix);
-                if (uri == null) {
-                    return XMLConstants.NULL_NS_URI;
-                } else {
-                    return uri;
-                }
-            }
+      public Object evaluate(List args) {
+        try {
+          return ctr.newInstance(args.toArray());
+        } catch (Exception exp) {
+          throw new RuntimeException(exp);
+        }
+      }
+    };
+  }
 
-            public String getPrefix(String namespaceURI) {
-                if (namespaceURI == null) {
-                    throw new IllegalArgumentException();
-                }
-                for (String prefix : namespaces.keySet()) {
-                    String uri = namespaces.get(prefix);
-                    if (namespaceURI.equals(uri)) {
-                        return prefix;
-                    }
-                }
-                return null;
-            }
+  private static XPathFunction makeXPathFunction(final Method method, int arity) {
+    int modifiers = method.getModifiers();
+    int numArgs = method.getParameterTypes().length;
+    if (Modifier.isStatic(modifiers) && numArgs == arity) {
+      // static method. expose "as is".
+      return new XPathFunction() {
 
-            public Iterator getPrefixes(String namespaceURI) {
-                if (namespaceURI == null) {
-                    throw new IllegalArgumentException();
-                }
-                List list = new ArrayList();
-                for (String prefix : namespaces.keySet()) {
-                    String uri = namespaces.get(prefix);
-                    if (namespaceURI.equals(uri)) {
-                        list.add(prefix);
-                    }
-                }
-                return Collections.unmodifiableList(list).iterator();
-            }
-        };
-    }
+        public Object evaluate(List args) {
+          try {
+            return method.invoke(null, args.toArray());
+          } catch (Exception exp) {
+            throw new RuntimeException(exp);
+          }
+        }
+      };
+    } else if ((numArgs + 1) == arity) {
+      // instance method. treat the first arg as 'this'
+      return new XPathFunction() {
 
-    private static XPathFunction makeXPathFunction(final Constructor ctr, int arity) {
-        if (ctr.getParameterTypes().length != arity) {
-            return null;
+        public Object evaluate(List args) {
+          List tmp = args.subList(1, args.size());
+          try {
+            return method.invoke(args.get(0), tmp.toArray());
+          } catch (Exception exp) {
+            throw new RuntimeException(exp);
+          }
         }
-        return new XPathFunction() {
-            public Object evaluate(List args) {
-                try {
-                    return ctr.newInstance(args.toArray());
-                } catch (Exception exp) {
-                    throw new RuntimeException(exp);
-                }
-            }
-        };
+      };
+    } else {
+      return null;
     }
+  }
 
-    private static XPathFunction makeXPathFunction(final Method method, int arity) {
-        int modifiers = method.getModifiers();
-        int numArgs = method.getParameterTypes().length;
-        if (Modifier.isStatic(modifiers) && numArgs == arity) {
-            // static method. expose "as is".
-            return new XPathFunction() {
-                public Object evaluate(List args) {
-                    try {
-                        return method.invoke(null, args.toArray());
-                    } catch (Exception exp) {
-                        throw new RuntimeException(exp);
-                    }
-                }
-            };             
-        } else if ((numArgs + 1) == arity) {
-            // instance method. treat the first arg as 'this'
-            return new XPathFunction() {
-                public Object evaluate(List args) {
-                    List tmp = args.subList(1, args.size());
-                    try {
-                        return method.invoke(args.get(0), tmp.toArray());
-                    } catch (Exception exp) {
-                        throw new RuntimeException(exp);
-                    }
-                }
-            };
-        } else {
-            return null;
+  private static XPathFunction makeXPathFunction(final String funcName, final Invocable invocable) {
+    return new XPathFunction() {
+
+      public Object evaluate(List args) {
+        try {
+          return invocable.invokeFunction(funcName, args.toArray());
+        } catch (Exception exp) {
+          throw new RuntimeException(exp);
         }
-    }
+      }
+    };
+  }
 
-    private static XPathFunction makeXPathFunction(final String funcName,
-                                   final Invocable invocable) {
-       return new XPathFunction() {
-            public Object evaluate(List args) {
-                try {
-                    return invocable.invokeFunction(funcName, args.toArray());
-                } catch (Exception exp) {
-                    throw new RuntimeException(exp);
-                }
-            }
-        };
+  // make a XPathFunction from given object
+  private static XPathFunction makeXPathFunction(QName qname, Object obj, int arity) {
+    if (obj == null) {
+      return null;
+    } else if (obj instanceof XPathFunction) {
+      // already XPathFunction - just return
+      return (XPathFunction) obj;
+    } else if (obj instanceof Method) {
+      // a Method object. wrap as XPathFunction
+      return makeXPathFunction((Method) obj, arity);
+    } else if (obj instanceof Constructor) {
+      // a Constructor object. wrap as XPathFunction
+      return makeXPathFunction((Constructor) obj, arity);
+    } else if (obj instanceof Invocable) {
+      // wrap a script function as XPathFunction. Using this,
+      // scripts from other languages (for eg. JavaScript) can use
+      // this engine and pass script functions as XPathFunction extensions
+
+      return makeXPathFunction(qname.getLocalPart(), (Invocable) obj);
+    } else {
+      // can't map the object as XPathFunction.
+      return null;
     }
+  }
 
+  // Internals only below this point
+  private XPathExpression compileXPath(String str, final ScriptContext ctx) throws ScriptException {
+    // JSR-223 requirement
+    ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
+    try {
+      XPath xpath = xpathFactory.newXPath();
+      xpath.setXPathVariableResolver(new XPathVariableResolver() {
 
-    // make a XPathFunction from given object
-    private static XPathFunction makeXPathFunction(QName qname, Object obj, int arity) {
-        if (obj == null) {
-            return null;
-        } else if (obj instanceof XPathFunction) {
-            // already XPathFunction - just return
-            return (XPathFunction) obj;
-        } else if (obj instanceof Method) {
-            // a Method object. wrap as XPathFunction
-            return makeXPathFunction((Method)obj, arity);          
-        } else if (obj instanceof Constructor) {
-            // a Constructor object. wrap as XPathFunction
-            return makeXPathFunction((Constructor)obj, arity);
-        } else if (obj instanceof Invocable) {
-            // wrap a script function as XPathFunction. Using this,
-            // scripts from other languages (for eg. JavaScript) can use
-            // this engine and pass script functions as XPathFunction extensions
+        public Object resolveVariable(QName qname) {
+          return findVariable(qname, ctx);
+        }
+      });
 
-            return makeXPathFunction(qname.getLocalPart(), (Invocable)obj);
-        } else {
-            // can't map the object as XPathFunction.
-            return null;
+      xpath.setXPathFunctionResolver(new XPathFunctionResolver() {
+
+        public XPathFunction resolveFunction(QName qname, int arity) {
+          Object obj = findVariable(qname, ctx);
+          return makeXPathFunction(qname, obj, arity);
         }
-    }
-    
-    // Internals only below this point
-    private XPathExpression compileXPath(String str, final ScriptContext ctx) 
-                                         throws ScriptException {
-        // JSR-223 requirement
-        ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
-        try {
-            XPath xpath = xpathFactory.newXPath();
-            xpath.setXPathVariableResolver(new XPathVariableResolver() {
-                        public Object resolveVariable(QName qname) {
-                            return findVariable(qname, ctx);
-                        }
-                    });
+      });
+      xpath.setNamespaceContext(makeNamespaceContext(ctx));
+      // xpath.setNamespaceContext(new BpmnFunctionResolver());
+      // xpath.setXPathFunctionResolver(new BpmnFunctionResolver());
+      int begin = str.indexOf("getObjectData") > -1 ? 14 : 0;
+      if (begin > 0) {
+        String objectDataRef = str.substring(begin + 1, str.indexOf(")") - 1);
 
-            xpath.setXPathFunctionResolver(new XPathFunctionResolver() {
-                        public XPathFunction resolveFunction(QName qname, int arity) {
-                            Object obj = findVariable(qname, ctx);
-                            return makeXPathFunction(qname, obj, arity);                            
-                        }
-                    });
-            xpath.setNamespaceContext(makeNamespaceContext(ctx));
-            //xpath.setNamespaceContext(new BpmnFunctionResolver());
-            //xpath.setXPathFunctionResolver(new BpmnFunctionResolver());
-            int begin = str.indexOf("getObjectData") > -1 ? 14 : 0;
-            if (begin > 0 ) {
-              String objectDataRef = str.substring(begin+1, str.indexOf(")")-1);
-              
-              objectData = (Document) ctx.getAttribute(objectDataRef);
-              //ctx.setAttribute(XPATH_INPUT_SRC, objectData , 100);
+        objectData = (Document) ctx.getAttribute(objectDataRef);
+        // ctx.setAttribute(XPATH_INPUT_SRC, objectData , 100);
 
-              ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-              Source xmlSource = new DOMSource(objectData);
-              Result outputTarget = new StreamResult(outputStream);
-              TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
-              InputStream is = new ByteArrayInputStream(outputStream.toByteArray());
-              ctx.setReader(new InputStreamReader(is));
-             
-              str = str.substring(str.indexOf(")")+1); 
-            }
-            XPathExpression xpe = xpath.compile(str); 
-            return xpe;
-        } catch (Exception exp) {
-            throw new ScriptException(exp);
-        }
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        Source xmlSource = new DOMSource(objectData);
+        Result outputTarget = new StreamResult(outputStream);
+        TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
+        InputStream is = new ByteArrayInputStream(outputStream.toByteArray());
+        ctx.setReader(new InputStreamReader(is));
+
+        str = str.substring(str.indexOf(")") + 1);
+      }
+      XPathExpression xpe = xpath.compile(str);
+      return xpe;
+    } catch (Exception exp) {
+      throw new ScriptException(exp);
     }
+  }
 
-    private Object getVariable(ScriptContext ctx, String name) {
-        synchronized (ctx) {
-            int scope = ctx.getAttributesScope(name);
-            if (scope != -1) {
-                return ctx.getAttribute(name, scope);
-            }
-        }
-        return null;
+  private Object getVariable(ScriptContext ctx, String name) {
+    synchronized (ctx) {
+      int scope = ctx.getAttributesScope(name);
+      if (scope != -1) {
+        return ctx.getAttribute(name, scope);
+      }
     }
-    private Object evalXPath(XPathExpression expr, final ScriptContext ctx) 
-                            throws ScriptException {
+    return null;
+  }
+  private Object evalXPath(XPathExpression expr, final ScriptContext ctx) throws ScriptException {
 
-        try {
-            Object resultType = getVariable(ctx, XPATH_RESULT_TYPE);       
-            Object input = getVariable(ctx, XPATH_INPUT_SRC);
-            
-            InputSource src;
-            if (input == null) {
-                // no input specified, use context reader
-                src = new InputSource(ctx.getReader());
-            } else {
-                // explicit InputSource specified
-                if (input instanceof InputSource) {
-                    src = (InputSource) input;
-                } else if (input instanceof String) {
-                    src = new InputSource((String)input);
-                } else if (input instanceof Reader) {
-                    src = new InputSource((Reader)input);
-                } else if (input instanceof InputStream) {
-                    src = new InputSource((InputStream)input);   
-                } else {
-                    // some other object input type specified (Node/NodeList)
-                    src = null;                    
-                }
-            }
-            
-            resultType = XPathConstants.BOOLEAN;
-            
-            if (resultType instanceof QName) {
-                return (src != null) ?  
-                    expr.evaluate(src, (QName) resultType) :
-                    expr.evaluate(input, (QName) resultType);
-            } else {
-                return (src != null) ?
-                    expr.evaluate(src) :
-                    expr.evaluate(input);
-            }
-        } catch (Exception exp) {
-            throw new ScriptException(exp);
+    try {
+      Object resultType = getVariable(ctx, XPATH_RESULT_TYPE);
+      Object input = getVariable(ctx, XPATH_INPUT_SRC);
+
+      InputSource src;
+      if (input == null) {
+        // no input specified, use context reader
+        src = new InputSource(ctx.getReader());
+      } else {
+        // explicit InputSource specified
+        if (input instanceof InputSource) {
+          src = (InputSource) input;
+        } else if (input instanceof String) {
+          src = new InputSource((String) input);
+        } else if (input instanceof Reader) {
+          src = new InputSource((Reader) input);
+        } else if (input instanceof InputStream) {
+          src = new InputSource((InputStream) input);
+        } else {
+          // some other object input type specified (Node/NodeList)
+          src = null;
         }
+      }
+
+      resultType = XPathConstants.BOOLEAN;
+
+      if (resultType instanceof QName) {
+        return (src != null) ? expr.evaluate(src, (QName) resultType) : expr.evaluate(input, (QName) resultType);
+      } else {
+        return (src != null) ? expr.evaluate(src) : expr.evaluate(input);
+      }
+    } catch (Exception exp) {
+      throw new ScriptException(exp);
     }
+  }
 
-    private String readFully(Reader reader) throws ScriptException { 
-        char[] arr = new char[8*1024]; // 8K at a time
-        StringBuilder buf = new StringBuilder();
-        int numChars;
-        try {
-            while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
-                buf.append(arr, 0, numChars);
-            }
-        } catch (IOException exp) {
-            throw new ScriptException(exp);
-        }
-        return buf.toString();
+  private String readFully(Reader reader) throws ScriptException {
+    char[] arr = new char[8 * 1024]; // 8K at a time
+    StringBuilder buf = new StringBuilder();
+    int numChars;
+    try {
+      while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
+        buf.append(arr, 0, numChars);
+      }
+    } catch (IOException exp) {
+      throw new ScriptException(exp);
     }
+    return buf.toString();
+  }
 }

Modified: jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml	2009-08-04 00:10:58 UTC (rev 5416)
@@ -1,11 +1,23 @@
 <activities>
-  <activity binding="org.jbpm.bpmn.flownodes.StartBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.UserTaskBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.ServiceActivityBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.ReceiveBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.ParallelGatewayBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.ExclusiveGatewayBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.ManualTaskBinding" />
-  <activity binding="org.jbpm.bpmn.flownodes.TaskBinding" />
+	
+	<!--  -->
+	<activity binding="org.jbpm.bpmn.flownodes.StartBinding" />
+	<activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
+	
+	<!-- Gateway bindings -->
+	<activity binding="org.jbpm.bpmn.flownodes.ExclusiveGatewayBinding" />
+	<activity binding="org.jbpm.bpmn.flownodes.ParallelGatewayBinding" />
+	
+	<!--  -->
+	<activity binding="org.jbpm.bpmn.flownodes.ReceiveBinding" />
+	
+	<!-- Task bindings -->
+	<activity binding="org.jbpm.bpmn.flownodes.ManualTaskBinding" />
+    <activity binding="org.jbpm.bpmn.flownodes.ScriptTaskBinding" />
+    <activity binding="org.jbpm.bpmn.flownodes.ServiceTaskBinding" />
+	<activity binding="org.jbpm.bpmn.flownodes.TaskBinding" />
+	<activity binding="org.jbpm.bpmn.flownodes.UserTaskBinding" />
+
 </activities>
+
+

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ExpressionEvaluator;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
+
+public class ScriptTaskActivity extends BpmnAutomaticActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  private ExpressionEvaluatorDescriptor script;
+
+  public void perform(ExecutionImpl execution) throws Exception {
+    try {
+      
+      //TODO: return values etc...
+      ((ExpressionEvaluator) WireContext.create(script)).evaluateExpression(execution);
+
+    } catch (Exception e) {
+      throw new WireException("couldn't run script: " + e.getMessage(), e);
+    }
+  }
+
+  public void setScript(ExpressionEvaluatorDescriptor expressionDescriptor) {
+    this.script = expressionDescriptor;
+  }
+
+  public ExpressionEvaluatorDescriptor getScript() {
+    return this.script;
+  }
+  
+}

Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+public class ScriptTaskBinding extends BpmnBinding {
+
+  
+  public ScriptTaskBinding() {
+    super("scriptTask");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ScriptTaskActivity scriptTaskActivity = new ScriptTaskActivity();
+
+    String scriptLanguage = XmlUtil.attribute(element, "scriptLanguage");    
+    String script = XmlUtil.element(element, "script").getTextContent();
+    if (script != null) {
+      ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(script, scriptLanguage);
+      scriptTaskActivity.setScript(expressionDescriptor);
+    }
+
+    return scriptTaskActivity;
+  }
+}

Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -1,208 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.bpmn.flownodes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.wire.WireException;
-
-public class ServiceActivity extends BpmnAutomaticActivity {
-
-  private static final long serialVersionUID = 1L;
-
-  public static class Data {
-    private String id;
-    private String xmlSchemaType;
-  }
-
-  public static class Assignment {
-    private String fromExpression;
-    private String toExpression;
-  }
-
-  // inputs
-  Data inputData = null; // more than one allowed in BPMN 2
-  List<Assignment> inputAssociation = new ArrayList<Assignment>();
-
-  // outputs
-  Data outputData = null; // more than one allowed in BPMN 2
-  List<Assignment> outputAssociation = new ArrayList<Assignment>();
-
-  // endpoint and binding
-  private String operation;
-  private String endpointAddress;
-  private String portName;
-  private String serviceName;
-
-  public void perform(ExecutionImpl execution) throws Exception {
-    try {
-      callWebservice();
-    } catch (Exception e) {
-      throw new WireException("couldn't invoke WS " + operation + ": " + e.getMessage(), e);
-    }
-  }
-
-  private void callWebservice() {
-    System.out.println("calling ws: " + getOperation());
-    // // Qnames for service as defined in wsdl.
-    // QName serviceName =
-    // new QName(getNamespace(), getServiceName());
-    //
-    // //QName for Port As defined in wsdl.
-    // QName portName =
-    // new QName(getNamespace(), getPort());
-    //
-    // //Endpoint Address
-    // String endpointAddress = getEndpointAdress();
-    //
-    // // Create a dynamic Service instance
-    // Service service = Service.create(serviceName);
-    //
-    // // Add a port to the Service
-    // service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
-    // endpointAddress);
-    //
-    // //Create a dispatch instance
-    // Dispatch<SOAPMessage> dispatch =
-    // service.createDispatch(portName, SOAPMessage.class,
-    // Service.Mode.MESSAGE);
-    //
-    // // Use Dispatch as BindingProvider
-    // BindingProvider bp = (BindingProvider) dispatch;
-    //
-    // // Optionally Configure RequestContext to send SOAPAction HTTP Header
-    // Map<String, Object> rc = bp.getRequestContext();
-    // rc.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
-    // rc.put(BindingProvider.SOAPACTION_URI_PROPERTY, "hello");
-    //
-    // // Obtain a preconfigured SAAJ MessageFactory
-    // MessageFactory factory =
-    // ((SOAPBinding) bp.getBinding()).getMessageFactory();
-    //
-    // // Create SOAPMessage Request
-    // SOAPMessage request = factory.createMessage();
-    //
-    // // Request Header
-    // SOAPHeader header = request.getSOAPHeader();
-    //
-    // // Request Body
-    // SOAPBody body = request.getSOAPBody();
-    //
-    // // Compose the soap:Body payload
-    // QName payloadName =
-    // new QName("http://www.example.com/schemas/HelloWorld", "hello",
-    // "ns1");
-    //
-    // SOAPBodyElement payload = body.addBodyElement(payloadName);
-    //
-    // SOAPElement message = payload.addChildElement("message");
-    //
-    // message.addTextNode("Hello World!");
-    //
-    // // Invoke the endpoint synchronously
-    // SOAPMessage reply = null;
-    //
-    // try {
-    // //Invoke Endpoint Operation and read response
-    // reply = dispatch.invoke(request);
-    // } catch (WebServiceException wse){
-    // wse.printStackTrace();
-    // }
-    //
-    // // process the reply
-    // body = reply.getSOAPBody();
-    //
-    // QName responseName =
-    // new QName("http://www.example.com/schemas/HelloWorld",
-    // "helloResponse");
-    //
-    // SOAPBodyElement bodyElement =
-    // body.getChildElements(responseName).next());
-    // String message = bodyElement.getValue();
-  }
-
-  public Data getInputData() {
-    return inputData;
-  }
-
-  public void setInputData(Data inputData) {
-    this.inputData = inputData;
-  }
-
-  public List<Assignment> getInputAssociation() {
-    return inputAssociation;
-  }
-
-  public void setInputAssociation(List<Assignment> inputAssociation) {
-    this.inputAssociation = inputAssociation;
-  }
-
-  public Data getOutputData() {
-    return outputData;
-  }
-
-  public void setOutputData(Data outputData) {
-    this.outputData = outputData;
-  }
-
-  public List<Assignment> getOutputAssociation() {
-    return outputAssociation;
-  }
-
-  public void setOutputAssociation(List<Assignment> outputAssociation) {
-    this.outputAssociation = outputAssociation;
-  }
-
-  public String getOperation() {
-    return operation;
-  }
-
-  public void setOperation(String operation) {
-    this.operation = operation;
-  }
-
-  public String getEndpointAddress() {
-    return endpointAddress;
-  }
-
-  public void setEndpointAddress(String endpointAddress) {
-    this.endpointAddress = endpointAddress;
-  }
-
-  public String getPortName() {
-    return portName;
-  }
-
-  public void setPortName(String portName) {
-    this.portName = portName;
-  }
-
-  public String getServiceName() {
-    return serviceName;
-  }
-
-  public void setServiceName(String serviceName) {
-    this.serviceName = serviceName;
-  }
-}

Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.bpmn.flownodes;
-
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-public class ServiceActivityBinding extends BpmnBinding {
-
-  
-  public ServiceActivityBinding() {
-    super("serviceTask");
-  }
-
-  public Object parse(Element element, Parse parse, Parser parser) {
-    ServiceActivity wsActivity = new ServiceActivity();
-
-    String methodName = XmlUtil.attribute(element, "operationRef", true, parse, null);
-//    javaActivity.setMethodName(methodName);
-
-    String variableName = XmlUtil.attribute(element, "var");
-//    javaActivity.setVariableName(variableName);
-
-//    List<Element> argElements = XmlUtil.elements(element, "arg");
-//    if (!argElements.isEmpty()) {
-//      List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
-//      InvokeOperation invokeOperation = new InvokeOperation();
-//      invokeOperation.setArgDescriptors(argDescriptors);
-//      javaActivity.setInvokeOperation(invokeOperation);
-//    }
-//
-//    if (element.hasAttribute("class")) {
-//      ObjectDescriptor objectDescriptor = JpdlParser.parseObjectDescriptor(element, parse);
-//      javaActivity.setTargetDescriptor(objectDescriptor);
-//
-//    } else if (element.hasAttribute("expr")) {
-//      String expression = element.getAttribute("expr");
-//      javaActivity.setTargetExpression(expression);
-//      javaActivity.setTargetLanguage(XmlUtil.attribute(element, "lang"));
-//    
-//    } else {
-//      // parse.addProblem("no target specified in "+TAG+": must specify attribute 'class' or 'expr'", element);
-//    }
-     
-    return wsActivity;
-  }
-}

Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskActivity.java (from rev 5382, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivity.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskActivity.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.WireException;
+
+public class ServiceTaskActivity extends BpmnAutomaticActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public static class Data {
+    private String id;
+    private String xmlSchemaType;
+  }
+
+  public static class Assignment {
+    private String fromExpression;
+    private String toExpression;
+  }
+
+  // inputs
+  Data inputData = null; // more than one allowed in BPMN 2
+  List<Assignment> inputAssociation = new ArrayList<Assignment>();
+
+  // outputs
+  Data outputData = null; // more than one allowed in BPMN 2
+  List<Assignment> outputAssociation = new ArrayList<Assignment>();
+
+  // endpoint and binding
+  private String operation;
+  private String endpointAddress;
+  private String portName;
+  private String serviceName;
+
+  public void perform(ExecutionImpl execution) throws Exception {
+    try {
+      callWebservice();
+    } catch (Exception e) {
+      throw new WireException("couldn't invoke WS " + operation + ": " + e.getMessage(), e);
+    }
+  }
+
+  private void callWebservice() {
+    System.out.println("calling ws: " + getOperation());
+    // // Qnames for service as defined in wsdl.
+    // QName serviceName =
+    // new QName(getNamespace(), getServiceName());
+    //
+    // //QName for Port As defined in wsdl.
+    // QName portName =
+    // new QName(getNamespace(), getPort());
+    //
+    // //Endpoint Address
+    // String endpointAddress = getEndpointAdress();
+    //
+    // // Create a dynamic Service instance
+    // Service service = Service.create(serviceName);
+    //
+    // // Add a port to the Service
+    // service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
+    // endpointAddress);
+    //
+    // //Create a dispatch instance
+    // Dispatch<SOAPMessage> dispatch =
+    // service.createDispatch(portName, SOAPMessage.class,
+    // Service.Mode.MESSAGE);
+    //
+    // // Use Dispatch as BindingProvider
+    // BindingProvider bp = (BindingProvider) dispatch;
+    //
+    // // Optionally Configure RequestContext to send SOAPAction HTTP Header
+    // Map<String, Object> rc = bp.getRequestContext();
+    // rc.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+    // rc.put(BindingProvider.SOAPACTION_URI_PROPERTY, "hello");
+    //
+    // // Obtain a preconfigured SAAJ MessageFactory
+    // MessageFactory factory =
+    // ((SOAPBinding) bp.getBinding()).getMessageFactory();
+    //
+    // // Create SOAPMessage Request
+    // SOAPMessage request = factory.createMessage();
+    //
+    // // Request Header
+    // SOAPHeader header = request.getSOAPHeader();
+    //
+    // // Request Body
+    // SOAPBody body = request.getSOAPBody();
+    //
+    // // Compose the soap:Body payload
+    // QName payloadName =
+    // new QName("http://www.example.com/schemas/HelloWorld", "hello",
+    // "ns1");
+    //
+    // SOAPBodyElement payload = body.addBodyElement(payloadName);
+    //
+    // SOAPElement message = payload.addChildElement("message");
+    //
+    // message.addTextNode("Hello World!");
+    //
+    // // Invoke the endpoint synchronously
+    // SOAPMessage reply = null;
+    //
+    // try {
+    // //Invoke Endpoint Operation and read response
+    // reply = dispatch.invoke(request);
+    // } catch (WebServiceException wse){
+    // wse.printStackTrace();
+    // }
+    //
+    // // process the reply
+    // body = reply.getSOAPBody();
+    //
+    // QName responseName =
+    // new QName("http://www.example.com/schemas/HelloWorld",
+    // "helloResponse");
+    //
+    // SOAPBodyElement bodyElement =
+    // body.getChildElements(responseName).next());
+    // String message = bodyElement.getValue();
+  }
+
+  public Data getInputData() {
+    return inputData;
+  }
+
+  public void setInputData(Data inputData) {
+    this.inputData = inputData;
+  }
+
+  public List<Assignment> getInputAssociation() {
+    return inputAssociation;
+  }
+
+  public void setInputAssociation(List<Assignment> inputAssociation) {
+    this.inputAssociation = inputAssociation;
+  }
+
+  public Data getOutputData() {
+    return outputData;
+  }
+
+  public void setOutputData(Data outputData) {
+    this.outputData = outputData;
+  }
+
+  public List<Assignment> getOutputAssociation() {
+    return outputAssociation;
+  }
+
+  public void setOutputAssociation(List<Assignment> outputAssociation) {
+    this.outputAssociation = outputAssociation;
+  }
+
+  public String getOperation() {
+    return operation;
+  }
+
+  public void setOperation(String operation) {
+    this.operation = operation;
+  }
+
+  public String getEndpointAddress() {
+    return endpointAddress;
+  }
+
+  public void setEndpointAddress(String endpointAddress) {
+    this.endpointAddress = endpointAddress;
+  }
+
+  public String getPortName() {
+    return portName;
+  }
+
+  public void setPortName(String portName) {
+    this.portName = portName;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+}

Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java (from rev 5382, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceActivityBinding.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+public class ServiceTaskBinding extends BpmnBinding {
+
+  
+  public ServiceTaskBinding() {
+    super("serviceTask");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ServiceTaskActivity wsActivity = new ServiceTaskActivity();
+
+    String methodName = XmlUtil.attribute(element, "operationRef", true, parse, null);
+//    javaActivity.setMethodName(methodName);
+
+    
+    String variableName = XmlUtil.attribute(element, "var");
+//    javaActivity.setVariableName(variableName);
+
+//    List<Element> argElements = XmlUtil.elements(element, "arg");
+//    if (!argElements.isEmpty()) {
+//      List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+//      InvokeOperation invokeOperation = new InvokeOperation();
+//      invokeOperation.setArgDescriptors(argDescriptors);
+//      javaActivity.setInvokeOperation(invokeOperation);
+//    }
+//
+//    if (element.hasAttribute("class")) {
+//      ObjectDescriptor objectDescriptor = JpdlParser.parseObjectDescriptor(element, parse);
+//      javaActivity.setTargetDescriptor(objectDescriptor);
+//
+//    } else if (element.hasAttribute("expr")) {
+//      String expression = element.getAttribute("expr");
+//      javaActivity.setTargetExpression(expression);
+//      javaActivity.setTargetLanguage(XmlUtil.attribute(element, "lang"));
+//    
+//    } else {
+//      // parse.addProblem("no target specified in "+TAG+": must specify attribute 'class' or 'expr'", element);
+//    }
+     
+    return wsActivity;
+  }
+}

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -179,7 +179,9 @@
 
       TagBinding activityBinding = (TagBinding) getBinding(nestedElement, CATEGORY_ACTIVITY);
       if (activityBinding == null) {
-        log.debug("unrecognized activity: " + tagName);
+        if (!"sequenceFlow".equals(tagName)) {
+          log.debug("unrecognized activity: " + tagName);
+        }
         continue;
       }
 
@@ -228,7 +230,6 @@
         }
       }
 
-      //compositeElement.findActivity(sourceRef).add
       compositeElement.findActivity(targetRef).addIncomingTransition(transition);
 
       transition.setName(transitionId);

Added: jbpm4/trunk/modules/bpmn/src/main/lib/bsh-engine.jar
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/bpmn/src/main/lib/bsh-engine.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -142,7 +142,8 @@
         Document objectData;
         
         objectData = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(this.getClass().getResourceAsStream("xmlTestDocument.xml"));
-        variables.put("test", objectData);
+        variables.put("justadocument", objectData);
+        variables.put("test", "just");
         
         ProcessInstance pi = executionService.startProcessInstanceByKey("ExclusiveGateway", variables );
         String pid = pi.getId();

Added: jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.dom4j.DocumentFactory;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.TaskQuery;
+import org.jbpm.api.task.Task;
+import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Problem;
+import org.jbpm.test.JbpmTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Tom Baeyens
+ * @author Ronald van Kuijk (kukeltje)
+ */
+public class ScriptTaskTest extends JbpmTestCase {
+
+  static BpmnParser bpmnParser = new BpmnParser();
+
+  public List<Problem> parse(String resource) {
+
+    List<Problem> problems = bpmnParser.createParse().setResource(resource).execute().getProblems();
+
+    return problems;
+  }
+
+  public void testNormal() {
+
+    List<Problem> problems = parse("org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml");
+
+    if (!problems.isEmpty()) {
+      fail("No problems should have occured. Problems: " + problems);
+    }
+  }
+  
+  public void testNormalExecute() {
+
+    String deploymentId = repositoryService.createDeployment().addResourceFromClasspath("org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml").deploy();
+
+    try {
+        Map variables = new HashMap();
+        String[] values = {"st", "nd", "rd", "th", "th"}; 
+        variables.put("test", values);
+        
+        ProcessInstance pi = executionService.startProcessInstanceByKey("ScriptTask", variables );
+        String pid = pi.getId();
+
+        // process instance should be ended
+        pi = executionService.findProcessInstanceById(pid);
+        assertNull(pi);
+        
+    }
+    finally {
+        repositoryService.deleteDeploymentCascade(deploymentId);
+    }
+  }
+}

Modified: jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/exclusiveGatewayXPath.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/exclusiveGatewayXPath.bpmn.xml	2009-08-03 18:34:11 UTC (rev 5415)
+++ jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/exclusiveGatewayXPath.bpmn.xml	2009-08-04 00:10:58 UTC (rev 5416)
@@ -19,7 +19,7 @@
 
 		<bpmn:sequenceFlow id="flow2" sourceRef="exclusiveGatewayDecision"
 			targetRef="doSomething">
-			<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression" language="xpath">getObjectData("test")/root/child1/text()="just"</bpmn:conditionExpression>
+			<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression" language="xpath">getObjectData("justadocument")/root/child1/text()=$test</bpmn:conditionExpression>
 		</bpmn:sequenceFlow>
 		<bpmn:sequenceFlow id="flow3" sourceRef="exclusiveGatewayDecision"
 			targetRef="doSomethingElse">

Added: jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml	                        (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/flownodes/scriptTask.bpmn.xml	2009-08-04 00:10:58 UTC (rev 5416)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions id="ExclusiveGatewayNormal"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../main/resources/BPMN20.xsd"
+	xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+	expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/">
+
+	<bpmn:process id="ScriptTask" name="ScriptTask">
+		<!-- Start-Event -->
+		<bpmn:startEvent id="Start" />
+
+		<bpmn:sequenceFlow id="flow1" sourceRef="Start"
+			targetRef="scriptTask" name="Start->ScriptTask" />
+
+		<bpmn:scriptTask id="scriptTask" name="Script Task"
+			scriptLanguage="bsh">
+			<bpmn:script><![CDATA[
+for(int i=0;i<5;i++){
+  System.out.println((i+1) + test[i] + " universe");
+}]]>
+</bpmn:script>
+		</bpmn:scriptTask>
+		<bpmn:sequenceFlow id="flow2" sourceRef="scriptTask"
+			targetRef="End" />
+
+		<!-- End Events -->
+		<bpmn:endEvent id="End" name="End" />
+	</bpmn:process>
+</bpmn:definitions>



More information about the jbpm-commits mailing list