[jbpm-commits] JBoss JBPM SVN: r5760 - in jbpm4/trunk/modules: db/src/main/java/org/jbpm/db/internal/upgrade and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Oct 20 10:39:09 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-10-20 10:39:08 -0400 (Tue, 20 Oct 2009)
New Revision: 5760
Added:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/CreatePropertiesTask.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/CreatePropertiesCmd.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/GetJbpmVersionCmd.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradePropertiesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/ConfigurationTest.java
Removed:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
jbpm4/trunk/modules/test-cactus/src/test/java/org/jbpm/test/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
Modified:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
Log:
JBPM-2509 database upgrade work. refactored properties handling. in upgrade, schema creation and during process engine construction time
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/CreatePropertiesTask.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/CreatePropertiesTask.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/CreatePropertiesTask.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,50 @@
+/*
+ * 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.db.internal.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.db.internal.upgrade.CreatePropertiesCmd;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class CreatePropertiesTask extends Task {
+
+ public void execute() throws BuildException {
+ try {
+ ProcessEngine processEngine =
+ new ProcessEngineImpl()
+ .skipDbCheck()
+ .buildProcessEngine();
+
+ // create properties
+ processEngine.execute(new CreatePropertiesCmd());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException("failed to create jbpm properties during schema creation");
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/CreatePropertiesTask.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -30,22 +30,13 @@
*/
public class UpgradeTask extends Task {
- private String jbpmCfg;
-
- @Override
public void execute() throws BuildException {
- UpgradeTool upgradeTool = jbpmCfg == null ? new UpgradeTool() : new UpgradeTool(jbpmCfg);
try {
- upgradeTool.upgrade();
+ UpgradeTool.upgrade();
}
catch (Exception e) {
e.printStackTrace();
throw new BuildException("failed to upgrade jbpm database");
}
}
-
- public void setJbpmCfg(String jbpmCfg) {
- this.jbpmCfg = jbpmCfg;
- }
-
}
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/CreatePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/CreatePropertiesCmd.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/CreatePropertiesCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,42 @@
+/*
+ * 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.db.internal.upgrade;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.id.PropertyImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class CreatePropertiesCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ PropertyImpl.createProperties(session);
+ return null;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/CreatePropertiesCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/GetJbpmVersionCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/GetJbpmVersionCmd.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/GetJbpmVersionCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,52 @@
+/*
+ * 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.db.internal.upgrade;
+
+import org.hibernate.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.PropertyImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetJbpmVersionCmd implements Command<JbpmVersion> {
+
+ private static final long serialVersionUID = 1L;
+
+ public JbpmVersion execute(Environment environment) throws Exception {
+ Session session = EnvironmentImpl.getFromCurrent(Session.class);
+ if (!PropertyImpl.propertiesTableExists(session)) {
+ return JbpmVersion.V_4_0;
+ }
+
+ String dbVersion = PropertyImpl.getDbVersion(session);
+ if (dbVersion==null) {
+ throw new JbpmException("invalid db state: property table exists, but no db version property is present");
+ }
+
+ return JbpmVersion.getJbpmVersion(dbVersion);
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/GetJbpmVersionCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -1,41 +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.db.internal.upgrade;
-
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.id.DatabaseDbidGenerator;
-
-/**
- * @author Alejandro Guizar
- */
-public class InitDbidGeneratorCmd implements Command<Void> {
-
- private static final long serialVersionUID = 1L;
-
- public Void execute(Environment environment) throws Exception {
- DatabaseDbidGenerator dbidGenerator = environment.get(DatabaseDbidGenerator.class);
- dbidGenerator.initialize();
- return null;
- }
-
-}
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.internal.upgrade;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JbpmVersion {
+
+ public static final JbpmVersion V_4_0 = new JbpmVersion(4,0);
+ public static final JbpmVersion V_4_2 = new JbpmVersion(4,2);
+
+ private static Map<String, JbpmVersion> versions = new HashMap<String, JbpmVersion>();
+
+ private int major = -1;
+ private int minor = -1;
+
+ private JbpmVersion(int major, int minor) {
+ this.major = major;
+ this.minor = minor;
+ versions.put(toString(), this);
+ }
+
+ public boolean earlierThen(JbpmVersion other) {
+ return (minor<other.minor);
+ }
+
+ public String toString() {
+ return major+"."+minor;
+ }
+
+ public static JbpmVersion getJbpmVersion(String dbVersion) {
+ if (dbVersion.endsWith("-SNAPSHOT")) {
+ dbVersion = dbVersion.substring(0, dbVersion.length()-9);
+ }
+ return versions.get(dbVersion);
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/JbpmVersion.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradePropertiesCmd.java (from rev 5758, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradePropertiesCmd.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradePropertiesCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,42 @@
+/*
+ * 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.db.internal.upgrade;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.id.PropertyImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class UpgradePropertiesCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ PropertyImpl.upgradeProperties(session);
+ return null;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradePropertiesCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,37 +21,36 @@
*/
package org.jbpm.db.internal.upgrade;
-import org.jbpm.api.Configuration;
+import java.util.List;
+
import org.jbpm.api.ProcessEngine;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
/**
* @author Alejandro Guizar
*/
public class UpgradeTool {
+
+ public static void upgrade() throws Exception {
+ ProcessEngine processEngine =
+ new ProcessEngineImpl()
+ .skipDbCheck()
+ .buildProcessEngine();
- private final ProcessEngine processEngine;
-
- public UpgradeTool() {
- processEngine = Configuration.getProcessEngine();
- }
-
- public UpgradeTool(String configResource) {
- processEngine = new Configuration().setResource(configResource).buildProcessEngine();
- }
-
- public void upgrade() {
// update database schema
processEngine.execute(new UpdateSchemaCmd());
- // add property "langid" to each deployed process
- processEngine.execute(new AddLangIdCmd());
+ JbpmVersion currentVersion = processEngine.execute(new GetJbpmVersionCmd());
- // initialize database id generator
- processEngine.execute(new InitDbidGeneratorCmd());
+ if (currentVersion.earlierThen(JbpmVersion.V_4_2)) {
+ // add property "langid" to each deployed process
+ processEngine.execute(new AddLangIdCmd());
+ // upgrade properties
+ processEngine.execute(new UpgradePropertiesCmd());
+ }
}
- public static void main(String[] args) {
- UpgradeTool upgradeTool = args.length == 0 ? new UpgradeTool() : new UpgradeTool(args[0]);
- upgradeTool.upgrade();
+ public static void main(String[] args) throws Exception {
+ upgrade();
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -44,6 +44,7 @@
import org.jbpm.api.TaskService;
import org.jbpm.api.cmd.Command;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.CheckDbCmd;
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -100,6 +101,7 @@
public static final String JBPM_LIBRARY_VERSION = "4.2-SNAPSHOT";
transient protected String jndiName;
+ transient protected boolean checkDb = true;
transient protected boolean isConfigured = false;
transient protected WireContext processEngineWireContext = new WireContext(new WireDefinition(), Context.CONTEXTNAME_PROCESS_ENGINE, true);
transient protected WireDefinition transactionWireDefinition = new WireDefinition();
@@ -151,6 +153,7 @@
}
}
}
+
processEngineWireContext.create();
userCommandService = (CommandService) processEngineWireContext.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);
@@ -163,10 +166,18 @@
throw new JbpmException("JNDI binding problem", e);
}
}
+
+ checkDb();
return this;
}
+ protected void checkDb() {
+ if (checkDb) {
+ userCommandService.execute(new CheckDbCmd());
+ }
+ }
+
public Configuration setHibernateSessionFactory(Object hibernateSessionFactory) {
processEngineWireContext
.getWireDefinition()
@@ -363,6 +374,11 @@
return userCommandService.execute(command);
}
+ public ProcessEngineImpl skipDbCheck() {
+ checkDb = false;
+ return this;
+ }
+
public String getJndiName() {
return jndiName;
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.PropertyImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckDbCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static Log log = Log.getLog(CheckDbCmd.class.getName());
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = EnvironmentImpl.getFromCurrent(Session.class);
+
+ // if table JBPM4_PROPERTIES doesn't exist,
+ if (!PropertyImpl.propertiesTableExists(session)) {
+ // tell users to run upgrade
+ throw new JbpmException("jBPM DB schema not in sync with library version: no JBPM4_PROPERTIES table. Run the upgrade tool first.");
+
+ } else {
+ Long nextDbid = PropertyImpl.getNextDbid(session);
+ // if there is no next.dbid property specified
+ if (nextDbid==null) {
+ // (this only happens in the test suite)
+ // initialize the dbid property.
+ PropertyImpl.setNextDbid(session, 1);
+ }
+ }
+
+ // verify if DB version matches with library version,
+ String dbVersion = PropertyImpl.getDbVersion(session);
+ log.info("jBPM version info: library["+ProcessEngineImpl.JBPM_LIBRARY_VERSION+"], schema["+dbVersion+"]");
+
+ if ( (dbVersion!=null)
+ && (!dbVersion.equals(ProcessEngineImpl.JBPM_LIBRARY_VERSION))
+ ) {
+ // tell users to run upgrade
+ throw new JbpmException("jBPM DB schema version ("+dbVersion+") differs from jBPM library version ("+ProcessEngineImpl.JBPM_LIBRARY_VERSION+"): run the upgrade tool first.");
+ }
+
+ return null;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -23,7 +23,7 @@
PropertyImpl property = (PropertyImpl) session.createQuery(
"select property " +
"from "+PropertyImpl.class.getName()+" as property " +
- "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
+ "where property.key = '"+PropertyImpl.NEXT_DBID_KEY+"'"
).uniqueResult();
String nextIdText = property.getValue();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -60,35 +60,7 @@
// try couple of times
try {
- for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
- try {
- // acquire block
- nextId = commandService.execute(new AcquireDbidBlockCmd(blocksize));
- lastId = nextId + blocksize - 1;
-
- log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
-
- } catch (StaleStateException e) {
- // optimistic locking exception indicating another thread tried to
- // acquire a block of ids concurrently
- attempts--;
-
- // if no attempts left
- if (attempts==0) {
- // fail the surrounding transaction
- throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
- }
-
- // if there are still attempts left, first wait a bit
- int millis = 20 + random.nextInt(200);
- log.debug("optimistic locking failure while trying to acquire id block. retrying in "+millis+" millis");
- try {
- Thread.sleep(millis);
- } catch (InterruptedException e1) {
- log.debug("waiting after id block locking failure got interrupted");
- }
- }
- }
+ acquireDbidBlock();
} catch (Exception e) {
throw new JbpmException("couldn't acquire block of ids", e);
}
@@ -96,6 +68,38 @@
return nextId++;
}
+
+ protected void acquireDbidBlock() {
+ for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
+ try {
+ // acquire block
+ nextId = commandService.execute(new AcquireDbidBlockCmd(blocksize));
+ lastId = nextId + blocksize - 1;
+
+ log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
+
+ } catch (StaleStateException e) {
+ // optimistic locking exception indicating another thread tried to
+ // acquire a block of ids concurrently
+ attempts--;
+
+ // if no attempts left
+ if (attempts==0) {
+ // fail the surrounding transaction
+ throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
+ }
+
+ // if there are still attempts left, first wait a bit
+ int millis = 20 + random.nextInt(200);
+ log.debug("optimistic locking failure while trying to acquire id block. retrying in "+millis+" millis");
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e1) {
+ log.debug("waiting after id block locking failure got interrupted");
+ }
+ }
+ }
+ }
public void initialize() {
nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,12 +21,31 @@
*/
package org.jbpm.pvm.internal.id;
+import java.util.ArrayList;
+import java.util.List;
+
import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
+import org.jbpm.pvm.internal.identity.impl.GroupImpl;
+import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
+import org.jbpm.pvm.internal.identity.impl.UserImpl;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.DeploymentProperty;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.type.Variable;
/**
@@ -59,13 +78,13 @@
PropertyImpl property = (PropertyImpl) session.createQuery(
"select property " +
"from "+PropertyImpl.class.getName()+" as property " +
- "where property.key = '"+PropertyImpl.SCHEMA_VERSION_KEY+"'"
+ "where property.key = '"+PropertyImpl.DB_VERSION_KEY+"'"
).uniqueResult();
log.debug("version of jbpm library: "+ProcessEngineImpl.JBPM_LIBRARY_VERSION);
if (property==null) {
- log.debug("version of jbpm db schema: none");
+ log.info("version of jbpm db schema: none");
} else {
String dbSchemaVersion = property.getValue();
@@ -80,13 +99,14 @@
PropertyImpl property = (PropertyImpl) session.createQuery(
"select property " +
"from "+PropertyImpl.class.getName()+" as property " +
- "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
+ "where property.key = '"+PropertyImpl.NEXT_DBID_KEY+"'"
).uniqueResult();
Long nextId;
if (property==null) {
- nextId = 1L;
- property = new PropertyImpl(PropertyImpl.NEXT_ID_KEY, Long.toString(blocksize+1));
+ nextId = getMaxDbid(session);
+ nextId++;
+ property = new PropertyImpl(PropertyImpl.NEXT_DBID_KEY, Long.toString(nextId+blocksize));
session.save(property);
} else {
@@ -98,4 +118,46 @@
return nextId;
}
+
+ private Long getMaxDbid(Session session) {
+ Long nextId;
+ nextId = 0L;
+
+ List<String> persistedTypes = new ArrayList<String>();
+ persistedTypes.add(DeploymentImpl.class.getName());
+ persistedTypes.add(DeploymentProperty.class.getName());
+ persistedTypes.add(ExecutionImpl.class.getName());
+ persistedTypes.add(GroupImpl.class.getName());
+ persistedTypes.add(HistoryActivityInstanceImpl.class.getName());
+ persistedTypes.add(HistoryDetailImpl.class.getName());
+ persistedTypes.add(HistoryTaskImpl.class.getName());
+ persistedTypes.add(HistoryVariableImpl.class.getName());
+ persistedTypes.add(JobImpl.class.getName());
+ persistedTypes.add(Lob.class.getName());
+ persistedTypes.add(MembershipImpl.class.getName());
+ persistedTypes.add(ParticipationImpl.class.getName());
+ persistedTypes.add(PropertyImpl.class.getName());
+ persistedTypes.add(SwimlaneImpl.class.getName());
+ persistedTypes.add(TaskImpl.class.getName());
+ persistedTypes.add(UserImpl.class.getName());
+ persistedTypes.add(Variable.class.getName());
+
+ for (String persistedType: persistedTypes) {
+ try {
+ Long maxDbid = (Long) session.createQuery(
+ "select max(object.dbid) " +
+ "from "+persistedType+" as object"
+ ).uniqueResult();
+
+ if ( (maxDbid!=null)
+ && (maxDbid.longValue()>nextId)
+ ) {
+ nextId = maxDbid.longValue();
+ }
+ } catch (Exception e) {
+ log.info("couldn't get max dbid for "+persistedType);
+ }
+ }
+ return nextId;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,7 +21,30 @@
*/
package org.jbpm.pvm.internal.id;
+import java.util.ArrayList;
+import java.util.List;
+import org.hibernate.Session;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
+import org.jbpm.pvm.internal.identity.impl.GroupImpl;
+import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
+import org.jbpm.pvm.internal.identity.impl.UserImpl;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.DeploymentProperty;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.type.Variable;
+
+
/** jbpm installation properties.
*
* currently there are 2 use cases for these properties:
@@ -32,8 +55,10 @@
*/
public class PropertyImpl {
- public static final String SCHEMA_VERSION_KEY = "schema.version";
- public static final String NEXT_ID_KEY = "next.id";
+ private static Log log = Log.getLog(PropertyImpl.class.getName());
+
+ public static final String DB_VERSION_KEY = "db.version";
+ public static final String NEXT_DBID_KEY = "next.dbid";
protected int version;
protected String key;
@@ -46,7 +71,124 @@
this.key = key;
this.value = value;
}
+
+ public static Long getNextDbid(Session session) {
+ String dbidPropertyValue = getPropertyValue(session, PropertyImpl.NEXT_DBID_KEY);
+ if (dbidPropertyValue!=null) {
+ return Long.valueOf(dbidPropertyValue);
+ }
+ return null;
+ }
+ public static void setNextDbid(Session session, long nextDbid) {
+ setPropertyValue(session, PropertyImpl.NEXT_DBID_KEY, Long.toString(nextDbid));
+ }
+
+ public static String getDbVersion(Session session) {
+ String dbVersionPropertyValue = getPropertyValue(session, PropertyImpl.DB_VERSION_KEY);
+ if (dbVersionPropertyValue!=null) {
+ return dbVersionPropertyValue;
+ }
+ return null;
+ }
+
+ public static void setDbVersionToLibraryVersion(Session session) {
+ setPropertyValue(session, PropertyImpl.DB_VERSION_KEY, ProcessEngineImpl.JBPM_LIBRARY_VERSION);
+ }
+
+ public static void createProperties(Session session) {
+ setDbVersionToLibraryVersion(session);
+ setNextDbid(session, 1);
+ }
+
+ public static void upgradeProperties(Session session) {
+ setDbVersionToLibraryVersion(session);
+ long nextDbid = getMaxDbid(session)+1;
+ setNextDbid(session, nextDbid);
+ }
+
+ public static boolean propertiesTableExists(Session session) {
+ try {
+ session.createQuery("from "+PropertyImpl.class.getName())
+ .setMaxResults(1)
+ .uniqueResult();
+ return true;
+
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ protected static long getMaxDbid(Session session) {
+ long maxDbid = 0;
+
+ List<String> persistedTypes = new ArrayList<String>();
+ persistedTypes.add(DeploymentImpl.class.getName());
+ persistedTypes.add(DeploymentProperty.class.getName());
+ persistedTypes.add(ExecutionImpl.class.getName());
+ persistedTypes.add(GroupImpl.class.getName());
+ persistedTypes.add(HistoryActivityInstanceImpl.class.getName());
+ persistedTypes.add(HistoryDetailImpl.class.getName());
+ persistedTypes.add(HistoryTaskImpl.class.getName());
+ persistedTypes.add(HistoryVariableImpl.class.getName());
+ persistedTypes.add(JobImpl.class.getName());
+ persistedTypes.add(Lob.class.getName());
+ persistedTypes.add(MembershipImpl.class.getName());
+ persistedTypes.add(ParticipationImpl.class.getName());
+ persistedTypes.add(SwimlaneImpl.class.getName());
+ persistedTypes.add(TaskImpl.class.getName());
+ persistedTypes.add(UserImpl.class.getName());
+ persistedTypes.add(Variable.class.getName());
+
+ for (String persistedType: persistedTypes) {
+ try {
+ Long typeMaxDbid = (Long) session.createQuery(
+ "select max(object.dbid) " +
+ "from "+persistedType+" as object"
+ ).uniqueResult();
+
+ if ( (typeMaxDbid!=null)
+ && (typeMaxDbid.longValue()>maxDbid)
+ ) {
+ maxDbid = typeMaxDbid.longValue();
+ }
+ } catch (Exception e) {
+ log.info("couldn't get max dbid for "+persistedType);
+ }
+ }
+
+ return maxDbid;
+ }
+
+ protected static String getPropertyValue(Session session, String propertyKey) {
+ PropertyImpl dbidProperty = getProperty(session, propertyKey);
+ if (dbidProperty==null) {
+ return null;
+ }
+ return dbidProperty.getValue();
+ }
+
+ protected static void setPropertyValue(Session session, String propertyKey, String propertyValue) {
+ PropertyImpl dbidProperty = getProperty(session, propertyKey);
+ if (dbidProperty==null) {
+ dbidProperty = new PropertyImpl(PropertyImpl.NEXT_DBID_KEY, propertyValue);
+ session.save(dbidProperty);
+ } else {
+ dbidProperty.setValue(propertyValue);
+ session.update(dbidProperty);
+ }
+ }
+
+ protected static PropertyImpl getProperty(Session session, String key) {
+ return (PropertyImpl) session.createQuery(
+ "select property " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+key+"'"
+ ).uniqueResult();
+ }
+
+ // getters and setters //////////////////////////////////////////////////////
+
public String getKey() {
return key;
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -49,7 +49,7 @@
assertEquals("10001", session.createQuery(
"select property.value " +
"from "+PropertyImpl.class.getName()+" as property " +
- "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'").uniqueResult());
+ "where property.key = '"+PropertyImpl.NEXT_DBID_KEY+"'").uniqueResult());
return null;
}
});
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -3,9 +3,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.jbpm.api.Configuration;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.env.Transaction;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
@@ -26,12 +24,6 @@
super.tearDown();
}
- public static EnvironmentImpl openEnvironment(String xmlString) {
- EnvironmentFactory environmentFactory = (EnvironmentFactory)
- new Configuration().setXmlString(xmlString).buildProcessEngine();
- return environmentFactory.openEnvironment();
- }
-
public static class MyResource implements StandardResource {
public static List<String> events = null;
public void commit() { events.add("commit"); }
@@ -41,7 +33,7 @@
}
public void testEnlist() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -71,7 +63,7 @@
}
public void testEnlistRollback() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -101,7 +93,7 @@
}
public void testEnlistInOtherContext() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -134,7 +126,7 @@
}
public void testEnlistInOtherContextWithRollback() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -167,7 +159,7 @@
}
public void testEnlistNotAResource() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -191,7 +183,7 @@
}
public void testEnlistNotATransaction() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -215,7 +207,7 @@
}
public void testMissingTransactionName() {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,9 +21,7 @@
*/
package org.jbpm.pvm.internal.tx;
-import org.jbpm.api.Configuration;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.test.BaseJbpmTestCase;
/**
@@ -45,20 +43,13 @@
}
}
- public static EnvironmentImpl openEnvironment(String xmlString) {
- EnvironmentFactory environmentFactory = (EnvironmentFactory)
- new Configuration().setXmlString(xmlString).buildProcessEngine();
- return environmentFactory.openEnvironment();
- }
-
-
public void testMultipleResourcesFailingPrepare() {
TestResource resourceOne = null;
TestResource resourceTwo = null;
TestResource resourceThree = null;
try {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -130,7 +121,7 @@
TestResource resourceThree = null;
try {
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,10 +21,7 @@
*/
package org.jbpm.pvm.internal.tx;
-import org.jbpm.api.Configuration;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.tx.StandardTransaction;
import org.jbpm.test.BaseJbpmTestCase;
@@ -33,18 +30,11 @@
*/
public class TransactionResourcesCommitTest extends BaseJbpmTestCase {
- public static EnvironmentImpl openEnvironment(String xmlString) {
- EnvironmentFactory environmentFactory = (EnvironmentFactory)
- new Configuration().setXmlString(xmlString).buildProcessEngine();
- return environmentFactory.openEnvironment();
- }
-
-
public void testOneResourceCommit() {
TestResource resourceOne = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -81,7 +71,7 @@
TestResource resourceTwo = null;
TestResource resourceThree = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -139,7 +129,7 @@
public void testFetchOneResourceOutOfManyCommit() {
TestResource resourceTwo = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,11 +21,8 @@
*/
package org.jbpm.pvm.internal.tx;
-import org.jbpm.api.Configuration;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.env.Transaction;
-import org.jbpm.pvm.internal.tx.StandardTransaction;
import org.jbpm.test.BaseJbpmTestCase;
@@ -34,18 +31,11 @@
*/
public class TransactionResourcesSetRollbackOnlyTest extends BaseJbpmTestCase {
- public static EnvironmentImpl openEnvironment(String xmlString) {
- EnvironmentFactory environmentFactory = (EnvironmentFactory)
- new Configuration().setXmlString(xmlString).buildProcessEngine();
- return environmentFactory.openEnvironment();
- }
-
-
public void testOneResourceSetRollbackOnly() {
TestResource resourceOne = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -84,7 +74,7 @@
TestResource resourceTwo = null;
TestResource resourceThree = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
@@ -144,7 +134,7 @@
public void testFetchOneResourceOutOfManySetRollbackOnly() {
TestResource resourceTwo = null;
- EnvironmentImpl environment = openEnvironment(
+ EnvironmentImpl environment = TxTests.openEnvironment(
"<jbpm-configuration>" +
" <process-engine/>"+
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -21,6 +21,11 @@
*/
package org.jbpm.pvm.internal.tx;
+import org.jbpm.api.Configuration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
+import org.jbpm.pvm.internal.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -29,6 +34,13 @@
* @author Tom Baeyens
*/
public class TxTests {
+
+ public static EnvironmentImpl openEnvironment(String xmlString) {
+ ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) new Configuration().setXmlString(xmlString);
+ processEngineImpl.skipDbCheck();
+ EnvironmentFactory environmentFactory = (EnvironmentFactory) processEngineImpl.buildProcessEngine();
+ return environmentFactory.openEnvironment();
+ }
public static Test suite() {
TestSuite suite = new TestSuite("org.jbpm.pvm.internal.tx");
Copied: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/ConfigurationTest.java (from rev 5758, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/ConfigurationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/ConfigurationTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.configcreation;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConfigurationTest extends BaseJbpmTestCase {
+
+ public void testDefaultConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testMinimalConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString("<jbpm-configuration />")
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testConfigurationServices() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString(
+ "<jbpm-configuration>" +
+ " <process-engine-context>" +
+ " <repository-service />" +
+ " <execution-service />" +
+ " <management-service />" +
+ " </process-engine-context>" +
+ "</jbpm-configuration>"
+ )
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ assertNotNull(processEngine.getExecutionService());
+ assertNotNull(processEngine.getManagementService());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/configcreation/ConfigurationTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2009-10-20 07:37:23 UTC (rev 5759)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2009-10-20 14:39:08 UTC (rev 5760)
@@ -1,62 +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.cfg;
-
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.test.BaseJbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ConfigurationTest extends BaseJbpmTestCase {
-
- public void testDefaultConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testMinimalConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString("<jbpm-configuration />")
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testConfigurationServices() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString(
- "<jbpm-configuration>" +
- " <process-engine-context>" +
- " <repository-service />" +
- " <execution-service />" +
- " <management-service />" +
- " </process-engine-context>" +
- "</jbpm-configuration>"
- )
- .buildProcessEngine();
- assertNotNull(processEngine);
- assertNotNull(processEngine.getExecutionService());
- assertNotNull(processEngine.getManagementService());
- }
-}
More information about the jbpm-commits
mailing list