JBoss JBPM SVN: r5056 - projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-06-18 06:22:56 -0400 (Thu, 18 Jun 2009)
New Revision: 5056
Modified:
projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/Application.html
Log:
Fix JBPM-2338: Blank page upon login
Modified: projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/Application.html
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/Application.html 2009-06-18 09:52:17 UTC (rev 5055)
+++ projects/gwt-console/trunk/gui/war/src/main/resources/org/jboss/bpm/console/public/Application.html 2009-06-18 10:22:56 UTC (rev 5056)
@@ -3,14 +3,14 @@
<title>GWT Console Application</title>
<!-- BPM console configuration -->
- <script type="text/javascript" src="console.config.js"/>
+ <script src="console.config.js" type="text/javascript"></script>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
- <script language='javascript' src='org.jboss.bpm.console.Application.nocache.js'/>
+ <script src="org.jboss.bpm.console.Application.nocache.js" type="text/javascript"></script>
<link rel="stylesheet" href="console.css" type="text/css">
16 years, 10 months
JBoss JBPM SVN: r5055 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/action and 3 other directories.
by do-not-reply@jboss.org
Author: jim.ma
Date: 2009-06-18 05:52:17 -0400 (Thu, 18 Jun 2009)
New Revision: 5055
Added:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Decision.java
Modified:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Node.java
jbpm4/branches/jimma/modules/migration/src/main/resources/action.converter.types.xml
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Log:
Added event and script conversion support
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -165,7 +165,8 @@
readActions(root, null, null);
readNodes(root, jpdl4Document.getRootElement());
- /* readEvents(root, jpdl4Document);
+ readEvents(root, jpdl4Document.getRootElement());
+ /*
readExceptionHandlers(root, jpdl4Document);
*/
readTasks(root, jpdl4Document.getRootElement());
@@ -303,15 +304,18 @@
if (tasks != null && tasks.length > 0) {
for (int i = 0 ; i < tasks.length; i++) {
Element tmpTask = tasks[i];
- Element task4 = readTask(tmpTask, jpdl4Element);
+ Element task4 = readTask(tmpTask, jpdl4Element);
+
if (i ==0 ) {
task4.addAttribute("name", element.attributeValue("name"));
+ } else{
+ task4.addAttribute("name", tmpTask.attributeValue("name"));
}
if (i+1 < tasks.length) {
Element newTransistion = task4.addElement("transition");
String to = tasks[i+1].attributeValue("name");
newTransistion.addAttribute("name", to);
- newTransistion.addAttribute("to", "to");
+ newTransistion.addAttribute("to", to);
} else {
//The last task node
List<Element> transitions = element.elements("transition");
@@ -359,7 +363,7 @@
// parse common subelements
//TODO: convert the task timer
//readTaskTimers(taskElement, task);
- //readEvents(taskElement, task);
+ readEvents(taskElement, jpdlElement);
//readExceptionHandlers(taskElement, task);
// TODO:duedate and priority
@@ -567,7 +571,7 @@
*/
// parse common subelements
readNodeTimers(nodeElement, jpdl4Element);
- //readEvents(nodeElement, jpdl4Element);
+ readEvents(nodeElement, jpdl4Element);
//readExceptionHandlers(nodeElement, jpdl4Element);
// save the transitions and parse them at the end
@@ -616,13 +620,25 @@
protected void readTaskTimer(Element timerElement, Task task)
{
}
-
- protected void readEvents(Element parentElement, Element jpdl4doc)
+ */
+ public void readEvents(Element parentElement, Element jpdl4Element)
{
+ Iterator<?> iter = parentElement.elementIterator("event");
+ while (iter.hasNext())
+ {
+ Element eventElement = (Element)iter.next();
+ //String eventType = eventElement.attributeValue("type");
+ //TODO:how to handle the event type
+ Element onElement = jpdl4Element.addElement("on");
+ //TODO:look at how to convert event type
+ String type = eventElement.attributeValue("type");
+ onElement.addAttribute("event", type);
+ readActions(eventElement, onElement, type);
+ }
}
- */
+
public void readActions(Element eventElement, Element jpdl4Element, String eventType)
{ // for all the elements in the event element
Iterator<?> nodeElementIter = eventElement.elementIterator();
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -54,7 +54,7 @@
public void read(Element actionElement, Jpdl3ConverterReader jpdlReader) {
String expression = actionElement.attributeValue("expression");
if (expression!=null) {
- convertedElement.addAttribute("expr", "expression");
+ convertedElement.addAttribute("expr", expression);
convertedElement.addAttribute("lang", "juel");
} else if (actionElement.attribute("ref-name")!=null) {
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Script.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -0,0 +1,51 @@
+/*
+ * 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.convert.action;
+
+import org.dom4j.Element;
+import org.jbpm.jpdl.internal.convert.Jpdl3ConverterReader;
+
+public class Script extends Action {
+ @Override
+ public Element createConvertedElement(Element actionElement,
+ Element jpdl4Doc) {
+ convertedElement = jpdl4Doc.addElement("script");
+ return convertedElement;
+ }
+
+ @Override
+ public void read(Element actionElement, Jpdl3ConverterReader jpdlReader) {
+ String expression = null;
+ if (actionElement.isTextOnly()) {
+ expression = actionElement.getText();
+ } else {
+ /*
+ * this.variableAccesses = new HashSet<VariableAccess>(
+ * jpdlReader.readVariableAccesses(scriptElement));
+ */
+ expression = actionElement.element("expression").getText();
+ }
+ Element txtElement = convertedElement.addElement("text");
+ txtElement.addText(expression);
+ }
+
+}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Decision.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Decision.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Decision.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -0,0 +1,37 @@
+/*
+ * 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.convert.node;
+
+import org.dom4j.Element;
+import org.jbpm.jpdl.internal.convert.Jpdl3ConverterReader;
+
+public class Decision extends Node {
+ public Element createConvertedElement(Element jpdl4Doc) {
+ convertedElement = jpdl4Doc.addElement("decision");
+ return convertedElement;
+ }
+
+ public void read(Jpdl3ConverterReader reader) {
+
+
+ }
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Node.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Node.java 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/Node.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -39,6 +39,7 @@
//TODO:implement it
Element actionElement = nodeElement.element("action");
action.read(actionElement, reader);
+
}
public Element getConvertedElement() {
Modified: jbpm4/branches/jimma/modules/migration/src/main/resources/action.converter.types.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/resources/action.converter.types.xml 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/main/resources/action.converter.types.xml 2009-06-18 09:52:17 UTC (rev 5055)
@@ -2,6 +2,6 @@
<action-type element="action" class="org.jbpm.jpdl.internal.convert.action.Action" />
<action-type element="create-timer" class="org.jbpm.scheduler.def.CreateTimerAction" />
<action-type element="cancel-timer" class="org.jbpm.scheduler.def.CancelTimerAction" />
- <action-type element="script" class="org.jbpm.graph.action.Script" />
+ <action-type element="script" class="org.jbpm.jpdl.internal.convert.action.Script" />
<action-type element="mail" class="org.jbpm.graph.action.MailAction" />
</action-types>
\ No newline at end of file
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -26,13 +26,14 @@
import org.dom4j.Document;
import org.jbpm.api.Problem;
+import org.jbpm.api.env.EnvironmentFactory;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.xml.sax.InputSource;
-public class Jpdl3ConverterReaderTest {
-
+public class Jpdl3ConverterReaderTest {
@Test
public void testSimpleProcesss() throws Exception {
testConvert("simple.xml");
@@ -43,7 +44,19 @@
testConvert("businesstrip.xml");
}
- public void testConvert(String resourcefile) throws Exception {
+ @Test
+ public void testAssignment() throws Exception {
+ testConvert("assignment.xml");
+ }
+
+ @Test
+ public void testEvent() throws Exception {
+ setUpScriptManager();
+ testConvert("process-event.xml");
+ }
+
+
+ private void testConvert(String resourcefile) throws Exception {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resourcefile);
//Convert to process file to jpdl4
InputSource ins = new InputSource(inputStream);
@@ -54,4 +67,19 @@
List<Problem> problems = new JpdlParser().createParse().setString(doc.asXML()).execute().getProblems();
Assert.assertEquals(problems.toString(), 0, problems.size());
}
+
+
+ private void setUpScriptManager() throws Exception {
+ EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <process-engine-context>"
+ + " <script-manager default-expression-language='juel'"
+ + " default-script-language='juel'"
+ + " read-contexts='execution, environment, process-engine' "
+ + " write-context='execution'>"
+ + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
+ + " </script-manager>"
+ + " </process-engine-context> </jbpm-configuration>");
+
+ environmentFactory.openEnvironment();
+ }
}
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-06-17 21:20:43 UTC (rev 5054)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-06-18 09:52:17 UTC (rev 5055)
@@ -24,7 +24,9 @@
import java.net.URL;
import java.util.List;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
import org.jbpm.api.Problem;
+import org.jbpm.api.env.EnvironmentFactory;
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.junit.Assert;
import org.junit.Ignore;
@@ -47,8 +49,19 @@
public void testDescision() throws Exception {
testConvert("testDecision.xml");
}
- @Ignore
+ @Test
public void testEvent() throws Exception {
+ EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <process-engine-context>"
+ + " <script-manager default-expression-language='juel'"
+ + " default-script-language='juel'"
+ + " read-contexts='execution, environment, process-engine' "
+ + " write-context='execution'>"
+ + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
+ + " </script-manager>"
+ + " </process-engine-context> </jbpm-configuration>");
+
+ environmentFactory.openEnvironment();
testConvert("process-event.xml");
}
16 years, 10 months
JBoss JBPM SVN: r5054 - in jbpm3/branches/jbpm-3.2-soa: modules/core/src/main/java/org/jbpm/db and 2 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-06-17 17:20:43 -0400 (Wed, 17 Jun 2009)
New Revision: 5054
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
jbpm3/branches/jbpm-3.2-soa/profiles.xml.example
Log:
JBPM-2292: Move jBPM3-SOA continuous integration to QA lab (RESOLVED)
Have JbpmSchema recreate the connection provider in each operation as SchemaExport does
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-06-17 17:24:36 UTC (rev 5053)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-06-17 21:20:43 UTC (rev 5054)
@@ -25,7 +25,6 @@
import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -80,9 +79,8 @@
Configuration configuration = persistenceServiceFactory.getConfiguration();
JbpmSchema jbpmSchema = new JbpmSchema(configuration);
- Map rowsPerTable = jbpmSchema.getRowsPerTable();
- for (Iterator i = rowsPerTable.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Entry) i.next();
+ for (Iterator i = jbpmSchema.getRowsPerTable().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
Long count = (Long) entry.getValue();
if (count.intValue() != 0) {
hasLeftOvers = true;
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-06-17 17:24:36 UTC (rev 5053)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-06-17 21:20:43 UTC (rev 5054)
@@ -46,6 +46,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.ConnectionProviderFactory;
import org.hibernate.mapping.Table;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
@@ -58,17 +59,17 @@
*/
public class JbpmSchema {
- final Configuration configuration;
- final Settings settings;
+ private final Configuration configuration;
+ private final Settings settings;
- ConnectionProvider connectionProvider = null;
- Connection connection = null;
+ private ConnectionProvider connectionProvider;
+ private Connection connection;
- final List exceptions = new ArrayList();
+ private final List exceptions = new ArrayList();
public JbpmSchema(Configuration configuration) {
this.configuration = configuration;
- this.settings = configuration.buildSettings();
+ settings = configuration.buildSettings();
}
public String[] getCreateSql() {
@@ -101,8 +102,7 @@
DatabaseMetaData metaData = connection.getMetaData();
boolean storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
- ResultSet resultSet = metaData.getTables(settings.getDefaultCatalogName(),
- settings.getDefaultSchemaName(), null, new String[] { "TABLE" });
+ ResultSet resultSet = metaData.getTables(settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), null, new String[] { "TABLE" });
try {
while (resultSet.next()) {
String tableName = resultSet.getString("TABLE_NAME");
@@ -218,8 +218,7 @@
public void createTable(String tableName) {
Table table = findTableMapping(tableName);
- String sql = table.sqlCreateString(settings.getDialect(), configuration.buildMapping(),
- settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
+ String sql = table.sqlCreateString(settings.getDialect(), configuration.buildMapping(), settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
try {
execute(new String[] { sql });
}
@@ -232,9 +231,7 @@
Table table = findTableMapping(tableName);
try {
createConnection();
- Iterator sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(),
- getTableMetadata(table), settings.getDefaultCatalogName(),
- settings.getDefaultSchemaName());
+ Iterator sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(), getTableMetadata(table), settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
Statement statement = connection.createStatement();
while (sqls.hasNext()) {
@@ -267,43 +264,47 @@
private TableMetadata getTableMetadata(Table table) throws SQLException {
DatabaseMetadata databaseMetadata = new DatabaseMetadata(connection, settings.getDialect());
- return databaseMetadata.getTableMetadata(table.getName(),
- table.getSchema() == null ? settings.getDefaultSchemaName() : table.getSchema(),
- table.getCatalog() == null ? settings.getDefaultCatalogName() : table.getCatalog(),
- table.isQuoted());
+ return databaseMetadata.getTableMetadata(table.getName(), table.getSchema() == null ? settings.getDefaultSchemaName()
+ : table.getSchema(), table.getCatalog() == null ? settings.getDefaultCatalogName()
+ : table.getCatalog(), table.isQuoted());
}
public static void main(String[] args) {
- if ((args == null) || (args.length == 0)) {
- syntax();
+ if (args.length == 0) syntax();
+
+ if ("scripts".equalsIgnoreCase(args[0]) && args.length >= 3 && args.length <= 5) {
+ JbpmSchema jbpmSchema = new JbpmSchema(createConfiguration(args, 3));
+ jbpmSchema.saveSqlScripts(args[1], args[2]);
}
- else if ("create".equalsIgnoreCase(args[0]) && args.length <= 3) {
- Configuration configuration = createConfiguration(args, 1);
- new JbpmSchema(configuration).createSchema();
+ else if (args.length <= 3) {
+ if ("create".equalsIgnoreCase(args[0])) {
+ JbpmSchema jbpmSchema = new JbpmSchema(createConfiguration(args, 1));
+ jbpmSchema.createSchema();
+ }
+ else if ("drop".equalsIgnoreCase(args[0])) {
+ JbpmSchema jbpmSchema = new JbpmSchema(createConfiguration(args, 1));
+ jbpmSchema.dropSchema();
+ }
+ else if ("clean".equalsIgnoreCase(args[0])) {
+ JbpmSchema jbpmSchema = new JbpmSchema(createConfiguration(args, 1));
+ jbpmSchema.cleanSchema();
+ }
+ else {
+ syntax();
+ }
}
- else if ("drop".equalsIgnoreCase(args[0]) && args.length <= 3) {
- Configuration configuration = createConfiguration(args, 1);
- new JbpmSchema(configuration).dropSchema();
- }
- else if ("clean".equalsIgnoreCase(args[0]) && args.length <= 3) {
- Configuration configuration = createConfiguration(args, 1);
- new JbpmSchema(configuration).cleanSchema();
- }
- else if ("scripts".equalsIgnoreCase(args[0]) && args.length >= 3 && args.length <= 5) {
- Configuration configuration = createConfiguration(args, 3);
- new JbpmSchema(configuration).saveSqlScripts(args[1], args[2]);
- }
else {
syntax();
}
}
private static void syntax() {
- System.err.println("syntax:");
+ System.err.println("Syntax:");
System.err.println("JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
System.err.println("JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
System.err.println("JbpmSchema clean [<hibernate.cfg.xml> [<hibernate.properties>]]");
System.err.println("JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
+ System.exit(1);
}
static Configuration createConfiguration(String[] args, int index) {
@@ -365,9 +366,9 @@
}
void createConnection() throws SQLException {
- connectionProvider = settings.getConnectionProvider();
+ connectionProvider = ConnectionProviderFactory.newConnectionProvider(configuration.getProperties());
connection = connectionProvider.getConnection();
- if (!connection.getAutoCommit()) {
+ if (connection.getAutoCommit() == false) {
connection.commit();
connection.setAutoCommit(true);
}
@@ -383,7 +384,10 @@
log.debug("could not close " + connection, e);
}
finally {
+ connection = null;
+
connectionProvider.close();
+ connectionProvider = null;
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java 2009-06-17 17:24:36 UTC (rev 5053)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceServiceFactory.java 2009-06-17 21:20:43 UTC (rev 5054)
@@ -35,8 +35,7 @@
import org.jbpm.svc.ServiceFactory;
import org.jbpm.util.JndiUtil;
-public class DbPersistenceServiceFactory implements ServiceFactory
-{
+public class DbPersistenceServiceFactory implements ServiceFactory {
private static final long serialVersionUID = 1L;
@@ -52,25 +51,21 @@
boolean isCurrentSessionEnabled = false;
SchemaExport schemaExport = null;
+ JbpmSchema jbpmSchema = null;
- public Service openService()
- {
+ public Service openService() {
log.debug("creating persistence service");
return new DbPersistenceService(this);
}
- public synchronized Configuration getConfiguration()
- {
- if (configuration == null)
- {
+ public synchronized Configuration getConfiguration() {
+ if (configuration == null) {
String hibernateCfgXmlResource = null;
- if (JbpmConfiguration.Configs.hasObject("resource.hibernate.cfg.xml"))
- {
+ if (JbpmConfiguration.Configs.hasObject("resource.hibernate.cfg.xml")) {
hibernateCfgXmlResource = JbpmConfiguration.Configs.getString("resource.hibernate.cfg.xml");
}
String hibernatePropertiesResource = null;
- if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties"))
- {
+ if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) {
hibernatePropertiesResource = JbpmConfiguration.Configs.getString("resource.hibernate.properties");
}
configuration = HibernateHelper.createConfiguration(hibernateCfgXmlResource, hibernatePropertiesResource);
@@ -78,29 +73,31 @@
return configuration;
}
- public synchronized SchemaExport getSchemaExport()
- {
- if (schemaExport == null)
- {
+ public synchronized SchemaExport getSchemaExport() {
+ if (schemaExport == null) {
log.debug("creating schema export");
schemaExport = new SchemaExport(getConfiguration());
}
return schemaExport;
}
- public synchronized SessionFactory getSessionFactory()
- {
- if (sessionFactory == null)
- {
+ public synchronized JbpmSchema getJbpmSchema() {
+ if (jbpmSchema == null) {
+ log.debug("creating jbpm schema tool");
+ jbpmSchema = new JbpmSchema(getConfiguration());
+ }
+ return jbpmSchema;
+ }
- if (sessionFactoryJndiName != null)
- {
+ public synchronized SessionFactory getSessionFactory() {
+ if (sessionFactory == null) {
+
+ if (sessionFactoryJndiName != null) {
log.debug("looking up hibernate session factory in jndi '" + sessionFactoryJndiName + "'");
- sessionFactory = (SessionFactory)JndiUtil.lookup(sessionFactoryJndiName, SessionFactory.class);
+ sessionFactory = (SessionFactory) JndiUtil.lookup(sessionFactoryJndiName, SessionFactory.class);
}
- else
- {
+ else {
log.debug("building hibernate session factory");
sessionFactory = getConfiguration().buildSessionFactory();
}
@@ -108,116 +105,94 @@
return sessionFactory;
}
- public DataSource getDataSource()
- {
- if ((dataSource == null) && (dataSourceJndiName != null))
- {
+ public DataSource getDataSource() {
+ if ((dataSource == null) && (dataSourceJndiName != null)) {
log.debug("looking up datasource from jndi location '" + dataSourceJndiName + "'");
- dataSource = (DataSource)JndiUtil.lookup(dataSourceJndiName, DataSource.class);
+ dataSource = (DataSource) JndiUtil.lookup(dataSourceJndiName, DataSource.class);
}
return dataSource;
}
- public void cleanSchema()
- {
- new JbpmSchema(getConfiguration()).cleanSchema();
+ public void cleanSchema() {
+ getJbpmSchema().cleanSchema();
HibernateHelper.clearHibernateCache(getSessionFactory());
}
- public void createSchema()
- {
- getSchemaExport().create(getScript(), true);
+ public void createSchema() {
+ getJbpmSchema().createSchema();
HibernateHelper.clearHibernateCache(getSessionFactory());
}
- public void dropSchema()
- {
+ public void dropSchema() {
+ getJbpmSchema().dropSchema();
HibernateHelper.clearHibernateCache(getSessionFactory());
- getSchemaExport().drop(getScript(), true);
}
- boolean getScript()
- {
+ boolean getScript() {
boolean script = false;
String showSql = getConfiguration().getProperty("hibernate.show_sql");
- if ("true".equalsIgnoreCase(showSql))
- {
+ if ("true".equalsIgnoreCase(showSql)) {
script = true;
}
return script;
}
- public void close()
- {
- if (sessionFactory != null)
- {
+ public void close() {
+ if (sessionFactory != null) {
log.debug("closing hibernate session factory");
sessionFactory.close();
}
}
- public void finalize() throws Throwable
- {
+ public void finalize() throws Throwable {
close();
}
- public String getDataSourceJndiName()
- {
+ public String getDataSourceJndiName() {
return dataSourceJndiName;
}
- public void setDataSourceJndiName(String dataSourceJndiName)
- {
+ public void setDataSourceJndiName(String dataSourceJndiName) {
this.dataSourceJndiName = dataSourceJndiName;
}
- public String getSessionFactoryJndiName()
- {
+ public String getSessionFactoryJndiName() {
return sessionFactoryJndiName;
}
- public void setSessionFactoryJndiName(String sessionFactoryJndiName)
- {
+ public void setSessionFactoryJndiName(String sessionFactoryJndiName) {
this.sessionFactoryJndiName = sessionFactoryJndiName;
}
- public void setConfiguration(Configuration configuration)
- {
+ public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
- public void setDataSource(DataSource dataSource)
- {
+ public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
- public void setSchemaExport(SchemaExport schemaExport)
- {
+ public void setSchemaExport(SchemaExport schemaExport) {
this.schemaExport = schemaExport;
}
- public void setSessionFactory(SessionFactory sessionFactory)
- {
+ public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
- public boolean isTransactionEnabled()
- {
+ public boolean isTransactionEnabled() {
return isTransactionEnabled;
}
- public void setTransactionEnabled(boolean isTransactionEnabled)
- {
+ public void setTransactionEnabled(boolean isTransactionEnabled) {
this.isTransactionEnabled = isTransactionEnabled;
}
- public boolean isCurrentSessionEnabled()
- {
+ public boolean isCurrentSessionEnabled() {
return isCurrentSessionEnabled;
}
- public void setCurrentSessionEnabled(boolean isCurrentSessionEnabled)
- {
+ public void setCurrentSessionEnabled(boolean isCurrentSessionEnabled) {
this.isCurrentSessionEnabled = isCurrentSessionEnabled;
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-06-17 17:24:36 UTC (rev 5053)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-06-17 21:20:43 UTC (rev 5054)
@@ -53,7 +53,10 @@
public void testDropSchema() {
jbpmSchema.dropSchema();
Set existingTables = jbpmSchema.getExistingTables();
- assert existingTables.removeAll(jbpmSchema.getJbpmTables()) == false : existingTables;
+ for (Iterator i = jbpmSchema.getJbpmTables().iterator(); i.hasNext();) {
+ String jbpmTable = (String) i.next();
+ assert !existingTables.contains(jbpmTable) : jbpmTable;
+ }
}
public void testCleanSchema() {
Modified: jbpm3/branches/jbpm-3.2-soa/profiles.xml.example
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/profiles.xml.example 2009-06-17 17:24:36 UTC (rev 5053)
+++ jbpm3/branches/jbpm-3.2-soa/profiles.xml.example 2009-06-17 21:20:43 UTC (rev 5054)
@@ -1,21 +1,19 @@
-<profilesXml xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
+<profilesXml xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/profiles-1.0.0.xsd">
<profiles>
-
<!-- This profile can also be defined in ~/.m2/settings.xml -->
<profile>
- <id>jboss-home-profile</id>
+ <id>local</id>
<activation>
- <property>
- <name>user.name</name>
- </property>
+ <activeByDefault>true</activeByDefault>
</activation>
<properties>
- <jboss405.home>${user.home}/Downloads/jboss/jboss-4.0.5.GA</jboss405.home>
- <jboss423.home>${user.home}/Downloads/jboss/jboss-4.2.3.GA</jboss423.home>
- <jboss501.home>${user.home}/Downloads/jboss/jboss-5.0.1.GA</jboss501.home>
+ <jboss405.home>${user.home}/jboss-4.0.5.GA</jboss405.home>
+ <jboss423.home>${user.home}/jboss-4.2.3.GA</jboss423.home>
+ <jboss501.home>${user.home}/jboss-5.0.1.GA</jboss501.home>
- <!--
<jdbc.mysql.server>localhost</jdbc.mysql.server>
<jdbc.mysql.port>3306</jdbc.mysql.port>
<jdbc.mysql.database>jbpmtest</jdbc.mysql.database>
@@ -38,9 +36,14 @@
<jdbc.sybase.password>jbpmtest</jdbc.sybase.password>
<jdbc.sybase.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.sybase.driver>
<jdbc.sybase.datasource>com.sybase.jdbc3.jdbc.SybXADataSource</jdbc.sybase.datasource>
- -->
+
+ <jdbc.oracle.server>localhost</jdbc.oracle.server>
+ <jdbc.oracle.port>1521</jdbc.oracle.port>
+ <jdbc.oracle.database>XE</jdbc.oracle.database>
+ <jdbc.oracle.url>jdbc:oracle:thin:@${jdbc.oracle.server}:${jdbc.oracle.port}:${jdbc.oracle.database}</jdbc.oracle.url>
+ <jdbc.oracle.username>jbpmtest</jdbc.oracle.username>
+ <jdbc.oracle.password>jbpmtest</jdbc.oracle.password>
</properties>
</profile>
-
</profiles>
</profilesXml>
16 years, 10 months
JBoss JBPM SVN: r5053 - in jbpm4/trunk/modules/devguide/src/main: docbook/en/images and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-06-17 13:24:36 -0400 (Wed, 17 Jun 2009)
New Revision: 5053
Modified:
jbpm4/trunk/modules/devguide/src/main/diagrams/diagrams.mdzip
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/class.diagram.process.execution.png
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.anatomy.classes.png
Log:
JBPM-2306 updating dev guide
Modified: jbpm4/trunk/modules/devguide/src/main/diagrams/diagrams.mdzip
===================================================================
(Binary files differ)
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/class.diagram.process.execution.png
===================================================================
(Binary files differ)
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.anatomy.classes.png
===================================================================
(Binary files differ)
16 years, 10 months
JBoss JBPM SVN: r5052 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-06-17 08:36:35 -0400 (Wed, 17 Jun 2009)
New Revision: 5052
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch06-ProcessAnatomy.xml
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch07-ImplementingAdvancedActivities.xml
Log:
JBPM-2306 updating dev guide
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml 2009-06-17 12:35:36 UTC (rev 5051)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml 2009-06-17 12:36:35 UTC (rev 5052)
@@ -1,76 +1,96 @@
<chapter id="configuration">
<title>Configuration</title>
- <para>The userguide explains how to install jBPM into the most
- common runtime environments. That is the most simple and convenient
- way to get started with jBPM. Please use those instructions.
- These docs provide some background information for developers
- that want to understand more about the way how configurations are
- handled. Use at your own risk :-)
- </para>
- <para>The jbpm.jar contains a number of default configuration
- files that can be imported by the user configuration file.
- </para>
- <para>This way, it's easy to include
- or exclude features for users. And also the configuration details are kept in
- the implementation so users that only import those configuration files
- will not be affected when we release changes in those configuration files.
- </para>
- <para>Configuration files that can be imported by the user's <literal>jbpm.cfg.xml</literal>:</para>
- <programlisting>jbpm.default.cfg.xml
-jbpm.identity.cfg.xml
-jbpm.jbossremote.cfg.xml
-jbpm.jobexecutor.cfg.xml
-jbpm.tx.hibernate.cfg.xml
-jbpm.tx.jta.cfg.xml</programlisting>
- <para><literal>jbpm.default.cfg.xml</literal>: Contains the default configurations
- like the services, the hibernate configuration (configured from resource jbpm.hibernate.cfg.xml),
- hibernate session factory, business calendar and so on.
- </para>
- <para>A typical configuration for standard java would look like this:
- </para>
- <programlisting><?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration>
-
- <import resource="jbpm.default.cfg.xml" />
- <import resource="jbpm.tx.hibernate.cfg.xml" />
- <import resource="jbpm.jpdl.cfg.xml" />
- <import resource="jbpm.identity.cfg.xml" />
- <import resource="jbpm.jobexecutor.cfg.xml" />
-
-</jbpm-configuration></programlisting>
- <para>In a JTA environment, replace <literal>jbpm.tx.hibernate.cfg.xml</literal>
- with <literal>jbpm.tx.jta.cfg.xml</literal> </para>
- <para>To customize any of these configurations users can just replace
- the import with the customized content in the <literal>jbpm.cfg.xml</literal>.
- </para>
+ <section>
+ <title>Configuration basics</title>
+
+ <para>The userguide explains how to install jBPM into the most
+ common runtime environments. That is the most simple and convenient
+ way to get started with jBPM. Please use those instructions.
+ These docs provide some background information for developers
+ that want to understand more about the way how configurations are
+ handled. Use at your own risk :-)
+ </para>
+ <para>The jbpm.jar contains a number of default configuration
+ files that can be imported by the user configuration file.
+ </para>
+ <para>This way, it's easy to include
+ or exclude features for users. And also the configuration details are kept in
+ the implementation so users that only import those configuration files
+ will not be affected when we release changes in those configuration files.
+ </para>
+ <para>Configuration files that can be imported by the user's <literal>jbpm.cfg.xml</literal>:</para>
+ <itemizedlist>
+ <listitem>jbpm.default.cfg.xml</listitem>
+ <listitem>jbpm.identity.cfg.xml</listitem>
+ <listitem>jbpm.jbossremote.cfg.xml</listitem>
+ <listitem>jbpm.jobexecutor.cfg.xml</listitem>
+ <listitem>jbpm.tx.hibernate.cfg.xml</listitem>
+ <listitem>jbpm.tx.jta.cfg.xml</listitem>
+ </itemizedlist>
+ <para><literal>jbpm.default.cfg.xml</literal>: Contains the default configurations
+ like the services, the hibernate configuration (configured from resource jbpm.hibernate.cfg.xml),
+ hibernate session factory, business calendar and so on.
+ </para>
+ <para>A typical configuration for standard java would look like this:
+ </para>
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
- <para>The jbpm.jar contains also following hibernate mapping configuration files:</para>
- <programlisting>jbpm.execution.hbm.xml
-jbpm.history.hbm.xml
-jbpm.identity.hbm.xml
-jbpm.repository.hbm.xml
-jbpm.task.hbm.xml
-jbpm.jpdl.hbm.xml</programlisting>
- <para>These all map the java domain model objects to a relational database.
- </para>
- <para>Other various configuration files that are included in jbpm.jar:</para>
- <programlisting>jbpm.task.lifecycle.xml
-jbpm.variable.types.xml
-jbpm.wire.bindings.xml
-jbpm.jpdl.activities.xml
-jbpm.jpdl.eventlisteners.xml</programlisting>
-
- <para>To get started on the parsing for the configuration files, see
- </para>
- <itemizedlist>
- <listitem>class org.jbpm.pvm.internal.env.JbpmConfigurationParser</listitem>
- <listitem>resource modules/pvm/src/main/resources/jbpm.wire.bindings.xml</listitem>
- <listitem>package modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding</listitem>
- </itemizedlist>
+ <jbpm-configuration>
- <section>
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.jobexecutor.cfg.xml" />
+
+ </jbpm-configuration></programlisting>
+
+ <para>When you want to change the configuration, first consider
+ to change an import with one of the other provided importable
+ configuration files.
+ </para>
+
+ <para>For example, in a JTA environment, replace the import of
+ <literal>jbpm.tx.hibernate.cfg.xml</literal>
+ with <literal>jbpm.tx.jta.cfg.xml</literal>
+ </para>
+
+ <para>The second way to define a more customized configuration is to
+ specify configuration items directly into the <literal>jbpm.cfg.xml</literal>.
+ For an example, see <xref linkend="customizingtheidentitycomponent" /> below.
+ The more you customize, the more likely you are doing things we didn't
+ anticipate.
+ </para>
+
+ <para>The jbpm.jar contains also following hibernate mapping configuration files:</para>
+ <programlisting>jbpm.execution.hbm.xml
+ jbpm.history.hbm.xml
+ jbpm.identity.hbm.xml
+ jbpm.repository.hbm.xml
+ jbpm.task.hbm.xml
+ jbpm.jpdl.hbm.xml</programlisting>
+ <para>These all map the java domain model objects to a relational database.
+ </para>
+ <para>Other various configuration files that are included in jbpm.jar:</para>
+ <programlisting>jbpm.task.lifecycle.xml
+ jbpm.variable.types.xml
+ jbpm.wire.bindings.xml
+ jbpm.jpdl.activities.xml
+ jbpm.jpdl.eventlisteners.xml</programlisting>
+
+ <para>Normally it is not necessary to dive into the parsing itself. It's most
+ a matter of figuring out how to specify the configuration that you want :-)
+ But just in case: To get started on the parsing for the configuration files, see
+ </para>
+ <itemizedlist>
+ <listitem>class org.jbpm.pvm.internal.env.JbpmConfigurationParser</listitem>
+ <listitem>resource modules/pvm/src/main/resources/jbpm.wire.bindings.xml</listitem>
+ <listitem>package modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding</listitem>
+ </itemizedlist>
+ </section>
+
+ <section id="customizingtheidentitycomponent">
<title>Customizing the identity component</title>
<para>There are 2 identity components that we support out of the box:
</para>
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch06-ProcessAnatomy.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch06-ProcessAnatomy.xml 2009-06-17 12:35:36 UTC (rev 5051)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch06-ProcessAnatomy.xml 2009-06-17 12:36:35 UTC (rev 5052)
@@ -18,7 +18,12 @@
<mediaobject><imageobject><imagedata align="center" fileref="images/process.anatomy.classes.png"/></imageobject></mediaobject>
</figure>
- <para>Next we'll show a series of example diagram structures that can be formed
+ <para>By separating the structure of a process from the behaviour of the activities,
+ any process model can be formed in the PVM. It's up to the activity implementations
+ to use this structure. Activities can also impose restrictions on the diagram
+ structures they can support. Typically activities that control process concurrency
+ will impose restrictions on the process model structures that they can support.
+ Next we'll show a series of example diagram structures that can be formed
with the PVM process model.
</para>
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch07-ImplementingAdvancedActivities.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch07-ImplementingAdvancedActivities.xml 2009-06-17 12:35:36 UTC (rev 5051)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch07-ImplementingAdvancedActivities.xml 2009-06-17 12:36:35 UTC (rev 5052)
@@ -12,16 +12,10 @@
</para>
</section>
- <!-- ### SUB PROCESSES ################################################## -->
- <section>
- <title>Sub processes</title>
- <para>TODO: sub processes</para>
- </section>
-
<!-- ### DEFAULT PROCEED BEHAVIOUR ###################################### -->
<section id="implicitproceedbehaviour">
<title>Implicit proceed behaviour</title>
- <para>When an <literal>Activity</literal> is used as activity behaviour, it can
+ <para>An <literal>ActivityBehaviour</literal> can
explicitely propagate the execution with following methods:
</para>
<itemizedlist>
@@ -31,7 +25,15 @@
<listitem><literal>execute(Activity)</literal></listitem>
<listitem><literal>createExecution(*)</literal></listitem>
</itemizedlist>
- <para>When <literal>Activity</literal> implementations used for activity behviour
+
+ <para>As a side note, some of these methods are not exposed in the
+ interfaces, but only in the implementation. Those methods are still
+ in 'incubation'. So if you want to use those, you can use them at your
+ own risk by casting the ActivityExecution interface to the implementation
+ class ExecutionImpl.
+ </para>
+
+ <para>When <literal>ActivityBehaviour</literal> implementations used for activity behviour
don't call any of the following execution propagation methods, then, after
the activity is executed, the execution will apply the implicit proceed behaviour.
</para>
@@ -50,13 +52,13 @@
<!-- ### FUNCTIONAL ACTIVITIES ################################ -->
<section id="functionalactivities">
<title>Functional activities</title>
- <para>Activities that also can be used as event listeners are called functional
+ <para>ActivityBehaviours that also can be used as event listeners are called functional
activities. Examples of automatic activities are sending an email, doing a database
update, generating a pdf, calculating an average, etc. All of these are automatic
activities that do not change the execution flow. Here's how such activities can
be implemented:
</para>
- <programlisting>public class FunctionalActivity implements Activity, EventListener {
+ <programlisting>public class FunctionalActivity implements ActivityBehaviour, EventListener {
public void execute(ActivityExecution execution) {
perform(execution);
}
@@ -95,8 +97,10 @@
for the Process Virtual Machine to operate. Two more levels of asynchonous
execution complement this default behaviour:
<link linkend="asynchronouscontinuations">Asynchronous continuations</link>
- and the <link linkend="architecture">asynchronous command service</link>.
+ and in the future we'll also provide a way to invoke service methods asynchronously.
</para>
+ <para>TODO: update the example that is now commented</para>
+ <!--
<para>The next process will show the basics concretely. It has three wait states
and four automatic activities.
</para>
@@ -171,6 +175,7 @@
<title>The second signal brought the execution all the way to 'wait 3'.</title>
<mediaobject><imageobject><imagedata align="center" fileref="images/ch04.automatic.wait3.png"/></imageobject></mediaobject>
</figure>
+ -->
<para>The benefits of using this paradigm is that the same process definition
can be executed in <link linkend="clientexecutionmode">client execution mode</link>
(in-memory without persistence) as well as in <link linkend="persistentexecutionmode">
16 years, 10 months
JBoss JBPM SVN: r5051 - in jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test: execution and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-06-17 08:35:36 -0400 (Wed, 17 Jun 2009)
New Revision: 5051
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEndCombinationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEventListenerOnEndTest.java
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java
Log:
JBPM-2275 async end combinations
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEndCombinationTest.java (from rev 5049, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEndCombinationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEndCombinationTest.java 2009-06-17 12:35:36 UTC (rev 5051)
@@ -0,0 +1,126 @@
+/*
+ * 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.async;
+
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncEndCombinationTest extends JbpmTestCase {
+
+ public void testConcurrentEndScenario1() {
+ deployJpdlXmlString(
+ "<process name='AsyncEndCombination'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='a' continue='async' />" +
+ " <transition to='end' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+
+ List<Job> jobs = managementService
+ .createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .list();
+
+ assertEquals(0, jobs.size());
+ }
+
+ public void testConcurrentScenario2() {
+ deployJpdlXmlString(
+ "<process name='AsyncEndCombination'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='end' />" +
+ " <transition to='a' continue='async' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+
+ List<Job> jobs = managementService
+ .createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .list();
+
+ assertEquals(0, jobs.size());
+ }
+
+ public void testAsyncToEnd() {
+ deployJpdlXmlString(
+ "<process name='AsyncEndCombination'>" +
+ " <start>" +
+ " <transition to='s' />" +
+ " </start>" +
+ " <state name='s'>" +
+ " <transition to='end' continue='async' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
+ String processInstanceId = processInstance.getId();
+ processInstance = executionService.signalExecutionById(processInstanceId);
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+ List<Job> jobs = managementService
+ .createJobQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+
+ assertEquals(1, jobs.size());
+
+ managementService.executeJob(jobs.get(0).getDbid());
+
+ jobs = managementService
+ .createJobQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+
+ assertEquals(0, jobs.size());
+
+ assertNull(executionService.findProcessInstanceById(processInstanceId));
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEndCombinationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEventListenerOnEndTest.java (from rev 5049, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEventListenerOnEndTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEventListenerOnEndTest.java 2009-06-17 12:35:36 UTC (rev 5051)
@@ -0,0 +1,108 @@
+/*
+ * 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.async;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncEventListenerOnEndTest extends JbpmTestCase {
+
+ public static class AsyncEventListener implements EventListener {
+ private static final long serialVersionUID = 1L;
+ public void notify(EventListenerExecution execution) throws Exception {
+ }
+ }
+
+ public void testAsyncEventListenerAfterWaitState() {
+ deployJpdlXmlString(
+ "<process name='AsyncEventListenerOnEnd'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition name='start-to-end' to='end'>" +
+ " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
+ " </transition>" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
+
+ processInstance = executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ assertNotNull(job);
+
+ managementService.executeJob(job.getDbid());
+
+ assertEquals(Execution.STATE_ENDED,
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getState() );
+ }
+
+ public void testAsyncEventListenerInStartTransaction() {
+ deployJpdlXmlString(
+ "<process name='AsyncEventListenerOnEnd'>" +
+ " <start name='start'>" +
+ " <transition name='start-to-end' to='end'>" +
+ " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
+ " </transition>" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ assertNotNull(job);
+
+ managementService.executeJob(job.getDbid());
+
+ assertEquals(Execution.STATE_ENDED,
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getState() );
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncEventListenerOnEndTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java 2009-06-17 09:57:20 UTC (rev 5050)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java 2009-06-17 12:35:36 UTC (rev 5051)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.execution;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class AsyncEndCombinationTest extends JbpmTestCase {
-
- public void testConcurrentEndScenario1() {
- deployJpdlXmlString(
- "<process name='AsyncEndCombination'>" +
- " <start>" +
- " <transition to='f' />" +
- " </start>" +
- " <fork name='f'>" +
- " <transition to='a' continue='async' />" +
- " <transition to='end' />" +
- " </fork>" +
- " <state name='a' />" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
- assertEquals(Execution.STATE_ENDED, processInstance.getState());
- }
-
- public void testConcurrentScenario2() {
- deployJpdlXmlString(
- "<process name='AsyncEndCombination'>" +
- " <start>" +
- " <transition to='f' />" +
- " </start>" +
- " <fork name='f'>" +
- " <transition to='end' />" +
- " <transition to='a' continue='async' />" +
- " </fork>" +
- " <state name='a' />" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
- assertEquals(Execution.STATE_ENDED, processInstance.getState());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java 2009-06-17 09:57:20 UTC (rev 5050)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java 2009-06-17 12:35:36 UTC (rev 5051)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.execution;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.job.Job;
-import org.jbpm.api.listener.EventListener;
-import org.jbpm.api.listener.EventListenerExecution;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class AsyncEventListenerOnEndTest extends JbpmTestCase {
-
- public static class AsyncEventListener implements EventListener {
- private static final long serialVersionUID = 1L;
- public void notify(EventListenerExecution execution) throws Exception {
- }
- }
-
- public void testAsyncEventListenerAfterWaitState() {
- deployJpdlXmlString(
- "<process name='AsyncEventListenerOnEnd'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition name='start-to-end' to='end'>" +
- " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
- " </transition>" +
- " </state>" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
-
- processInstance = executionService.signalExecutionById(processInstance.getId());
-
- assertEquals(Execution.STATE_ASYNC, processInstance.getState());
-
- Job job = managementService.createJobQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult();
-
- assertNotNull(job);
-
- managementService.executeJob(job.getDbid());
-
- assertEquals(Execution.STATE_ENDED,
- historyService.createHistoryProcessInstanceQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult()
- .getState() );
- }
-
- public void testAsyncEventListenerInStartTransaction() {
- deployJpdlXmlString(
- "<process name='AsyncEventListenerOnEnd'>" +
- " <start name='start'>" +
- " <transition name='start-to-end' to='end'>" +
- " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
- " </transition>" +
- " </start>" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
- assertEquals(Execution.STATE_ASYNC, processInstance.getState());
-
- Job job = managementService.createJobQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult();
-
- assertNotNull(job);
-
- managementService.executeJob(job.getDbid());
-
- assertEquals(Execution.STATE_ENDED,
- historyService.createHistoryProcessInstanceQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult()
- .getState() );
- }
-}
16 years, 10 months
JBoss JBPM SVN: r5050 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-06-17 05:57:20 -0400 (Wed, 17 Jun 2009)
New Revision: 5050
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
Log:
Added tests for JBPM-1214 : self-transition/loop back to State activity
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2009-06-17 08:57:15 UTC (rev 5049)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2009-06-17 09:57:20 UTC (rev 5050)
@@ -149,4 +149,59 @@
ProcessInstance processInstance = executionService.signalExecutionById("p.one");
assertTrue(processInstance.isActive("a"));
}
+
+ /**
+ * Test for JBPM-1214
+ *
+ * When a self transition comes back into the same state in the same transaction,
+ * potentially there could be optimistick locking failures.
+ */
+ public void testSelfTransition() {
+ deployJpdlXmlString(
+ "<process name='selfTransition'>" +
+ " <start>" +
+ " <transition to='wait' />" +
+ " </start>" +
+ " <state name='wait' >" +
+ " <transition to='wait' />" +
+ " </state>" +
+ "</process>"
+ );
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("selfTransition");
+ assertTrue(processInstance.isActive("wait"));
+ executionService.signalExecutionById(processInstance.getId());
+ assertTrue(processInstance.isActive("wait"));
+ }
+
+ /**
+ * Test for JBPM-1214
+ *
+ * When a wait state is signalled and the execution comes back to the
+ * wait state, there can potentially be optimistic locking exceptions.
+ */
+ public void testLoopBackToSignalledState() {
+ deployJpdlXmlString(
+ "<process name='loopBackToState'>" +
+ " <start>" +
+ " <transition to='wait' />" +
+ " </start>" +
+ " <state name='wait' >" +
+ " <transition to='go further' />" +
+ " </state>" +
+ " <custom name='go further' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='go even further' />" +
+ " </custom>" +
+ " <custom name='go even further' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='wait' />" +
+ " </custom>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("loopBackToState");
+ assertTrue(processInstance.isActive("wait"));
+ executionService.signalExecutionById(processInstance.getId());
+ assertTrue(processInstance.isActive("wait"));
+ }
+
}
16 years, 10 months
JBoss JBPM SVN: r5049 - in jbpm4/trunk/modules/test-concurrent: src and 13 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-06-17 04:57:15 -0400 (Wed, 17 Jun 2009)
New Revision: 5049
Added:
jbpm4/trunk/modules/test-concurrent/.classpath
jbpm4/trunk/modules/test-concurrent/.project
jbpm4/trunk/modules/test-concurrent/pom.xml
jbpm4/trunk/modules/test-concurrent/src/
jbpm4/trunk/modules/test-concurrent/src/main/
jbpm4/trunk/modules/test-concurrent/src/main/java/
jbpm4/trunk/modules/test-concurrent/src/main/java/org/
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/ConcurrentJbpmTestCase.java
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulator.java
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorPool.java
jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorSynchronization.java
jbpm4/trunk/modules/test-concurrent/src/main/resources/
jbpm4/trunk/modules/test-concurrent/src/test/
jbpm4/trunk/modules/test-concurrent/src/test/java/
jbpm4/trunk/modules/test-concurrent/src/test/java/org/
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/OptimisticLockTestGround.java
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/PassThroughActivity.java
jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/TimerVsSignalConcurrencyTest.java
jbpm4/trunk/modules/test-concurrent/src/test/resources/
jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-concurrent/src/test/resources/logging.properties
Log:
Initial import for concurrency tests (JBPM-1987)
Added: jbpm4/trunk/modules/test-concurrent/.classpath
===================================================================
--- jbpm4/trunk/modules/test-concurrent/.classpath (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/.classpath 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: jbpm4/trunk/modules/test-concurrent/.project
===================================================================
--- jbpm4/trunk/modules/test-concurrent/.project (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/.project 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>test-concurrent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: jbpm4/trunk/modules/test-concurrent/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-concurrent/pom.xml (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/pom.xml 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <name>jBPM 4 - Test DB</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-concurrent</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-pvm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- DB drivers -->
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.1.114</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.3-603.jdbc4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/ConcurrentJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/ConcurrentJbpmTestCase.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/ConcurrentJbpmTestCase.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,75 @@
+/*
+ * 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.concurrent;
+
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Base class for unit tests involving testing concurrency.
+ *
+ * @author Joram Barrez
+ */
+public abstract class ConcurrentJbpmTestCase extends JbpmTestCase {
+
+ protected EnvironmentFactory environmentFactory;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.environmentFactory = (EnvironmentFactory) processEngine; // Is there a better way to do this?
+ }
+
+ protected class OffloadThread extends Thread {
+
+ private ThreadCallback threadCallback;
+
+ private Exception exception;
+
+ public OffloadThread(ThreadCallback threadCallback) {
+ this.threadCallback = threadCallback;
+ }
+
+ public void run() {
+ try {
+ threadCallback.executeInThread();
+ } catch (Exception e) {
+ this.exception = e;
+ }
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ }
+
+ protected interface ThreadCallback {
+
+ void executeInThread();
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulator.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulator.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulator.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,302 @@
+/*
+ * 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.concurrent;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.api.job.Job;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+
+/**
+ * Emulates the JobExecutorThread by executing the ExecuteJobCmd in
+ * a dedicated thread.
+ *
+ * Has several sync points available (see {@link JobExecutorEmulatorSynchronization}):
+ * - before/after transaction is started
+ * - before/after job execution
+ * - before/after transaction is done (ie commit)
+ *
+ * TODO: implement transaction sync, now only sync on job execution is done - waiting until use case passes by
+ *
+ * @author Joram Barrez
+ */
+public class JobExecutorEmulator extends Thread {
+
+ /** Used to create environment blocks */
+ private EnvironmentFactory environmentFactory;
+
+ /** The database id of the job that is executed by this JobExecutorEmulator */
+ private Long jobId;
+
+ /**
+ * If an exception occurs in a thread that is not the JUnit thread, then
+ * the JUnit thread will never notice this. The solution is to catch the
+ * exception and store it in this field, so the JUnit thread can check
+ * if there were any exceptions when executing the job.
+ */
+ private Exception exception;
+
+ /** Indicates if the thread must be blocked (ie this.wait() must be called) */
+ private boolean threadBlocked;
+
+ /**
+ * List of synchronizations that will be called on specific point in the
+ * execution of this thread.
+ */
+ private List<JobExecutorEmulatorSynchronization> synchronizations;
+
+ /* SYNC PRIMITIVES */
+
+ /** Sync point when the job is executed */
+ private CyclicBarrier afterJobExecutionBarrier;
+
+ private List<String> afterJobExecutionSyncThreads;
+
+ /** Sync point before the job is executed */
+ private CyclicBarrier beforeJobExecutionBarrier;
+
+ private List<String> beforeJobExecutionSyncThreads;
+
+ /**
+ * Constructor.
+ *
+ * @param job The job that must be executred by this emulator.
+ */
+ public JobExecutorEmulator(EnvironmentFactory environmentFactory, Job job) {
+ this.environmentFactory = environmentFactory;
+ this.jobId = job.getDbid();
+ this.threadBlocked = false;
+
+ this.synchronizations = new ArrayList<JobExecutorEmulatorSynchronization>();
+ synchronizations.add(new DefaultSynchronization());
+ }
+
+ public void run() {
+
+ Environment environment = environmentFactory.openEnvironment();
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ try {
+
+ handleBeforeJobExecutionSynchronizations();
+ ExecuteJobCmd executeJobCmd = new ExecuteJobCmd(jobId);
+ executeJobCmd.execute(environment);
+ handleAfterJobExecutionSynchronizations(); // Sync point: after job execution
+
+ } catch (Exception e) {
+
+ standardTransaction.setRollbackOnly();
+ this.exception = e;
+
+ } finally {
+
+ if (standardTransaction.isRollbackOnly()) {
+ exception = new Exception("Transaction was rollbacked due to an exception");
+ }
+
+ try {
+ standardTransaction.complete();
+ } catch (Exception e) {
+
+ }
+
+ }
+ environment.close();
+ }
+
+ /**
+ * Executes all synchronizations that must be executed before the job is executed
+ */
+ private void handleBeforeJobExecutionSynchronizations() {
+ for (JobExecutorEmulatorSynchronization synchronization : synchronizations) {
+ synchronization.beforeJobExecution();
+ }
+ }
+
+ /**
+ * Executes all synchronizations that must be executed when the job is executed
+ */
+ private void handleAfterJobExecutionSynchronizations() {
+ for (JobExecutorEmulatorSynchronization synchronization : synchronizations) {
+ synchronization.afterJobExecution();
+ }
+ }
+
+ /**
+ * Unit tests that use this class can use this method to synchronize
+ * when the job just has been executed.
+ *
+ * @param blockJobExecutor If true, the jobExecutor will be halted
+ * when leaving the synchronisation point
+ */
+ public void waitUntilJobExecuted(boolean blockJobExecutor) {
+ if (afterJobExecutionBarrier != null) {
+ try {
+ threadBlocked = blockJobExecutor;
+ afterJobExecutionBarrier.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public JobExecutorEmulator synchroniseAfterJobExecution(String threadName) {
+ if (isAlive()) {
+ throw new RuntimeException("Cannot set synchronization point once the JobExecutorEmulator has been started");
+ }
+
+ if (afterJobExecutionSyncThreads == null) {
+ afterJobExecutionSyncThreads = new ArrayList<String>();
+ }
+
+ if (afterJobExecutionBarrier == null ) {
+ afterJobExecutionBarrier = new CyclicBarrier(2);
+ } else {
+ afterJobExecutionBarrier = new CyclicBarrier(afterJobExecutionBarrier.getParties() + 1);
+ }
+
+ return this;
+ }
+
+ public JobExecutorEmulator synchroniseBeforeJobExecution(String threadName) {
+ if (isAlive()) {
+ throw new RuntimeException("Cannot set synchronization point once the JobExecutorEmulator has been started");
+ }
+
+ if (beforeJobExecutionBarrier == null) {
+ beforeJobExecutionSyncThreads = new ArrayList<String>();
+ }
+
+ if (beforeJobExecutionBarrier == null ) {
+ beforeJobExecutionBarrier = new CyclicBarrier(2);
+ } else {
+ beforeJobExecutionBarrier = new CyclicBarrier(beforeJobExecutionBarrier.getParties() + 1);
+ }
+
+ return this;
+ }
+
+ /**
+ * Helper method: check if the flag 'threadBlocked' has been raised.
+ * If so, this thread will block until it is notified again.
+ */
+ private void blockIfNeeded() {
+ if (threadBlocked) {
+ synchronized (this) {
+ try {
+ threadBlocked = false;
+ wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * Unit tests can use this method to proceed a halted JobExecutorEmulator.
+ * (ie this means that the wait() was called on this thread in the past).
+ */
+ public void goOn() {
+ synchronized (this) {
+ notify();
+ };
+ }
+
+ /**
+ * Adds a custom synchronization to the JobExecutorEmulator.
+ */
+ public void addSynchronization(JobExecutorEmulatorSynchronization synchronization) {
+ synchronizations.add(synchronization);
+ }
+
+ /* GETTERS AND SETTERS */
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public boolean isBlockThread() {
+ return threadBlocked;
+ }
+
+ public void setBlockThread(boolean blockThread) {
+ this.threadBlocked = blockThread;
+ }
+
+ public void setAfterJobExecutionBarrier(CyclicBarrier afterJobExecutionBarrier) {
+ this.afterJobExecutionBarrier = afterJobExecutionBarrier;
+ }
+
+ public void setBeforeJobExecutionBarrier(CyclicBarrier beforeJobExecutionBarrier) {
+ this.beforeJobExecutionBarrier = beforeJobExecutionBarrier;
+ }
+
+ /**
+ * Default synchronization, executed by all JobExecutorEmulators.
+ * The default logic will synchronize at every sync point (ie barrier)
+ * which is not null and will check if any external caller has raised
+ * the 'threadBlocked' flag.
+ */
+ private class DefaultSynchronization extends JobExecutorEmulatorSynchronization {
+
+ public void afterJobExecution() {;
+ if (afterJobExecutionBarrier != null) {
+ try {
+ afterJobExecutionBarrier.await();
+ blockIfNeeded();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void beforeJobExecution() {;
+ if (beforeJobExecutionBarrier != null) {
+ try {
+ beforeJobExecutionBarrier.await();
+ blockIfNeeded();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (BrokenBarrierException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorPool.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorPool.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorPool.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -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.test.concurrent;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.api.job.Job;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class JobExecutorEmulatorPool {
+
+ private EnvironmentFactory environmentFactory;
+
+ private List<JobExecutorEmulator> jobExecutorEmulators;
+
+ public JobExecutorEmulatorPool(EnvironmentFactory environmentFactory) {
+ this.environmentFactory = environmentFactory;
+ this.jobExecutorEmulators = new ArrayList<JobExecutorEmulator>();
+ }
+
+ public void emulateJobExecution(Collection<Job> jobs) {
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorSynchronization.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorSynchronization.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/main/java/org/jbpm/test/concurrent/JobExecutorEmulatorSynchronization.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,47 @@
+/*
+ * 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.concurrent;
+
+/**
+ * Implementations can extend this class to add logic to sync points of the
+ * {@link JobExecutorEmulator}.
+ *
+ * @author Joram Barrez
+ */
+public abstract class JobExecutorEmulatorSynchronization {
+
+ public void beforeTransactionStarts() { }
+
+ public void afterTransactionStarted() { }
+
+ public void beforeJobExecution() { }
+
+ public void afterJobExecution() { }
+
+ public void beforeTransactionDone() { }
+
+ public void afterTransactionDone() { }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/OptimisticLockTestGround.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/OptimisticLockTestGround.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/OptimisticLockTestGround.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,256 @@
+/*
+ * 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.concurrent;
+
+import java.util.List;
+import java.util.concurrent.Semaphore;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.api.job.Job;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Class to test different approaches to the concurrency problem.
+ *
+ * Doesnt work anymore, but dont delete yet, I need some stuff in here for later!
+ *
+ * @author Joram Barrez
+ */
+public class OptimisticLockTestGround extends JbpmTestCase {
+
+ private EnvironmentFactory environmentFactory;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.environmentFactory = (EnvironmentFactory) processEngine; // Better way to do this?
+ }
+
+
+ public void testMe() throws Exception {
+ deployJpdlXmlString(
+ "<process name='asyncFork'>" +
+ " <start>" +
+ " <transition to='theFork' />" +
+ " </start>" +
+ " <fork name='theFork'>" +
+ " <on event='end' continue='async' />" +
+ " <transition to='pathA' />" +
+ " <transition to='pathB' />" +
+ " </fork>" +
+ " <custom name='pathA' class='org.jbpm.test.concurrent.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <custom name='pathB' class='org.jbpm.test.concurrent.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <join name='theJoin' lockmode='none'>" +
+ " <transition to='end' />" +
+ " </join>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("asyncFork");
+ final List<Job> jobs = managementService.createJobQuery().processInstanceId(processInstance.getId()).list();
+ assertEquals(2, jobs.size());
+
+ JobExecutorEmulator jobExecutorEmulator1 = new JobExecutorEmulator(jobs.get(0));
+ jobExecutorEmulator1.start();
+
+ JobExecutorEmulator jobExecutorEmulator2 = new JobExecutorEmulator(jobs.get(1));
+ jobExecutorEmulator2.start();
+
+ // TODO check if transitions are marked for rollback -> exception happened
+
+ jobExecutorEmulator1.join();
+ if (jobExecutorEmulator1.getException() != null) {
+ fail("Error while executing job: " + jobExecutorEmulator1.getException().getMessage());
+ }
+
+ jobExecutorEmulator2.join();
+ if (jobExecutorEmulator2.getException() != null) {
+ fail("Error while executing job: " + jobExecutorEmulator2.getException().getMessage());
+ }
+
+ }
+
+ public void testMeToo() throws Exception {
+
+ semaphore = new Semaphore(0);
+
+ deployJpdlXmlString(
+ "<process name='timer_vs_signal'>" +
+ " <start>" +
+ " <transition to='wait' />" +
+ " </start>" +
+ " <state name='wait'>" +
+ " <transition name='timeout' to='end'>" +
+ " <timer duedate='1 second' />" +
+ " </transition>" +
+ " <transition to='end' name='go on' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("timer_vs_signal");
+ final List<Job> jobs = managementService.createJobQuery().processInstanceId(processInstance.getId()).list();
+ assertEquals(1, jobs.size());
+
+ JobExecutorEmulator jobExecutorEmulator1 = new JobExecutorEmulator(jobs.get(0));
+ jobExecutorEmulator1.start();
+
+ while (!semaphore.hasQueuedThreads()) {
+ synchronized (this) {
+ System.out.println("------------------> waiting ...");
+ wait(20L);
+ }
+ }
+
+ // cause conflict
+ System.out.println("---------------------------> Causing MayHem");
+
+ Execution executionAtState = processInstance.findActiveExecutionIn("wait");
+ assertNotNull(executionAtState);
+ executionService.signalExecutionById(executionAtState.getId(), "go on");
+ semaphore.release();
+ System.out.println("----------------------------> Released semaphore");
+
+ // TODO check if transitions are marked for rollback -> exception happened
+
+ jobExecutorEmulator1.join();
+ if (jobExecutorEmulator1.getException() != null) {
+ fail("Error while executing job: " + jobExecutorEmulator1.getException().getMessage());
+ }
+
+ }
+
+ // Todo refactor
+ private static Semaphore semaphore = new Semaphore(1); // binary semaphore
+
+
+ private class JobExecutorEmulator extends Thread {
+
+ private Long jobId;
+
+ private Exception exception;
+
+ public JobExecutorEmulator(Job job) {
+ this.jobId = job.getDbid();
+ }
+
+ public void run() {
+
+ Environment environment = environmentFactory.openEnvironment();
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ try {
+
+ System.out.println(Thread.currentThread().getName() + "----------------------------------------> executing job " + jobId);
+ ExecuteJobCmd executeJobCmd = new ExecuteJobCmd(jobId);
+ executeJobCmd.execute(environment);
+
+ System.out.println(Thread.currentThread().getName() +"-------------------------------------------------------> DONE EXECUTING JOB " + jobId);
+
+ } catch (Exception e) {
+ standardTransaction.setRollbackOnly();
+ this.exception = e;
+
+ System.out.println(Thread.currentThread().getName() +" -----------------------------------------------------> IM A FAILURE");
+ } finally {
+
+
+ // error: both threads entering at the same time!
+ /*
+ boolean acquired = false;
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> BEFORE SYNC BLOCK");
+ synchronized (semaphore) {
+ acquired = semaphore.tryAcquire();
+ }
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> AFTER SYNC BLOCK");
+ if (acquired) {
+
+ try {
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> ACQUIRING");
+ synchronized (semaphore) {
+ semaphore.wait();
+ }
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> FREED FROM ACQUIRED");
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ */
+
+
+ if (!semaphore.hasQueuedThreads()) {
+ try {
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> ACQUIRING");
+ semaphore.acquire();
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> FREED FROM ACQUIRED");
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+
+ if (standardTransaction.isRollbackOnly()) {
+ exception = new Exception("Transaction was rollbacked");
+ }
+
+ System.out.println(Thread.currentThread().getName() + "-------------------------------------------------> COMPLETING ");
+ standardTransaction.complete();
+
+ System.out.println(Thread.currentThread().getName() + "------------------------------------------------------> RELEASING");
+
+ /*if (!acquired) {
+ semaphore.release();
+ synchronized (semaphore) {
+ semaphore.notify();
+ }
+ }*/
+
+ }
+ environment.close();
+ System.out.println(Thread.currentThread().getName() + " has finished");
+ }
+
+
+ public Exception getException() {
+ return exception;
+ }
+
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/PassThroughActivity.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/PassThroughActivity.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/PassThroughActivity.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,49 @@
+/*
+ * 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.concurrent;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class PassThroughActivity implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ public void signal(ActivityExecution execution, String signalName, Map<String, ? > parameters) throws Exception {
+ execution.take(signalName);
+ }
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execution.takeDefaultTransition();
+ }
+
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/TimerVsSignalConcurrencyTest.java
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/TimerVsSignalConcurrencyTest.java (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/java/org/jbpm/test/concurrent/TimerVsSignalConcurrencyTest.java 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,117 @@
+/*
+ * 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.concurrent;
+
+import java.util.List;
+import java.util.concurrent.CyclicBarrier;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class TimerVsSignalConcurrencyTest extends ConcurrentJbpmTestCase {
+
+ public void testStaleObjectExceptionThrown() throws Exception {
+
+ deployJpdlXmlString(
+ "<process name='timer_vs_signal'>" +
+ " <start>" +
+ " <transition to='wait' />" +
+ " </start>" +
+ " <state name='wait'>" +
+ " <transition name='timeout' to='end'>" +
+ " <timer duedate='1 second' />" +
+ " </transition>" +
+ " <transition to='end' name='go on' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("timer_vs_signal");
+ final List<Job> jobs = managementService.createJobQuery().processInstanceId(processInstance.getId()).list();
+ assertEquals(1, jobs.size());
+
+ JobExecutorEmulator jobExecutorEmulator = new JobExecutorEmulator(environmentFactory, jobs.get(0));
+ jobExecutorEmulator.synchroniseAfterJobExecution(Thread.currentThread().getName());
+ jobExecutorEmulator.start();
+
+ jobExecutorEmulator.waitUntilJobExecuted(true); // transaction will be stalled
+
+ // Cause conflicting transaction
+ final Execution executionAtState = processInstance.findActiveExecutionIn("wait");
+ assertNotNull(executionAtState);
+ OffloadThread signalThread = new OffloadThread(new ThreadCallback() {
+ public void executeInThread() {
+ executionService.signalExecutionById(executionAtState.getId(), "go on");
+ }
+ });
+ signalThread.start();
+
+ /*
+ // Checking current stacktrace of thread
+ int i = 1;
+ while (i == 1) {
+ System.out.println("-----------> STATE = " + temp.getState());
+ StackTraceElement[] stack = temp.getStackTrace();
+ for (StackTraceElement e : stack) {
+ System.out.println("-----------> " + e);
+ }
+
+ synchronized (this) {
+ try {
+ wait(1000L);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ */
+
+ // Best effort: wait 1 sec and see if the staleObjectException has been caused
+ synchronized (this) {
+ wait(1000L);
+ }
+
+ jobExecutorEmulator.goOn();
+ jobExecutorEmulator.join();
+
+
+ if (jobExecutorEmulator.getException() != null) {
+ fail("Error while executing job: " + jobExecutorEmulator.getException().getMessage());
+ } if (signalThread.getException() != null) {
+ fail("Error while executing signal " + signalThread.getException().getMessage());
+ }
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.cfg.xml 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+
+ <!--
+ In the concurrency tests, we'll emulate the job executor to have full
+ control on when syncing occurs
+
+ <import resource="jbpm.jobexecutor.cfg.xml" />
+ -->
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/resources/jbpm.hibernate.cfg.xml 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!--
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+ <property name="hibernate.connection.username">sa</property> <property
+ name="hibernate.connection.password"></property>
+ -->
+
+ <!-- H2 config -->
+ <property name="hibernate.connection.driver_class">org.h2.Driver</property>
+ <property name="hibernate.connection.url">jdbc:h2:mem:.;MVCC=TRUE</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password">sa</property>
+ <property name="hibernate.default_schema">PUBLIC</property>
+ <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
+
+
+ <!-- POSTGRES config
+ <property name="hibernate.connection.driver_class">org.h2.Driver</property>
+ <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/jbpm</property>
+ <property name="hibernate.connection.username">postgres</property>
+ <property name="hibernate.connection.password">postgres</property>
+ <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
+ -->
+
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.jpdl.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-concurrent/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-concurrent/src/test/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-concurrent/src/test/resources/logging.properties 2009-06-17 08:57:15 UTC (rev 5049)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+#org.hibernate.SQL.level=FINEST
+#org.hibernate.type.level=FINEST
+#org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+org.hibernate.transaction.level=FINEST
\ No newline at end of file
16 years, 10 months
JBoss JBPM SVN: r5048 - jbpm4/trunk/modules.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-06-17 04:51:48 -0400 (Wed, 17 Jun 2009)
New Revision: 5048
Added:
jbpm4/trunk/modules/test-concurrent/
Log:
Importing work done for concurrent testing (JBPM-1987)
16 years, 10 months
JBoss JBPM SVN: r5047 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-06-17 04:44:23 -0400 (Wed, 17 Jun 2009)
New Revision: 5047
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml
Log:
added pointer on how to configure identity component
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml 2009-06-17 07:48:06 UTC (rev 5046)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Configuration.xml 2009-06-17 08:44:23 UTC (rev 5047)
@@ -69,5 +69,31 @@
<listitem>resource modules/pvm/src/main/resources/jbpm.wire.bindings.xml</listitem>
<listitem>package modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding</listitem>
</itemizedlist>
+
+ <section>
+ <title>Customizing the identity component</title>
+ <para>There are 2 identity components that we support out of the box:
+ </para>
+ <itemizedlist>
+ <listitem>jBPM's built-in identity component: ships with the jBPM project distro</listitem>
+ <listitem>JBoss IDM: ships in the JBoss product platforms</listitem>
+ </itemizedlist>
+ <para>The <literal>jboss/build.xml</literal> installation scripts can be used
+ to install jBPM in JBoss using the JBoss IDM component. There is some
+ property in that build file to overwrite the default built-in identity component
+ with the value for the JBoss IDM component.
+ </para>
+ <para>If you want to plug in your own identity component, remove the
+ following line in the <literal>jbpm.cfg.xml</literal>:
+ </para>
+ <programlisting><import resource="jbpm.identity.cfg.xml" /></programlisting>
+ <para>And in the same file, add following section</para>
+ <programlisting><transaction-context>
+ <object class="your.package.YourIdentitySessionImpl" />
+</transaction-context></programlisting>
+ <para>YourIdentitySessionImpl should implement <literal>org.jbpm.pvm.internal.identity.spi.IdentitySession</literal>
+ Making this identity pluggable is not our first target, but it was taken into the design. Let us know how it goes.
+ </para>
+ </section>
</chapter>
\ No newline at end of file
16 years, 10 months