JBoss JBPM SVN: r5761 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/job and 7 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-10-20 10:51:31 -0400 (Tue, 20 Oct 2009)
New Revision: 5761
Added:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/process.jpdl.xml
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/DbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java
Log:
Bugfix: when recreating a process engine and deploying a process after other processes have been deployed, the dbidGenerator is reset to the wrong values.
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 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -101,6 +101,10 @@
}
}
+ public void reset() {
+ initialize(); // resetting the DatabaseIdGenerator means just reinitializing the id
+ }
+
public void initialize() {
nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
lastId = nextId + blocksize - 1;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -44,4 +44,7 @@
}
public abstract long getNextId();
+
+ public abstract void reset();
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -27,9 +27,14 @@
*/
public class MemoryDbidGenerator extends DbidGenerator {
- static long nextId = 1;
+ long nextId = 1;
public synchronized long getNextId() {
return nextId++;
}
+
+ public synchronized void reset() {
+ nextId = 1;
+ }
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -125,7 +125,7 @@
ObjectOutputStream objectStream = new ObjectOutputStream(byteStream);
objectStream.writeObject(configuration);
byte[] bytes = byteStream.toByteArray();
- configurationBytes = new Lob(bytes);
+ configurationBytes = new Lob(bytes, true);
} catch (Exception e) {
throw new JbpmException("couldn't serialize configuration object for "+this, e);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -60,19 +60,35 @@
return dbid;
}
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
+
+ // Only for Hibernate. Do not use directly!
public Lob() {
}
- public Lob(byte[] bytes) {
+ /**
+ * @param bytes The actual bytes that will be stored.
+ * @param generateId If true, the default {@link DbidGenerator} will be used
+ * generate a dbid for this Lob object.
+ */
+ public Lob(byte[] bytes, boolean generateDbid) {
cachedBytes = bytes;
getBlobStrategy().set(bytes, this);
- this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+
+ if (generateDbid) {
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+ }
}
- public Lob(char[] text) {
+ public Lob(char[] text, boolean generateDbid) {
cachedChars = text;
getClobStrategy().set(text, this);
- this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+
+ if (generateDbid) {
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -41,6 +41,7 @@
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.cmd.DeployCmd;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.lob.Lob;
import org.jbpm.pvm.internal.stream.ByteArrayStreamInput;
import org.jbpm.pvm.internal.stream.FileStreamInput;
@@ -144,8 +145,12 @@
} catch (IOException e) {
throw new JbpmException("couldn't read from "+streamInput, e);
}
- Lob lob = new Lob(bytes);
+
+ // Since this method is probably called outside an environment block, we
+ // need to generate the dbid of the Lob later (during the actual deployment).
+ Lob lob = new Lob(bytes, false);
resources.put(name, lob);
+
return this;
}
@@ -156,6 +161,20 @@
return resources.keySet();
}
+ /**
+ * This method should be called before saving the deployment. It will assign a
+ * generated dbid to the resource Lobs.
+ *
+ * Note: when using a database, this method must be called within an
+ * environment block!
+ */
+ public void initResourceLobDbids() {
+ for (Lob resource : resources.values()) {
+ long resourceDbid = DbidGenerator.getDbidGenerator().getNextId();
+ resource.setDbid(resourceDbid);
+ }
+ }
+
public byte[] getBytes(String resourceName) {
if (resources!=null) {
Lob lob = resources.get(resourceName);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -33,6 +33,7 @@
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.id.DbidGenerator;
+import org.jbpm.pvm.internal.lob.Lob;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
@@ -54,8 +55,9 @@
long dbid = DbidGenerator.getDbidGenerator().getNextId();
deploymentImpl.setDbid(dbid);
- session.save(deploymentImpl);
+ deploymentImpl.initResourceLobDbids();
+ session.save(deploymentImpl); // will also save the attached resources
deployerManager.deploy(deploymentImpl);
return deploymentImpl.getId();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -49,7 +49,7 @@
dbSession.delete(this.lob);
}
}
- this.lob = new Lob((byte[])value);
+ this.lob = new Lob((byte[])value, true);
}
public Lob getLob() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java 2009-10-20 14:39:08 UTC (rev 5760)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -44,7 +44,7 @@
}
public void setObject(Object value) {
- this.lob = new Lob((char[])value);
+ this.lob = new Lob((char[])value, true);
}
public Lob getLob() {
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/idgenerator/DeploymentIdGenerationTest.java 2009-10-20 14:51:31 UTC (rev 5761)
@@ -0,0 +1,110 @@
+/*
+ * 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.idgenerator;
+
+import java.util.List;
+
+import javax.persistence.Lob;
+
+import org.jbpm.api.Deployment;
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.pvm.internal.id.DbidGenerator;
+import org.jbpm.pvm.internal.id.MemoryDbidGenerator;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.test.JbpmCustomCfgTestCase;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class DeploymentIdGenerationTest extends JbpmCustomCfgTestCase {
+
+ /**
+ * Test for a specific problem discovered after changing the idGeneration:
+ *
+ * After deploying some processes, the server is restarted and the
+ * {@link ProcessEngine} is recreated. At that point, when trying to deploy a
+ * process from the classpath, a new {@link Lob} object is created.
+ *
+ * This Lob object required a new dbId from the current DbIdGenerator.
+ * However, the id acquirement happened outside an environment block which
+ * means that the default DbIdGenerator was used: the
+ * {@link MemoryDbidGenerator}.
+ *
+ * Of course, after a restart the member fields of the
+ * {@link MemoryDbidGenerator} were reset, leading to generated ids that were
+ * used before, causing all kind of strange Hibernate errors.
+ *
+ * This test emulates this situation by closing and nullifying the
+ * {@link ProcessEngine} and deploying and continuing a given process.
+ */
+ public void testDeploymentIdGenerationAfterProcessEngineClose() {
+
+ // Start a simple process
+ deployTestProcess();
+ String pid = executionService.startProcessInstanceByKey("simpleProcess").getId();
+
+ // reset process engine and redeploy
+ resetProcessEngineAndDbidGenerator();
+ deployTestProcess();
+
+ // There should now be 2 deployments in the database, with a different id
+ List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
+ assertEquals(2, deployments.size());
+ assertNotSame(deployments.get(0).getId(), deployments.get(1).getId());
+
+ String execId = executionService.findProcessInstanceById(pid).findActiveExecutionIn("a").getId();
+ executionService.signalExecutionById(execId);
+ assertActivityActive(pid, "b");
+
+ resetProcessEngineAndDbidGenerator();
+ execId = executionService.findProcessInstanceById(pid).findActiveExecutionIn("b").getId();
+ executionService.signalExecutionById(execId);
+ assertProcessInstanceEnded(pid);
+ }
+
+ private void deployTestProcess() {
+ NewDeployment deployment = repositoryService.createDeployment()
+ .addResourceFromClasspath(getClass().getPackage().getName().replace(".", "/")+"/process.jpdl.xml");
+ deployment.deploy();
+ registerDeployment(deployment.getId());
+ }
+
+ private void resetProcessEngineAndDbidGenerator() {
+ // Close the process engine and recreate it
+ ProcessEngine oldProcessEngine = processEngine;
+ processEngine.close();
+ processEngine = null;
+
+ initialize(); // creates a new ProcessEngine and services
+ assertNotSame(oldProcessEngine, processEngine);
+
+ // Reset the in memory generator and redeploy the process
+ DbidGenerator.getDefaultIdGenerator().reset();
+ }
+
+}
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml 2009-10-20 14:51:31 UTC (rev 5761)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+ <process-engine-context>
+
+ <repository-service />
+ <repository-cache />
+ <execution-service />
+ <history-service />
+ <management-service />
+ <identity-service />
+ <task-service />
+
+ <hibernate-configuration>
+ <cfg resource="org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
+ <invoke method="initialize" />
+ </object>
+
+ <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
+ <script-manager default-expression-language="juel"
+ default-script-language="juel">
+ <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
+ </script-manager>
+
+ <types resource="jbpm.variable.types.xml" />
+
+ <address-resolver />
+
+ </process-engine-context>
+
+ <transaction-context>
+ <repository-session />
+ <db-session />
+
+ <message-session />
+ <timer-session />
+ <history-session />
+ <mail-session>
+ <mail-server>
+ <session-properties resource="jbpm.mail.properties" />
+ </mail-server>
+ </mail-session>
+ </transaction-context>
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml 2009-10-20 14:51:31 UTC (rev 5761)
@@ -0,0 +1,26 @@
+<?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>
+ <property name="hibernate.format_sql">true</property>
+
+ <property name="hibernate.hbm2ddl.auto">update</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.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/process.jpdl.xml 2009-10-20 14:51:31 UTC (rev 5761)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process name='simpleProcess'>
+ <start>
+ <transition to='a' />
+ </start>
+ <state name='a'>
+ <transition to='b' />
+ </state>
+ <state name='b'>
+ <transition to='c' />
+ </state>
+ <end name='c' />
+</process>
\ No newline at end of file
16 years, 6 months
JBoss JBPM SVN: r5760 - in jbpm4/trunk/modules: db/src/main/java/org/jbpm/db/internal/upgrade and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)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());
- }
-}
16 years, 6 months
JBoss JBPM SVN: r5759 - in jbpm4/trunk/modules/db/src: test/java/org/jbpm/db/internal/upgrade and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-10-20 03:37:23 -0400 (Tue, 20 Oct 2009)
New Revision: 5759
Added:
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmdTest.java
Modified:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
Log:
[JBPM-2509] test UpdateSchemaCmd
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java 2009-10-20 04:16:28 UTC (rev 5758)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java 2009-10-20 07:37:23 UTC (rev 5759)
@@ -33,15 +33,19 @@
*
* @author Alejandro Guizar
*/
-public class UpdateSchemaCmd implements Command<List<Exception>> {
+public class UpdateSchemaCmd implements Command<Void> {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- public List<Exception> execute(Environment environment) throws Exception {
+ public Void execute(Environment environment) throws Exception {
SchemaUpdate schemaUpdate = new SchemaUpdate(environment.get(Configuration.class));
schemaUpdate.execute(false, true);
- return schemaUpdate.getExceptions();
+ List< ? > exceptions = schemaUpdate.getExceptions();
+ if (!exceptions.isEmpty()) {
+ // in case there were several exceptions, schema update logged them already
+ throw (Exception) exceptions.get(0);
+ }
+ return null;
}
}
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 04:16:28 UTC (rev 5758)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java 2009-10-20 07:37:23 UTC (rev 5759)
@@ -21,8 +21,6 @@
*/
package org.jbpm.db.internal.upgrade;
-import java.util.List;
-
import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
@@ -41,11 +39,9 @@
processEngine = new Configuration().setResource(configResource).buildProcessEngine();
}
- public void upgrade() throws Exception {
+ public void upgrade() {
// update database schema
- List<Exception> exceptions = processEngine.execute(new UpdateSchemaCmd());
- if (!exceptions.isEmpty())
- throw exceptions.get(0);
+ processEngine.execute(new UpdateSchemaCmd());
// add property "langid" to each deployed process
processEngine.execute(new AddLangIdCmd());
@@ -54,7 +50,7 @@
processEngine.execute(new InitDbidGeneratorCmd());
}
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
UpgradeTool upgradeTool = args.length == 0 ? new UpgradeTool() : new UpgradeTool(args[0]);
upgradeTool.upgrade();
}
Added: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmdTest.java
===================================================================
--- jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmdTest.java (rev 0)
+++ jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmdTest.java 2009-10-20 07:37:23 UTC (rev 5759)
@@ -0,0 +1,205 @@
+/*
+ * 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.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.ConnectionProviderFactory;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.mapping.Table;
+import org.hibernate.util.JDBCExceptionReporter;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class UpdateSchemaCmdTest extends JbpmTestCase {
+
+ public void testUpdateSchema() {
+ // drop some jbpm table
+ processEngine.execute(new DropTableCmd("JBPM4_PROPERTY"));
+ assertFalse(processEngine.execute(new TableExistsCmd("JBPM4_PROPERTY")));
+
+ // run schema update tool
+ processEngine.execute(new UpdateSchemaCmd());
+
+ // verify jbpm table was created again
+ assertTrue(processEngine.execute(new TableExistsCmd("JBPM4_PROPERTY")));
+ }
+
+ /**
+ * Base class for SQL commands on top of Hibernate.
+ *
+ * @author Alejandro Guizar
+ */
+ static abstract class SqlCmd<T> implements Command<T> {
+
+ private Configuration configuration;
+ private ConnectionProvider connectionProvider;
+
+ private static final long serialVersionUID = 1L;
+
+ public T execute(Environment environment) throws SQLException {
+ configuration = environment.get(Configuration.class);
+ Connection connection = null;
+ try {
+ connection = createConnection();
+ return execute(connection);
+ } finally {
+ closeConnection(connection);
+ configuration = null;
+ }
+ }
+
+ protected abstract T execute(Connection connection) throws SQLException;
+
+ protected Dialect getDialect() {
+ return Dialect.getDialect(configuration.getProperties());
+ }
+
+ protected String getDefaultCatalog() {
+ return configuration.getProperty(org.hibernate.cfg.Environment.DEFAULT_CATALOG);
+ }
+
+ protected String getDefaultSchema() {
+ return configuration.getProperty(org.hibernate.cfg.Environment.DEFAULT_SCHEMA);
+ }
+
+ protected Table findTable(String tableName) {
+ for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+ Table table = (Table) i.next();
+ if (tableName.equals(table.getName()))
+ return table;
+ }
+ throw new NoSuchElementException(tableName);
+ }
+
+ private Connection createConnection() throws SQLException {
+ try {
+ connectionProvider = ConnectionProviderFactory.newConnectionProvider(configuration.getProperties());
+ } catch (HibernateException e) {
+ throw new SQLException(e.getMessage());
+ }
+ Connection connection = connectionProvider.getConnection();
+ if (connection.getAutoCommit() == false) {
+ connection.commit();
+ connection.setAutoCommit(true);
+ }
+ return connection;
+ }
+
+ private void closeConnection(Connection connection) {
+ if (connectionProvider != null) {
+ try {
+ if (connection != null) {
+ JDBCExceptionReporter.logAndClearWarnings(connection);
+ connectionProvider.closeConnection(connection);
+ }
+ } catch (SQLException e) {
+ JDBCExceptionReporter.logExceptions(e);
+ } finally {
+ connectionProvider.close();
+ connectionProvider = null;
+ }
+ }
+ }
+ }
+
+ /**
+ * Drop the named table from the database.
+ *
+ * @author Alejandro Guizar
+ */
+ static class DropTableCmd extends SqlCmd<Void> {
+
+ private final String tableName;
+
+ private static final long serialVersionUID = 1L;
+
+ DropTableCmd(String tableName) {
+ this.tableName = tableName;
+ }
+
+ protected Void execute(Connection connection) throws SQLException {
+ Table table = findTable(tableName);
+
+ // generate sql to drop table
+ String dropSql = table.sqlDropString(getDialect(), getDefaultCatalog(), getDefaultSchema());
+
+ // execute sql to drop table
+ Statement statement = connection.createStatement();
+ try {
+ statement.executeUpdate(dropSql);
+
+ SQLWarning warning = statement.getWarnings();
+ if (warning != null) {
+ JDBCExceptionReporter.logWarnings(warning);
+ statement.clearWarnings();
+ }
+ } finally {
+ statement.close();
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Tell whether the named table exists in the database.
+ *
+ * @author Alejandro Guizar
+ */
+ static class TableExistsCmd extends SqlCmd<Boolean> {
+
+ private final String tableName;
+
+ private static final long serialVersionUID = 1L;
+ private static final String[] TABLE_TYPES = { "TABLE" };
+
+ TableExistsCmd(String tableName) {
+ this.tableName = tableName;
+ }
+
+ protected Boolean execute(Connection connection) throws SQLException {
+ DatabaseMetaData metaData = connection.getMetaData();
+ ResultSet resultSet = metaData.getTables(getDefaultCatalog(), getDefaultSchema(), tableName, TABLE_TYPES);
+ try {
+ return resultSet.next();
+ } finally {
+ resultSet.close();
+ }
+ }
+
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmdTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 6 months
JBoss JBPM SVN: r5758 - in jbpm4/trunk/modules: db/src and 11 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-10-20 00:16:28 -0400 (Tue, 20 Oct 2009)
New Revision: 5758
Added:
jbpm4/trunk/modules/db/src/test/
jbpm4/trunk/modules/db/src/test/java/
jbpm4/trunk/modules/db/src/test/java/org/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/
jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
jbpm4/trunk/modules/db/src/test/resources/
jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/db/src/test/resources/logging.properties
Modified:
jbpm4/trunk/modules/db/.classpath
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
Log:
[JBPM-2509] add langid property to processes that do not have it
Modified: jbpm4/trunk/modules/db/.classpath
===================================================================
--- jbpm4/trunk/modules/db/.classpath 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/db/.classpath 2009-10-20 04:16:28 UTC (rev 5758)
@@ -2,6 +2,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/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -24,9 +24,12 @@
import java.util.List;
import org.hibernate.Session;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.DeploymentProperty;
/**
* Adds the "langid" property to each deployed process.
@@ -37,16 +40,31 @@
private static final long serialVersionUID = 1L;
+ @SuppressWarnings("unchecked")
public Void execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
- // find process definitions without a langid property
- List processDefinitions = session.createCriteria(JpdlProcessDefinition.class).list();
+ // find deployments without a langid property
+ List<DeploymentImpl> deployments = session.createQuery("from "
+ + DeploymentImpl.class.getName()
+ + " d\n"
+ + "where not exists(\n"
+ + " from "
+ + DeploymentProperty.class.getName()
+ + " p\n"
+ + " where p.deployment = d\n"
+ + " and p.key = '"
+ + DeploymentImpl.KEY_PROCESS_LANGUAGE_ID
+ + "')").list();
// initialize missing langid property to "jpdl-4.0"
- for (Object element : processDefinitions) {
- JpdlProcessDefinition processDefinition = (JpdlProcessDefinition) element;
- // TODO how?
+ RepositoryService repositoryService = environment.get(RepositoryService.class);
+ for (DeploymentImpl deployment : deployments) {
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .deploymentId(deployment.getId())
+ .list();
+ for (ProcessDefinition processDefinition : processDefinitions) {
+ deployment.setProcessLanguageId(processDefinition.getName(), "jpdl-4.0");
+ }
}
return null;
}
-
}
Added: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
===================================================================
--- jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java (rev 0)
+++ jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,81 @@
+/*
+ * 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.repository.DeploymentImpl;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class AddLangIdCmdTest extends JbpmTestCase {
+
+ private String deploymentId;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromString("process.jpdl.xml", "<process name='"
+ + getName()
+ + "'>"
+ + " <start/>"
+ + "</process>")
+ .deploy();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+ super.tearDown();
+ }
+
+ public void testAddLangId() {
+ processEngine.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ DeploymentImpl deployment = (DeploymentImpl) environment.get(Session.class)
+ .load(DeploymentImpl.class, Long.valueOf(deploymentId));
+ Object langId = deployment.removeObjectProperty(getName(), DeploymentImpl.KEY_PROCESS_LANGUAGE_ID);
+ assertEquals("jpdl-4.2", langId);
+ return null;
+ }
+ });
+
+ processEngine.execute(new AddLangIdCmd());
+
+ processEngine.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ DeploymentImpl deployment = (DeploymentImpl) environment.get(Session.class)
+ .load(DeploymentImpl.class, Long.valueOf(deploymentId));
+ assertEquals("jpdl-4.0", deployment.getProcessLanguageId(getName()));
+ return null;
+ }
+ });
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/test/java/org/jbpm/db/internal/upgrade/AddLangIdCmdTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,25 @@
+<?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>
+ <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.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Property changes on: jbpm4/trunk/modules/db/src/test/resources/jbpm.hibernate.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/db/src/test/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/db/src/test/resources/logging.properties 2009-10-20 04:16:28 UTC (rev 5758)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINE
+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
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-10-20 04:16:28 UTC (rev 5758)
@@ -151,7 +151,7 @@
public Set<String> getResourceNames() {
if (resources==null) {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
return resources.keySet();
}
@@ -217,6 +217,20 @@
objectProperties.add(deploymentProperty);
}
+ public Object removeObjectProperty(String objectName, String key) {
+ if (objectProperties != null) {
+ for (DeploymentProperty deploymentProperty : objectProperties) {
+ if (deploymentProperty.getObjectName().equals(objectName)
+ && deploymentProperty.getKey().equals(key)) {
+ Object value = deploymentProperty.getValue();
+ objectProperties.remove(deploymentProperty);
+ return value;
+ }
+ }
+ }
+ return null;
+ }
+
public Object getObjectProperty(String objectName, String key) {
if (objectProperties!=null) {
for (DeploymentProperty deploymentProperty: objectProperties) {
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-10-19 14:12:03 UTC (rev 5757)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-10-20 04:16:28 UTC (rev 5758)
@@ -26,7 +26,7 @@
<set name="objectProperties"
table="JBPM4_DEPLOYPROPS"
- cascade="all">
+ cascade="all-delete-orphan">
<key column="DEPLOYMENT_" />
<one-to-many class="org.jbpm.pvm.internal.repository.DeploymentProperty" />
</set>
16 years, 6 months
JBoss JBPM SVN: r5757 - jbpm4/trunk/modules/distro/src/main/files.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-19 10:12:03 -0400 (Mon, 19 Oct 2009)
New Revision: 5757
Modified:
jbpm4/trunk/modules/distro/src/main/files/readme.html
Log:
JBPM-2548 documented the known limitation
Modified: jbpm4/trunk/modules/distro/src/main/files/readme.html
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-10-19 13:27:02 UTC (rev 5756)
+++ jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-10-19 14:12:03 UTC (rev 5757)
@@ -38,6 +38,13 @@
<h1>Release Notes for jBPM 4.2</h1>
+<h2>Known limitations</h2>
+
+<p>On oracle, using DeploymentQuery.PROPERTY_NAME is causing a problem.
+We've deprecated the property because of that reason and in one of the next
+releases, the DeploymentQuery.PROPERTY_NAME will be removed.
+</p>
+
<h2>API changes</h2>
<ul>
16 years, 6 months
JBoss JBPM SVN: r5756 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/activity and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-19 09:27:02 -0400 (Mon, 19 Oct 2009)
New Revision: 5756
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/GroupConcurrencyCombinationTest.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
Log:
JBPM-2487 fixed group concurrency problem
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-10-19 12:15:40 UTC (rev 5755)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-10-19 13:27:02 UTC (rev 5756)
@@ -56,7 +56,7 @@
ExecutionImpl concurrentRoot = null;
if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
concurrentRoot = execution;
- } else if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
+ } else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
concurrentRoot = execution.getParent();
} else {
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/GroupConcurrencyCombinationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/GroupConcurrencyCombinationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/GroupConcurrencyCombinationTest.java 2009-10-19 13:27:02 UTC (rev 5756)
@@ -0,0 +1,251 @@
+/*
+ * 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.activity.group;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroupConcurrencyCombinationTest extends JbpmTestCase {
+
+
+ public void testGroupConcurrencyWithStartEndSignalFirstGroup() {
+ deployJpdlXmlString(
+ "<process name='GroupConcurrency'>" +
+ " <start>" +
+ " <transition to='fork'/>" +
+ " </start>" +
+ " <fork name='fork'>" +
+ " <transition to='group'/>" +
+ " <transition to='concurrent-wait'/>" +
+ " </fork>" +
+ " <group name='group'>" +
+ " <start name='group-start'>" +
+ " <transition to='group-wait'/>" +
+ " </start>" +
+ " <state name='group-wait'>" +
+ " <transition to='group-end'/>" +
+ " </state>" +
+ " <end name='group-end'/>" +
+ " <transition to='join'/>" +
+ " </group>" +
+ " <state name='concurrent-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " <join name='join'>" +
+ " <transition to='end'/>" +
+ " </join>" +
+ " <state name='end'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("GroupConcurrency");
+
+ Set<String> expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ Execution executionInGroupWait = processInstance.findActiveExecutionIn("group-wait");
+ assertNotNull(executionInGroupWait);
+
+ Execution executionInConcurrentWait = processInstance.findActiveExecutionIn("concurrent-wait");
+ assertNotNull(executionInConcurrentWait);
+
+ processInstance = executionService.signalExecutionById(executionInGroupWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ processInstance = executionService.signalExecutionById(executionInConcurrentWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("end");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+ }
+
+ public void testGroupConcurrencyWithStartEndSignalFirstConcurrent() {
+ deployJpdlXmlString(
+ "<process name='GroupConcurrency'>" +
+ " <start>" +
+ " <transition to='fork'/>" +
+ " </start>" +
+ " <fork name='fork'>" +
+ " <transition to='group'/>" +
+ " <transition to='concurrent-wait'/>" +
+ " </fork>" +
+ " <group name='group'>" +
+ " <start name='group-start'>" +
+ " <transition to='group-wait'/>" +
+ " </start>" +
+ " <state name='group-wait'>" +
+ " <transition to='group-end'/>" +
+ " </state>" +
+ " <end name='group-end'/>" +
+ " <transition to='join'/>" +
+ " </group>" +
+ " <state name='concurrent-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " <join name='join'>" +
+ " <transition to='end'/>" +
+ " </join>" +
+ " <state name='end'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("GroupConcurrency");
+
+ Set<String> expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ Execution executionInGroupWait = processInstance.findActiveExecutionIn("group-wait");
+ assertNotNull(executionInGroupWait);
+
+ Execution executionInConcurrentWait = processInstance.findActiveExecutionIn("concurrent-wait");
+ assertNotNull(executionInConcurrentWait);
+
+ processInstance = executionService.signalExecutionById(executionInConcurrentWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ processInstance = executionService.signalExecutionById(executionInGroupWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("end");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+ }
+
+ public void testGroupConcurrencyDirectTransitionsSignalFirstGroup() {
+ deployJpdlXmlString(
+ "<process name='GroupConcurrency'>" +
+ " <start>" +
+ " <transition to='fork'/>" +
+ " </start>" +
+ " <fork name='fork'>" +
+ " <transition to='group-wait'/>" +
+ " <transition to='concurrent-wait'/>" +
+ " </fork>" +
+ " <group name='group'>" +
+ " <state name='group-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " </group>" +
+ " <state name='concurrent-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " <join name='join'>" +
+ " <transition to='end'/>" +
+ " </join>" +
+ " <state name='end'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("GroupConcurrency");
+
+ Set<String> expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ Execution executionInGroupWait = processInstance.findActiveExecutionIn("group-wait");
+ assertNotNull(executionInGroupWait);
+
+ Execution executionInConcurrentWait = processInstance.findActiveExecutionIn("concurrent-wait");
+ assertNotNull(executionInConcurrentWait);
+
+ processInstance = executionService.signalExecutionById(executionInGroupWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ processInstance = executionService.signalExecutionById(executionInConcurrentWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("end");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+ }
+
+ public void testGroupConcurrencyDirectTransitionsSignalFirstConcurrent() {
+ deployJpdlXmlString(
+ "<process name='GroupConcurrency'>" +
+ " <start>" +
+ " <transition to='fork'/>" +
+ " </start>" +
+ " <fork name='fork'>" +
+ " <transition to='group-wait'/>" +
+ " <transition to='concurrent-wait'/>" +
+ " </fork>" +
+ " <group name='group'>" +
+ " <state name='group-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " </group>" +
+ " <state name='concurrent-wait'>" +
+ " <transition to='join'/>" +
+ " </state>" +
+ " <join name='join'>" +
+ " <transition to='end'/>" +
+ " </join>" +
+ " <state name='end'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("GroupConcurrency");
+
+ Set<String> expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ expectedActivityNames.add("concurrent-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ Execution executionInGroupWait = processInstance.findActiveExecutionIn("group-wait");
+ assertNotNull(executionInGroupWait);
+
+ Execution executionInConcurrentWait = processInstance.findActiveExecutionIn("concurrent-wait");
+ assertNotNull(executionInConcurrentWait);
+
+ processInstance = executionService.signalExecutionById(executionInConcurrentWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("group-wait");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ processInstance = executionService.signalExecutionById(executionInGroupWait.getId());
+
+ expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("end");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/group/GroupConcurrencyCombinationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss JBPM SVN: r5755 - in jbpm4/trunk/modules: distro/src/main/files/install/src/cfg/jbpm and 4 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-19 08:15:40 -0400 (Mon, 19 Oct 2009)
New Revision: 5755
Added:
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.console.cfg.xml
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/jta.jbpm.cfg.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.jbpm.cfg.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/standalone.jbpm.cfg.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/jboss/config/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java
Log:
renamed jbpm.console.webservice.port (and host) to jbpm.console.server.port and fixed tomcat setup for these properties
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -73,7 +73,7 @@
<or>
<os family="unix" />
<os family="mac" />
- <os family="sunos" />
+ <os name="sunos" />
</or>
</condition>
<condition property="hsqldb.needed">
@@ -434,7 +434,7 @@
<!-- create the jbpm configuration jar file and drop in /lib -->
<jar destfile="${tomcat.home}/lib/jbpm.cfg.jar">
- <fileset dir="generated/cfg">
+ <fileset dir="${jbpm.home}/install/generated/cfg">
<exclude name="logging.properties"/>
</fileset>
</jar>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/jta.jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/jta.jbpm.cfg.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/jta.jbpm.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -7,6 +7,7 @@
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
</jbpm-configuration>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.jbpm.cfg.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.jbpm.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -7,6 +7,7 @@
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
</jbpm-configuration>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -7,6 +7,7 @@
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.mail.templates.examples.xml" />
</jbpm-configuration>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/standalone.jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/standalone.jbpm.cfg.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/standalone.jbpm.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -7,6 +7,7 @@
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
</jbpm-configuration>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/jboss/config/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/jboss/config/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/jboss/config/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -8,10 +8,6 @@
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
- <process-engine-context>
- <string name="jbpm.console.webservice.host" value="localhost" />
- <string name="jbpm.console.webservice.port" value="8080" />
- </process-engine-context>
-
</jbpm-configuration>
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-10-19 12:15:40 UTC (rev 5755)
@@ -78,13 +78,13 @@
this.processEngine = Configuration.getProcessEngine();
}
- this.webServiceHost = (String) processEngine.get("jbpm.console.webservice.host");
- this.webServicePort = (String) processEngine.get("jbpm.console.webservice.port");
+ this.webServiceHost = (String) processEngine.get("jbpm.console.server.host");
+ this.webServicePort = (String) processEngine.get("jbpm.console.server.port");
if ( (webServiceHost==null)
|| (webServicePort==null)
) {
- throw new JbpmException("make sure that strings 'jbpm.console.webservice.host' and 'jbpm.console.webservice.port' are properly configured in the process-engine-context of jbpm.cfg.xml");
+ throw new JbpmException("make sure that strings 'jbpm.console.server.host' and 'jbpm.console.server.port' are properly configured in the process-engine-context of jbpm.cfg.xml");
}
}
Modified: jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java 2009-10-19 09:04:45 UTC (rev 5754)
+++ jbpm4/trunk/modules/integration/graphView-plugin/src/main/java/org/jbpm/integration/console/graphView/GraphViewerPluginImpl.java 2009-10-19 12:15:40 UTC (rev 5755)
@@ -69,13 +69,13 @@
this.processEngine = Configuration.getProcessEngine();
}
- this.webServiceHost = (String) processEngine.get("jbpm.console.webservice.host");
- this.webServicePort = (String) processEngine.get("jbpm.console.webservice.port");
+ this.webServiceHost = (String) processEngine.get("jbpm.console.server.host");
+ this.webServicePort = (String) processEngine.get("jbpm.console.server.port");
if ( (webServiceHost==null)
|| (webServicePort==null)
) {
- throw new JbpmException("make sure that strings 'jbpm.console.webservice.host' and 'jbpm.console.webservice.port' are properly configured in the process-engine-context of jbpm.cfg.xml");
+ throw new JbpmException("make sure that strings 'jbpm.console.server.host' and 'jbpm.console.server.port' are properly configured in the process-engine-context of jbpm.cfg.xml");
}
}
Added: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.console.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.console.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.console.cfg.xml 2009-10-19 12:15:40 UTC (rev 5755)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <process-engine-context>
+ <string name="jbpm.console.server.host" value="localhost" />
+ <string name="jbpm.console.server.port" value="8080" />
+ </process-engine-context>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.console.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss JBPM SVN: r5754 - jbpm4/trunk/modules/distro/src/main/files/install.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-10-19 05:04:45 -0400 (Mon, 19 Oct 2009)
New Revision: 5754
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
Log:
JBPM-2586 add support for sunos in installation scripts
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-18 08:03:52 UTC (rev 5753)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-10-19 09:04:45 UTC (rev 5754)
@@ -73,6 +73,7 @@
<or>
<os family="unix" />
<os family="mac" />
+ <os family="sunos" />
</or>
</condition>
<condition property="hsqldb.needed">
16 years, 6 months
JBoss JBPM SVN: r5753 - in jbpm4/trunk/modules/db/src/main/java/org/jbpm/db: internal and 2 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-10-18 04:03:52 -0400 (Sun, 18 Oct 2009)
New Revision: 5753
Added:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/
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/
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
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/UpdateSchemaCmd.java
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
Removed:
jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java
Log:
[JBPM-2509] provide upgrade tool and related ant task
Deleted: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java 2009-10-18 06:30:10 UTC (rev 5752)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -1,49 +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;
-
-import org.jbpm.api.JbpmException;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DbUpgrade {
-
- public static void main(String[] args) {
- System.out.println("jBPM DB upgrade tool");
- if (args!=null) {
- for (int i=0; i<args.length; i++) {
- System.out.println(" args["+i+"]="+args[i]);
- }
- }
-
- throw new JbpmException("TODO initialize langid deployproperties for existing processes");
-
-// String dbVersion = getDbVersion();
-// String distroVersion = "4.2";
-//
-// if (upgrade41to40Necessary(dbVersion)) {
-// upgrade41to40();
-// }
- }
-}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -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.db.internal.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.jbpm.db.internal.upgrade.UpgradeTool;
+
+/**
+ * @author Alejandro Guizar
+ */
+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();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException("failed to upgrade jbpm database");
+ }
+ }
+
+ public void setJbpmCfg(String jbpmCfg) {
+ this.jbpmCfg = jbpmCfg;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/ant/UpgradeTask.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -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 java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+
+/**
+ * Adds the "langid" property to each deployed process.
+ *
+ * @author Alejandro Guizar
+ */
+public class AddLangIdCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ // find process definitions without a langid property
+ List processDefinitions = session.createCriteria(JpdlProcessDefinition.class).list();
+ // initialize missing langid property to "jpdl-4.0"
+ for (Object element : processDefinitions) {
+ JpdlProcessDefinition processDefinition = (JpdlProcessDefinition) element;
+ // TODO how?
+ }
+ return null;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/AddLangIdCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.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;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/InitDbidGeneratorCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -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.db.internal.upgrade;
+
+import java.util.List;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+
+/**
+ * Executes the Hibernate schema update tool.
+ *
+ * @author Alejandro Guizar
+ */
+public class UpdateSchemaCmd implements Command<List<Exception>> {
+
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings("unchecked")
+ public List<Exception> execute(Environment environment) throws Exception {
+ SchemaUpdate schemaUpdate = new SchemaUpdate(environment.get(Configuration.class));
+ schemaUpdate.execute(false, true);
+ return schemaUpdate.getExceptions();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpdateSchemaCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java (from rev 5748, jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/DbUpgrade.java)
===================================================================
--- jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java (rev 0)
+++ jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java 2009-10-18 08:03:52 UTC (rev 5753)
@@ -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.List;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class UpgradeTool {
+
+ private final ProcessEngine processEngine;
+
+ public UpgradeTool() {
+ processEngine = Configuration.getProcessEngine();
+ }
+
+ public UpgradeTool(String configResource) {
+ processEngine = new Configuration().setResource(configResource).buildProcessEngine();
+ }
+
+ public void upgrade() throws Exception {
+ // update database schema
+ List<Exception> exceptions = processEngine.execute(new UpdateSchemaCmd());
+ if (!exceptions.isEmpty())
+ throw exceptions.get(0);
+
+ // add property "langid" to each deployed process
+ processEngine.execute(new AddLangIdCmd());
+
+ // initialize database id generator
+ processEngine.execute(new InitDbidGeneratorCmd());
+ }
+
+ public static void main(String[] args) throws Exception {
+ UpgradeTool upgradeTool = args.length == 0 ? new UpgradeTool() : new UpgradeTool(args[0]);
+ upgradeTool.upgrade();
+ }
+}
Property changes on: jbpm4/trunk/modules/db/src/main/java/org/jbpm/db/internal/upgrade/UpgradeTool.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
16 years, 6 months