incubator-agila-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r165042 [16/30] - in /incubator/agila/trunk: ./ config/ modules/ modules/bpel/ modules/bpel/client/ modules/bpel/client/api/ modules/bpel/client/api/src/ modules/bpel/client/api/src/conf/ modules/bpel/client/api/src/java/ modules/bpel/client/api/src/java/org/ modules/bpel/client/api/src/java/org/apache/ modules/bpel/client/api/src/java/org/apache/agila/ modules/bpel/client/api/src/java/org/apache/agila/bpel/ modules/bpel/client/api/src/java/org/apache/agila/bpel/client/ modules/bpel/client/api/src/test/ modules/bpel/client/api/src/test/junit/ modules/bpel/client/api/src/test/junit/org/ modules/bpel/client/api/src/test/junit/org/apache/ modules/bpel/client/api/src/test/junit/org/apache/agila/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/client/ modules/bpel/client/web/ modules/bpel/client/web/src/ modules/bpel/client/web/src/conf/ modules/bpel/client/web/src/java/ modules/bpel/client/web/src/java/org/ modules/bpel/client/web/src/java/org/apache/ modules/bpel/client/web/src/java/org/apache/agila/ modules/bpel/client/web/src/java/org/apache/agila/bpel/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/common/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/util/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/action/ modules/bpel/client/web/src/webapp/ modules/bpel/client/web/src/webapp/META-INF/ modules/bpel/client/web/src/webapp/WEB-INF/ modules/bpel/client/web/src/webapp/WEB-INF/classes/ modules/bpel/client/web/src/webapp/images/ modules/bpel/client/web/src/webapp/images/audit/ modules/bpel/client/web/src/webapp/style/ modules/bpel/common/ modules/bpel/common/src/ modules/bpel/common/src/aspect/ modules/bpel/common/src/conf/ modules/bpel/common/src/java/ modules/bpel/common/src/java/org/ modules/bpel/common/src/java/org/apache/ modules/bpel/common/src/java/org/apache/agila/ modules/bpel/common/src/java/org/apache/agila/bpel/ modules/bpel/common/src/java/org/apache/agila/bpel/common/ modules/bpel/common/src/java/org/apache/agila/bpel/common/aspect/ modules/bpel/common/src/java/org/apache/agila/bpel/common/configuration/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/logger/ modules/bpel/common/src/test/ modules/bpel/common/src/test/junit/ modules/bpel/common/src/test/junit/org/ modules/bpel/common/src/test/junit/org/apache/ modules/bpel/common/src/test/junit/org/apache/agila/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/util/ modules/bpel/dist/ modules/bpel/dist/src/ modules/bpel/dist/src/java/ modules/bpel/dist/src/java/org/ modules/bpel/dist/src/java/org/apache/ modules/bpel/dist/src/java/org/apache/agila/ modules/bpel/dist/src/java/org/apache/agila/bpel/ modules/bpel/dist/src/java/org/apache/agila/bpel/util/ modules/bpel/dist/src/script/ modules/bpel/engine/ modules/bpel/engine/common/ modules/bpel/engine/common/src/ modules/bpel/engine/common/src/aspect/ modules/bpel/engine/common/src/hibernate/ modules/bpel/engine/common/src/hibernate/org/ modules/bpel/engine/common/src/hibernate/org/apache/ modules/bpel/engine/common/src/hibernate/org/apache/agila/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/ modules/bpel/engine/common/src/java/org/ modules/bpel/engine/common/src/java/org/apache/ modules/bpel/engine/common/src/java/org/apache/agila/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/aspect/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/impl/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/dao/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/monitoring/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/persistence/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/transaction/ modules/bpel/engine/common/src/test/ modules/bpel/engine/common/src/test/junit/ modules/bpel/engine/common/src/test/junit/org/ modules/bpel/engine/common/src/test/junit/org/apache/ modules/bpel/engine/common/src/test/junit/org/apache/agila/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/test/resources/ modules/bpel/engine/core/ modules/bpel/engine/core/src/ modules/bpel/engine/core/src/aspect/ modules/bpel/engine/core/src/hibernate/ modules/bpel/engine/core/src/hibernate/org/ modules/bpel/engine/core/src/hibernate/org/apache/ modules/bpel/engine/core/src/hibernate/org/apache/agila/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/ modules/bpel/engine/core/src/java/org/ modules/bpel/engine/core/src/java/org/apache/ modules/bpel/engine/core/src/java/org/apache/agila/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/exception/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ modules/bpel/engine/core/s
Date Wed, 27 Apr 2005 20:28:07 GMT
Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ProcessInstanceDAO.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ProcessInstanceDAO.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ProcessInstanceDAO.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ProcessInstanceDAO.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.core.dynamic.impl.dao;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.hibernate.Query;
+import net.sf.hibernate.Session;
+
+import org.apache.agila.bpel.engine.common.persistence.DBSessionException;
+import org.apache.agila.bpel.engine.common.persistence.DBSessionManager;
+import org.apache.agila.bpel.engine.common.persistence.FinderException;
+import org.apache.agila.bpel.engine.common.persistence.PersistentDataAccess;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ValuedProperty;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.impl.ProcessInstanceImpl;
+
+public class ProcessInstanceDAO extends PersistentDataAccess {
+
+    private static String FINDBY_CORRELATION =
+            "SELECT DISTINCT instance " +
+            "FROM org.apache.agila.bpel.engine.priv.core.dynamic.impl.ProcessInstanceImpl as instance, " +
+            "instance.properties as props, instance.process.correlationSets as correl, " +
+            "WHERE props.name in (:propNames) and props.value in (:propValues) and correl.name = :corrSetName";
+
+    private static String FINDBY_STATUS =
+            "FROM org.apache.agila.bpel.engine.priv.core.dynamic.impl.ProcessInstanceImpl as instance " +
+            "WHERE instance.status in (:status)";
+
+    public static ProcessInstanceImpl findInstanceByCorrelation(String correlationSetName, Map propertyValues) throws DBSessionException, FinderException {
+        Session session = DBSessionManager.getActiveSession();
+
+        List instances = null;
+        try {
+            Query byProperties = session.createQuery(FINDBY_CORRELATION);
+
+            byProperties.setParameterList("propNames", propertyValues.keySet());
+            byProperties.setParameterList("propValues", propertyValues.values());
+            byProperties.setString("corrSetName", correlationSetName);
+
+            instances = byProperties.list();
+        } catch (net.sf.hibernate.HibernateException e) {
+            throw new DBSessionException(e);
+        }
+
+        // There's no easy way to filtrate a couple of columns to a map, so we have to perform
+        // an additional filtering.
+        ArrayList filteredInstance = new ArrayList();
+        for (int m = 0; m < instances.size(); m++) {
+            ProcessInstanceImpl processInstance = (ProcessInstanceImpl) instances.get(m);
+            boolean isAllreadyCorrelated = true;
+            boolean doesPropExist = false;
+            for (Iterator propsIter = propertyValues.keySet().iterator(); propsIter.hasNext();) {
+              doesPropExist = false;
+              String propName = (String) propsIter.next();
+              Collection vps = processInstance.getProperties();
+              for (Iterator vpsIter = vps.iterator(); vpsIter.hasNext();) {
+                ValuedProperty valuedProperty = (ValuedProperty) vpsIter.next();
+                if (valuedProperty.getCorrSet().equals(correlationSetName) && valuedProperty.getName().equals(propName) && valuedProperty.getValue().equals(propertyValues.get(propName))) {
+                  doesPropExist = true;
+                }
+              }
+              if (!doesPropExist) {
+                isAllreadyCorrelated = false;
+              }
+            }
+            if (isAllreadyCorrelated) {
+             filteredInstance.add(processInstance);
+            }
+        }
+
+        if (filteredInstance.size() == 0) {
+            throw new FinderException("No instances could be found in findInstanceByCorrelation. Possible reasons " +
+                    "are : the provided correlation set doesn't exist (" + correlationSetName + "); the properties " +
+                    "provided do not match the correlation set (" + propertyValues.keySet() + "); the property " +
+                    "values are wrong (" + propertyValues.values() + "); there are simply no instances yet for the " +
+                    "correlation and properties passed.");
+        }
+        if (filteredInstance.size() > 1) {
+            throw new FinderException("More than one process instance has been found in findInstanceByCorrelation " +
+                    "when querying with correlation set " + correlationSetName + " and properties " + propertyValues +
+                    ". Please check your database or contact your DBA as this shouldn't happen.");
+        }
+
+        return (ProcessInstanceImpl) filteredInstance.get(0);
+    }
+
+    public static List findInstanceByStatus(Collection status) throws DBSessionException {
+        Session session = DBSessionManager.getActiveSession();
+        List instances = null;
+        try {
+            Query byStatus = session.createQuery(FINDBY_STATUS);
+
+            byStatus.setParameterList("status", status);
+
+            instances = byStatus.list();
+        } catch (net.sf.hibernate.HibernateException e) {
+            throw new DBSessionException(e);
+        }
+        return instances;
+    }
+
+    public static ProcessInstance findById(Long id) throws FinderException {
+      return (ProcessInstance) PersistentDataAccess.findById(id, ProcessInstanceImpl.class);
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/CorrelationXAO.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/CorrelationXAO.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/CorrelationXAO.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/CorrelationXAO.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.core.dynamic.impl.xao;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.apache.agila.bpel.engine.common.persistence.XMLDataAccess;
+import org.apache.agila.bpel.engine.common.persistence.XMLSessionException;
+import org.xmldb.api.base.Collection;
+
+/**
+ * An XML Access Object specialized for correlations.
+ */
+public class CorrelationXAO extends XMLDataAccess {
+
+    public static void createCorrelation(String processName, String correlationName, Long instanceId, Map properyValues)
+            throws XMLSessionException {
+
+        Collection correlColl = getCollection("/" + processName + "/correlation/");
+        if (correlColl == null) {
+            // Testing if the process collection already exist (doesn't if first execution)
+            Collection processColl = getCollection("/" + processName + "/");
+            if (processColl == null) {
+                // When it doesn't exist, creating it
+                Collection rootColl = getRootCollection();
+                processColl = createCollection(rootColl, processName);
+            }
+            correlColl = createCollection(processColl, "correlation");
+        }
+
+        // Preparing the correlation document
+        Document document = DocumentHelper.createDocument();
+        Element root = document.addElement("correlation")
+                .addAttribute("instanceid", ""+instanceId.longValue());
+        for (Iterator propValuesIter = properyValues.keySet().iterator(); propValuesIter.hasNext();) {
+            String property = (String) propValuesIter.next();
+            root.addElement("property")
+                    .addAttribute("name", property)
+                    .addAttribute("value", (String)properyValues.get(property));
+        }
+
+        // Inserting the document
+        insertDocument(correlColl, correlationName + instanceId.longValue(), document);
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/VariableXAO.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/VariableXAO.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/VariableXAO.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/VariableXAO.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,615 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.core.dynamic.impl.xao;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.IllegalAddException;
+import org.dom4j.Node;
+import org.dom4j.Namespace;
+import org.dom4j.tree.DefaultElement;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom4j.Dom4jXPath;
+import org.jaxen.expr.DefaultAbsoluteLocationPath;
+import org.jaxen.expr.DefaultNameStep;
+import org.apache.agila.bpel.common.util.XMLUtil;
+import org.apache.agila.bpel.engine.common.persistence.FinderException;
+import org.apache.agila.bpel.engine.common.persistence.XMLDataAccess;
+import org.apache.agila.bpel.engine.common.persistence.XMLSessionException;
+import org.xmldb.api.base.Collection;
+import org.jaxen.JaxenException;
+/**
+ * An XML Access Object specialized for variable processing.
+ */
+public class VariableXAO extends XMLDataAccess {
+
+    public static Document getVariable(String processName, String variableName, Long instanceId) throws XMLSessionException, FinderException {
+        Document varDoc = getDocument("/" + processName + "/variable", variableName + instanceId.longValue());
+        return varDoc;
+    }
+
+    /**
+     * Queries a message variable with its part and returns the text of the found
+     * element.
+     * @param processName
+     * @param variableName
+     * @param instanceId
+     * @param part
+     * @param query
+     * @return String text of the found element
+     * @throws XMLSessionException
+     * @throws FinderException
+     */
+    public static String queryVariableValue(String processName,
+            String namespace, String variableName, Long instanceId,
+            String part, String query) throws XMLSessionException,
+            FinderException {
+        // If no query is defined we must return the content of the part, not
+        // the part itself
+        if (query == null || query.length() == 0) {
+            query = "/*";
+        } else if (!query.startsWith("/")) {
+            throw new IllegalArgumentException("The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        String value = queryDocumentForValue(processName, namespace,
+                variableName + instanceId.longValue(), "/" + msgPart + query);
+        return value;
+    }
+
+    /**
+     * Queries a message variable with its part and returns the text of the found
+     * element.
+     * @param processName
+     * @param variableName
+     * @param instanceId
+     * @param part
+     * @param query
+     * @return String text of the found element
+     * @throws XMLSessionException
+     * @throws FinderException
+     */
+    public static String queryVariableValue(String processName, String variableName, Long instanceId, String part, String query) throws XMLSessionException, FinderException {
+        // If no query is defined we must return the content of the part, not the part itself
+        if (query == null || query.length() == 0) {
+            query = "/*";
+        } else if (!query.startsWith("/")) {
+            throw new IllegalArgumentException("The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        String value = queryDocumentForValue(getCollection("/" + processName + "/variable"),
+                variableName + instanceId.longValue(), "/" + msgPart + query );
+        return value;
+    }
+    
+    /**
+     * Returns the single element in a variable found at the specified part and query
+     * location.
+     * @param processName
+     * @param variableName
+     * @param instanceId
+     * @param part
+     * @param query
+     * @return Element the found element
+     * @throws XMLSessionException
+     * @throws FinderException
+     */
+    public static List queryVariable(String processName, String namespace,
+            String variableName, Long instanceId, String part, String query)
+            throws XMLSessionException, FinderException {
+        // If no query is defined we must return the content of the part, not
+        // the part itself
+        if (query == null) {
+            query = "";
+        } else if (!query.startsWith("/") && query.length() > 0) {
+            throw new IllegalArgumentException(
+                    "The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        List result = queryDocument(processName, namespace, variableName
+                + instanceId.longValue(), "/" + msgPart + query);
+
+        return result;
+    }
+
+    /**
+     * Returns the single element in a variable found at the specified part and query
+     * location.
+     * @param processName
+     * @param variableName
+     * @param instanceId
+     * @param part
+     * @param query
+     * @return Element the found element
+     * @throws XMLSessionException
+     * @throws FinderException
+     */
+    public static List queryVariable(String processName, String variableName, Long instanceId, String part, String query) throws XMLSessionException, FinderException {
+        // If no query is defined we must return the content of the part, not the part itself
+        if (query == null) {
+            query = "";
+        } else if (!query.startsWith("/") && query.length() > 0) {
+            throw new IllegalArgumentException("The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        List result = queryDocument(getCollection("/" + processName + "/variable"),
+                variableName + instanceId.longValue(), "/" + msgPart + query );
+
+        return result;
+    }
+
+    /**
+     * Creates a variable corresponding to a message, the provided element must
+     * therefore be a 'message' element containing its parts.
+     * @param processName
+     * @param variableName
+     * @param instanceId
+     * @param msg
+     * @throws XMLSessionException
+     */
+    public static void createVariable(String processName, String variableName, Long instanceId, Document msg) throws XMLSessionException {
+        if (!"message".equals(msg.getRootElement().getName())) {
+            throw new IllegalArgumentException("The provided message element must be named 'message");
+        }
+        Collection varColl = initializeVariableCollection(processName);
+
+        // Inserting the document
+        insertDocument(varColl, variableName + instanceId.longValue(), msg);
+    }
+
+    public static void setVariableElement(String processName, String namespace,
+            String variableName, Long instanceId, String part, String query,
+            Node element) throws XMLSessionException {
+
+        if (query == null)
+            query = "";
+        if (!query.startsWith("/") && (query.length() > 0)) {
+            throw new IllegalArgumentException(
+                    "The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        Collection processVariables = initializeVariableCollection(processName);
+
+        Document sourceDoc = null;
+        try {
+            sourceDoc = getDocument(processVariables, variableName
+                    + instanceId.longValue());
+        } catch (FinderException e) {
+            // Nothing to do, if a finder exception is thrown sourceDoc will be
+            // null
+        }
+        Document docRef = null;
+        Map namespaceMap = null;
+        try {
+
+            docRef = getDocument(getCollection("/process"), ""
+                    + (namespace + processName).hashCode());
+            namespaceMap = getPrefixesNamespaces(docRef, query);
+        } catch (FinderException e) {
+            throw new XMLSessionException("could not find proces:" + namespace
+                    + processName, e);
+        } catch (XMLSessionException e) {
+            throw new XMLSessionException(e);
+        }
+
+        if (sourceDoc == null) {
+            Document newDoc = DocumentHelper.createDocument();
+
+            buildDocumentFromPath(newDoc, part, query, element, true,
+                    namespaceMap);
+            Document cleanCopy = XMLUtil.cleanCopy(newDoc);
+            insertDocument(processVariables, variableName
+                    + instanceId.longValue(), cleanCopy);
+        } else {
+            //TODO: tu to musi tiez prejst cez namespacing
+            Node elmtToChange = null;
+            try{
+                Map set = getPrefixesNamespaces(docRef, "/" + msgPart + query);
+                Dom4jXPath xp = new Dom4jXPath("/" + msgPart + query);
+                xp.setNamespaceContext(new SimpleNamespaceContext(set));
+                elmtToChange = (Node)xp.selectSingleNode(sourceDoc);
+            }catch(JaxenException e)
+            {
+                throw new XMLSessionException("Unable to select node from query:"+ query,e);
+            }
+            if (elmtToChange == null) {
+
+                sourceDoc = buildDocumentFromPath(sourceDoc, part, query,
+                        element, false, namespaceMap);
+            } else {
+                // If the provided list contains only one element and it is a
+                // text node we just
+                // want to set the text of an element so we need to remove the
+                // original text
+                // to avoid appending
+                if (element.getNodeType() == Node.TEXT_NODE) {
+                    elmtToChange.setText("");
+                }
+                Element existingElmtToChange = null;
+                if (elmtToChange instanceof Element) {
+                    existingElmtToChange = (Element) elmtToChange;
+                } else {
+                    existingElmtToChange = ((Document) elmtToChange)
+                            .getRootElement();
+                }
+                if (existingElmtToChange != null) {
+                    if (element instanceof Element) {
+                        // Detaching all nodes of the old part
+                        List oldElmts = existingElmtToChange.elements();
+                        for (int m = 0; m < oldElmts.size(); m++) {
+                            ((Element) oldElmts.get(m)).detach();
+                        }
+                        // Attaching new elements
+                        Element newPart = (Element) element;
+                        List newPartElmts = newPart.elements();
+                        for (int m = 0; m < newPartElmts.size(); m++) {
+                            Element currentElmt = (Element) newPartElmts.get(0);
+                            currentElmt.detach();
+                            existingElmtToChange.add(currentElmt);
+                        }
+                        // Eventually attaching text also
+                        if (newPart.getText() != null
+                                && newPart.getText().length() > 0) {
+                            existingElmtToChange.setText(newPart.getText());
+                        }
+                    } else {
+                       /* if(element instanceof Node && element.getNodeType()==Node.TEXT_NODE)
+                        	existingElmtToChange.setText(element.getText());
+                        else*/
+                        	existingElmtToChange.add(element);
+                    }
+                } else {
+                    ((Document) elmtToChange).setRootElement((Element) element);
+                }
+            }
+
+            deleteDocument(processVariables, variableName
+                    + instanceId.longValue());
+            insertDocument(processVariables, variableName
+                    + instanceId.longValue(), sourceDoc);
+        }
+    }
+
+    public static void setVariableElement(String processName, String variableName, Long instanceId, String part, 
+    		String query, Node element) throws XMLSessionException {
+    	
+        if (query == null) query = "";
+        if (!query.startsWith("/") && (query.length() > 0)) {
+            throw new IllegalArgumentException("The query expression must start with the '/' character.");
+        }
+        String msgPart = part;
+        if (part != null && part.length() > 0) {
+            msgPart = "message/" + msgPart;
+        }
+        Collection processVariables = initializeVariableCollection(processName);
+
+        Document sourceDoc = null;
+        try {
+            sourceDoc = getDocument(processVariables, variableName + instanceId.longValue());
+        } catch (FinderException e) {
+            // Nothing to do, if a finder exception is thrown sourceDoc will be null
+        }
+        if (sourceDoc == null) {
+            Document newDoc = DocumentHelper.createDocument();
+            buildDocumentFromPath(newDoc, part, query, element, true);
+            Document cleanCopy = XMLUtil.cleanCopy(newDoc);
+            insertDocument(processVariables, variableName + instanceId.longValue(), cleanCopy);
+        } else {
+            Node elmtToChange = sourceDoc.selectSingleNode("/" + msgPart + query);
+            if (elmtToChange == null) {
+                sourceDoc = buildDocumentFromPath(sourceDoc, part, query, element, false);
+            } else {
+                // If the provided list contains only one element and it is a text node we just
+                // want to set the text of an element so we need to remove the original text
+                // to avoid appending
+                if (element.getNodeType() == Node.TEXT_NODE) {
+                    elmtToChange.setText("");
+                }
+                Element existingElmtToChange = null;
+                if (elmtToChange instanceof Element) {
+                    existingElmtToChange = (Element)elmtToChange;
+                } else {
+                    existingElmtToChange = ((Document)elmtToChange).getRootElement();
+                }
+                if (existingElmtToChange != null) {
+                	if (element instanceof Element) {
+	            		// Detaching all nodes of the old part
+	            		List oldElmts = existingElmtToChange.elements();
+	            		for (int m = 0; m < oldElmts.size(); m++) {
+	            			((Element)oldElmts.get(m)).detach();
+	            		}
+	            		// Attaching new elements
+	            		Element newPart = (Element)element;
+	            		List newPartElmts = newPart.elements();
+	            		for (int m = 0; m < newPartElmts.size(); m++) {
+	            			Element currentElmt = (Element)newPartElmts.get(0);
+	            			currentElmt.detach();
+	            			existingElmtToChange.add(currentElmt);
+	            		}
+	            		// Eventually attaching text also
+	            		if (newPart.getText() != null && newPart.getText().length() > 0) {
+	            			existingElmtToChange.setText(newPart.getText());
+	            		}
+                	} else {
+                		existingElmtToChange.add(element);
+                	}
+                } else {
+                    ((Document)elmtToChange).setRootElement((Element) element);
+                }
+            }
+
+            deleteDocument(processVariables, variableName + instanceId.longValue());
+            insertDocument(processVariables, variableName + instanceId.longValue(), sourceDoc);
+        }
+    }
+
+    private static Collection initializeVariableCollection(String processName) throws XMLSessionException {
+        // Testing if the process collection already exist (doesn't if first execution)
+        Collection result = getCollection("/" + processName + "/variable");
+        if (result == null) {
+            Collection processColl = null;
+            try {
+                processColl = getCollection("/" + processName);
+            } catch (XMLSessionException e) { }
+            if (processColl == null) {
+                // When it doesn't exist, creating it
+                Collection rootColl = getRootCollection();
+                processColl = createCollection(rootColl, processName);
+            }
+            result = createCollection(processColl, "variable");
+        }
+        return result;
+    }
+
+    /**
+     * Build a document creating the elements described by the provided part and XPath
+     * query, placing the provided Node inside the final path.
+     * @param doc
+     * @param part
+     * @param query
+     * @param element
+     * @return
+     */
+    private static Document buildDocumentFromPath(Document doc, String part, String query, 
+            Node element, boolean pathFound) {
+
+        Element elmt = doc.getRootElement();
+        if (elmt == null) {
+            elmt = doc.addElement("message");
+        }
+        if (part != null && part.length() > 0) {
+            if (elmt.element(part) == null) {
+                elmt = elmt.addElement(part);
+            } else {
+                elmt = elmt.element(part);
+            }
+        }
+        StringTokenizer pathTokenizer = new StringTokenizer(query, "/");
+        while (pathTokenizer.hasMoreTokens()) {
+            String pathElmt = eliminateFilter(pathTokenizer.nextToken());
+            if (elmt.element(pathElmt) == null || (!pathTokenizer.hasMoreTokens() && !pathFound)) {
+                elmt = elmt.addElement(pathElmt);
+            } else {
+                elmt = elmt.element(pathElmt);
+            }
+        }
+
+        if (element.getNodeType() != Node.ELEMENT_NODE) {
+            elmt.add(element);
+        } else {
+        	List children = ((Element)element).elements();
+        	for (Iterator childIter = children.iterator(); childIter.hasNext();) {
+				Node child = (Node) childIter.next();
+				child.detach();
+				elmt.add(child);
+			}
+    		if (element.getText() != null && element.getText().length() > 0) {
+    			elmt.setText(element.getText());
+    		}
+
+        }
+        return doc;
+    }
+
+    /**
+     * Build a document creating the elements described by the provided part and
+     * XPath query, placing the provided Node inside the final path.
+     * 
+     * @param doc
+     * @param part
+     * @param query
+     * @param element
+     * @param mapNS
+     *            map Namespaces and prefixes
+     * @return
+     */
+    private static Document buildDocumentFromPath(Document doc, String part,
+            String query, Node element, boolean pathFound, Map mapNS) {
+
+        Element elmt = doc.getRootElement();
+        if (elmt == null) {
+            elmt = doc.addElement("message");
+        }
+        if (part != null && part.length() > 0) {
+            StringTokenizer partTokenizer = new StringTokenizer(part, ":");
+            int count = partTokenizer.countTokens();
+            if (count > 0 && count < 3) {
+                String partElmt = partTokenizer.nextToken();
+                if (count == 1) {
+
+                    if (elmt.element(partElmt) == null) {
+                        elmt = elmt.addElement(partElmt);
+                    } else {
+                        elmt = elmt.element(partElmt);
+                    }
+
+                }
+                if (count == 2) {
+                    String localpart = partTokenizer.nextToken();
+                    DefaultElement elem;
+
+                    String strNS = (String) mapNS.get(partElmt);
+                    if (strNS == null) {
+                        throw new IllegalAddException(
+                                "No suchnamespace defined for prefix:"
+                                        + partElmt);
+                    } else {
+                        mapNS.remove(partElmt);
+                    }
+
+                    if (elmt.element(localpart) == null) {
+
+                        elem = new DefaultElement(localpart, new Namespace(partElmt,strNS));//partElmt
+                        //elem.addNamespace(partElmt, strNS);
+
+                        elmt.add((Element) elem);
+                        elmt = elem;
+                    } else {
+                        elmt = elmt.element(localpart);
+                        elmt.addNamespace(partElmt, strNS);
+                    }
+
+                }
+
+                /*
+                 * if(partTokenizer.countTokens()==2) if (elmt.element(pathElmt) ==
+                 * null || (!pathTokenizer.hasMoreTokens() && !pathFound)) {
+                 * elmt = elmt.addElement(pathElmt); } else { elmt =
+                 * elmt.element(pathElmt); }
+                 */
+            } else {
+                throw new IllegalAddException("could not parse part:" + part);
+            }
+        }
+        /*
+         * if (part != null && part.length() > 0) { if (elmt.element(part) ==
+         * null) { elmt = elmt.addElement(part); } else { elmt =
+         * elmt.element(part); } }
+         */
+        if (query != null && !query.trim().equals("")) {
+            try {
+                Dom4jXPath xp = new Dom4jXPath(query);
+                //org.jaxen.VariableContext vc = xp.getVariableContext();
+
+                DefaultAbsoluteLocationPath ex = (DefaultAbsoluteLocationPath) xp
+                        .getRootExpr();
+                /*
+                 * for (Iterator iter = ex.convertToIterator(); iter.hasNext();) {
+                 * type element = (type) iter.next();
+                 *  }
+                 */
+                List steps = ex.getSteps();
+                DefaultElement elem;
+                String prefix, localname;
+                for (Iterator iter = steps.iterator(); iter.hasNext();) {
+                    DefaultNameStep dnsElement = (DefaultNameStep) iter.next();
+                    //System.out.println(element.getPrefix()+":" +
+                    // element.getLocalName());
+                    prefix = dnsElement.getPrefix();
+                    localname = eliminateFilter(dnsElement.getLocalName());
+                    if (prefix != null && prefix != "") {
+                        String strNS = (String) mapNS.get(prefix);
+                        if (strNS != null) {
+                            mapNS.remove(prefix);
+                            elem = new DefaultElement(prefix+":"+localname);//prefix
+                            elem.add(new Namespace(prefix,strNS));
+                        } else {
+                            elem = new DefaultElement(prefix + ":" + localname);
+                        }
+                        if (elmt.element(prefix + ":" + localname) == null
+                                || (!iter.hasNext() && !pathFound)) {
+                            elmt.add(elem);
+                            elmt = elem;
+                        } else {
+                            elmt = elmt.element(prefix + ":" + localname);
+                        }
+
+                    } else {
+                        String pathElmt = eliminateFilter(dnsElement
+                                .getLocalName());
+                        if (elmt.element(pathElmt) == null
+                                || (!iter.hasNext() && !pathFound)) {
+                            elmt = elmt.addElement(pathElmt);
+                        } else {
+                            elmt = elmt.element(pathElmt);
+                        }
+                    }
+
+                }
+
+            } catch (org.jaxen.JaxenException e) {
+                throw new IllegalAddException(
+                        "An exception ocured when parsing query " + query);
+            }
+        }
+
+        /*
+         * StringTokenizer pathTokenizer = new StringTokenizer(query, "/");
+         * while (pathTokenizer.hasMoreTokens()) { String pathElmt =
+         * eliminateFilter(pathTokenizer.nextToken()); if
+         * (elmt.element(pathElmt) == null || (!pathTokenizer.hasMoreTokens() &&
+         * !pathFound)) { elmt = elmt.addElement(pathElmt); } else { elmt =
+         * elmt.element(pathElmt); } }
+         */
+
+        if (element.getNodeType() != Node.ELEMENT_NODE) {
+            elmt.add(element);
+        } else {
+            List children = ((Element) element).elements();
+            for (Iterator childIter = children.iterator(); childIter.hasNext();) {
+                Node child = (Node) childIter.next();
+                child.detach();
+                elmt.add(child);
+            }
+            if (element.getText() != null && element.getText().length() > 0) {
+                elmt.setText(element.getText());
+            }
+
+        }
+        return doc;
+    }
+
+    /**
+     * Eliminates the XPath's filter in square bracket in a path element
+     * @param str
+     * @return
+     */
+    private static String eliminateFilter(String str) {
+    	if (str.indexOf("[") >= 0) return str.substring(0, str.indexOf("["));
+    	else return str;
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessor.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessor.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessor.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.expression;
+
+import java.util.Date;
+
+import org.apache.agila.bpel.engine.exception.XPathEvaluationException;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+
+/**
+ * Evaluates an expression against Agila XML database and returns the
+ * appropriate value.
+ */
+public interface ExpressionProcessor {
+
+    public boolean evaluateAsBoolean(ProcessInstance instance, String expression) throws XPathEvaluationException;
+    public Date evaluateAsDate(ProcessInstance instance, String expression) throws XPathEvaluationException;
+
+    /**
+     * Evaluates an expression resulting in a duration value and adds this duration
+     * to now to obtain a new date.
+     * @param instance
+     * @param expression
+     * @return Date
+     * @throws XPathEvaluationException
+     */
+    public Date evaluateDurationAsDate(ProcessInstance instance, String expression) throws XPathEvaluationException;
+
+    public String evaluateAsString(ProcessInstance instance, String expression) throws XPathEvaluationException;
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessorFactory.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessorFactory.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ExpressionProcessorFactory.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.expression;
+
+import org.apache.agila.bpel.engine.priv.expression.impl.BPELExpressionProcessorImpl;
+
+/**
+ * Factory for the ExpressionProcessor interface.
+ */
+public class ExpressionProcessorFactory {
+
+    private static ExpressionProcessor processor = null;
+
+    public static ExpressionProcessor getBPELExpressionProcessor() {
+        if (processor == null) {
+            processor = new BPELExpressionProcessorImpl();
+        }
+        return processor;
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/impl/BPELExpressionProcessorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/impl/BPELExpressionProcessorImpl.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/impl/BPELExpressionProcessorImpl.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/impl/BPELExpressionProcessorImpl.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.expression.impl;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.StringTokenizer;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.relaxng.datatype.DatatypeException;
+import org.apache.agila.bpel.common.util.DurationUtil;
+import org.apache.agila.bpel.common.util.StringUtil;
+import org.apache.agila.bpel.engine.common.persistence.FinderException;
+import org.apache.agila.bpel.engine.common.persistence.XMLSessionException;
+import org.apache.agila.bpel.engine.exception.SelectionFailureException;
+import org.apache.agila.bpel.engine.exception.XPathEvaluationException;
+import org.apache.agila.bpel.engine.priv.core.definition.PropertyAlias;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.impl.xao.VariableXAO;
+import org.apache.agila.bpel.engine.priv.expression.ExpressionProcessor;
+
+import com.sun.msv.datatype.xsd.DatatypeFactory;
+import com.sun.msv.datatype.xsd.XSDatatype;
+import com.sun.msv.datatype.xsd.datetime.BigTimeDurationValueType;
+
+/**
+ * Implementation of the ExpressionProcessor interface that evaluates BPEL
+ * expressions. Those expressions follow the XPath grammar with the additions
+ * of BPEL functions.
+ */
+public class BPELExpressionProcessorImpl implements ExpressionProcessor {
+
+    private static final String VARIABLE_PROP_FUNC_PREFIX = "bpws:getVariableProperty(";
+    private static final String VARIABLE_DATA_FUNC_PREFIX = "bpws:getVariableData(";
+
+    private static final String QUOTE = "'";
+
+    public boolean evaluateAsBoolean(ProcessInstance instance, String expression) throws XPathEvaluationException {
+        Boolean result = null;
+        try {
+            result = (Boolean) evaluateAsObject(instance, expression);
+        } catch (ClassCastException e) {
+            throw new XPathEvaluationException("Expression evaluation didn't return a boolean.");
+        }
+        return result.booleanValue();
+    }
+
+    public String evaluateAsString(ProcessInstance instance, String expression) throws XPathEvaluationException {
+        String result = null;
+        try {
+            result = evaluateAsObject(instance, expression).toString();
+        } catch (ClassCastException e) {
+            throw new XPathEvaluationException("Expression evaluation didn't return a String.");
+        }
+        return result;
+    }
+
+    // TODO implement a property evaluation where date can be added with durations
+    public Date evaluateAsDate(ProcessInstance instance, String expression) throws XPathEvaluationException {
+        XSDatatype dateTimeType = null;
+        try {
+            dateTimeType = DatatypeFactory.getTypeByName("dateTime");
+        } catch (DatatypeException e) {
+            throw new XPathEvaluationException("Unable to get msv type classes", e);
+        }
+        String reducedExpr = null;
+        try {
+            reducedExpr = reduceBPELFunctions(instance, expression);
+        } catch (XMLSessionException e) {
+            throw new XPathEvaluationException(e);
+        }
+        if (dateTimeType.isValid(reducedExpr, null)) {
+            return ((Calendar) dateTimeType.createJavaObject(reducedExpr, null)).getTime();
+        } else {
+            throw new XPathEvaluationException("The expression could not be evaluated as a Date : " + expression);
+        }
+    }
+
+    public Date evaluateDurationAsDate(ProcessInstance instance, String expression) throws XPathEvaluationException {
+        XSDatatype durationType = null;
+        try {
+            durationType = DatatypeFactory.getTypeByName("duration");
+        } catch (DatatypeException e) {
+            throw new XPathEvaluationException("Unable to get msv type classes", e);
+        }
+        String reducedExpr = null;
+        try {
+            reducedExpr = reduceBPELFunctions(instance, expression);
+        } catch (XMLSessionException e) {
+            throw new XPathEvaluationException(e);
+        }
+        if (durationType.isValid(reducedExpr, null)) {
+            Calendar cal = Calendar.getInstance();
+            BigTimeDurationValueType duration =
+                    (BigTimeDurationValueType) durationType.createJavaObject(reducedExpr, null);
+            DurationUtil.addDuration(cal, duration);
+            return cal.getTime();
+        } else {
+            throw new XPathEvaluationException("The expression could not be evaluated as a Duration : " + expression);
+        }
+    }
+
+    private Object evaluateAsObject(ProcessInstance instance, String expression) throws XPathEvaluationException {
+        String reduceExpression = null;
+        try {
+            reduceExpression = reduceBPELFunctions(instance, expression);
+        } catch (XMLSessionException e) {
+            throw new XPathEvaluationException("Could not connect to the xml database when evaluating the " +
+                    "xpath expression " + expression, e);
+        }
+        Document testDoc = DocumentHelper.createDocument();
+        Element root = testDoc.addElement("root");
+        Object result = root.selectObject(reduceExpression);
+        return result;
+    }
+
+    private String reduceBPELFunctions(ProcessInstance instance, String expression) throws SelectionFailureException, XMLSessionException {
+        String reducedExpr = expression;
+        int varPropFuncIndex = expression.indexOf(VARIABLE_PROP_FUNC_PREFIX);
+        int varDataFuncIndex = expression.indexOf(VARIABLE_DATA_FUNC_PREFIX);
+        while (varPropFuncIndex > -1 || varDataFuncIndex > -1) {
+            if (varPropFuncIndex > -1) {
+                // Isolating parameters
+                String varPropFuncParam1ToEnd = reducedExpr.substring(varPropFuncIndex + 25, reducedExpr.length());
+                StringTokenizer tokenizer = new StringTokenizer(varPropFuncParam1ToEnd, "'");
+                String variableName = tokenizer.nextToken();
+                tokenizer.nextToken();
+                String propertyName = tokenizer.nextToken();
+
+                // Selecting corresponding value
+                // TODO Consider only the alias with right messageType
+                PropertyAlias alias = (PropertyAlias) instance.getProcess().getProperty(propertyName)
+                        .getAliases().iterator().next();
+                String selectedValue = null;
+                try {
+                    selectedValue = VariableXAO.queryVariableValue(instance.getProcess().getName(),instance.getProcess().getNamespace(), variableName,
+                            instance.getId(), alias.getPart(), alias.getQuery());
+                } catch (FinderException e) {
+                    throw new SelectionFailureException(e);
+                }
+
+                // Reducing the expression with the selected value
+                reducedExpr = reducedExpr.substring(0, varPropFuncIndex) + selectedValue +
+                        varPropFuncParam1ToEnd.substring(varPropFuncParam1ToEnd.indexOf(")") + 1,
+                                varPropFuncParam1ToEnd.length());
+            }
+            if (varDataFuncIndex > -1) {
+                // Recalculating in case a the expressions has been reduced by the preceding case
+                varDataFuncIndex = reducedExpr.indexOf(VARIABLE_DATA_FUNC_PREFIX);
+                // Isolating parameters
+                String varDataFuncParam1ToEnd = reducedExpr.substring(varDataFuncIndex + 21, reducedExpr.length());
+                StringTokenizer tokenizer = new StringTokenizer(varDataFuncParam1ToEnd, "'");
+                String variableName = tokenizer.nextToken();
+                String nextToken = tokenizer.nextToken();
+                String partName = null;
+                String locationPath = null;
+                if (nextToken.trim().startsWith(",")) {
+                    partName = tokenizer.nextToken();
+                    nextToken = tokenizer.nextToken();
+                    if (nextToken.trim().startsWith(",")) {
+                        locationPath = tokenizer.nextToken();
+                    }
+                }
+
+                // Selecting corresponding values
+                String selectedValue = null;
+                try {
+                    if (locationPath != null) {
+                        selectedValue = VariableXAO.queryVariableValue(instance.getProcess().getName(),instance.getProcess().getNamespace(), variableName,
+                                instance.getId(), partName, locationPath);
+                    } else if (partName != null) {
+                        selectedValue = VariableXAO.queryVariableValue(instance.getProcess().getName(),instance.getProcess().getNamespace(), variableName,
+                                instance.getId(), partName, "/");
+                    } else {
+                        selectedValue = VariableXAO.queryVariableValue(instance.getProcess().getName(),instance.getProcess().getNamespace(), variableName,
+                                instance.getId(), "", "");
+                    }
+                } catch (FinderException e) {
+                    throw new SelectionFailureException(e);
+                }
+                selectedValue = stringify(selectedValue);
+                reducedExpr = reducedExpr.substring(0, varDataFuncIndex) + selectedValue +
+                        varDataFuncParam1ToEnd.substring(varDataFuncParam1ToEnd.indexOf(")") + 1,
+                                varDataFuncParam1ToEnd.length());
+            }
+            varPropFuncIndex = reducedExpr.indexOf(VARIABLE_PROP_FUNC_PREFIX);
+            varDataFuncIndex = reducedExpr.indexOf(VARIABLE_DATA_FUNC_PREFIX);
+        }
+        return reducedExpr;
+    }
+
+    /**
+     * Trying to see of the provided value is a string and if so surround
+     * it with quotes. It's doing it by elimination, testing most other
+     * types first
+     * @param value
+     * @return 
+     */
+    private String stringify(String value) {
+        XSDatatype dateTimeType = null;
+        try {
+            dateTimeType = DatatypeFactory.getTypeByName("dateTime");
+        } catch (DatatypeException e) {
+            throw new RuntimeException("The 'dateTime' MSV type could not be found.", e);
+        }
+        if (value == null || dateTimeType.isValid(value, null)) {
+            return value;
+        } else {
+            XSDatatype durationType = null;
+            try {
+                durationType = DatatypeFactory.getTypeByName("duration");
+            } catch (DatatypeException e) {
+                throw new RuntimeException("The 'duration' MSV type could not be found.", e);
+            }
+            if (durationType.isValid(value, null)) {
+                return value;
+            } else if (StringUtil.isBoolean(value)) {
+                return Boolean.toString(StringUtil.booleanValue(value)) + "()";
+            } else if (StringUtil.isNumber(value)) {
+                return value;
+            } else if (Character.isLetter(value.charAt(0))) {
+                return QUOTE + value + QUOTE;
+            }
+        }
+        return value;
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/Filter.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/Filter.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/Filter.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/Filter.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+import org.dom4j.Document;
+
+/**
+ * This class can be implemented in order to filtrate messages produced by
+ * web services in response to Agila's calls or do anything you want to
+ * with the message itself.
+ * @author mriou
+ */
+public interface Filter {
+
+    public void doFilter(Document message) throws FilterException;
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/FilterException.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/FilterException.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/FilterException.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/FilterException.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+/**
+ * Thrown by a filter when either there's something wrong in the message or when
+ * the filter itself failed. Be careful, when a filter throws a FilterExcetion
+ * the whole Agila transaction will be rolledback.
+ * @author mriou
+ */
+public class FilterException extends Exception {
+
+    public FilterException(String message) {
+        super(message);
+    }
+
+    public FilterException(Throwable cause) {
+        super(cause);
+    }
+
+    public FilterException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/InvocationException.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/InvocationException.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/InvocationException.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/InvocationException.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+/**
+ * Thrown when a web service invokation fails.
+ */
+public class InvocationException extends RuntimeException {
+
+    public InvocationException(String message) {
+        super(message);
+    }
+
+    public InvocationException(Throwable cause) {
+        super(cause);
+    }
+
+    public InvocationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageBroker.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageBroker.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageBroker.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageBroker.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,395 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import org.apache.log4j.Logger;
+
+import org.apache.agila.bpel.common.configuration.EngineConfiguration;
+import org.apache.agila.bpel.engine.common.persistence.CreationException;
+import org.apache.agila.bpel.engine.priv.core.definition.Activity;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.Receive;
+import org.apache.agila.bpel.engine.priv.core.definition.Sequence;
+import org.apache.agila.bpel.worklist.AgilaWorkListFactory;
+import org.apache.agila.bpel.worklist.exception.InvalidMessageException;
+
+/**
+ * Creates and sends messages as ordered by the engine core. This class is abstract and
+ * therefore must be subclassed to do anything interesting. By subclassing it you'll be
+ * able to receive messages and forward them to your own services in a relevent
+ * way for your own business. To make this class call your services you will have to
+ * provide your own implementation, put it in the classpath and change the
+ * <i>agila.messagebroker.impl</i> property in the agila-implementation.properties
+ * file.
+ */
+public abstract class MessageBroker {
+
+    private static final String WORKLIST_PT = "WORKLISTPT";
+    private static final String WORKLIST_NS = "http://www.apache.org/agila/worklist".toUpperCase();
+    private static final String WORKLIST_OP = "CREATEWORK";
+    private static final String VARIABLE_ELMT = "variable";
+    private static final String PROCESS_ELMT = "process";
+    private static final String NAMESPACE_ELMT = "namespace";
+    private static final String SEPARATOR = "/";
+
+    protected static Logger log = Logger.getLogger("MessageBroker");
+
+    protected static HashMap messages = new HashMap();
+    protected static int recordMessages = -1;
+
+    /**
+     * Sends asynchronously a message to the specified (operation, portType, partner).
+     * As it's asynchronous, no response are expected. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * Check if the message is not targeted at the WorkList Manager. If it is, creates
+     * a new WorkItem, if it isn't, just forward the call to <code>asyncCall</call>.
+     * @param partner   
+     * @param portType  
+     * @param operation 
+     * @param message   
+     */
+    public final void asyncInvoke(Activity sender, String partner, String portType, String operation, Document message) {
+        recordMessage(partner, portType, operation, message);
+        asyncSend(sender, partner, portType, operation, message);
+    }
+
+    /**
+     * Sends asynchronously a message to the specified (operation, portType, partner).
+     * As it's asynchronous, no response are expected. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * Check if the message is not targeted at the WorkList Manager. If it is, creates
+     * a new WorkItem, if it isn't, just forward the call to <code>asyncCall</call>.
+     * 
+     * @param partner
+     * @param namespace   
+     * @param portType  
+     * @param operation 
+     * @param message   
+     */
+    public final void asyncInvoke(Activity sender, String partner,String namespace, String portType, String operation, Document message) {
+        recordMessage(partner, namespace, portType, operation, message);
+        asyncSend(sender, partner, namespace, portType, operation, message);
+    }
+
+    /**
+     * Syncronously send a message to the specified (operation, portType, partner). A
+     * response is expected in return.
+     * @param partner   
+     * @param portType  
+     * @param operation 
+     * @param message   
+     * @return 
+     */
+    public final Document syncInvoke(Activity sender, String partner, String portType, String operation, Document message) {
+        recordMessage(partner, portType, operation, message);
+        if (WORKLIST_PT.equals(portType.toUpperCase().trim())
+                && WORKLIST_OP.equals(operation.toUpperCase().trim())) {
+
+            // If a response is expected, variable and process must be provided to the work list
+            // manager so that it can ask for a form matching the wanted response.
+            if (sender instanceof Invoke) {
+                if (sender.getContainer() instanceof Sequence) {
+                    Sequence sequence = null;
+                    Receive next = null;
+                    try {
+                        sequence = (Sequence) sender.getContainer();
+                        int senderPos = sequence.getActivities().indexOf(sender);
+                        next = (Receive) sequence.getActivities().get(senderPos + 1);
+                    } catch (IndexOutOfBoundsException e) {
+                        log.error("Could not create a WorkItem properly, the Invoke activity requesting for the " +
+                                "WorkItem creation is not properly followed by a Receive in a Sequence.");
+                    }
+                    String variable = next.getVariable();
+                    String process = sequence.fetchProcess().getName();
+                    String namespace = sequence.fetchProcess().getNamespace();
+                    if (variable != null && variable.length() > 0) {
+                        message.getRootElement().addElement(VARIABLE_ELMT).setText(variable);
+                        message.getRootElement().addElement(NAMESPACE_ELMT).setText(namespace);
+                        message.getRootElement().addElement(PROCESS_ELMT).setText(process);
+                    }
+                }
+            }
+
+            Long wiId = null;
+            try {
+                wiId = AgilaWorkListFactory.getWorkList().createWorkItem(message);
+            } catch (InvalidMessageException e) {
+                log.error("Could not create a WorkItem, the message sent to the WorkList Manager is " +
+                        "not valid", e);
+            }
+
+            Document resultDoc = DocumentHelper.createDocument();
+            Element resultMsg = resultDoc.addElement("message");
+            resultMsg.addElement("wipart").addElement("workitemid").setText(wiId.toString());
+            return resultDoc;
+        } else {
+            return syncSend(sender, partner, portType, operation, message);
+        }
+    }
+
+    /**
+     * Syncronously send a message to the specified (operation, portType, partner). A
+     * response is expected in return.
+     * porttype is as QName
+     * @param partner   
+     * @param portType
+     * @param namespace
+     * @param operation 
+     * @param message   
+     * @return 
+     */
+    public final Document syncInvoke(Activity sender, String partner, String namespace, String portType, String operation, Document message) {
+        recordMessage(partner, namespace, portType, operation, message);
+        if (WORKLIST_PT.equals(portType.toUpperCase().trim())
+                && WORKLIST_OP.equals(operation.toUpperCase().trim())) {
+
+            // If a response is expected, variable and process must be provided to the work list
+            // manager so that it can ask for a form matching the wanted response.
+            if (sender instanceof Invoke) {
+                if (sender.getContainer() instanceof Sequence) {
+                    Sequence sequence = null;
+                    Receive next = null;
+                    try {
+                        sequence = (Sequence) sender.getContainer();
+                        int senderPos = sequence.getActivities().indexOf(sender);
+                        next = (Receive) sequence.getActivities().get(senderPos + 1);
+                    } catch (IndexOutOfBoundsException e) {
+                        log.error("Could not create a WorkItem properly, the Invoke activity requesting for the " +
+                                "WorkItem creation is not properly followed by a Receive in a Sequence.");
+                    }
+                    String variable = next.getVariable();
+                    String process = sequence.fetchProcess().getName();
+                    String namespace1 = sequence.fetchProcess().getNamespace();
+                    if (variable != null && variable.length() > 0) {
+                        message.getRootElement().addElement(VARIABLE_ELMT).setText(variable);
+                        message.getRootElement().addElement(NAMESPACE_ELMT).setText(namespace1);
+                        message.getRootElement().addElement(PROCESS_ELMT).setText(process);
+                    }
+                }
+            }
+
+            Long wiId = null;
+            try {
+                wiId = AgilaWorkListFactory.getWorkList().createWorkItem(message);
+            } catch (InvalidMessageException e) {
+                log.error("Could not create a WorkItem, the message sent to the WorkList Manager is " +
+                        "not valid", e);
+            }
+
+            Document resultDoc = DocumentHelper.createDocument();
+            Element resultMsg = resultDoc.addElement("message");
+            resultMsg.addElement("wipart").addElement("workitemid").setText(wiId.toString());
+            return resultDoc;
+        } else {
+            return syncSend(sender, partner, namespace, portType, operation, message);
+        }
+    }
+
+    /**
+     * Implement this method in your subclass to receive messages from the process
+     * engine and execute your own tasks accordingly. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * @param sender
+     * @param partner   
+     * @param portType  
+     * @param operation 
+     * @param message   
+     */
+    protected abstract void asyncSend(Activity sender, String partner, String portType,
+                                      String operation, Document message);
+
+    /**
+     * Implement this method in your subclass to receive messages from the process
+     * engine and execute your own tasks accordingly. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * portType as QName
+     * @param sender
+     * @param partner   
+     * @param portType  
+     * @param namespace
+     * @param operation 
+     * @param message   
+     */
+    protected abstract void asyncSend(Activity sender, String partner, String namespace, String portType,
+                                      String operation, Document message);
+
+    /**
+     * Implement this method in your subclass to receive messages from the process
+     * engine and execute your own tasks accordingly. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * @param sender
+     * @param partner
+     * @param portType  
+     * @param operation 
+     * @param message   
+     * @return 
+     */
+    protected abstract Document syncSend(Activity sender, String partner, String portType,
+                                         String operation, Document message);
+
+    /**
+     * Implement this method in your subclass to receive messages from the process
+     * engine and execute your own tasks accordingly. Keep in mind that the provided
+     * message can be null if we're simply invoking a service with no input parameter.
+     * porttype as QName
+     * @param sender
+     * @param partner
+     * @param namespace
+     * @param portType  
+     * @param operation 
+     * @param message   
+     * @return 
+     */
+    protected abstract Document syncSend(Activity sender, String partner, String namespace, String portType,
+                                         String operation, Document message);
+
+    /**
+     * Gets a message that has already been sent by the engine. If no message has been sent
+     * to the provided partner, portType, operation, returns null. Message records are not
+     * persisted so they do not survive a server shutdown.
+     * 
+     * @param partner   
+     * @param portType  
+     * @param operation 
+     * @return a DOM4J Document holding the sent message or null
+     */
+    public static Document getMessage(String partner, String portType, String operation) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(partner);
+        buf.append(SEPARATOR);
+        buf.append(portType);
+        buf.append(SEPARATOR);
+        buf.append(operation);
+        return (Document) messages.get(buf.toString());
+    }
+    
+    /**
+     * TODO upravit, aby davalo porttype namespacovane
+     * Gets a message that has already been sent by the engine. If no message has been sent
+     * to the provided partner, portType, operation, returns null. Message records are not
+     * persisted so they do not survive a server shutdown.
+     * porttype as QName
+     * 
+     * @param partner   
+     * @param portType
+     * @param namespace  
+     * @param operation 
+     * @return a DOM4J Document holding the sent message or null
+     */
+    public static Document getMessage(String partner,String namespace, String portType, String operation) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(partner);
+        buf.append(SEPARATOR);
+        buf.append("{" + namespace + "}");
+        buf.append(portType);
+        buf.append(SEPARATOR);
+        buf.append(operation);
+        return (Document) messages.get(buf.toString());
+    }
+
+    /**
+     * Returns a map holding as key a string with format partner/porttype/operation of the
+     * sent message and as value the sent message as a XML string. Message records are not
+     * persisted so they do not survive a server shutdown.
+     * 
+     * @return a Map with string key and string value
+     */
+    public static Map getMessages() {
+        HashMap result = new HashMap();
+        for (Iterator messageIter = messages.keySet().iterator(); messageIter.hasNext();) {
+            String destination = (String) messageIter.next();
+            result.put(destination, ((Document) messages.get(destination)).asXML());
+        }
+        return result;
+    }
+
+    /**
+     * Stores sent messages to the message map.
+     * 
+     * @param partner   
+     * @param portType  
+     * @param operation 
+     * @param message   
+     */
+    private void recordMessage(String partner, String portType, String operation, Document message) {
+        if (recordMessages == -1) {
+            if (EngineConfiguration.isHistorizeMessages()) {
+                recordMessages = 1;
+            } else {
+                recordMessages = 0;
+            }
+        }
+        if (recordMessages == 1) {
+            StringBuffer buf = new StringBuffer();
+            buf.append(partner);
+            buf.append(SEPARATOR);
+            buf.append(portType);
+            buf.append(SEPARATOR);
+            buf.append(operation);
+            if (message != null) {
+                messages.put(buf.toString(), message);
+            } else {
+                Document nullDoc = DocumentHelper.createDocument();
+                nullDoc.addElement("null");
+                messages.put(buf.toString(), nullDoc);
+            }
+        }
+    }
+    
+    /**
+     * TODO upravit, aby davalo porttype namespacovane
+     * Stores sent messages to the message map.
+     * 
+     * @param partner   
+     * @param portType
+     * @param namespace  
+     * @param operation 
+     * @param message   
+     */
+    private void recordMessage(String partner, String namespace, String portType, String operation, Document message) {
+        if (recordMessages == -1) {
+            if (EngineConfiguration.isHistorizeMessages()) {
+                recordMessages = 1;
+            } else {
+                recordMessages = 0;
+            }
+        }
+        if (recordMessages == 1) {
+            StringBuffer buf = new StringBuffer();
+            buf.append(partner);
+            buf.append(SEPARATOR);
+            buf.append("{" + namespace + "}");
+            buf.append(portType);
+            buf.append(SEPARATOR);
+            buf.append(operation);
+            if (message != null) {
+                messages.put(buf.toString(), message);
+            } else {
+                Document nullDoc = DocumentHelper.createDocument();
+                nullDoc.addElement("null");
+                messages.put(buf.toString(), nullDoc);
+            }
+        }
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageController.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageController.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageController.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageController.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+import org.dom4j.Document;
+import org.apache.agila.bpel.engine.exception.ConflictingReceiveException;
+import org.apache.agila.bpel.engine.exception.CorrelationViolationException;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ReceiveEC;
+
+/**
+ * Controls message received by the engine, check if they are relevant
+ * to any process of process instance and if so do the appropriate thing
+ * to the appropriate activity or execution context.<br><br>
+ * The received message must have a root element named 'message' that
+ * contains all message parts.
+ */
+public interface MessageController {
+
+    /**
+     * Processes provided message checking if an existing execution context is waiting
+     * for this message to complete or if this message can trigger the execution of a
+     * new process.<br>
+     * The received message must have a root element named 'message' that
+     * contains all message parts.
+     * @param partnerLink
+     * @param namespace
+     * @param portType
+     * @param operation
+     * @param message
+     * @return Document reply to the message (everything fine or error)
+     */
+    public ReceiveEC acknowledge(String partnerLink, String namespace, String portType, String operation, Document message) throws CorrelationViolationException, ConflictingReceiveException;
+
+    /**
+     * Processes provided message checking if an existing execution context is waiting
+     * for this message to complete or if this message can trigger the execution of a
+     * new process.<br>
+     * The received message must have a root element named 'message' that
+     * contains all message parts.
+     * @param partnerLink
+     * @param portType
+     * @param operation
+     * @param message
+     * @return Document reply to the message (everything fine or error)
+     */
+    public ReceiveEC acknowledge(String partnerLink, String portType, String operation, Document message) throws CorrelationViolationException, ConflictingReceiveException;
+
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageFilter.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageFilter.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageFilter.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessageFilter.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+import org.dom4j.Document;
+import org.apache.agila.bpel.common.configuration.EngineConfiguration;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The message filter just calls all the filters that have been registered to it
+ * (using Agila's configuration file).
+ * @see Filter
+ * @author mriou
+ */
+public class MessageFilter {
+
+    private static Logger log = Logger.getLogger(MessageFilter.class);
+
+    private static  ArrayList filters = null;
+
+    public static void addFilter(Filter filter) {
+        if (filters == null) loadFilters();
+        filters.add(filter);
+    }
+
+    public static void filterMessage(Document message) throws FilterException {
+        if (filters == null) loadFilters();
+        for (int m = 0; m < filters.size(); m++) {
+            Filter filter = (Filter) filters.get(m);
+            filter.doFilter(message);
+        }
+    }
+
+    private static void loadFilters() {
+        List filterClasses = EngineConfiguration.getMessageFilters();
+        filters = new ArrayList();
+        if (filterClasses != null) {
+            for (int m = 0; m < filterClasses.size(); m++) {
+                String classname = (String) filterClasses.get(m);
+                try {
+                    Filter filter = (Filter) Class.forName(classname).newInstance();
+                    filters.add(filter);
+                } catch (InstantiationException e) {
+                    log.fatal("Could not initialize message filters.", e);
+                    throw new RuntimeException("Could not initialize message filters.", e);
+                } catch (IllegalAccessException e) {
+                    log.fatal("Could not initialize message filters.", e);
+                    throw new RuntimeException("Could not initialize message filters.", e);
+                } catch (ClassNotFoundException e) {
+                    log.fatal("Could not initialize message filters.", e);
+                    throw new RuntimeException("Could not initialize message filters.", e);
+                }
+            }
+        }
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessagingFactory.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessagingFactory.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessagingFactory.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/MessagingFactory.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.agila.bpel.engine.priv.messaging;
+
+import org.apache.log4j.Logger;
+
+import org.apache.agila.bpel.common.configuration.EngineConfiguration;
+import org.apache.agila.bpel.engine.priv.Constants;
+import org.apache.agila.bpel.engine.priv.messaging.impl.MessageControllerImpl;
+
+/**
+ * A factory for MessageBroker and MessageController interfaces
+ * @see MessageBroker
+ * @see MessageController
+ */
+public class MessagingFactory {
+
+    private static Logger log = Logger.getLogger(MessagingFactory.class);
+
+    private static MessageController controller = null;
+    private static MessageBroker broker = null;
+
+    /**
+     * This method is the factory method of the MessageBroker interface. The default implementation
+     * for this interface does nothing interesting so to customize your MessageBroker just redefine
+     * your own one and declare it as the implementation in the agila-implementations.properties
+     * file.
+     * @return a MessageBroker implementation
+     */
+    public static MessageBroker getMessageBroker() {
+        if (broker == null) {
+            try {
+                String brokerClassName = EngineConfiguration.getMessageBroker();
+                broker = (MessageBroker) Class.forName(brokerClassName).newInstance();
+            } catch (ClassNotFoundException e) {
+                log.error("Could not instantiate a MessageBroker, could not find the broker class as defined "+
+                        "in file " + Constants.IMPL_PROPERTY);
+            } catch (InstantiationException e) {
+                log.error("Could not instantiate a MessageBroker", e);
+            } catch (IllegalAccessException e) {
+                log.error("Could not access the implementation class of a MessageBroker", e);
+            }
+        }
+        return broker;
+    }
+
+    /**
+     * @return the MessageController implementation
+     */
+    public static MessageController getMessageController() {
+        if (controller== null) {
+            controller = new MessageControllerImpl();
+        }
+        return controller;
+    }
+}



Mime
View raw message