[jbpm-commits] JBoss JBPM SVN: r5943 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/serializablevariable and 21 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Dec 10 12:02:21 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-12-10 12:02:19 -0500 (Thu, 10 Dec 2009)
New Revision: 5943
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/SerializableVariableTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/Room.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/RulesTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.png
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/rules.drl
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/rules.drl
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionConditionActivity.java
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Transaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java
Log:
JBPM-2006 rules activity and JBPM-2684 automatic saving of updates to serializable variables
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/SerializableVariableTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/SerializableVariableTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/SerializableVariableTest.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.serializablevariable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SerializableVariableTest extends JbpmTestCase {
+
+ String deploymentId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/serializablevariable/process.jpdl.xml")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+
+ super.tearDown();
+ }
+
+ public void testSerializableVariableUpdate() {
+ Set<String> messages = new HashSet<String>();
+ messages.add("serialize");
+ messages.add("me");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("messages", messages);
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("SerializableVariable", variables);
+ String pid = processInstance.getId();
+ executionService.signalExecutionById(pid);
+
+ Set<String> expectedMessages = new HashSet<String>();
+ expectedMessages.add("i");
+ expectedMessages.add("was");
+ expectedMessages.add("updated");
+
+ messages = (Set<String>) executionService.getVariable(pid, "messages");
+ assertEquals(expectedMessages, messages);
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/SerializableVariableTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.serializablevariable;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UpdateSerializedVariables implements ActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ Set<String> messages = (Set<String>) execution.getVariable("messages");
+ messages.clear();
+ messages.add("i");
+ messages.add("was");
+ messages.add("updated");
+ }
+
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/process.jpdl.xml 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="SerializableVariable" xmlns="http://jbpm.org/4.3/jpdl">
+
+ <start g="20,20,48,48">
+ <transition to="wait before update" />
+ </start>
+
+ <state name="wait before update">
+ <transition to="update serialized variables" />
+ </state>
+
+ <custom name="update serialized variables"
+ class="org.jbpm.examples.serializablevariable.UpdateSerializedVariables"
+ g="96,16,100,52">
+
+ <transition to="wait after update" />
+ </custom>
+
+ <state name="wait after update" g="231,19,80,40"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/serializablevariable/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionConditionActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionConditionActivity.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionConditionActivity.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -38,12 +38,12 @@
private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
+ public void execute(ActivityExecution execution) throws Exception {
execute((ExecutionImpl) execution);
}
- public void execute(ExecutionImpl execution) {
- Transition transition = findTransition(execution);
+ public void execute(ExecutionImpl execution) throws Exception {
+ Transition transition = findTransitionUsingConditions(execution);
if (transition==null) {
throw new JbpmException("no outgoing transition condition evaluated to true for decision "+execution.getActivity());
}
@@ -53,7 +53,7 @@
execution.take(transition);
}
- private Transition findTransition(ExecutionImpl execution) {
+ public static Transition findTransitionUsingConditions(ExecutionImpl execution) {
Activity activity = execution.getActivity();
List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
for (Transition transition : outgoingTransitions) {
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesActivity.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesActivity.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.drools.KnowledgeBase;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.jpdl.internal.rules.ExecutionGlobals;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.repository.RulesDeployer;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesActivity extends DecisionConditionActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ List<RulesFact> rulesFacts = new ArrayList<RulesFact>();
+
+ public void execute(ActivityExecution execution) throws Exception {
+ ExecutionImpl executionImpl = (ExecutionImpl)execution;
+ String deploymentId = executionImpl.getProcessDefinition().getDeploymentId();
+ KnowledgeBase knowledgeBase = RulesDeployer.getKnowledgeBase(deploymentId);
+
+ StatefulKnowledgeSession knowledgeSession =
+ knowledgeBase.newStatefulKnowledgeSession();
+
+ ExecutionGlobals executionGlobals = new ExecutionGlobals(execution);
+ knowledgeSession.getGlobals().setDelegate(executionGlobals);
+
+ for (RulesFact rulesFact: rulesFacts) {
+ Object fact = rulesFact.getObject(execution);
+ knowledgeSession.insert(fact);
+ }
+
+ knowledgeSession.fireAllRules();
+
+ super.execute(executionImpl);
+ }
+
+ public void addRulesFact(RulesFact rulesFact) {
+ rulesFacts.add(rulesFact);
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesActivity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.List;
+
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesBinding extends JpdlBinding {
+
+ public RulesBinding() {
+ super("rules");
+ }
+
+ public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
+ RulesActivity rulesActivity = new RulesActivity();
+
+ List<Element> factElements = XmlUtil.elements(element, "fact");
+ for (Element factElement: factElements) {
+ RulesFact rulesFact = new RulesFact();
+
+ String factVar = XmlUtil.attribute(factElement, "var");
+ if (factVar!=null) {
+ rulesFact.setVariableName(factVar);
+
+ } else {
+ String factExpr = XmlUtil.attribute(factElement, "expr");
+
+ if (factExpr!=null) {
+ String factLang = XmlUtil.attribute(factElement, "lang");
+ rulesFact.setExpression(factExpr);
+ rulesFact.setLanguage(factLang);
+
+ } else {
+ parse.addProblem("'fact' element inside 'rules' activity requires attribute 'var' or 'expr'", element);
+ }
+ }
+
+ rulesActivity.addRulesFact(rulesFact);
+ }
+
+ return rulesActivity;
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.io.Serializable;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesFact implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String variableName;
+ protected String expression;
+ protected String language;
+
+ public String getVariableName() {
+ return variableName;
+ }
+
+ public void setVariableName(String variableName) {
+ this.variableName = variableName;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public Object getObject(ActivityExecution execution) {
+ if (variableName!=null) {
+ return execution.getVariable(variableName);
+
+ } else if (expression!=null) {
+ return ScriptManager.getScriptManager().evaluateExpression(expression, language);
+ }
+
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml 2009-12-10 17:02:19 UTC (rev 5943)
@@ -19,6 +19,7 @@
<activity binding="org.jbpm.jpdl.internal.activity.CustomBinding" />
<activity binding="org.jbpm.jpdl.internal.activity.AssignBinding" />
<activity binding="org.jbpm.jpdl.internal.activity.PassthroughBinding" />
+ <activity binding="org.jbpm.jpdl.internal.activity.RulesBinding" />
<activity binding="org.jbpm.jpdl.internal.activity.RulesDecisionBinding" />
<eventlistener binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Transaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Transaction.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Transaction.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -23,7 +23,10 @@
import javax.transaction.Synchronization;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.type.Variable;
+
/** provides access to the transaction in the environment.
*
* @author Tom Baeyens
@@ -40,4 +43,8 @@
/** register a transaction listener. This method will have no
* effect if the transactionListener is null. */
void registerSynchronization(Synchronization synchronization);
+
+ /** registers an object that is deserialized from the db so that it
+ * can be serialized and saved at the commit. */
+ void registerDeserializedObject(Object object, ScopeInstanceImpl scopeInstance, Variable variable);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -951,7 +951,7 @@
Variable variable = systemVariables.get(key);
if (variable!=null) {
log.debug("setting system variable '"+key+"' in '"+this+"' to value '"+value+"'");
- variable.setValue(value);
+ variable.setValue(value, this);
} else {
log.debug("creating system variable '"+key+"' in '"+this+"' to value '"+value+"'");
createSystemVariable(key, value, null);
@@ -961,7 +961,7 @@
public Object getSystemVariable(String key) {
Variable variable = systemVariables.get(key);
if (variable!=null) {
- return variable.getValue();
+ return variable.getValue(this);
}
return null;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -137,7 +137,7 @@
variable.setTask(getTask());
variable.setHistoryEnabled(isHistoryEnabled);
- variable.setValue(value);
+ variable.setValue(value, this);
long dbid = DbidGenerator.getDbidGenerator().getNextId();
variable.setDbid(dbid);
@@ -158,7 +158,7 @@
Variable variable = getVariableObject(key);
// if there is already a variable instance and it doesn't support the current type...
if ( (variable!=null)
- && (!variable.supports(value))
+ && (!variable.supports(value, this))
) {
// delete the old variable instance
log.debug("variable type change. deleting '"+key+"' from '"+this+"'");
@@ -168,7 +168,7 @@
if (variable!=null) {
log.debug("updating variable '"+key+"' in '"+this+"' to value '"+value+"'");
- variable.setValue(value);
+ variable.setValue(value, this);
} else if (getParentVariableScope()==null) {
createVariable(key, value, null, false);
@@ -189,7 +189,7 @@
public Object getVariable(String key) {
Variable variable = getVariableObject(key);
if (variable!=null) {
- return variable.getValue();
+ return variable.getValue(this);
}
ScopeInstanceImpl parentScope = getParentVariableScope();
@@ -237,7 +237,7 @@
for (Map.Entry<String, Variable> entry: variables.entrySet()) {
String name = (String) entry.getKey();
Variable variable = entry.getValue();
- Object value = variable.getValue();
+ Object value = variable.getValue(this);
values.put(name, value);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -29,6 +29,7 @@
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
import org.jbpm.pvm.internal.query.HistoryDetailQueryImpl;
@@ -37,6 +38,9 @@
import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
import org.jbpm.pvm.internal.query.TaskQueryImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.tx.jta.JtaTransaction;
+import org.jbpm.pvm.internal.type.Variable;
/**
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.type.Variable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeserializedObjects implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected List<Object[]> deserializedObjects = new ArrayList<Object[]>();
+
+ public void registerDeserializedObject(Object object, ScopeInstanceImpl scopeInstance, Variable variable) {
+ if (deserializedObjects!=null) {
+ deserializedObjects.add(new Object[] { object, scopeInstance, variable });
+ }
+ }
+
+ public void flushDeserializedObjects() {
+ List<Object[]> copy = new ArrayList<Object[]>(deserializedObjects);
+ deserializedObjects = null;
+ for (Object[] triple: copy) {
+ Object deserializedObject = triple[0];
+ ScopeInstanceImpl scopeInstance = (ScopeInstanceImpl) triple[1];
+ Variable variable = (Variable) triple[2];
+
+ String variableName = variable.getKey();
+ Object currentValue = scopeInstance.getVariable(variableName);
+
+ if ( (currentValue!=null)
+ && (currentValue==deserializedObject)
+ ) {
+ variable.setValue(deserializedObject, scopeInstance);
+ }
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -29,6 +29,8 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.Transaction;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.type.Variable;
/** simple 2 phase commit transaction.
@@ -52,6 +54,7 @@
protected List<StandardResource> resources;
protected List<StandardSynchronization> synchronizations;
protected State state = State.CREATED;
+ protected DeserializedObjects deserializedObjects = new DeserializedObjects();
// methods for interceptor //////////////////////////////////////////////////
@@ -96,6 +99,8 @@
log.trace("committing "+this);
try {
+ deserializedObjects.flushDeserializedObjects();
+
beforeCompletion();
if (resources!=null) {
@@ -237,6 +242,14 @@
return resources;
}
+ // deserialized objects /////////////////////////////////////////////////////
+
+ public void registerDeserializedObject(Object object, ScopeInstanceImpl scopeInstance, Variable variable) {
+ deserializedObjects.registerDeserializedObject(object, scopeInstance, variable);
+ }
+
+ // general methods //////////////////////////////////////////////////////////
+
public String toString() {
return "StandardTransaction["+System.identityHashCode(this)+"]";
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,6 +21,8 @@
*/
package org.jbpm.pvm.internal.tx.jta;
+import java.util.List;
+
import javax.naming.InitialContext;
import javax.transaction.Status;
import javax.transaction.Synchronization;
@@ -31,6 +33,9 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.Transaction;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.tx.DeserializedObjects;
+import org.jbpm.pvm.internal.type.Variable;
/**
@@ -45,6 +50,7 @@
protected String userTransactionJndiName = JNDINAME_USERTRANSACTION_JBOSS_GLOBAL;
protected String transactionManagerJndiName = JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL;
+ protected DeserializedObjects deserializedObjects = new DeserializedObjects();
public boolean isRollbackOnly() {
try {
@@ -88,6 +94,7 @@
public void commit() {
try {
+ deserializedObjects.flushDeserializedObjects();
lookupJeeUserTransaction().commit();
} catch (Exception e) {
throw new JbpmException("couldn't commit: "+e.getMessage(), e);
@@ -148,4 +155,10 @@
log.trace("jta transaction status: "+JtaStatusHelper.toString(status));
return status;
}
+
+ // deserialized objects /////////////////////////////////////////////////////
+
+ public void registerDeserializedObject(Object object, ScopeInstanceImpl scopeInstance, Variable variable) {
+ deserializedObjects.registerDeserializedObject(object, scopeInstance, variable);
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -23,6 +23,8 @@
import java.io.Serializable;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
/**
* @author Tom Baeyens
*/
@@ -31,15 +33,15 @@
/**
* is true if this converter supports the given type, false otherwise.
*/
- boolean supports(Object value);
+ boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable);
/**
* converts a given object to its persistable format.
*/
- Object convert(Object o);
+ Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable);
/**
* reverts a persisted object to its original formResourceName.
*/
- Object revert(Object o);
+ Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -28,8 +28,8 @@
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.HistorySession;
import org.jbpm.pvm.internal.history.events.VariableUpdate;
-import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
/**
@@ -70,19 +70,19 @@
// variable management //////////////////////////////////////////////////////
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance) {
if (converter!=null) {
- return converter.supports(value);
+ return converter.supports(value, scopeInstance, this);
}
return isStorable(value);
}
- public void setValue(Object value) {
+ public void setValue(Object value, ScopeInstanceImpl scopeInstance) {
if (converter!=null) {
- if (! converter.supports(value)) {
+ if (! converter.supports(value, scopeInstance, this)) {
throw new JbpmException("the converter '"+converter.getClass().getName()+"' in variable instance '"+this.getClass().getName()+"' does not support values of type '"+value.getClass().getName()+"'. to change the type of a variable, you have to delete it first");
}
- value = converter.convert(value);
+ value = converter.convert(value, scopeInstance, this);
}
if ( (value!=null)
&& (! this.isStorable(value)) ) {
@@ -98,11 +98,11 @@
}
}
- public Object getValue() {
+ public Object getValue(ScopeInstanceImpl scopeInstance) {
Object value = getObject();
if ( (value!=null)
&& (converter!=null) ) {
- value = converter.revert(value);
+ value = converter.revert(value, scopeInstance, this);
}
return value;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,7 +21,9 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class BooleanToStringConverter implements Converter {
@@ -30,12 +32,12 @@
public static final String TRUE_TEXT = "T";
public static final String FALSE_TEXT = "F";
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Boolean.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
String convertedValue = FALSE_TEXT;
if (((Boolean)o).booleanValue()) {
convertedValue = TRUE_TEXT;
@@ -43,7 +45,7 @@
return convertedValue;
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
Boolean revertedValue = Boolean.FALSE;
if (TRUE_TEXT.equals(o)) {
revertedValue = Boolean.TRUE;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class ByteToLongConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Byte.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Long( ((Number)o).longValue() );
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Byte(((Long)o).byteValue());
}
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class CharacterToStringConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Character.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return o.toString();
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Character(((String)o).charAt(0));
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -23,22 +23,24 @@
import java.util.Date;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class DateToLongConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (Date.class.isAssignableFrom(value.getClass()));
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Long(((Date)o).getTime());
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Date(((Long)o).longValue());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -27,7 +27,9 @@
import java.util.Date;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
/**
* @author Tom Baeyens
@@ -38,11 +40,11 @@
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return dateFormat.format((Date)o);
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
try {
return dateFormat.parseObject((String)o);
} catch (ParseException e) {
@@ -50,7 +52,7 @@
}
}
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
return ((value!=null) && (value instanceof Date));
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class DoubleToStringConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Double.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return o.toString();
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Double((String)o);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class FloatToDoubleConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Float.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Double(((Float)o).doubleValue());
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Float(((Double)o).floatValue());
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class FloatToStringConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Float.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return o.toString();
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Float((String)o);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class IntegerToLongConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (Integer.class.equals(value.getClass()));
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Long( ((Number)o).longValue() );
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Integer(((Long)o).intValue());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -29,18 +29,23 @@
import java.io.Serializable;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.env.Transaction;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class SerializableToBytesConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return Serializable.class.isAssignableFrom(value.getClass());
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
byte[] bytes = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -55,12 +60,20 @@
return bytes;
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
byte[] bytes = (byte[]) o;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
- return ois.readObject();
+ Object object = ois.readObject();
+
+ Transaction transaction = EnvironmentImpl.getFromCurrent(Transaction.class, false);
+ if (transaction!=null) {
+ transaction.registerDeserializedObject(object, scopeInstance, variable);
+ }
+
+ return object;
+
} catch (Exception e) {
throw new JbpmException("couldn't deserialize object", e);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -21,22 +21,24 @@
*/
package org.jbpm.pvm.internal.type.converter;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Variable;
public class ShortToLongConverter implements Converter {
private static final long serialVersionUID = 1L;
- public boolean supports(Object value) {
+ public boolean supports(Object value, ScopeInstanceImpl scopeInstance, Variable variable) {
if (value==null) return true;
return (value.getClass()==Short.class);
}
- public Object convert(Object o) {
+ public Object convert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Long( ((Number)o).longValue() );
}
- public Object revert(Object o) {
+ public Object revert(Object o, ScopeInstanceImpl scopeInstance, Variable variable) {
return new Short(((Long)o).shortValue());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -23,6 +23,7 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.type.Variable;
@@ -31,6 +32,7 @@
private static final long serialVersionUID = 1L;
protected Lob lob = null;
+ protected Object cachedValue = null;
public boolean isStorable(Object value) {
if (value==null) return true;
@@ -52,6 +54,19 @@
this.lob = new Lob((byte[])value, true);
}
+ public Object getValue(ScopeInstanceImpl scopeInstance) {
+ if (cachedValue!=null) {
+ return cachedValue;
+ }
+ cachedValue = super.getValue(scopeInstance);
+ return cachedValue;
+ }
+
+ public void setValue(Object value, ScopeInstanceImpl scopeInstance) {
+ super.setValue(value, scopeInstance);
+ cachedValue = value;
+ }
+
public Lob getLob() {
return lob;
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -33,7 +33,6 @@
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.type.variable.BlobVariable;
-import org.jbpm.pvm.internal.type.variable.ClobVariable;
import org.jbpm.pvm.internal.type.variable.DoubleVariable;
import org.jbpm.pvm.internal.type.variable.LongVariable;
import org.jbpm.pvm.internal.type.variable.StringVariable;
@@ -211,7 +210,7 @@
assertEquals(BlobVariable.class, variable.getClass());
BlobVariable blobVariable = (BlobVariable) variable;
- byte[] blobVariableBytes = (byte[]) blobVariable.getValue();
+ byte[] blobVariableBytes = (byte[]) blobVariable.getValue(execution);
assertTrue(Arrays.equals(bytes, blobVariableBytes));
}
@@ -258,7 +257,7 @@
assertTrue(Arrays.equals(expected, blobVariableBytes));
- Object deserialized = blobVariable.getValue();
+ Object deserialized = blobVariable.getValue(execution);
assertNotNull(deserialized);
assertEquals(testSerializable, deserialized);
}
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2009-12-10 11:15:51 UTC (rev 5942)
+++ jbpm4/trunk/modules/test-db/pom.xml 2009-12-10 17:02:19 UTC (rev 5943)
@@ -58,6 +58,14 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<scope>test</scope>
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/Room.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/Room.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/Room.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.rules;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Room implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ int temperature = 21;
+ boolean smoke = false;
+ boolean isOnFire = false;
+
+ public Room(int temperature, boolean smoke) {
+ this.temperature = temperature;
+ this.smoke = smoke;
+ }
+
+ public int getTemperature() {
+ return temperature;
+ }
+ public void setTemperature(int temperature) {
+ this.temperature = temperature;
+ }
+ public boolean isSmoke() {
+ return smoke;
+ }
+ public void setSmoke(boolean smoke) {
+ this.smoke = smoke;
+ }
+ public boolean isOnFire() {
+ return isOnFire;
+ }
+ public void setOnFire(boolean isOnFire) {
+ this.isOnFire = isOnFire;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/Room.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/RulesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/RulesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/RulesTest.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.rules;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesTest extends JbpmTestCase {
+
+ String deploymentId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/rules/process.jpdl.xml")
+ .addResourceFromClasspath("org/jbpm/examples/rules/rules.drl")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+
+ super.tearDown();
+ }
+
+
+ public void testRoomOnFire() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("room", new Room(350, true));
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Rules", variables);
+
+ assertTrue(processInstance.isActive("getFireExtinguisher"));
+ }
+
+ public void testRoomWithoutFire() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("room", new Room(21, false));
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Rules", variables);
+
+ assertTrue(processInstance.isActive("goToPub"));
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rules/RulesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rulesdecision (from rev 5935, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision)
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java 2009-12-09 03:22:10 UTC (rev 5935)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -40,7 +40,7 @@
deploymentId = repositoryService.createDeployment()
.addResourceFromClasspath("org/jbpm/examples/rulesdecision/process.jpdl.xml")
- .addResourceFromClasspath("org/jbpm/examples/rulesdecision/isImportant.drl")
+ .addResourceFromClasspath("org/jbpm/examples/rulesdecision/rules.drl")
.deploy();
}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.activity.custom.CustomConfigurationsTest.MyCustomAutomatic;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SerializedVariableUpdate extends JbpmTestCase {
+
+ public static class UpdateAndReplace implements ActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ Set<String> messages = (Set<String>) execution.getVariable("messages");
+ messages.clear();
+ messages.add("i");
+ messages.add("was");
+ messages.add("updated");
+
+ Set<String> newMessagesObject = new HashSet<String>();
+ newMessagesObject.add("completely");
+ newMessagesObject.add("new");
+ newMessagesObject.add("object");
+ execution.setVariable("messages", newMessagesObject);
+ }
+
+ }
+
+ public void testSerializableVariableUpdate() {
+ deployJpdlXmlString(
+ "<process name='SerializedVariableUpdate'>" +
+ " <start>" +
+ " <transition to='wait before' />" +
+ " </start>" +
+ " <state name='wait before'>" +
+ " <transition to='update' />" +
+ " </state>" +
+ " <custom name='update' class='"+UpdateAndReplace.class.getName()+"'>" +
+ " <transition to='wait after' />" +
+ " </custom>" +
+ " <state name='wait after'/>" +
+ "</process>"
+ );
+
+ Set<String> messages = new HashSet<String>();
+ messages.add("serialize");
+ messages.add("me");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("messages", messages);
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("SerializedVariableUpdate", variables);
+ String pid = processInstance.getId();
+ executionService.signalExecutionById(pid);
+
+ Set<String> expectedMessages = new HashSet<String>();
+ expectedMessages.add("completely");
+ expectedMessages.add("new");
+ expectedMessages.add("object");
+
+ messages = (Set<String>) executionService.getVariable(pid, "messages");
+ assertEquals(expectedMessages, messages);
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Rules" xmlns="http://jbpm.org/4/jpdl">
+
+ <start g="49,93,80,40">
+ <transition to="evaluateStatus"/>
+ </start>
+
+ <rules name="evaluateStatus">
+ <fact var="room" />
+ <transition to="checkForFires"/>
+ </rules>
+
+ <decision g="215,93,80,40" name="checkForFires">
+ <transition to="getFireExtinguisher" g="240,69:">
+ <condition expr="#{room.onFire}" />
+ </transition>
+ <transition to="goToPub" g="240,164:"/>
+ </decision>
+
+ <state g="294,43,120,52" name="getFireExtinguisher"/>
+ <state g="292,139,124,49" name="goToPub"/>
+
+</process>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/rules.drl
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/rules.drl (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/rules.drl 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,6 @@
+rule "CheckRoomOnFire"
+ when
+ room : org.jbpm.examples.rules.Room( temperature > 30, smoke == true )
+ then
+ room.setOnFire( true );
+end
Copied: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision (from rev 5935, jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision)
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl 2009-12-09 03:22:10 UTC (rev 5935)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl 2009-12-10 17:02:19 UTC (rev 5943)
@@ -1,25 +0,0 @@
-global java.lang.Integer amount;
-global java.lang.String product;
-global org.jbpm.jpdl.internal.rules.Outcome outcome;
-
-rule "LessThen3IsIrrelevant"
- when
- eval(amount < 3)
- then
- outcome.set("irrelevant");
-end
-
-rule "MoreThen24IsImportant"
- when
- eval(amount > 24)
- then
- outcome.set("important");
-end
-
-rule "TwelveTempranillosIsImportant"
- when
- eval(product == "Tempranillo")
- eval(amount > 12)
- then
- outcome.set("important");
-end
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/rules.drl
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/rules.drl (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rulesdecision/rules.drl 2009-12-10 17:02:19 UTC (rev 5943)
@@ -0,0 +1,25 @@
+global java.lang.Integer amount;
+global java.lang.String product;
+global org.jbpm.jpdl.internal.rules.Outcome outcome;
+
+rule "LessThen3IsIrrelevant"
+ when
+ eval(amount < 3)
+ then
+ outcome.set("irrelevant");
+end
+
+rule "MoreThen24IsImportant"
+ when
+ eval(amount > 24)
+ then
+ outcome.set("important");
+end
+
+rule "TwelveTempranillosIsImportant"
+ when
+ eval(product == "Tempranillo")
+ eval(amount > 12)
+ then
+ outcome.set("important");
+end
More information about the jbpm-commits
mailing list