OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | orchestra-commits List | July 2007 Index

<--  Date Index  --> <--  Thread Index  -->

[689] trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util: remove language specific dependencies (XPath) where generic code must be used


Title: [689] trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util: remove language specific dependencies (XPath) where generic code must be used
Revision
689
Author
souillac
Date
2007-07-05 17:46:40 +0200 (Thu, 05 Jul 2007)

Log Message

remove language specific dependencies (XPath) where generic code must be used

Modified Paths

Added Paths

Diff

Modified: trunk/OrchestraPVM/modules/deployment/src/main/java/org/ow2/orchestra/deployment/Deployer.java (688 => 689)


--- trunk/OrchestraPVM/modules/deployment/src/main/java/org/ow2/orchestra/deployment/Deployer.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/deployment/src/main/java/org/ow2/orchestra/deployment/Deployer.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -66,6 +66,7 @@
 
     Namespaces namespaces = new Namespaces(parse);
     parse.pushObject(namespaces);
+    parse.pushObject(context);
 
     BpelProcess bpelProcess = new BpelProcess();
     StyleSheetRepository styleSheetRepository = new StyleSheetRepository();

Modified: trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/VariableRuntime.java (688 => 689)


--- trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/VariableRuntime.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/VariableRuntime.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -16,14 +16,11 @@
 import java.util.HashMap;
 
 import javax.wsdl.Part;
-import javax.xml.namespace.QName;
 
 import org.jbpm.util.Log;
 import org.ow2.orchestra.execution.element.Variable;
-import org.ow2.orchestra.util.BpelUtil;
 import org.ow2.orchestra.var.InformationItem;
 import org.ow2.orchestra.var.Message;
-import org.w3c.dom.Node;
 
 /**
  * @author Charles Souillard
@@ -103,51 +100,6 @@
   }
 
   /**
-   * Return the XPath Variable Binding of a WS-BPEL variable.
-   * @param variable The WS-BPEL variable binding.
-   * @param part : if the Variable is defined with a messageType, we return the
-   * XPath variable Binding of the part given in parameter.
-   * if they are still not initiliazed.
-   * @return the XPath variable
-   */
-  public static Object getVariableXPathBinding(VariableRuntime variable, String part) {
-    if (variable == null) {
-      return null;
-    }
-    if (variable.getVariableDefinition().getMessageType() != null) {
-      Message mess = (Message)variable.getValue();
-      InformationItem ii = mess.getPartII(part);
-      Node rootElement = ii.getRootElement();
-      return ((Message)variable.getValue()).getPartII(part).getRootElement();
-    } else if (variable.getVariableDefinition().getElement() != null) {
-      return ((InformationItem) variable.getValue()).getRootElement();
-    } else if (variable.getVariableDefinition().getType() != null) {
-      //TODO : see if it is a simple type
-      //and see which kind of type it is
-      QName type = variable.getVariableDefinition().getType();
-      if (BpelUtil.isXmlSchemaNs(type.getNamespaceURI())) {
-        //it is a simple type
-        String stringValue = ((InformationItem) variable.getValue()).getTextContent();
-        if (stringValue == null) {
-          return (String) null;
-        }
-        if (type.getLocalPart().equals("integer")) {
-          return new Double(stringValue);
-        }
-
-        if (type.getLocalPart().equals("boolean")) {
-          return new Boolean(stringValue);
-        }
-        //DEFAUT: ->String transformation
-        return stringValue;
-      } else {
-        return ((InformationItem) variable.getValue()).getRootElement();
-      }
-    }
-    return null;
-  }
-
-  /**
    * This method must be called only if the variable is not a message.
    * @return true is the variable is already initialized
    * @throws Exception exception

Modified: trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/FromTo.java (688 => 689)


--- trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/FromTo.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/FromTo.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -84,10 +84,9 @@
    */
   public InformationItem retrieveII(BpelExecution execution) throws Exception {
     if (variant == EXPRESSIONVARIANT) {
-      // TODO : replace with _expression_ Executor
       ExpressionExecutor expressionExecutor =
         ExpressionExecutor.getExpressionExecutor(_expression_.getLanguage(), execution.getContext());
-      return (InformationItem) expressionExecutor.executeGeneralExpression(_expression_, execution);
+      return (InformationItem) expressionExecutor.executeGeneralExpression(_expression_, execution, this instanceof To);
     } else if (variant == VARIABLEVARIANT) {
       if (query == null) {
         VariableRuntime var = execution.getVariableByName(variable);
@@ -107,10 +106,10 @@
       //the query is not null
       //we set the content of the query
       QueryExecutor queryExecutor = QueryExecutor.getQueryExecutor(query.getLanguage(), execution.getContext());
-      return queryExecutor.executeQuery(query, execution, this instanceof From);
+      return queryExecutor.executeQuery(query, execution);
     } else if (variant == PROPERTYVARIANT) {
       QueryExecutor queryExecutor = QueryExecutor.getQueryExecutor(query.getLanguage(), execution.getContext());
-      return queryExecutor.executeQuery(query, execution, this instanceof From);
+      return queryExecutor.executeQuery(query, execution);
 
     } else if (variant == PARTNERLINKVARIANT) {
       if (endpointReference != null) {

Modified: trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/To.java (688 => 689)


--- trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/To.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/execution/src/main/java/org/ow2/orchestra/execution/element/To.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -28,7 +28,7 @@
   /**
    * If the to-spec returns a variable defined with a simple type, we store the variableName
    * of this variable in the simpleTypeVariableName. Indeed, this variable must not be transformed
-   * in a simple XPath type (a String for exemple).
+   * in a simple type (a String for exemple).
    */
   private String simpleTypeVariableName;
 

Modified: trunk/OrchestraPVM/modules/parsing/src/main/java/org/ow2/orchestra/parsing/binding/AssignBinding.java (688 => 689)


--- trunk/OrchestraPVM/modules/parsing/src/main/java/org/ow2/orchestra/parsing/binding/AssignBinding.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/parsing/src/main/java/org/ow2/orchestra/parsing/binding/AssignBinding.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -16,6 +16,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jbpm.ctx.Context;
 import org.jbpm.util.Log;
 import org.jbpm.xml.Parse;
 import org.jbpm.xml.Parser;
@@ -31,7 +32,8 @@
 import org.ow2.orchestra.execution.element.Variable;
 import org.ow2.orchestra.util.BpelUtil;
 import org.ow2.orchestra.util._expression_;
-import org.ow2.orchestra.util.Language;
+import org.ow2.orchestra.util.LanguageProcessor;
+import org.ow2.orchestra.util.LanguageResolver;
 import org.ow2.orchestra.util.Query;
 import org.ow2.orchestra.util.XmlConstants;
 import org.ow2.orchestra.var.InformationItem;
@@ -144,15 +146,6 @@
     //we look if the variable returned is a simple type variable
     if (to.getVariant() == FromTo.EXPRESSIONVARIANT) {
       _expression_ _expression_ = to.getExpression();
-
-      if (_expression_.getLanguage() == Language.XPath) {
-        String expressionString = _expression_.getExpression();
-        if (expressionString.charAt(0) == '$') {
-          String subString = expressionString.substring(1);
-          variable = enclosingScope.findVariable(subString);
-        }
-      }
-
     } else if (to.getVariant() == FromTo.VARIABLEVARIANT || to.getVariant() == FromTo.PROPERTYVARIANT) {
       variable = enclosingScope.findVariable(to.getVariable());
 
@@ -223,30 +216,18 @@
         fromTo.setExpressionLanguage(bpelProcess.getExpressionLanguage());
       }
       String expressionString = _expression_.getExpression();
-      if (expressionString.charAt(0) == '$') {
-        String subString = expressionString.substring(1);
-        Variable variable = enclosingScope.findVariable(subString);
+      Context context = parse.findObject(Context.class);
+
+      LanguageProcessor processor = (LanguageProcessor) context.find(LanguageProcessor.getLanguageProcessorKey(
+              LanguageResolver.getLanguageFromString(fromTo.getExpressionLanguage())));
+      String messageVariableName = processor.getMessageFromExpression(expressionString);
+      if (messageVariableName != null) {
+        Variable variable = enclosingScope.findVariable(messageVariableName);
         if (variable != null && variable.getMessageType() != null) {
-          fromTo.setMessageTypeVariableReturned(subString);
-        } else if (variable != null && variable.getMessageType() == null) {
-          fromTo.setVariable(subString);
-        } else if (subString.contains(".")) {
-          String[] tabString = subString.split("\\.");
-          if (tabString.length > 0) {
-            String varName = tabString[0];
-            if (varName != null) {
-              variable = enclosingScope.findVariable(varName);
-              try {
-                if (bpelProcess.getWsdlInfos().getMessage(variable.getMessageType()).getPart(tabString[1]) != null) {
-                  fromTo.setPart(tabString[1]);
-                }
-              } catch (ClassCastException ex) {
-                System.err.println("Class cast exception");
-              }
-            }
-          }
+          fromTo.setMessageTypeVariableReturned(messageVariableName);
         }
       }
+
     }
   }
 

Added: trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util/LanguageProcessor.java (688 => 689)


--- trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util/LanguageProcessor.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util/LanguageProcessor.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2006  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library 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
+ * version 2.1 of the License.
+ * This library 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
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.ow2.orchestra.util;
+
+import org.jbpm.ctx.Context;
+
+/**
+ *
+ * @author Charles Souillard
+ */
+public abstract class LanguageProcessor {
+
+  /** key to use to find an object in the wiring context. */
+  public static final String DEFAULT_KEY = "languageProcessor_";
+
+  /**
+   * Return the queryExecutor able to execute a query using the given queryLanguage.
+   * @param language language of the query
+   * @param context context
+   * @return the queryExecutor able to execute a query using the given queryLanguage.
+   */
+  public static LanguageProcessor getLanguageProcessor(Language language, Context context) {
+    String key = getLanguageProcessorKey(language);
+    return (LanguageProcessor) context.find(key);
+  }
+
+  /**
+   * Return the key of the queryExecutor.
+   * @param language language
+   * @return the key of the queryExecutor.
+   */
+  public static String getLanguageProcessorKey(Language language) {
+    return DEFAULT_KEY + language.toString();
+  }
+
+  /**
+   * Return the message represented by the given _expression_.
+   * If the expressions format represents something else than a variable (unique and without part)
+   * return null.
+   * @param _expression_ _expression_ to analyze
+   * @return the message represented by the given _expression_.
+   * If the expressions format represents something else than a variable (unique and without part)
+   * return null.
+   */
+  public abstract String getMessageFromExpression(String _expression_);
+}
+
+
Property changes on: trunk/OrchestraPVM/modules/util/src/main/java/org/ow2/orchestra/util/LanguageProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenExpressionExecutor.java (688 => 689)


--- trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenExpressionExecutor.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenExpressionExecutor.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -29,6 +29,17 @@
 public class JaxenExpressionExecutor extends ExpressionExecutor {
 
   /**
+   * processor.
+   */
+  private JaxenProcessor processor;
+
+  /**
+   * Default constructor.
+   */
+  public JaxenExpressionExecutor() {
+    processor = new JaxenProcessor();
+  }
+  /**
    * Evaluates the given boolean _expression_ using the given parameters.
    * @param _expression_ _expression_ to evaluate
    * @param execution execution
@@ -39,7 +50,7 @@
    */
   private boolean executeBooleanExpression(_expression_ _expression_,
       BpelExecution execution, SimpleVariableContext xpathContext, boolean useBpelFunctions) throws Exception {
-    XPath xpath = JaxenProcessor.getXPath(_expression_.getExpression(),
+    XPath xpath = processor.getXPath(_expression_.getExpression(),
         execution, xpathContext, _expression_.getNamespaces(), useBpelFunctions);
     xpath.setVariableContext(xpathContext);
 
@@ -72,7 +83,7 @@
       BpelExecution execution) throws Exception {
     String xpathExpr = _expression_.getExpression();
     //we look for links in the query
-    SimpleVariableContext variableContext = JaxenProcessor.getVariableContextFromString(xpathExpr, execution, false);
+    SimpleVariableContext variableContext = processor.getVariableContextFromString(xpathExpr, execution, false);
     return executeBooleanExpression(_expression_, execution, variableContext, true);
   }
 
@@ -93,16 +104,17 @@
    * Executes the given general _expression_ and return the resulted object.
    * @param _expression_ _expression_ to execute
    * @param execution execution
+   * @param hasToInitializeVariable hasToInitializeVariable
    * @return the resulting object of the _expression_ evaluation
    * @throws Exception exception
    */
   public InformationItem executeGeneralExpression(_expression_ _expression_,
-      BpelExecution execution) throws Exception {
+      BpelExecution execution, boolean hasToInitializeVariable) throws Exception {
     String xpathExpr = _expression_.getExpression();
     try {
       SimpleVariableContext xpathContext =
-        JaxenProcessor.getVariableContextFromString(xpathExpr, execution, true);
-      return JaxenProcessor.executeGeneralXpathExpr(xpathExpr, execution,
+        processor.getVariableContextFromString(xpathExpr, execution, hasToInitializeVariable);
+      return processor.executeGeneralXpathExpr(xpathExpr, execution,
           xpathContext, _expression_.getNamespaces(), null, true);
 
     } catch (Exception e) {
@@ -146,7 +158,7 @@
    */
   private SimpleVariableContext getLinkContextFromQuery(String xpathExpr, BpelExecution execution) throws Exception {
     SimpleVariableContext variableContext = new SimpleVariableContext();
-    List<String> links = JaxenProcessor.extractVariables(xpathExpr);
+    List<String> links = (new JaxenProcessor()).extractVariables(xpathExpr);
     for (String linkName : links) {
       Boolean linkStatus = execution.getFlowRuntime(linkName).getLinkStatus(linkName);
       variableContext.setVariableValue(linkName, linkStatus);

Modified: trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenProcessor.java (688 => 689)


--- trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenProcessor.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenProcessor.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -17,6 +17,8 @@
 import java.util.HashMap;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+
 import org.jaxen.JaxenException;
 import org.jaxen.SimpleFunctionContext;
 import org.jaxen.SimpleVariableContext;
@@ -25,22 +27,20 @@
 import org.jaxen.dom.DOMXPath;
 import org.ow2.orchestra.execution.BpelExecution;
 import org.ow2.orchestra.execution.VariableRuntime;
+import org.ow2.orchestra.util.BpelUtil;
+import org.ow2.orchestra.util.LanguageProcessor;
 import org.ow2.orchestra.util.XmlConstants;
 import org.ow2.orchestra.var.InformationItem;
+import org.ow2.orchestra.var.Message;
 import org.w3c.dom.Node;
 
 /**
  *
  * @author Charles Souillard
  */
-public final class JaxenProcessor {
+public class JaxenProcessor extends LanguageProcessor {
 
   /**
-   * Private constructor.
-   */
-  private JaxenProcessor() { }
-
-  /**
    * Execute the query with the environment given in parameter.
    * @param xpathExpr : xpathExpr which will be executed.
    * @param execution execution
@@ -52,7 +52,7 @@
    * @throws Exception exception
    */
   @SuppressWarnings("unchecked")
-  public static XPath getXPath(String xpathExpr, BpelExecution execution,
+  public XPath getXPath(String xpathExpr, BpelExecution execution,
       SimpleVariableContext xpathContext, HashMap<String, String> namespaces, boolean useBpelFunctions)
     throws Exception {
     try {
@@ -91,7 +91,7 @@
    * @throws Exception exception
    */
   @SuppressWarnings("unchecked")
-  public static InformationItem executeGeneralXpathExpr(String xpathExpr, BpelExecution execution,
+  public InformationItem executeGeneralXpathExpr(String xpathExpr, BpelExecution execution,
       SimpleVariableContext xpathContext, HashMap<String, String> namespaces, Object contextObject, boolean useBpelFunctions)
     throws Exception {
     XPath xpath = getXPath(xpathExpr, execution,
@@ -134,7 +134,7 @@
    * @param car : character tested
    * @return : the boolean answer
    */
-  public static boolean isASeparator(char car) {
+  public boolean isASeparator(char car) {
     return car == '"' || car == '/' || car == '[' || car == ']' || car == ',' || car == '(' || car == ')'
       || car == '+' || car == '*' || car == '-';
   }
@@ -147,7 +147,7 @@
    * @return a populated variable context
    * @throws Exception exception
    */
-  public static SimpleVariableContext getVariableContextFromString(String xpathExpr, BpelExecution execution,
+  public SimpleVariableContext getVariableContextFromString(String xpathExpr, BpelExecution execution,
       boolean hasToInitializeVariable) throws Exception {
 
     SimpleVariableContext variableContext = new SimpleVariableContext();
@@ -161,16 +161,36 @@
         if (hasToInitializeVariable && !variableRuntime.isPartInitialized(partName)) {
           variableRuntime.initializePart(execution, partName);
         }
+        /*
         variableContext.setVariableValue(variable,
-            VariableRuntime.getVariableXPathBinding(variableRuntime, partName));
+            VariableRuntime.getVariableXPathBinding(variableRuntime, null));
+         */
+        if (!hasToInitializeVariable) {
+          variableContext.setVariableValue(variable,
+              getVariableXPathBinding(variableRuntime, partName));
+        } else {
+          variableContext.setVariableValue(variable,((Message)variableRuntime.getValue()).getPartII(partName).getRootElement());
+        }
 
+
       } else {
         VariableRuntime variableRuntime = execution.getVariableByName(variable);
         if (hasToInitializeVariable && !variableRuntime.isIIInitialized()) {
           variableRuntime.initializeII(execution);
         }
+        /*
         variableContext.setVariableValue(variable,
             VariableRuntime.getVariableXPathBinding(variableRuntime, null));
+         */
+
+        if (!hasToInitializeVariable) {
+          variableContext.setVariableValue(variable,
+              getVariableXPathBinding(variableRuntime, null));
+        } else {
+          variableContext.setVariableValue(variable,
+              ((InformationItem)variableRuntime.getValue()).getRootElement());
+        }
+
       }
     }
     return variableContext;
@@ -180,7 +200,7 @@
    * @param xpathExpr _expression_ to analyze
    * @return all variables of the xpath _expression_ : $a and $a.part.
    */
-  public static List<String> extractVariables(String xpathExpr) {
+  public List<String> extractVariables(String xpathExpr) {
     List<String> variables = new ArrayList<String>();
 
     if (xpathExpr != null) {
@@ -202,7 +222,7 @@
    * @param s string to analyze
    * @return the index of the next separator in the given string. The string length else.
    */
-  private static int getIndexOfNextSeparator(String s) {
+  private int getIndexOfNextSeparator(String s) {
     char[] chars = s.toCharArray();
     for (int i = 0; i < chars.length; i++) {
       if (isASeparator(chars[i])) {
@@ -212,6 +232,73 @@
     return s.length();
   }
 
+  /**
+   * Return the message represented by the given _expression_.
+   * If the expressions format represents something else than a variable (unique and without part)
+   * return null.
+   * @param _expression_ _expression_ to analyze
+   * @return the message represented by the given _expression_.
+   * If the expressions format represents something else than a variable (unique and without part)
+   * return null.
+   */
+  public String getMessageFromExpression(String _expression_) {
+    String withoutSpaces = _expression_.trim();
+    List<String> variables = extractVariables(withoutSpaces);
+    if (variables.size() != 1) {
+      return null;
+    }
+    String variable = variables.get(0);
+    if (variable.length() == (withoutSpaces.length() - 1)) {
+      return variable;
+    }
+    return null;
+  }
+
+  /**
+   * Return the XPath Variable Binding of a WS-BPEL variable.
+   * @param variable The WS-BPEL variable binding.
+   * @param part : if the Variable is defined with a messageType, we return the
+   * XPath variable Binding of the part given in parameter.
+   * if they are still not initiliazed.
+   * @return the XPath variable
+   */
+  public static Object getVariableXPathBinding(VariableRuntime variable, String part) {
+    if (variable == null) {
+      return null;
+    }
+    if (variable.getVariableDefinition().getMessageType() != null) {
+      Message mess = (Message)variable.getValue();
+      InformationItem ii = mess.getPartII(part);
+      Node rootElement = ii.getRootElement();
+      return ((Message)variable.getValue()).getPartII(part).getRootElement();
+    } else if (variable.getVariableDefinition().getElement() != null) {
+      return ((InformationItem) variable.getValue()).getRootElement();
+    } else if (variable.getVariableDefinition().getType() != null) {
+      //TODO : see if it is a simple type
+      //and see which kind of type it is
+      QName type = variable.getVariableDefinition().getType();
+      if (BpelUtil.isXmlSchemaNs(type.getNamespaceURI())) {
+        //it is a simple type
+        String stringValue = ((InformationItem) variable.getValue()).getTextContent();
+        if (stringValue == null) {
+          return (String) null;
+        }
+        if (type.getLocalPart().equals("integer")) {
+          return new Double(stringValue);
+        }
+
+        if (type.getLocalPart().equals("boolean")) {
+          return new Boolean(stringValue);
+        }
+        //DEFAUT: ->String transformation
+        return stringValue;
+      } else {
+        return ((InformationItem) variable.getValue()).getRootElement();
+      }
+    }
+    return null;
+  }
+
 }
 
 

Modified: trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenQueryExecutor.java (688 => 689)


--- trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenQueryExecutor.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/modules/xpath/src/main/java/org/ow2/orchestra/xpath/JaxenQueryExecutor.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -15,7 +15,6 @@
 
 import org.jaxen.SimpleVariableContext;
 import org.ow2.orchestra.execution.BpelExecution;
-import org.ow2.orchestra.execution.VariableRuntime;
 import org.ow2.orchestra.execution.function.QueryExecutor;
 import org.ow2.orchestra.util.Query;
 import org.ow2.orchestra.var.InformationItem;
@@ -25,29 +24,39 @@
  */
 public class JaxenQueryExecutor extends QueryExecutor {
 
+  /**
+   * processor.
+   */
+  private JaxenProcessor processor;
 
   /**
+   * Default constructor.
+   */
+  public JaxenQueryExecutor() {
+    processor = new JaxenProcessor();
+  }
+
+  /**
    * Execute the query with the environment given in parameter.
    * @param query : query which will be executed.
    * @param execution execution
-   * @param hasToInitializeVariable :indicate if variable used in _expression_ or query have to be initialized.
    * @return the InformationItem selectionned. May be an informationItem or a name of variable
    * which is a variable.
    * @throws Exception exception
    */
   @SuppressWarnings("unchecked")
-  public InformationItem executeQuery(Query query, BpelExecution execution, boolean hasToInitializeVariable) throws Exception {
+  public InformationItem executeQuery(Query query, BpelExecution execution) throws Exception {
     String xpathExpr = query.getExpression();
 
     try {
-      Object contextObject = VariableRuntime.getVariableXPathBinding(
+      Object contextObject = JaxenProcessor.getVariableXPathBinding(
           execution.getVariableByName(query.getContextNodeVariableName()),
           query.getContextNodePartName());
 
       //we look for variables in the query
       SimpleVariableContext xpathContext =
-        JaxenProcessor.getVariableContextFromString(xpathExpr, execution, hasToInitializeVariable);
-      return JaxenProcessor.executeGeneralXpathExpr(xpathExpr, execution,
+        processor.getVariableContextFromString(xpathExpr, execution, false);
+      return processor.executeGeneralXpathExpr(xpathExpr, execution,
           xpathContext, query.getNamespaces(), contextObject, true);
 
     } catch (Exception e) {

Modified: trunk/OrchestraPVM/tests/functionnal/src/main/java/org/ow2/orchestra/tests/functionnal/BpelTestCase.java (688 => 689)


--- trunk/OrchestraPVM/tests/functionnal/src/main/java/org/ow2/orchestra/tests/functionnal/BpelTestCase.java	2007-07-05 13:17:53 UTC (rev 688)
+++ trunk/OrchestraPVM/tests/functionnal/src/main/java/org/ow2/orchestra/tests/functionnal/BpelTestCase.java	2007-07-05 15:46:40 UTC (rev 689)
@@ -50,12 +50,14 @@
 import org.ow2.orchestra.tests.functionnal.TestInvoker.ServiceInvocation;
 import org.ow2.orchestra.util.BpelUtil;
 import org.ow2.orchestra.util.Language;
+import org.ow2.orchestra.util.LanguageProcessor;
 import org.ow2.orchestra.util.XmlConstants;
 import org.ow2.orchestra.var.InformationItem;
 import org.ow2.orchestra.var.Message;
 import org.ow2.orchestra.var.MessagePart;
 import org.ow2.orchestra.xpath.JaxenExpressionExecutor;
 import org.ow2.orchestra.xpath.JaxenGetVariablePropertyFunction;
+import org.ow2.orchestra.xpath.JaxenProcessor;
 import org.ow2.orchestra.xpath.JaxenQueryExecutor;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -108,6 +110,7 @@
         + getObjectDecl(GetVariablePropertyFunction.DEFAULT_KEY, JaxenGetVariablePropertyFunction.class)
         + getObjectDecl(ExpressionExecutor.getExpressionExecutorKey(Language.XPath), JaxenExpressionExecutor.class)
         + getObjectDecl(QueryExecutor.getQueryExecutorKey(Language.XPath), JaxenQueryExecutor.class)
+        + getObjectDecl(LanguageProcessor.getLanguageProcessorKey(Language.XPath), JaxenProcessor.class)
         + "  </application>"
         + "  <context-block>"
         + "  </context-block>"


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.