[jbpm-commits] JBoss JBPM SVN: r3587 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/builder and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 5 16:43:55 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-01-05 16:43:54 -0500 (Mon, 05 Jan 2009)
New Revision: 3587
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/CompositeBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/FlowBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/NodeBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/PvmProcessBuilder.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/BuilderTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Decision.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/DecisionBuilder.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Sequence.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/SequenceBuilder.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.png
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
travel work
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/CompositeBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/CompositeBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/CompositeBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,58 @@
+/*
+ * 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.builder;
+
+import java.lang.reflect.Constructor;
+
+import org.jbpm.pvm.internal.model.CompositeElementImpl;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class CompositeBuilder {
+
+ private static final Class<?>[] NODEBUILDER_PARAMTYPES = new Class<?>[]{CompositeBuilder.class};
+ protected CompositeElementImpl compositeElement;
+
+ protected NodeImpl createNode() {
+ return compositeElement.createNode();
+ }
+
+ protected <T extends NodeBuilder> T startNode(Class<T> nodeBuilderType) {
+ if (nodeBuilderType==null) {
+ throw new RuntimeException("nodeBuilderType is null");
+ }
+ try {
+ Constructor<T> constructor = nodeBuilderType.getConstructor(NODEBUILDER_PARAMTYPES);
+ T nodeBuilder = constructor.newInstance(new Object[]{this});
+ return nodeBuilder;
+ } catch (Exception e) {
+ throw new RuntimeException("couldn't instantiate node builder type "+nodeBuilderType.getName(), e);
+ }
+ }
+
+ public abstract ProcessDefinitionImpl endProcess();
+ public abstract CompositeBuilder endNode();
+}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/FlowBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/FlowBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/FlowBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,53 @@
+/*
+ * 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.builder;
+
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FlowBuilder {
+
+ protected NodeBuilder<?> nodeBuilder;
+ protected TransitionImpl transition;
+
+ public FlowBuilder(NodeBuilder<?> nodeBuilder, TransitionImpl transition) {
+ this.nodeBuilder = nodeBuilder;
+ this.transition = transition;
+ }
+
+ public FlowBuilder name(String name) {
+ transition.setName(name);
+ return this;
+ }
+
+ public FlowBuilder expr(String expression) {
+ // transition.setExpression(expression);
+ return this;
+ }
+
+ public NodeBuilder<NodeBuilder<?>> endFlow() {
+ return (NodeBuilder) nodeBuilder;
+ }
+}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/NodeBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/NodeBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/NodeBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -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.builder;
+
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NodeBuilder<T> extends CompositeBuilder {
+
+ /** the enclosing composite */
+ protected CompositeBuilder compositeBuilder;
+ protected NodeImpl node;
+
+ protected NodeBuilder(CompositeBuilder compositeBuilder) {
+ this.compositeBuilder = compositeBuilder;
+ this.node = compositeBuilder.createNode();
+ }
+
+ public CompositeBuilder endNode() {
+ return compositeBuilder;
+ }
+
+ public FlowBuilder startFlowTo(String to) {
+ // TransitionImpl flow = node.createOutgoingTransition();
+ return null;
+ }
+
+ public ProcessDefinitionImpl endProcess() {
+ return compositeBuilder.endProcess();
+ }
+
+ public T name(String name) {
+ compositeElement.setName(name);
+ return (T) this;
+ }
+
+
+ public T flow(String to) {
+ startFlowTo(to);
+ return (T) this;
+ }
+
+ public T flow(String to, String name) {
+ startFlowTo(to).name(name);
+ return (T) this;
+ }
+
+}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/PvmProcessBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/PvmProcessBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/builder/PvmProcessBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,62 @@
+/*
+ * 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.builder;
+
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmProcessBuilder extends CompositeBuilder {
+
+ protected ProcessDefinitionImpl processDefinition;
+
+ protected PvmProcessBuilder(ProcessDefinitionImpl processDefinition) {
+ this.processDefinition = processDefinition;
+ }
+
+ public static PvmProcessBuilder startProcess() {
+ return new PvmProcessBuilder(new ProcessDefinitionImpl());
+ }
+
+ public ProcessDefinitionImpl endProcess() {
+ return processDefinition;
+ }
+
+ public PvmProcessBuilder name(String name) {
+ processDefinition.setName(name);
+ return this;
+ }
+
+ public PvmProcessBuilder key(String key) {
+ processDefinition.setKey(key);
+ return this;
+ }
+
+ public <T extends NodeBuilder> T startNode(Class<T> nodeBuilderType) {
+ return super.startNode(nodeBuilderType);
+ }
+
+ public CompositeBuilder endNode() {
+ throw new UnsupportedOperationException("calling endNode on a processBuilder is invalid");
+ }
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java 2009-01-02 05:08:29 UTC (rev 3586)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -44,7 +44,7 @@
* creates a nested node. Also the nested node's parent pointer will be set
* appropriatly.
*/
- public Node createNode() {
+ public NodeImpl createNode() {
return createNode(null);
}
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/BuilderTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/BuilderTest.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/BuilderTest.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -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.builder;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BuilderTest extends JbpmTestCase {
+
+ public void testBuilder() {
+ ProcessDefinition processDefinition = PvmProcessBuilder.startProcess()
+ .name("insurance claim")
+/*
+ .startNode(DecisionBuilder.class)
+ .name("decision")
+ .expr("expression")
+ .flow("one")
+ .flow("three", "langs hier")
+ .startFlowTo("")
+ .expr("#{mount > 20}")
+ .endFlow()
+ .endNode()
+ .startNode(SequenceBuilder.class)
+ .name("sequence")
+ .startNode(DecisionBuilder.class)
+ .name("one")
+ .endNode()
+ .startNode(DecisionBuilder.class)
+ .name("two")
+ .endNode()
+ .startNode(DecisionBuilder.class)
+ .name("three")
+ .endNode()
+ .endNode()
+*/
+ .endProcess();
+ }
+}
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Decision.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Decision.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Decision.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,40 @@
+/*
+ * 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.builder;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Decision implements Activity {
+
+ private static final long serialVersionUID = 1L;
+
+ String expression;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ }
+
+}
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/DecisionBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/DecisionBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/DecisionBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,41 @@
+/*
+ * 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.builder;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionBuilder extends NodeBuilder<DecisionBuilder> {
+
+ Decision decision = new Decision();
+
+ public DecisionBuilder(CompositeBuilder compositeBuilder) {
+ super(compositeBuilder);
+ }
+
+ public DecisionBuilder expr(String expression) {
+ decision.expression = expression;
+ return this;
+ }
+}
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Sequence.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Sequence.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/Sequence.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,38 @@
+/*
+ * 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.builder;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Sequence implements Activity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ }
+
+}
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/SequenceBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/SequenceBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/builder/SequenceBuilder.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,40 @@
+/*
+ * 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.builder;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SequenceBuilder extends NodeBuilder<SequenceBuilder> {
+
+ Sequence sequence = new Sequence();
+
+ protected SequenceBuilder(CompositeBuilder compositeBuilder) {
+ super(compositeBuilder);
+ node.setBehaviour(sequence);
+ }
+
+ public <T extends NodeBuilder> T startNode(Class<T> nodeBuilderType) {
+ return super.startNode(nodeBuilderType);
+ }
+}
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java 2009-01-02 05:08:29 UTC (rev 3586)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -34,7 +34,7 @@
*/
public class BasicVariablesTest extends DbTestCase {
- public void testNoVariables() {
+ public void testStartProcessInstanceWithoutVariables() {
deployJpdlXmlString(
"<process name='var'>" +
" <start name='a'>" +
@@ -50,7 +50,7 @@
assertEquals(0, variableNames.size());
}
- public void testThreeVariables() {
+ public void testStartProcessInstanceWithThreeVariables() {
deployJpdlXmlString(
"<process name='var'>" +
" <start name='a'>" +
@@ -79,4 +79,38 @@
assertEquals(expectedVariables, variables);
}
+
+ public void testSetAndUpdateVariable() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("var", "one");
+ executionService.setVariable("var/one", "msg", "hello");
+ assertEquals("hello", executionService.getVariable("var/one", "msg"));
+ executionService.setVariable("var/one", "msg", "world");
+ assertEquals("world", executionService.getVariable("var/one", "msg"));
+ }
+
+ public void testUpdateVariableToDifferentType() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("var", "one");
+ executionService.setVariable("var/one", "msg", "hello");
+ assertEquals("hello", executionService.getVariable("var/one", "msg"));
+ executionService.setVariable("var/one", "msg", new Integer(5));
+ assertEquals(new Integer(5), executionService.getVariable("var/one", "msg"));
+ }
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java 2009-01-05 21:43:54 UTC (rev 3587)
@@ -0,0 +1,122 @@
+/*
+ * 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.io.Serializable;
+import java.util.Date;
+
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableBasicTypesTest extends DbTestCase {
+
+ public void checkVariableValue(Object variableValue) {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("var", "one");
+ executionService.setVariable("var/one", "msg", variableValue);
+ assertEquals(variableValue, executionService.getVariable("var/one", "msg"));
+ }
+
+ public void testVariableTypeString() {
+ checkVariableValue("hello");
+ }
+
+ public void testVariableTypeCharacter() {
+ checkVariableValue(new Character('x'));
+ }
+
+ public void testVariableTypeBoolean() {
+ checkVariableValue(Boolean.TRUE);
+ }
+
+ public void testVariableTypeByte() {
+ checkVariableValue(new Byte((byte)5));
+ }
+
+ public void testVariableTypeShort() {
+ checkVariableValue(new Short((short)5));
+ }
+
+ public void testVariableTypeInteger() {
+ checkVariableValue(new Integer(5));
+ }
+
+ public void testVariableTypeLong() {
+ checkVariableValue(new Long(5));
+ }
+
+ public void testVariableTypeFloat() {
+ checkVariableValue(new Float(5.7));
+ }
+
+ public void testVariableTypeDouble() {
+ checkVariableValue(new Double(5.7));
+ }
+
+ public void testVariableTypeDate() {
+ checkVariableValue(new Date());
+ }
+
+ public static class SerializeMe implements Serializable {
+ private static final long serialVersionUID = 1L;
+ String text;
+ public SerializeMe(String text) {
+ this.text = text;
+ }
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((text == null) ? 0 : text.hashCode());
+ return result;
+ }
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SerializeMe other = (SerializeMe) obj;
+ if (text == null) {
+ if (other.text != null)
+ return false;
+ } else if (!text.equals(other.text))
+ return false;
+ return true;
+ }
+ }
+
+ public void testVariableTypeSerializable() {
+ checkVariableValue(new SerializeMe("hello world"));
+ }
+}
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-01-02 05:08:29 UTC (rev 3586)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-01-05 21:43:54 UTC (rev 3587)
@@ -474,6 +474,66 @@
</section>
+ <section id="concurrency">
+ <title><literal>concurrency</literal></title>
+ <para>With the <literal>fork</literal> and <literal>join</literal> activities,
+ concurrent paths of executions can be modeled.
+ </para>
+ <para>For example:</para>
+ <figure id="process.concurrency">
+ <title>The concurrency example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.concurrency.png"/></imageobject></mediaobject>
+ </figure>
+
+ <programlisting><process name="ConcurrencyGraphBased" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="fork"/>
+ </start>
+
+ <emphasis role="bold"><fork name="fork">
+ <flow to="send invoice" />
+ <flow to="load truck"/>
+ <flow to="print shipping documents" />
+ </fork></emphasis>
+
+ <state name="send invoice" >
+ <flow to="final join" />
+ </state>
+
+ <state name="load truck" >
+ <flow to="shipping join" />
+ </state>
+
+ <state name="print shipping documents">
+ <flow to="shipping join" />
+ </state>
+
+ <emphasis role="bold"><join name="shipping join" >
+ <flow to="drive truck to destination" />
+ </join></emphasis>
+
+ <state name="drive truck to destination" >
+ <flow to="final join" />
+ </state>
+
+ <emphasis role="bold"><join name="final join" >
+ <flow to="end"/>
+ </join></emphasis>
+
+ <end name="end" />
+
+</process></programlisting>
+ </section>
+
+
+
+
+
+
+
+
+
<section id="end">
<title><literal>end</literal></title>
<para>Ends the execution.
More information about the jbpm-commits
mailing list