[jbpm-commits] JBoss JBPM SVN: r3694 - in jbpm3/trunk: hudson/hudson-home/jobs/jBPM3-Matrix and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jan 21 01:12:21 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-01-21 01:12:12 -0500 (Wed, 21 Jan 2009)
New Revision: 3694
Modified:
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/config.xml
jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/config.xml
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml
jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.sybase.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/perf/TasklistEagerLoadingTest.java
jbpm3/trunk/modules/core/src/test/resources/log4j.xml
jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml
jbpm3/trunk/pom.xml
Log:
JBPM-1369 merge r3688:r3693 from https://svn.jboss.org/repos/jbpm/jbpm3/branches/
Modified: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/config.xml
===================================================================
--- jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/config.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-Matrix/config.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -44,6 +44,7 @@
<values>
<string>hsqldb</string>
<string>mysql</string>
+ <string>postgresql</string>
<string>sybase</string>
</values>
</axis>
Modified: jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/config.xml
===================================================================
--- jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/config.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/hudson/hudson-home/jobs/jBPM3-ShortMatrix/config.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -38,6 +38,7 @@
<values>
<string>hsqldb</string>
<string>mysql</string>
+ <string>postgresql</string>
<string>sybase</string>
</values>
</axis>
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -23,7 +23,6 @@
// $Id$
-import java.util.Iterator;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -46,8 +45,7 @@
import org.jbpm.svc.Services;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public abstract class AbstractDbTestCase extends AbstractJbpmTestCase
-{
+public abstract class AbstractDbTestCase extends AbstractJbpmTestCase {
private static final Log log = LogFactory.getLog(AbstractDbTestCase.class);
protected JbpmConfiguration jbpmConfiguration;
@@ -64,164 +62,136 @@
protected JobExecutor jobExecutor;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
beginSessionTransaction();
}
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
commitAndCloseSession();
ensureCleanDatabase();
super.tearDown();
}
- private void ensureCleanDatabase()
- {
+ private void ensureCleanDatabase() {
boolean hasLeftOvers = false;
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)getJbpmConfiguration().getServiceFactory("persistence");
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) getJbpmConfiguration().getServiceFactory("persistence");
Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
JbpmSchema jbpmSchema = new JbpmSchema(configuration);
- Map jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
- for (Iterator iter = jbpmTablesRecordCount.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry)iter.next();
- String tableName = (String)entry.getKey();
- Integer count = (Integer)entry.getValue();
+ Map<String, Integer> jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
+ for (Map.Entry<String, Integer> entry : jbpmTablesRecordCount.entrySet()) {
+ // String tableName = entry.getKey();
+ Integer count = entry.getValue();
- if ((count == null) || (count != 0))
- {
+ if ((count == null) || (count != 0)) {
hasLeftOvers = true;
// [JBPM-1812] Fix tests that don't cleanup the database
- // Only uncomment this if you intnde to fix it. Otherwise it just generates noise.
- // System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left " + count + " records in " + tableName);
+ // Only uncomment this if you intend to fix it. Otherwise it just generates noise.
+ // System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left " + count
+ // + " records in " + tableName);
}
}
- if (hasLeftOvers)
- {
+ if (hasLeftOvers) {
// TODO: JBPM-1781
// jbpmSchema.cleanSchema();
}
}
- protected String getHibernateDialect()
- {
- DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory)jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ protected String getHibernateDialect() {
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
return factory.getConfiguration().getProperty(Environment.DIALECT);
}
- protected void beginSessionTransaction()
- {
+ protected void beginSessionTransaction() {
createJbpmContext();
initializeMembers();
}
- protected void commitAndCloseSession()
- {
+ protected void commitAndCloseSession() {
closeJbpmContext();
resetMembers();
}
- protected void newTransaction()
- {
+ protected void newTransaction() {
commitAndCloseSession();
beginSessionTransaction();
}
- protected ProcessInstance saveAndReload(ProcessInstance pi)
- {
+ protected ProcessInstance saveAndReload(ProcessInstance pi) {
jbpmContext.save(pi);
newTransaction();
return graphSession.loadProcessInstance(pi.getId());
}
- protected TaskInstance saveAndReload(TaskInstance taskInstance)
- {
+ protected TaskInstance saveAndReload(TaskInstance taskInstance) {
jbpmContext.save(taskInstance);
newTransaction();
- return (TaskInstance)session.load(TaskInstance.class, new Long(taskInstance.getId()));
+ return (TaskInstance) session.load(TaskInstance.class, new Long(taskInstance.getId()));
}
- protected ProcessDefinition saveAndReload(ProcessDefinition pd)
- {
+ protected ProcessDefinition saveAndReload(ProcessDefinition pd) {
graphSession.saveProcessDefinition(pd);
newTransaction();
return graphSession.loadProcessDefinition(pd.getId());
}
- protected ProcessLog saveAndReload(ProcessLog processLog)
- {
+ protected ProcessLog saveAndReload(ProcessLog processLog) {
loggingSession.saveProcessLog(processLog);
newTransaction();
return loggingSession.loadProcessLog(processLog.getId());
}
- protected void createSchema()
- {
+ protected void createSchema() {
getJbpmConfiguration().createSchema();
}
- protected void cleanSchema()
- {
+ protected void cleanSchema() {
getJbpmConfiguration().cleanSchema();
}
- protected void dropSchema()
- {
+ protected void dropSchema() {
getJbpmConfiguration().dropSchema();
}
- protected String getJbpmTestConfig()
- {
+ protected String getJbpmTestConfig() {
return "org/jbpm/db/jbpm.db.test.cfg.xml";
}
- protected JbpmConfiguration getJbpmConfiguration()
- {
- if (jbpmConfiguration == null)
- {
+ protected JbpmConfiguration getJbpmConfiguration() {
+ if (jbpmConfiguration == null) {
String jbpmTestConfiguration = getJbpmTestConfig();
jbpmConfiguration = JbpmConfiguration.getInstance(jbpmTestConfiguration);
}
return jbpmConfiguration;
}
- protected void createJbpmContext()
- {
+ protected void createJbpmContext() {
jbpmContext = getJbpmConfiguration().createJbpmContext();
}
- protected void closeJbpmContext()
- {
- if (jbpmContext != null)
- {
+ protected void closeJbpmContext() {
+ if (jbpmContext != null) {
jbpmContext.close();
jbpmContext = null;
}
}
- protected void startJobExecutor()
- {
+ protected void startJobExecutor() {
jobExecutor = getJbpmConfiguration().getJobExecutor();
jobExecutor.start();
}
- protected void waitForJobs(long timeout)
- {
+ protected void waitForJobs(long timeout) {
// install a timer that will interrupt if it takes too long
- // if that happens, it will lead to an interrupted exception and the test
- // will fail
- TimerTask interruptTask = new TimerTask()
- {
+ // if that happens, it will lead to an interrupted exception and the test will fail
+ TimerTask interruptTask = new TimerTask() {
Thread testThread = Thread.currentThread();
- public void run()
- {
+ public void run() {
log.debug("test " + getName() + " took too long. going to interrupt...");
testThread.interrupt();
}
@@ -229,100 +199,81 @@
Timer timer = new Timer();
timer.schedule(interruptTask, timeout);
- try
- {
- while (getNbrOfJobsAvailable() > 0)
- {
+ try {
+ while (getNbrOfJobsAvailable() > 0) {
log.debug("going to sleep for 200 millis, waiting for the job executor to process more jobs");
Thread.sleep(200);
}
}
- catch (InterruptedException e)
- {
+ catch (InterruptedException e) {
fail("test execution exceeded treshold of " + timeout + " milliseconds");
}
- finally
- {
+ finally {
timer.cancel();
}
}
- protected int getNbrOfJobsAvailable()
- {
- if (session != null)
- {
+ protected int getNbrOfJobsAvailable() {
+ if (session != null) {
return getNbrOfJobsAvailable(session);
}
- else
- {
+ else {
beginSessionTransaction();
- try
- {
+ try {
return getNbrOfJobsAvailable(session);
}
- finally
- {
+ finally {
commitAndCloseSession();
}
}
}
- private int getNbrOfJobsAvailable(Session session)
- {
+ private int getNbrOfJobsAvailable(Session session) {
int nbrOfJobsAvailable = 0;
- Number jobs = (Number)session.createQuery("select count(*) from org.jbpm.job.Job").uniqueResult();
+ Number jobs = (Number) session.createQuery("select count(*) from org.jbpm.job.Job")
+ .uniqueResult();
log.debug("there are " + jobs + " jobs in the database");
- if (jobs != null)
- {
+ if (jobs != null) {
nbrOfJobsAvailable = jobs.intValue();
}
return nbrOfJobsAvailable;
}
- protected int getTimerCount()
- {
- Number timerCount = (Number)session.createQuery("select count(*) from org.jbpm.job.Timer").uniqueResult();
+ protected int getTimerCount() {
+ Number timerCount = (Number) session.createQuery("select count(*) from org.jbpm.job.Timer")
+ .uniqueResult();
log.debug("there are " + timerCount + " timers in the database");
return timerCount.intValue();
}
- protected Job getJob()
- {
- return (Job)session.createQuery("from org.jbpm.job.Job").uniqueResult();
+ protected Job getJob() {
+ return (Job) session.createQuery("from org.jbpm.job.Job").uniqueResult();
}
- protected void processJobs(long maxWait)
- {
+ protected void processJobs(long maxWait) {
commitAndCloseSession();
startJobExecutor();
- try
- {
+ try {
waitForJobs(maxWait);
}
- finally
- {
+ finally {
stopJobExecutor();
beginSessionTransaction();
}
}
- protected void stopJobExecutor()
- {
- if (jobExecutor != null)
- {
- try
- {
+ protected void stopJobExecutor() {
+ if (jobExecutor != null) {
+ try {
jobExecutor.stopAndJoin();
}
- catch (InterruptedException e)
- {
+ catch (InterruptedException e) {
throw new RuntimeException("waiting for job executor to stop and join got interrupted", e);
}
}
}
- protected void initializeMembers()
- {
+ protected void initializeMembers() {
session = jbpmContext.getSession();
graphSession = jbpmContext.getGraphSession();
taskMgmtSession = jbpmContext.getTaskMgmtSession();
@@ -331,8 +282,7 @@
contextSession = jbpmContext.getContextSession();
}
- protected void resetMembers()
- {
+ protected void resetMembers() {
session = null;
graphSession = null;
taskMgmtSession = null;
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -67,8 +66,9 @@
ConnectionProvider connectionProvider = null;
Connection connection = null;
- Statement statement = null;
+ private Statement statement;
+
public JbpmSchema(Configuration configuration) {
this.configuration = configuration;
this.settings = configuration.buildSettings();
@@ -96,15 +96,16 @@
Mapping mapping = configuration.buildMapping();
// loop over all foreign key constraints
- List dropForeignKeysSql = new ArrayList();
- List createForeignKeysSql = new ArrayList();
- List deleteSql = new ArrayList();
+ List<String> dropForeignKeysSql = new ArrayList<String>();
+ List<String> createForeignKeysSql = new ArrayList<String>();
+ List<String> deleteSql = new ArrayList<String>();
- Iterator iter = configuration.getTableMappings();
+ Iterator<?> iter = configuration.getTableMappings();
while (iter.hasNext()) {
Table table = (Table) iter.next();
+
if (table.isPhysicalTable()) {
- Iterator subIter = table.getForeignKeyIterator();
+ Iterator<?> subIter = table.getForeignKeyIterator();
while (subIter.hasNext()) {
ForeignKey fk = (ForeignKey) subIter.next();
@@ -118,7 +119,7 @@
createForeignKeysSql.add(sqlCreateString);
}
}
- deleteSql.add("delete from " + table.getName());
+ deleteSql.add("DELETE FROM " + table.getName());
}
}
@@ -132,16 +133,16 @@
return cleanSql;
}
- private static String[] concat(List<String>... lists) {
+ private static String[] concat(List<?>... lists) {
int length = 0;
- for (List<String> list : lists) {
+ for (List<?> list : lists) {
length += list.size();
}
String[] array = new String[length];
- int i = 0;
- for (List<String> list : lists) {
- for (String element : list) {
- array[i++] = element;
+ int index = 0;
+ for (List<?> list : lists) {
+ for (Object element : list) {
+ array[index++] = (String) element;
}
}
return array;
@@ -151,12 +152,13 @@
return (getJbpmTables().size() > 0);
}
- public List getJbpmTables() {
+ public List<String> getJbpmTables() {
// delete all the data in the jbpm tables
- List jbpmTableNames = new ArrayList();
- Iterator iter = configuration.getTableMappings();
+ List<String> jbpmTableNames = new ArrayList<String>();
+ Iterator<?> iter = configuration.getTableMappings();
while (iter.hasNext()) {
Table table = (Table) iter.next();
+
if (table.isPhysicalTable()) {
jbpmTableNames.add(table.getName());
}
@@ -164,34 +166,31 @@
return jbpmTableNames;
}
- public Map getJbpmTablesRecordCount() {
- Map recordCounts = new HashMap();
-
- String sql = null;
-
+ public Map<String, Integer> getJbpmTablesRecordCount() {
+ Map<String, Integer> recordCounts = new HashMap<String, Integer>();
try {
- Iterator iter = getJbpmTables().iterator();
-
createConnection();
- while (iter.hasNext()) {
- statement = connection.createStatement();
- String tableName = (String) iter.next();
- sql = "SELECT COUNT(*) FROM " + tableName;
- ResultSet resultSet = statement.executeQuery(sql);
- resultSet.next();
- int count = resultSet.getInt(1);
- resultSet.close();
- statement.close();
- recordCounts.put(tableName, count);
+
+ statement = connection.createStatement();
+ for (String tableName : getJbpmTables()) {
+ String sql = "SELECT COUNT(*) FROM " + tableName;
+ try {
+ ResultSet resultSet = statement.executeQuery(sql);
+ resultSet.next();
+ recordCounts.put(tableName, resultSet.getInt(1));
+ resultSet.close();
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not execute sql '" + sql + "'", e);
+ }
}
}
catch (SQLException e) {
- throw new JbpmException("couldn't execute sql '" + sql + "'", e);
+ throw new JbpmException("database connection failed", e);
}
finally {
closeConnection();
}
-
return recordCounts;
}
@@ -204,7 +203,7 @@
}
public void cleanSchema() {
- if (getJbpmTables().size() > 0)
+ if (!getJbpmTables().isEmpty())
execute(getCleanSql());
}
@@ -260,8 +259,7 @@
System.err.println("JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
System.err.println("JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
System.err.println("JbpmSchema clean [<hibernate.cfg.xml> [<hibernate.properties>]]");
- System.err
- .println("JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
+ System.err.println("JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
}
static Configuration createConfiguration(String[] args, int index) {
@@ -285,43 +283,37 @@
return configuration;
}
- void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException {
- FileOutputStream fileOutputStream = new FileOutputStream(fileName);
+ void saveSqlScript(String fileName, String[] sql) throws IOException {
+ PrintStream out = new PrintStream(new FileOutputStream(fileName));
try {
- PrintStream printStream = new PrintStream(fileOutputStream);
- for (int i = 0; i < sql.length; i++) {
- printStream.println(sql[i] + getSqlDelimiter());
+ for (String line : sql) {
+ out.println(line + getSqlDelimiter());
}
}
finally {
- try {
- fileOutputStream.close();
- }
- catch (IOException e) {
- log.debug("failed to close file", e);
- }
+ out.close();
}
}
void execute(String[] sqls) {
- String sql = null;
boolean showSql = settings.isShowSqlEnabled();
-
try {
createConnection();
- statement = connection.createStatement();
- for (int i = 0; i < sqls.length; i++) {
- sql = sqls[i];
-
+ statement = connection.createStatement();
+ for (String sql : sqls) {
if (showSql)
log.debug(sql);
- statement.executeUpdate(sql);
+ try {
+ statement.executeUpdate(sql);
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not execute '" + sql + "'", e);
+ }
}
-
}
catch (SQLException e) {
- throw new JbpmException("couldn't execute sql '" + sql + "'", e);
+ throw new JbpmException("database connection failed", e);
}
finally {
closeConnection();
@@ -334,19 +326,20 @@
statement.close();
}
catch (SQLException e) {
- log.debug("could not close jdbc statement", e);
+ log.debug("could not close " + statement, e);
}
}
if (connection != null) {
try {
- JDBCExceptionReporter.logWarnings(connection.getWarnings());
- connection.clearWarnings();
+ JDBCExceptionReporter.logAndClearWarnings(connection);
connectionProvider.closeConnection(connection);
- connectionProvider.close();
}
catch (SQLException e) {
- log.debug("could not close jdbc connection", e);
+ log.debug("could not close " + connection, e);
}
+ finally {
+ connectionProvider.close();
+ }
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -40,7 +40,7 @@
protected String pooledActorsExpression = null;
protected Delegation assignmentDelegation = null;
protected TaskMgmtDefinition taskMgmtDefinition = null;
- protected Set tasks = null;
+ protected Set<Task> tasks = null;
public Swimlane() {
}
@@ -60,12 +60,12 @@
// tasks ////////////////////////////////////////////////////////////////////
public void addTask( Task task ) {
- if (tasks==null) tasks = new HashSet();
+ if (tasks==null) tasks = new HashSet<Task>();
tasks.add(task);
task.setSwimlane(this);
}
- public Set getTasks() {
+ public Set<Task> getTasks() {
return tasks;
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -22,7 +22,6 @@
package org.jbpm.taskmgmt.def;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -33,10 +32,8 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.instantiation.Delegation;
-import org.jbpm.instantiation.ProcessClassLoaderFactory;
import org.jbpm.instantiation.UserCodeInterceptorConfig;
import org.jbpm.taskmgmt.exe.TaskInstance;
-import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.EqualsUtil;
/**
@@ -62,7 +59,7 @@
/**
* maps process variable names (java.lang.String) to VariableAccess objects.
*/
- List variableAccesses = null;
+ List<VariableAccess> variableAccesses = null;
public TaskController() {
}
@@ -96,9 +93,7 @@
ContextInstance contextInstance = processInstance.getContextInstance();
if (variableAccesses != null) {
- Iterator iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
+ for (VariableAccess variableAccess : variableAccesses) {
String mappedName = variableAccess.getMappedName();
if (variableAccess.isReadable()) {
String variableName = variableAccess.getVariableName();
@@ -146,9 +141,7 @@
if (variableAccesses != null) {
String missingTaskVariables = null;
- Iterator iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
+ for (VariableAccess variableAccess : variableAccesses) {
String mappedName = variableAccess.getMappedName();
// first check if the required variableInstances are present
if ((variableAccess.isRequired()) && (!taskInstance.hasVariableLocally(mappedName))) {
@@ -166,9 +159,7 @@
throw new IllegalArgumentException("missing task variables: " + missingTaskVariables);
}
- iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
+ for (VariableAccess variableAccess : variableAccesses) {
String mappedName = variableAccess.getMappedName();
String variableName = variableAccess.getVariableName();
if (variableAccess.isWritable()) {
@@ -195,7 +186,7 @@
// getters and setters //////////////////////////////////////////////////////
- public List getVariableAccesses() {
+ public List<VariableAccess> getVariableAccesses() {
return variableAccesses;
}
public Delegation getTaskControllerDelegation() {
@@ -208,7 +199,7 @@
return id;
}
- public void setVariableAccesses(List variableAccesses) {
+ public void setVariableAccesses(List<VariableAccess> variableAccesses) {
this.variableAccesses = variableAccesses;
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -42,5 +42,5 @@
* Use this method to offer the task to a group of users. Each user in the group
* can then take the task by calling the {@link #setActorId(String)}.
*/
- public void setPooledActors(String[] pooledActors);
+ public void setPooledActors(String... pooledActors);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -23,7 +23,6 @@
import java.io.Serializable;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.jbpm.util.EqualsUtil;
@@ -35,7 +34,7 @@
long id = 0;
int version = 0;
protected String actorId = null;
- protected Set taskInstances = null;
+ protected Set<TaskInstance> taskInstances = null;
protected SwimlaneInstance swimlaneInstance = null;
public static Set<PooledActor> createPool(String[] actorIds, SwimlaneInstance swimlaneInstance, TaskInstance taskInstance) {
@@ -53,13 +52,11 @@
return pooledActors;
}
- public static Set extractActorIds(Set poooledActors) {
- Set extractedActorIds = null;
- if (poooledActors!=null) {
- extractedActorIds = new HashSet();
- Iterator iter = poooledActors.iterator();
- while (iter.hasNext()) {
- PooledActor pooledActor = (PooledActor) iter.next();
+ public static Set<String> extractActorIds(Set<PooledActor> pooledActors) {
+ Set<String> extractedActorIds = null;
+ if (pooledActors!=null) {
+ extractedActorIds = new HashSet<String>();
+ for (PooledActor pooledActor : pooledActors) {
extractedActorIds.add(pooledActor.getActorId());
}
}
@@ -74,10 +71,10 @@
}
public void addTaskInstance(TaskInstance taskInstance) {
- if (taskInstances==null) taskInstances = new HashSet();
+ if (taskInstances==null) taskInstances = new HashSet<TaskInstance>();
taskInstances.add(taskInstance);
}
- public Set getTaskInstances() {
+ public Set<TaskInstance> getTaskInstances() {
return taskInstances;
}
public void removeTaskInstance(TaskInstance taskInstance) {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -21,10 +21,10 @@
*/
package org.jbpm.taskmgmt.exe;
-import java.io.*;
+import java.io.Serializable;
import java.util.Set;
-import org.jbpm.taskmgmt.def.*;
+import org.jbpm.taskmgmt.def.Swimlane;
import org.jbpm.util.EqualsUtil;
/**
@@ -50,7 +50,7 @@
this.swimlane = swimlane;
}
- public void setPooledActors(String[] actorIds) {
+ public void setPooledActors(String... actorIds) {
this.pooledActors = PooledActor.createPool(actorIds, this, null);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -52,11 +51,10 @@
import org.jbpm.util.EqualsUtil;
/**
- * is one task instance that can be assigned to an actor (read: put in someones task list) and that can trigger the
- * coninuation of execution of the token upon completion.
+ * is one task instance that can be assigned to an actor (read: put in someones task list) and that
+ * can trigger the coninuation of execution of the token upon completion.
*/
-public class TaskInstance extends VariableContainer implements Identifiable, Assignable
-{
+public class TaskInstance extends VariableContainer implements Identifiable, Assignable {
private static final long serialVersionUID = 1L;
@@ -81,27 +79,24 @@
protected TaskMgmtInstance taskMgmtInstance = null;
protected ProcessInstance processInstance = null;
protected Set<PooledActor> pooledActors = null;
- protected List comments = null;
+ protected List<Comment> comments = null;
- protected String previousActorId = null; // not persisted. just extra information for listeners of the assign-event
+ protected String previousActorId = null; // not persisted. just extra information for listeners of
+ // the assign-event
- public TaskInstance()
- {
+ public TaskInstance() {
}
- public TaskInstance(String taskName)
- {
+ public TaskInstance(String taskName) {
this.name = taskName;
}
- public TaskInstance(String taskName, String actorId)
- {
+ public TaskInstance(String taskName, String actorId) {
this.name = taskName;
this.actorId = actorId;
}
- public void setTask(Task task)
- {
+ public void setTask(Task task) {
this.name = task.getName();
this.description = task.getDescription();
this.task = task;
@@ -110,60 +105,52 @@
this.isSignalling = task.isSignalling();
}
- void submitVariables()
- {
+ void submitVariables() {
TaskController taskController = (task != null ? task.getTaskController() : null);
// if there is a task controller,
- if (taskController != null)
- {
+ if (taskController != null) {
// the task controller is responsible for copying variables back into the process
taskController.submitParameters(this);
// if there is no task controller
}
- else if ((token != null) && (token.getProcessInstance() != null))
- {
+ else if ((token != null) && (token.getProcessInstance() != null)) {
// the default behaviour is that all task-local variables are flushed to the process
- if (variableInstances != null)
- {
+ if (variableInstances != null) {
ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
- Iterator iter = variableInstances.values().iterator();
- while (iter.hasNext())
- {
- VariableInstance variableInstance = (VariableInstance)iter.next();
- log.debug("flushing variable '" + variableInstance.getName() + "' from task '" + name + "' to process variables");
- // This might be optimized, but this was the simplest way to make a clone of the variable instance.
+ for (VariableInstance variableInstance : variableInstances.values()) {
+ log.debug("flushing variable '"
+ + variableInstance.getName()
+ + "' from task '"
+ + name
+ + "' to process variables");
+ // This might be optimized, but this was the simplest way to make a clone of the variable
+ // instance.
contextInstance.setVariable(variableInstance.getName(), variableInstance.getValue(), token);
}
}
}
}
- void initializeVariables()
- {
+ void initializeVariables() {
TaskController taskController = (task != null ? task.getTaskController() : null);
- if (taskController != null)
- {
+ if (taskController != null) {
taskController.initializeVariables(this);
}
}
- public void create()
- {
+ public void create() {
create(null);
}
- public void create(ExecutionContext executionContext)
- {
- if (create != null)
- {
+ public void create(ExecutionContext executionContext) {
+ if (create != null) {
throw new IllegalStateException("task instance '" + id + "' was already created");
}
create = Clock.getCurrentTime();
// if this task instance is associated with a task...
- if ((task != null) && (executionContext != null))
- {
+ if ((task != null) && (executionContext != null)) {
// the TASK_CREATE event is fired
executionContext.setTaskInstance(this);
executionContext.setTask(task);
@@ -175,18 +162,15 @@
// See also: TaskMgmtInstance.createTaskInstance
}
- public void assign(ExecutionContext executionContext)
- {
+ public void assign(ExecutionContext executionContext) {
TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
Swimlane swimlane = task.getSwimlane();
// if this task is in a swimlane
- if (swimlane != null)
- {
+ if (swimlane != null) {
// if this is a task assignment for a start-state
- if (isStartTaskInstance())
- {
+ if (isStartTaskInstance()) {
// initialize the swimlane
swimlaneInstance = new SwimlaneInstance(swimlane);
taskMgmtInstance.addSwimlaneInstance(swimlaneInstance);
@@ -194,8 +178,7 @@
swimlaneInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
}
- else
- {
+ else {
// lazy initialize the swimlane...
// get the swimlane instance (if there is any)
@@ -206,32 +189,25 @@
}
}
- else
- { // this task is not in a swimlane
+ else { // this task is not in a swimlane
taskMgmtInstance.performAssignment(task.getAssignmentDelegation(), task.getActorIdExpression(), task.getPooledActorsExpression(), this, executionContext);
}
updatePooledActorsReferences(swimlaneInstance);
}
- public boolean isStartTaskInstance()
- {
+ public boolean isStartTaskInstance() {
boolean isStartTaskInstance = false;
- if ((taskMgmtInstance != null) && (taskMgmtInstance.getTaskMgmtDefinition() != null))
- {
- isStartTaskInstance = ((task != null) && (task.equals(taskMgmtInstance.getTaskMgmtDefinition().getStartTask())));
+ if ((taskMgmtInstance != null) && (taskMgmtInstance.getTaskMgmtDefinition() != null)) {
+ isStartTaskInstance = ((task != null) && (task.equals(taskMgmtInstance.getTaskMgmtDefinition()
+ .getStartTask())));
}
return isStartTaskInstance;
}
- void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance)
- {
- if (pooledActors != null)
- {
- Iterator iter = pooledActors.iterator();
- while (iter.hasNext())
- {
- PooledActor pooledActor = (PooledActor)iter.next();
+ void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance) {
+ if (pooledActors != null) {
+ for (PooledActor pooledActor : pooledActors) {
pooledActor.setSwimlaneInstance(swimlaneInstance);
pooledActor.addTaskInstance(this);
}
@@ -239,35 +215,31 @@
}
/**
- * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of the given swimlane
- * into this taskInstance.
+ * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of
+ * the given swimlane into this taskInstance.
*/
- public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance)
- {
+ public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance) {
setSwimlaneInstance(swimlaneInstance);
setActorId(swimlaneInstance.getActorId());
setPooledActors(swimlaneInstance.getPooledActors());
}
/**
- * gets the pool of actors for this task instance. If this task has a simlaneInstance and no pooled actors, the pooled
- * actors of the swimlane instance are returned.
+ * gets the pool of actors for this task instance. If this task has a simlaneInstance and no
+ * pooled actors, the pooled actors of the swimlane instance are returned.
*/
- public Set<PooledActor> getPooledActors()
- {
- if ((swimlaneInstance != null) && ((pooledActors == null) || (pooledActors.isEmpty())))
- {
+ public Set<PooledActor> getPooledActors() {
+ if ((swimlaneInstance != null) && ((pooledActors == null) || (pooledActors.isEmpty()))) {
return swimlaneInstance.getPooledActors();
}
return pooledActors;
}
/**
- * (re)assign this task to the given actor. If this task is related to a swimlane instance, that swimlane instance
- * will be updated as well.
+ * (re)assign this task to the given actor. If this task is related to a swimlane instance, that
+ * swimlane instance will be updated as well.
*/
- public void setActorId(String actorId)
- {
+ public void setActorId(String actorId) {
setActorId(actorId, true);
}
@@ -275,22 +247,20 @@
* (re)assign this task to the given actor.
*
* @param actorId is reference to the person that is assigned to this task.
- * @param overwriteSwimlane specifies if the related swimlane should be overwritten with the given swimlaneActorId.
+ * @param overwriteSwimlane specifies if the related swimlane should be overwritten with the given
+ * swimlaneActorId.
*/
- public void setActorId(String actorId, boolean overwriteSwimlane)
- {
+ public void setActorId(String actorId, boolean overwriteSwimlane) {
// do the actual assignment
this.previousActorId = this.actorId;
this.actorId = actorId;
- if ((swimlaneInstance != null) && (overwriteSwimlane))
- {
+ if ((swimlaneInstance != null) && (overwriteSwimlane)) {
log.debug("assigning task '" + name + "' to '" + actorId + "'");
swimlaneInstance.setActorId(actorId);
}
// fire the event
- if ((task != null) && (token != null))
- {
+ if ((task != null) && (token != null)) {
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTask(task);
executionContext.setTaskInstance(this);
@@ -302,32 +272,27 @@
}
// add the log
- if (token != null)
- {
+ if (token != null) {
// log this assignment
token.addLog(new TaskAssignLog(this, previousActorId, actorId));
}
}
/** takes a set of String's as the actorIds */
- public void setPooledActors(String[] actorIds)
- {
+ public void setPooledActors(String... actorIds) {
this.pooledActors = PooledActor.createPool(actorIds, null, this);
}
/**
* can optionally be used to indicate that the actor is starting to work on this task instance.
*/
- public void start()
- {
- if (start != null)
- {
+ public void start() {
+ if (start != null) {
throw new IllegalStateException("task instance '" + id + "' is already started");
}
start = Clock.getCurrentTime();
- if ((task != null) && (token != null))
- {
+ if ((task != null) && (token != null)) {
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTask(task);
executionContext.setTaskInstance(this);
@@ -338,16 +303,14 @@
/**
* convenience method that combines a {@link #setActorId(String)} and a {@link #start()}.
*/
- public void start(String actorId)
- {
+ public void start(String actorId) {
start(actorId, true);
}
/**
* convenience method that combines a {@link #setActorId(String,boolean)} and a {@link #start()}.
*/
- public void start(String actorId, boolean overwriteSwimlane)
- {
+ public void start(String actorId, boolean overwriteSwimlane) {
setActorId(actorId, overwriteSwimlane);
start();
}
@@ -355,101 +318,90 @@
/**
* overwrite start date
*/
- public void setStart(Date date)
- {
+ public void setStart(Date date) {
start = null;
}
- private void markAsCancelled()
- {
+ private void markAsCancelled() {
this.isCancelled = true;
this.isOpen = false;
}
/**
- * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation doesn't influence
- * singalling and continuation of process execution.
+ * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation
+ * doesn't influence singalling and continuation of process execution.
*/
- public void cancel()
- {
+ public void cancel() {
markAsCancelled();
end();
}
/**
- * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
- * cancellation doesn't influence singalling and continuation of process execution.
+ * cancels this task, takes the specified transition. This task intance will be marked as
+ * cancelled and as ended. But cancellation doesn't influence singalling and continuation of
+ * process execution.
*/
- public void cancel(Transition transition)
- {
+ public void cancel(Transition transition) {
markAsCancelled();
end(transition);
}
/**
- * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
- * cancellation doesn't influence singalling and continuation of process execution.
+ * cancels this task, takes the specified transition. This task intance will be marked as
+ * cancelled and as ended. But cancellation doesn't influence singalling and continuation of
+ * process execution.
*/
- public void cancel(String transitionName)
- {
+ public void cancel(String transitionName) {
markAsCancelled();
end(transitionName);
}
/**
- * marks this task as done. If this task is related to a task node this might trigger a signal on the token.
+ * marks this task as done. If this task is related to a task node this might trigger a signal on
+ * the token.
*
* @see #end(Transition)
*/
- public void end()
- {
- end((Transition)null);
+ public void end() {
+ end((Transition) null);
}
/**
- * marks this task as done and specifies the name of a transition leaving the task-node for the case that the
- * completion of this task instances triggers a signal on the token. If this task leads to a signal on the token, the
- * given transition name will be used in the signal. If this task completion does not trigger execution to move on,
- * the transitionName is ignored.
+ * marks this task as done and specifies the name of a transition leaving the task-node for the
+ * case that the completion of this task instances triggers a signal on the token. If this task
+ * leads to a signal on the token, the given transition name will be used in the signal. If this
+ * task completion does not trigger execution to move on, the transitionName is ignored.
*/
- public void end(String transitionName)
- {
+ public void end(String transitionName) {
Transition leavingTransition = null;
- if (task != null)
- {
+ if (task != null) {
Node node = task.getTaskNode();
- if (node == null)
- {
- node = (Node)task.getParent();
+ if (node == null) {
+ node = (Node) task.getParent();
}
- if (node != null)
- {
+ if (node != null) {
leavingTransition = node.getLeavingTransition(transitionName);
}
}
- if (leavingTransition == null)
- {
+ if (leavingTransition == null) {
throw new JbpmException("task node does not have leaving transition '" + transitionName + "'");
}
end(leavingTransition);
}
/**
- * marks this task as done and specifies a transition leaving the task-node for the case that the completion of this
- * task instances triggers a signal on the token. If this task leads to a signal on the token, the given transition
- * name will be used in the signal. If this task completion does not trigger execution to move on, the transition is
- * ignored.
+ * marks this task as done and specifies a transition leaving the task-node for the case that the
+ * completion of this task instances triggers a signal on the token. If this task leads to a
+ * signal on the token, the given transition name will be used in the signal. If this task
+ * completion does not trigger execution to move on, the transition is ignored.
*/
- public void end(Transition transition)
- {
- if (this.end != null)
- {
+ public void end(Transition transition) {
+ if (this.end != null) {
throw new IllegalStateException("task instance '" + id + "' is already ended");
}
- if (this.isSuspended)
- {
+ if (this.isSuspended) {
throw new JbpmException("task instance '" + id + "' is suspended");
}
@@ -458,8 +410,7 @@
this.isOpen = false;
// fire the task instance end event
- if ((task != null) && (token != null))
- {
+ if ((task != null) && (token != null)) {
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTask(task);
executionContext.setTaskInstance(this);
@@ -467,8 +418,7 @@
}
// log this assignment
- if (token != null)
- {
+ if (token != null) {
token.addLog(new TaskEndLog(this));
}
@@ -476,40 +426,39 @@
submitVariables();
// verify if the end of this task triggers continuation of execution
- if (isSignalling)
- {
+ if (isSignalling) {
this.isSignalling = false;
if (this.isStartTaskInstance() // ending start tasks always leads to a signal
- || ((task != null) && (token != null) && (task.getTaskNode() != null) && (task.getTaskNode().completionTriggersSignal(this))))
- {
+ || ((task != null) && (token != null) && (task.getTaskNode() != null) && (task.getTaskNode().completionTriggersSignal(this)))) {
- if (transition == null)
- {
- log.debug("completion of task '" + task.getName() + "' results in taking the default transition");
+ if (transition == null) {
+ log.debug("completion of task '"
+ + task.getName()
+ + "' results in taking the default transition");
token.signal();
}
- else
- {
- log.debug("completion of task '" + task.getName() + "' results in taking transition '" + transition + "'");
+ else {
+ log.debug("completion of task '"
+ + task.getName()
+ + "' results in taking transition '"
+ + transition
+ + "'");
token.signal(transition);
}
}
}
}
- public boolean hasEnded()
- {
+ public boolean hasEnded() {
return (end != null);
}
/**
* suspends a process execution.
*/
- public void suspend()
- {
- if (!isOpen)
- {
+ public void suspend() {
+ if (!isOpen) {
throw new JbpmException("a task that is not open cannot be suspended: " + toString());
}
isSuspended = true;
@@ -518,10 +467,8 @@
/**
* resumes a process execution.
*/
- public void resume()
- {
- if (!isOpen)
- {
+ public void resume() {
+ if (!isOpen) {
throw new JbpmException("a task that is not open cannot be resumed: " + toString());
}
isSuspended = false;
@@ -529,49 +476,40 @@
// comments /////////////////////////////////////////////////////////////////
- public void addComment(String message)
- {
+ public void addComment(String message) {
addComment(new Comment(message));
}
- public void addComment(Comment comment)
- {
- if (comment != null)
- {
- if (comments == null)
- comments = new ArrayList();
+ public void addComment(Comment comment) {
+ if (comment != null) {
+ if (comments == null) comments = new ArrayList<Comment>();
comments.add(comment);
comment.setTaskInstance(this);
- if (token != null)
- {
+ if (token != null) {
comment.setToken(token);
token.addComment(comment);
}
}
}
- public List getComments()
- {
+ public List<Comment> getComments() {
return comments;
}
// task form ////////////////////////////////////////////////////////////////
- public boolean isLast()
- {
+ public boolean isLast() {
return ((token != null) && (taskMgmtInstance != null) && (!taskMgmtInstance.hasUnfinishedTasks(token)));
}
/**
- * is the list of transitions that can be used in the end method and it is null in case this is not the last task
- * instance.
+ * is the list of transitions that can be used in the end method and it is null in case this is
+ * not the last task instance.
*/
- public List getAvailableTransitions()
- {
- List transitions = null;
- if ((!isLast()) && (token != null))
- {
- transitions = new ArrayList(token.getAvailableTransitions());
+ public List<Transition> getAvailableTransitions() {
+ List<Transition> transitions = null;
+ if ((!isLast()) && (token != null)) {
+ transitions = new ArrayList<Transition>(token.getAvailableTransitions());
}
return transitions;
}
@@ -579,209 +517,168 @@
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
- public boolean equals(Object o)
- {
+ public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
- public String toString()
- {
- return "TaskInstance" + (name != null ? "(" + name + ")" : "@" + Integer.toHexString(hashCode()));
+ public String toString() {
+ return "TaskInstance"
+ + (name != null ? "(" + name + ")" : "@" + Integer.toHexString(hashCode()));
}
// private //////////////////////////////////////////////////////////////////
/** takes a set of {@link PooledActor}s */
- public void setPooledActors(Set pooledActors)
- {
- if (pooledActors != null)
- {
- this.pooledActors = new HashSet(pooledActors);
- Iterator iter = pooledActors.iterator();
- while (iter.hasNext())
- {
- PooledActor pooledActor = (PooledActor)iter.next();
+ public void setPooledActors(Set<PooledActor> pooledActors) {
+ if (pooledActors != null) {
+ this.pooledActors = new HashSet<PooledActor>(pooledActors);
+ for (PooledActor pooledActor : pooledActors) {
pooledActor.addTaskInstance(this);
}
}
- else
- {
+ else {
this.pooledActors = null;
}
}
// protected ////////////////////////////////////////////////////////////////
- protected VariableContainer getParentVariableContainer()
- {
+ protected VariableContainer getParentVariableContainer() {
ContextInstance contextInstance = getContextInstance();
return (contextInstance != null ? contextInstance.getOrCreateTokenVariableMap(token) : null);
}
// getters and setters //////////////////////////////////////////////////////
- public String getActorId()
- {
+ public String getActorId() {
return actorId;
}
- public Date getDueDate()
- {
+ public Date getDueDate() {
return dueDate;
}
- public void setDueDate(Date dueDate)
- {
+ public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
- public Date getEnd()
- {
+ public Date getEnd() {
return end;
}
- public void setEnd(Date end)
- {
+ public void setEnd(Date end) {
this.end = end;
}
- public void setCreate(Date create)
- {
+ public void setCreate(Date create) {
this.create = create;
}
- public long getId()
- {
+ public long getId() {
return id;
}
- public void setId(long id)
- {
+ public void setId(long id) {
this.id = id;
}
- public Date getStart()
- {
+ public Date getStart() {
return start;
}
- public TaskMgmtInstance getTaskMgmtInstance()
- {
+ public TaskMgmtInstance getTaskMgmtInstance() {
return taskMgmtInstance;
}
- public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance)
- {
+ public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance) {
this.taskMgmtInstance = taskMgmtInstance;
}
- public Token getToken()
- {
+ public Token getToken() {
return token;
}
- public void setToken(Token token)
- {
+ public void setToken(Token token) {
this.token = token;
}
- public void setSignalling(boolean isSignalling)
- {
+ public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
- public boolean isSignalling()
- {
+ public boolean isSignalling() {
return isSignalling;
}
- public boolean isCancelled()
- {
+ public boolean isCancelled() {
return isCancelled;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
- public boolean isBlocking()
- {
+ public boolean isBlocking() {
return isBlocking;
}
- public void setBlocking(boolean isBlocking)
- {
+ public void setBlocking(boolean isBlocking) {
this.isBlocking = isBlocking;
}
- public Date getCreate()
- {
+ public Date getCreate() {
return create;
}
- public Task getTask()
- {
+ public Task getTask() {
return task;
}
- public SwimlaneInstance getSwimlaneInstance()
- {
+ public SwimlaneInstance getSwimlaneInstance() {
return swimlaneInstance;
}
- public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance)
- {
+ public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance) {
this.swimlaneInstance = swimlaneInstance;
}
- public String getPreviousActorId()
- {
+ public String getPreviousActorId() {
return previousActorId;
}
- public int getPriority()
- {
+ public int getPriority() {
return priority;
}
- public void setPriority(int priority)
- {
+ public void setPriority(int priority) {
this.priority = priority;
}
- public boolean isOpen()
- {
+ public boolean isOpen() {
return isOpen;
}
- public String getDescription()
- {
+ public String getDescription() {
return description;
}
- public void setDescription(String description)
- {
+ public void setDescription(String description) {
this.description = description;
}
- public boolean isSuspended()
- {
+ public boolean isSuspended() {
return isSuspended;
}
- public ProcessInstance getProcessInstance()
- {
+ public ProcessInstance getProcessInstance() {
return processInstance;
}
- public void setProcessInstance(ProcessInstance processInstance)
- {
+ public void setProcessInstance(ProcessInstance processInstance) {
this.processInstance = processInstance;
}
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.common.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -18,9 +18,9 @@
<!-- ################################### -->
<!-- Automatic schema creation (begin) -->
- <property name="hibernate.hbm2ddl.auto">create</property>
+ <property name="hibernate.hbm2ddl.auto">update</property>
<!-- Automatic schema creation (end) -->
-
+
<!-- Simple memory-only cache -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.postgresql.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -1,4 +1,11 @@
+ <!--
+ System Service QA Database PostgreSQL
+ https://wiki.corp.jboss.com/bin/view/IT/SystemServiceQaDatabasePostgresql
+ Install PostgreSQL on Fedora
+ http://www.jboss.org/community/docs/DOC-13270
+ -->
+
<!-- hibernate dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
Modified: jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.sybase.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.sybase.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/main/resources/hibernate.properties.sybase.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -1,12 +1,12 @@
<!--
- Out-of-the-box compatibility with Sybase
- https://jira.jboss.org/jira/browse/JBPM-700
-
System Service QA Database Sybase
https://wiki.corp.jboss.com/bin/view/IT/SystemServiceQaDatabaseSybase
-
- Install Sybase ASE 15.0.2 on Fedora9
+
+ Install Sybase ASE 15.0.2 on Fedora
https://www.jboss.org/community/docs/DOC-12932
+
+ jBPM 3.3 on Sybase ASE 15
+ http://www.jboss.org/community/docs/DOC-12936
-->
<!-- hibernate dialect -->
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -4,55 +4,62 @@
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
/**
- * Potential nullpointer in asynchronous jobs when process ends
- *
+ * Potential null pointer in asynchronous jobs when process ends
* https://jira.jboss.org/jira/browse/JBPM-1798
*
* @author Thomas.Diesler at jboss.com
*/
-public class JBPM1798Test extends AbstractDbTestCase
-{
- public void testJobExecution()
- {
- if (true)
- {
- System.out.println("FIXME: [JBPM-1798] Potential nullpointer in asynchronous jobs when process ends");
- return;
- }
-
+public class JBPM1798Test extends AbstractDbTestCase {
+
+ private static final long maxWaitTime = 10 * 1000;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ getJbpmConfiguration().getJobExecutor().setNbrOfThreads(2);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
+ super.tearDown();
+ }
+
+ public void testJobExecution() {
ProcessDefinition pd = getProcessDefinition();
jbpmContext.deployProcessDefinition(pd);
-
- pd.createProcessInstance();
-
newTransaction();
-
- startJobExecutor();
+ try {
+ pd.createProcessInstance();
+ newTransaction();
+ assertEquals(2, getNbrOfJobsAvailable());
+ processJobs(maxWaitTime);
+ }
+ finally {
+ graphSession.deleteProcessDefinition(pd.getId());
+ }
}
- private ProcessDefinition getProcessDefinition()
- {
- ProcessDefinition pd = ProcessDefinition.parseXmlString(
- "<process-definition name='customjobexecution' initial='start'>" +
- " <node name='start'>" +
- " <transition to='end'>" +
- " <action async='true' class='" + AsyncAction.class.getName() + "' />" +
- " </transition>" +
- " </node>" +
- " <end-state name='end' />" +
- "</process-definition>");
+ private ProcessDefinition getProcessDefinition() {
+ ProcessDefinition pd = ProcessDefinition.parseXmlString("<process-definition name='customjobexecution' initial='start'>"
+ + " <node name='start'>"
+ + " <transition to='end'>"
+ + " <action async='true' class='"
+ + AsyncAction.class.getName()
+ + "' />"
+ + " </transition>"
+ + " </node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
return pd;
}
- public static class AsyncAction implements ActionHandler
- {
+ public static class AsyncAction implements ActionHandler {
private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception
- {
+ public void execute(ExecutionContext executionContext) throws Exception {
System.out.println("do stuff");
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/perf/TasklistEagerLoadingTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/perf/TasklistEagerLoadingTest.java 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/perf/TasklistEagerLoadingTest.java 2009-01-21 06:12:12 UTC (rev 3694)
@@ -1,6 +1,7 @@
package org.jbpm.perf;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.jbpm.db.AbstractDbTestCase;
@@ -8,32 +9,52 @@
public class TasklistEagerLoadingTest extends AbstractDbTestCase {
+ private List<Long> taskInstanceIds = new ArrayList<Long>();
+
public void testTasklistEagerLoading() {
- for (int i=0; i<20; i++) {
- TaskInstance taskInstance = new TaskInstance("task "+i);
+ for (int i = 0; i < 20; i++) {
+ TaskInstance taskInstance = new TaskInstance("task " + i);
taskInstance.setActorId("johndoe");
- session.save(taskInstance);
+ save(taskInstance);
}
newTransaction();
-
- assertEquals(20, jbpmContext.getTaskList("johndoe").size());
+ try {
+ assertEquals(20, jbpmContext.getTaskList("johndoe").size());
+ }
+ finally {
+ deleteTaskInstances();
+ }
}
public void testPooledTasklistEagerLoading() {
- for (int i=0; i<20; i++) {
- TaskInstance taskInstance = new TaskInstance("group task "+i);
- taskInstance.setPooledActors(new String[]{"group"+i});
- session.save(taskInstance);
+ for (int i = 0; i < 20; i++) {
+ TaskInstance taskInstance = new TaskInstance("group task " + i);
+ taskInstance.setPooledActors(new String[] { "group" + i });
+ save(taskInstance);
}
- for (int i=0; i<20; i++) {
- TaskInstance taskInstance = new TaskInstance("task "+i);
- taskInstance.setPooledActors(new String[]{"johndoe", "bachelors", "partyanimals", "wildwomen"});
- session.save(taskInstance);
+ for (int i = 0; i < 20; i++) {
+ TaskInstance taskInstance = new TaskInstance("task " + i);
+ taskInstance.setPooledActors(new String[] { "johndoe", "bachelors", "partyanimals",
+ "wildwomen" });
+ save(taskInstance);
}
newTransaction();
-
- List actorIds = new ArrayList();
- actorIds.add("johndoe");
- assertEquals(20, jbpmContext.getGroupTaskList(actorIds).size());
+ try {
+ assertEquals(20, jbpmContext.getGroupTaskList(Collections.singletonList("johndoe")).size());
+ }
+ finally {
+ deleteTaskInstances();
+ }
}
+
+ private void save(TaskInstance taskInstance) {
+ session.save(taskInstance);
+ taskInstanceIds.add(taskInstance.getId());
+ }
+
+ private void deleteTaskInstances() {
+ for (Long id : taskInstanceIds) {
+ session.delete(session.load(TaskInstance.class, id));
+ }
+ }
}
Modified: jbpm3/trunk/modules/core/src/test/resources/log4j.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/log4j.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/core/src/test/resources/log4j.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -38,9 +38,14 @@
<category name="org.hibernate.SQL">
<priority value="DEBUG" />
</category>
- <category name="org.hibernate.connection">
+ <!--
+ <category name="org.hibernate.type">
<priority value="TRACE" />
</category>
+ -->
+ <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
+ <priority value="ERROR" />
+ </category>
<!-- ======================= -->
<!-- Setup the Root category -->
Modified: jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml
===================================================================
--- jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/modules/distribution/src/main/resources/installer/user-input-spec.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -20,7 +20,7 @@
<spec>
<choice txt="Hypersonic" value="hsqldb"/>
<choice txt="MySQL" value="mysql" set="true"/>
- <!-- choice txt="PostgreSQL" value="postgresql"/-->
+ <choice txt="PostgreSQL" value="postgresql"/>
<choice txt="Sybase" value="sybase"/>
</spec>
</field>
Modified: jbpm3/trunk/pom.xml
===================================================================
--- jbpm3/trunk/pom.xml 2009-01-21 05:11:44 UTC (rev 3693)
+++ jbpm3/trunk/pom.xml 2009-01-21 06:12:12 UTC (rev 3694)
@@ -541,7 +541,7 @@
<!--
Name: postgresql
- Descr: MySQL Database Setup
+ Descr: PostgreSQL Database Setup
-->
<profile>
<id>postgresql</id>
More information about the jbpm-commits
mailing list