[jbpm-commits] JBoss JBPM SVN: r4706 - in jbpm3/branches/jbpm-3.2.5.SP: hudson and 71 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon May 4 05:33:29 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-05-04 05:33:28 -0400 (Mon, 04 May 2009)
New Revision: 4706
Added:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/Semaphore.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ArchiveDeployer.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestHelper.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestSetup.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/JBossArchiveDeployer.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ObjectNameFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/resources/jboss405-dependencies.txt
Removed:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/CollectionUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/StaticUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/db/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.classpath
Modified:
jbpm3/branches/jbpm-3.2.5.SP/hudson/ant.properties.example
jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/command.sh
jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/config.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/core/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/core/pom.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/AntHelper.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/ShutDownHsqldb.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CompositeCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeTokenCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SignalCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendTokenCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/impl/CommandServiceImpl.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Node.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/EndState.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Fork.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Join.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/StartState.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/State.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/TaskNode.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/Timer.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationServiceFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/TokenVariableMapDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableInstanceDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableQueryDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/TaskMgmtSessionDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1778/JBPM1778Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/xml/AbstractXmlTestCase.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/TaskWithVariablesTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/SwimlaneDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/TaskMgmtDefinitionDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskMgmtInstanceDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/log/SwimlaneLogDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/context/exe/CustomSerializable.zip
jbpm3/branches/jbpm-3.2.5.SP/modules/db/.project
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.project
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/pom.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/ant-actions-spec.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/auto-install-template.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/download-helper.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/install-definition.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/user-input-spec.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/pom.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/ContainerProvidedJarsTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/businesstrip/BusinessTripRequestTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/raise/RaiseRequestTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/rulesaction/RulesActionTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/identity/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/assignment/ExpressionAssignmentHandlerTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/hibernate/UserDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/.classpath
jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/jpdl/SimulationDefinition.java
jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/report/ScenarioReport.java
jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/BusinessFiguresTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/VariableSourceAndFilterTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.project
jbpm3/branches/jbpm-3.2.5.SP/pom.xml
jbpm3/branches/jbpm-3.2.5.SP/profiles.xml.example
Log:
[JBPM-2205] restore compatibility with jdk 1.4.2
Modified: jbpm3/branches/jbpm-3.2.5.SP/hudson/ant.properties.example
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/hudson/ant.properties.example 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/hudson/ant.properties.example 2009-05-04 09:33:28 UTC (rev 4706)
@@ -11,6 +11,7 @@
jboss.bind.address=127.0.0.1
# JDK settings
+java.home.jdk14=/usr/java/jdk1.4.2_17
java.home.jdk15=/usr/java/jdk1.5.0_15
java.home.jdk16=/usr/java/jdk1.6.0_06
@@ -28,9 +29,9 @@
hudson.admin.port=8150
hudson.http.port=8180
-#hudson.jboss422.zip=file:///home/hudson/download/java/jboss/jboss-4.2.2.GA.zip
-#hudson.jboss423.zip=file:///home/hudson/download/java/jboss/jboss-4.2.3.GA.zip
-#hudson.jboss500.zip=file:///home/hudson/download/java/jboss/jboss-5.0.0.GA.zip
+#hudson.jboss405.zip=file:/home/hudson/download/java/jboss/jboss-4.0.5.GA.zip
+#hudson.jboss423.zip=file:/home/hudson/download/java/jboss/jboss-4.2.3.GA.zip
+#hudson.jboss501.zip=file:/home/hudson/download/java/jboss/jboss-5.0.1.GA.zip
hudson.mail.recipients=
hudson.smtp.host=localhost
Modified: jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/command.sh
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/command.sh 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/command.sh 2009-05-04 09:33:28 UTC (rev 4706)
@@ -10,16 +10,16 @@
DISTRODIR=$JBPMDIR/modules/distribution/target
case "$CONTAINER" in
- jboss422*)
- JBOSS_BUILD=jboss-4.2.2.GA
+ jboss405*)
+ JBOSS_BUILD=jboss-4.0.5.GA
;;
jboss423*)
JBOSS_BUILD=jboss-4.2.3.GA
;;
- jboss500*)
- JBOSS_BUILD=jboss-5.0.0.GA
+ jboss501*)
+ JBOSS_BUILD=jboss-5.0.1.GA
;;
esac
Modified: jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/config.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/hudson/hudson-home/config.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -14,6 +14,10 @@
</systemMessage>
<jdks>
<jdk>
+ <name>jdk1.4</name>
+ <javaHome>@java.home.jdk14@</javaHome>
+ </jdk>
+ <jdk>
<name>jdk1.5</name>
<javaHome>@java.home.jdk15@</javaHome>
</jdk>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,7 +4,7 @@
<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.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/pom.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/pom.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -103,11 +103,6 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<!-- Plugins -->
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -27,42 +27,38 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-public abstract class AbstractJbpmTestCase extends TestCase
-{
+public abstract class AbstractJbpmTestCase extends TestCase {
+
private static Log log = LogFactory.getLog(AbstractJbpmTestCase.class);
-
- protected void setUp() throws Exception
- {
- log.debug("### START " + getLongName() + " ####################################################");
+
+ protected void setUp() throws Exception {
+ log.debug("### START "
+ + getLongName()
+ + " ####################################################");
}
- protected void tearDown() throws Exception
- {
- log.debug("### END " + getLongName() + " ######################################################");
+ protected void tearDown() throws Exception {
+ log.debug("### END "
+ + getLongName()
+ + " ######################################################");
}
-
- protected String getShortName()
- {
+
+ protected String getShortName() {
String shortName = getClass().getName();
return shortName.substring(shortName.lastIndexOf('.') + 1) + "." + getName();
}
-
- protected String getLongName()
- {
+
+ protected String getLongName() {
return getClass().getName() + "." + getName();
}
-
+
protected void runTest() throws Throwable {
try {
super.runTest();
- } catch (AssertionFailedError e) {
- log.error("");
- log.error("ASSERTION FAILURE: "+e.getMessage());
- log.error("");
+ }
+ catch (AssertionFailedError e) {
+ log.error("ASSERTION FAILURE: " + e.getMessage());
throw e;
- } catch (Throwable t) {
- t.printStackTrace();
- throw t;
}
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/AntHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/AntHelper.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/AntHelper.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,24 +21,21 @@
*/
package org.jbpm.ant;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.Configuration;
+
import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmException;
+import org.jbpm.util.ClassLoaderUtil;
/**
- * common strategy for jbpm ant tasks to obtain a hibernate SessionFactory.
+ * common strategy for jbpm ant tasks to obtain configuration instances.
*/
-public class AntHelper
-{
+public class AntHelper {
final static Map configurations = new HashMap();
final static Map jbpmConfigurations = new HashMap();
@@ -47,54 +44,30 @@
// prevent instantiation
}
- public static Configuration getConfiguration(String hibernateCfgResource, String hibernatePropertiesResource)
- {
- Object key = getKey(hibernateCfgResource, hibernatePropertiesResource);
- Configuration configuration = (Configuration)configurations.get(key);
- if (configuration == null)
- {
- log.debug("creating hibernate configuration from cfg '" + hibernateCfgResource + "' and properties '" + hibernatePropertiesResource + "'");
+ public static Configuration getConfiguration(String hibernateCfg, String hibernateProperties) {
+ Object key = getKey(hibernateCfg, hibernateProperties);
+ Configuration configuration = (Configuration) configurations.get(key);
+ if (configuration == null) {
configuration = new Configuration();
- configuration.configure(hibernateCfgResource);
- if (hibernatePropertiesResource != null)
- {
- try
- {
- InputStream propertiesInputStream = AntHelper.class.getResourceAsStream(hibernatePropertiesResource);
- if (propertiesInputStream == null)
- throw new IllegalArgumentException("Cannot read properties: " + hibernatePropertiesResource);
-
- Properties properties = new Properties();
- properties.load(propertiesInputStream);
- configuration.setProperties(properties);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- throw new JbpmException("couldn't set properties '" + hibernatePropertiesResource + "'", ex);
- }
+ configuration.configure(hibernateCfg);
+
+ if (hibernateProperties != null) {
+ Properties properties = ClassLoaderUtil.getProperties(hibernateProperties);
+ configuration.addProperties(properties);
}
configurations.put(key, configuration);
}
- else
- {
- log.debug("got hibernate configuration from cfg '" + hibernateCfgResource + "' and properties '" + hibernatePropertiesResource + "' from the cache");
- }
return configuration;
}
- public static JbpmConfiguration getJbpmConfiguration(String jbpmCfg)
- {
- JbpmConfiguration jbpmConfiguration = (JbpmConfiguration)jbpmConfigurations.get(jbpmCfg);
- if (jbpmConfiguration == null)
- {
- if (jbpmCfg == null)
- {
+ public static JbpmConfiguration getJbpmConfiguration(String jbpmCfg) {
+ JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) jbpmConfigurations.get(jbpmCfg);
+ if (jbpmConfiguration == null) {
+ if (jbpmCfg == null) {
jbpmConfiguration = JbpmConfiguration.getInstance();
}
- else
- {
+ else {
jbpmConfiguration = JbpmConfiguration.getInstance(jbpmCfg);
}
@@ -103,13 +76,10 @@
return jbpmConfiguration;
}
- static Object getKey(String cfg, String properties)
- {
+ static Object getKey(String cfg, String properties) {
List key = new ArrayList();
key.add(cfg);
key.add(properties);
return key;
}
-
- private static final Log log = LogFactory.getLog(AntHelper.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/JbpmSchemaTask.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -23,58 +23,44 @@
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintStream;
+import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
-import org.hibernate.util.ConfigHelper;
-public class JbpmSchemaTask extends Task
-{
- String config;
+public class JbpmSchemaTask extends Task {
+
+ String config = "hibernate.cfg.xml";
String properties;
- String action;
+ String action = "create";
String output;
String delimiter;
- public void execute() throws BuildException
- {
- if (action == null)
- action = "create";
-
- if (config == null)
- config = "hibernate.cfg.xml";
-
- List<Exception> exceptions = null;
- try
- {
- Configuration configuration = getConfiguration();
- if ("drop".equalsIgnoreCase(action))
- {
+ public void execute() throws BuildException {
+ List exceptions;
+ try {
+ Configuration configuration = AntHelper.getConfiguration(config, properties);
+ if ("drop".equalsIgnoreCase(action)) {
SchemaExport schemaExport = getSchemaExport(configuration);
schemaExport.execute(false, false, true, false);
exceptions = schemaExport.getExceptions();
}
- else if ("create".equalsIgnoreCase(action))
- {
+ else if ("create".equalsIgnoreCase(action)) {
SchemaExport schemaExport = getSchemaExport(configuration);
schemaExport.execute(false, false, false, true);
exceptions = schemaExport.getExceptions();
}
- else if ("update".equalsIgnoreCase(action))
- {
+ else if ("update".equalsIgnoreCase(action)) {
PrintStream fileOut = null;
PrintStream systemOut = System.out;
- try
- {
- if (output != null)
- {
+ try {
+ if (output != null) {
fileOut = new PrintStream(new FileOutputStream(output));
System.setOut(fileOut);
}
@@ -82,98 +68,58 @@
schemaUpdate.execute(true, false);
exceptions = schemaUpdate.getExceptions();
}
- finally
- {
- if (fileOut != null)
- {
+ finally {
+ if (fileOut != null) {
System.setOut(systemOut);
fileOut.close();
}
}
}
- else
- {
+ else {
throw new IllegalArgumentException("Unsupported action: " + action);
}
}
- catch (IOException ex)
- {
+ catch (IOException ex) {
throw new BuildException(ex);
}
// Print the exceptions if there are any
- for (Exception ex : exceptions)
- log(ex.toString());
- }
-
- private Configuration getConfiguration() throws IOException
- {
- log("Action '" + action + "' using " + config + "," + properties);
- Configuration configuration = new Configuration();
- configuration.configure(config);
-
- if (properties != null)
- {
- InputStream inStream = ConfigHelper.getResourceAsStream(properties);
- if (inStream == null)
- throw new IllegalArgumentException("Cannot read properties: " + properties);
-
- try
- {
- Properties properties = new Properties();
- properties.load(inStream);
- configuration.setProperties(properties);
- }
- finally
- {
- inStream.close();
- }
+ for (Iterator i = exceptions.iterator(); i.hasNext();) {
+ Object ex = i.next();
+ log(ex.toString(), Project.MSG_ERR);
}
- return configuration;
}
- private SchemaExport getSchemaExport(Configuration configuration)
- {
+ private SchemaExport getSchemaExport(Configuration configuration) {
SchemaExport schemaExport = new SchemaExport(configuration);
-
- if (output != null)
- schemaExport.setOutputFile(output);
-
- if (delimiter != null)
- schemaExport.setDelimiter(delimiter);
-
schemaExport.setFormat(false);
+ if (output != null) schemaExport.setOutputFile(output);
+ if (delimiter != null) schemaExport.setDelimiter(delimiter);
return schemaExport;
}
- private SchemaUpdate getSchemaUpdate(Configuration configuration)
- {
+ private SchemaUpdate getSchemaUpdate(Configuration configuration) {
SchemaUpdate schemaUpdate = new SchemaUpdate(configuration);
return schemaUpdate;
}
- public void setAction(String action)
- {
+ public void setAction(String action) {
this.action = action;
}
- public void setConfig(String config)
- {
+ public void setConfig(String config) {
this.config = config;
}
- public void setProperties(String properties)
- {
+ public void setProperties(String properties) {
this.properties = properties;
}
- public void setDelimiter(String delimiter)
- {
+ public void setDelimiter(String delimiter) {
this.delimiter = delimiter;
}
- public void setOutput(String output)
- {
+ public void setOutput(String output) {
this.output = output;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/ShutDownHsqldb.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/ShutDownHsqldb.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/ant/ShutDownHsqldb.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -6,34 +6,42 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+import org.hibernate.cfg.Configuration;
import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.impl.SessionFactoryImpl;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.persistence.db.DbPersistenceServiceFactory;
-import org.jbpm.svc.Services;
+import org.hibernate.engine.SessionFactoryImplementor;
public class ShutDownHsqldb extends Task {
+ private String config = "hibernate.cfg.xml";
+ private String properties;
+
public void execute() throws BuildException {
- Connection connection = null;
- JbpmConfiguration jbpmConfiguration = AntHelper.getJbpmConfiguration(null);
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ Configuration configuration = AntHelper.getConfiguration(config, properties);
+ SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) configuration.buildSessionFactory();
+ ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider();
try {
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- SessionFactoryImpl sessionFactory = (SessionFactoryImpl) dbPersistenceServiceFactory.getSessionFactory();
- ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider();
- connection = connectionProvider.getConnection();
+ Connection connection = connectionProvider.getConnection();
Statement statement = connection.createStatement();
+
log("shutting down database");
statement.executeUpdate("SHUTDOWN");
- connection.close();
-
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- jbpmContext.close();
+
+ connectionProvider.closeConnection(connection);
}
+ catch (SQLException e) {
+ throw new BuildException("could not shut down database", e);
+ }
+ finally {
+ connectionProvider.close();
+ }
}
+ public void setConfig(String config) {
+ this.config = config;
+ }
+
+ public void setProperties(String properties) {
+ this.properties = properties;
+ }
+
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,32 +1,29 @@
package org.jbpm.command;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.util.ArrayUtil;
/**
- * Abstract base class for all commands working on {@link org.jbpm.graph.exe.ProcessInstance}s.
+ * Abstract base class for all commands working on {@link org.jbpm.graph.exe.ProcessInstance}s. The
+ * {@link ProcessInstance} can either be specified by id or multiple ids. The alternative is to
+ * specify a {@link ProcessDefinition} name and version. In this case <b>all</b> found
+ * {@link ProcessInstance}s are processed. If no version is specified, <b>all</b> versions are taken
+ * into account. if onlyRunning is set to false (default is true) already ended
+ * {@link ProcessInstance}s are processed too.
*
- * The {@link ProcessInstance} can either be specified by id or multiple ids.
- *
- * The alternative is to specify a {@link ProcessDefinition} name and version.
- * In this case <b>all</b> found {@link ProcessInstance}s are processed.
- * If no version is specified, <b>all</b> versions are taken into account.
- *
- * if onlyRunning is set to false (default is true) already ended {@link ProcessInstance}s
- * are processed too.
- *
* @author bernd.ruecker at camunda.com
*/
-public abstract class AbstractProcessInstanceBaseCommand extends AbstractBaseCommand
-{
+public abstract class AbstractProcessInstanceBaseCommand extends AbstractBaseCommand {
+
protected Log log = LogFactory.getLog(this.getClass());
private long[] processInstanceIds = null;
@@ -35,47 +32,38 @@
private boolean onlyRunning = true;
private boolean operateOnSingleObject;
-
+
private transient JbpmContext jbpmContext;
- public AbstractProcessInstanceBaseCommand()
- {
- super();
- }
-
+ private static final long serialVersionUID = 1L;
+
protected JbpmContext getJbpmContext() {
return jbpmContext;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
ArrayList result = new ArrayList();
this.jbpmContext = jbpmContext;
- try {
+ try {
log.debug("executing " + this);
-
+
// batch tokens
- if (processInstanceIds != null && processInstanceIds.length > 0)
- {
- for (int i = 0; i < processInstanceIds.length; i++)
- {
+ if (processInstanceIds != null && processInstanceIds.length > 0) {
+ for (int i = 0; i < processInstanceIds.length; i++) {
ProcessInstance pi = jbpmContext.loadProcessInstanceForUpdate(processInstanceIds[i]);
- result.add(
- execute(pi));
+ result.add(execute(pi));
}
}
-
+
// search for ProcessInstances according to parameters
- if (processName != null)
- {
+ if (processName != null) {
operateOnSingleObject = false;
-
+
GetProcessInstancesCommand cmd = new GetProcessInstancesCommand();
- cmd.setProcessName(processName);
+ cmd.setProcessDefinitionName(processName);
cmd.setOnlyRunning(onlyRunning);
- if (processVersion>0)
- cmd.setVersion(String.valueOf(processVersion));
-
+ if (processVersion > 0) cmd.setVersion(String.valueOf(processVersion));
+
// Query query = null;
// if (processVersion>0) {
// query = jbpmContext.getSession().getNamedQuery("GraphSession.findProcessDefinitionByNameAndVersion");
@@ -85,24 +73,23 @@
// query = jbpmContext.getSession().getNamedQuery("GraphSession.findTokensForProcessInNode");
// }
// query.setString("name", processName);
- List processInstanceList = (List)cmd.execute(jbpmContext);
-
+ List processInstanceList = (List) cmd.execute(jbpmContext);
+
Iterator iter = processInstanceList.iterator();
- while (iter.hasNext())
- {
- ProcessInstance pi = (ProcessInstance)iter.next();
+ while (iter.hasNext()) {
+ ProcessInstance pi = (ProcessInstance) iter.next();
execute(pi);
}
}
-
+
if (operateOnSingleObject) {
- if (result.size()<1)
+ if (result.size() < 1)
return null;
- else
+ else
return result.get(0);
}
else {
- return result;
+ return result;
}
}
finally {
@@ -111,116 +98,107 @@
}
public abstract ProcessInstance execute(ProcessInstance processInstance);
-
- public void setProcessInstanceIds(long[] processInstanceIds)
- {
+
+ public void setProcessInstanceIds(long[] processInstanceIds) {
this.operateOnSingleObject = false;
this.processInstanceIds = processInstanceIds;
}
- public void setProcessInstanceId(long processInstanceId)
- {
+ public void setProcessInstanceId(long processInstanceId) {
this.operateOnSingleObject = true;
this.processInstanceIds = new long[1];
- this.processInstanceIds[0] = processInstanceId;
+ this.processInstanceIds[0] = processInstanceId;
}
-
+
/**
* Overwrite toString to keep semantic of getAdditionalToStringInformation
*/
public String toString() {
- if (processName!=null) {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(processInstanceIds)
- + ";processName=" + processName
- + ";processVersion=" + (processVersion>0 ? processVersion : "NA")
- + getAdditionalToStringInformation()
- + "]";
+ if (processName != null) {
+ return this.getClass().getName()
+ + " [tokenIds="
+ + ArrayUtil.toString(processInstanceIds)
+ + ";processName="
+ + processName
+ + ";processVersion="
+ + (processVersion > 0 ? Integer.toString(processVersion) : "NA")
+ + getAdditionalToStringInformation()
+ + "]";
}
else {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(processInstanceIds)
- + ";operateOnSingleObject=" + operateOnSingleObject
- + getAdditionalToStringInformation()
- + "]";
+ return this.getClass().getName()
+ + " [tokenIds="
+ + ArrayUtil.toString(processInstanceIds)
+ + ";operateOnSingleObject="
+ + operateOnSingleObject
+ + getAdditionalToStringInformation()
+ + "]";
}
- }
+ }
- public String getProcessName()
- {
+ public String getProcessName() {
return processName;
}
- public void setProcessName(String processName)
- {
+ public void setProcessName(String processName) {
this.processName = processName;
}
-
- public int getProcessVersion()
- {
+
+ public int getProcessVersion() {
return processVersion;
}
- public void setProcessVersion(int processVersion)
- {
+ public void setProcessVersion(int processVersion) {
this.processVersion = processVersion;
}
- public long[] getProcessInstanceIds()
- {
+ public long[] getProcessInstanceIds() {
return processInstanceIds;
}
/**
- * return the process instance id in case only one
- * process instance id is set. Otherwise an {@link IllegalStateException}
- * is thrown
+ * return the process instance id in case only one process instance id is set. Otherwise an
+ * {@link IllegalStateException} is thrown
*/
- public long getProcessInstanceId()
- {
- if (processInstanceIds==null || processInstanceIds.length!=1)
- throw new IllegalStateException("getProcessInstanceId can only be called if only one process instance id is set on command " + this + " but was " + processInstanceIds);
+ public long getProcessInstanceId() {
+ if (processInstanceIds == null || processInstanceIds.length > 1) {
+ throw new IllegalStateException("multiple process instance ids set: "
+ + ArrayUtil.toString(processInstanceIds));
+ }
return processInstanceIds[0];
}
- public boolean isOnlyRunning()
- {
+ public boolean isOnlyRunning() {
return onlyRunning;
}
- public void setOnlyRunning(boolean onlyRunning)
- {
+ public void setOnlyRunning(boolean onlyRunning) {
this.onlyRunning = onlyRunning;
}
// methods for fluent programming
- public AbstractProcessInstanceBaseCommand processInstanceIds(long[] processInstanceIds)
- {
- setProcessInstanceIds( processInstanceIds );
+ public AbstractProcessInstanceBaseCommand processInstanceIds(long[] processInstanceIds) {
+ setProcessInstanceIds(processInstanceIds);
return this;
}
- public AbstractProcessInstanceBaseCommand processInstanceId(long processInstanceId)
- {
- setProcessInstanceId(processInstanceId);
+ public AbstractProcessInstanceBaseCommand processInstanceId(long processInstanceId) {
+ setProcessInstanceId(processInstanceId);
return this;
}
- public AbstractProcessInstanceBaseCommand processName(String processName)
- {
- setProcessName( processName );
+ public AbstractProcessInstanceBaseCommand processName(String processName) {
+ setProcessName(processName);
return this;
}
-
- public AbstractProcessInstanceBaseCommand processVersion(int processVersion)
- {
- setProcessVersion( processVersion );
+
+ public AbstractProcessInstanceBaseCommand processVersion(int processVersion) {
+ setProcessVersion(processVersion);
return this;
}
- public AbstractProcessInstanceBaseCommand onlyRunning(boolean onlyRunning)
- {
+ public AbstractProcessInstanceBaseCommand onlyRunning(boolean onlyRunning) {
setOnlyRunning(onlyRunning);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,101 +1,89 @@
package org.jbpm.command;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
+
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.Token;
+import org.jbpm.util.ArrayUtil;
/**
- * Abstract base class for commands working on Tokens.
+ * Abstract base class for commands working on Tokens. The {@link Token} can either be specified by
+ * id or multiple ids. The alternative is to specify a {@link ProcessDefinition} name, a required
+ * node name and version. In this case <b>all</b> found {@link Token}s are processed. If no version
+ * is specified, <b>all</b> versions are taken into account.
*
- * The {@link Token} can either be specified by id or multiple ids.
- *
- * The alternative is to specify a {@link ProcessDefinition} name, a
- * required node name and version.
- * In this case <b>all</b> found {@link Token}s are processed.
- * If no version is specified, <b>all</b> versions are taken into account.
- *
* @author bernd.ruecker at camunda.com
*/
-public abstract class AbstractTokenBaseCommand implements Command
-{
+public abstract class AbstractTokenBaseCommand implements Command {
+
protected Log log = LogFactory.getLog(this.getClass());
private long[] tokenIds = null;
private String processName = null;
private String stateName = null;
private int processVersion = 0;
-
+
private boolean operateOnSingleObject;
private transient JbpmContext jbpmContext;
- public AbstractTokenBaseCommand()
- {
- super();
- }
-
+ private static final long serialVersionUID = 1L;
+
protected JbpmContext getJbpmContext() {
return jbpmContext;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
this.jbpmContext = jbpmContext;
- try {
+ try {
ArrayList result = new ArrayList();
log.debug("executing " + this);
-
+
// batch tokens
- if (tokenIds != null && tokenIds.length > 0)
- {
- for (int i = 0; i < tokenIds.length; i++)
- {
+ if (tokenIds != null && tokenIds.length > 0) {
+ for (int i = 0; i < tokenIds.length; i++) {
Token token = jbpmContext.loadTokenForUpdate(tokenIds[i]);
- result.add(
- execute(token));
+ result.add(execute(token));
}
}
-
+
// search for tokens in process/state
- if (processName != null && stateName != null)
- {
+ if (processName != null && stateName != null) {
this.operateOnSingleObject = false;
-
+
Query query = null;
- if (processVersion>0) {
- query = jbpmContext.getSession().getNamedQuery("GraphSession.findTokensForProcessVersionInNode");
+ if (processVersion > 0) {
+ query = jbpmContext.getSession().getNamedQuery(
+ "GraphSession.findTokensForProcessVersionInNode");
query.setInteger("processDefinitionVersion", processVersion);
}
else {
- query = jbpmContext.getSession().getNamedQuery("GraphSession.findTokensForProcessInNode");
+ query = jbpmContext.getSession().getNamedQuery("GraphSession.findTokensForProcessInNode");
}
query.setString("processDefinitionName", processName);
query.setString("nodeName", stateName);
-
+
Iterator iter = query.list().iterator();
- while (iter.hasNext())
- {
- Token token = (Token)iter.next();
- result.add(
- execute(token));
+ while (iter.hasNext()) {
+ Token token = (Token) iter.next();
+ result.add(execute(token));
}
}
-
+
if (operateOnSingleObject) {
- if (result.size()<1)
+ if (result.size() < 1)
return null;
- else
+ else
return result.get(0);
}
else {
- return result;
+ return result;
}
}
finally {
@@ -105,118 +93,109 @@
public abstract Object execute(Token token);
- public void setTokenIds(long[] tokenIds)
- {
+ public void setTokenIds(long[] tokenIds) {
this.operateOnSingleObject = false;
this.tokenIds = tokenIds;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.operateOnSingleObject = true;
this.tokenIds = new long[1];
this.tokenIds[0] = tokenId;
}
-
+
public String getAdditionalToStringInformation() {
return "";
}
- public String getProcessName()
- {
+ public String getProcessName() {
return processName;
}
- public void setProcessName(String processName)
- {
+ public void setProcessName(String processName) {
this.processName = processName;
}
- public int getProcessVersion()
- {
+ public int getProcessVersion() {
return processVersion;
}
- public void setProcessVersion(int processVersion)
- {
+ public void setProcessVersion(int processVersion) {
this.processVersion = processVersion;
}
- public String getStateName()
- {
+ public String getStateName() {
return stateName;
}
- public void setStateName(String stateName)
- {
+ public void setStateName(String stateName) {
this.stateName = stateName;
}
- public long[] getTokenIds()
- {
+ public long[] getTokenIds() {
return tokenIds;
}
-
+
/**
- * return the process instance id in case only one
- * process instance id is set. Otherwise an {@link IllegalStateException}
- * is thrown
+ * return the token id in case only one token id is set. Otherwise an
+ * {@link IllegalStateException} is thrown
*/
- public long getTokenId()
- {
- if (tokenIds==null || tokenIds.length!=1)
- throw new IllegalStateException("getTokenIds can only be called if only one token id is set on command " + this + " but was " + tokenIds);
+ public long getTokenId() {
+ if (tokenIds == null || tokenIds.length != 1) {
+ throw new IllegalStateException("multiple token ids set: " + ArrayUtil.toString(tokenIds));
+ }
return tokenIds[0];
- }
-
+ }
+
public String toString() {
- if (processName!=null && stateName!=null) {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(tokenIds)
- + ";processName=" + processName
- + ";processVersion=" + (processVersion>0 ? processVersion : "NA")
- + ";stateName=" + stateName
- + getAdditionalToStringInformation()
- + "]";
+ if (processName != null && stateName != null) {
+ return this.getClass().getName()
+ + " [tokenIds="
+ + ArrayUtil.toString(tokenIds)
+ + ";processName="
+ + processName
+ + ";processVersion="
+ + (processVersion > 0 ? Integer.toString(processVersion) : "NA")
+ + ";stateName="
+ + stateName
+ + getAdditionalToStringInformation()
+ + "]";
}
else {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(tokenIds)
- + ";operateOnSingleObject=" + operateOnSingleObject
- + getAdditionalToStringInformation()
- + "]";
+ return this.getClass().getName()
+ + " [tokenIds="
+ + ArrayUtil.toString(tokenIds)
+ + ";operateOnSingleObject="
+ + operateOnSingleObject
+ + getAdditionalToStringInformation()
+ + "]";
}
}
-
+
// methods for fluent programming
- public AbstractTokenBaseCommand tokenIds(long[] tokenIds)
- {
+ public AbstractTokenBaseCommand tokenIds(long[] tokenIds) {
setTokenIds(tokenIds);
return this;
}
- public AbstractTokenBaseCommand tokenId(long tokenId)
- {
+ public AbstractTokenBaseCommand tokenId(long tokenId) {
setTokenId(tokenId);
return this;
}
-
- public AbstractTokenBaseCommand processName(String processName)
- {
+
+ public AbstractTokenBaseCommand processName(String processName) {
setProcessName(processName);
return this;
}
- public AbstractTokenBaseCommand processVersion(int processVersion)
- {
+ public AbstractTokenBaseCommand processVersion(int processVersion) {
setProcessVersion(processVersion);
return this;
}
- public AbstractTokenBaseCommand stateName(String stateName)
- {
+ public AbstractTokenBaseCommand stateName(String stateName) {
setStateName(stateName);
return this;
- }
+ }
}
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,66 +5,59 @@
import org.jbpm.graph.exe.Token;
/**
- * a bunch of processes is signaled with this command. you can specify the
- * tokens either
- * <li>by a array of token ids
- * <li>or by processName, processVersion (optional, without all versions),
- * stateName
+ * a bunch of processes is signaled with this command. you can specify the tokens either <li>by a
+ * array of token ids <li>or by processName, processVersion (optional, without all versions),
+ * stateName transitionName specifies the transition to take (if null, the default transition is
+ * taken).
*
- * transitionName specifies the transition to take (if null, the default
- * transition is taken).
- *
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
public class BatchSignalCommand extends AbstractTokenBaseCommand {
- private static final long serialVersionUID = -4330623193546102772L;
+ private static final long serialVersionUID = -4330623193546102772L;
- /**
- * if set, only tokens which are started after this date are signaled
- * (interesting to implement some timeout for example)
- */
- private Date inStateAtLeastSince = null;
+ /**
+ * if set, only tokens which are started after this date are signaled (interesting to implement
+ * some timeout for example)
+ */
+ private Date inStateAtLeastSince = null;
- private String transitionName = null;
+ private String transitionName = null;
- public Object execute(Token token) {
- if (inStateAtLeastSince == null
- || token.getNodeEnter().before(inStateAtLeastSince)) {
+ public Object execute(Token token) {
+ if (inStateAtLeastSince == null || token.getNodeEnter().before(inStateAtLeastSince)) {
- log.debug("signal token " + token);
- if (transitionName == null) {
- token.signal();
- } else {
- token.signal(transitionName);
- }
- }
- return token;
- }
+ log.debug("signal token " + token);
+ if (transitionName == null) {
+ token.signal();
+ }
+ else {
+ token.signal(transitionName);
+ }
+ }
+ return token;
+ }
- public String getTransitionName() {
- return transitionName;
- }
+ public String getTransitionName() {
+ return transitionName;
+ }
- public void setTransitionName(String transitionName) {
- this.transitionName = transitionName;
- }
+ public void setTransitionName(String transitionName) {
+ this.transitionName = transitionName;
+ }
- public Date getInStateAtLeastSince() {
- return inStateAtLeastSince;
- }
+ public Date getInStateAtLeastSince() {
+ return inStateAtLeastSince;
+ }
- public void setInStateAtLeastSince(Date inStateAtLeastSince) {
- this.inStateAtLeastSince = inStateAtLeastSince;
- }
+ public void setInStateAtLeastSince(Date inStateAtLeastSince) {
+ this.inStateAtLeastSince = inStateAtLeastSince;
+ }
- @Override
- public String getAdditionalToStringInformation()
- {
- return ";transitionName=" + transitionName
- + ";inStateAtLeastSince=" + inStateAtLeastSince;
+ public String getAdditionalToStringInformation() {
+ return ";transitionName=" + transitionName + ";inStateAtLeastSince=" + inStateAtLeastSince;
}
-
+
// methods for fluent programming
public BatchSignalCommand transitionName(String transitionName) {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,55 +1,47 @@
package org.jbpm.command;
-import java.util.Date;
-
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.util.Clock;
/**
- * Cancel the given {@link ProcessInstance} with all {@link Token}s.
+ * Cancel the given {@link ProcessInstance} with all {@link Token}s. <b>Maybe running sub process
+ * instances are currently not canceled.</b>
*
- * <b>Maybe running sub process instances are currently not canceled.</b>
- *
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class CancelProcessInstanceCommand extends AbstractCancelCommand
-{
+public class CancelProcessInstanceCommand extends AbstractCancelCommand {
private static final long serialVersionUID = 7145293049356621597L;
-
+
private long processInstanceId;
- public CancelProcessInstanceCommand()
- {
+ public CancelProcessInstanceCommand() {
}
- public CancelProcessInstanceCommand(long processInstanceId)
- {
+ public CancelProcessInstanceCommand(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
this.jbpmContext = jbpmContext;
cancelProcess(processInstanceId);
this.jbpmContext = null;
return null;
}
- protected void cancelProcess(long processIdToCancel)
- {
+ protected void cancelProcess(long processIdToCancel) {
ProcessInstance pi = jbpmContext.getGraphSession().loadProcessInstance(processIdToCancel);
log.info("cancel process instance " + pi.getId());
// Record a standardized variable that we can use to determine that this
// process has been 'canceled' and not just ended.
- pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime());
+ pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME,
+ Clock.getCurrentTime());
- try
- {
+ try {
// End the process instance and any open tokens
// TODO: Think about maybe canceling sub processes?
cancelToken(pi.getRootToken());
@@ -58,49 +50,41 @@
log.info("finished process cancellation");
}
- catch (RuntimeException ex)
- {
+ catch (RuntimeException ex) {
log.error("problems while cancel process", ex);
throw ex;
}
}
- public long getProcessInstanceId()
- {
+ public long getProcessInstanceId() {
return processInstanceId;
}
- public void setProcessInstanceId(long processInstanceId)
- {
+ public void setProcessInstanceId(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
/**
* @deprecated use getProcessInstanceId instead
*/
- public long getProcessId()
- {
+ public long getProcessId() {
return processInstanceId;
}
/**
* @deprecated use setProcessInstanceId instead
*/
- public void setProcessId(long processId)
- {
+ public void setProcessId(long processId) {
this.processInstanceId = processId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
+ public String getAdditionalToStringInformation() {
return "processInstanceId=" + processInstanceId;
}
-
+
// methods for fluent programming
- public CancelProcessInstanceCommand processInstanceId(long processInstanceId)
- {
+ public CancelProcessInstanceCommand processInstanceId(long processInstanceId) {
setProcessInstanceId(processInstanceId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -9,24 +9,20 @@
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class CancelTokenCommand extends AbstractCancelCommand
-{
+public class CancelTokenCommand extends AbstractCancelCommand {
private static final long serialVersionUID = 7145293049356621597L;
private long tokenId;
- public CancelTokenCommand()
- {
+ public CancelTokenCommand() {
}
- public CancelTokenCommand(long tokenId)
- {
+ public CancelTokenCommand(long tokenId) {
this.tokenId = tokenId;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
this.jbpmContext = jbpmContext;
Token token = jbpmContext.getGraphSession().loadToken(tokenId);
@@ -34,31 +30,26 @@
token.getProcessInstance().getContextInstance().createVariable(
CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime(), token);
- cancelToken(token);
+ cancelToken(token);
this.jbpmContext = null;
return null;
}
- public long getTokenId()
- {
+ public long getTokenId() {
return tokenId;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.tokenId = tokenId;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
+
+ public String getAdditionalToStringInformation() {
return "tokenId=" + tokenId;
}
// methods for fluent programming
- public CancelTokenCommand tokenId(long tokenId)
- {
+ public CancelTokenCommand tokenId(long tokenId) {
setTokenId(tokenId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,57 +4,47 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
/**
- * The current authorizes actor starts to work on the TaskInstance so the actor is set to the given actor
- *
- * see some more information why we need that in the <a
+ * The current authorizes actor starts to work on the TaskInstance so the actor is set to the given
+ * actor see some more information why we need that in the <a
* href="http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018785">jbpm forum</a>
*
* @author Bernd Ruecker
*/
-public class CancelWorkOnTaskCommand extends AbstractBaseCommand
-{
+public class CancelWorkOnTaskCommand extends AbstractBaseCommand {
private static final long serialVersionUID = -172457633891242288L;
private long taskInstanceId;
- public CancelWorkOnTaskCommand(long taskInstanceId)
- {
+ public CancelWorkOnTaskCommand(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public CancelWorkOnTaskCommand()
- {
+ public CancelWorkOnTaskCommand() {
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
TaskInstance ti = jbpmContext.getTaskInstance(taskInstanceId);
ti.setActorId(null);
ti.setStart(null);
return null;
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
+ public String getAdditionalToStringInformation() {
return ";taskInstanceId=" + taskInstanceId;
}
-
+
// methods for fluent programming
- public CancelWorkOnTaskCommand taskInstanceId(long taskInstanceId)
- {
+ public CancelWorkOnTaskCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -8,6 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
+
import org.jbpm.JbpmException;
import org.jbpm.graph.def.GraphElement;
import org.jbpm.graph.def.Node;
@@ -24,38 +25,29 @@
/**
* <b>THIS COMMAND IS NOT YET STABLE, BUT FEEL FREE TO TEST :-)</b><br>
- *
- * Status update: Still not complete, but refactored and added simple test cases:
+ * Status update: Still not complete, but refactored and added simple test cases:
* {@link ChangeProcessInstanceVersionCommandTest}.<br>
- *
- * Change the version of a running process instance.
- *
- * This works only, if the current node is also available in the new
- * version of the process definition or a name mapping has to be provided.<br>
- *
+ * Change the version of a running process instance. This works only, if the current node is also
+ * available in the new version of the process definition or a name mapping has to be provided.<br>
* <b>Currently known limitations:</b>
* <ul>
- * <li> {@link Task}s cannot move "into" another node. If an active
- * {@link TaskInstance} exists, the {@link Task} definition must
- * exist in the {@link TaskNode} with the same (or mapped) name.
- * Otherwise the right node cannot be found easily because it may be
- * ambiguous.</li>
- * <li> Sub processes aren't yet tested. Since the {@link ProcessState} is
- * a {@link Node} like any other, it should work anyway.</li>
- * <li> Can have <b>negative impact on referential integrity</b>! Because
- * one {@link ProcessInstance} can have {@link ProcessLog}s point to
- * old {@link ProcessDefinition}s. Hence, delete a {@link ProcessDefinition}
- * may not work and throw an Exception (Integrity constraint violation)</li>
- * <li> In combination with ESB the ESB uses {@link Token}.id <b>and</b> {@link Node}.id
- * as correlation identifier. After changing the version of a {@link ProcessInstance}
- * the {@link Node}.id has changed, so a signal from ESB will result in an exception
- * and has to be corrected manually.</li>
+ * <li> {@link Task}s cannot move "into" another node. If an active {@link TaskInstance} exists, the
+ * {@link Task} definition must exist in the {@link TaskNode} with the same (or mapped) name.
+ * Otherwise the right node cannot be found easily because it may be ambiguous.</li>
+ * <li>Sub processes aren't yet tested. Since the {@link ProcessState} is a {@link Node} like any
+ * other, it should work anyway.</li>
+ * <li>Can have <b>negative impact on referential integrity</b>! Because one {@link ProcessInstance}
+ * can have {@link ProcessLog}s point to old {@link ProcessDefinition}s. Hence, delete a
+ * {@link ProcessDefinition} may not work and throw an Exception (Integrity constraint violation)</li>
+ * <li>In combination with ESB the ESB uses {@link Token}.id <b>and</b> {@link Node}.id as
+ * correlation identifier. After changing the version of a {@link ProcessInstance} the {@link Node}
+ * .id has changed, so a signal from ESB will result in an exception and has to be corrected
+ * manually.</li>
* </ul>
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class ChangeProcessInstanceVersionCommand extends AbstractProcessInstanceBaseCommand
-{
+public class ChangeProcessInstanceVersionCommand extends AbstractProcessInstanceBaseCommand {
private static final long serialVersionUID = 2277080393930008224L;
@@ -67,64 +59,68 @@
private static final Log log = LogFactory.getLog(ChangeProcessInstanceVersionCommand.class);
/**
- * the map configures for every node-name in the old process definition
- * (as key) which node-name to use in the new
- * process definition.
- *
- * if a node is not mentioned in this Map,
- * old node name = new node name is applied
+ * the map configures for every node-name in the old process definition (as key) which node-name
+ * to use in the new process definition. if a node is not mentioned in this Map, old node name =
+ * new node name is applied
*/
- private Map<String, String> nodeNameMapping = new HashMap<String, String>();
+ private Map nodeNameMapping = new HashMap();
- private Map<String, String> taskNameMapping = new HashMap<String, String>();
+ private Map taskNameMapping = new HashMap();
- public ChangeProcessInstanceVersionCommand()
- {
+ public ChangeProcessInstanceVersionCommand() {
}
- public ChangeProcessInstanceVersionCommand(long processId, int newVersion)
- {
+ public ChangeProcessInstanceVersionCommand(long processId, int newVersion) {
super();
super.setProcessInstanceId(processId);
this.newVersion = newVersion;
}
-
+
public String getAdditionalToStringInformation() {
return ";newVersion=" + newVersion;
}
- private ProcessDefinition loadNewProcessDefinition(String processName)
- {
+ private ProcessDefinition loadNewProcessDefinition(String processName) {
if (newVersion <= 0)
return getJbpmContext().getGraphSession().findLatestProcessDefinition(processName);
else
return getJbpmContext().getGraphSession().findProcessDefinition(processName, newVersion);
}
- public ProcessInstance execute(ProcessInstance pi)
- {
+ public ProcessInstance execute(ProcessInstance pi) {
ProcessDefinition oldDef = pi.getProcessDefinition();
ProcessDefinition newDef = loadNewProcessDefinition(oldDef.getName());
-
- if (newDef==null) {
- throw new JbpmException("Process definition " + oldDef.getName() + " in version " + newVersion + " not found.");
+
+ if (newDef == null) {
+ throw new JbpmException("Process definition "
+ + oldDef.getName()
+ + " in version "
+ + newVersion
+ + " not found.");
}
- log.debug("Start changing process id " + pi.getId() + " from version " + pi.getProcessDefinition().getVersion() + " to new version " + newDef.getVersion());
+ log.debug("Start changing process id "
+ + pi.getId()
+ + " from version "
+ + pi.getProcessDefinition().getVersion()
+ + " to new version "
+ + newDef.getVersion());
pi.setProcessDefinition(newDef);
changeTokenVersion(pi.getRootToken());
- log.debug("process id " + pi.getId() + " changed to version " + pi.getProcessDefinition().getVersion());
- return pi;
+ log.debug("process id "
+ + pi.getId()
+ + " changed to version "
+ + pi.getProcessDefinition().getVersion());
+ return pi;
}
-
- private ProcessDefinition getNewProcessDefinition(Token t) {
+
+ private ProcessDefinition getNewProcessDefinition(Token t) {
return t.getProcessInstance().getProcessDefinition();
}
- private void changeTokenVersion(Token token)
- {
+ private void changeTokenVersion(Token token) {
ProcessDefinition newDef = getNewProcessDefinition(token);
log.debug("change token id " + token.getId() + " to new version " + newDef.getVersion());
@@ -140,166 +136,150 @@
adjustTaskInstancesForToken(token);
// change children recursively
- if (token.getChildren()!=null) {
- Iterator<Token> tokenIter = token.getChildren().values().iterator();
- while (tokenIter.hasNext())
- {
- changeTokenVersion(tokenIter.next());
+ if (token.getChildren() != null) {
+ for (Iterator i = token.getChildren().values().iterator(); i.hasNext();) {
+ changeTokenVersion((Token) i.next());
}
}
}
- private void adjustTaskInstancesForToken(Token token)
- {
+ private void adjustTaskInstancesForToken(Token token) {
ProcessDefinition newDef = getNewProcessDefinition(token);
- Iterator<TaskInstance> iter = getTasksForToken(token).iterator();
- while (iter.hasNext())
- {
- TaskInstance ti = iter.next();
+ for (Iterator i = getTasksForToken(token).iterator(); i.hasNext();) {
+ TaskInstance ti = (TaskInstance) i.next();
// find new task
Task oldTask = ti.getTask();
Node oldNode = oldTask.getTaskNode();
-
+
Task newTask = findReplacementTask(newDef, oldNode, oldTask);
ti.setTask(newTask);
log.debug("change dependent task-instance with id " + oldTask.getId());
}
}
- private void adjustTimersForToken(Token token)
- {
+ private void adjustTimersForToken(Token token) {
ProcessDefinition newDef = getNewProcessDefinition(token);
- List<Job> jobs = getJbpmContext().getJobSession().findJobsByToken(token);
- for (Job job : jobs)
- {
- if (job instanceof Timer)
- {
+ List jobs = getJbpmContext().getJobSession().findJobsByToken(token);
+ for (Iterator i = jobs.iterator(); i.hasNext();) {
+ Job job = (Job) i.next();
+ if (job instanceof Timer) {
// check all timers if connected to a GraphElement
- Timer timer = (Timer)job;
- if (timer.getGraphElement()!=null) {
-
+ Timer timer = (Timer) job;
+ if (timer.getGraphElement() != null) {
+
// and change the reference (take name mappings into account!)
if (timer.getGraphElement() instanceof Task) {
// change to new task definition
- Task oldTask = (Task)timer.getGraphElement();
- TaskNode oldNode = oldTask.getTaskNode();
- timer.setGraphElement(
- findReplacementTask(newDef, oldNode, oldTask));
+ Task oldTask = (Task) timer.getGraphElement();
+ TaskNode oldNode = oldTask.getTaskNode();
+ timer.setGraphElement(findReplacementTask(newDef, oldNode, oldTask));
}
else {
// change to new node
GraphElement oldNode = timer.getGraphElement();
// TODO: What with other GraphElements?
- timer.setGraphElement(
- findReplacementNode(newDef, oldNode));
- }
+ timer.setGraphElement(findReplacementNode(newDef, oldNode));
+ }
}
}
}
}
-
- private Node findReplacementNode(ProcessDefinition newDef, GraphElement oldNode)
- {
- String name = getReplacementNodeName( oldNode );
+
+ private Node findReplacementNode(ProcessDefinition newDef, GraphElement oldNode) {
+ String name = getReplacementNodeName(oldNode);
Node newNode = newDef.findNode(name);
- if (newNode == null)
- {
+ if (newNode == null) {
throw new JbpmException("node with name '" + name + "' not found in new process definition");
}
return newNode;
}
- private Task findReplacementTask(ProcessDefinition newDef, Node oldNode, Task oldTask)
- {
- String replacementTaskName = getReplacementTaskName( oldTask );
+ private Task findReplacementTask(ProcessDefinition newDef, Node oldNode, Task oldTask) {
+ String replacementTaskName = getReplacementTaskName(oldTask);
Node newTaskNode = findReplacementNode(newDef, oldNode);
-
+
Query q = getJbpmContext().getSession().getNamedQuery("TaskMgmtSession.findTaskForNode");
q.setString("taskName", replacementTaskName);
q.setLong("taskNodeId", newTaskNode.getId());
- Task newTask = (Task)q.uniqueResult();
- if (newTask == null)
- {
- throw new JbpmException("Task '" + replacementTaskName + "' for node '" + newTaskNode.getName() + "' not found in new process definition");
+ Task newTask = (Task) q.uniqueResult();
+ if (newTask == null) {
+ throw new JbpmException("Task '"
+ + replacementTaskName
+ + "' for node '"
+ + newTaskNode.getName()
+ + "' not found in new process definition");
}
return newTask;
}
/**
* @param oldNode
- * @return the name of the new node (given in the map or return default value, which is the old node name)
+ * @return the name of the new node (given in the map or return default value, which is the old
+ * node name)
*/
- private String getReplacementNodeName(GraphElement oldNode)
- {
- String oldName = (oldNode instanceof Node ? ((Node)oldNode).getFullyQualifiedName() : oldNode.getName());
- if (nodeNameMapping.containsKey(oldName))
- {
- return (String)nodeNameMapping.get(oldName);
+ private String getReplacementNodeName(GraphElement oldNode) {
+ String oldName = (oldNode instanceof Node ? ((Node) oldNode).getFullyQualifiedName()
+ : oldNode.getName());
+ if (nodeNameMapping.containsKey(oldName)) {
+ return (String) nodeNameMapping.get(oldName);
}
// return new node name = old node name as default
return oldName;
}
- private String getReplacementTaskName(Task oldTask)
- {
+ private String getReplacementTaskName(Task oldTask) {
String oldName = oldTask.getName();
- if (taskNameMapping.containsKey(oldName))
- {
- return (String)taskNameMapping.get(oldName);
+ if (taskNameMapping.containsKey(oldName)) {
+ return (String) taskNameMapping.get(oldName);
}
// return new node name = old node name as default
return oldName;
}
/**
- * We may still have open tasks, even though their parent tokens have been ended. So we'll simply get all tasks from
- * this process instance and cancel them if they are still active.
- *
+ * We may still have open tasks, even though their parent tokens have been ended. So we'll simply
+ * get all tasks from this process instance and cancel them if they are still active.
*/
- private List getTasksForToken(Token token)
- {
- Query query = getJbpmContext().getSession().getNamedQuery("TaskMgmtSession.findTaskInstancesByTokenId");
+ private List getTasksForToken(Token token) {
+ Query query = getJbpmContext().getSession().getNamedQuery(
+ "TaskMgmtSession.findTaskInstancesByTokenId");
query.setLong("tokenId", token.getId());
return query.list();
}
- public Map getNodeNameMapping()
- {
+ public Map getNodeNameMapping() {
return nodeNameMapping;
}
-
- public void setNodeNameMapping(Map<String, String> nameMapping)
- {
+
+ public void setNodeNameMapping(Map nameMapping) {
if (nameMapping == null) {
- this.nodeNameMapping = new HashMap<String, String>();
- } else {
+ this.nodeNameMapping = new HashMap();
+ }
+ else {
this.nodeNameMapping = nameMapping;
}
}
- public int getNewVersion()
- {
+ public int getNewVersion() {
return newVersion;
}
- public void setNewVersion(int newVersion)
- {
+ public void setNewVersion(int newVersion) {
this.newVersion = newVersion;
}
-
- public Map getTaskNameMapping()
- {
+
+ public Map getTaskNameMapping() {
return taskNameMapping;
}
- public void setTaskNameMapping(Map<String, String> nameMapping)
- {
+ public void setTaskNameMapping(Map nameMapping) {
if (nameMapping == null) {
- this.taskNameMapping = new HashMap<String, String>();
- } else {
+ this.taskNameMapping = new HashMap();
+ }
+ else {
this.taskNameMapping = nameMapping;
}
}
@@ -307,9 +287,8 @@
/**
* @deprecated use getProcessInstanceId instead
*/
- public long getProcessId()
- {
- if (getProcessInstanceIds()!=null && getProcessInstanceIds().length>0)
+ public long getProcessId() {
+ if (getProcessInstanceIds() != null && getProcessInstanceIds().length > 0)
return getProcessInstanceIds()[0];
else
return 0;
@@ -317,17 +296,15 @@
/**
* @deprecated use setProcessInstanceId instead
- */
- public void setProcessId(long processId)
- {
+ */
+ public void setProcessId(long processId) {
super.setProcessInstanceId(processId);
}
/**
* @deprecated use getNodeNameMapping instead
*/
- public Map getNameMapping()
- {
+ public Map getNameMapping() {
return getNodeNameMapping();
}
@@ -340,40 +317,37 @@
// methods for fluent programming
- public ChangeProcessInstanceVersionCommand nodeNameMapping(Map<String, String> nameMapping)
- {
+ public ChangeProcessInstanceVersionCommand nodeNameMapping(Map nameMapping) {
setNodeNameMapping(nameMapping);
return this;
}
- public ChangeProcessInstanceVersionCommand newVersion(int newVersion)
- {
+ public ChangeProcessInstanceVersionCommand newVersion(int newVersion) {
setNewVersion(newVersion);
return this;
}
- public ChangeProcessInstanceVersionCommand taskNameMapping(Map<String, String> nameMapping)
- {
+ public ChangeProcessInstanceVersionCommand taskNameMapping(Map nameMapping) {
setTaskNameMapping(nameMapping);
return this;
- }
-
- public ChangeProcessInstanceVersionCommand nodeNameMappingAdd(String oldNodeName, String newNodeName)
- {
+ }
+
+ public ChangeProcessInstanceVersionCommand nodeNameMappingAdd(String oldNodeName,
+ String newNodeName) {
if (nodeNameMapping == null) {
- this.nodeNameMapping = new HashMap<String, String>();
+ this.nodeNameMapping = new HashMap();
}
-
+
this.nodeNameMapping.put(oldNodeName, newNodeName);
return this;
}
- public ChangeProcessInstanceVersionCommand taskNameMappingAdd(String oldTaskName, String newNodeName)
- {
+ public ChangeProcessInstanceVersionCommand taskNameMappingAdd(String oldTaskName,
+ String newNodeName) {
if (taskNameMapping == null) {
- this.taskNameMapping = new HashMap<String, String>();
+ this.taskNameMapping = new HashMap();
}
-
+
this.taskNameMapping.put(oldTaskName, newNodeName);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CompositeCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CompositeCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/CompositeCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -7,32 +7,27 @@
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
+import org.jbpm.util.ClassUtil;
-public class CompositeCommand implements Command
-{
+public class CompositeCommand implements Command {
private static final long serialVersionUID = 1L;
List commands = null;
- public CompositeCommand(List commands)
- {
+ public CompositeCommand(List commands) {
this.commands = commands;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
List results = null;
- if (commands != null)
- {
+ if (commands != null) {
Object lastResult = null;
results = new ArrayList(commands.size());
Iterator iter = commands.iterator();
- while (iter.hasNext())
- {
- Command command = (Command)iter.next();
- if (lastResult != null)
- {
+ while (iter.hasNext()) {
+ Command command = (Command) iter.next();
+ if (lastResult != null) {
tryToInject(lastResult, command);
}
lastResult = command.execute(jbpmContext);
@@ -42,33 +37,27 @@
return results;
}
- protected void tryToInject(Object lastResult, Command command)
- {
+ protected void tryToInject(Object lastResult, Command command) {
Field field = findField(lastResult.getClass());
- if (field != null)
- {
+ if (field != null) {
field.setAccessible(true);
- try
- {
+ try {
field.set(command, lastResult);
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw new JbpmException("couldn't propagate composite command context", e);
}
}
}
- protected Field findField(Class clazz)
- {
+ protected Field findField(Class clazz) {
Field field = null;
int i = 0;
Field[] fields = clazz.getDeclaredFields();
- while ((i < fields.length) && (field == null))
- {
+ while ((i < fields.length) && (field == null)) {
Field candidate = fields[i];
- if ((candidate.getType().isAssignableFrom(clazz)) && (candidate.getName().startsWith("previous")))
- {
+ if ((candidate.getType().isAssignableFrom(clazz))
+ && (candidate.getName().startsWith("previous"))) {
field = candidate;
}
i++;
@@ -76,10 +65,8 @@
return field;
}
- @Override
- public String toString()
- {
- return this.getClass().getSimpleName() + " consists of (" + commands + ")";
+ public String toString() {
+ return ClassUtil.getSimpleName(getClass()) + commands;
}
-
+
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -22,57 +22,49 @@
package org.jbpm.command;
import org.jbpm.JbpmContext;
+import org.jbpm.util.ClassUtil;
/**
* Delete a proces definition by ID
*
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
-public class DeleteProcessDefinitionCommand extends AbstractGetObjectBaseCommand
-{
+public class DeleteProcessDefinitionCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -1908847549444051495L;
private long id;
- public DeleteProcessDefinitionCommand()
- {
+ public DeleteProcessDefinitionCommand() {
}
- public DeleteProcessDefinitionCommand(long id)
- {
+ public DeleteProcessDefinitionCommand(long id) {
super();
this.id = id;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(id);
return Boolean.TRUE;
}
- @Override
- public String toString()
- {
- return this.getClass().getSimpleName() + " [processDefinition.id=" + id + "]";
+ public String toString() {
+ return ClassUtil.getSimpleName(getClass()) + " [processDefinition.id=" + id + "]";
}
- public long getId()
- {
+ public long getId() {
return id;
}
- public void setId(long id)
- {
+ public void setId(long id) {
this.id = id;
}
-
+
// methods for fluent programming
- public DeleteProcessDefinitionCommand id(long id)
- {
+ public DeleteProcessDefinitionCommand id(long id) {
setId(id);
return this;
}
-
+
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -7,8 +7,7 @@
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetProcessDefinitionCommand extends AbstractGetObjectBaseCommand
-{
+public class GetProcessDefinitionCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -1908847549444051495L;
@@ -16,69 +15,58 @@
private String name;
- public GetProcessDefinitionCommand()
- {
+ public GetProcessDefinitionCommand() {
}
- public GetProcessDefinitionCommand(String name)
- {
+ public GetProcessDefinitionCommand(String name) {
super();
this.name = name;
}
- public GetProcessDefinitionCommand(String name, int version)
- {
+ public GetProcessDefinitionCommand(String name, int version) {
super();
this.version = version;
this.name = name;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
if (version >= 0)
- return retrieveProcessDefinition(jbpmContext.getGraphSession().findProcessDefinition(name, version));
+ return retrieveProcessDefinition(jbpmContext.getGraphSession().findProcessDefinition(name,
+ version));
else
- return retrieveProcessDefinition(jbpmContext.getGraphSession().findLatestProcessDefinition(name));
+ return retrieveProcessDefinition(jbpmContext.getGraphSession().findLatestProcessDefinition(
+ name));
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
- public int getVersion()
- {
+ public int getVersion() {
return version;
}
- public void setVersion(int version)
- {
+ public void setVersion(int version) {
this.version = version;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return "name=" + name
- + ";version=" + version;
- }
-
+ public String getAdditionalToStringInformation() {
+ return "name=" + name + ";version=" + version;
+ }
+
// methods for fluent programming
- public GetProcessDefinitionCommand version(int version)
- {
+ public GetProcessDefinitionCommand version(int version) {
setVersion(version);
return this;
}
-
- public GetProcessDefinitionCommand name(String name)
- {
+
+ public GetProcessDefinitionCommand name(String name) {
setName(name);
- return this;
+ return this;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -11,60 +11,51 @@
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetProcessDefinitionsCommand extends AbstractGetObjectBaseCommand
-{
+public class GetProcessDefinitionsCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -1908847549444051495L;
private boolean onlyLatest = true;
- public GetProcessDefinitionsCommand()
- {
+ public GetProcessDefinitionsCommand() {
}
- public GetProcessDefinitionsCommand(boolean onlyLatest)
- {
+ public GetProcessDefinitionsCommand(boolean onlyLatest) {
this.onlyLatest = onlyLatest;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
setJbpmContext(jbpmContext);
- List result = (onlyLatest ? jbpmContext.getGraphSession().findLatestProcessDefinitions() : jbpmContext.getGraphSession().findAllProcessDefinitions());
+ List result = (onlyLatest ? jbpmContext.getGraphSession().findLatestProcessDefinitions()
+ : jbpmContext.getGraphSession().findAllProcessDefinitions());
/*
* traverse and access property if it is missing in the default fetchgroup
*/
Iterator iter = result.iterator();
- while (iter.hasNext())
- {
- ProcessDefinition pd = (ProcessDefinition)iter.next();
+ while (iter.hasNext()) {
+ ProcessDefinition pd = (ProcessDefinition) iter.next();
retrieveProcessDefinition(pd);
}
return result;
}
- public boolean isOnlyLatest()
- {
+ public boolean isOnlyLatest() {
return onlyLatest;
}
- public void setOnlyLatest(boolean onlyLatest)
- {
+ public void setOnlyLatest(boolean onlyLatest) {
this.onlyLatest = onlyLatest;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
+
+ public String getAdditionalToStringInformation() {
return "onlyLatest=" + onlyLatest;
}
// methods for fluent programming
- public GetProcessDefinitionsCommand onlyLatest(boolean onlyLatest)
- {
+ public GetProcessDefinitionsCommand onlyLatest(boolean onlyLatest) {
setOnlyLatest(onlyLatest);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,13 +4,12 @@
import org.jbpm.graph.exe.ProcessInstance;
/**
- * This command can retrieve the matching process instances (e.g. for admin client) with the given process-id, token id
- * or task-id
+ * This command can retrieve the matching process instances (e.g. for admin client) with the given
+ * process-id, token id or task-id
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetProcessInstanceCommand extends AbstractGetObjectBaseCommand
-{
+public class GetProcessInstanceCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -8436697080972165601L;
@@ -20,23 +19,20 @@
private long taskInstanceId;
- public GetProcessInstanceCommand()
- {
+ public GetProcessInstanceCommand() {
}
- public GetProcessInstanceCommand(long processInstanceId)
- {
+ public GetProcessInstanceCommand(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- public GetProcessInstanceCommand(long processInstanceId, boolean includeVariables, boolean includeLogs)
- {
+ public GetProcessInstanceCommand(long processInstanceId, boolean includeVariables,
+ boolean includeLogs) {
super(true, true);
this.processInstanceId = processInstanceId;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
setJbpmContext(jbpmContext);
ProcessInstance processInstance = null;
@@ -47,67 +43,58 @@
else if (taskInstanceId != 0)
processInstance = jbpmContext.getTaskInstance(taskInstanceId).getProcessInstance();
- if (processInstance != null)
- {
+ if (processInstance != null) {
processInstance = retrieveProcessInstance(processInstance);
}
return processInstance;
}
- public long getProcessInstanceId()
- {
+ public long getProcessInstanceId() {
return processInstanceId;
}
- public void setProcessInstanceId(long processInstanceId)
- {
+ public void setProcessInstanceId(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public long getTokenId()
- {
+ public long getTokenId() {
return tokenId;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.tokenId = tokenId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return "processInstanceId=" + processInstanceId
- + ";tokenId=" + tokenId
- + ";taskInstanceId=" + taskInstanceId;
+ public String getAdditionalToStringInformation() {
+ return "processInstanceId="
+ + processInstanceId
+ + ";tokenId="
+ + tokenId
+ + ";taskInstanceId="
+ + taskInstanceId;
}
// methods for fluent programming
- public GetProcessInstanceCommand processInstanceId(long processInstanceId)
- {
+ public GetProcessInstanceCommand processInstanceId(long processInstanceId) {
setProcessInstanceId(processInstanceId);
return this;
}
- public GetProcessInstanceCommand taskInstanceId(long taskInstanceId)
- {
+ public GetProcessInstanceCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
- public GetProcessInstanceCommand tokenId(long tokenId)
- {
+ public GetProcessInstanceCommand tokenId(long tokenId) {
setTokenId(tokenId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -9,54 +9,43 @@
import org.jbpm.logging.log.ProcessLog;
/**
- * Retrieve the <code>org.jbpm.logging.log.ProcessLog</code> for
- * the process with the given process-id
+ * Retrieve the <code>org.jbpm.logging.log.ProcessLog</code> for the process with the given
+ * process-id returns a map that maps {@link Token}s to {@link List}s.
*
- * returns a map that maps {@link Token}s to {@link List}s.
- *
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
- *
*/
-public class GetProcessInstanceLogCommand extends AbstractBaseCommand
-{
+public class GetProcessInstanceLogCommand extends AbstractBaseCommand {
private static final long serialVersionUID = -2812852941518870502L;
private long processInstanceId;
- public GetProcessInstanceLogCommand()
- {
+ public GetProcessInstanceLogCommand() {
}
- public GetProcessInstanceLogCommand(long processInstanceId)
- {
+ public GetProcessInstanceLogCommand(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
Map logMap = jbpmContext.getLoggingSession().findLogsByProcessInstance(processInstanceId);
return loadLogdFromMap(logMap);
}
/**
- * access everything on all ProcessLog objects, which is not in the default fetch group from hibernate, but needs to
- * be accesible from the client
- *
- * overwrite this method, if you need more details in your client
+ * access everything on all ProcessLog objects, which is not in the default fetch group from
+ * hibernate, but needs to be accesible from the client overwrite this method, if you need more
+ * details in your client
*/
- protected Map loadLogdFromMap(Map logMap)
- {
+ protected Map loadLogdFromMap(Map logMap) {
Iterator iter = logMap.keySet().iterator();
- while (iter.hasNext())
- {
- Token t = (Token)iter.next();
+ while (iter.hasNext()) {
+ Token t = (Token) iter.next();
- List logs = (List)logMap.get(t);
+ List logs = (List) logMap.get(t);
Iterator iter2 = logs.iterator();
- while (iter2.hasNext())
- {
- ProcessLog pl = (ProcessLog)iter2.next();
+ while (iter2.hasNext()) {
+ ProcessLog pl = (ProcessLog) iter2.next();
// TODO: I am not sure if we need that, write a test for it
pl.getActorId();
pl.toString();
@@ -68,39 +57,32 @@
/**
* @deprecated use getProcessInstanceId instead
*/
- public long getProcessId()
- {
+ public long getProcessId() {
return processInstanceId;
}
/**
* @deprecated use setProcessInstanceId instead
*/
- public void setProcessId(long processId)
- {
+ public void setProcessId(long processId) {
this.processInstanceId = processId;
}
- public long getProcessInstanceId()
- {
+ public long getProcessInstanceId() {
return processInstanceId;
}
- public void setProcessInstanceId(long processInstanceId)
- {
+ public void setProcessInstanceId(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
+ public String getAdditionalToStringInformation() {
return "processInstanceId=" + processInstanceId;
}
-
+
// methods for fluent programming
-
- public GetProcessInstanceLogCommand processInstanceId(long processInstanceId)
- {
+
+ public GetProcessInstanceLogCommand processInstanceId(long processInstanceId) {
setProcessInstanceId(processInstanceId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,18 +5,17 @@
import java.util.List;
import org.hibernate.Query;
+
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
/**
- * This command can retrieve all process instances (e.g. for admin client).
+ * This command can retrieve all process instances (e.g. for admin client). You have the possibility
+ * to filter the command, therefor use the available attributes
*
- * You have the possibility to filter the command, therefor use the available attributes
- *
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetProcessInstancesCommand extends AbstractGetObjectBaseCommand
-{
+public class GetProcessInstancesCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -5601050489405283851L;
@@ -50,54 +49,46 @@
private transient boolean firstExpression = true;
- private String getConcatExpression()
- {
- if (firstExpression)
- {
+ private String getConcatExpression() {
+ if (firstExpression) {
firstExpression = false;
return " where ";
}
return " and ";
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
setJbpmContext(jbpmContext);
firstExpression = true;
- StringBuffer queryText = new StringBuffer("select pi" + " from org.jbpm.graph.exe.ProcessInstance as pi ");
+ StringBuffer queryText = new StringBuffer("select pi"
+ + " from org.jbpm.graph.exe.ProcessInstance as pi ");
- if (onlyRunning)
- {
+ if (onlyRunning) {
queryText.append(getConcatExpression()).append(" pi.end = null");
}
- if (fromStartDate != null)
- {
+ if (fromStartDate != null) {
queryText.append(getConcatExpression()).append(" pi.start >= :from ");
}
- if (untilStartDate != null)
- {
+ if (untilStartDate != null) {
queryText.append(getConcatExpression()).append(" pi.start <= :until ");
}
- if (version != null)
- {
+ if (version != null) {
queryText.append(getConcatExpression()).append(" pi.version = :version ");
}
// name
- if (processInstanceId != -1)
- {
+ if (processInstanceId != -1) {
queryText.append(getConcatExpression()).append(" pi.processDefinition.id = :processId ");
}
- else if (processDefinitionName != null && processDefinitionName.length() > 0)
- {
- queryText.append(getConcatExpression()).append(" pi.processDefinition.name = :processDefinitionName ");
+ else if (processDefinitionName != null && processDefinitionName.length() > 0) {
+ queryText.append(getConcatExpression()).append(
+ " pi.processDefinition.name = :processDefinitionName ");
}
// TODO: this code only fecthes root tokens, child-tokens has to be
// considered too!
- if (stateName != null && stateName.length() > 0)
- {
+ if (stateName != null && stateName.length() > 0) {
queryText.append(getConcatExpression()).append(" pi.rootToken.node.name = :nodeName ");
}
@@ -105,31 +96,25 @@
Query query = jbpmContext.getSession().createQuery(queryText.toString());
- if (fromStartDate != null)
- {
+ if (fromStartDate != null) {
query.setTimestamp("from", fromStartDate);
}
- if (untilStartDate != null)
- {
+ if (untilStartDate != null) {
query.setTimestamp("until", untilStartDate);
}
- if (processInstanceId != -1)
- {
+ if (processInstanceId != -1) {
query.setLong("processId", processInstanceId);
}
- if (processDefinitionName != null && processDefinitionName.length() > 0)
- {
+ if (processDefinitionName != null && processDefinitionName.length() > 0) {
query.setString("processDefinitionName", processDefinitionName);
}
- if (stateName != null && stateName.length() > 0)
- {
+ if (stateName != null && stateName.length() > 0) {
query.setString("nodeName", stateName);
}
- if (version != null)
- {
+ if (version != null) {
query.setString("version", version);
}
@@ -137,175 +122,152 @@
}
/**
- * access everything on all processInstance objects, which is not in the default fetch group from hibernate, but needs
- * to be accesible from the client
- *
- * overwrite this, if you need more details in your client
+ * access everything on all processInstance objects, which is not in the default fetch group from
+ * hibernate, but needs to be accesible from the client overwrite this, if you need more details
+ * in your client
*/
- public List retrieveProcessInstanceDetails(List processInstanceList)
- {
+ public List retrieveProcessInstanceDetails(List processInstanceList) {
Iterator it = processInstanceList.iterator();
- while (it.hasNext())
- {
- retrieveProcessInstance((ProcessInstance)it.next());
+ while (it.hasNext()) {
+ retrieveProcessInstance((ProcessInstance) it.next());
}
return processInstanceList;
}
- public Date getFromStartDate()
- {
+ public Date getFromStartDate() {
return fromStartDate;
}
- public void setFromStartDate(Date fromStartDate)
- {
+ public void setFromStartDate(Date fromStartDate) {
this.fromStartDate = fromStartDate;
}
- public boolean isOnlyRunning()
- {
+ public boolean isOnlyRunning() {
return onlyRunning;
}
- public void setOnlyRunning(boolean onlyRunning)
- {
+ public void setOnlyRunning(boolean onlyRunning) {
this.onlyRunning = onlyRunning;
}
/**
* @deprecated
*/
- public String getProcessName()
- {
+ public String getProcessName() {
return processDefinitionName;
}
/**
* @deprecated
*/
- public void setProcessName(String processName)
- {
+ public void setProcessName(String processName) {
this.processDefinitionName = processName;
}
- public String getProcessDefinitionName()
- {
+ public String getProcessDefinitionName() {
return processDefinitionName;
}
- public void setProcessDefinitionName(String processName)
- {
+ public void setProcessDefinitionName(String processName) {
this.processDefinitionName = processName;
}
- public String getStateName()
- {
+ public String getStateName() {
return stateName;
}
- public void setStateName(String stateName)
- {
+ public void setStateName(String stateName) {
this.stateName = stateName;
}
- public Date getUntilStartDate()
- {
+ public Date getUntilStartDate() {
return untilStartDate;
}
- public void setUntilStartDate(Date untilStartDate)
- {
+ public void setUntilStartDate(Date untilStartDate) {
this.untilStartDate = untilStartDate;
}
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
- public void setVersion(String version)
- {
+ public void setVersion(String version) {
this.version = version;
}
- public long getProcessInstanceId()
- {
+ public long getProcessInstanceId() {
return processInstanceId;
}
- public void setProcessInstanceId(long processId)
- {
+ public void setProcessInstanceId(long processId) {
this.processInstanceId = processId;
}
/**
* @deprecated
*/
- public long getProcessId()
- {
+ public long getProcessId() {
return processInstanceId;
}
/**
* @deprecated
*/
- public void setProcessId(long processId)
- {
+ public void setProcessId(long processId) {
this.processInstanceId = processId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return "processInstanceId=" + processInstanceId
- + ";processDefinitionName=" + processDefinitionName
- + ";version=" + version
- + ";stateName=" + stateName
- + ";fromStartDate=" + fromStartDate
- + ";untilStartDate=" + untilStartDate
- + ";onlyRunning=" + onlyRunning;
+ public String getAdditionalToStringInformation() {
+ return "processInstanceId="
+ + processInstanceId
+ + ";processDefinitionName="
+ + processDefinitionName
+ + ";version="
+ + version
+ + ";stateName="
+ + stateName
+ + ";fromStartDate="
+ + fromStartDate
+ + ";untilStartDate="
+ + untilStartDate
+ + ";onlyRunning="
+ + onlyRunning;
}
-
+
// methods for fluent programming
- public GetProcessInstancesCommand fromStartDate(Date fromStartDate)
- {
+ public GetProcessInstancesCommand fromStartDate(Date fromStartDate) {
setFromStartDate(fromStartDate);
return this;
}
- public GetProcessInstancesCommand onlyRunning(boolean onlyRunning)
- {
+ public GetProcessInstancesCommand onlyRunning(boolean onlyRunning) {
setOnlyRunning(onlyRunning);
return this;
}
- public GetProcessInstancesCommand processDefinitionName(String processName)
- {
+ public GetProcessInstancesCommand processDefinitionName(String processName) {
setProcessDefinitionName(processName);
return this;
}
- public GetProcessInstancesCommand stateName(String stateName)
- {
+ public GetProcessInstancesCommand stateName(String stateName) {
setStateName(stateName);
return this;
}
- public GetProcessInstancesCommand untilStartDate(Date untilStartDate)
- {
+ public GetProcessInstancesCommand untilStartDate(Date untilStartDate) {
setUntilStartDate(untilStartDate);
return this;
}
- public GetProcessInstancesCommand version(String version)
- {
+ public GetProcessInstancesCommand version(String version) {
setVersion(version);
return this;
}
- public GetProcessInstancesCommand processInstanceId(long processId)
- {
+ public GetProcessInstancesCommand processInstanceId(long processId) {
setProcessInstanceId(processId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -7,13 +7,12 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
/**
- * This command can retrieve a task instance (for client) with the given task-id or the token-id (then, the first task
- * for the token is searched)
+ * This command can retrieve a task instance (for client) with the given task-id or the token-id
+ * (then, the first task for the token is searched)
*
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetTaskInstanceCommand extends AbstractGetObjectBaseCommand
-{
+public class GetTaskInstanceCommand extends AbstractGetObjectBaseCommand {
private static final long serialVersionUID = -8436697080972165601L;
@@ -30,63 +29,51 @@
private long processInstanceId;
/**
- * NOT YET USED! JUST TO DOCUMENT THE IDEA...
- *
- * result of the Command: a gui element, configured via the TaskController. Can be used to identify a Swing-Class,
- * JSF-Site, ...
+ * NOT YET USED! JUST TO DOCUMENT THE IDEA... result of the Command: a gui element, configured via
+ * the TaskController. Can be used to identify a Swing-Class, JSF-Site, ...
*/
private String configuredGuiElement;
- public GetTaskInstanceCommand()
- {
+ public GetTaskInstanceCommand() {
}
- public GetTaskInstanceCommand(long taskInstanceId)
- {
+ public GetTaskInstanceCommand(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public GetTaskInstanceCommand(long taskInstanceId, boolean includeVariables, boolean includeLogs)
- {
+ public GetTaskInstanceCommand(long taskInstanceId, boolean includeVariables, boolean includeLogs) {
super(includeVariables, includeLogs);
this.taskInstanceId = taskInstanceId;
}
- public GetTaskInstanceCommand(long taskInstanceId, String[] variablesToInclude)
- {
+ public GetTaskInstanceCommand(long taskInstanceId, String[] variablesToInclude) {
super(variablesToInclude);
this.taskInstanceId = taskInstanceId;
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
- if (taskInstanceId > 0)
- {
+ if (taskInstanceId > 0) {
TaskInstance taskInstance = jbpmContext.getTaskInstance(taskInstanceId);
- if (taskInstance != null)
- {
+ if (taskInstance != null) {
retrieveTaskInstanceDetails(taskInstance);
}
return taskInstance;
}
- else if (tokenId > 0)
- {
+ else if (tokenId > 0) {
List result = jbpmContext.getTaskMgmtSession().findTaskInstancesByToken(tokenId);
- for (Iterator iter = result.iterator(); iter.hasNext();)
- {
- TaskInstance ti = (TaskInstance)iter.next();
+ for (Iterator iter = result.iterator(); iter.hasNext();) {
+ TaskInstance ti = (TaskInstance) iter.next();
retrieveTaskInstanceDetails(ti);
}
return result;
}
- else if (processInstanceId > 0)
- {
- List result = jbpmContext.getTaskMgmtSession().findTaskInstancesByProcessInstance(jbpmContext.getProcessInstance(processInstanceId));
- for (Iterator iter = result.iterator(); iter.hasNext();)
- {
- TaskInstance ti = (TaskInstance)iter.next();
+ else if (processInstanceId > 0) {
+ List result = jbpmContext.getTaskMgmtSession().findTaskInstancesByProcessInstance(
+ jbpmContext.getProcessInstance(processInstanceId));
+ for (Iterator iter = result.iterator(); iter.hasNext();) {
+ TaskInstance ti = (TaskInstance) iter.next();
retrieveTaskInstanceDetails(ti);
}
return result;
@@ -95,60 +82,52 @@
return null;
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public long getTokenId()
- {
+ public long getTokenId() {
return tokenId;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.tokenId = tokenId;
}
- public long getProcessInstanceId()
- {
+ public long getProcessInstanceId() {
return processInstanceId;
}
- public void setProcessInstanceId(long processInstanceId)
- {
+ public void setProcessInstanceId(long processInstanceId) {
this.processInstanceId = processInstanceId;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return "processInstanceId=" + processInstanceId
- + ";tokenId=" + tokenId
- + ";taskInstanceId=" + taskInstanceId;
+ public String getAdditionalToStringInformation() {
+ return "processInstanceId="
+ + processInstanceId
+ + ";tokenId="
+ + tokenId
+ + ";taskInstanceId="
+ + taskInstanceId;
}
-
+
// methods for fluent programming
- public GetTaskInstanceCommand taskInstanceId(long taskInstanceId)
- {
+ public GetTaskInstanceCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
- public GetTaskInstanceCommand tokenId(long tokenId)
- {
+ public GetTaskInstanceCommand tokenId(long tokenId) {
setTokenId(tokenId);
- return this;
+ return this;
}
- public GetTaskInstanceCommand processInstanceId(long processInstanceId)
- {
+ public GetTaskInstanceCommand processInstanceId(long processInstanceId) {
setProcessInstanceId(processInstanceId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -7,20 +7,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.util.ArrayUtil;
/**
- * return a {@link java.util.List} of {@link org.jbpm.taskmgmt.exe.TaskInstance}s for the given actor(s).
+ * return a {@link java.util.List} of {@link org.jbpm.taskmgmt.exe.TaskInstance}s for the given
+ * actor(s). if no actor is used, the current authenticated user is taken as actor. for all actors
+ * it is checked, if they are pooled or assigned actor!
*
- * if no actor is used, the current authenticated user is taken as actor.
- *
- * for all actors it is checked, if they are pooled or assigned actor!
- *
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class GetTaskListCommand extends AbstractGetObjectBaseCommand implements Command
-{
+public class GetTaskListCommand extends AbstractGetObjectBaseCommand implements Command {
private static final long serialVersionUID = -1627380259541998349L;
@@ -28,34 +27,28 @@
private String[] actor;
- public GetTaskListCommand(String[] actor)
- {
+ public GetTaskListCommand(String[] actor) {
setActor(actor);
}
- public GetTaskListCommand(String actor, boolean includeVariables)
- {
+ public GetTaskListCommand(String actor, boolean includeVariables) {
super(includeVariables, false);
setActor(actor);
}
- public GetTaskListCommand(String actor, String[] variablesToInclude)
- {
+ public GetTaskListCommand(String actor, String[] variablesToInclude) {
super(variablesToInclude);
setActor(actor);
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
setJbpmContext(jbpmContext);
List result = null;
if (actor == null || actor.length == 0)
result = jbpmContext.getTaskList();
- else
- {
+ else {
result = new ArrayList();
- for (int i = 0; i < actor.length; i++)
- {
+ for (int i = 0; i < actor.length; i++) {
result.addAll(jbpmContext.getTaskList(actor[i]));
}
result.addAll(jbpmContext.getGroupTaskList(Arrays.asList(actor)));
@@ -65,51 +58,41 @@
}
/**
- * access everything on all TaskInstance objects, which is not in the default fetch group from hibernate, but needs to
- * be accesible from the client
- *
- * overwrite this, if you need more details in your client
+ * access everything on all TaskInstance objects, which is not in the default fetch group from
+ * hibernate, but needs to be accesible from the client overwrite this, if you need more details
+ * in your client
*/
- public List retrieveTaskInstanceDetails(List taskInstanceList)
- {
- for (Iterator iter = taskInstanceList.iterator(); iter.hasNext();)
- {
- retrieveTaskInstanceDetails((TaskInstance)iter.next());
+ public List retrieveTaskInstanceDetails(List taskInstanceList) {
+ for (Iterator iter = taskInstanceList.iterator(); iter.hasNext();) {
+ retrieveTaskInstanceDetails((TaskInstance) iter.next());
}
return taskInstanceList;
}
- public String[] getActor()
- {
+ public String[] getActor() {
return actor;
}
- public void setActor(String actor)
- {
+ public void setActor(String actor) {
this.actor = new String[] { actor };
}
- public void setActor(String[] actor)
- {
+ public void setActor(String[] actor) {
this.actor = actor;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
- return "actors=" + Arrays.toString( actor );
+
+ public String getAdditionalToStringInformation() {
+ return "actors=" + ArrayUtil.toString(actor);
}
// methods for fluent programming
- public GetTaskListCommand actor(String actor)
- {
+ public GetTaskListCommand actor(String actor) {
this.actor = new String[] { actor };
return this;
}
- public GetTaskListCommand actor(String[] actor)
- {
+ public GetTaskListCommand actor(String[] actor) {
this.actor = actor;
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,14 +30,13 @@
import org.jbpm.graph.exe.ProcessInstance;
/**
- * Graph command to start a new process and create a task instance if the start node has a start task definition.
+ * Graph command to start a new process and create a task instance if the start node has a start
+ * task definition. The result of this command, if requested, is a {@link Long} value containing the
+ * process instance id.
*
- * The result of this command, if requested, is a {@link Long} value containing the process instance id.
- *
* @author Jim Rigsbee, Tom Baeyens, Bernd Ruecker
*/
-public class NewProcessInstanceCommand extends AbstractBaseCommand
-{
+public class NewProcessInstanceCommand extends AbstractBaseCommand {
private static final long serialVersionUID = 1L;
@@ -52,12 +51,10 @@
private String key;
- public NewProcessInstanceCommand()
- {
+ public NewProcessInstanceCommand() {
}
- public NewProcessInstanceCommand(String processDefinitionName)
- {
+ public NewProcessInstanceCommand(String processDefinitionName) {
this.processDefinitionName = processDefinitionName;
}
@@ -66,47 +63,39 @@
*
* @throws Exception
*/
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
- if (actorId != null)
- {
+ if (actorId != null) {
jbpmContext.setActorId(actorId);
}
ProcessInstance processInstance = null;
- if (processDefinitionName != null)
- {
+ if (processDefinitionName != null) {
processInstance = jbpmContext.newProcessInstance(processDefinitionName);
}
- else
- {
- ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId);
+ else {
+ ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(
+ processDefinitionId);
processInstance = new ProcessInstance(processDefinition);
}
- if (key != null)
- {
+ if (key != null) {
processInstance.setKey(key);
}
Object result = null;
- if (createStartTask)
- {
+ if (createStartTask) {
result = processInstance.getTaskMgmtInstance().createStartTaskInstance();
}
- else
- {
+ else {
result = processInstance;
}
- if (variables != null)
- {
+ if (variables != null) {
ContextInstance contextInstance = processInstance.getContextInstance();
Iterator iter = variables.keySet().iterator();
- while (iter.hasNext())
- {
- String variableName = (String)iter.next();
+ while (iter.hasNext()) {
+ String variableName = (String) iter.next();
contextInstance.setVariable(variableName, variables.get(variableName));
}
}
@@ -116,142 +105,124 @@
return result;
}
- public String getActorId()
- {
+ public String getActorId() {
return actorId;
}
- public void setActorId(String actorId)
- {
+ public void setActorId(String actorId) {
this.actorId = actorId;
}
- public long getProcessDefinitionId()
- {
+ public long getProcessDefinitionId() {
return processDefinitionId;
}
- public void setProcessDefinitionId(long processId)
- {
+ public void setProcessDefinitionId(long processId) {
this.processDefinitionId = processId;
}
/**
* @deprecated use getProcessDefinitionId instead
*/
- public long getProcessId()
- {
+ public long getProcessId() {
return processDefinitionId;
}
/**
* @deprecated use setProcessDefinitionId instead
*/
- public void setProcessId(long processId)
- {
+ public void setProcessId(long processId) {
this.processDefinitionId = processId;
}
/**
* @deprecated use getProcessDefinitionName instead
*/
- public String getProcessName()
- {
+ public String getProcessName() {
return processDefinitionName;
}
/**
* @deprecated use setProcessDefinitionName instead
*/
- public void setProcessName(String processName)
- {
+ public void setProcessName(String processName) {
this.processDefinitionName = processName;
}
-
- public boolean isCreateStartTask()
- {
+
+ public boolean isCreateStartTask() {
return createStartTask;
}
- public void setCreateStartTask(boolean createStartTask)
- {
+ public void setCreateStartTask(boolean createStartTask) {
this.createStartTask = createStartTask;
}
- public Map getVariables()
- {
+ public Map getVariables() {
return variables;
}
- public String getProcessDefinitionName()
- {
+
+ public String getProcessDefinitionName() {
return processDefinitionName;
}
- public void setProcessDefinitionName(String processDefinitionName)
- {
+ public void setProcessDefinitionName(String processDefinitionName) {
this.processDefinitionName = processDefinitionName;
}
-
- public void setVariables(Map variables)
- {
+
+ public void setVariables(Map variables) {
this.variables = variables;
}
- public String getKey()
- {
+ public String getKey() {
return key;
}
- public void setKey(String key)
- {
+ public void setKey(String key) {
this.key = key;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
- return "processDefinitionId=" + processDefinitionId
- + ";processDefinitionName=" + processDefinitionName
- + ";createStartTask=" + createStartTask
- + ";businessKey=" + key
- // TODO: not sure how this is
- + ";variables=" + variables;
+
+ public String getAdditionalToStringInformation() {
+ return "processDefinitionId="
+ + processDefinitionId
+ + ";processDefinitionName="
+ + processDefinitionName
+ + ";createStartTask="
+ + createStartTask
+ + ";businessKey="
+ + key
+ // TODO: not sure how this is
+ + ";variables="
+ + variables;
}
-
+
// methods for fluent programming
-
- public NewProcessInstanceCommand actorId(String actorId)
- {
+
+ public NewProcessInstanceCommand actorId(String actorId) {
setActorId(actorId);
return this;
}
- public NewProcessInstanceCommand processDefinitionId(long processId)
- {
+ public NewProcessInstanceCommand processDefinitionId(long processId) {
setProcessDefinitionId(processId);
return this;
}
- public NewProcessInstanceCommand processDefinitionName(String processName)
- {
+ public NewProcessInstanceCommand processDefinitionName(String processName) {
setProcessDefinitionName(processName);
return this;
}
- public NewProcessInstanceCommand createStartTask(boolean createStartTask)
- {
+ public NewProcessInstanceCommand createStartTask(boolean createStartTask) {
setCreateStartTask(createStartTask);
return this;
}
- public NewProcessInstanceCommand variables(Map variables)
- {
+ public NewProcessInstanceCommand variables(Map variables) {
setVariables(variables);
return this;
}
- public NewProcessInstanceCommand key(String key)
- {
+ public NewProcessInstanceCommand key(String key) {
setKey(key);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,18 +4,16 @@
/**
* Resume the specified {@link ProcessInstance}(s). See {@link AbstractProcessInstanceBaseCommand}
- * to check possibilities to specify {@link ProcessInstance}(s).
+ * to check possibilities to specify {@link ProcessInstance}(s).
*
* @author bernd.ruecker at camunda.com
*/
public class ResumeProcessInstanceCommand extends AbstractProcessInstanceBaseCommand {
-
+
private static final long serialVersionUID = 1L;
- @Override
- public ProcessInstance execute(ProcessInstance processInstance)
- {
+ public ProcessInstance execute(ProcessInstance processInstance) {
processInstance.resume();
- return processInstance;
+ return processInstance;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeTokenCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeTokenCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/ResumeTokenCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -3,8 +3,8 @@
import org.jbpm.graph.exe.Token;
/**
- * Resume the specified {@link Token}(s). See {@link AbstractTokenBaseCommand}
- * to check possibilities to specify {@link Token}(s).
+ * Resume the specified {@link Token}(s). See {@link AbstractTokenBaseCommand} to check
+ * possibilities to specify {@link Token}(s).
*
* @author bernd.ruecker at camunda.com
*/
@@ -12,9 +12,7 @@
private static final long serialVersionUID = 1L;
- @Override
- public Token execute(Token token)
- {
+ public Object execute(Token token) {
token.resume();
return token;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SignalCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SignalCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SignalCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.graph.exe.ProcessInstance;
@@ -35,8 +36,7 @@
*
* @author ??, Bernd Ruecker
*/
-public class SignalCommand extends AbstractBaseCommand
-{
+public class SignalCommand extends AbstractBaseCommand {
private static final long serialVersionUID = 1L;
private static Log log = LogFactory.getLog(SignalCommand.class);
@@ -46,7 +46,8 @@
private String transitionName = null;
/**
- * if given, it is checked if the state is as expected. If not, a exception is thrown Ignored if null
+ * if given, it is checked if the state is as expected. If not, a exception is thrown Ignored if
+ * null
*/
private String expectedStateName = null;
@@ -56,138 +57,121 @@
private Map variables;
- public SignalCommand()
- {
+ public SignalCommand() {
}
- public SignalCommand(long tokenId, String transitionName)
- {
+ public SignalCommand(long tokenId, String transitionName) {
this.tokenId = tokenId;
this.transitionName = transitionName;
}
- public Object execute(JbpmContext jbpmContext)
- {
+ public Object execute(JbpmContext jbpmContext) {
log.debug("executing " + this);
- if (previousProcessInstance != null)
- {
+ if (previousProcessInstance != null) {
if (variables != null && variables.size() > 0)
previousProcessInstance.getContextInstance().addVariables(variables);
- if (transitionName == null)
- {
+ if (transitionName == null) {
previousProcessInstance.signal();
}
- else
- {
+ else {
previousProcessInstance.signal(transitionName);
}
return previousProcessInstance.getRootToken();
}
- else
- {
+ else {
Token token = getToken(jbpmContext);
if (expectedStateName != null && !expectedStateName.equals(token.getNode().getName()))
- throw new JbpmException("token is not in expected state '" + expectedStateName + "' but in '" + token.getNode().getName() + "'");
+ throw new JbpmException("token is not in expected state '"
+ + expectedStateName
+ + "' but in '"
+ + token.getNode().getName()
+ + "'");
if (variables != null && variables.size() > 0)
token.getProcessInstance().getContextInstance().addVariables(variables);
- if (transitionName == null)
- {
+ if (transitionName == null) {
token.signal();
}
- else
- {
+ else {
token.signal(transitionName);
}
return token;
}
}
- protected Token getToken(JbpmContext jbpmContext)
- {
- if (previousToken != null)
- {
+ protected Token getToken(JbpmContext jbpmContext) {
+ if (previousToken != null) {
return previousToken;
}
return jbpmContext.loadTokenForUpdate(tokenId);
}
- public long getTokenId()
- {
+ public long getTokenId() {
return tokenId;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.tokenId = tokenId;
}
- public String getTransitionName()
- {
+ public String getTransitionName() {
return transitionName;
}
- public void setTransitionName(String transitionName)
- {
+ public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
}
- public Map getVariables()
- {
+ public Map getVariables() {
return variables;
}
- public void setVariables(Map variables)
- {
+ public void setVariables(Map variables) {
this.variables = variables;
}
- public String getExpectedStateName()
- {
+ public String getExpectedStateName() {
return expectedStateName;
}
- public void setExpectedStateName(String expectedStateName)
- {
+ public void setExpectedStateName(String expectedStateName) {
this.expectedStateName = expectedStateName;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
- return "tokenId=" + tokenId
- + ";transitionName=" + transitionName
- + ";processDefinitionName=" + expectedStateName
- // TODO: not sure how this is
- + ";variables=" + variables;
- }
+ public String getAdditionalToStringInformation() {
+ return "tokenId="
+ + tokenId
+ + ";transitionName="
+ + transitionName
+ + ";processDefinitionName="
+ + expectedStateName
+ // TODO: not sure how this is
+ + ";variables="
+ + variables;
+ }
+
// methods for fluent programming
- public SignalCommand tokenId(long tokenId)
- {
+ public SignalCommand tokenId(long tokenId) {
setTokenId(tokenId);
return this;
}
- public SignalCommand transitionName(String transitionName)
- {
+ public SignalCommand transitionName(String transitionName) {
setTransitionName(transitionName);
return this;
}
- public SignalCommand variables(Map variables)
- {
+ public SignalCommand variables(Map variables) {
setVariables(variables);
return this;
}
- public SignalCommand expectedStateName(String expectedStateName)
- {
+ public SignalCommand expectedStateName(String expectedStateName) {
setExpectedStateName(expectedStateName);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,14 +5,12 @@
/**
* Graph command to start a new process and signal it immidiatly. The transition named in
- * <code>startTransitionName</code> is used (or the default transition if it is null).
+ * <code>startTransitionName</code> is used (or the default transition if it is null). The result of
+ * this command, if requested, is a {@link Long} value containing the process instance id.
*
- * The result of this command, if requested, is a {@link Long} value containing the process instance id.
- *
* @author Jim Rigsbee, Tom Baeyens, Bernd Ruecker
*/
-public class StartProcessInstanceCommand extends NewProcessInstanceCommand implements Command
-{
+public class StartProcessInstanceCommand extends NewProcessInstanceCommand implements Command {
private static final long serialVersionUID = -2428234069404269048L;
@@ -21,12 +19,10 @@
*/
private String startTransitionName = null;
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
Object object = super.execute(jbpmContext);
- if (object instanceof ProcessInstance)
- {
- ProcessInstance processInstance = (ProcessInstance)object;
+ if (object instanceof ProcessInstance) {
+ ProcessInstance processInstance = (ProcessInstance) object;
if (startTransitionName == null || startTransitionName.length() == 0)
processInstance.signal();
else
@@ -35,27 +31,21 @@
return object;
}
- public String getStartTransitionName()
- {
+ public String getStartTransitionName() {
return startTransitionName;
}
- public void setStartTransitionName(String startTransitionName)
- {
+ public void setStartTransitionName(String startTransitionName) {
this.startTransitionName = startTransitionName;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return super.getAdditionalToStringInformation()
- + ";startTransitionName=" + startTransitionName;
- }
-
+ public String getAdditionalToStringInformation() {
+ return super.getAdditionalToStringInformation() + ";startTransitionName=" + startTransitionName;
+ }
+
// methods for fluent programming
- public StartProcessInstanceCommand startTransitionName(String startTransitionName)
- {
+ public StartProcessInstanceCommand startTransitionName(String startTransitionName) {
setStartTransitionName(startTransitionName);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -2,16 +2,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.taskmgmt.exe.TaskInstance;
/**
- * The current authorizes actor starts to work on the TaskInstance so the actor is set to the given actor
+ * The current authorizes actor starts to work on the TaskInstance so the actor is set to the given
+ * actor
*
* @author Bernd Ruecker
*/
-public class StartWorkOnTaskCommand extends AbstractBaseCommand
-{
+public class StartWorkOnTaskCommand extends AbstractBaseCommand {
private static final long serialVersionUID = 53004484398726736L;
@@ -23,23 +24,19 @@
private String actorId;
- public StartWorkOnTaskCommand(long taskInstanceId, boolean overwriteSwimlane)
- {
+ public StartWorkOnTaskCommand(long taskInstanceId, boolean overwriteSwimlane) {
this.taskInstanceId = taskInstanceId;
this.overwriteSwimlane = overwriteSwimlane;
}
- public StartWorkOnTaskCommand()
- {
+ public StartWorkOnTaskCommand() {
}
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
String actor = this.actorId == null ? jbpmContext.getActorId() : this.actorId;
TaskInstance taskInstance = jbpmContext.getTaskInstance(taskInstanceId);
- if (taskInstance.getStart() != null)
- {
+ if (taskInstance.getStart() != null) {
log.warn("Force stop on task " + taskInstance.getId() + ". Will be restarted.");
taskInstance.setStart(null); // strange, but means isNotStarted()
}
@@ -49,60 +46,52 @@
return null;
}
- public boolean isOverwriteSwimlane()
- {
+ public boolean isOverwriteSwimlane() {
return overwriteSwimlane;
}
- public void setOverwriteSwimlane(boolean overwriteSwimlane)
- {
+ public void setOverwriteSwimlane(boolean overwriteSwimlane) {
this.overwriteSwimlane = overwriteSwimlane;
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public void setActorId(String actorId)
- {
+ public void setActorId(String actorId) {
this.actorId = actorId;
}
- public String getActorId()
- {
+ public String getActorId() {
return actorId;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
- return "tokenId=" + taskInstanceId
- + ";transitionName=" + actorId
- + ";processDefinitionName=" + overwriteSwimlane;
+
+ public String getAdditionalToStringInformation() {
+ return "tokenId="
+ + taskInstanceId
+ + ";transitionName="
+ + actorId
+ + ";processDefinitionName="
+ + overwriteSwimlane;
}
-
+
// methods for fluent programming
- public StartWorkOnTaskCommand overwriteSwimlane(boolean overwriteSwimlane)
- {
+ public StartWorkOnTaskCommand overwriteSwimlane(boolean overwriteSwimlane) {
setOverwriteSwimlane(overwriteSwimlane);
return this;
}
- public StartWorkOnTaskCommand taskInstanceId(long taskInstanceId)
- {
+ public StartWorkOnTaskCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
- public StartWorkOnTaskCommand actorId(String actorId)
- {
+ public StartWorkOnTaskCommand actorId(String actorId) {
setActorId(actorId);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendProcessInstanceCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendProcessInstanceCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,20 +5,17 @@
/**
* Suspend the specified {@link ProcessInstance}(s). See {@link AbstractProcessInstanceBaseCommand}
- * to check possibilities to specify {@link ProcessInstance}(s).
+ * to check possibilities to specify {@link ProcessInstance}(s). With filter to all
+ * {@link ProcessDefinition}s this can be used like an emergency shutdown for
+ * {@link ProcessDefinition}s.
*
- * With filter to all {@link ProcessDefinition}s this can be used
- * like an emergency shutdown for {@link ProcessDefinition}s.
- *
* @author bernd.ruecker at camunda.com
*/
public class SuspendProcessInstanceCommand extends AbstractProcessInstanceBaseCommand {
private static final long serialVersionUID = 1L;
- @Override
- public ProcessInstance execute(ProcessInstance processInstance)
- {
+ public ProcessInstance execute(ProcessInstance processInstance) {
processInstance.suspend();
return processInstance;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendTokenCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendTokenCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/SuspendTokenCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -3,8 +3,8 @@
import org.jbpm.graph.exe.Token;
/**
- * Suspend the specified {@link Token}(s). See {@link AbstractTokenBaseCommand}
- * to check possibilities to specify {@link Token}(s).
+ * Suspend the specified {@link Token}(s). See {@link AbstractTokenBaseCommand} to check
+ * possibilities to specify {@link Token}(s).
*
* @author bernd.ruecker at camunda.com
*/
@@ -12,9 +12,7 @@
private static final long serialVersionUID = 1L;
- @Override
- public Token execute(Token token)
- {
+ public Object execute(Token token) {
token.suspend();
return token;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -27,12 +27,12 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
/**
- * end the task with the given id if variables are given as a map, they are added/changed bevore ending the task
+ * end the task with the given id if variables are given as a map, they are added/changed bevore
+ * ending the task
*
* @author ??, Bernd Ruecker (bernd.ruecker at camunda.com)
*/
-public class TaskInstanceEndCommand extends AbstractBaseCommand
-{
+public class TaskInstanceEndCommand extends AbstractBaseCommand {
private static final long serialVersionUID = 5721341060757950369L;
@@ -44,106 +44,89 @@
private TaskInstance previoustaskInstance = null;
- public TaskInstanceEndCommand()
- {
+ public TaskInstanceEndCommand() {
}
- public TaskInstanceEndCommand(long taskInstanceId, String transitionName)
- {
+ public TaskInstanceEndCommand(long taskInstanceId, String transitionName) {
this.taskInstanceId = taskInstanceId;
this.transitionName = transitionName;
}
- public TaskInstanceEndCommand(long taskInstanceId, String transitionName, Map variables)
- {
+ public TaskInstanceEndCommand(long taskInstanceId, String transitionName, Map variables) {
this.taskInstanceId = taskInstanceId;
this.transitionName = transitionName;
this.variables = variables;
}
- public Object execute(JbpmContext jbpmContext)
- {
+ public Object execute(JbpmContext jbpmContext) {
TaskInstance taskInstance = getTaskInstance(jbpmContext);
- if (variables != null && variables.size() > 0)
- {
+ if (variables != null && variables.size() > 0) {
taskInstance.getContextInstance().addVariables(variables);
}
- if (transitionName == null)
- {
+ if (transitionName == null) {
taskInstance.end();
}
- else
- {
+ else {
taskInstance.end(transitionName);
}
return taskInstance;
}
- protected TaskInstance getTaskInstance(JbpmContext jbpmContext)
- {
- if (previoustaskInstance != null)
- {
+ protected TaskInstance getTaskInstance(JbpmContext jbpmContext) {
+ if (previoustaskInstance != null) {
return previoustaskInstance;
}
return jbpmContext.getTaskInstance(taskInstanceId);
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public String getTransitionName()
- {
+ public String getTransitionName() {
return transitionName;
}
- public void setTransitionName(String transitionName)
- {
+ public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
}
- public Map getVariables()
- {
+ public Map getVariables() {
return variables;
}
- public void setVariables(Map variables)
- {
+ public void setVariables(Map variables) {
this.variables = variables;
}
- @Override
- public String getAdditionalToStringInformation()
- {
- return "taskInstanceId=" + taskInstanceId
- + ";transitionName=" + transitionName
- + ";variables=" + variables;
- }
+ public String getAdditionalToStringInformation() {
+ return "taskInstanceId="
+ + taskInstanceId
+ + ";transitionName="
+ + transitionName
+ + ";variables="
+ + variables;
+ }
// methods for fluent programming
- public TaskInstanceEndCommand taskInstanceId(long taskInstanceId)
- {
+ public TaskInstanceEndCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
- public TaskInstanceEndCommand transitionName(String transitionName)
- {
+ public TaskInstanceEndCommand transitionName(String transitionName) {
setTransitionName(transitionName);
return this;
}
- public TaskInstanceEndCommand variables(Map variables)
- {
+ public TaskInstanceEndCommand variables(Map variables) {
setVariables(variables);
return this;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -8,8 +8,7 @@
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class VariablesCommand extends AbstractBaseCommand
-{
+public class VariablesCommand extends AbstractBaseCommand {
private static final long serialVersionUID = 1L;
@@ -21,103 +20,81 @@
Token previousToken = null;
TaskInstance previousTaskInstance = null;
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
+ public Object execute(JbpmContext jbpmContext) throws Exception {
VariableContainer variableContainer = getVariableContainer(jbpmContext);
- if ((variableContainer != null) && (variables != null))
- {
+ if ((variableContainer != null) && (variables != null)) {
variableContainer.addVariables(variables);
}
return variableContainer;
}
- protected VariableContainer getVariableContainer(JbpmContext jbpmContext)
- {
- if (previousProcessInstance != null)
- {
+ protected VariableContainer getVariableContainer(JbpmContext jbpmContext) {
+ if (previousProcessInstance != null) {
return getVariableContainer(previousProcessInstance.getRootToken());
}
- if (previousToken != null)
- {
+ if (previousToken != null) {
return getVariableContainer(previousToken);
}
- if (previousTaskInstance != null)
- {
+ if (previousTaskInstance != null) {
return previousTaskInstance;
}
- if (tokenId != 0)
- {
+ if (tokenId != 0) {
return getVariableContainer(jbpmContext.getToken(tokenId));
}
- if (taskInstanceId != 0)
- {
+ if (taskInstanceId != 0) {
return jbpmContext.getTaskInstance(taskInstanceId);
}
return null;
}
- protected VariableContainer getVariableContainer(Token token)
- {
+ protected VariableContainer getVariableContainer(Token token) {
return token.getProcessInstance().getContextInstance().getTokenVariableMap(token);
}
- public long getTaskInstanceId()
- {
+ public long getTaskInstanceId() {
return taskInstanceId;
}
- public void setTaskInstanceId(long taskInstanceId)
- {
+ public void setTaskInstanceId(long taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
- public long getTokenId()
- {
+ public long getTokenId() {
return tokenId;
}
- public void setTokenId(long tokenId)
- {
+ public void setTokenId(long tokenId) {
this.tokenId = tokenId;
}
- public Map getVariables()
- {
+ public Map getVariables() {
return variables;
}
- public void setVariables(Map variables)
- {
+ public void setVariables(Map variables) {
this.variables = variables;
}
-
- @Override
- public String getAdditionalToStringInformation()
- {
- return "tokenId=" + tokenId
- + ";taskInstanceId=" + taskInstanceId
- + ";variables=" + variables;
- }
+ public String getAdditionalToStringInformation() {
+ return "tokenId=" + tokenId + ";taskInstanceId=" + taskInstanceId + ";variables=" + variables;
+ }
+
// methods for fluent programming
-
- public VariablesCommand taskInstanceId(long taskInstanceId)
- {
+
+ public VariablesCommand taskInstanceId(long taskInstanceId) {
setTaskInstanceId(taskInstanceId);
return this;
}
- public VariablesCommand tokenId(long tokenId)
- {
+ public VariablesCommand tokenId(long tokenId) {
setTokenId(tokenId);
return this;
}
- public VariablesCommand variables(Map variables)
- {
+ public VariablesCommand variables(Map variables) {
setVariables(variables);
return this;
}
-
+
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/impl/CommandServiceImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/impl/CommandServiceImpl.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/command/impl/CommandServiceImpl.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -37,47 +37,47 @@
*
* @author Jim Rigsbee, Tom Baeyens
*/
-public class CommandServiceImpl implements CommandService, Serializable
-{
+public class CommandServiceImpl implements CommandService, Serializable {
+
private static final long serialVersionUID = 1L;
protected JbpmConfiguration jbpmConfiguration = null;
/**
- * Establish an instance of the command service with a particular jBPM configuration which provides connectivity to
- * the jBPM engine and its related services including the persistence manager.
+ * Establish an instance of the command service with a particular jBPM configuration which
+ * provides connectivity to the jBPM engine and its related services including the persistence
+ * manager.
*
* @param jbpmConfiguration jBPM Configuration
*/
- public CommandServiceImpl(JbpmConfiguration jbpmConfiguration)
- {
+ public CommandServiceImpl(JbpmConfiguration jbpmConfiguration) {
this.jbpmConfiguration = jbpmConfiguration;
}
/**
- * Executes command based on its current context. Each command contains the appropriate context information such as
- * token, process instance, etc. to insure that the operation is carried out on the proper graph object.
+ * Executes command based on its current context. Each command contains the appropriate context
+ * information such as token, process instance, etc. to insure that the operation is carried out
+ * on the proper graph object.
*
* @param command jBPM engine command to execute
*/
- public Object execute(Command command)
- {
- Object result = null;
+ public Object execute(Command command) {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
log.debug("executing " + command);
- result = command.execute(jbpmContext);
+ return command.execute(jbpmContext);
}
- catch (Exception e)
- {
- throw new JbpmException("couldn't execute " + command, e);
+ catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
}
- finally
- {
+ catch (Exception e) {
+ jbpmContext.setRollbackOnly();
+ throw new JbpmException("failed to execute " + command, e);
+ }
+ finally {
jbpmContext.close();
}
- return result;
}
private static final Log log = LogFactory.getLog(CommandServiceImpl.class);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -37,7 +37,6 @@
private static final long serialVersionUID = 1L;
- ClassLoader classLoader = null; // lazy load it later! See below..
List objectInfos = null;
Map namedObjectInfos = null;
Map singletons = new HashMap();
@@ -161,14 +160,7 @@
// "lazy load" classloader, shouldn't be loaded too early
// because if jbpm.cfg.xml is not yet parsed, the correct class loader
// may not be initialized yet.
- if (classLoader==null) {
- classLoader = ClassLoaderUtil.getClassLoader();
- }
- try {
- return classLoader.loadClass(className);
- } catch (ClassNotFoundException e) {
- throw new JbpmException("couldn't load class '"+className+"'", e);
- }
+ return ClassLoaderUtil.loadClass(className);
}
Object getRegistryKey(ObjectInfo objectInfo) {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -23,7 +23,9 @@
// $Id$
+import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,6 +33,7 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.tool.hbm2ddl.SchemaExport;
+
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
@@ -75,15 +78,17 @@
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<String, Long> rowsPerTable = jbpmSchema.getRowsPerTable();
- for (Map.Entry<String, Long> entry : rowsPerTable.entrySet()) {
+ Map rowsPerTable = jbpmSchema.getRowsPerTable();
+ for (Iterator i = rowsPerTable.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Entry) i.next();
// String tableName = entry.getKey();
- Long count = entry.getValue();
- if (count != 0) {
+ Long count = (Long) entry.getValue();
+ if (count.intValue() != 0) {
hasLeftOvers = true;
// [JBPM-1812] Fix tests that don't cleanup the database
// Only uncomment this if you intend to fix it. Otherwise it just generates noise.
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -32,14 +33,13 @@
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
+
import org.jbpm.JbpmException;
-import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.graph.node.ProcessState;
-import org.jbpm.logging.log.ProcessLog;
-import org.jbpm.util.CollectionUtil;
+import org.jbpm.persistence.JbpmPersistenceException;
/**
* are the graph related database operations.
@@ -49,6 +49,7 @@
final Session session;
final JbpmSession jbpmSession;
+ /** @deprecated use {@link #GraphSession(Session)} instead */
public GraphSession(JbpmSession jbpmSession) {
this.session = jbpmSession.getSession();
this.jbpmSession = jbpmSession;
@@ -92,25 +93,25 @@
try {
session.save(processDefinition);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not save " + processDefinition, e);
+ throw new JbpmPersistenceException("could not save " + processDefinition, e);
}
}
/**
* loads a process definition from the database by the identifier.
*
- * @throws JbpmException in case the referenced process definition doesn't exist.
+ * @throws JbpmPersistenceException in case the referenced process definition doesn't exist.
*/
public ProcessDefinition loadProcessDefinition(long processDefinitionId) {
try {
- return (ProcessDefinition) session.load(ProcessDefinition.class,
- new Long(processDefinitionId));
+ return (ProcessDefinition) session.load(ProcessDefinition.class, new Long(processDefinitionId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not load process definition " + processDefinitionId, e);
+ throw new JbpmPersistenceException(
+ "could not load process definition " + processDefinitionId, e);
}
}
@@ -123,9 +124,10 @@
try {
return (ProcessDefinition) session.get(ProcessDefinition.class, new Long(processDefinitionId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not get process definition " + processDefinitionId, e);
+ throw new JbpmPersistenceException("could not get process definition " + processDefinitionId,
+ e);
}
}
@@ -139,9 +141,9 @@
.setInteger("version", version)
.uniqueResult();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find process definition '"
+ throw new JbpmPersistenceException("could not find process definition '"
+ name
+ "' at version "
+ version, e);
@@ -158,9 +160,9 @@
.setMaxResults(1)
.uniqueResult();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find process definition '" + name + "'", e);
+ throw new JbpmPersistenceException("could not find process definition '" + name + "'", e);
}
}
@@ -168,44 +170,41 @@
* queries the database for the latest version of each process definition. Process definitions are
* distinct by name.
*/
- public List<ProcessDefinition> findLatestProcessDefinitions() {
+ public List findLatestProcessDefinitions() {
try {
- List<?> tuples = session.getNamedQuery("GraphSession.findLatestProcessDefinitions")
- .list();
- List<ProcessDefinition> result = new ArrayList<ProcessDefinition>();
- for (Object[] tuple : CollectionUtil.checkList(tuples, Object[].class)) {
+ List tuples = session.getNamedQuery("GraphSession.findLatestProcessDefinitions").list();
+ List result = new ArrayList();
+ for (Iterator i = tuples.iterator(); i.hasNext();) {
+ Object[] tuple = (Object[]) i.next();
String name = (String) tuple[0];
Integer version = (Integer) tuple[1];
- result.add(findProcessDefinition(name, version));
+ result.add(findProcessDefinition(name, version.intValue()));
}
return result;
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find latest versions of process definitions", e);
+ throw new JbpmPersistenceException("could not find latest versions of process definitions", e);
}
}
- public List<ProcessDefinition> findProcessDefinitions(Collection<Long> processDefinitionIds) {
- List<?> processDefinitions = session.createCriteria(ProcessDefinition.class)
+ public List findProcessDefinitions(Collection processDefinitionIds) {
+ return session.createCriteria(ProcessDefinition.class)
.add(Restrictions.in("id", processDefinitionIds))
.list();
- return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
}
/**
* queries the database for all process definitions, ordered by name (ascending), then by version
* (descending).
*/
- public List<ProcessDefinition> findAllProcessDefinitions() {
+ public List findAllProcessDefinitions() {
try {
- List<?> processDefinitions = session.getNamedQuery("GraphSession.findAllProcessDefinitions")
- .list();
- return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
+ return session.getNamedQuery("GraphSession.findAllProcessDefinitions").list();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find all process definitions", e);
+ throw new JbpmPersistenceException("could not find all process definitions", e);
}
}
@@ -213,16 +212,17 @@
* queries the database for all versions of process definitions with the given name, ordered by
* version (descending).
*/
- public List<ProcessDefinition> findAllProcessDefinitionVersions(String name) {
+ public List findAllProcessDefinitionVersions(String name) {
try {
- List<?> processDefinitions = session.getNamedQuery("GraphSession.findAllProcessDefinitionVersions")
+ return session.getNamedQuery("GraphSession.findAllProcessDefinitionVersions")
.setString("name", name)
.list();
- return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
}
catch (HibernateException e) {
log.error(e);
- throw new JbpmException("could not find all versions of process definition '" + name + "'", e);
+ throw new JbpmPersistenceException("could not find all versions of process definition '"
+ + name
+ + "'", e);
}
}
@@ -231,17 +231,14 @@
}
public void deleteProcessDefinition(ProcessDefinition processDefinition) {
- if (processDefinition == null) {
- throw new IllegalArgumentException("processDefinition cannot be null");
- }
-
try {
// delete all the process instances of this definition
- List<?> processInstanceIds = session.getNamedQuery("GraphSession.findAllProcessInstanceIdsForDefinition")
+ List processInstanceIds = session.getNamedQuery("GraphSession.findAllProcessInstanceIdsForDefinition")
.setLong("processDefinitionId", processDefinition.getId())
.list();
- for (Long processInstanceId : CollectionUtil.checkList(processInstanceIds, Long.class)) {
- ProcessInstance processInstance = getProcessInstance(processInstanceId);
+ for (Iterator i = processInstanceIds.iterator(); i.hasNext();) {
+ Long processInstanceId = (Long) i.next();
+ ProcessInstance processInstance = getProcessInstance(processInstanceId.longValue());
if (processInstance != null) {
deleteProcessInstance(processInstance);
}
@@ -250,25 +247,25 @@
}
}
- List<ProcessState> referencingProcessStates = findReferencingProcessStates(processDefinition);
- for (ProcessState processState : referencingProcessStates) {
+ List referencingProcessStates = findReferencingProcessStates(processDefinition);
+ for (Iterator i = referencingProcessStates.iterator(); i.hasNext();) {
+ ProcessState processState = (ProcessState) i.next();
processState.setSubProcessDefinition(null);
}
// then delete the process definition
session.delete(processDefinition);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not delete " + processDefinition, e);
+ throw new JbpmPersistenceException("could not delete " + processDefinition, e);
}
}
- List<ProcessState> findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
- List<?> processStates = session.getNamedQuery("GraphSession.findReferencingProcessStates")
+ List findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
+ return session.getNamedQuery("GraphSession.findReferencingProcessStates")
.setEntity("subProcessDefinition", subProcessDefinition)
.list();
- return CollectionUtil.checkList(processStates, ProcessState.class);
}
// process instances ////////////////////////////////////////////////////////
@@ -286,15 +283,15 @@
* the process instance doesn't exist.
*
* @see #getProcessInstance(long)
- * @throws JbpmException in case the process instance doesn't exist.
+ * @throws JbpmPersistenceException in case the process instance doesn't exist.
*/
public ProcessInstance loadProcessInstance(long processInstanceId) {
try {
return (ProcessInstance) session.load(ProcessInstance.class, new Long(processInstanceId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not load process instance " + processInstanceId, e);
+ throw new JbpmPersistenceException("could not load process instance " + processInstanceId, e);
}
}
@@ -306,9 +303,9 @@
try {
return (ProcessInstance) session.get(ProcessInstance.class, new Long(processInstanceId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not get process instance " + processInstanceId, e);
+ throw new JbpmPersistenceException("could not get process instance " + processInstanceId, e);
}
}
@@ -316,15 +313,15 @@
* loads a token from the database by the identifier.
*
* @return the token.
- * @throws JbpmException in case the referenced token doesn't exist.
+ * @throws JbpmPersistenceException in case the referenced token doesn't exist.
*/
public Token loadToken(long tokenId) {
try {
return (Token) session.load(Token.class, new Long(tokenId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not load token " + tokenId, e);
+ throw new JbpmPersistenceException("could not load token " + tokenId, e);
}
}
@@ -337,9 +334,9 @@
try {
return (Token) session.get(Token.class, new Long(tokenId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not get token " + tokenId, e);
+ throw new JbpmPersistenceException("could not get token " + tokenId, e);
}
}
@@ -348,11 +345,11 @@
*/
public void lockProcessInstance(long processInstanceId) {
try {
- session.load(ProcessInstance.class, processInstanceId, LockMode.UPGRADE);
+ session.load(ProcessInstance.class, new Long(processInstanceId), LockMode.UPGRADE);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not lock process instance " + processInstanceId, e);
+ throw new JbpmPersistenceException("could not lock process instance " + processInstanceId, e);
}
}
@@ -363,9 +360,9 @@
try {
session.lock(processInstance, LockMode.UPGRADE);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not lock " + processInstance, e);
+ throw new JbpmPersistenceException("could not lock " + processInstance, e);
}
}
@@ -373,16 +370,15 @@
* fetches all processInstances for the given process definition from the database. The returned
* list of process instances is sorted start date, youngest first.
*/
- public List<ProcessInstance> findProcessInstances(long processDefinitionId) {
+ public List findProcessInstances(long processDefinitionId) {
try {
- List<?> processInstances = session.getNamedQuery("GraphSession.findAllProcessInstancesForDefinition")
+ return session.getNamedQuery("GraphSession.findAllProcessInstancesForDefinition")
.setLong("processDefinitionId", processDefinitionId)
.list();
- return CollectionUtil.checkList(processInstances, ProcessInstance.class);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find process instances for process definition "
+ throw new JbpmPersistenceException("could not find process instances for process definition "
+ processDefinitionId, e);
}
}
@@ -433,11 +429,11 @@
// delete tasks (TaskLogs reference tasks, so tasks must be deleted after logs)
if (includeTasks) {
log.debug("deleting tasks for " + processInstance);
- List<?> tasks = session.getNamedQuery("GraphSession.findTaskInstancesForProcessInstance")
+ List tasks = session.getNamedQuery("GraphSession.findTaskInstancesForProcessInstance")
.setEntity("processInstance", processInstance)
.list();
- for (Object task : tasks) {
- session.delete(task);
+ for (Iterator i = tasks.iterator(); i.hasNext();) {
+ session.delete(i.next());
}
}
@@ -445,24 +441,24 @@
log.debug("deleting " + processInstance);
session.delete(processInstance);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not delete " + processInstance, e);
+ throw new JbpmPersistenceException("could not delete " + processInstance, e);
}
}
void deleteLogs(ProcessInstance processInstance) {
- List<?> logs = session.getNamedQuery("GraphSession.findLogsForProcessInstance")
+ List logs = session.getNamedQuery("GraphSession.findLogsForProcessInstance")
.setEntity("processInstance", processInstance)
.list();
- for (ProcessLog processLog : CollectionUtil.checkList(logs, ProcessLog.class)) {
- session.delete(processLog);
+ for (Iterator i = logs.iterator(); i.hasNext();) {
+ session.delete(i.next());
}
}
void deleteSubProcesses(ProcessInstance processInstance) {
if (processInstance != null) {
- List<?> subProcessInstances = session.getNamedQuery("GraphSession.findSubProcessInstances")
+ List subProcessInstances = session.getNamedQuery("GraphSession.findSubProcessInstances")
.setEntity("processInstance", processInstance)
.list();
@@ -471,7 +467,8 @@
return;
}
- for (ProcessInstance subProcessInstance : CollectionUtil.checkList(subProcessInstances, ProcessInstance.class)) {
+ for (Iterator i = subProcessInstances.iterator(); i.hasNext();) {
+ ProcessInstance subProcessInstance = (ProcessInstance) i.next();
log.debug("preparing to delete sub process instance " + subProcessInstance.getId());
deleteProcessInstance(subProcessInstance);
}
@@ -536,19 +533,19 @@
}
}
- public List<AverageNodeTimeEntry> calculateAverageTimeByNode(long processDefinitionId,
- long minumumDurationMillis) {
+ public List calculateAverageTimeByNode(long processDefinitionId, long minumumDurationMillis) {
try {
- List<?> tuples = session.getNamedQuery("GraphSession.calculateAverageTimeByNode")
+ List tuples = session.getNamedQuery("GraphSession.calculateAverageTimeByNode")
.setLong("processDefinitionId", processDefinitionId)
.setDouble("minimumDuration", minumumDurationMillis)
.list();
- List<AverageNodeTimeEntry> results;
+ List results;
if (!tuples.isEmpty()) {
- results = new ArrayList<AverageNodeTimeEntry>();
+ results = new ArrayList();
- for (Object[] values : CollectionUtil.checkList(tuples, Object[].class)) {
+ for (Iterator i = tuples.iterator(); i.hasNext();) {
+ Object[] values = (Object[]) i.next();
AverageNodeTimeEntry averageNodeTimeEntry = new AverageNodeTimeEntry();
averageNodeTimeEntry.setNodeId(((Number) values[0]).longValue());
averageNodeTimeEntry.setNodeName((String) values[1]);
@@ -561,27 +558,27 @@
}
}
else {
- results = Collections.emptyList();
+ results = Collections.EMPTY_LIST;
}
return results;
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not calculate average time by node for process definition "
- + processDefinitionId, e);
+ throw new JbpmPersistenceException(
+ "could not calculate average time by node for process definition " + processDefinitionId,
+ e);
}
}
- public List<Node> findActiveNodesByProcessInstance(ProcessInstance processInstance) {
+ public List findActiveNodesByProcessInstance(ProcessInstance processInstance) {
try {
- List<?> nodes = session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance")
+ return session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance")
.setEntity("processInstance", processInstance)
.list();
- return CollectionUtil.checkList(nodes, Node.class);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not find active nodes for " + processInstance, e);
+ throw new JbpmPersistenceException("could not find active nodes for " + processInstance, e);
}
}
@@ -592,9 +589,9 @@
.setString("key", key)
.uniqueResult();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("could not get process instance with key '" + key + "'", e);
+ throw new JbpmPersistenceException("could not get process instance with key '" + key + "'", e);
}
}
@@ -606,8 +603,9 @@
return processInstance;
}
- private void handle(Exception e) {
- log.error(e);
+ private void handle(HibernateException exception) {
+ // exception will be rethrown, no need to log here at a verbose level
+ log.debug(exception);
if (jbpmSession != null) jbpmSession.handleException();
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -50,6 +50,7 @@
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
import org.hibernate.util.JDBCExceptionReporter;
+
import org.jbpm.JbpmException;
/**
@@ -63,7 +64,7 @@
ConnectionProvider connectionProvider = null;
Connection connection = null;
- final List<SQLException> exceptions = new ArrayList<SQLException>();
+ final List exceptions = new ArrayList();
public JbpmSchema(Configuration configuration) {
this.configuration = configuration;
@@ -82,9 +83,9 @@
return concat(getDropSql(), getCreateSql());
}
- public Set<String> getJbpmTables() {
- Set<String> jbpmTables = new HashSet<String>();
- for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+ public Set getJbpmTables() {
+ Set jbpmTables = new HashSet();
+ for (Iterator i = configuration.getTableMappings(); i.hasNext();) {
Table table = (Table) i.next();
if (table.isPhysicalTable()) {
jbpmTables.add(table.getName());
@@ -93,10 +94,10 @@
return jbpmTables;
}
- public Set<String> getExistingTables() {
+ public Set getExistingTables() {
try {
createConnection();
- Set<String> existingTables = new HashSet<String>();
+ Set existingTables = new HashSet();
DatabaseMetaData metaData = connection.getMetaData();
boolean storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
@@ -124,12 +125,13 @@
}
}
- public Map<String, Long> getRowsPerTable() {
- Map<String, Long> rowsPerTable = new HashMap<String, Long>();
+ public Map getRowsPerTable() {
+ Map rowsPerTable = new HashMap();
try {
createConnection();
Statement statement = connection.createStatement();
- for (String tableName : getJbpmTables()) {
+ for (Iterator i = getJbpmTables().iterator(); i.hasNext();) {
+ String tableName = (String) i.next();
String sql = "SELECT COUNT(*) FROM " + tableName;
ResultSet resultSet = statement.executeQuery(sql);
if (!resultSet.next()) throw new JbpmException("empty result set: " + sql);
@@ -137,7 +139,7 @@
long count = resultSet.getLong(1);
if (resultSet.wasNull()) throw new JbpmException("count was null: " + sql);
- rowsPerTable.put(tableName, count);
+ rowsPerTable.put(tableName, new Long(count));
resultSet.close();
}
statement.close();
@@ -219,7 +221,7 @@
String sql = table.sqlCreateString(settings.getDialect(), configuration.buildMapping(),
settings.getDefaultCatalogName(), settings.getDefaultSchemaName());
try {
- execute(sql);
+ execute(new String[] { sql });
}
catch (SQLException e) {
throw new JbpmException("could not create table: " + tableName, e);
@@ -230,7 +232,7 @@
Table table = findTableMapping(tableName);
try {
createConnection();
- Iterator<?> sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(),
+ Iterator sqls = table.sqlAlterStrings(settings.getDialect(), configuration.buildMapping(),
getTableMetadata(table), settings.getDefaultCatalogName(),
settings.getDefaultSchemaName());
@@ -249,12 +251,12 @@
}
}
- public List<SQLException> getExceptions() {
+ public List getExceptions() {
return exceptions;
}
private Table findTableMapping(String tableName) {
- for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+ for (Iterator i = configuration.getTableMappings(); i.hasNext();) {
Table table = (Table) i.next();
if (tableName.equals(table.getName())) {
return table;
@@ -328,8 +330,8 @@
void saveSqlScript(String fileName, String[] sql) throws IOException {
PrintStream out = new PrintStream(new FileOutputStream(fileName));
try {
- for (String line : sql) {
- out.println(line + getSqlDelimiter());
+ for (int i = 0; i < sql.length; i++) {
+ out.println(sql[i] + getSqlDelimiter());
}
}
finally {
@@ -337,17 +339,18 @@
}
}
- void execute(String... sqls) throws SQLException {
+ void execute(String[] sql) throws SQLException {
boolean showSql = settings.isShowSqlEnabled();
exceptions.clear();
try {
createConnection();
Statement statement = connection.createStatement();
- for (String sql : sqls) {
- if (showSql) System.out.println(sql);
- log.debug(sql);
+ for (int i = 0; i < sql.length; i++) {
+ String line = sql[i];
+ if (showSql) System.out.println(line);
+ log.debug(line);
try {
- statement.executeUpdate(sql);
+ statement.executeUpdate(line);
}
catch (SQLException e) {
exceptions.add(e);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,9 +21,9 @@
*/
package org.jbpm.db;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -32,12 +32,13 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
-import org.jbpm.JbpmException;
+
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.job.Job;
import org.jbpm.job.Timer;
-import org.jbpm.util.CollectionUtil;
+import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.util.ArrayUtil;
public class JobSession {
@@ -56,40 +57,38 @@
.uniqueResult();
}
catch (HibernateException e) {
- throw new JbpmException("could not get first acquirable job", e);
+ throw new JbpmPersistenceException("could not get first acquirable job", e);
}
}
- public List<Job> findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
+ public List findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
try {
- List<?> jobs = session.getNamedQuery("JobSession.findExclusiveJobs")
+ return session.getNamedQuery("JobSession.findExclusiveJobs")
.setString("lockOwner", lockOwner)
.setTimestamp("now", new Date())
.setParameter("processInstance", processInstance)
.list();
- return CollectionUtil.checkList(jobs, Job.class);
}
catch (HibernateException e) {
- throw new JbpmException("could not find exclusive jobs owned by '"
+ throw new JbpmPersistenceException("could not find exclusive jobs owned by '"
+ lockOwner
+ "' for "
+ processInstance, e);
}
}
- public List<Job> findJobsByToken(Token token) {
+ public List findJobsByToken(Token token) {
try {
- List<?> jobs = session.getNamedQuery("JobSession.findJobsByToken")
+ return session.getNamedQuery("JobSession.findJobsByToken")
.setParameter("token", token)
.list();
- return CollectionUtil.checkList(jobs, Job.class);
}
catch (HibernateException e) {
- throw new JbpmException("could not find jobs for " + token, e);
+ throw new JbpmPersistenceException("could not find jobs for " + token, e);
}
}
- public Job getFirstDueJob(String lockOwner, Collection<Long> monitoredJobs) {
+ public Job getFirstDueJob(String lockOwner, Collection monitoredJobs) {
try {
Query query;
if (monitoredJobs == null || monitoredJobs.isEmpty()) {
@@ -99,12 +98,10 @@
query = session.getNamedQuery("JobSession.getFirstDueJobExcludingMonitoredJobs");
query.setParameterList("monitoredJobIds", monitoredJobs);
}
- return (Job) query.setString("lockOwner", lockOwner)
- .setMaxResults(1)
- .uniqueResult();
+ return (Job) query.setString("lockOwner", lockOwner).setMaxResults(1).uniqueResult();
}
catch (HibernateException e) {
- throw new JbpmException("could not get first due job owned by '"
+ throw new JbpmPersistenceException("could not get first due job owned by '"
+ lockOwner
+ "' ignoring jobs "
+ monitoredJobs, e);
@@ -116,7 +113,7 @@
session.save(job);
}
catch (HibernateException e) {
- throw new JbpmException("could not save " + job, e);
+ throw new JbpmPersistenceException("could not save " + job, e);
}
}
@@ -126,7 +123,7 @@
log.debug("deleted " + job);
}
catch (HibernateException e) {
- throw new JbpmException("could not delete " + job, e);
+ throw new JbpmPersistenceException("could not delete " + job, e);
}
}
@@ -135,7 +132,7 @@
return (Job) session.load(Job.class, new Long(jobId));
}
catch (HibernateException e) {
- throw new JbpmException("could not load job " + jobId, e);
+ throw new JbpmPersistenceException("could not load job " + jobId, e);
}
}
@@ -144,19 +141,18 @@
return (Timer) session.load(Timer.class, new Long(timerId));
}
catch (HibernateException e) {
- throw new JbpmException("could not load timer " + timerId, e);
+ throw new JbpmPersistenceException("could not load timer " + timerId, e);
}
}
- public List<Job> loadJobs(long... jobIds) {
+ public List loadJobs(long[] jobIds) {
try {
- List<?> jobs = session.createCriteria(Job.class)
+ return session.createCriteria(Job.class)
.add(Restrictions.in("id", toObjectArray(jobIds)))
.list();
- return CollectionUtil.checkList(jobs, Job.class);
}
catch (HibernateException e) {
- throw new JbpmException("could not load jobs " + Arrays.toString(jobIds), e);
+ throw new JbpmPersistenceException("could not load jobs " + ArrayUtil.toString(jobIds), e);
}
}
@@ -164,7 +160,7 @@
final int length = primitives.length;
Long[] objects = new Long[length];
for (int i = 0; i < length; i++) {
- objects[i] = primitives[i];
+ objects[i] = new Long(primitives[i]);
}
return objects;
}
@@ -174,7 +170,7 @@
return (Job) session.get(Job.class, new Long(jobId));
}
catch (HibernateException e) {
- throw new JbpmException("could not get job " + jobId, e);
+ throw new JbpmPersistenceException("could not get job " + jobId, e);
}
}
@@ -183,7 +179,7 @@
session.getNamedQuery("JobSession.suspendJobs").setParameter("token", token).executeUpdate();
}
catch (HibernateException e) {
- throw new JbpmException("could not suspend jobs for " + token, e);
+ throw new JbpmPersistenceException("could not suspend jobs for " + token, e);
}
}
@@ -192,7 +188,7 @@
session.getNamedQuery("JobSession.resumeJobs").setParameter("token", token).executeUpdate();
}
catch (HibernateException e) {
- throw new JbpmException("could not resume jobs for " + token, e);
+ throw new JbpmPersistenceException("could not resume jobs for " + token, e);
}
}
@@ -206,14 +202,17 @@
log.debug("deleted " + entityCount + " timers by name '" + name + "' for " + token);
// prevent further repetitions
- List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersByName")
+ List timers = session.getNamedQuery("JobSession.findRepeatingTimersByName")
.setString("name", name)
.setParameter("token", token)
.list();
preventFurtherRepetitions(timers);
}
catch (HibernateException e) {
- throw new JbpmException("could not delete timers by name '" + name + "' for " + token, e);
+ throw new JbpmPersistenceException("could not delete timers by name '"
+ + name
+ + "' for "
+ + token, e);
}
}
@@ -233,34 +232,34 @@
log.debug("deleted " + entityCount + " jobs for " + processInstance);
// prevent further repetitions
- List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersForProcessInstance")
+ List timers = session.getNamedQuery("JobSession.findRepeatingTimersForProcessInstance")
.setParameter("processInstance", processInstance)
.list();
preventFurtherRepetitions(timers);
}
catch (HibernateException e) {
- throw new JbpmException("could not delete jobs for " + processInstance, e);
+ throw new JbpmPersistenceException("could not delete jobs for " + processInstance, e);
}
}
- private static void preventFurtherRepetitions(List<?> timers) {
+ private static void preventFurtherRepetitions(List timers) {
if (!timers.isEmpty()) {
- for (Timer timer : CollectionUtil.checkList(timers, Timer.class)) {
+ for (Iterator i = timers.iterator(); i.hasNext();) {
+ Timer timer = (Timer) i.next();
timer.setRepeat(null);
}
log.debug("prevented further repetitions of " + timers);
}
}
- public List<Job> findJobsWithOverdueLockTime(Date threshold) {
+ public List findJobsWithOverdueLockTime(Date threshold) {
try {
- List<?> jobs = session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
+ return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
.setDate("threshold", threshold)
.list();
- return CollectionUtil.checkList(jobs, Job.class);
}
catch (HibernateException e) {
- throw new JbpmException("could not find jobs with lock time over " + threshold, e);
+ throw new JbpmPersistenceException("could not find jobs with lock time over " + threshold, e);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -28,90 +28,88 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Query;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.jbpm.JbpmException;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.logging.log.ProcessLog;
+import org.jbpm.persistence.JbpmPersistenceException;
public class LoggingSession {
- JbpmSession jbpmSession;
- Session session;
-
+ final JbpmSession jbpmSession;
+ final Session session;
+
+ /** @deprecated use {@link #LoggingSession(Session)} instead */
public LoggingSession(JbpmSession jbpmSession) {
+ this.session = jbpmSession.getSession();
this.jbpmSession = jbpmSession;
- this.session = jbpmSession.getSession();
}
-
+
public LoggingSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
/**
- * returns a map that maps {@link Token}s to {@link List}s. The lists contain the ordered
- * logs for the given token. The lists are retrieved with {@link #findLogsByToken(long)}.
+ * returns a map that maps {@link Token}s to {@link List}s. The lists contain the ordered logs for
+ * the given token. The lists are retrieved with {@link #findLogsByToken(long)}.
*/
public Map findLogsByProcessInstance(long processInstanceId) {
Map tokenLogs = new HashMap();
try {
- ProcessInstance processInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long(processInstanceId));
+ ProcessInstance processInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long(
+ processInstanceId));
collectTokenLogs(tokenLogs, processInstance.getRootToken());
- } catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
- throw new JbpmException("couldn't get logs for process instance '"+processInstanceId+"'", e);
- }
+ }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't get logs for process instance "
+ + processInstanceId, e);
+ }
return tokenLogs;
}
private void collectTokenLogs(Map tokenLogs, Token token) {
tokenLogs.put(token, findLogsByToken(token.getId()));
Map children = token.getChildren();
- if ( (children!=null)
- && (!children.isEmpty())
- ) {
- Iterator iter = children.values().iterator();
- while (iter.hasNext()) {
- Token child = (Token) iter.next();
+ if (children != null) {
+ for (Iterator i = children.values().iterator(); i.hasNext();) {
+ Token child = (Token) i.next();
collectTokenLogs(tokenLogs, child);
}
}
}
-
+
/**
* collects the logs for a given token, ordered by creation time.
*/
public List findLogsByToken(long tokenId) {
- List result = null;
try {
Token token = (Token) session.load(Token.class, new Long(tokenId));
- Query query = session.getNamedQuery("LoggingSession.findLogsByToken");
- query.setEntity("token", token);
- result = query.list();
- } catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
- throw new JbpmException("couldn't get logs for token '"+tokenId+"'", e);
- }
- return result;
+ return session.getNamedQuery("LoggingSession.findLogsByToken")
+ .setEntity("token", token)
+ .list();
+ }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't get logs for token '" + tokenId + "'", e);
+ }
}
-
+
/**
* saves the given process log to the database.
*/
public void saveProcessLog(ProcessLog processLog) {
try {
session.save(processLog);
- } catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
- throw new JbpmException("couldn't save process log '"+processLog+"'", e);
- }
+ }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't save process log '" + processLog + "'", e);
+ }
}
-
+
/**
* load the process log for a given id.
*/
@@ -119,14 +117,14 @@
ProcessLog processLog = null;
try {
processLog = (ProcessLog) session.load(ProcessLog.class, new Long(processLogId));
- } catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
- throw new JbpmException("couldn't load process log '"+processLogId+"'", e);
- }
+ }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't load process log '" + processLogId + "'", e);
+ }
return processLog;
}
-
+
/**
* get the process log for a given id.
*/
@@ -134,13 +132,19 @@
ProcessLog processLog = null;
try {
processLog = (ProcessLog) session.get(ProcessLog.class, new Long(processLogId));
- } catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
- throw new JbpmException("couldn't get process log '"+processLogId+"'", e);
- }
+ }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't get process log '" + processLogId + "'", e);
+ }
return processLog;
}
-
+
+ private void handle(HibernateException exception) {
+ // exception will be rethrown, no need to log here at a verbose level
+ log.debug(exception);
+ if (jbpmSession != null) jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(LoggingSession.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,27 +21,24 @@
*/
package org.jbpm.db;
-import java.io.Serializable;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Query;
+import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.jbpm.JbpmException;
+
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.JbpmPersistenceException;
import org.jbpm.taskmgmt.exe.TaskInstance;
-import org.jbpm.util.CollectionUtil;
-public class TaskMgmtSession implements Serializable {
+public class TaskMgmtSession {
- private static final long serialVersionUID = 1L;
-
final Session session;
final JbpmSession jbpmSession;
+ /** @deprecated use {@link #TaskMgmtSession(Session)} instead */
public TaskMgmtSession(JbpmSession jbpmSession) {
this.session = jbpmSession.getSession();
this.jbpmSession = jbpmSession;
@@ -55,15 +52,17 @@
/**
* get the tasklist for a given actor.
*/
- public List<TaskInstance> findTaskInstances(String actorId) {
+ public List findTaskInstances(String actorId) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorId");
- query.setString("actorId", actorId);
- return CollectionUtil.checkList(query.list(), TaskInstance.class);
+ return session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorId")
+ .setString("actorId", actorId)
+ .list();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instances list for actor '" + actorId + "'", e);
+ throw new JbpmPersistenceException("couldn't get task instances list for actor '"
+ + actorId
+ + "'", e);
}
}
@@ -71,57 +70,60 @@
* get all the task instances for all the given actorIds.
*
* @return a list of task instances. An empty list is returned in case no task instances are
- * found.
+ * found.
*/
- public List<TaskInstance> findTaskInstances(List<String> actorIds) {
+ public List findTaskInstances(List actorIds) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorIds");
- query.setParameterList("actorIds", actorIds);
- return CollectionUtil.checkList(query.list(), TaskInstance.class);
+ return session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorIds")
+ .setParameterList("actorIds", actorIds)
+ .list();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instances list for actors '" + actorIds + "'", e);
+ throw new JbpmPersistenceException("couldn't get task instances list for actors '"
+ + actorIds
+ + "'", e);
}
}
/**
* get all the task instances for all the given actorIds.
*/
- public List<TaskInstance> findTaskInstances(String[] actorIds) {
+ public List findTaskInstances(String[] actorIds) {
return findTaskInstances(Arrays.asList(actorIds));
}
/**
* get the task instances for which the given actor is in the pool.
*/
- public List<TaskInstance> findPooledTaskInstances(String actorId) {
+ public List findPooledTaskInstances(String actorId) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findPooledTaskInstancesByActorId");
- query.setString("actorId", actorId);
- List<Long> taskInstanceIds = CollectionUtil.checkList(query.list(), Long.class);
+ List taskInstanceIds = session.getNamedQuery("TaskMgmtSession.findPooledTaskInstancesByActorId")
+ .setString("actorId", actorId)
+ .list();
return findTaskInstancesByIds(taskInstanceIds);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException(
- "couldn't get pooled task instances list for actor '" + actorId + "'", e);
+ throw new JbpmPersistenceException("couldn't get pooled task instances list for actor '"
+ + actorId
+ + "'", e);
}
}
/**
* get the task instances for which the given actor is in the pool.
*/
- public List<TaskInstance> findPooledTaskInstances(List<String> actorIds) {
+ public List findPooledTaskInstances(List actorIds) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findPooledTaskInstancesByActorIds");
- query.setParameterList("actorIds", actorIds);
- List<Long> taskInstanceIds = CollectionUtil.checkList(query.list(), Long.class);
+ List taskInstanceIds = session.getNamedQuery("TaskMgmtSession.findPooledTaskInstancesByActorIds")
+ .setParameterList("actorIds", actorIds)
+ .list();
return findTaskInstancesByIds(taskInstanceIds);
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get pooled task instances list for actors '"
+ throw new JbpmPersistenceException("couldn't get pooled task instances list for actors '"
+ actorIds
+ "'", e);
}
@@ -130,30 +132,31 @@
/**
* get active task instances for a given token.
*/
- public List<TaskInstance> findTaskInstancesByToken(long tokenId) {
+ public List findTaskInstancesByToken(long tokenId) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByTokenId");
- query.setLong("tokenId", tokenId);
- return CollectionUtil.checkList(query.list(), TaskInstance.class);
+ return session.getNamedQuery("TaskMgmtSession.findTaskInstancesByTokenId")
+ .setLong("tokenId", tokenId)
+ .list();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instances by token '" + tokenId + "'", e);
+ throw new JbpmPersistenceException("couldn't get task instances by token '" + tokenId + "'",
+ e);
}
}
/**
* get active task instances for a given process instance.
*/
- public List<TaskInstance> findTaskInstancesByProcessInstance(ProcessInstance processInstance) {
+ public List findTaskInstancesByProcessInstance(ProcessInstance processInstance) {
try {
- Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByProcessInstance");
- query.setEntity("processInstance", processInstance);
- return CollectionUtil.checkList(query.list(), TaskInstance.class);
+ return session.getNamedQuery("TaskMgmtSession.findTaskInstancesByProcessInstance")
+ .setEntity("processInstance", processInstance)
+ .list();
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instances by process instance '"
+ throw new JbpmPersistenceException("couldn't get task instances by process instance '"
+ processInstance
+ "'", e);
}
@@ -167,9 +170,9 @@
try {
taskInstance = (TaskInstance) session.load(TaskInstance.class, new Long(taskInstanceId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
+ throw new JbpmPersistenceException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
}
@@ -182,36 +185,31 @@
try {
taskInstance = (TaskInstance) session.get(TaskInstance.class, new Long(taskInstanceId));
}
- catch (Exception e) {
+ catch (HibernateException e) {
handle(e);
- throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
+ throw new JbpmPersistenceException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
}
- public List<TaskInstance> findTaskInstancesByIds(List<Long> taskInstanceIds) {
- List<TaskInstance> result;
- if (taskInstanceIds.isEmpty()) {
- result = Collections.emptyList();
+ public List findTaskInstancesByIds(List taskInstanceIds) {
+ try {
+ return session.getNamedQuery("TaskMgmtSession.findTaskInstancesByIds")
+ .setParameterList("taskInstanceIds", taskInstanceIds)
+ .list();
}
- else {
- try {
- Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByIds");
- query.setParameterList("taskInstanceIds", taskInstanceIds);
- result = CollectionUtil.checkList(query.list(), TaskInstance.class);
- }
- catch (Exception e) {
- handle(e);
- throw new JbpmException("couldn't get task instances by ids '" + taskInstanceIds + "'", e);
- }
+ catch (HibernateException e) {
+ handle(e);
+ throw new JbpmPersistenceException("couldn't get task instances by ids '"
+ + taskInstanceIds
+ + "'", e);
}
- return result;
}
- private void handle(Exception exception) {
- log.error(exception);
- if (jbpmSession != null)
- jbpmSession.handleException();
+ private void handle(HibernateException exception) {
+ // exception will be rethrown, no need to log here at a verbose level
+ log.debug(exception);
+ if (jbpmSession != null) jbpmSession.handleException();
}
private static final Log log = LogFactory.getLog(TaskMgmtSession.class);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -25,26 +25,27 @@
import java.util.Map;
import org.dom4j.Element;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.instantiation.Delegation;
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
-import org.jbpm.util.ClassLoaderUtil;
+import org.jbpm.util.ClassUtil;
import org.jbpm.util.EqualsUtil;
public class Action implements ActionHandler, Parsable, Serializable {
private static final long serialVersionUID = 1L;
-
+
long id = 0;
protected String name = null;
protected boolean isPropagationAllowed = true;
protected boolean isAsync = false;
protected boolean isAsyncExclusive = false;
protected Action referencedAction = null;
- protected Delegation actionDelegation = null;
+ protected Delegation actionDelegation = null;
protected String actionExpression = null;
protected Event event = null;
protected ProcessDefinition processDefinition = null;
@@ -55,41 +56,47 @@
public Action(Delegation actionDelegate) {
this.actionDelegation = actionDelegate;
}
-
+
public String toString() {
String toString = null;
- if (actionExpression!=null) {
- toString = "Action("+actionExpression+')';
- } else {
- String className = getClass().getSimpleName();
- if (name!=null) {
- toString = className+'('+name+')';
- } else {
- toString = className+'@'+Integer.toHexString(hashCode());
+ if (actionExpression != null) {
+ toString = "Action(" + actionExpression + ')';
+ }
+ else {
+ String className = ClassUtil.getSimpleName(getClass());
+ if (name != null) {
+ toString = className + '(' + name + ')';
}
+ else {
+ toString = className + '@' + Integer.toHexString(hashCode());
+ }
}
return toString;
}
public void read(Element actionElement, JpdlXmlReader jpdlReader) {
String expression = actionElement.attributeValue("expression");
- if (expression!=null) {
+ if (expression != null) {
actionExpression = expression;
- } else if (actionElement.attribute("ref-name")!=null) {
+ }
+ else if (actionElement.attribute("ref-name") != null) {
jpdlReader.addUnresolvedActionReference(actionElement, this);
- } else if (actionElement.attribute("class")!=null) {
+ }
+ else if (actionElement.attribute("class") != null) {
actionDelegation = new Delegation();
actionDelegation.read(actionElement, jpdlReader);
-
- } else {
- jpdlReader.addWarning("action does not have class nor ref-name attribute "+actionElement.asXML());
+
}
+ else {
+ jpdlReader.addWarning("action does not have class nor ref-name attribute "
+ + actionElement.asXML());
+ }
String acceptPropagatedEvents = actionElement.attributeValue("accept-propagated-events");
if ("false".equalsIgnoreCase(acceptPropagatedEvents)
- || "no".equalsIgnoreCase(acceptPropagatedEvents)
+ || "no".equalsIgnoreCase(acceptPropagatedEvents)
|| "off".equalsIgnoreCase(acceptPropagatedEvents)) {
isPropagationAllowed = false;
}
@@ -97,14 +104,15 @@
String asyncText = actionElement.attributeValue("async");
if ("true".equalsIgnoreCase(asyncText)) {
isAsync = true;
- } else if ("exclusive".equalsIgnoreCase(asyncText)) {
+ }
+ else if ("exclusive".equalsIgnoreCase(asyncText)) {
isAsync = true;
isAsyncExclusive = true;
}
}
public void write(Element actionElement) {
- if (actionDelegation!=null) {
+ if (actionDelegation != null) {
actionDelegation.write(actionElement);
}
}
@@ -113,31 +121,34 @@
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
+ Thread.currentThread().setContextClassLoader(
+ JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
if (referencedAction != null) {
referencedAction.execute(executionContext);
- } else if (actionExpression != null) {
+ }
+ else if (actionExpression != null) {
JbpmExpressionEvaluator.evaluate(actionExpression, executionContext);
- } else if (actionDelegation != null) {
+ }
+ else if (actionDelegation != null) {
ActionHandler actionHandler = (ActionHandler) actionDelegation.getInstance();
actionHandler.execute(executionContext);
}
- } finally {
+ }
+ finally {
Thread.currentThread().setContextClassLoader(surroundingClassLoader);
}
}
public void setName(String name) {
// if the process definition is already set
- if (processDefinition!=null) {
+ if (processDefinition != null) {
// update the process definition action map
Map actionMap = processDefinition.getActions();
// the != string comparison is to avoid null pointer checks. it is no problem if the body is executed a few times too much :-)
- if ( (this.name != name)
- && (actionMap!=null) ) {
+ if ((this.name != name) && (actionMap != null)) {
actionMap.remove(this.name);
actionMap.put(name, this);
}
@@ -146,14 +157,14 @@
// then update the name
this.name = name;
}
-
+
// 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) {
return EqualsUtil.equals(this, o);
}
-
+
// getters and setters //////////////////////////////////////////////////////
public boolean acceptsPropagatedEvents() {
@@ -163,6 +174,7 @@
public boolean isPropagationAllowed() {
return isPropagationAllowed;
}
+
public void setPropagationAllowed(boolean isPropagationAllowed) {
this.isPropagationAllowed = isPropagationAllowed;
}
@@ -170,45 +182,59 @@
public long getId() {
return id;
}
+
public String getName() {
return name;
}
+
public Event getEvent() {
return event;
}
+
public ProcessDefinition getProcessDefinition() {
return processDefinition;
}
+
public void setProcessDefinition(ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
}
+
public Delegation getActionDelegation() {
return actionDelegation;
}
+
public void setActionDelegation(Delegation instantiatableDelegate) {
this.actionDelegation = instantiatableDelegate;
}
+
public Action getReferencedAction() {
return referencedAction;
}
+
public void setReferencedAction(Action referencedAction) {
this.referencedAction = referencedAction;
}
+
public boolean isAsync() {
return isAsync;
}
+
public boolean isAsyncExclusive() {
return isAsyncExclusive;
}
+
public String getActionExpression() {
return actionExpression;
}
+
public void setActionExpression(String actionExpression) {
this.actionExpression = actionExpression;
}
+
public void setEvent(Event event) {
this.event = event;
}
+
public void setAsync(boolean isAsync) {
this.isAsync = isAsync;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -23,9 +23,9 @@
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
+import java.util.Map.Entry;
import javax.transaction.Status;
import javax.transaction.Synchronization;
@@ -35,6 +35,7 @@
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
+import org.jbpm.util.Semaphore;
public class EventCallback implements Serializable {
@@ -43,7 +44,7 @@
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(EventCallback.class);
- private static Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
+ private static Map eventSemaphores = new HashMap();
public void processStart() {
registerNotification(Event.EVENTTYPE_PROCESS_START);
@@ -96,10 +97,8 @@
}
};
- JbpmContext.getCurrentJbpmContext()
- .getSession()
- .getTransaction()
- .registerSynchronization(notification);
+ JbpmContext.getCurrentJbpmContext().getSession().getTransaction().registerSynchronization(
+ notification);
}
public static void waitForEvent(String event) {
@@ -118,7 +117,7 @@
log.debug("waiting for " + event);
Semaphore eventSemaphore = getEventSemaphore(event);
try {
- if (eventSemaphore.tryAcquire(occurrences, timeout, TimeUnit.MILLISECONDS)) {
+ if (eventSemaphore.tryAcquire(occurrences, timeout)) {
log.debug("received '" + event + "' notification");
}
else {
@@ -132,7 +131,7 @@
private static Semaphore getEventSemaphore(String event) {
synchronized (eventSemaphores) {
- Semaphore semaphore = eventSemaphores.get(event);
+ Semaphore semaphore = (Semaphore) eventSemaphores.get(event);
if (semaphore == null) {
semaphore = new Semaphore(0);
eventSemaphores.put(event, semaphore);
@@ -142,8 +141,10 @@
}
public static void clear() {
- for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
- int permits = entry.getValue().drainPermits();
+ for (Iterator i = eventSemaphores.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Entry) i.next();
+ Semaphore semaphore = (Semaphore) entry.getValue();
+ int permits = semaphore.drainPermits();
if (permits != 0) {
log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -31,6 +31,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.graph.exe.ExecutionContext;
@@ -44,6 +45,7 @@
import org.jbpm.signal.EventService;
import org.jbpm.svc.Service;
import org.jbpm.svc.Services;
+import org.jbpm.util.ClassUtil;
import org.jbpm.util.EqualsUtil;
public abstract class GraphElement implements Identifiable, Serializable {
@@ -67,9 +69,9 @@
// events ///////////////////////////////////////////////////////////////////
/**
- * indicative set of event types supported by this graph element. this is currently only used by the process designer
- * to know which event types to show on a given graph element. in process definitions and at runtime, there are no
- * contstraints on the event-types.
+ * indicative set of event types supported by this graph element. this is currently only used by
+ * the process designer to know which event types to show on a given graph element. in process
+ * definitions and at runtime, there are no contstraints on the event-types.
*/
public abstract String[] getSupportedEventTypes();
@@ -168,10 +170,15 @@
&& (Math.max(oldIndex, newIndex) < exceptionHandlers.size())) {
Object o = exceptionHandlers.remove(oldIndex);
exceptionHandlers.add(newIndex, o);
- } else {
- throw new IndexOutOfBoundsException("couldn't reorder element from index '" + oldIndex
- + "' to index '" + newIndex + "' in " + exceptionHandlers);
}
+ else {
+ throw new IndexOutOfBoundsException("couldn't reorder element from index '"
+ + oldIndex
+ + "' to index '"
+ + newIndex
+ + "' in "
+ + exceptionHandlers);
+ }
}
// event handling ///////////////////////////////////////////////////////////
@@ -194,7 +201,8 @@
}
fireAndPropagateEvent(eventType, executionContext);
- } finally {
+ }
+ finally {
executionContext.setEventSource(null);
}
}
@@ -234,10 +242,12 @@
Action action = (Action) iter.next();
if (action.acceptsPropagatedEvents() || (!isPropagated)) {
if (action.isAsync()) {
- ExecuteActionJob job = createAsyncActionExecutionJob(executionContext.getToken(), action);
+ ExecuteActionJob job = createAsyncActionExecutionJob(executionContext.getToken(),
+ action);
MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE);
messageService.send(job);
- } else {
+ }
+ else {
executeAction(action, executionContext);
}
}
@@ -280,17 +290,20 @@
if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
UserCodeInterceptorConfig.userCodeInterceptor.executeAction(action, executionContext);
- } else {
+ }
+ else {
action.execute(executionContext);
}
- } finally {
+ }
+ finally {
if (actionMustBeLocked) {
token.unlock(lockOwnerId);
}
}
- } catch (Exception exception) {
+ }
+ catch (Exception exception) {
// NOTE that Errors are not caught because that might halt the JVM and mask the original Error
log.error("action threw exception: " + exception.getMessage(), exception);
@@ -299,7 +312,8 @@
// if an exception handler is available
raiseException(exception, executionContext);
- } finally {
+ }
+ finally {
executionContext.setAction(null);
token.endCompositeLog();
}
@@ -316,8 +330,7 @@
if ((this.equals(runtimeAction.getGraphElement()))
&& (eventType.equals(runtimeAction.getEventType()))) {
// ... add its action to the list of runtime actions
- if (runtimeActionsForEvent == null)
- runtimeActionsForEvent = new ArrayList();
+ if (runtimeActionsForEvent == null) runtimeActionsForEvent = new ArrayList();
runtimeActionsForEvent.add(runtimeAction.getAction());
}
}
@@ -326,11 +339,11 @@
}
/*
- * // the next instruction merges the actions specified in the process definition with the runtime actions List
- * actions = event.collectActions(executionContext);
+ * // the next instruction merges the actions specified in the process definition with the runtime
+ * actions List actions = event.collectActions(executionContext);
*
- * // loop over all actions of this event Iterator iter = actions.iterator(); while (iter.hasNext()) { Action action =
- * (Action) iter.next(); executionContext.setAction(action);
+ * // loop over all actions of this event Iterator iter = actions.iterator(); while
+ * (iter.hasNext()) { Action action = (Action) iter.next(); executionContext.setAction(action);
*
* if ( (!isPropagated) || (action.acceptsPropagatedEvents() ) ) {
*
@@ -339,20 +352,22 @@
*
* try { // execute the action action.execute(executionContext);
*
- * } catch (Exception exception) { // NOTE that Error's are not caught because that might halt the JVM and mask the
- * original Error. Event.log.error("action threw exception: "+exception.getMessage(), exception);
+ * } catch (Exception exception) { // NOTE that Error's are not caught because that might halt the
+ * JVM and mask the original Error.
+ * Event.log.error("action threw exception: "+exception.getMessage(), exception);
*
* // log the action exception actionLog.setException(exception);
*
- * // if an exception handler is available event.graphElement.raiseException(exception, executionContext); } finally {
- * executionContext.getToken().endCompositeLog(); } } } }
+ * // if an exception handler is available event.graphElement.raiseException(exception,
+ * executionContext); } finally { executionContext.getToken().endCompositeLog(); } } } }
*/
/**
- * throws an ActionException if no applicable exception handler is found. An ExceptionHandler is searched for in this
- * graph element and then recursively up the parent hierarchy. If an exception handler is found, it is applied. If the
- * exception handler does not throw an exception, the exception is considered handled. Otherwise the search for an
- * applicable exception handler continues where it left of with the newly thrown exception.
+ * throws an ActionException if no applicable exception handler is found. An ExceptionHandler is
+ * searched for in this graph element and then recursively up the parent hierarchy. If an
+ * exception handler is found, it is applied. If the exception handler does not throw an
+ * exception, the exception is considered handled. Otherwise the search for an applicable
+ * exception handler continues where it left of with the newly thrown exception.
*/
public void raiseException(Throwable exception, ExecutionContext executionContext)
throws DelegationException {
@@ -365,7 +380,8 @@
exceptionHandler.handleException(this, executionContext);
return;
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM
// and mask the original Error.
exception = e;
@@ -397,15 +413,18 @@
* </ul>
*/
private static boolean isAbleToHandleExceptions(ExecutionContext executionContext) {
- /* if an exception is already set, we are already handling an exception;
- * in this case don't give the exception to the handlers but throw it to the client
- * see https://jira.jboss.org/jira/browse/JBPM-1887 */
- if (executionContext.getException() != null)
- return false;
+ /*
+ * if an exception is already set, we are already handling an exception; in this case don't give
+ * the exception to the handlers but throw it to the client see
+ * https://jira.jboss.org/jira/browse/JBPM-1887
+ */
+ if (executionContext.getException() != null) return false;
- /* check whether the transaction is still active before scanning the exception handlers.
- * that way we can load the exception handlers lazily
- * see https://jira.jboss.org/jira/browse/JBPM-1775 */
+ /*
+ * check whether the transaction is still active before scanning the exception handlers. that
+ * way we can load the exception handlers lazily see
+ * https://jira.jboss.org/jira/browse/JBPM-1775
+ */
JbpmContext jbpmContext = executionContext.getJbpmContext();
if (jbpmContext != null) {
Services services = jbpmContext.getServices();
@@ -413,7 +432,8 @@
Service service = services.getPersistenceService();
if (service instanceof DbPersistenceService) {
DbPersistenceService persistenceService = (DbPersistenceService) service;
- return persistenceService.isTransactionActive() || persistenceService.getTransaction() == null;
+ return persistenceService.isTransactionActive()
+ || persistenceService.getTransaction() == null;
}
}
}
@@ -472,8 +492,8 @@
}
public String toString() {
- return getClass().getSimpleName() + (name != null ? '(' + name + ')'
- : '@' + Integer.toHexString(hashCode()));
+ return ClassUtil.getSimpleName(getClass())
+ + (name != null ? '(' + name + ')' : '@' + Integer.toHexString(hashCode()));
}
// equals ///////////////////////////////////////////////////////////////////
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -32,6 +32,7 @@
import java.util.Set;
import org.dom4j.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.graph.action.ActionTypes;
import org.jbpm.graph.exe.ExecutionContext;
@@ -44,47 +45,57 @@
import org.jbpm.svc.Services;
import org.jbpm.util.Clock;
-public class Node extends GraphElement implements Parsable
-{
+public class Node extends GraphElement implements Parsable {
private static final long serialVersionUID = 1L;
-
- public enum NodeType { Node, StartState, EndState, State, Task, Fork, Join, Decision };
- protected List<Transition> leavingTransitions = null;
+ public static class NodeType {
+
+ private final String name;
+
+ public static final NodeType Node = new NodeType("Node");
+ public static final NodeType StartState = new NodeType("StartState");
+ public static final NodeType EndState = new NodeType("EndState");
+ public static final NodeType State = new NodeType("State");
+ public static final NodeType Task = new NodeType("Task");
+ public static final NodeType Fork = new NodeType("Fork");
+ public static final NodeType Join = new NodeType("Join");
+ public static final NodeType Decision = new NodeType("Decision");
+
+ protected NodeType(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+ };
+
+ protected List leavingTransitions = null;
transient Map leavingTransitionMap = null;
- protected Set<Transition> arrivingTransitions = null;
+ protected Set arrivingTransitions = null;
protected Action action = null;
protected SuperState superState = null;
protected boolean isAsync = false;
protected boolean isAsyncExclusive = false;
-
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.Node;
}
-
- public String getNameExt()
- {
+
+ public String getNameExt() {
String name = super.getName();
- if (name == null)
- name = "#anonymous" + getNodeType();
-
+ if (name == null) name = "#anonymous" + getNodeType();
+
return name;
}
// event types //////////////////////////////////////////////////////////////
- public static final String[] supportedEventTypes = new String[] {
- Event.EVENTTYPE_NODE_ENTER,
- Event.EVENTTYPE_NODE_LEAVE,
- Event.EVENTTYPE_BEFORE_SIGNAL,
- Event.EVENTTYPE_AFTER_SIGNAL
- };
+ public static final String[] supportedEventTypes = new String[] { Event.EVENTTYPE_NODE_ENTER,
+ Event.EVENTTYPE_NODE_LEAVE, Event.EVENTTYPE_BEFORE_SIGNAL, Event.EVENTTYPE_AFTER_SIGNAL };
- public String[] getSupportedEventTypes()
- {
+ public String[] getSupportedEventTypes() {
return supportedEventTypes;
}
@@ -93,27 +104,22 @@
/**
* creates an unnamed node.
*/
- public Node()
- {
+ public Node() {
}
/**
* creates a node with the given name.
*/
- public Node(String name)
- {
+ public Node(String name) {
super(name);
}
- public void read(Element nodeElement, JpdlXmlReader jpdlXmlReader)
- {
+ public void read(Element nodeElement, JpdlXmlReader jpdlXmlReader) {
action = jpdlXmlReader.readSingleAction(nodeElement);
}
- public void write(Element nodeElement)
- {
- if (action != null)
- {
+ public void write(Element nodeElement) {
+ if (action != null) {
String actionName = ActionTypes.getActionName(action.getClass());
Element actionElement = nodeElement.addElement(actionName);
action.write(actionElement);
@@ -122,29 +128,24 @@
// leaving transitions //////////////////////////////////////////////////////
- public List<Transition> getLeavingTransitions()
- {
+ public List getLeavingTransitions() {
return leavingTransitions;
}
- public List<Transition> getLeavingTransitionsList()
- {
+ public List getLeavingTransitionsList() {
return leavingTransitions;
}
/**
* are the leaving {@link Transition}s, mapped by their name (java.lang.String).
*/
- public Map getLeavingTransitionsMap()
- {
- if ((leavingTransitionMap == null) && (leavingTransitions != null))
- {
+ public Map getLeavingTransitionsMap() {
+ if ((leavingTransitionMap == null) && (leavingTransitions != null)) {
// initialize the cached leaving transition map
leavingTransitionMap = new HashMap();
ListIterator iter = leavingTransitions.listIterator(leavingTransitions.size());
- while (iter.hasPrevious())
- {
- Transition leavingTransition = (Transition)iter.previous();
+ while (iter.hasPrevious()) {
+ Transition leavingTransition = (Transition) iter.previous();
leavingTransitionMap.put(leavingTransition.getName(), leavingTransition);
}
}
@@ -156,12 +157,10 @@
*
* @throws IllegalArgumentException if leavingTransition is null.
*/
- public Transition addLeavingTransition(Transition leavingTransition)
- {
+ public Transition addLeavingTransition(Transition leavingTransition) {
if (leavingTransition == null)
throw new IllegalArgumentException("can't add a null leaving transition to an node");
- if (leavingTransitions == null)
- leavingTransitions = new ArrayList();
+ if (leavingTransitions == null) leavingTransitions = new ArrayList();
leavingTransitions.add(leavingTransition);
leavingTransition.from = this;
leavingTransitionMap = null;
@@ -173,14 +172,11 @@
*
* @throws IllegalArgumentException if leavingTransition is null.
*/
- public void removeLeavingTransition(Transition leavingTransition)
- {
+ public void removeLeavingTransition(Transition leavingTransition) {
if (leavingTransition == null)
throw new IllegalArgumentException("can't remove a null leavingTransition from an node");
- if (leavingTransitions != null)
- {
- if (leavingTransitions.remove(leavingTransition))
- {
+ if (leavingTransitions != null) {
+ if (leavingTransitions.remove(leavingTransition)) {
leavingTransition.from = null;
leavingTransitionMap = null;
}
@@ -192,26 +188,21 @@
*
* @return true if this node has a leaving transition with the given name, false otherwise.
*/
- public boolean hasLeavingTransition(String transitionName)
- {
- if (leavingTransitions == null)
- return false;
+ public boolean hasLeavingTransition(String transitionName) {
+ if (leavingTransitions == null) return false;
return getLeavingTransitionsMap().containsKey(transitionName);
}
/**
- * retrieves a leaving transition by name. note that also the leaving transitions of the supernode are taken into
- * account.
+ * retrieves a leaving transition by name. note that also the leaving transitions of the supernode
+ * are taken into account.
*/
- public Transition getLeavingTransition(String transitionName)
- {
+ public Transition getLeavingTransition(String transitionName) {
Transition transition = null;
- if (leavingTransitions != null)
- {
- transition = (Transition)getLeavingTransitionsMap().get(transitionName);
+ if (leavingTransitions != null) {
+ transition = (Transition) getLeavingTransitionsMap().get(transitionName);
}
- if ((transition == null) && (superState != null))
- {
+ if ((transition == null) && (superState != null)) {
transition = superState.getLeavingTransition(transitionName);
}
return transition;
@@ -220,19 +211,16 @@
/**
* true if this transition has leaving transitions.
*/
- public boolean hasNoLeavingTransitions()
- {
+ public boolean hasNoLeavingTransitions() {
return (((leavingTransitions == null) || (leavingTransitions.size() == 0)) && ((superState == null) || (superState.hasNoLeavingTransitions())));
}
/**
* generates a new name for a transition that will be added as a leaving transition.
*/
- public String generateNextLeavingTransitionName()
- {
+ public String generateNextLeavingTransitionName() {
String name = null;
- if (leavingTransitions != null && containsName(leavingTransitions, null))
- {
+ if (leavingTransitions != null && containsName(leavingTransitions, null)) {
int n = 1;
while (containsName(leavingTransitions, Integer.toString(n)))
n++;
@@ -241,18 +229,14 @@
return name;
}
- boolean containsName(List leavingTransitions, String name)
- {
+ boolean containsName(List leavingTransitions, String name) {
Iterator iter = leavingTransitions.iterator();
- while (iter.hasNext())
- {
- Transition transition = (Transition)iter.next();
- if ((name == null) && (transition.getName() == null))
- {
+ while (iter.hasNext()) {
+ Transition transition = (Transition) iter.next();
+ if ((name == null) && (transition.getName() == null)) {
return true;
}
- else if ((name != null) && (name.equals(transition.getName())))
- {
+ else if ((name != null) && (name.equals(transition.getName()))) {
return true;
}
}
@@ -264,23 +248,19 @@
/**
* is the default leaving transition.
*/
- public Transition getDefaultLeavingTransition()
- {
+ public Transition getDefaultLeavingTransition() {
Transition defaultTransition = null;
- if (leavingTransitions != null)
- {
+ if (leavingTransitions != null) {
// Select the first unconditional transition
- for (Transition auxTransition : leavingTransitions)
- {
- if (auxTransition.getCondition() == null)
- {
+ for (Iterator i = leavingTransitions.iterator(); i.hasNext();) {
+ Transition auxTransition = (Transition) i.next();
+ if (auxTransition.getCondition() == null) {
defaultTransition = auxTransition;
break;
}
}
}
- else if (superState != null)
- {
+ else if (superState != null) {
defaultTransition = superState.getDefaultLeavingTransition();
}
return defaultTransition;
@@ -289,12 +269,12 @@
/**
* moves one leaving transition from the oldIndex and inserts it at the newIndex.
*/
- public void reorderLeavingTransition(int oldIndex, int newIndex)
- {
- if ((leavingTransitions != null) && (Math.min(oldIndex, newIndex) >= 0) && (Math.max(oldIndex, newIndex) < leavingTransitions.size()))
- {
- Transition o = leavingTransitions.remove(oldIndex);
- leavingTransitions.add(newIndex, o);
+ public void reorderLeavingTransition(int oldIndex, int newIndex) {
+ if (leavingTransitions != null
+ && Math.min(oldIndex, newIndex) >= 0
+ && Math.max(oldIndex, newIndex) < leavingTransitions.size()) {
+ Object transition = leavingTransitions.remove(oldIndex);
+ leavingTransitions.add(newIndex, transition);
}
}
@@ -303,8 +283,7 @@
/**
* are the arriving transitions.
*/
- public Set<Transition> getArrivingTransitions()
- {
+ public Set getArrivingTransitions() {
return arrivingTransitions;
}
@@ -313,12 +292,10 @@
*
* @throws IllegalArgumentException if t is null.
*/
- public Transition addArrivingTransition(Transition arrivingTransition)
- {
+ public Transition addArrivingTransition(Transition arrivingTransition) {
if (arrivingTransition == null)
throw new IllegalArgumentException("can't add a null arrivingTransition to a node");
- if (arrivingTransitions == null)
- arrivingTransitions = new HashSet();
+ if (arrivingTransitions == null) arrivingTransitions = new HashSet();
arrivingTransitions.add(arrivingTransition);
arrivingTransition.to = this;
return arrivingTransition;
@@ -329,14 +306,11 @@
*
* @throws IllegalArgumentException if t is null.
*/
- public void removeArrivingTransition(Transition arrivingTransition)
- {
+ public void removeArrivingTransition(Transition arrivingTransition) {
if (arrivingTransition == null)
throw new IllegalArgumentException("can't remove a null arrivingTransition from a node");
- if (arrivingTransitions != null)
- {
- if (arrivingTransitions.remove(arrivingTransition))
- {
+ if (arrivingTransitions != null) {
+ if (arrivingTransitions.remove(arrivingTransition)) {
arrivingTransition.to = null;
}
}
@@ -347,11 +321,9 @@
/**
* is the {@link SuperState} or the {@link ProcessDefinition} in which this node is contained.
*/
- public GraphElement getParent()
- {
+ public GraphElement getParent() {
GraphElement parent = processDefinition;
- if (superState != null)
- parent = superState;
+ if (superState != null) parent = superState;
return parent;
}
@@ -360,8 +332,7 @@
/**
* called by a transition to pass execution to this node.
*/
- public void enter(ExecutionContext executionContext)
- {
+ public void enter(ExecutionContext executionContext) {
Token token = executionContext.getToken();
// update the runtime context information
@@ -378,21 +349,18 @@
executionContext.setTransitionSource(null);
// execute the node
- if (isAsync)
- {
+ if (isAsync) {
ExecuteNodeJob job = createAsyncContinuationJob(token);
- MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE);
+ MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE);
messageService.send(job);
token.lock(job.toString());
}
- else
- {
+ else {
execute(executionContext);
}
}
- protected ExecuteNodeJob createAsyncContinuationJob(Token token)
- {
+ protected ExecuteNodeJob createAsyncContinuationJob(Token token) {
ExecuteNodeJob job = new ExecuteNodeJob(token);
job.setNode(this);
job.setDueDate(new Date());
@@ -403,27 +371,22 @@
/**
* override this method to customize the node behaviour.
*/
- public void execute(ExecutionContext executionContext)
- {
+ public void execute(ExecutionContext executionContext) {
// if there is a custom action associated with this node
- if (action != null)
- {
- try
- {
+ if (action != null) {
+ try {
// execute the action
executeAction(action, executionContext);
}
- catch (Exception exception)
- {
+ catch (Exception exception) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
// search for an exception handler or throw to the client
raiseException(exception, executionContext);
}
}
- else
- {
+ else {
// let this node handle the token
// the default behaviour is to leave the node over the default transition.
leave(executionContext);
@@ -433,20 +396,21 @@
/**
* called by the implementation of this node to continue execution over the default transition.
*/
- public void leave(ExecutionContext executionContext)
- {
+ public void leave(ExecutionContext executionContext) {
leave(executionContext, getDefaultLeavingTransition());
}
/**
* called by the implementation of this node to continue execution over the specified transition.
*/
- public void leave(ExecutionContext executionContext, String transitionName)
- {
+ public void leave(ExecutionContext executionContext, String transitionName) {
Transition transition = getLeavingTransition(transitionName);
- if (transition == null)
- {
- throw new JbpmException("transition '" + transitionName + "' is not a leaving transition of node '" + this + "'");
+ if (transition == null) {
+ throw new JbpmException("transition '"
+ + transitionName
+ + "' is not a leaving transition of node '"
+ + this
+ + "'");
}
leave(executionContext, transition);
}
@@ -454,8 +418,7 @@
/**
* called by the implementation of this node to continue execution over the given transition.
*/
- public void leave(ExecutionContext executionContext, Transition transition)
- {
+ public void leave(ExecutionContext executionContext, Transition transition) {
if (transition == null)
throw new JbpmException("can't leave node '" + this + "' without leaving transition");
Token token = executionContext.getToken();
@@ -466,8 +429,7 @@
fireEvent(Event.EVENTTYPE_NODE_LEAVE, executionContext);
// log this node
- if (token.getNodeEnter() != null)
- {
+ if (token.getNodeEnter() != null) {
addNodeLog(token);
}
@@ -479,18 +441,15 @@
transition.take(executionContext);
}
- protected void addNodeLog(Token token)
- {
+ protected void addNodeLog(Token token) {
token.addLog(new NodeLog(this, token.getNodeEnter(), Clock.getCurrentTime()));
}
// ///////////////////////////////////////////////////////////////////////////
- public ProcessDefinition getProcessDefinition()
- {
+ public ProcessDefinition getProcessDefinition() {
ProcessDefinition pd = this.processDefinition;
- if (superState != null)
- {
+ if (superState != null) {
pd = superState.getProcessDefinition();
}
return pd;
@@ -500,28 +459,30 @@
/**
* updates the name of this node
*/
- public void setName(String name)
- {
- if (isDifferent(this.name, name))
- {
+ public void setName(String name) {
+ if (isDifferent(this.name, name)) {
String oldName = this.name;
- if (superState != null)
- {
- if (superState.hasNode(name))
- {
- throw new IllegalArgumentException("couldn't set name '" + name + "' on node '" + this
- + "'cause the superState of this node has already another child node with the same name");
+ if (superState != null) {
+ if (superState.hasNode(name)) {
+ throw new IllegalArgumentException(
+ "couldn't set name '"
+ + name
+ + "' on node '"
+ + this
+ + "'cause the superState of this node has already another child node with the same name");
}
Map nodes = superState.getNodesMap();
nodes.remove(oldName);
nodes.put(name, this);
}
- else if (processDefinition != null)
- {
- if (processDefinition.hasNode(name))
- {
- throw new IllegalArgumentException("couldn't set name '" + name + "' on node '" + this
- + "'cause the process definition of this node has already another node with the same name");
+ else if (processDefinition != null) {
+ if (processDefinition.hasNode(name)) {
+ throw new IllegalArgumentException(
+ "couldn't set name '"
+ + name
+ + "' on node '"
+ + this
+ + "'cause the process definition of this node has already another node with the same name");
}
Map nodeMap = processDefinition.getNodesMap();
nodeMap.remove(oldName);
@@ -531,14 +492,11 @@
}
}
- boolean isDifferent(String name1, String name2)
- {
- if ((name1 != null) && (name1.equals(name2)))
- {
+ boolean isDifferent(String name1, String name2) {
+ if ((name1 != null) && (name1.equals(name2))) {
return false;
}
- else if ((name1 == null) && (name2 == null))
- {
+ else if ((name1 == null) && (name2 == null)) {
return false;
}
return true;
@@ -547,62 +505,51 @@
/**
* the slash separated name that includes all the superstate names.
*/
- public String getFullyQualifiedName()
- {
+ public String getFullyQualifiedName() {
String fullyQualifiedName = name;
- if (superState != null)
- {
+ if (superState != null) {
fullyQualifiedName = superState.getFullyQualifiedName() + "/" + name;
}
return fullyQualifiedName;
}
/** indicates wether this node is a superstate. */
- public boolean isSuperStateNode()
- {
+ public boolean isSuperStateNode() {
return false;
}
/** returns a list of child nodes (only applicable for {@link SuperState})s. */
- public List getNodes()
- {
+ public List getNodes() {
return null;
}
// getters and setters //////////////////////////////////////////////////////
- public SuperState getSuperState()
- {
+ public SuperState getSuperState() {
return superState;
}
- public Action getAction()
- {
+ public Action getAction() {
return action;
}
- public void setAction(Action action)
- {
+ public void setAction(Action action) {
this.action = action;
}
- public boolean isAsync()
- {
+ public boolean isAsync() {
return isAsync;
}
- public void setAsync(boolean isAsync)
- {
+ public void setAsync(boolean isAsync) {
this.isAsync = isAsync;
}
- public boolean isAsyncExclusive()
- {
+ public boolean isAsyncExclusive() {
return isAsyncExclusive;
}
- public void setAsyncExclusive(boolean isAsyncExclusive)
- {
+ public void setAsyncExclusive(boolean isAsyncExclusive) {
this.isAsyncExclusive = isAsyncExclusive;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -35,6 +35,8 @@
import java.util.StringTokenizer;
import java.util.zip.ZipInputStream;
+import org.xml.sax.InputSource;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.context.def.ContextDefinition;
@@ -48,40 +50,29 @@
import org.jbpm.module.def.ModuleDefinition;
import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
import org.jbpm.util.ClassLoaderUtil;
-import org.xml.sax.InputSource;
public class ProcessDefinition extends GraphElement implements NodeCollection {
private static final long serialVersionUID = 1L;
-
+
protected int version = -1;
protected boolean isTerminationImplicit = false;
protected Node startState = null;
- protected List<Node> nodes = null;
+ protected List nodes = null;
transient Map nodesMap = null;
protected Map actions = null;
protected Map definitions = null;
// event types //////////////////////////////////////////////////////////////
- public static final String[] supportedEventTypes = new String[]{
- Event.EVENTTYPE_PROCESS_START,
- Event.EVENTTYPE_PROCESS_END,
- Event.EVENTTYPE_NODE_ENTER,
- Event.EVENTTYPE_NODE_LEAVE,
- Event.EVENTTYPE_TASK_CREATE,
- Event.EVENTTYPE_TASK_ASSIGN,
- Event.EVENTTYPE_TASK_START,
- Event.EVENTTYPE_TASK_END,
- Event.EVENTTYPE_TRANSITION,
- Event.EVENTTYPE_BEFORE_SIGNAL,
- Event.EVENTTYPE_AFTER_SIGNAL,
- Event.EVENTTYPE_SUPERSTATE_ENTER,
- Event.EVENTTYPE_SUPERSTATE_LEAVE,
- Event.EVENTTYPE_SUBPROCESS_CREATED,
- Event.EVENTTYPE_SUBPROCESS_END,
- Event.EVENTTYPE_TIMER
- };
+ public static final String[] supportedEventTypes = new String[] { Event.EVENTTYPE_PROCESS_START,
+ Event.EVENTTYPE_PROCESS_END, Event.EVENTTYPE_NODE_ENTER, Event.EVENTTYPE_NODE_LEAVE,
+ Event.EVENTTYPE_TASK_CREATE, Event.EVENTTYPE_TASK_ASSIGN, Event.EVENTTYPE_TASK_START,
+ Event.EVENTTYPE_TASK_END, Event.EVENTTYPE_TRANSITION, Event.EVENTTYPE_BEFORE_SIGNAL,
+ Event.EVENTTYPE_AFTER_SIGNAL, Event.EVENTTYPE_SUPERSTATE_ENTER,
+ Event.EVENTTYPE_SUPERSTATE_LEAVE, Event.EVENTTYPE_SUBPROCESS_CREATED,
+ Event.EVENTTYPE_SUBPROCESS_END, Event.EVENTTYPE_TIMER };
+
public String[] getSupportedEventTypes() {
return supportedEventTypes;
}
@@ -94,7 +85,7 @@
public static ProcessDefinition createNewProcessDefinition() {
ProcessDefinition processDefinition = new ProcessDefinition();
-
+
// now add all the default modules that are configured in the file jbpm.default.modules
String resource = JbpmConfiguration.Configs.getString("resource.default.modules");
Properties defaultModulesProperties = ClassLoaderUtil.getProperties(resource);
@@ -102,12 +93,14 @@
while (iter.hasNext()) {
String moduleClassName = (String) iter.next();
try {
- ModuleDefinition moduleDefinition = (ModuleDefinition) ClassLoaderUtil.loadClass(moduleClassName).newInstance();
+ ModuleDefinition moduleDefinition = (ModuleDefinition) ClassLoaderUtil.loadClass(
+ moduleClassName).newInstance();
processDefinition.addDefinition(moduleDefinition);
-
- } catch (Exception e) {
- throw new JbpmException("couldn't instantiate default module '"+moduleClassName+"'", e);
+
}
+ catch (Exception e) {
+ throw new JbpmException("couldn't instantiate default module '" + moduleClassName + "'", e);
+ }
}
return processDefinition;
}
@@ -135,15 +128,17 @@
}
public void setProcessDefinition(ProcessDefinition processDefinition) {
- if (! this.equals(processDefinition)) {
- throw new JbpmException("can't set the process-definition-property of a process defition to something else then a self-reference");
+ if (!this.equals(processDefinition)) {
+ throw new JbpmException(
+ "can't set the process-definition-property of a process defition to something else then a self-reference");
}
}
// parsing //////////////////////////////////////////////////////////////////
-
+
/**
* parse a process definition from an xml string.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
public static ProcessDefinition parseXmlString(String xml) {
@@ -154,6 +149,7 @@
/**
* parse a process definition from an xml resource file.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
public static ProcessDefinition parseXmlResource(String xmlResource) {
@@ -161,21 +157,23 @@
if (resourceURL == null) {
throw new JpdlException("resource not found: " + xmlResource);
}
- JpdlXmlReader jpdlReader = new JpdlXmlReader(new InputSource(resourceURL.toString()));
+ JpdlXmlReader jpdlReader = new JpdlXmlReader(new InputSource(resourceURL.toString()));
return jpdlReader.readProcessDefinition();
}
/**
* parse a process definition from an xml input stream.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
public static ProcessDefinition parseXmlInputStream(InputStream inputStream) {
- JpdlXmlReader jpdlReader = new JpdlXmlReader(new InputSource(inputStream));
+ JpdlXmlReader jpdlReader = new JpdlXmlReader(new InputSource(inputStream));
return jpdlReader.readProcessDefinition();
}
/**
* parse a process definition from an xml reader.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
public static ProcessDefinition parseXmlReader(Reader reader) {
@@ -185,14 +183,17 @@
/**
* parse a process definition from a process archive zip-stream.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
- public static ProcessDefinition parseParZipInputStream(ZipInputStream zipInputStream) throws IOException {
+ public static ProcessDefinition parseParZipInputStream(ZipInputStream zipInputStream)
+ throws IOException {
return new ProcessArchive(zipInputStream).parseProcessDefinition();
}
/**
* parse a process definition from a process archive resource.
+ *
* @throws org.jbpm.jpdl.JpdlException if parsing reported an error.
*/
public static ProcessDefinition parseParResource(String parResource) throws IOException {
@@ -202,19 +203,19 @@
// nodes ////////////////////////////////////////////////////////////////////
// javadoc description in NodeCollection
- public List<Node> getNodes() {
+ public List getNodes() {
return nodes;
}
// javadoc description in NodeCollection
public Map getNodesMap() {
- if (nodesMap==null) {
+ if (nodesMap == null) {
nodesMap = new HashMap();
- if (nodes!=null) {
+ if (nodes != null) {
Iterator iter = nodes.iterator();
while (iter.hasNext()) {
Node node = (Node) iter.next();
- nodesMap.put(node.getName(),node);
+ nodesMap.put(node.getName(), node);
}
}
}
@@ -223,27 +224,26 @@
// javadoc description in NodeCollection
public Node getNode(String name) {
- if (nodes==null) return null;
+ if (nodes == null) return null;
return (Node) getNodesMap().get(name);
}
// javadoc description in NodeCollection
public boolean hasNode(String name) {
- if (nodes==null) return false;
+ if (nodes == null) return false;
return getNodesMap().containsKey(name);
}
// javadoc description in NodeCollection
public Node addNode(Node node) {
- if (node == null) throw new IllegalArgumentException("can't add a null node to a processdefinition");
+ if (node == null)
+ throw new IllegalArgumentException("can't add a null node to a processdefinition");
if (nodes == null) nodes = new ArrayList();
nodes.add(node);
node.processDefinition = this;
nodesMap = null;
-
- if( (node instanceof StartState)
- && (this.startState==null)
- ) {
+
+ if ((node instanceof StartState) && (this.startState == null)) {
this.startState = node;
}
return node;
@@ -252,7 +252,8 @@
// javadoc description in NodeCollection
public Node removeNode(Node node) {
Node removedNode = null;
- if (node == null) throw new IllegalArgumentException("can't remove a null node from a process definition");
+ if (node == null)
+ throw new IllegalArgumentException("can't remove a null node from a process definition");
if (nodes != null) {
if (nodes.remove(node)) {
removedNode = node;
@@ -260,8 +261,8 @@
nodesMap = null;
}
}
-
- if (startState==removedNode) {
+
+ if (startState == removedNode) {
startState = null;
}
return removedNode;
@@ -269,14 +270,18 @@
// javadoc description in NodeCollection
public void reorderNode(int oldIndex, int newIndex) {
- if ( (nodes!=null)
- && (Math.min(oldIndex, newIndex)>=0)
- && (Math.max(oldIndex, newIndex)<nodes.size()) ) {
- Node o = nodes.remove(oldIndex);
- nodes.add(newIndex, o);
- } else {
- throw new IndexOutOfBoundsException("couldn't reorder element from index '"+oldIndex+"' to index '"+newIndex+"' in nodeList '"+nodes+"'");
+ if (nodes != null
+ && Math.min(oldIndex, newIndex) >= 0
+ && Math.max(oldIndex, newIndex) < nodes.size()) {
+ Object node = nodes.remove(oldIndex);
+ nodes.add(newIndex, node);
}
+ else {
+ throw new IndexOutOfBoundsException("couldn't reorder element from index "
+ + oldIndex
+ + " to index "
+ + newIndex);
+ }
}
// javadoc description in NodeCollection
@@ -291,11 +296,13 @@
public static String generateNodeName(List nodes) {
String name = null;
- if (nodes==null) {
+ if (nodes == null) {
name = "1";
- } else {
+ }
+ else {
int n = 1;
- while (containsName(nodes, Integer.toString(n))) n++;
+ while (containsName(nodes, Integer.toString(n)))
+ n++;
name = Integer.toString(n);
}
return name;
@@ -305,7 +312,7 @@
Iterator iter = nodes.iterator();
while (iter.hasNext()) {
Node node = (Node) iter.next();
- if ( name.equals(node.getName()) ) {
+ if (name.equals(node.getName())) {
return true;
}
}
@@ -314,38 +321,40 @@
public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) {
Node node = null;
- if ((hierarchicalName != null) && (!"".equals(hierarchicalName.trim())) ) {
-
- if ( (hierarchicalName.startsWith("/"))
- && (nodeCollection instanceof SuperState) ){
- nodeCollection = ((SuperState)nodeCollection).getProcessDefinition();
+ if ((hierarchicalName != null) && (!"".equals(hierarchicalName.trim()))) {
+
+ if ((hierarchicalName.startsWith("/")) && (nodeCollection instanceof SuperState)) {
+ nodeCollection = ((SuperState) nodeCollection).getProcessDefinition();
}
StringTokenizer tokenizer = new StringTokenizer(hierarchicalName, "/");
while (tokenizer.hasMoreElements()) {
String namePart = tokenizer.nextToken();
- if ("..".equals(namePart) ) {
+ if ("..".equals(namePart)) {
if (nodeCollection instanceof ProcessDefinition) {
- throw new JbpmException("couldn't find node '"+hierarchicalName+"' because of a '..' on the process definition.");
+ throw new JbpmException("couldn't find node '"
+ + hierarchicalName
+ + "' because of a '..' on the process definition.");
}
- nodeCollection = (NodeCollection) ((GraphElement)nodeCollection).getParent();
- } else if ( tokenizer.hasMoreElements() ) {
- nodeCollection = (NodeCollection)nodeCollection.getNode(namePart);
- } else {
+ nodeCollection = (NodeCollection) ((GraphElement) nodeCollection).getParent();
+ }
+ else if (tokenizer.hasMoreElements()) {
+ nodeCollection = (NodeCollection) nodeCollection.getNode(namePart);
+ }
+ else {
node = nodeCollection.getNode(namePart);
}
}
}
return node;
}
-
+
public void setStartState(StartState startState) {
- if ( (this.startState!=startState)
- && (this.startState!=null) ){
+ if ((this.startState != startState) && (this.startState != null)) {
removeNode(this.startState);
}
this.startState = startState;
- if (startState!=null) {
+ if (startState != null) {
addNode(startState);
}
}
@@ -358,11 +367,14 @@
/**
* creates a bidirectional relation between this process definition and the given action.
+ *
* @throws IllegalArgumentException if action is null or if action.getName() is null.
*/
public Action addAction(Action action) {
- if (action == null) throw new IllegalArgumentException("can't add a null action to an process definition");
- if (action.getName() == null) throw new IllegalArgumentException("can't add an unnamed action to an process definition");
+ if (action == null)
+ throw new IllegalArgumentException("can't add a null action to an process definition");
+ if (action.getName() == null)
+ throw new IllegalArgumentException("can't add an unnamed action to an process definition");
if (actions == null) actions = new HashMap();
actions.put(action.getName(), action);
action.processDefinition = this;
@@ -371,13 +383,17 @@
/**
* removes the bidirectional relation between this process definition and the given action.
- * @throws IllegalArgumentException if action is null or if the action was not present in the actions of this process definition.
+ *
+ * @throws IllegalArgumentException if action is null or if the action was not present in the
+ * actions of this process definition.
*/
public void removeAction(Action action) {
- if (action == null) throw new IllegalArgumentException("can't remove a null action from an process definition");
+ if (action == null)
+ throw new IllegalArgumentException("can't remove a null action from an process definition");
if (actions != null) {
- if (! actions.containsValue(action)) {
- throw new IllegalArgumentException("can't remove an action that is not part of this process definition");
+ if (!actions.containsValue(action)) {
+ throw new IllegalArgumentException(
+ "can't remove an action that is not part of this process definition");
}
actions.remove(action.getName());
action.processDefinition = null;
@@ -388,14 +404,13 @@
if (actions == null) return null;
return (Action) actions.get(name);
}
-
+
public Map getActions() {
return actions;
}
public boolean hasActions() {
- return ( (actions!=null)
- && (actions.size()>0) );
+ return ((actions != null) && (actions.size() > 0));
}
// module definitions ///////////////////////////////////////////////////////
@@ -405,20 +420,24 @@
}
public ModuleDefinition addDefinition(ModuleDefinition moduleDefinition) {
- if (moduleDefinition == null) throw new IllegalArgumentException("can't add a null moduleDefinition to a process definition");
- if (definitions == null)
- definitions = new HashMap();
+ if (moduleDefinition == null)
+ throw new IllegalArgumentException(
+ "can't add a null moduleDefinition to a process definition");
+ if (definitions == null) definitions = new HashMap();
definitions.put(moduleDefinition.getClass().getName(), moduleDefinition);
moduleDefinition.setProcessDefinition(this);
return moduleDefinition;
}
-
+
public ModuleDefinition removeDefinition(ModuleDefinition moduleDefinition) {
ModuleDefinition removedDefinition = null;
- if (moduleDefinition == null) throw new IllegalArgumentException("can't remove a null moduleDefinition from a process definition");
+ if (moduleDefinition == null)
+ throw new IllegalArgumentException(
+ "can't remove a null moduleDefinition from a process definition");
if (definitions != null) {
- removedDefinition = (ModuleDefinition) definitions.remove(moduleDefinition.getClass().getName());
- if (removedDefinition!=null) {
+ removedDefinition = (ModuleDefinition) definitions.remove(moduleDefinition.getClass()
+ .getName());
+ if (removedDefinition != null) {
moduleDefinition.setProcessDefinition(null);
}
}
@@ -432,7 +451,7 @@
}
return moduleDefinition;
}
-
+
public ContextDefinition getContextDefinition() {
return (ContextDefinition) getDefinition(ContextDefinition.class);
}
@@ -440,6 +459,7 @@
public FileDefinition getFileDefinition() {
return (FileDefinition) getDefinition(FileDefinition.class);
}
+
public TaskMgmtDefinition getTaskMgmtDefinition() {
return (TaskMgmtDefinition) getDefinition(TaskMgmtDefinition.class);
}
@@ -465,7 +485,7 @@
public Node getStartState() {
return startState;
}
-
+
public void setStartState(Node startState) {
this.startState = startState;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -33,7 +33,6 @@
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.context.exe.ContextInstance;
-import org.jbpm.db.JobSession;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Identifiable;
import org.jbpm.graph.def.Node;
@@ -54,12 +53,10 @@
import org.jbpm.util.EqualsUtil;
/**
- * is one execution of a {@link org.jbpm.graph.def.ProcessDefinition}. To create a new process execution of a process
- * definition, just use the {@link #ProcessInstance(ProcessDefinition)}.
- *
+ * is one execution of a {@link org.jbpm.graph.def.ProcessDefinition}. To create a new process
+ * execution of a process definition, just use the {@link #ProcessInstance(ProcessDefinition)}.
*/
-public class ProcessInstance implements Identifiable, Serializable
-{
+public class ProcessInstance implements Identifiable, Serializable {
private static final long serialVersionUID = 1L;
@@ -80,53 +77,51 @@
// constructors /////////////////////////////////////////////////////////////
- public ProcessInstance()
- {
+ public ProcessInstance() {
}
/**
- * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
- * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
- * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
- * module instance will be created.
+ * creates a new process instance for the given process definition, puts the root-token (=main
+ * path of execution) in the start state and executes the initial node. In case the initial node
+ * is a start-state, it will behave as a wait state. For each of the optional module definitions
+ * contained in the {@link ProcessDefinition}, the corresponding module instance will be created.
*
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition)
- {
+ public ProcessInstance(ProcessDefinition processDefinition) {
this(processDefinition, null, null);
}
/**
- * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
- * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
- * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
- * module instance will be created.
+ * creates a new process instance for the given process definition, puts the root-token (=main
+ * path of execution) in the start state and executes the initial node. In case the initial node
+ * is a start-state, it will behave as a wait state. For each of the optional module definitions
+ * contained in the {@link ProcessDefinition}, the corresponding module instance will be created.
*
- * @param variables will be inserted into the context variables after the context submodule has been created and
- * before the process-start event is fired, which is also before the execution of the initial node.
+ * @param variables will be inserted into the context variables after the context submodule has
+ * been created and before the process-start event is fired, which is also before the
+ * execution of the initial node.
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition, Map variables)
- {
+ public ProcessInstance(ProcessDefinition processDefinition, Map variables) {
this(processDefinition, variables, null);
}
/**
- * creates a new process instance for the given process definition, puts the root-token (=main path of execution) in
- * the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait
- * state. For each of the optional module definitions contained in the {@link ProcessDefinition}, the corresponding
- * module instance will be created.
+ * creates a new process instance for the given process definition, puts the root-token (=main
+ * path of execution) in the start state and executes the initial node. In case the initial node
+ * is a start-state, it will behave as a wait state. For each of the optional module definitions
+ * contained in the {@link ProcessDefinition}, the corresponding module instance will be created.
*
- * @param variables will be inserted into the context variables after the context submodule has been created and
- * before the process-start event is fired, which is also before the execution of the initial node.
+ * @param variables will be inserted into the context variables after the context submodule has
+ * been created and before the process-start event is fired, which is also before the
+ * execution of the initial node.
* @throws JbpmException if processDefinition is null.
*/
- public ProcessInstance(ProcessDefinition processDefinition, Map variables, String key)
- {
- if (processDefinition == null)
+ public ProcessInstance(ProcessDefinition processDefinition, Map variables, String key) {
+ if (processDefinition == null) {
throw new JbpmException("can't create a process instance when processDefinition is null");
-
+ }
// initialize the members
this.processDefinition = processDefinition;
this.rootToken = new Token(this);
@@ -148,44 +143,35 @@
fireStartEvent(initialNode);
}
- public void addInitialContextVariables(Map variables)
- {
+ public void addInitialContextVariables(Map variables) {
ContextInstance contextInstance = getContextInstance();
- if ((contextInstance != null) && (variables != null))
- {
+ if ((contextInstance != null) && (variables != null)) {
contextInstance.addVariables(variables);
}
}
- public void addInitialModuleDefinitions(ProcessDefinition processDefinition)
- {
+ public void addInitialModuleDefinitions(ProcessDefinition processDefinition) {
Map definitions = processDefinition.getDefinitions();
// if the state-definition has optional definitions
- if (definitions != null)
- {
+ if (definitions != null) {
instances = new HashMap();
// loop over each optional definition
- Iterator iter = definitions.values().iterator();
- while (iter.hasNext())
- {
- ModuleDefinition definition = (ModuleDefinition)iter.next();
+ for (Iterator i = definitions.values().iterator(); i.hasNext();) {
+ ModuleDefinition definition = (ModuleDefinition) i.next();
// and create the corresponding optional instance
ModuleInstance instance = definition.createInstance();
- if (instance != null)
- {
+ if (instance != null) {
addInstance(instance);
}
}
}
}
- public void fireStartEvent(Node initialNode)
- {
+ public void fireStartEvent(Node initialNode) {
this.start = Clock.getCurrentTime();
-
+
// fire the process start event
- if (initialNode != null)
- {
+ if (initialNode != null) {
ExecutionContext executionContext = new ExecutionContext(rootToken);
processDefinition.fireEvent(Event.EVENTTYPE_PROCESS_START, executionContext);
@@ -199,12 +185,11 @@
/**
* adds the given optional moduleinstance (bidirectional).
*/
- public ModuleInstance addInstance(ModuleInstance moduleInstance)
- {
- if (moduleInstance == null)
+ public ModuleInstance addInstance(ModuleInstance moduleInstance) {
+ if (moduleInstance == null) {
throw new IllegalArgumentException("can't add a null moduleInstance to a process instance");
- if (instances == null)
- instances = new HashMap();
+ }
+ if (instances == null) instances = new HashMap();
instances.put(moduleInstance.getClass().getName(), moduleInstance);
moduleInstance.setProcessInstance(this);
return moduleInstance;
@@ -213,16 +198,15 @@
/**
* removes the given optional moduleinstance (bidirectional).
*/
- public ModuleInstance removeInstance(ModuleInstance moduleInstance)
- {
+ public ModuleInstance removeInstance(ModuleInstance moduleInstance) {
ModuleInstance removedModuleInstance = null;
- if (moduleInstance == null)
- throw new IllegalArgumentException("can't remove a null moduleInstance from a process instance");
- if (instances != null)
- {
- removedModuleInstance = (ModuleInstance)instances.remove(moduleInstance.getClass().getName());
- if (removedModuleInstance != null)
- {
+ if (moduleInstance == null) {
+ throw new IllegalArgumentException(
+ "can't remove a null moduleInstance from a process instance");
+ }
+ if (instances != null) {
+ removedModuleInstance = (ModuleInstance) instances.remove(moduleInstance.getClass().getName());
+ if (removedModuleInstance != null) {
moduleInstance.setProcessInstance(null);
}
}
@@ -232,33 +216,28 @@
/**
* looks up an optional module instance by its class.
*/
- public ModuleInstance getInstance(Class clazz)
- {
+ public ModuleInstance getInstance(Class clazz) {
ModuleInstance moduleInstance = null;
- if (instances != null)
- {
- moduleInstance = (ModuleInstance)instances.get(clazz.getName());
+ if (instances != null) {
+ moduleInstance = (ModuleInstance) instances.get(clazz.getName());
}
- if (moduleInstance == null)
- {
- if (transientInstances == null)
- transientInstances = new HashMap();
+ if (moduleInstance == null) {
+ if (transientInstances == null) transientInstances = new HashMap();
// client requested an instance that is not in the map of instances.
// so we can safely assume that the client wants a transient instance
- moduleInstance = (ModuleInstance)transientInstances.get(clazz.getName());
- if (moduleInstance == null)
- {
- try
- {
- moduleInstance = (ModuleInstance)clazz.newInstance();
+ moduleInstance = (ModuleInstance) transientInstances.get(clazz.getName());
+ if (moduleInstance == null) {
+ try {
+ moduleInstance = (ModuleInstance) clazz.newInstance();
moduleInstance.setProcessInstance(this);
}
- catch (Exception e)
- {
- throw new JbpmException("couldn't instantiate transient module '" + clazz.getName() + "' with the default constructor");
+ catch (Exception e) {
+ throw new JbpmException("couldn't instantiate transient module '"
+ + clazz.getName()
+ + "' with the default constructor");
}
transientInstances.put(clazz.getName(), moduleInstance);
}
@@ -270,67 +249,61 @@
/**
* process instance extension for process variableInstances.
*/
- public ContextInstance getContextInstance()
- {
- return (ContextInstance)getInstance(ContextInstance.class);
+ public ContextInstance getContextInstance() {
+ return (ContextInstance) getInstance(ContextInstance.class);
}
/**
* process instance extension for managing the tasks and actors.
*/
- public TaskMgmtInstance getTaskMgmtInstance()
- {
- return (TaskMgmtInstance)getInstance(TaskMgmtInstance.class);
+ public TaskMgmtInstance getTaskMgmtInstance() {
+ return (TaskMgmtInstance) getInstance(TaskMgmtInstance.class);
}
/**
- * process instance extension for logging. Probably you don't need to access the logging instance directly. Mostly,
- * {@link Token#addLog(ProcessLog)} is sufficient and more convenient.
+ * process instance extension for logging. Probably you don't need to access the logging instance
+ * directly. Mostly, {@link Token#addLog(ProcessLog)} is sufficient and more convenient.
*/
- public LoggingInstance getLoggingInstance()
- {
- return (LoggingInstance)getInstance(LoggingInstance.class);
+ public LoggingInstance getLoggingInstance() {
+ return (LoggingInstance) getInstance(LoggingInstance.class);
}
// operations ///////////////////////////////////////////////////////////////
/**
- * instructs the main path of execution to continue by taking the default transition on the current node.
+ * instructs the main path of execution to continue by taking the default transition on the
+ * current node.
*
* @throws IllegalStateException if the token is not active.
*/
- public void signal()
- {
- if (hasEnded())
- {
+ public void signal() {
+ if (hasEnded()) {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal();
}
/**
- * instructs the main path of execution to continue by taking the specified transition on the current node.
+ * instructs the main path of execution to continue by taking the specified transition on the
+ * current node.
*
* @throws IllegalStateException if the token is not active.
*/
- public void signal(String transitionName)
- {
- if (hasEnded())
- {
+ public void signal(String transitionName) {
+ if (hasEnded()) {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal(transitionName);
}
/**
- * instructs the main path of execution to continue by taking the specified transition on the current node.
+ * instructs the main path of execution to continue by taking the specified transition on the
+ * current node.
*
* @throws IllegalStateException if the token is not active.
*/
- public void signal(Transition transition)
- {
- if (hasEnded())
- {
+ public void signal(Transition transition) {
+ if (hasEnded()) {
throw new IllegalStateException("couldn't signal token : token has ended");
}
rootToken.signal(transition);
@@ -339,13 +312,11 @@
/**
* ends (=cancels) this process instance and all the tokens in it.
*/
- public void end()
- {
+ public void end() {
// end the main path of execution
rootToken.end();
- if (end == null)
- {
+ if (end == null) {
// mark this process instance as ended
end = Clock.getCurrentTime();
@@ -357,8 +328,7 @@
rootToken.addLog(new ProcessInstanceEndLog());
// check if this process was started as a subprocess of a super process
- if (superProcessToken != null && !superProcessToken.hasEnded())
- {
+ if (superProcessToken != null && !superProcessToken.hasEnded()) {
addCascadeProcessInstance(superProcessToken.getProcessInstance());
ExecutionContext superExecutionContext = new ExecutionContext(superProcessToken);
@@ -369,15 +339,13 @@
// make sure jobs for this process instance are canceled
// after the process end updates are posted to the database
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null)
- {
+ if (jbpmContext != null) {
Services services = jbpmContext.getServices();
MessageService messageService = services.getMessageService();
PersistenceService persistenceService = services.getPersistenceService();
if (messageService != null
&& persistenceService != null
- && persistenceService.getJobSession().countDeletableJobsForProcessInstance(this) > 0)
- {
+ && persistenceService.getJobSession().countDeletableJobsForProcessInstance(this) > 0) {
CleanUpProcessJob job = new CleanUpProcessJob(rootToken);
job.setDueDate(new Date());
messageService.send(job);
@@ -387,26 +355,24 @@
}
/**
- * suspends this execution. This will make sure that tasks, timers and messages related to this process instance will
- * not show up in database queries.
+ * suspends this execution. This will make sure that tasks, timers and messages related to this
+ * process instance will not show up in database queries.
*
* @see #resume()
*/
- public void suspend()
- {
+ public void suspend() {
isSuspended = true;
rootToken.suspend();
}
/**
- * resumes a suspended execution. All timers that have been suspended might fire if the duedate has been passed. If an
- * admin resumes a process instance, the option should be offered to update, remove and create the timers and messages
- * related to this process instance.
+ * resumes a suspended execution. All timers that have been suspended might fire if the duedate
+ * has been passed. If an admin resumes a process instance, the option should be offered to
+ * update, remove and create the timers and messages related to this process instance.
*
* @see #suspend()
*/
- public void resume()
- {
+ public void resume() {
isSuspended = false;
rootToken.resume();
}
@@ -416,12 +382,11 @@
/**
* adds an action to be executed upon a process event in the future.
*/
- public RuntimeAction addRuntimeAction(RuntimeAction runtimeAction)
- {
- if (runtimeAction == null)
+ public RuntimeAction addRuntimeAction(RuntimeAction runtimeAction) {
+ if (runtimeAction == null) {
throw new IllegalArgumentException("can't add a null runtimeAction to a process instance");
- if (runtimeActions == null)
- runtimeActions = new ArrayList();
+ }
+ if (runtimeActions == null) runtimeActions = new ArrayList();
runtimeActions.add(runtimeAction);
runtimeAction.processInstance = this;
return runtimeAction;
@@ -430,15 +395,14 @@
/**
* removes a runtime action.
*/
- public RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction)
- {
+ public RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction) {
RuntimeAction removedRuntimeAction = null;
- if (runtimeAction == null)
- throw new IllegalArgumentException("can't remove a null runtimeAction from an process instance");
- if (runtimeActions != null)
- {
- if (runtimeActions.remove(runtimeAction))
- {
+ if (runtimeAction == null) {
+ throw new IllegalArgumentException(
+ "can't remove a null runtimeAction from an process instance");
+ }
+ if (runtimeActions != null) {
+ if (runtimeActions.remove(runtimeAction)) {
removedRuntimeAction = runtimeAction;
runtimeAction.processInstance = null;
}
@@ -449,8 +413,7 @@
/**
* is the list of all runtime actions.
*/
- public List getRuntimeActions()
- {
+ public List getRuntimeActions() {
return runtimeActions;
}
@@ -459,19 +422,16 @@
/**
* tells if this process instance is still active or not.
*/
- public boolean hasEnded()
- {
+ public boolean hasEnded() {
return (end != null);
}
/**
* calculates if this process instance has still options to continue.
*/
- public boolean isTerminatedImplicitly()
- {
+ public boolean isTerminatedImplicitly() {
boolean isTerminatedImplicitly = true;
- if (end == null)
- {
+ if (end == null) {
isTerminatedImplicitly = rootToken.isTerminatedImplicitly();
}
return isTerminatedImplicitly;
@@ -483,33 +443,28 @@
* @param tokenPath is a slash-separated name that specifies a token in the tree.
* @return the specified token or null if the token is not found.
*/
- public Token findToken(String tokenPath)
- {
+ public Token findToken(String tokenPath) {
return (rootToken != null ? rootToken.findToken(tokenPath) : null);
}
/**
* collects all instances for this process instance.
*/
- public List findAllTokens()
- {
+ public List findAllTokens() {
List tokens = new ArrayList();
tokens.add(rootToken);
rootToken.collectChildrenRecursively(tokens);
return tokens;
}
- void addCascadeProcessInstance(ProcessInstance cascadeProcessInstance)
- {
- if (cascadeProcessInstances == null)
- {
+ void addCascadeProcessInstance(ProcessInstance cascadeProcessInstance) {
+ if (cascadeProcessInstances == null) {
cascadeProcessInstances = new ArrayList();
}
cascadeProcessInstances.add(cascadeProcessInstance);
}
- public Collection removeCascadeProcessInstances()
- {
+ public Collection removeCascadeProcessInstances() {
Collection removed = cascadeProcessInstances;
cascadeProcessInstances = null;
return removed;
@@ -518,105 +473,86 @@
// 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 "ProcessInstance" + (key != null ? '(' + key + ')'
- : id != 0 ? "(" + id + ')' : '@' + Integer.toHexString(hashCode()));
+ public String toString() {
+ return "ProcessInstance"
+ + (key != null ? '(' + key + ')' : id != 0 ? "(" + id + ')'
+ : '@' + Integer.toHexString(hashCode()));
}
// getters and setters //////////////////////////////////////////////////////
- public long getId()
- {
+ public long getId() {
return id;
}
- public Token getRootToken()
- {
+ public Token getRootToken() {
return rootToken;
}
- public Date getStart()
- {
+ public Date getStart() {
return start;
}
- public Date getEnd()
- {
+ public Date getEnd() {
return end;
}
- public Map getInstances()
- {
+ public Map getInstances() {
return instances;
}
- public ProcessDefinition getProcessDefinition()
- {
+ public ProcessDefinition getProcessDefinition() {
return processDefinition;
}
- public Token getSuperProcessToken()
- {
+ public Token getSuperProcessToken() {
return superProcessToken;
}
- public void setSuperProcessToken(Token superProcessToken)
- {
+ public void setSuperProcessToken(Token superProcessToken) {
this.superProcessToken = superProcessToken;
}
- public boolean isSuspended()
- {
+ public boolean isSuspended() {
return isSuspended;
}
- public int getVersion()
- {
+ public int getVersion() {
return version;
}
- public void setVersion(int version)
- {
+ public void setVersion(int version) {
this.version = version;
}
- public void setEnd(Date end)
- {
+ public void setEnd(Date end) {
this.end = end;
}
- public void setProcessDefinition(ProcessDefinition processDefinition)
- {
+ public void setProcessDefinition(ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
}
- public void setRootToken(Token rootToken)
- {
+ public void setRootToken(Token rootToken) {
this.rootToken = rootToken;
}
- public void setStart(Date start)
- {
+ public void setStart(Date start) {
this.start = start;
}
/** a unique business key */
- public String getKey()
- {
+ public String getKey() {
return key;
}
/** set the unique business key */
- public void setKey(String key)
- {
+ public void setKey(String key) {
this.key = key;
}
- // private static Log log = LogFactory.getLog(ProcessInstance.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -33,6 +33,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.db.JobSession;
@@ -55,11 +56,11 @@
/**
* represents one path of execution and maintains a pointer to a node in the
- * {@link org.jbpm.graph.def.ProcessDefinition}. Most common way to get a hold of the token objects is with
- * {@link ProcessInstance#getRootToken()} or {@link org.jbpm.graph.exe.ProcessInstance#findToken(String)}.
+ * {@link org.jbpm.graph.def.ProcessDefinition}. Most common way to get a hold of the token objects
+ * is with {@link ProcessInstance#getRootToken()} or
+ * {@link org.jbpm.graph.exe.ProcessInstance#findToken(String)}.
*/
-public class Token implements Identifiable, Serializable
-{
+public class Token implements Identifiable, Serializable {
private static final long serialVersionUID = 1L;
@@ -72,7 +73,7 @@
protected Date nodeEnter = null;
protected ProcessInstance processInstance = null;
protected Token parent = null;
- protected Map<String,Token> children = null;
+ protected Map children = null;
protected List comments = null;
protected ProcessInstance subProcessInstance = null;
protected int nextLogIndex = 0;
@@ -85,15 +86,13 @@
// ////////////////////
///////////////////////////////////////////////////////
- public Token()
- {
+ public Token() {
}
/**
* creates a root token.
*/
- public Token(ProcessInstance processInstance)
- {
+ public Token(ProcessInstance processInstance) {
this.start = Clock.getCurrentTime();
this.processInstance = processInstance;
this.node = processInstance.getProcessDefinition().getStartState();
@@ -106,8 +105,7 @@
/**
* creates a child token.
*/
- public Token(Token parent, String name)
- {
+ public Token(Token parent, String name) {
this.start = Clock.getCurrentTime();
this.processInstance = parent.getProcessInstance();
this.name = name;
@@ -124,101 +122,97 @@
// operations
// ///////////////////////////////////////////////////////////////////////////
- void addChild(Token token)
- {
- if (children == null)
- {
- children = new HashMap<String,Token>();
+ void addChild(Token token) {
+ if (children == null) {
+ children = new HashMap();
}
children.put(token.getName(), token);
}
/**
- * provides a signal to the token. this method activates this token and leaves the current state over the default
- * transition.
+ * provides a signal to the token. this method activates this token and leaves the current state
+ * over the default transition.
*/
- public void signal()
- {
- if (node == null)
- {
- throw new JbpmException("token '" + this + "' can't be signalled cause it is currently not positioned in a node");
+ public void signal() {
+ if (node == null) {
+ throw new JbpmException("token '"
+ + this
+ + "' can't be signalled cause it is currently not positioned in a node");
}
- if (node.getDefaultLeavingTransition() == null)
- {
- throw new JbpmException("couldn't signal token '" + this + "' : node '" + node + "' doesn't have a default transition");
+ if (node.getDefaultLeavingTransition() == null) {
+ throw new JbpmException("couldn't signal "
+ + this
+ + " : node "
+ + node
+ + " has no default transition");
}
signal(node.getDefaultLeavingTransition(), new ExecutionContext(this));
}
/**
- * Provides a signal to the token.
- * This leave the current state over the given transition name.
+ * Provides a signal to the token. This leave the current state over the given transition name.
*/
- public void signal(String transitionName)
- {
+ public void signal(String transitionName) {
if (node == null)
- throw new JbpmException("token '" + this + "' can't be signalled cause it is currently not positioned in a node");
-
+ throw new JbpmException("token '"
+ + this
+ + "' can't be signalled cause it is currently not positioned in a node");
+
Transition leavingTransition = node.getLeavingTransition(transitionName);
-
- if (leavingTransition == null)
- {
+
+ if (leavingTransition == null) {
// Fall back to the name of the target node
- for (Transition auxTrans : node.getLeavingTransitions())
- {
- if (transitionName.equals(auxTrans.getTo().getName()))
- {
+ for (Iterator i = node.getLeavingTransitions().iterator(); i.hasNext();) {
+ Transition auxTrans = (Transition) i.next();
+ if (transitionName.equals(auxTrans.getTo().getName())) {
leavingTransition = auxTrans;
break;
}
}
}
-
+
if (leavingTransition == null)
throw new JbpmException("transition '" + transitionName + "' does not exist on " + node);
-
+
signal(leavingTransition, new ExecutionContext(this));
}
/**
* provides a signal to the token. this leave the current state over the given transition name.
*/
- public void signal(Transition transition)
- {
+ public void signal(Transition transition) {
signal(transition, new ExecutionContext(this));
}
- void signal(ExecutionContext executionContext)
- {
+ void signal(ExecutionContext executionContext) {
signal(node.getDefaultLeavingTransition(), executionContext);
}
- void signal(Transition transition, ExecutionContext executionContext)
- {
- if (transition == null)
- {
- throw new JbpmException("couldn't signal without specifying a leaving transition : transition is null");
+ void signal(Transition transition, ExecutionContext executionContext) {
+ if (transition == null) {
+ throw new JbpmException(
+ "couldn't signal without specifying a leaving transition : transition is null");
}
- if (executionContext == null)
- {
- throw new JbpmException("couldn't signal without an execution context: executionContext is null");
+ if (executionContext == null) {
+ throw new JbpmException(
+ "couldn't signal without an execution context: executionContext is null");
}
- if (isSuspended)
- {
+ if (isSuspended) {
throw new JbpmException("can't signal token '" + name + "' (" + id + "): it is suspended");
}
- if (isLocked())
- {
+ if (isLocked()) {
throw new JbpmException("this token is locked by " + lock);
}
- if (hasEnded())
- {
- throw new JbpmException("Token '" + name + "' (" + id + ") is already ended and cannot be signaled");
+ if (hasEnded()) {
+ throw new JbpmException("Token '"
+ + name
+ + "' ("
+ + id
+ + ") is already ended and cannot be signaled");
}
startCompositeLog(new SignalLog(transition));
- try
- {
+ try {
// fire the event before-signal
Node signalNode = node;
signalNode.fireEvent(Event.EVENTTYPE_BEFORE_SIGNAL, executionContext);
@@ -233,80 +227,71 @@
signalNode.fireEvent(Event.EVENTTYPE_AFTER_SIGNAL, executionContext);
}
- finally
- {
+ finally {
endCompositeLog();
}
}
/**
- * a set of all the leaving transitions on the current node for which the condition expression resolves to true.
+ * a set of all the leaving transitions on the current node for which the condition expression
+ * resolves to true.
*/
- public Set getAvailableTransitions()
- {
+ public Set getAvailableTransitions() {
Set availableTransitions = new HashSet();
- if (node != null)
- {
+ if (node != null) {
addAvailableTransitionsOfNode(node, availableTransitions);
}
return availableTransitions;
}
/**
- * adds available transitions of that node to the Set and after that calls itself recursivly for the SuperSate of the
- * Node if it has a super state
+ * adds available transitions of that node to the Set and after that calls itself recursivly for
+ * the SuperSate of the Node if it has a super state
*/
- private void addAvailableTransitionsOfNode(Node currentNode, Set availableTransitions)
- {
+ private void addAvailableTransitionsOfNode(Node currentNode, Set availableTransitions) {
List leavingTransitions = currentNode.getLeavingTransitions();
- if (leavingTransitions != null)
- {
+ if (leavingTransitions != null) {
Iterator iter = leavingTransitions.iterator();
- while (iter.hasNext())
- {
- Transition transition = (Transition)iter.next();
+ while (iter.hasNext()) {
+ Transition transition = (Transition) iter.next();
String conditionExpression = transition.getCondition();
- if (conditionExpression != null)
- {
- Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, new ExecutionContext(this));
- if ((result instanceof Boolean) && (((Boolean)result).booleanValue()))
- {
+ if (conditionExpression != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(conditionExpression,
+ new ExecutionContext(this));
+ if ((result instanceof Boolean) && (((Boolean) result).booleanValue())) {
availableTransitions.add(transition);
}
}
- else
- {
+ else {
availableTransitions.add(transition);
}
}
}
- if (currentNode.getSuperState() != null)
- {
+ if (currentNode.getSuperState() != null) {
addAvailableTransitionsOfNode(currentNode.getSuperState(), availableTransitions);
}
}
/**
- * ends this token and all of its children (if any). this is the last active (=not-ended) child of a parent token, the
- * parent token will be ended as well and that verification will continue to propagate.
+ * ends this token and all of its children (if any). this is the last active (=not-ended) child of
+ * a parent token, the parent token will be ended as well and that verification will continue to
+ * propagate.
*/
- public void end()
- {
+ public void end() {
end(true);
}
/**
* ends this token with optional parent ending verification.
*
- * @param verifyParentTermination specifies if the parent token should be checked for termination. if
- * verifyParentTermination is set to true and this is the last non-ended child of a parent token, the parent
- * token will be ended as well and the verification will continue to propagate.
+ * @param verifyParentTermination specifies if the parent token should be checked for termination.
+ * if verifyParentTermination is set to true and this is the last non-ended child of a
+ * parent token, the parent token will be ended as well and the verification will
+ * continue to propagate.
*/
- public void end(boolean verifyParentTermination)
- {
+ public void end(boolean verifyParentTermination) {
// if not already ended
- if (end == null)
- {
+ if (end == null) {
// ended tokens cannot reactivate parents
isAbleToReactivateParent = false;
@@ -316,40 +301,34 @@
this.end = Clock.getCurrentTime();
// end all this token's children
- if (children != null)
- {
+ if (children != null) {
Iterator iter = children.values().iterator();
- while (iter.hasNext())
- {
- Token child = (Token)iter.next();
- if (!child.hasEnded())
- {
+ while (iter.hasNext()) {
+ Token child = (Token) iter.next();
+ if (!child.hasEnded()) {
child.end();
}
}
}
- if (subProcessInstance != null)
- {
+ if (subProcessInstance != null) {
subProcessInstance.end();
}
// only log the end of child-tokens. the process instance logs replace the root token logs.
- if (parent != null)
- {
+ if (parent != null) {
// add a log
parent.addLog(new TokenEndLog(this));
}
// if there are tasks associated to this token, remove signaling capabilities
- TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance() : null);
- if (taskMgmtInstance != null)
- {
+ TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance()
+ : null);
+ if (taskMgmtInstance != null) {
taskMgmtInstance.removeSignalling(this);
}
- if (verifyParentTermination)
- {
+ if (verifyParentTermination) {
// if this is the last active token of the parent,
// the parent needs to be ended as well
notifyParentOfTokenEnd();
@@ -359,21 +338,17 @@
// comments /////////////////////////////////////////////////////////////////
- public void addComment(String message)
- {
+ public void addComment(String message) {
addComment(new Comment(message));
}
- public void addComment(Comment comment)
- {
- if (comments == null)
- comments = new ArrayList();
+ public void addComment(Comment comment) {
+ if (comments == null) comments = new ArrayList();
comments.add(comment);
comment.setToken(this);
}
- public List getComments()
- {
+ public List getComments() {
return comments;
}
@@ -382,17 +357,13 @@
/**
* notifies a parent that one of its nodeMap has ended.
*/
- void notifyParentOfTokenEnd()
- {
- if (isRoot())
- {
+ void notifyParentOfTokenEnd() {
+ if (isRoot()) {
processInstance.end();
}
- else
- {
+ else {
- if (!parent.hasActiveChildren())
- {
+ if (!parent.hasActiveChildren()) {
parent.end();
}
}
@@ -401,19 +372,15 @@
/**
* tells if this token has child tokens that have not yet ended.
*/
- public boolean hasActiveChildren()
- {
+ public boolean hasActiveChildren() {
boolean foundActiveChildToken = false;
// try and find at least one child token that is
// still active (= not ended)
- if (children != null)
- {
+ if (children != null) {
Iterator iter = children.values().iterator();
- while ((iter.hasNext()) && (!foundActiveChildToken))
- {
- Token child = (Token)iter.next();
- if (!child.hasEnded())
- {
+ while ((iter.hasNext()) && (!foundActiveChildToken)) {
+ Token child = (Token) iter.next();
+ if (!child.hasEnded()) {
foundActiveChildToken = true;
}
}
@@ -426,25 +393,21 @@
/**
* convenience method for adding a process log.
*/
- public void addLog(ProcessLog processLog)
- {
- LoggingInstance li = (LoggingInstance)processInstance.getInstance(LoggingInstance.class);
- if (li != null)
- {
+ public void addLog(ProcessLog processLog) {
+ LoggingInstance li = (LoggingInstance) processInstance.getInstance(LoggingInstance.class);
+ if (li != null) {
processLog.setToken(this);
li.addLog(processLog);
}
}
/**
- * convenience method for starting a composite log. When you add composite logs, make sure you put the
- * {@link #endCompositeLog()} in a finally block.
+ * convenience method for starting a composite log. When you add composite logs, make sure you put
+ * the {@link #endCompositeLog()} in a finally block.
*/
- public void startCompositeLog(CompositeLog compositeLog)
- {
- LoggingInstance li = (LoggingInstance)processInstance.getInstance(LoggingInstance.class);
- if (li != null)
- {
+ public void startCompositeLog(CompositeLog compositeLog) {
+ LoggingInstance li = (LoggingInstance) processInstance.getInstance(LoggingInstance.class);
+ if (li != null) {
compositeLog.setToken(this);
li.startCompositeLog(compositeLog);
}
@@ -453,156 +416,122 @@
/**
* convenience method for ending a composite log. Make sure you put this in a finally block.
*/
- public void endCompositeLog()
- {
- LoggingInstance li = (LoggingInstance)processInstance.getInstance(LoggingInstance.class);
- if (li != null)
- {
+ public void endCompositeLog() {
+ LoggingInstance li = (LoggingInstance) processInstance.getInstance(LoggingInstance.class);
+ if (li != null) {
li.endCompositeLog();
}
}
// various information extraction methods ///////////////////////////////////
- public String toString()
- {
+ public String toString() {
return "Token(" + getFullName() + ')';
}
- public boolean hasEnded()
- {
+ public boolean hasEnded() {
return (end != null);
}
- public boolean isRoot()
- {
+ public boolean isRoot() {
return (parent == null);
}
- public boolean hasParent()
- {
+ public boolean hasParent() {
return (parent != null);
}
- public boolean hasChild(String name)
- {
+ public boolean hasChild(String name) {
return (children != null ? children.containsKey(name) : false);
}
- public Token getChild(String name)
- {
+ public Token getChild(String name) {
Token child = null;
- if (children != null)
- {
- child = (Token)children.get(name);
+ if (children != null) {
+ child = (Token) children.get(name);
}
return child;
}
- public String getFullName()
- {
- if (parent == null)
- return "/";
- if (parent.getParent() == null)
- return "/" + name;
+ public String getFullName() {
+ if (parent == null) return "/";
+ if (parent.getParent() == null) return "/" + name;
return parent.getFullName() + "/" + name;
}
- public List getChildrenAtNode(Node aNode)
- {
+ public List getChildrenAtNode(Node aNode) {
List foundChildren = new ArrayList();
getChildrenAtNode(aNode, foundChildren);
return foundChildren;
}
- void getChildrenAtNode(Node aNode, List foundTokens)
- {
- if (aNode.equals(node))
- {
+ void getChildrenAtNode(Node aNode, List foundTokens) {
+ if (aNode.equals(node)) {
foundTokens.add(this);
}
- else if (children != null && !children.isEmpty())
- {
- for (Iterator it = children.values().iterator(); it.hasNext();)
- {
- Token aChild = (Token)it.next();
+ else if (children != null && !children.isEmpty()) {
+ for (Iterator it = children.values().iterator(); it.hasNext();) {
+ Token aChild = (Token) it.next();
aChild.getChildrenAtNode(aNode, foundTokens);
}
}
}
- public void collectChildrenRecursively(List tokens)
- {
- if (children != null)
- {
+ public void collectChildrenRecursively(List tokens) {
+ if (children != null) {
Iterator iter = children.values().iterator();
- while (iter.hasNext())
- {
- Token child = (Token)iter.next();
+ while (iter.hasNext()) {
+ Token child = (Token) iter.next();
tokens.add(child);
child.collectChildrenRecursively(tokens);
}
}
}
- public Token findToken(String relativeTokenPath)
- {
- if (relativeTokenPath == null)
- return null;
+ public Token findToken(String relativeTokenPath) {
+ if (relativeTokenPath == null) return null;
String path = relativeTokenPath.trim();
- if (("".equals(path)) || (".".equals(path)))
- {
+ if (("".equals(path)) || (".".equals(path))) {
return this;
}
- if ("..".equals(path))
- {
+ if ("..".equals(path)) {
return parent;
}
- if (path.startsWith("/"))
- {
+ if (path.startsWith("/")) {
Token root = processInstance.getRootToken();
return root.findToken(path.substring(1));
}
- if (path.startsWith("./"))
- {
+ if (path.startsWith("./")) {
return findToken(path.substring(2));
}
- if (path.startsWith("../"))
- {
- if (parent != null)
- {
+ if (path.startsWith("../")) {
+ if (parent != null) {
return parent.findToken(path.substring(3));
}
return null;
}
int slashIndex = path.indexOf('/');
- if (slashIndex == -1)
- {
- return (Token)(children != null ? children.get(path) : null);
+ if (slashIndex == -1) {
+ return (Token) (children != null ? children.get(path) : null);
}
Token token = null;
String name = path.substring(0, slashIndex);
- token = (Token)children.get(name);
- if (token != null)
- {
+ token = (Token) children.get(name);
+ if (token != null) {
return token.findToken(path.substring(slashIndex + 1));
}
return null;
}
- public Map getActiveChildren()
- {
+ public Map getActiveChildren() {
Map activeChildren = new HashMap();
- if (children != null)
- {
+ if (children != null) {
Iterator iter = children.entrySet().iterator();
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
- Token child = (Token)entry.getValue();
- if (!child.hasEnded())
- {
- String childName = (String)entry.getKey();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ Token child = (Token) entry.getValue();
+ if (!child.hasEnded()) {
+ String childName = (String) entry.getKey();
activeChildren.put(childName, child);
}
}
@@ -610,38 +539,30 @@
return activeChildren;
}
- public void checkImplicitTermination()
- {
- if (isTerminationImplicit && node.hasNoLeavingTransitions())
- {
+ public void checkImplicitTermination() {
+ if (isTerminationImplicit && node.hasNoLeavingTransitions()) {
end();
- if (processInstance.isTerminatedImplicitly())
- {
+ if (processInstance.isTerminatedImplicitly()) {
processInstance.end();
}
}
}
- public boolean isTerminatedImplicitly()
- {
- if (end != null)
- return true;
+ public boolean isTerminatedImplicitly() {
+ if (end != null) return true;
Map leavingTransitions = node.getLeavingTransitionsMap();
- if ((leavingTransitions != null) && (leavingTransitions.size() > 0))
- {
+ if ((leavingTransitions != null) && (leavingTransitions.size() > 0)) {
// ok: found a non-terminated token
return false;
}
// loop over all active child tokens
Iterator iter = getActiveChildren().values().iterator();
- while (iter.hasNext())
- {
- Token child = (Token)iter.next();
- if (!child.isTerminatedImplicitly())
- {
+ while (iter.hasNext()) {
+ Token child = (Token) iter.next();
+ if (!child.isTerminatedImplicitly()) {
return false;
}
}
@@ -649,48 +570,41 @@
return true;
}
- public int nextLogIndex()
- {
+ public int nextLogIndex() {
return nextLogIndex++;
}
/**
* suspends a process execution.
*/
- public void suspend()
- {
+ public void suspend() {
isSuspended = true;
suspendJobs();
suspendTaskInstances();
// propagate to child tokens
- if (children != null)
- {
+ if (children != null) {
Iterator iter = children.values().iterator();
- while (iter.hasNext())
- {
- Token child = (Token)iter.next();
+ while (iter.hasNext()) {
+ Token child = (Token) iter.next();
child.suspend();
}
}
}
- void suspendJobs()
- {
+ void suspendJobs() {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
JobSession jobSession = (jbpmContext != null ? jbpmContext.getJobSession() : null);
- if (jobSession != null)
- {
+ if (jobSession != null) {
jobSession.suspendJobs(this);
}
}
- void suspendTaskInstances()
- {
- TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance() : null);
- if (taskMgmtInstance != null)
- {
+ void suspendTaskInstances() {
+ TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance()
+ : null);
+ if (taskMgmtInstance != null) {
taskMgmtInstance.suspend(this);
}
}
@@ -698,40 +612,34 @@
/**
* resumes a process execution.
*/
- public void resume()
- {
+ public void resume() {
isSuspended = false;
resumeJobs();
resumeTaskInstances();
// propagate to child tokens
- if (children != null)
- {
+ if (children != null) {
Iterator iter = children.values().iterator();
- while (iter.hasNext())
- {
- Token child = (Token)iter.next();
+ while (iter.hasNext()) {
+ Token child = (Token) iter.next();
child.resume();
}
}
}
- void resumeJobs()
- {
+ void resumeJobs() {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
JobSession jobSession = (jbpmContext != null ? jbpmContext.getJobSession() : null);
- if (jobSession != null)
- {
+ if (jobSession != null) {
jobSession.resumeJobs(this);
}
}
- void resumeTaskInstances()
- {
- TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance() : null);
- if (taskMgmtInstance != null)
- {
+ void resumeTaskInstances() {
+ TaskMgmtInstance taskMgmtInstance = (processInstance != null ? processInstance.getTaskMgmtInstance()
+ : null);
+ if (taskMgmtInstance != null) {
taskMgmtInstance.resume(this);
}
}
@@ -739,13 +647,11 @@
// 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 ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition)
- {
+ public ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition) {
// create the new sub process instance
subProcessInstance = new ProcessInstance(subProcessDefinition);
// bind the subprocess to the super-process-token
@@ -757,20 +663,24 @@
}
/**
- * locks a process instance for further execution. A locked token cannot continue execution. This is a non-persistent
- * operation. This is used to prevent tokens being propagated during the execution of actions.
+ * locks a process instance for further execution. A locked token cannot continue execution. This
+ * is a non-persistent operation. This is used to prevent tokens being propagated during the
+ * execution of actions.
*
* @see #unlock(String)
*/
- public void lock(String lockOwnerId)
- {
- if (lockOwnerId == null)
- {
+ public void lock(String lockOwnerId) {
+ if (lockOwnerId == null) {
throw new JbpmException("can't lock with null value for the lockOwnerId");
}
- if ((lock != null) && (!lock.equals(lockOwnerId)))
- {
- throw new JbpmException("token '" + id + "' can't be locked by '" + lockOwnerId + "' cause it's already locked by '" + lock + "'");
+ if ((lock != null) && (!lock.equals(lockOwnerId))) {
+ throw new JbpmException("token '"
+ + id
+ + "' can't be locked by '"
+ + lockOwnerId
+ + "' cause it's already locked by '"
+ + lock
+ + "'");
}
log.debug("token[" + id + "] is locked by " + lockOwnerId);
lock = lockOwnerId;
@@ -779,151 +689,131 @@
/**
* @see #lock(String)
*/
- public void unlock(String lockOwnerId)
- {
- if (lock == null)
- {
- log.warn("lock owner '" + lockOwnerId + "' tries to unlock token '" + id + "' which is not locked");
+ public void unlock(String lockOwnerId) {
+ if (lock == null) {
+ log.warn("lock owner '"
+ + lockOwnerId
+ + "' tries to unlock token '"
+ + id
+ + "' which is not locked");
}
- else if (!lock.equals(lockOwnerId))
- {
- throw new JbpmException("'" + lockOwnerId + "' can't unlock token '" + id + "' because it was already locked by '" + lock + "'");
+ else if (!lock.equals(lockOwnerId)) {
+ throw new JbpmException("'"
+ + lockOwnerId
+ + "' can't unlock token '"
+ + id
+ + "' because it was already locked by '"
+ + lock
+ + "'");
}
log.debug("token[" + id + "] is unlocked by " + lockOwnerId);
lock = null;
}
/**
- * force unlocking the token, even if the owner is not known. In some
- * use cases (e.g. in the jbpm esb integration) the lock is persistent,
- * so a state can be reached where the client needs a possibility to force
- * unlock of a token without knowing the owner.
- *
- * See https://jira.jboss.org/jira/browse/JBPM-1888
+ * force unlocking the token, even if the owner is not known. In some use cases (e.g. in the jbpm
+ * esb integration) the lock is persistent, so a state can be reached where the client needs a
+ * possibility to force unlock of a token without knowing the owner. See
+ * https://jira.jboss.org/jira/browse/JBPM-1888
*/
- public void foreUnlock()
- {
- if (lock == null)
- {
+ public void foreUnlock() {
+ if (lock == null) {
log.warn("Unlock of token '" + id + "' forced, but it is not locked");
}
log.debug("Foce unlock of token[" + id + "] which was locked by " + lock);
lock = null;
}
-
+
/**
- * return the current lock owner of the token
- *
- * See https://jira.jboss.org/jira/browse/JBPM-1888
+ * return the current lock owner of the token See https://jira.jboss.org/jira/browse/JBPM-1888
*/
public String getLockOwner() {
- return lock;
+ return lock;
}
-
- public boolean isLocked()
- {
+
+ public boolean isLocked() {
return lock != null;
}
// getters and setters //////////////////////////////////////////////////////
- public long getId()
- {
+ public long getId() {
return id;
}
- public Date getStart()
- {
+ public Date getStart() {
return start;
}
- public Date getEnd()
- {
+ public Date getEnd() {
return end;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public ProcessInstance getProcessInstance()
- {
+ public ProcessInstance getProcessInstance() {
return processInstance;
}
- public Map<String,Token> getChildren()
- {
+ public Map getChildren() {
return children;
}
- public Node getNode()
- {
+ public Node getNode() {
return node;
}
- public void setNode(Node node)
- {
+ public void setNode(Node node) {
this.node = node;
}
- public Token getParent()
- {
+ public Token getParent() {
return parent;
}
- public void setParent(Token parent)
- {
+ public void setParent(Token parent) {
this.parent = parent;
}
- public void setProcessInstance(ProcessInstance processInstance)
- {
+ public void setProcessInstance(ProcessInstance processInstance) {
this.processInstance = processInstance;
}
- public ProcessInstance getSubProcessInstance()
- {
+ public ProcessInstance getSubProcessInstance() {
return subProcessInstance;
}
- public Date getNodeEnter()
- {
+ public Date getNodeEnter() {
return nodeEnter;
}
- public void setNodeEnter(Date nodeEnter)
- {
+ public void setNodeEnter(Date nodeEnter) {
this.nodeEnter = nodeEnter;
}
- public boolean isAbleToReactivateParent()
- {
+ public boolean isAbleToReactivateParent() {
return isAbleToReactivateParent;
}
- public void setAbleToReactivateParent(boolean isAbleToReactivateParent)
- {
+ public void setAbleToReactivateParent(boolean isAbleToReactivateParent) {
this.isAbleToReactivateParent = isAbleToReactivateParent;
}
- public boolean isTerminationImplicit()
- {
+ public boolean isTerminationImplicit() {
return isTerminationImplicit;
}
- public void setTerminationImplicit(boolean isTerminationImplicit)
- {
+ public void setTerminationImplicit(boolean isTerminationImplicit) {
this.isTerminationImplicit = isTerminationImplicit;
}
- public boolean isSuspended()
- {
+ public boolean isSuspended() {
return isSuspended;
}
- public void setSubProcessInstance(ProcessInstance subProcessInstance)
- {
+ public void setSubProcessInstance(ProcessInstance subProcessInstance) {
this.subProcessInstance = subProcessInstance;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.Node;
@@ -36,13 +37,12 @@
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
-import org.jbpm.util.ClassLoaderUtil;
/**
* decision node.
*/
-public class Decision extends Node implements Parsable
-{
+public class Decision extends Node implements Parsable {
+
static final String NEWLINE = System.getProperty("line.separator");
static final String DECISION_CONDITION_RESULT = "decision_condition_result";
static final long serialVersionUID = 1L;
@@ -51,124 +51,113 @@
Delegation decisionDelegation = null;
String decisionExpression = null;
- public Decision()
- {
+ public Decision() {
}
- public Decision(String name)
- {
+ public Decision(String name) {
super(name);
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.Decision;
}
- public void read(Element decisionElement, JpdlXmlReader jpdlReader)
- {
+ public void read(Element decisionElement, JpdlXmlReader jpdlReader) {
String expression = decisionElement.attributeValue("expression");
Element decisionHandlerElement = decisionElement.element("handler");
- if (expression != null)
- {
+ if (expression != null) {
decisionExpression = expression;
}
- else if (decisionHandlerElement != null)
- {
+ else if (decisionHandlerElement != null) {
decisionDelegation = new Delegation();
decisionDelegation.read(decisionHandlerElement, jpdlReader);
}
}
- public void execute(ExecutionContext executionContext)
- {
+ public void execute(ExecutionContext executionContext) {
Transition transition = null;
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
- try
- {
+ try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
+ Thread.currentThread().setContextClassLoader(
+ JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
- try
- {
- if (decisionDelegation != null)
- {
- DecisionHandler decisionHandler = (DecisionHandler)decisionDelegation.getInstance();
+ try {
+ if (decisionDelegation != null) {
+ DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.getInstance();
if (decisionHandler == null)
- decisionHandler = (DecisionHandler)decisionDelegation.instantiate();
+ decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
String transitionName = decisionHandler.decide(executionContext);
transition = getLeavingTransition(transitionName);
- if (transition == null)
- {
- throw new JbpmException("decision '" + name + "' selected non existing transition '" + transitionName + "'");
+ if (transition == null) {
+ throw new JbpmException("decision '"
+ + name
+ + "' selected non existing transition '"
+ + transitionName
+ + "'");
}
}
- else if (decisionExpression != null)
- {
+ else if (decisionExpression != null) {
Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
- if (result == null)
- {
- throw new JbpmException("decision expression '" + decisionExpression + "' returned null");
+ if (result == null) {
+ throw new JbpmException("decision expression '"
+ + decisionExpression
+ + "' returned null");
}
String transitionName = result.toString();
transition = getLeavingTransition(transitionName);
- if (transition == null)
- {
- throw new JbpmException("decision '" + name + "' selected non existing transition '" + transitionName + "'");
+ if (transition == null) {
+ throw new JbpmException("decision '"
+ + name
+ + "' selected non existing transition '"
+ + transitionName
+ + "'");
}
}
- else if (decisionConditions != null && !decisionConditions.isEmpty())
- {
+ else if (decisionConditions != null && !decisionConditions.isEmpty()) {
// backwards compatible mode based on separate DecisionCondition's
Iterator iter = decisionConditions.iterator();
- while (iter.hasNext() && (transition == null))
- {
- DecisionCondition decisionCondition = (DecisionCondition)iter.next();
- Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(), executionContext);
- if (Boolean.TRUE.equals(result))
- {
+ while (iter.hasNext() && (transition == null)) {
+ DecisionCondition decisionCondition = (DecisionCondition) iter.next();
+ Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(),
+ executionContext);
+ if (Boolean.TRUE.equals(result)) {
String transitionName = decisionCondition.getTransitionName();
transition = getLeavingTransition(transitionName);
- if (transition != null)
- {
+ if (transition != null) {
transition.removeConditionEnforcement();
}
}
}
}
- else
- {
+ else {
// new mode based on conditions in the transition itself
Iterator iter = leavingTransitions.iterator();
- while (iter.hasNext() && (transition == null))
- {
- Transition candidate = (Transition)iter.next();
+ while (iter.hasNext() && (transition == null)) {
+ Transition candidate = (Transition) iter.next();
String conditionExpression = candidate.getCondition();
- if (conditionExpression != null)
- {
- Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
- if (Boolean.TRUE.equals(result))
- {
+ if (conditionExpression != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(conditionExpression,
+ executionContext);
+ if (Boolean.TRUE.equals(result)) {
transition = candidate;
}
}
}
}
+ if (transition == null) transition = getDefaultLeavingTransition();
+
if (transition == null)
- transition = getDefaultLeavingTransition();
-
- if (transition == null)
throw new IllegalStateException("decision cannot select transition: " + this);
-
+
log.debug("decision didn't select transition, taking default " + transition);
// since the decision node evaluates condition expressions, the
@@ -180,27 +169,23 @@
transition.removeConditionEnforcement();
}
- catch (Exception exception)
- {
+ catch (Exception exception) {
raiseException(exception, executionContext);
}
}
- finally
- {
+ finally {
Thread.currentThread().setContextClassLoader(surroundingClassLoader);
}
log.debug("decision " + name + " is taking '" + transition + "'");
executionContext.leaveNode(transition);
}
- public List getDecisionConditions()
- {
+ public List getDecisionConditions() {
return decisionConditions;
}
- public void setDecisionDelegation(Delegation decisionDelegation)
- {
+ public void setDecisionDelegation(Delegation decisionDelegation) {
this.decisionDelegation = decisionDelegation;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/EndState.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/EndState.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/EndState.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -22,22 +22,24 @@
package org.jbpm.graph.node;
import org.dom4j.Element;
+
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.Transition;
-import org.jbpm.graph.exe.*;
+import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.jpdl.xml.JpdlXmlReader;
public class EndState extends Node {
private static final long serialVersionUID = 1L;
-
+
String endCompleteProcess = null;
public EndState() {
}
-
- public static final String[] supportedEventTypes = new String[]{Event.EVENTTYPE_NODE_ENTER};
+
+ public static final String[] supportedEventTypes = new String[] { Event.EVENTTYPE_NODE_ENTER };
+
public String[] getSupportedEventTypes() {
return supportedEventTypes;
}
@@ -45,10 +47,8 @@
public EndState(String name) {
super(name);
}
-
- @Override
- public NodeType getNodeType()
- {
+
+ public NodeType getNodeType() {
return NodeType.EndState;
}
@@ -57,15 +57,14 @@
}
public void execute(ExecutionContext executionContext) {
- if ( (endCompleteProcess!=null)
- && (endCompleteProcess.equalsIgnoreCase("true"))
- ) {
+ if ((endCompleteProcess != null) && (endCompleteProcess.equalsIgnoreCase("true"))) {
executionContext.getProcessInstance().end();
- } else {
+ }
+ else {
executionContext.getToken().end();
}
}
-
+
public Transition addLeavingTransition(Transition t) {
throw new UnsupportedOperationException("can't add a leaving transition to an end-state");
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Fork.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Fork.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Fork.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,6 +30,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.graph.action.Script;
import org.jbpm.graph.def.Node;
@@ -40,23 +41,18 @@
/**
* specifies configurable fork behaviour.
- *
- * <p>if this fork behaviour is not sufficient for your needs, consider
- * writing your own custom TokenHandler.
+ * <p>
+ * if this fork behaviour is not sufficient for your needs, consider writing your own custom
+ * TokenHandler.
* </p>
- *
- * <p>this forkhandler can be configured in 3 ways :
+ * <p>
+ * this forkhandler can be configured in 3 ways :
* <ul>
- * <li>without configuration : in that case the fork will launch one
- * new sub-token over each of the leaving tranisions of the fork
- * node.
- * </li>
- * <li>a script : can be used to calculate a collection of transition
- * names at runtime. if a script is configured, the script must have
- * exactly one variable with 'write' access. that variable
- * should be assigned a java.util.Collection in the script
- * expression.
- * </li>
+ * <li>without configuration : in that case the fork will launch one new sub-token over each of the
+ * leaving tranisions of the fork node.</li>
+ * <li>a script : can be used to calculate a collection of transition names at runtime. if a script
+ * is configured, the script must have exactly one variable with 'write' access. that variable
+ * should be assigned a java.util.Collection in the script expression.</li>
* </ul>
* </p>
*/
@@ -76,15 +72,13 @@
super(name);
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.Fork;
}
public void read(Element forkElement, JpdlXmlReader jpdlReader) {
Element scriptElement = forkElement.element("script");
- if (scriptElement!=null) {
+ if (scriptElement != null) {
log.warn("KNOWN LIMITATION: the script in a fork is not persisted. script in fork might be removed in later versions of jPDL");
script = new Script();
script.read(scriptElement, jpdlReader);
@@ -93,35 +87,40 @@
public void execute(ExecutionContext executionContext) {
Token token = executionContext.getToken();
-
+
// phase one: collect all the transitionNames
- Collection transitionNames = null;
+ Collection transitionNames = null;
List forkedTokens = new ArrayList();
// by default, the fork spawns a token for each leaving transition
- if (script==null) {
+ if (script == null) {
transitionNames = getLeavingTransitionsMap().keySet();
- } else { // a script is specified
+ }
+ else { // a script is specified
// if a script is specified, use that script to calculate the set
// of leaving transitions to be used for forking tokens.
Map outputMap = null;
try {
outputMap = script.eval(token);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
this.raiseException(e, executionContext);
}
- if (outputMap.size()==1) {
+ if (outputMap.size() == 1) {
Object result = outputMap.values().iterator().next();
if (result instanceof Collection) {
transitionNames = (Collection) result;
}
}
- if (transitionNames==null) {
- throw new JbpmException("script for fork '"+name+"' should produce one collection (in one writable variable): "+transitionNames);
+ if (transitionNames == null) {
+ throw new JbpmException("script for fork '"
+ + name
+ + "' should produce one collection (in one writable variable): "
+ + transitionNames);
}
}
-
+
// TODO add some way of blocking the current token here and disable that blocking when the join reactivates this token
// Then an exception can be thrown by in case someone tries to signal a token that is waiting in a fork.
// Suspend and resume can NOT be used for this since that will also suspend any related timers, tasks and messages...
@@ -137,14 +136,15 @@
// phase three: launch child tokens from the fork over the given transitions
iter = forkedTokens.iterator();
- while( iter.hasNext() ) {
+ while (iter.hasNext()) {
ForkedToken forkedToken = (ForkedToken) iter.next();
Token childToken = forkedToken.token;
String leavingTransitionName = forkedToken.leavingTransitionName;
ExecutionContext childExecutionContext = new ExecutionContext(childToken);
- if (leavingTransitionName!=null) {
+ if (leavingTransitionName != null) {
leave(childExecutionContext, leavingTransitionName);
- } else {
+ }
+ else {
leave(childExecutionContext);
}
}
@@ -157,25 +157,27 @@
// create a forked token
ForkedToken forkedToken = null;
forkedToken = new ForkedToken(childToken, transitionName);
-
+
return forkedToken;
}
protected String getTokenName(Token parent, String transitionName) {
String tokenName = null;
- if ( transitionName != null ) {
- if ( ! parent.hasChild( transitionName ) ) {
+ if (transitionName != null) {
+ if (!parent.hasChild(transitionName)) {
tokenName = transitionName;
- } else {
+ }
+ else {
int i = 2;
- tokenName = transitionName + Integer.toString( i );
- while ( parent.hasChild( tokenName ) ) {
+ tokenName = transitionName + Integer.toString(i);
+ while (parent.hasChild(tokenName)) {
i++;
- tokenName = transitionName + Integer.toString( i );
+ tokenName = transitionName + Integer.toString(i);
}
}
- } else { // no transition name
- int size = ( parent.getChildren()!=null ? parent.getChildren().size()+1 : 1 );
+ }
+ else { // no transition name
+ int size = (parent.getChildren() != null ? parent.getChildren().size() + 1 : 1);
tokenName = Integer.toString(size);
}
return tokenName;
@@ -184,18 +186,21 @@
public Script getScript() {
return script;
}
+
public void setScript(Script script) {
this.script = script;
}
-
+
static class ForkedToken {
+
Token token = null;
String leavingTransitionName = null;
+
public ForkedToken(Token token, String leavingTransitionName) {
this.token = token;
this.leavingTransitionName = leavingTransitionName;
}
}
-
+
private static Log log = LogFactory.getLog(Fork.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Join.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Join.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/Join.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,6 +29,7 @@
import org.dom4j.Element;
import org.hibernate.LockMode;
import org.hibernate.Session;
+
import org.jbpm.JbpmContext;
import org.jbpm.graph.action.Script;
import org.jbpm.graph.def.Node;
@@ -40,17 +41,16 @@
public class Join extends Node implements Parsable {
private static final long serialVersionUID = 1L;
-
- /**
- * specifies what type of hibernate lock should be acquired.
- * null value defaults to LockMode.UPGRADE
- */
+
+ /**
+ * specifies what type of hibernate lock should be acquired. null value defaults to
+ * LockMode.UPGRADE
+ */
String parentLockMode;
/**
- * specifies if this join is a discriminator.
- * a descriminator reactivates the parent when the first
- * concurrent token enters the join.
+ * specifies if this join is a discriminator. a descriminator reactivates the parent when the
+ * first concurrent token enters the join.
*/
boolean isDiscriminator = false;
@@ -63,12 +63,11 @@
* a script that calculates concurrent tokens at runtime.
*/
Script script = null;
-
+
/**
* reactivate the parent if the n-th token arrives in the join.
*/
int nOutOfM = -1;
-
public Join() {
}
@@ -77,9 +76,7 @@
super(name);
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.Join;
}
@@ -98,28 +95,28 @@
public void execute(ExecutionContext executionContext) {
Token token = executionContext.getToken();
-
+
boolean isAbleToReactivateParent = token.isAbleToReactivateParent();
-
+
if (!token.hasEnded()) {
token.end(false);
}
-
+
// if this token is not able to reactivate the parent,
// we don't need to check anything
- if ( isAbleToReactivateParent ) {
+ if (isAbleToReactivateParent) {
// the token arrived in the join and can only reactivate
// the parent once
token.setAbleToReactivateParent(false);
Token parentToken = token.getParent();
-
- if ( parentToken != null ) {
-
+
+ if (parentToken != null) {
+
JbpmContext jbpmContext = executionContext.getJbpmContext();
- Session session = (jbpmContext!=null ? jbpmContext.getSession() : null);
- if (session!=null) {
+ Session session = (jbpmContext != null ? jbpmContext.getSession() : null);
+ if (session != null) {
// obtain update lock by default (LockMode.UPGRADE)
LockMode lockMode = parentLockMode != null ? LockMode.parse(parentLockMode)
: LockMode.UPGRADE;
@@ -131,61 +128,68 @@
boolean reactivateParent = true;
// if this is a discriminator
- if ( isDiscriminator ) {
+ if (isDiscriminator) {
// reactivate the parent when the first token arrives in the join.
// this must be the first token arriving, otherwise isAbleToReactivateParent()
// should have been false above.
reactivateParent = true;
- // if a fixed set of tokenNames is specified at design time...
- } else if ( tokenNames != null ) {
+ // if a fixed set of tokenNames is specified at design time...
+ }
+ else if (tokenNames != null) {
// check reactivation on the basis of those tokenNames
- reactivateParent = mustParentBeReactivated(parentToken, tokenNames.iterator() );
+ reactivateParent = mustParentBeReactivated(parentToken, tokenNames.iterator());
- // if a script is specified
- } else if ( script != null ) {
+ // if a script is specified
+ }
+ else if (script != null) {
// check if the script returns a collection or a boolean
Object result = null;
try {
- result = script.eval( token );
- } catch (Exception e) {
+ result = script.eval(token);
+ }
+ catch (Exception e) {
this.raiseException(e, executionContext);
}
// if the result is a collection
- if ( result instanceof Collection ) {
+ if (result instanceof Collection) {
// it must be a collection of tokenNames
Collection runtimeTokenNames = (Collection) result;
- reactivateParent = mustParentBeReactivated(parentToken, runtimeTokenNames.iterator() );
+ reactivateParent = mustParentBeReactivated(parentToken, runtimeTokenNames.iterator());
-
- // if it's a boolean...
- } else if ( result instanceof Boolean ) {
+ // if it's a boolean...
+ }
+ else if (result instanceof Boolean) {
// the boolean specifies if the parent needs to be reactivated
- reactivateParent = ((Boolean)result).booleanValue();
+ reactivateParent = ((Boolean) result).booleanValue();
}
- // if a nOutOfM is specified
- } else if ( nOutOfM != -1 ) {
+ // if a nOutOfM is specified
+ }
+ else if (nOutOfM != -1) {
int n = 0;
// wheck how many tokens already arrived in the join
Iterator iter = parentToken.getChildren().values().iterator();
- while ( iter.hasNext() ) {
- Token concurrentToken = (Token)iter.next();
+ while (iter.hasNext()) {
+ Token concurrentToken = (Token) iter.next();
if (this.equals(concurrentToken.getNode())) {
n++;
}
}
- if ( n < nOutOfM ) {
+ if (n < nOutOfM) {
reactivateParent = false;
}
-
- // if no configuration is specified..
- } else {
+
+ // if no configuration is specified..
+ }
+ else {
// the default behaviour is to check all concurrent tokens and reactivate
// the parent if the last token arrives in the join
- reactivateParent = mustParentBeReactivated(parentToken, parentToken.getChildren().keySet().iterator() );
+ reactivateParent = mustParentBeReactivated(parentToken, parentToken.getChildren()
+ .keySet()
+ .iterator());
}
// if the parent token needs to be reactivated from this join node
@@ -193,8 +197,8 @@
// write to all child tokens that the parent is already reactivated
Iterator iter = parentToken.getChildren().values().iterator();
- while ( iter.hasNext() ) {
- ((Token)iter.next()).setAbleToReactivateParent( false );
+ while (iter.hasNext()) {
+ ((Token) iter.next()).setAbleToReactivateParent(false);
}
// write to all child tokens that the parent is already reactivated
@@ -207,14 +211,15 @@
public boolean mustParentBeReactivated(Token parentToken, Iterator childTokenNameIterator) {
boolean reactivateParent = true;
- while ( (childTokenNameIterator.hasNext())
- && (reactivateParent) ){
+ while ((childTokenNameIterator.hasNext()) && (reactivateParent)) {
String concurrentTokenName = (String) childTokenNameIterator.next();
-
- Token concurrentToken = parentToken.getChild( concurrentTokenName );
-
+
+ Token concurrentToken = parentToken.getChild(concurrentTokenName);
+
if (concurrentToken.isAbleToReactivateParent()) {
- log.debug("join will not yet reactivate parent: found concurrent token '"+concurrentToken+"'");
+ log.debug("join will not yet reactivate parent: found concurrent token '"
+ + concurrentToken
+ + "'");
reactivateParent = false;
}
}
@@ -224,30 +229,39 @@
public String getParentLockMode() {
return parentLockMode;
}
+
public void setParentLockMode(String parentLockMode) {
this.parentLockMode = parentLockMode;
}
+
public Script getScript() {
return script;
}
+
public void setScript(Script script) {
this.script = script;
}
+
public Collection getTokenNames() {
return tokenNames;
}
+
public void setTokenNames(Collection tokenNames) {
this.tokenNames = tokenNames;
}
+
public boolean isDiscriminator() {
return isDiscriminator;
}
+
public void setDiscriminator(boolean isDiscriminator) {
this.isDiscriminator = isDiscriminator;
}
+
public int getNOutOfM() {
return nOutOfM;
}
+
public void setNOutOfM(int nOutOfM) {
this.nOutOfM = nOutOfM;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/StartState.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/StartState.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/StartState.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -24,6 +24,7 @@
import java.util.Map;
import org.dom4j.Element;
+
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.Transition;
@@ -31,9 +32,9 @@
import org.jbpm.jpdl.xml.JpdlXmlReader;
public class StartState extends Node {
-
+
private static final long serialVersionUID = 1L;
-
+
public StartState() {
}
@@ -41,24 +42,19 @@
super(name);
}
- @Override
- public String getName()
- {
+ public String getName() {
return name;
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.StartState;
}
// event types //////////////////////////////////////////////////////////////
- public static final String[] supportedEventTypes = new String[]{
- Event.EVENTTYPE_NODE_LEAVE,
- Event.EVENTTYPE_AFTER_SIGNAL
- };
+ public static final String[] supportedEventTypes = new String[] { Event.EVENTTYPE_NODE_LEAVE,
+ Event.EVENTTYPE_AFTER_SIGNAL };
+
public String[] getSupportedEventTypes() {
return supportedEventTypes;
}
@@ -68,7 +64,7 @@
public void read(Element startStateElement, JpdlXmlReader jpdlReader) {
// if the start-state has a task specified,
Element startTaskElement = startStateElement.element("task");
- if (startTaskElement!=null) {
+ if (startTaskElement != null) {
// delegate the parsing of the start-state task to the jpdlReader
jpdlReader.readStartStateTask(startTaskElement, this);
}
@@ -76,23 +72,24 @@
public void write(Element nodeElement) {
}
-
+
public void leave(ExecutionContext executionContext, Transition transition) {
// leave this node as usual
super.leave(executionContext, transition);
}
-
+
public void execute(ExecutionContext executionContext) {
}
-
+
public Transition addArrivingTransition(Transition t) {
- throw new UnsupportedOperationException( "illegal operation : its not possible to add a transition that is arriving in a start state" );
+ throw new UnsupportedOperationException(
+ "illegal operation : its not possible to add a transition that is arriving in a start state");
}
-
+
public void setArrivingTransitions(Map arrivingTransitions) {
- if ( (arrivingTransitions!=null)
- && (arrivingTransitions.size()>0)) {
- throw new UnsupportedOperationException( "illegal operation : its not possible to set a non-empty map in the arriving transitions of a start state" );
+ if ((arrivingTransitions != null) && (arrivingTransitions.size() > 0)) {
+ throw new UnsupportedOperationException(
+ "illegal operation : its not possible to set a non-empty map in the arriving transitions of a start state");
}
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/State.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/State.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/State.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,28 +21,25 @@
*/
package org.jbpm.graph.node;
-import org.jbpm.graph.def.*;
-import org.jbpm.graph.exe.*;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.exe.ExecutionContext;
public class State extends Node {
-
+
private static final long serialVersionUID = 1L;
public State() {
this(null);
}
-
+
public State(String name) {
- super( name );
+ super(name);
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.State;
}
- public void execute(ExecutionContext executionContext)
- {
+ public void execute(ExecutionContext executionContext) {
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/TaskNode.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/TaskNode.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/TaskNode.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,20 +21,29 @@
*/
package org.jbpm.graph.node;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import org.dom4j.Element;
-import org.jbpm.graph.def.*;
-import org.jbpm.graph.exe.*;
+
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.Token;
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
-import org.jbpm.jpdl.xml.*;
-import org.jbpm.taskmgmt.def.*;
-import org.jbpm.taskmgmt.exe.*;
+import org.jbpm.jpdl.xml.JpdlXmlReader;
+import org.jbpm.jpdl.xml.Parsable;
+import org.jbpm.taskmgmt.def.Task;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
/**
- * is a node that relates to one or more tasks.
- * Property <code>signal</code> specifies how task completion
- * triggers continuation of execution.
+ * is a node that relates to one or more tasks. Property <code>signal</code> specifies how task
+ * completion triggers continuation of execution.
*/
public class TaskNode extends Node implements Parsable {
@@ -49,65 +58,76 @@
*/
public static final int SIGNAL_NEVER = 1;
/**
- * proceeds execution when the first task instance is completed.
- * when no tasks are created on entrance of this node, execution is continued.
+ * proceeds execution when the first task instance is completed. when no tasks are created on
+ * entrance of this node, execution is continued.
*/
public static final int SIGNAL_FIRST = 2;
/**
- * proceeds execution when the first task instance is completed.
- * when no tasks are created on entrance of this node, execution waits in the task node till tasks are created.
+ * proceeds execution when the first task instance is completed. when no tasks are created on
+ * entrance of this node, execution waits in the task node till tasks are created.
*/
public static final int SIGNAL_FIRST_WAIT = 3;
/**
- * proceeds execution when the last task instance is completed.
- * when no tasks are created on entrance of this node, execution is continued.
+ * proceeds execution when the last task instance is completed. when no tasks are created on
+ * entrance of this node, execution is continued.
*/
public static final int SIGNAL_LAST = 4;
/**
- * proceeds execution when the last task instance is completed.
- * when no tasks are created on entrance of this node, execution waits in the task node till tasks are created.
+ * proceeds execution when the last task instance is completed. when no tasks are created on
+ * entrance of this node, execution waits in the task node till tasks are created.
*/
public static final int SIGNAL_LAST_WAIT = 5;
-
+
public static int parseSignal(String text) {
if ("unsynchronized".equalsIgnoreCase(text)) {
return SIGNAL_UNSYNCHRONIZED;
- } else if ("never".equalsIgnoreCase(text)) {
+ }
+ else if ("never".equalsIgnoreCase(text)) {
return SIGNAL_NEVER;
- } else if ("first".equalsIgnoreCase(text)) {
+ }
+ else if ("first".equalsIgnoreCase(text)) {
return SIGNAL_FIRST;
- } else if ("first-wait".equalsIgnoreCase(text)) {
+ }
+ else if ("first-wait".equalsIgnoreCase(text)) {
return SIGNAL_FIRST_WAIT;
- } else if ("last-wait".equalsIgnoreCase(text)) {
+ }
+ else if ("last-wait".equalsIgnoreCase(text)) {
return SIGNAL_LAST_WAIT;
- } else { // return default
+ }
+ else { // return default
return SIGNAL_LAST;
}
}
-
+
public static String signalToString(int signal) {
- if (signal==SIGNAL_UNSYNCHRONIZED) {
+ if (signal == SIGNAL_UNSYNCHRONIZED) {
return "unsynchronized";
- } else if (signal==SIGNAL_NEVER) {
+ }
+ else if (signal == SIGNAL_NEVER) {
return "never";
- } else if (signal==SIGNAL_FIRST) {
+ }
+ else if (signal == SIGNAL_FIRST) {
return "first";
- } else if (signal==SIGNAL_FIRST_WAIT) {
+ }
+ else if (signal == SIGNAL_FIRST_WAIT) {
return "first-wait";
- } else if (signal==SIGNAL_LAST) {
+ }
+ else if (signal == SIGNAL_LAST) {
return "last";
- } else if (signal==SIGNAL_LAST_WAIT) {
+ }
+ else if (signal == SIGNAL_LAST_WAIT) {
return "last-wait";
- } else {
+ }
+ else {
return null;
}
}
-
+
Set tasks = null;
int signal = SIGNAL_LAST;
boolean createTasks = true;
boolean endTasks = false;
-
+
public TaskNode() {
}
@@ -115,57 +135,52 @@
super(name);
}
- @Override
- public NodeType getNodeType()
- {
+ public NodeType getNodeType() {
return NodeType.Task;
}
public void read(Element element, JpdlXmlReader jpdlReader) {
// get the signal
String signalText = element.attributeValue("signal");
- if (signalText!=null) {
+ if (signalText != null) {
signal = parseSignal(signalText);
}
// create tasks
String createTasksText = element.attributeValue("create-tasks");
- if (createTasksText!=null) {
- if (("no".equalsIgnoreCase(createTasksText))
- || ("false".equalsIgnoreCase(createTasksText)) ) {
+ if (createTasksText != null) {
+ if (("no".equalsIgnoreCase(createTasksText)) || ("false".equalsIgnoreCase(createTasksText))) {
createTasks = false;
}
}
-
+
// create tasks
String removeTasksText = element.attributeValue("end-tasks");
- if (removeTasksText!=null) {
- if (("yes".equalsIgnoreCase(removeTasksText))
- || ("true".equalsIgnoreCase(removeTasksText)) ) {
+ if (removeTasksText != null) {
+ if (("yes".equalsIgnoreCase(removeTasksText)) || ("true".equalsIgnoreCase(removeTasksText))) {
endTasks = true;
}
}
-
+
// parse the tasks
jpdlReader.readTasks(element, this);
}
public void addTask(Task task) {
- if (tasks==null) tasks = new HashSet();
+ if (tasks == null) tasks = new HashSet();
tasks.add(task);
task.setTaskNode(this);
}
// node behaviour methods
/////////////////////////////////////////////////////////////////////////////
-
+
public void execute(ExecutionContext executionContext) {
-
+
TaskMgmtInstance tmi = getTaskMgmtInstance(executionContext.getToken());
-
+
// if this tasknode should create instances
- if ( (createTasks)
- && (tasks!=null) ) {
+ if ((createTasks) && (tasks != null)) {
Iterator iter = tasks.iterator();
while (iter.hasNext()) {
Task task = (Task) iter.next();
@@ -179,24 +194,24 @@
// check if we should continue execution
boolean continueExecution;
switch (signal) {
- case SIGNAL_UNSYNCHRONIZED:
- continueExecution = true;
- break;
- case SIGNAL_FIRST:
- case SIGNAL_LAST:
- continueExecution = tmi.getSignallingTasks(executionContext).isEmpty();
- break;
- default:
- continueExecution = false;
+ case SIGNAL_UNSYNCHRONIZED:
+ continueExecution = true;
+ break;
+ case SIGNAL_FIRST:
+ case SIGNAL_LAST:
+ continueExecution = tmi.getSignallingTasks(executionContext).isEmpty();
+ break;
+ default:
+ continueExecution = false;
}
if (continueExecution) {
leave(executionContext);
}
}
-
+
boolean evaluateTaskCondition(String condition, ExecutionContext executionContext) {
- if (condition==null) return true;
+ if (condition == null) return true;
Object result = JbpmExpressionEvaluator.evaluate(condition, executionContext);
if (Boolean.TRUE.equals(result)) {
return true;
@@ -206,13 +221,13 @@
public void leave(ExecutionContext executionContext, Transition transition) {
TaskMgmtInstance tmi = getTaskMgmtInstance(executionContext.getToken());
- if (tmi.hasBlockingTaskInstances(executionContext.getToken()) ) {
- throw new IllegalStateException("task-node '"+name+"' still has blocking tasks");
+ if (tmi.hasBlockingTaskInstances(executionContext.getToken())) {
+ throw new IllegalStateException("task-node '" + name + "' still has blocking tasks");
}
removeTaskInstanceSynchronization(executionContext.getToken());
super.leave(executionContext, transition);
}
-
+
// task behaviour methods
/////////////////////////////////////////////////////////////////////////////
@@ -236,29 +251,27 @@
boolean isLastToComplete(TaskInstance taskInstance) {
Token token = taskInstance.getToken();
TaskMgmtInstance tmi = getTaskMgmtInstance(token);
-
+
boolean isLastToComplete = true;
Iterator iter = tmi.getTaskInstances().iterator();
- while ( iter.hasNext()
- && (isLastToComplete) ) {
+ while (iter.hasNext() && (isLastToComplete)) {
TaskInstance other = (TaskInstance) iter.next();
- if ( (token!=null)
- && (token.equals(other.getToken()))
- && (! other.equals(taskInstance))
- && (other.isSignalling())
- && (!other.hasEnded())
- ) {
+ if ((token != null)
+ && (token.equals(other.getToken()))
+ && (!other.equals(taskInstance))
+ && (other.isSignalling())
+ && (!other.hasEnded())) {
isLastToComplete = false;
}
}
-
+
return isLastToComplete;
}
public void removeTaskInstanceSynchronization(Token token) {
TaskMgmtInstance tmi = getTaskMgmtInstance(token);
Collection taskInstances = tmi.getTaskInstances();
- if (taskInstances!=null) {
+ if (taskInstances != null) {
Iterator iter = taskInstances.iterator();
while (iter.hasNext()) {
TaskInstance taskInstance = (TaskInstance) iter.next();
@@ -273,9 +286,7 @@
}
// if this is a non-finished task and all those
// tasks should be finished
- if ( (! taskInstance.hasEnded())
- && (endTasks)
- ) {
+ if ((!taskInstance.hasEnded()) && (endTasks)) {
if (tasks.contains(taskInstance.getTask())) {
// end this task
taskInstance.end();
@@ -294,12 +305,12 @@
/////////////////////////////////////////////////////////////////////////////
/**
- * is a Map with the tasks, keyed by task-name or an empty map in case
- * no tasks are present in this task-node.
+ * is a Map with the tasks, keyed by task-name or an empty map in case no tasks are present in
+ * this task-node.
*/
public Map getTasksMap() {
Map tasksMap = new HashMap();
- if (tasks!=null) {
+ if (tasks != null) {
Iterator iter = tasks.iterator();
while (iter.hasNext()) {
Task task = (Task) iter.next();
@@ -308,10 +319,10 @@
}
return tasksMap;
}
-
+
/**
- * is the task in this task-node with the given name or null if the given task
- * does not exist in this node.
+ * is the task in this task-node with the given name or null if the given task does not exist in
+ * this node.
*/
public Task getTask(String taskName) {
return (Task) getTasksMap().get(taskName);
@@ -320,24 +331,31 @@
public Set getTasks() {
return tasks;
}
+
public int getSignal() {
return signal;
}
+
public boolean getCreateTasks() {
return createTasks;
}
+
public boolean isEndTasks() {
return endTasks;
}
+
public void setCreateTasks(boolean createTasks) {
this.createTasks = createTasks;
}
+
public void setEndTasks(boolean endTasks) {
this.endTasks = endTasks;
}
+
public void setSignal(int signal) {
this.signal = signal;
}
+
public void setTasks(Set tasks) {
this.tasks = tasks;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.calendar.BusinessCalendar;
import org.jbpm.calendar.Duration;
@@ -20,13 +21,13 @@
private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
static BusinessCalendar businessCalendar = new BusinessCalendar();
-
+
String name;
String repeat;
String transitionName = null;
Action action = null;
GraphElement graphElement = null;
-
+
public Timer() {
}
@@ -38,25 +39,27 @@
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTimer(this);
- if (taskInstance!=null) {
+ if (taskInstance != null) {
executionContext.setTaskInstance(taskInstance);
}
// first fire the event if there is a graph element specified
- if (graphElement!=null) {
+ if (graphElement != null) {
graphElement.fireAndPropagateEvent(Event.EVENTTYPE_TIMER, executionContext);
}
// then execute the action if there is one
- if (action!=null) {
+ if (action != null) {
try {
- log.debug("executing '"+this+"'");
- if (graphElement!=null) {
+ log.debug("executing '" + this + "'");
+ if (graphElement != null) {
graphElement.executeAction(action, executionContext);
- } else {
+ }
+ else {
action.execute(executionContext);
}
- } catch (Exception actionException) {
+ }
+ catch (Exception actionException) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
log.warn("timer action threw exception", actionException);
// if there is a graphElement connected to this timer...
@@ -64,28 +67,29 @@
try {
// we give that graphElement a chance to catch the exception
graphElement.raiseException(actionException, executionContext);
- log.debug("timer exception got handled by '"+graphElement+"'");
- } catch (Exception handlerException) {
+ log.debug("timer exception got handled by '" + graphElement + "'");
+ }
+ catch (Exception handlerException) {
// if the exception handler rethrows or the original exception results in a DelegationException...
throw handlerException;
}
- } else {
+ }
+ else {
throw actionException;
}
}
}
// then take a transition if one is specified
- if ( (transitionName!=null)
- && (exception==null) // and if no unhandled exception occurred during the action
- ) {
+ if ((transitionName != null) && (exception == null) // and if no unhandled exception occurred during the action
+ ) {
if (token.getNode().hasLeavingTransition(transitionName)) {
token.signal(transitionName);
}
}
// if repeat is specified, reschedule the job
- if (repeat!=null) {
+ if (repeat != null) {
// suppose that it took the timer runner thread a
// very long time to execute the timers.
// then the repeat action dueDate could already have passed.
@@ -108,26 +112,22 @@
return false;
}
-
+
return true;
}
-
+
public String toString() {
- StringBuilder text = new StringBuilder("Timer");
+ StringBuffer text = new StringBuffer("Timer");
if (name != null || dueDate != null) {
text.append('(');
- if (name!=null)
- text.append(name).append(",");
- if (dueDate!=null)
- text.append(formatDueDate(dueDate)).append(",");
- if (taskInstance!=null)
- text.append(taskInstance).append(",");
+ if (name != null) text.append(name).append(",");
+ if (dueDate != null) text.append(formatDueDate(dueDate)).append(",");
+ if (taskInstance != null) text.append(taskInstance).append(",");
- if (token!=null)
+ if (token != null)
text.append(token);
- else if (processInstance!=null)
- text.append(processInstance);
+ else if (processInstance != null) text.append(processInstance);
text.append(')');
}
@@ -141,33 +141,42 @@
public String getRepeat() {
return repeat;
}
+
public void setRepeat(String repeat) {
this.repeat = repeat;
}
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
+
public String getTransitionName() {
return transitionName;
}
+
public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
}
+
public GraphElement getGraphElement() {
return graphElement;
}
+
public void setGraphElement(GraphElement graphElement) {
this.graphElement = graphElement;
}
+
public Action getAction() {
return action;
}
+
public void setAction(Action action) {
this.action = action;
}
-
+
private static Log log = LogFactory.getLog(Timer.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -18,18 +18,14 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Job;
import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
import org.jbpm.svc.Services;
public class JobExecutorThread extends Thread {
- public JobExecutorThread( String name,
- JobExecutor jobExecutor,
- JbpmConfiguration jbpmConfiguration,
- int idleInterval,
- int maxIdleInterval,
- long maxLockTime,
- int maxHistory
- ) {
+ public JobExecutorThread(String name, JobExecutor jobExecutor,
+ JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime,
+ int maxHistory) {
super(name);
this.jobExecutor = jobExecutor;
this.jbpmConfiguration = jbpmConfiguration;
@@ -38,7 +34,7 @@
this.maxLockTime = maxLockTime;
}
- final JobExecutor jobExecutor;
+ final JobExecutor jobExecutor;
final JbpmConfiguration jbpmConfiguration;
final int idleInterval;
final int maxIdleInterval;
@@ -52,39 +48,35 @@
while (isActive) {
try {
Collection acquiredJobs = acquireJobs();
-
- if (! acquiredJobs.isEmpty()) {
- Iterator iter = acquiredJobs.iterator();
- while (iter.hasNext() && isActive) {
- Job job = (Job) iter.next();
+ if (!acquiredJobs.isEmpty()) {
+ for (Iterator i = acquiredJobs.iterator(); i.hasNext() && isActive;) {
+ Job job = (Job) i.next();
executeJob(job);
}
-
- } else { // no jobs acquired
- if (isActive) {
- long waitPeriod = getWaitPeriod();
- if (waitPeriod>0) {
- synchronized(jobExecutor) {
- jobExecutor.wait(waitPeriod);
- }
+ }
+ if (isActive) {
+ long waitPeriod = getWaitPeriod();
+ if (waitPeriod > 0) {
+ synchronized (jobExecutor) {
+ jobExecutor.wait(waitPeriod);
}
}
}
-
- // no exception so resetting the currentIdleInterval
+ // no exception, reset current idle interval
currentIdleInterval = idleInterval;
-
- } catch (InterruptedException e) {
- log.info((isActive? "active" : "inactive")+" job executor thread '"+getName()+"' got interrupted");
- } catch (Exception e) {
- log.error("exception in job executor thread. waiting "+currentIdleInterval+" milliseconds", e);
+ }
+ catch (RuntimeException e) {
+ log.error("exception in job executor thread. waiting "
+ + currentIdleInterval
+ + " milliseconds", e);
try {
- synchronized(jobExecutor) {
+ synchronized (jobExecutor) {
jobExecutor.wait(currentIdleInterval);
}
- } catch (InterruptedException e2) {
- log.debug("delay after exception got interrupted", e2);
}
+ catch (InterruptedException ie) {
+ log.debug("delay after exception got interrupted", ie);
+ }
// after an exception, the current idle interval is doubled to prevent
// continuous exception generation when e.g. the db is unreachable
currentIdleInterval <<= 1;
@@ -92,8 +84,11 @@
currentIdleInterval = maxIdleInterval;
}
}
+ catch (InterruptedException e) {
+ log.info("job executor thread '" + getName() + "' got interrupted");
+ }
}
- log.info(getName()+" leaves cyberspace");
+ log.info(getName() + " leaves cyberspace");
}
protected Collection acquireJobs() {
@@ -107,46 +102,51 @@
String lockOwner = getName();
log.debug("querying for acquirable job...");
Job job = jobSession.getFirstAcquirableJob(lockOwner);
- if (job!=null) {
+ if (job != null) {
if (job.isExclusive()) {
- log.debug("found exclusive " + job);
+ log.debug("obtained exclusive " + job);
ProcessInstance processInstance = job.getProcessInstance();
log.debug("finding other exclusive jobs for " + processInstance);
jobsToLock = jobSession.findExclusiveJobs(lockOwner, processInstance);
- log.debug("trying to obtain exclusive locks on " + jobsToLock + " for " + processInstance);
- } else {
+ log.debug("trying to obtain exclusive locks on "
+ + jobsToLock
+ + " for "
+ + processInstance);
+ }
+ else {
log.debug("trying to obtain lock on " + job);
jobsToLock = Collections.singletonList(job);
}
-
+
Date lockTime = new Date();
- for (Iterator iter = jobsToLock.iterator(); iter.hasNext();) {
- job = (Job) iter.next();
+ for (Iterator i = jobsToLock.iterator(); i.hasNext();) {
+ job = (Job) i.next();
job.setLockOwner(lockOwner);
job.setLockTime(lockTime);
- // jbpmContext.getSession().update(job);
}
-
- // HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
- // TODO remove this hack already?
- // if (job instanceof Timer) {
- // Hibernate.initialize(((Timer)job).getGraphElement());
- // }
- } else {
+ }
+ else {
log.debug("no acquirable jobs in job table");
}
- } finally {
+ }
+ catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
+ finally {
try {
jbpmContext.close();
acquiredJobs = jobsToLock;
- log.debug("obtained lock on jobs: "+acquiredJobs);
+ log.debug("acquired lock on jobs: " + acquiredJobs);
}
catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, couldn't obtain lock on jobs "+jobsToLock);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "failed to acquire lock on jobs " + jobsToLock);
acquiredJobs = Collections.EMPTY_LIST;
- } else {
+ }
+ else {
throw e;
}
}
@@ -170,33 +170,38 @@
if (job.execute(jbpmContext)) {
jobSession.deleteJob(job);
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
log.debug("exception while executing " + job, e);
if (!isPersistenceException(e)) {
StringWriter memoryWriter = new StringWriter();
e.printStackTrace(new PrintWriter(memoryWriter));
job.setException(memoryWriter.toString());
- job.setRetries(job.getRetries()-1);
+ job.setRetries(job.getRetries() - 1);
}
else {
// allowing a transaction to proceed after a persistence exception is unsafe
jbpmContext.setRollbackOnly();
}
}
-
+
// if this job is locked too long
- long totalLockTimeInMillis = System.currentTimeMillis() - job.getLockTime().getTime();
- if (totalLockTimeInMillis>maxLockTime) {
+ long totalLockTimeInMillis = System.currentTimeMillis() - job.getLockTime().getTime();
+ if (totalLockTimeInMillis > maxLockTime) {
jbpmContext.setRollbackOnly();
}
- } finally {
+ }
+ finally {
try {
jbpmContext.close();
- } catch (JbpmPersistenceException e) {
+ }
+ catch (JbpmPersistenceException e) {
// if this is a stale state exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, couldn't complete job "+job);
- } else {
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "failed to complete job " + job);
+ }
+ else {
throw e;
}
}
@@ -205,8 +210,7 @@
private static boolean isPersistenceException(Throwable throwable) {
do {
- if (throwable instanceof HibernateException)
- return true;
+ if (throwable instanceof HibernateException) return true;
throwable = throwable.getCause();
} while (throwable != null);
return false;
@@ -214,24 +218,33 @@
protected Date getNextDueDate() {
Date nextDueDate = null;
+ String threadName = getName();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
JobSession jobSession = jbpmContext.getJobSession();
Collection jobIdsToIgnore = jobExecutor.getMonitoredJobIds();
- Job job = jobSession.getFirstDueJob(getName(), jobIdsToIgnore);
- if (job!=null) {
+ Job job = jobSession.getFirstDueJob(threadName, jobIdsToIgnore);
+ if (job != null) {
nextDueDate = job.getDueDate();
- jobExecutor.addMonitoredJobId(getName(), job.getId());
+ jobExecutor.addMonitoredJobId(threadName, job.getId());
}
- } finally {
+ }
+ catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
+ finally {
try {
jbpmContext.close();
- } catch (JbpmPersistenceException e) {
+ }
+ catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, couldn't get next due date");
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "failed to determine next due date for job executor thread " + threadName);
nextDueDate = null;
- } else {
+ }
+ else {
throw e;
}
}
@@ -242,14 +255,14 @@
protected long getWaitPeriod() {
long interval = currentIdleInterval;
Date nextDueDate = getNextDueDate();
- if (nextDueDate!=null) {
+ if (nextDueDate != null) {
long currentTime = System.currentTimeMillis();
long nextDueTime = nextDueDate.getTime();
- if (nextDueTime < currentTime+currentIdleInterval) {
- interval = nextDueTime-currentTime;
+ if (nextDueTime < currentTime + currentIdleInterval) {
+ interval = nextDueTime - currentTime;
}
}
- if (interval<0) {
+ if (interval < 0) {
interval = 0;
}
return interval;
@@ -259,18 +272,16 @@
* @deprecated As of jBPM 3.2.3, replaced by {@link #deactivate()}
*/
public void setActive(boolean isActive) {
- if (isActive == false)
- deactivate();
+ if (isActive == false) deactivate();
}
/**
- * Indicates that this thread should stop running.
- * Execution will cease shortly afterwards.
+ * Indicates that this thread should stop running. Execution will cease shortly afterwards.
*/
public void deactivate() {
if (isActive) {
isActive = false;
- interrupt();
+ interrupt();
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,10 +1,12 @@
package org.jbpm.job.executor;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.db.JobSession;
@@ -15,67 +17,77 @@
public class LockMonitorThread extends Thread {
- JbpmConfiguration jbpmConfiguration;
- int lockMonitorInterval;
- int maxLockTime;
- int lockBufferTime;
+ final JbpmConfiguration jbpmConfiguration;
+ final int lockMonitorInterval;
+ final int maxLockMonitorInterval;
+ final int maxLockTime;
+ final int lockBufferTime;
+ int currentLockMonitorInterval;
volatile boolean isActive = true;
public LockMonitorThread(JbpmConfiguration jbpmConfiguration, int lockMonitorInterval,
int maxLockTime, int lockBufferTime) {
this.jbpmConfiguration = jbpmConfiguration;
this.lockMonitorInterval = lockMonitorInterval;
+ this.maxLockMonitorInterval = jbpmConfiguration.getJobExecutor().getMaxIdleInterval();
this.maxLockTime = maxLockTime;
this.lockBufferTime = lockBufferTime;
}
public void run() {
- try {
- while (isActive) {
+ currentLockMonitorInterval = lockMonitorInterval;
+ while (isActive) {
+ try {
+ unlockOverdueJobs();
+ if (isActive) {
+ sleep(currentLockMonitorInterval);
+ }
+ // no exception, reset current lock monitor interval
+ currentLockMonitorInterval = lockMonitorInterval;
+ }
+ catch (RuntimeException e) {
+ log.error("exception in lock monitor thread. waiting "
+ + currentLockMonitorInterval
+ + " milliseconds", e);
try {
- unlockOverdueJobs();
- if ((isActive) && (lockMonitorInterval > 0)) {
- sleep(lockMonitorInterval);
- }
+ sleep(currentLockMonitorInterval);
}
- catch (InterruptedException e) {
- log.info("lock monitor thread '" + getName() + "' got interrupted");
+ catch (InterruptedException ie) {
+ log.debug("delay after exception got interrupted", ie);
}
- catch (Exception e) {
- log.error("exception in lock monitor thread. waiting "
- + lockMonitorInterval
- + " milliseconds", e);
- try {
- sleep(lockMonitorInterval);
- }
- catch (InterruptedException e2) {
- log.debug("delay after exception got interrupted", e2);
- }
+ // after an exception, double the current lock monitor interval to prevent
+ // continuous exception generation when e.g. the db is unreachable
+ currentLockMonitorInterval <<= 1;
+ if (currentLockMonitorInterval > maxLockMonitorInterval || currentLockMonitorInterval < 0) {
+ currentLockMonitorInterval = maxLockMonitorInterval;
}
}
+ catch (InterruptedException e) {
+ log.info("lock monitor thread '" + getName() + "' got interrupted");
+ }
}
- catch (Exception e) {
- log.error("exception in lock monitor thread", e);
- }
- finally {
- log.info(getName() + " leaves cyberspace");
- }
+ log.info(getName() + " leaves cyberspace");
}
protected void unlockOverdueJobs() {
- List<Job> overdueJobs = null;
+ List overdueJobs = null;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
Date threshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
JobSession jobSession = jbpmContext.getJobSession();
overdueJobs = jobSession.findJobsWithOverdueLockTime(threshold);
- for (Job job : overdueJobs) {
+ for (Iterator i = overdueJobs.iterator(); i.hasNext();) {
+ Job job = (Job) i.next();
log.debug("unlocking " + job + " owned by thread " + job.getLockOwner());
job.setLockOwner(null);
job.setLockTime(null);
}
}
+ catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
finally {
try {
jbpmContext.close();
@@ -83,9 +95,8 @@
catch (JbpmPersistenceException e) {
// if this is a stale object exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
- log.debug("optimistic locking failed, could not unlock overdue jobs: " + overdueJobs);
StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
- "problem unlocking overdue jobs: optimistic locking failed", e);
+ "optimistic locking failed, could not unlock overdue jobs: " + overdueJobs);
}
else {
throw e;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlWriter.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,172 +21,189 @@
*/
package org.jbpm.jpdl.xml;
-import java.io.*;
-import java.util.*;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
-import org.dom4j.*;
-import org.dom4j.io.*;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
import org.jbpm.JbpmException;
import org.jbpm.graph.action.ActionTypes;
-import org.jbpm.graph.def.*;
-import org.jbpm.graph.node.*;
-import org.jbpm.jpdl.*;
+import org.jbpm.graph.def.Action;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.GraphElement;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.node.ProcessFactory;
+import org.jbpm.graph.node.StartState;
+import org.jbpm.jpdl.JpdlException;
/**
- * @deprecated xml generation was never finished and will be removed in the future.
+ * Class for writing process definitions to character streams.
+ * <p>
+ * Saving process definitions to XML is in no way complete, but may be useful for process
+ * definitions with no custom nodes.
+ * </p>
*/
public class JpdlXmlWriter {
static final String JPDL_NAMESPACE = "http://jbpm.org/3/jpdl";
static final Namespace jbpmNamespace = new Namespace(null, JPDL_NAMESPACE);
-
+
Writer writer = null;
List problems = new ArrayList();
boolean useNamespace = false;
- public JpdlXmlWriter( Writer writer ) {
- if (writer==null) throw new JbpmException("writer is null");
+ public JpdlXmlWriter(Writer writer) {
+ if (writer == null) throw new JbpmException("writer is null");
this.writer = writer;
}
-
+
public void addProblem(String msg) {
problems.add(msg);
}
+
public static String toString(ProcessDefinition processDefinition) {
StringWriter stringWriter = new StringWriter();
JpdlXmlWriter jpdlWriter = new JpdlXmlWriter(stringWriter);
jpdlWriter.write(processDefinition);
return stringWriter.toString();
}
-
- public void setUseNamespace(boolean useNamespace)
- {
- this.useNamespace = useNamespace;
+
+ public void setUseNamespace(boolean useNamespace) {
+ this.useNamespace = useNamespace;
}
-
+
//newElement.add( jbpmNamespace );
public void write(ProcessDefinition processDefinition) {
problems = new ArrayList();
- if (processDefinition==null) throw new JbpmException("processDefinition is null");
+ if (processDefinition == null) throw new JbpmException("processDefinition is null");
try {
// collect the actions of the process definition
// we will remove each named event action and the remaining ones will be written
// on the process definition.
// create a dom4j dom-tree for the process definition
Document document = createDomTree(processDefinition);
-
+
// write the dom-tree to the given writer
- OutputFormat outputFormat = new OutputFormat( " ", true );
+ OutputFormat outputFormat = new OutputFormat(" ", true);
// OutputFormat outputFormat = OutputFormat.createPrettyPrint();
- XMLWriter xmlWriter = new XMLWriter( writer, outputFormat );
- xmlWriter.write( document );
+ XMLWriter xmlWriter = new XMLWriter(writer, outputFormat);
+ xmlWriter.write(document);
xmlWriter.flush();
writer.flush();
- } catch (IOException e) {
- addProblem("couldn't write process definition xml: "+e.getMessage());
}
-
- if (problems.size()>0) {
+ catch (IOException e) {
+ addProblem("couldn't write process definition xml: " + e.getMessage());
+ }
+
+ if (problems.size() > 0) {
throw new JpdlException(problems);
}
}
-
+
private Document createDomTree(ProcessDefinition processDefinition) {
Document document = DocumentHelper.createDocument();
Element root = null;
-
- if (useNamespace)
- root = document.addElement( "process-definition", jbpmNamespace.getURI() );
- else
- root = document.addElement( "process-definition"
- );
- addAttribute( root, "name", processDefinition.getName() );
+ if (useNamespace)
+ root = document.addElement("process-definition", jbpmNamespace.getURI());
+ else
+ root = document.addElement("process-definition");
+ addAttribute(root, "name", processDefinition.getName());
+
// write the start-state
- if ( processDefinition.getStartState()!=null ) {
+ if (processDefinition.getStartState() != null) {
writeComment(root, "START-STATE");
- writeStartNode( root, (StartState) processDefinition.getStartState() );
+ writeStartNode(root, (StartState) processDefinition.getStartState());
}
// write the nodeMap
- if ( ( processDefinition.getNodes()!=null )
- && ( processDefinition.getNodes().size() > 0 ) ) {
+ if ((processDefinition.getNodes() != null) && (processDefinition.getNodes().size() > 0)) {
writeComment(root, "NODES");
- writeNodes( root, processDefinition.getNodes() );
+ writeNodes(root, processDefinition.getNodes());
}
// write the process level actions
- if ( processDefinition.hasEvents() ) {
+ if (processDefinition.hasEvents()) {
writeComment(root, "PROCESS-EVENTS");
- writeEvents( root, processDefinition );
+ writeEvents(root, processDefinition);
}
- if( processDefinition.hasActions() ) {
+ if (processDefinition.hasActions()) {
writeComment(root, "ACTIONS");
List namedProcessActions = getNamedProcessActions(processDefinition.getActions());
writeActions(root, namedProcessActions);
}
- root.addText( System.getProperty("line.separator") );
+ root.addText(System.getProperty("line.separator"));
return document;
}
-
+
private List getNamedProcessActions(Map actions) {
List namedProcessActions = new ArrayList();
Iterator iter = actions.values().iterator();
while (iter.hasNext()) {
Action action = (Action) iter.next();
- if ( (action.getEvent()==null)
- && (action.getName()!=null) ) {
+ if ((action.getEvent() == null) && (action.getName() != null)) {
namedProcessActions.add(action);
}
}
return namedProcessActions;
}
- private void writeStartNode(Element element, StartState startState ) {
- if (startState!=null) {
- writeNode( addElement( element, getTypeName(startState) ), startState );
+ private void writeStartNode(Element element, StartState startState) {
+ if (startState != null) {
+ writeNode(addElement(element, getTypeName(startState)), startState);
}
}
-
+
private void writeNodes(Element parentElement, Collection nodes) {
Iterator iter = nodes.iterator();
while (iter.hasNext()) {
org.jbpm.graph.def.Node node = (org.jbpm.graph.def.Node) iter.next();
- if ( ! (node instanceof StartState) ) {
- Element nodeElement = addElement( parentElement, ProcessFactory.getTypeName(node) );
+ if (!(node instanceof StartState)) {
+ Element nodeElement = addElement(parentElement, ProcessFactory.getTypeName(node));
node.write(nodeElement);
- writeNode( nodeElement, node );
+ writeNode(nodeElement, node);
}
}
}
-
- private void writeNode(Element element, org.jbpm.graph.def.Node node ) {
- addAttribute( element, "name", node.getName() );
+
+ private void writeNode(Element element, org.jbpm.graph.def.Node node) {
+ addAttribute(element, "name", node.getName());
writeTransitions(element, node);
writeEvents(element, node);
}
private void writeTransitions(Element element, org.jbpm.graph.def.Node node) {
- if ( node.getLeavingTransitionsMap()!=null ) {
+ if (node.getLeavingTransitionsMap() != null) {
Iterator iter = node.getLeavingTransitionsList().iterator();
while (iter.hasNext()) {
Transition transition = (Transition) iter.next();
- writeTransition( element.addElement("transition"), transition );
+ writeTransition(element.addElement("transition"), transition);
}
}
}
private void writeTransition(Element transitionElement, Transition transition) {
- if (transition.getTo()!=null) {
- transitionElement.addAttribute( "to", transition.getTo().getName() );
+ if (transition.getTo() != null) {
+ transitionElement.addAttribute("to", transition.getTo().getName());
}
- if ( transition.getName()!=null ) {
- transitionElement.addAttribute( "name", transition.getName() );
+ if (transition.getName() != null) {
+ transitionElement.addAttribute("name", transition.getName());
}
Event transitionEvent = transition.getEvent(Event.EVENTTYPE_TRANSITION);
- if ( (transitionEvent!=null)
- && (transitionEvent.hasActions()) ){
+ if ((transitionEvent != null) && (transitionEvent.hasActions())) {
writeActions(transitionElement, transitionEvent.getActions());
}
}
@@ -196,7 +213,7 @@
Iterator iter = graphElement.getEvents().values().iterator();
while (iter.hasNext()) {
Event event = (Event) iter.next();
- writeEvent( element.addElement("event"), event );
+ writeEvent(element.addElement("event"), event);
}
}
}
@@ -207,7 +224,7 @@
Iterator actionIter = event.getActions().iterator();
while (actionIter.hasNext()) {
Action action = (Action) actionIter.next();
- writeAction( eventElement, action );
+ writeAction(eventElement, action);
}
}
}
@@ -216,15 +233,15 @@
Iterator actionIter = actions.iterator();
while (actionIter.hasNext()) {
Action action = (Action) actionIter.next();
- writeAction( parentElement, action );
+ writeAction(parentElement, action);
}
}
- private void writeAction(Element parentElement, Action action ) {
+ private void writeAction(Element parentElement, Action action) {
String actionName = ActionTypes.getActionName(action.getClass());
Element actionElement = parentElement.addElement(actionName);
- if (action.getName()!=null) {
+ if (action.getName() != null) {
actionElement.addAttribute("name", action.getName());
}
@@ -235,25 +252,25 @@
action.write(actionElement);
}
- private void writeComment(Element element, String comment ) {
- element.addText( System.getProperty("line.separator") );
- element.addComment( " " + comment + " " );
+ private void writeComment(Element element, String comment) {
+ element.addText(System.getProperty("line.separator"));
+ element.addComment(" " + comment + " ");
}
- private Element addElement( Element element, String elementName ) {
- Element newElement = element.addElement( elementName );
+ private Element addElement(Element element, String elementName) {
+ Element newElement = element.addElement(elementName);
return newElement;
}
- private void addAttribute( Element e, String attributeName, String value ) {
- if ( value != null ) {
- e.addAttribute( attributeName, value );
+ private void addAttribute(Element e, String attributeName, String value) {
+ if (value != null) {
+ e.addAttribute(attributeName, value);
}
}
- private String getTypeName( Object o ) {
- return ProcessFactory.getTypeName( (org.jbpm.graph.def.Node) o );
+ private String getTypeName(Object o) {
+ return ProcessFactory.getTypeName((org.jbpm.graph.def.Node) o);
}
-
+
// private static final Log log = LogFactory.getLog(JpdlXmlWriter.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,59 +29,53 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.security.AuthenticationService;
import org.jbpm.util.ClassLoaderUtil;
/**
- * gets the authenticated actor id from the current Subject.
- * This Authenticator is either configured via the {@link SubjectAuthenticationServiceFactory}
- * or it requires the two other configuration parameter
- * 'jbpm.authenticator.principal.classname' and 'jbpm.authenticator.principal.allow.overwrite'
- * This configuration property
- * specifies the class name of the principal that should be used from
- * the current subject. This could be for example org.jboss.security.CallerIdentity
- * in an JBoss AS.
- *
- * If not actorId is set, the name of that principal is used as the
- * currently authenticated actorId. If an actorId!=null is set (via setActorId)
- * this one overwrites the principal. This behavior is configurable via
- * the 'jbpm.authenticator.principal.allow.overwrite' attribute. If this
- * is set to false, setActorId is simply ignored.
- *
+ * gets the authenticated actor id from the current Subject. This Authenticator is either configured
+ * via the {@link SubjectAuthenticationServiceFactory} or it requires the two other configuration
+ * parameter 'jbpm.authenticator.principal.classname' and
+ * 'jbpm.authenticator.principal.allow.overwrite' This configuration property specifies the class
+ * name of the principal that should be used from the current subject. This could be for example
+ * org.jboss.security.CallerIdentity in an JBoss AS. If not actorId is set, the name of that
+ * principal is used as the currently authenticated actorId. If an actorId!=null is set (via
+ * setActorId) this one overwrites the principal. This behavior is configurable via the
+ * 'jbpm.authenticator.principal.allow.overwrite' attribute. If this is set to false, setActorId is
+ * simply ignored.
*/
public class SubjectAuthenticationService implements AuthenticationService {
-
+
private static final long serialVersionUID = 1L;
-
+
private static Log log = LogFactory.getLog(JbpmContext.class);
-
+
private Class principalClass;
-
+
private boolean allowActorIdOverwrite;
-
+
private String actorId;
-
- public SubjectAuthenticationService(String principalClassName, Boolean allowActorIdOverwrite)
- {
- if (principalClassName!=null) {
- initPrincipalClass( principalClassName );
+
+ public SubjectAuthenticationService(String principalClassName, Boolean allowActorIdOverwrite) {
+ if (principalClassName != null) {
+ initPrincipalClass(principalClassName);
}
else {
- initPrincipalClass(JbpmConfiguration.Configs.getString("jbpm.authenticator.principal.classname") );
+ initPrincipalClass(JbpmConfiguration.Configs.getString("jbpm.authenticator.principal.classname"));
}
- if (allowActorIdOverwrite!=null) {
- this.allowActorIdOverwrite = allowActorIdOverwrite;
+ if (allowActorIdOverwrite != null) {
+ this.allowActorIdOverwrite = allowActorIdOverwrite.booleanValue();
}
else {
this.allowActorIdOverwrite = JbpmConfiguration.Configs.getBoolean("jbpm.authenticator.principal.allow.overwrite");
}
}
- public SubjectAuthenticationService()
- {
- initPrincipalClass(JbpmConfiguration.Configs.getString("jbpm.authenticator.principal.classname") );
+ public SubjectAuthenticationService() {
+ initPrincipalClass(JbpmConfiguration.Configs.getString("jbpm.authenticator.principal.classname"));
allowActorIdOverwrite = JbpmConfiguration.Configs.getBoolean("jbpm.authenticator.principal.allow.overwrite");
}
@@ -90,18 +84,16 @@
}
public String getActorId() {
- if (actorId==null) {
+ if (actorId == null) {
Subject subject = Subject.getSubject(AccessController.getContext());
- if (subject==null) {
+ if (subject == null) {
log.warn("no javax.security.auth.Subject exists! Cannot set jbpm actorId");
return null;
}
-
+
Set principals = subject.getPrincipals(principalClass);
- if ( (principals!=null)
- && (!principals.isEmpty())
- ) {
+ if ((principals != null) && (!principals.isEmpty())) {
// always use the first one (so be patient what Principal classes are used)
Principal principal = (Principal) principals.iterator().next();
actorId = principal.getName();
@@ -110,14 +102,13 @@
return actorId;
}
- public void setActorId(String actorId)
- {
- if (allowActorIdOverwrite && actorId!=null) {
+ public void setActorId(String actorId) {
+ if (allowActorIdOverwrite && actorId != null) {
this.actorId = actorId;
}
}
-
+
public void close() {
}
-
+
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationServiceFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationServiceFactory.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationServiceFactory.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -25,39 +25,46 @@
import org.jbpm.svc.ServiceFactory;
/**
+ * <p>
* Factory to create a {@link SubjectAuthenticationService}.
+ * </p>
+ * <p>
+ * Two properties can be set: allowActorIdOverwrite & principalClassName
+ * </p>
+ * <p>
+ * principalClassName configuration property specifies the class name of the principal that should
+ * be used from the current subject. This could be for example org.jboss.security.CallerIdentity in
+ * an JBoss AS.
+ * </p>
+ * <p>
+ * If not actorId is set, the name of that principal is used as the currently authenticated actorId.
+ * If an actorId!=null is set (via setActorId) this one overwrites the principal. This behavior is
+ * configurable via the allowActorIdOverwrite attribute. If this is set to false, setActorId is
+ * simply ignored.
+ * <p>
+ * <p>
+ * Example:
+ * </p>
*
- * Two properties can be set: allowActorIdOverwrite & principalClassName.
- *
- * principalClassName configuration property
- * specifies the class name of the principal that should be used from
- * the current subject. This could be for example org.jboss.security.CallerIdentity
- * in an JBoss AS.
- *
- * If not actorId is set, the name of that principal is used as the
- * currently authenticated actorId. If an actorId!=null is set (via setActorId)
- * this one overwrites the principal. This behavior is configurable via
- * the allowActorIdOverwrite attribute. If this
- * is set to false, setActorId is simply ignored.
- *
- * Example:
- * <service name="authentication">
+ * <pre>
+ * <service name="authentication">
* <factory>
- * <bean class="org.jbpm.security.authentication.SubjectAuthenticationServiceFactory">
- * <field name="principalClassName"> <string value="org.jboss.security.CallerIdentity" /> </field>
- * <field name="allowActorIdOverwrite"> <boolean value="true" /> </field>
+ * <bean class="org.jbpm.security.authentication.SubjectAuthenticationServiceFactory">
+ * <field name="principalClassName"> <string value="org.jboss.security.CallerIdentity" /> </field>
+ * <field name="allowActorIdOverwrite"> <boolean value="true" /> </field>
* </bean>
* </factory>
* </service>
+ * </pre>
*
* @author bernd.ruecker at camunda.com
*/
public class SubjectAuthenticationServiceFactory implements ServiceFactory {
private static final long serialVersionUID = 1L;
-
+
private Boolean allowActorIdOverwrite;
-
+
private String principalClassName;
public Service openService() {
@@ -67,23 +74,19 @@
public void close() {
}
- public boolean isAllowActorIdOverwrite()
- {
+ public Boolean isAllowActorIdOverwrite() {
return allowActorIdOverwrite;
}
- public void setAllowActorIdOverwrite(boolean allowActorIdOverwrite)
- {
+ public void setAllowActorIdOverwrite(Boolean allowActorIdOverwrite) {
this.allowActorIdOverwrite = allowActorIdOverwrite;
}
- public String getPrincipalClassName()
- {
+ public String getPrincipalClassName() {
return principalClassName;
}
- public void setPrincipalClassName(String principalClassName)
- {
+ public void setPrincipalClassName(String principalClassName) {
this.principalClassName = principalClassName;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/svc/Services.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -32,6 +32,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.StaleStateException;
+import org.hibernate.exception.LockAcquisitionException;
+
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.graph.exe.ProcessInstance;
@@ -50,8 +52,8 @@
import org.jbpm.svc.save.SaveOperation;
import org.jbpm.tx.TxService;
-public class Services implements Serializable
-{
+public class Services implements Serializable {
+
private static final long serialVersionUID = 1L;
public static final String SERVICENAME_AUTHENTICATION = "authentication";
@@ -66,8 +68,7 @@
static final List defaultSaveOperations = createDefaultSaveOperations();
- private static List createDefaultSaveOperations()
- {
+ private static List createDefaultSaveOperations() {
SaveOperation[] operations = new SaveOperation[4];
operations[0] = new CheckUnpersistableVariablesOperation();
// first we save the runtime data (process instance)
@@ -79,101 +80,81 @@
return Arrays.asList(operations);
}
- Map<String, ServiceFactory> serviceFactories;
- Map<String, Service> services;
+ Map serviceFactories;
+ Map services;
List serviceNames = null;
List saveOperations = null;
- public static Service getCurrentService(String name)
- {
+ public static Service getCurrentService(String name) {
return getCurrentService(name, true);
}
- public static Service getCurrentService(String name, boolean isRequired)
- {
+ public static Service getCurrentService(String name, boolean isRequired) {
Service service = null;
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null)
- {
+ if (jbpmContext != null) {
service = jbpmContext.getServices().getService(name);
}
- if (isRequired && (service == null))
- {
+ if (isRequired && (service == null)) {
throw new JbpmServiceException("service '" + name + "' unavailable");
}
return service;
}
- public Services(Map serviceFactories)
- {
+ public Services(Map serviceFactories) {
this(serviceFactories, new ArrayList(serviceFactories.keySet()), null);
}
- public Services(Map serviceFactories, List serviceNames, List saveOperations)
- {
+ public Services(Map serviceFactories, List serviceNames, List saveOperations) {
this.serviceFactories = serviceFactories;
this.serviceNames = serviceNames;
this.saveOperations = saveOperations != null ? saveOperations : defaultSaveOperations;
}
- public void setSaveOperations(List saveOperations)
- {
- if (saveOperations == null)
- {
+ public void setSaveOperations(List saveOperations) {
+ if (saveOperations == null) {
throw new IllegalArgumentException("saveOperations cannot be null");
}
this.saveOperations = saveOperations;
}
- public void addSaveOperation(SaveOperation saveOperation)
- {
- if (saveOperation == null)
- {
+ public void addSaveOperation(SaveOperation saveOperation) {
+ if (saveOperation == null) {
throw new IllegalArgumentException("saveOperation cannot be null");
}
- if (saveOperations == defaultSaveOperations)
- {
+ if (saveOperations == defaultSaveOperations) {
saveOperations = new ArrayList(defaultSaveOperations);
}
saveOperations.add(saveOperation);
}
- public Map<String, ServiceFactory> getServiceFactories()
- {
- if (serviceFactories == null)
- {
- serviceFactories = new HashMap<String, ServiceFactory>();
+ public Map getServiceFactories() {
+ if (serviceFactories == null) {
+ serviceFactories = new HashMap();
}
return serviceFactories;
}
- public ServiceFactory getServiceFactory(String name)
- {
- return getServiceFactories().get(name);
+ public ServiceFactory getServiceFactory(String name) {
+ return (ServiceFactory) getServiceFactories().get(name);
}
- public boolean hasService(String name)
- {
+ public boolean hasService(String name) {
boolean hasService = false;
- if (services != null)
- {
+ if (services != null) {
hasService = services.containsKey(name);
}
return hasService;
}
- public Service getService(String name)
- {
- if (services == null)
- {
- services = new HashMap<String, Service>();
+ public Service getService(String name) {
+ if (services == null) {
+ services = new HashMap();
}
- Service service = services.get(name);
- if (service == null)
- {
+ Service service = (Service) services.get(name);
+ if (service == null) {
ServiceFactory serviceFactory = getServiceFactory(name);
- if (serviceFactory != null)
- {
+ if (serviceFactory != null) {
service = serviceFactory.openService();
services.put(name, service);
}
@@ -181,176 +162,139 @@
return service;
}
- public void save(ProcessInstance processInstance, JbpmContext jbpmContext)
- {
+ public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
Iterator iter = saveOperations.iterator();
- if (log.isDebugEnabled())
- {
- if (saveOperations == defaultSaveOperations)
- {
+ if (log.isDebugEnabled()) {
+ if (saveOperations == defaultSaveOperations) {
log.debug("executing default save operations");
}
- else
- {
+ else {
log.debug("executing custom save operations");
}
}
- while (iter.hasNext())
- {
- SaveOperation saveOperation = (SaveOperation)iter.next();
+ while (iter.hasNext()) {
+ SaveOperation saveOperation = (SaveOperation) iter.next();
saveOperation.save(processInstance, jbpmContext);
}
}
// services /////////////////////////////////////////////////////////////////
- public AuthenticationService getAuthenticationService()
- {
- return (AuthenticationService)getService(SERVICENAME_AUTHENTICATION);
+ public AuthenticationService getAuthenticationService() {
+ return (AuthenticationService) getService(SERVICENAME_AUTHENTICATION);
}
- public AuthorizationService getAuthorizationService()
- {
- return (AuthorizationService)getService(SERVICENAME_AUTHORIZATION);
+ public AuthorizationService getAuthorizationService() {
+ return (AuthorizationService) getService(SERVICENAME_AUTHORIZATION);
}
- public LoggingService getLoggingService()
- {
- return (LoggingService)getService(SERVICENAME_LOGGING);
+ public LoggingService getLoggingService() {
+ return (LoggingService) getService(SERVICENAME_LOGGING);
}
- public MessageService getMessageService()
- {
- return (MessageService)getService(SERVICENAME_MESSAGE);
+ public MessageService getMessageService() {
+ return (MessageService) getService(SERVICENAME_MESSAGE);
}
- public PersistenceService getPersistenceService()
- {
- return (PersistenceService)getService(SERVICENAME_PERSISTENCE);
+ public PersistenceService getPersistenceService() {
+ return (PersistenceService) getService(SERVICENAME_PERSISTENCE);
}
- public SchedulerService getSchedulerService()
- {
- return (SchedulerService)getService(SERVICENAME_SCHEDULER);
+ public SchedulerService getSchedulerService() {
+ return (SchedulerService) getService(SERVICENAME_SCHEDULER);
}
- public TxService getTxService()
- {
- return (TxService)getService(SERVICENAME_TX);
+ public TxService getTxService() {
+ return (TxService) getService(SERVICENAME_TX);
}
- public void setAuthenticationService(AuthenticationService authenticationService)
- {
+ public void setAuthenticationService(AuthenticationService authenticationService) {
services.put(SERVICENAME_AUTHENTICATION, authenticationService);
}
- public void setAuthorizationService(AuthorizationService authorizationService)
- {
+ public void setAuthorizationService(AuthorizationService authorizationService) {
services.put(SERVICENAME_AUTHORIZATION, authorizationService);
}
- public void setLoggingService(LoggingService loggingService)
- {
+ public void setLoggingService(LoggingService loggingService) {
services.put(SERVICENAME_LOGGING, loggingService);
}
- public void setMessageService(MessageService messageService)
- {
+ public void setMessageService(MessageService messageService) {
services.put(SERVICENAME_MESSAGE, messageService);
}
- public void setPersistenceService(PersistenceService persistenceService)
- {
+ public void setPersistenceService(PersistenceService persistenceService) {
services.put(SERVICENAME_PERSISTENCE, persistenceService);
}
- public void setSchedulerService(SchedulerService schedulerService)
- {
+ public void setSchedulerService(SchedulerService schedulerService) {
services.put(SERVICENAME_SCHEDULER, schedulerService);
}
- public void setTxService(TxService txService)
- {
+ public void setTxService(TxService txService) {
services.put(SERVICENAME_TX, txService);
}
- public void close()
- {
- if (services != null)
- {
+ public void close() {
+ if (services != null) {
Exception firstException = null;
Iterator iter = serviceNames.iterator();
- while (iter.hasNext())
- {
- String serviceName = (String)iter.next();
- Service service = (Service)services.get(serviceName);
- if (service != null)
- {
- try
- {
+ while (iter.hasNext()) {
+ String serviceName = (String) iter.next();
+ Service service = (Service) services.get(serviceName);
+ if (service != null) {
+ try {
log.debug("closing service '" + serviceName + "': " + service);
service.close();
}
- catch (JbpmPersistenceException e)
- {
+ catch (JbpmPersistenceException e) {
// if this is a stale state exception, the jbpm configuration has control over the logging
- if (isCausedByStaleState(e))
- {
- log.info("problem closing service '" + serviceName + "': optimistic locking failed");
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("problem closing service '" + serviceName + "': optimistic locking failed", e);
+ if (isCausedByStaleState(e)) {
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error(
+ "problem closing service '" + serviceName + "': optimistic locking failed", e);
}
- else
- {
+ else {
log.error("problem closing service '" + serviceName + "'", e);
}
- if (firstException == null)
- {
+ if (firstException == null) {
firstException = e;
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
log.error("problem closing service '" + serviceName + "'", e);
- if (firstException == null)
- {
+ if (firstException == null) {
firstException = e;
}
}
}
}
- if (firstException != null)
- {
- if (firstException instanceof JbpmException)
- {
- throw (JbpmException)firstException;
+ if (firstException != null) {
+ if (firstException instanceof JbpmException) {
+ throw (JbpmException) firstException;
}
throw new JbpmException("problem closing services", firstException);
}
}
}
- public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException)
- {
- for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause())
- {
- if (cause instanceof StaleStateException)
+ public static boolean isCausedByStaleState(JbpmPersistenceException persistenceException) {
+ for (Throwable cause = persistenceException.getCause(); cause != null; cause = cause.getCause()) {
+ if (cause instanceof StaleStateException || cause instanceof LockAcquisitionException)
return true;
}
return false;
}
- public static void assignId(Object object)
- {
+ public static void assignId(Object object) {
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null)
- {
+ if (jbpmContext != null) {
// give this process instance an id
Services services = jbpmContext.getServices();
- if (services.hasService(Services.SERVICENAME_PERSISTENCE))
- {
+ if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
PersistenceService persistenceService = services.getPersistenceService();
persistenceService.assignId(object);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -31,31 +31,32 @@
public class PooledActor implements Serializable {
private static final long serialVersionUID = 1L;
-
+
long id = 0;
int version = 0;
protected String actorId = null;
protected Set taskInstances = null;
protected SwimlaneInstance swimlaneInstance = null;
- public static Set<PooledActor> createPool(String[] actorIds, SwimlaneInstance swimlaneInstance, TaskInstance taskInstance) {
- Set<PooledActor> pooledActors = new HashSet<PooledActor>();
- for (int i=0; i<actorIds.length; i++) {
+ public static Set createPool(String[] actorIds, SwimlaneInstance swimlaneInstance,
+ TaskInstance taskInstance) {
+ Set pooledActors = new HashSet();
+ for (int i = 0; i < actorIds.length; i++) {
PooledActor pooledActor = new PooledActor(actorIds[i]);
- if (swimlaneInstance!=null) {
+ if (swimlaneInstance != null) {
pooledActor.setSwimlaneInstance(swimlaneInstance);
}
- if (taskInstance!=null) {
+ if (taskInstance != null) {
pooledActor.addTaskInstance(taskInstance);
}
pooledActors.add(pooledActor);
}
return pooledActors;
}
-
+
public static Set extractActorIds(Set poooledActors) {
Set extractedActorIds = null;
- if (poooledActors!=null) {
+ if (poooledActors != null) {
extractedActorIds = new HashSet();
Iterator iter = poooledActors.iterator();
while (iter.hasNext()) {
@@ -72,16 +73,18 @@
public PooledActor(String actorId) {
this.actorId = actorId;
}
-
+
public void addTaskInstance(TaskInstance taskInstance) {
- if (taskInstances==null) taskInstances = new HashSet();
+ if (taskInstances == null) taskInstances = new HashSet();
taskInstances.add(taskInstance);
}
+
public Set getTaskInstances() {
return taskInstances;
}
+
public void removeTaskInstance(TaskInstance taskInstance) {
- if (taskInstances!=null) {
+ if (taskInstances != null) {
taskInstances.remove(taskInstance);
}
}
@@ -92,25 +95,29 @@
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
public String toString() {
- return "PooledActor("+actorId+")";
+ return "PooledActor(" + actorId + ")";
}
-
+
// getters and setters //////////////////////////////////////////////////////
public String getActorId() {
return actorId;
}
+
public void setActorId(String actorId) {
this.actorId = actorId;
}
+
public SwimlaneInstance getSwimlaneInstance() {
return swimlaneInstance;
}
+
public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance) {
this.swimlaneInstance = swimlaneInstance;
}
+
public long getId() {
return id;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -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;
/**
@@ -38,13 +38,13 @@
int version = 0;
protected String name = null;
protected String actorId = null;
- protected Set<PooledActor> pooledActors = null;
+ protected Set pooledActors = null;
protected Swimlane swimlane = null;
protected TaskMgmtInstance taskMgmtInstance = null;
-
+
public SwimlaneInstance() {
}
-
+
public SwimlaneInstance(Swimlane swimlane) {
this.name = swimlane.getName();
this.swimlane = swimlane;
@@ -60,34 +60,42 @@
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
// getters and setters //////////////////////////////////////////////////////
public long getId() {
return id;
}
+
public String getName() {
return name;
}
+
public Swimlane getSwimlane() {
return swimlane;
}
+
public String getActorId() {
return actorId;
}
+
public void setActorId(String actorId) {
this.actorId = actorId;
}
+
public TaskMgmtInstance getTaskMgmtInstance() {
return taskMgmtInstance;
}
+
public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance) {
this.taskMgmtInstance = taskMgmtInstance;
}
- public Set<PooledActor> getPooledActors() {
+
+ public Set getPooledActors() {
return pooledActors;
}
- public void setPooledActors(Set<PooledActor> pooledActors) {
+
+ public void setPooledActors(Set pooledActors) {
this.pooledActors = pooledActors;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,6 +30,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmException;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.context.exe.VariableContainer;
@@ -52,11 +53,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;
@@ -80,28 +80,24 @@
protected SwimlaneInstance swimlaneInstance = null;
protected TaskMgmtInstance taskMgmtInstance = null;
protected ProcessInstance processInstance = null;
- protected Set<PooledActor> pooledActors = null;
+ protected Set pooledActors = null;
protected List comments = null;
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 +106,54 @@
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");
+ 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.
- contextInstance.setVariable(variableInstance.getName(), variableInstance.getValue(), token);
+ 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 +165,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,44 +181,40 @@
swimlaneInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
}
- else
- {
+ else {
// lazy initialize the swimlane...
// get the swimlane instance (if there is any)
- swimlaneInstance = taskMgmtInstance.getInitializedSwimlaneInstance(executionContext, swimlane);
+ swimlaneInstance = taskMgmtInstance.getInitializedSwimlaneInstance(executionContext,
+ swimlane);
// copy the swimlaneInstance assignment into the taskInstance assignment
copySwimlaneInstanceAssignment(swimlaneInstance);
}
}
- else
- { // this task is not in a swimlane
- taskMgmtInstance.performAssignment(task.getAssignmentDelegation(), task.getActorIdExpression(), task.getPooledActorsExpression(), this, executionContext);
+ 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)
- {
+ void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance) {
+ if (pooledActors != null) {
Iterator iter = pooledActors.iterator();
- while (iter.hasNext())
- {
- PooledActor pooledActor = (PooledActor)iter.next();
+ while (iter.hasNext()) {
+ PooledActor pooledActor = (PooledActor) iter.next();
pooledActor.setSwimlaneInstance(swimlaneInstance);
pooledActor.addTaskInstance(this);
}
@@ -239,35 +222,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 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 +254,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 +279,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 +310,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 +325,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 +417,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 +425,7 @@
}
// log this assignment
- if (token != null)
- {
+ if (token != null) {
token.addLog(new TaskEndLog(this));
}
@@ -476,40 +433,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 +474,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,48 +483,39 @@
// 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();
comments.add(comment);
comment.setTaskInstance(this);
- if (token != null)
- {
+ if (token != null) {
comment.setToken(token);
token.addComment(comment);
}
}
}
- public List getComments()
- {
+ public List 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()
- {
+ public List getAvailableTransitions() {
List transitions = null;
- if ((!isLast()) && (token != null))
- {
+ if ((!isLast()) && (token != null)) {
transitions = new ArrayList(token.getAvailableTransitions());
}
return transitions;
@@ -579,209 +524,170 @@
// 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)
- {
+ 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();
+ while (iter.hasNext()) {
+ PooledActor pooledActor = (PooledActor) iter.next();
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/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,7 +21,6 @@
*/
package org.jbpm.taskmgmt.exe;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
@@ -59,50 +58,44 @@
/**
* process instance extension for managing tasks on a process instance.
*/
-public class TaskMgmtInstance extends ModuleInstance
-{
+public class TaskMgmtInstance extends ModuleInstance {
private static final long serialVersionUID = 1L;
TaskMgmtDefinition taskMgmtDefinition = null;
- Map<String, SwimlaneInstance> swimlaneInstances = null;
- Set<TaskInstance> taskInstances = null;
+ Map swimlaneInstances = null;
+ Set taskInstances = null;
+
/**
* non persistent collection that stores all the task instances that have variable updates
*/
- Collection<TaskInstance> taskInstanceVariableUpdates = null;
+ Collection taskInstanceVariableUpdates = null;
- public TaskMgmtInstance()
- {
+ public TaskMgmtInstance() {
}
- public TaskMgmtInstance(TaskMgmtDefinition taskMgmtDefinition)
- {
+ public TaskMgmtInstance(TaskMgmtDefinition taskMgmtDefinition) {
this.taskMgmtDefinition = taskMgmtDefinition;
}
// task instances ///////////////////////////////////////////////////////////
- public TaskInstance createTaskInstance()
- {
- return createTaskInstance(null, (ExecutionContext)null);
+ public TaskInstance createTaskInstance() {
+ return createTaskInstance(null, (ExecutionContext) null);
}
- public TaskInstance createTaskInstance(Task task)
- {
- return createTaskInstance(task, (ExecutionContext)null);
+ public TaskInstance createTaskInstance(Task task) {
+ return createTaskInstance(task, (ExecutionContext) null);
}
- public TaskInstance createTaskInstance(Token token)
- {
+ public TaskInstance createTaskInstance(Token token) {
return createTaskInstance(null, new ExecutionContext(token));
}
/**
* creates a new task instance on the given token, for the given task.
*/
- public TaskInstance createTaskInstance(Task task, Token token)
- {
+ public TaskInstance createTaskInstance(Task task, Token token) {
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTask(task);
return createTaskInstance(task, executionContext);
@@ -111,8 +104,7 @@
/**
* creates a new task instance on the given task, in the given execution context.
*/
- public TaskInstance createTaskInstance(Task task, ExecutionContext executionContext)
- {
+ public TaskInstance createTaskInstance(Task task, ExecutionContext executionContext) {
// instantiate the new task instance
TaskInstance taskInstance = instantiateNewTaskInstance(executionContext);
@@ -120,95 +112,75 @@
addTaskInstance(taskInstance);
// initialize the task instance
- if (task != null)
- taskInstance.setTask(task);
+ if (task != null) taskInstance.setTask(task);
// assign an id to the task instance
Services.assignId(taskInstance);
- // copy the task properties
- /*
- * XXX property initialization was already done in taskInstance.setTask(task) String description = null; if
- * (task!=null) { description = task.getDescription(); taskInstance.setDescription(description);
- * taskInstance.setBlocking(task.isBlocking()); taskInstance.setSignalling(task.isSignalling()); }
- */
-
- if (executionContext != null)
- {
+ if (executionContext != null) {
Token token = executionContext.getToken();
taskInstance.setToken(token);
taskInstance.setProcessInstance(token.getProcessInstance());
taskInstance.initializeVariables();
- if (task != null && task.getDueDate() != null)
- {
+ if (task != null && task.getDueDate() != null) {
Date baseDate;
String dueDateString = task.getDueDate();
String durationString = null;
- if (dueDateString.startsWith("#"))
- {
+ if (dueDateString.startsWith("#")) {
String baseDateEL = dueDateString.substring(0, dueDateString.indexOf("}") + 1);
Object result = JbpmExpressionEvaluator.evaluate(baseDateEL, executionContext);
- if (result instanceof Date)
- {
- baseDate = (Date)result;
+ if (result instanceof Date) {
+ baseDate = (Date) result;
}
- else if (result instanceof Calendar)
- {
- baseDate = ((Calendar)result).getTime();
+ else if (result instanceof Calendar) {
+ baseDate = ((Calendar) result).getTime();
}
- else
- {
- throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + result.getClass().getName()
+ else {
+ throw new JbpmException("Invalid basedate type: "
+ + baseDateEL
+ + " is of type "
+ + result.getClass().getName()
+ ". Only Date and Calendar are supported");
}
int endOfELIndex = dueDateString.indexOf("}");
- if (endOfELIndex < (dueDateString.length() - 1))
- {
+ if (endOfELIndex < (dueDateString.length() - 1)) {
char durationSeparator = dueDateString.substring(endOfELIndex + 1).trim().charAt(0);
- if (durationSeparator != '+' && durationSeparator != '-')
- {
+ if (durationSeparator != '+' && durationSeparator != '-') {
throw new JbpmException("Invalid duedate, + or - missing after EL");
}
durationString = dueDateString.substring(endOfELIndex + 1).trim();
}
}
- else
- {
+ else {
baseDate = Clock.getCurrentTime();
durationString = dueDateString;
}
Date dueDate;
- if (durationString == null || durationString.length() == 0)
- {
+ if (durationString == null || durationString.length() == 0) {
dueDate = baseDate;
}
- else
- {
+ else {
BusinessCalendar businessCalendar = new BusinessCalendar();
dueDate = businessCalendar.add(baseDate, new Duration(durationString));
}
taskInstance.setDueDate(dueDate);
}
- try
- {
+ try {
// update the executionContext
executionContext.setTask(task);
executionContext.setTaskInstance(taskInstance);
executionContext.setEventSource(task);
// evaluate the description
- if (task != null)
- {
+ if (task != null) {
String description = task.getDescription();
- if ((description != null) && (description.indexOf("#{") != -1))
- {
+ if ((description != null) && (description.indexOf("#{") != -1)) {
Object result = JbpmExpressionEvaluator.evaluate(description, executionContext);
- if (result != null)
- {
+ if (result != null) {
taskInstance.setDescription(result.toString());
}
}
@@ -218,14 +190,11 @@
taskInstance.create(executionContext);
// if this task instance is created for a task, perform assignment
- if (task != null)
- {
+ if (task != null) {
taskInstance.assign(executionContext);
}
-
}
- finally
- {
+ finally {
// clean the executionContext
executionContext.setTask(null);
executionContext.setTaskInstance(null);
@@ -236,152 +205,136 @@
// WARNING: The events create and assign are fired in the right order, but
// the logs are still not ordered properly.
token.addLog(new TaskCreateLog(taskInstance, taskInstance.getActorId()));
-
}
- else
- {
+ else {
taskInstance.create();
}
-
return taskInstance;
}
- public SwimlaneInstance getInitializedSwimlaneInstance(ExecutionContext executionContext, Swimlane swimlane)
- {
+ public SwimlaneInstance getInitializedSwimlaneInstance(ExecutionContext executionContext,
+ Swimlane swimlane) {
// initialize the swimlane
- if (swimlaneInstances == null)
- swimlaneInstances = new HashMap<String, SwimlaneInstance>();
- SwimlaneInstance swimlaneInstance = swimlaneInstances.get(swimlane.getName());
- if (swimlaneInstance == null)
- {
+ if (swimlaneInstances == null) swimlaneInstances = new HashMap();
+ SwimlaneInstance swimlaneInstance = (SwimlaneInstance) swimlaneInstances.get(swimlane.getName());
+ if (swimlaneInstance == null) {
swimlaneInstance = new SwimlaneInstance(swimlane);
addSwimlaneInstance(swimlaneInstance);
// assign the swimlaneInstance
- performAssignment(swimlane.getAssignmentDelegation(), swimlane.getActorIdExpression(), swimlane.getPooledActorsExpression(), swimlaneInstance,
- executionContext);
+ performAssignment(swimlane.getAssignmentDelegation(), swimlane.getActorIdExpression(),
+ swimlane.getPooledActorsExpression(), swimlaneInstance, executionContext);
}
return swimlaneInstance;
}
- public void performAssignment(Delegation assignmentDelegation, String actorIdExpression, String pooledActorsExpression, Assignable assignable,
- ExecutionContext executionContext)
- {
- try
- {
- if (assignmentDelegation != null)
- {
+ public void performAssignment(Delegation assignmentDelegation, String actorIdExpression,
+ String pooledActorsExpression, Assignable assignable, ExecutionContext executionContext) {
+ try {
+ if (assignmentDelegation != null) {
performAssignmentDelegation(assignmentDelegation, assignable, executionContext);
}
- else
- {
- if (actorIdExpression != null)
- {
+ else {
+ if (actorIdExpression != null) {
performAssignmentActorIdExpr(actorIdExpression, assignable, executionContext);
}
- if (pooledActorsExpression != null)
- {
+ if (pooledActorsExpression != null) {
performAssignmentPooledActorsExpr(pooledActorsExpression, assignable, executionContext);
}
}
}
- catch (Exception exception)
- {
+ catch (Exception exception) {
GraphElement graphElement = executionContext.getEventSource();
- if (graphElement != null)
- {
+ if (graphElement != null) {
graphElement.raiseException(exception, executionContext);
}
- else
- {
+ else {
throw new DelegationException(exception, executionContext);
}
}
}
- void performAssignmentDelegation(Delegation assignmentDelegation, Assignable assignable, ExecutionContext executionContext) throws Exception
- {
+ void performAssignmentDelegation(Delegation assignmentDelegation, Assignable assignable,
+ ExecutionContext executionContext) throws Exception {
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
- try
- {
+ try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
+ Thread.currentThread().setContextClassLoader(
+ JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
// instantiate the assignment handler
- AssignmentHandler assignmentHandler = (AssignmentHandler)assignmentDelegation.instantiate();
+ AssignmentHandler assignmentHandler = (AssignmentHandler) assignmentDelegation.instantiate();
// invoke the assignment handler
- if (UserCodeInterceptorConfig.userCodeInterceptor != null)
- {
- UserCodeInterceptorConfig.userCodeInterceptor.executeAssignment(assignmentHandler, assignable, executionContext);
+ if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
+ UserCodeInterceptorConfig.userCodeInterceptor.executeAssignment(assignmentHandler,
+ assignable, executionContext);
}
- else
- {
+ else {
assignmentHandler.assign(assignable, executionContext);
}
-
}
- finally
- {
+ finally {
Thread.currentThread().setContextClassLoader(surroundingClassLoader);
}
}
- void performAssignmentActorIdExpr(String actorIdExpression, Assignable assignable, ExecutionContext executionContext)
- {
+ void performAssignmentActorIdExpr(String actorIdExpression, Assignable assignable,
+ ExecutionContext executionContext) {
Object result = null;
String actorId = null;
- try
- {
+ try {
result = JbpmExpressionEvaluator.evaluate(actorIdExpression, executionContext);
- if (result == null)
- {
+ if (result == null) {
throw new JbpmException("actor-id expression '" + actorIdExpression + "' returned null");
}
- actorId = (String)result;
+ actorId = (String) result;
}
- catch (ClassCastException e)
- {
- throw new JbpmException("actor-id expression '" + actorIdExpression + "' didn't resolve to a java.lang.String: '" + result + "' ("
- + result.getClass().getName() + ")");
+ catch (ClassCastException e) {
+ throw new JbpmException("actor-id expression '"
+ + actorIdExpression
+ + "' didn't resolve to a java.lang.String: '"
+ + result
+ + "' ("
+ + result.getClass().getName()
+ + ")");
}
assignable.setActorId(actorId);
}
- void performAssignmentPooledActorsExpr(String pooledActorsExpression, Assignable assignable, ExecutionContext executionContext)
- {
+ void performAssignmentPooledActorsExpr(String pooledActorsExpression, Assignable assignable,
+ ExecutionContext executionContext) {
String[] pooledActors = null;
Object result = JbpmExpressionEvaluator.evaluate(pooledActorsExpression, executionContext);
- if (result == null)
- {
- throw new JbpmException("pooled-actors expression '" + pooledActorsExpression + "' returned null");
+ if (result == null) {
+ throw new JbpmException("pooled-actors expression '"
+ + pooledActorsExpression
+ + "' returned null");
}
- if (result instanceof String[])
- {
- pooledActors = (String[])result;
-
+ if (result instanceof String[]) {
+ pooledActors = (String[]) result;
}
- else if (result instanceof Collection)
- {
- Collection collection = (Collection)result;
- pooledActors = (String[])collection.toArray(new String[collection.size()]);
-
+ else if (result instanceof Collection) {
+ Collection collection = (Collection) result;
+ pooledActors = (String[]) collection.toArray(new String[collection.size()]);
}
- else if (result instanceof String)
- {
+ else if (result instanceof String) {
List pooledActorList = new ArrayList();
- StringTokenizer tokenizer = new StringTokenizer((String)result, ",");
- while (tokenizer.hasMoreTokens())
- {
+ StringTokenizer tokenizer = new StringTokenizer((String) result, ",");
+ while (tokenizer.hasMoreTokens()) {
pooledActorList.add(tokenizer.nextToken().trim());
}
- pooledActors = (String[])pooledActorList.toArray(new String[pooledActorList.size()]);
+ pooledActors = (String[]) pooledActorList.toArray(new String[pooledActorList.size()]);
}
- else
- {
- throw new JbpmException("pooled-actors expression '" + pooledActorsExpression + "' didn't resolve to a comma separated String, a Collection or a String[]: '"
- + result + "' (" + result.getClass().getName() + ")");
+ else {
+ throw new JbpmException("pooled-actors expression '"
+ + pooledActorsExpression
+ + "' didn't resolve to a comma separated String, a Collection or a String[]: '"
+ + result
+ + "' ("
+ + result.getClass().getName()
+ + ")");
}
assignable.setPooledActors(pooledActors);
@@ -390,12 +343,10 @@
/**
* creates a task instance on the rootToken, and assigns it to the currently authenticated user.
*/
- public TaskInstance createStartTaskInstance()
- {
+ public TaskInstance createStartTaskInstance() {
TaskInstance taskInstance = null;
Task startTask = taskMgmtDefinition.getStartTask();
- if (startTask != null)
- {
+ if (startTask != null) {
Token rootToken = processInstance.getRootToken();
ExecutionContext executionContext = new ExecutionContext(rootToken);
taskInstance = createTaskInstance(startTask, executionContext);
@@ -404,59 +355,49 @@
return taskInstance;
}
- TaskInstance instantiateNewTaskInstance(ExecutionContext executionContext)
- {
- TaskInstanceFactory taskInstanceFactory = (TaskInstanceFactory)JbpmConfiguration.Configs.getObject("jbpm.task.instance.factory");
- if (taskInstanceFactory == null)
- {
+ TaskInstance instantiateNewTaskInstance(ExecutionContext executionContext) {
+ TaskInstanceFactory taskInstanceFactory = (TaskInstanceFactory) JbpmConfiguration.Configs.getObject("jbpm.task.instance.factory");
+ if (taskInstanceFactory == null) {
throw new JbpmException("jbpm.task.instance.factory was not configured in jbpm.cfg.xml");
}
return taskInstanceFactory.createTaskInstance(executionContext);
}
/**
- * is true if the given token has task instances that keep the token from leaving the current node.
+ * is true if the given token has task instances that keep the token from leaving the current
+ * node.
*/
- public boolean hasBlockingTaskInstances(Token token)
- {
- boolean hasBlockingTasks = false;
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext() && !hasBlockingTasks)
- {
- TaskInstance taskInstance = iter.next();
- if ((!taskInstance.hasEnded()) && (taskInstance.isBlocking()) && (token != null) && (token.equals(taskInstance.getToken())))
- {
- hasBlockingTasks = true;
+ public boolean hasBlockingTaskInstances(Token token) {
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if (!taskInstance.hasEnded()
+ && taskInstance.isBlocking()
+ && token != null
+ && token.equals(taskInstance.getToken())) {
+ return true;
}
}
}
- return hasBlockingTasks;
+ return false;
}
/**
* is true if the given token has task instances that are not yet ended.
*/
- public boolean hasUnfinishedTasks(Token token)
- {
+ public boolean hasUnfinishedTasks(Token token) {
return (getUnfinishedTasks(token).size() > 0);
}
/**
* is the collection of {@link TaskInstance}s on the given token that are not ended.
*/
- public Collection<TaskInstance> getUnfinishedTasks(Token token)
- {
- Collection<TaskInstance> unfinishedTasks = new ArrayList<TaskInstance>();
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance task = iter.next();
- if ((!task.hasEnded()) && (token != null) && (token.equals(task.getToken())))
- {
+ public Collection getUnfinishedTasks(Token token) {
+ Collection unfinishedTasks = new ArrayList();
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance task = (TaskInstance) i.next();
+ if (!task.hasEnded() && token != null && token.equals(task.getToken())) {
unfinishedTasks.add(task);
}
}
@@ -465,27 +406,24 @@
}
/**
- * is true if there are {@link TaskInstance}s on the given token that can trigger the token to continue.
+ * is true if there are {@link TaskInstance}s on the given token that can trigger the token to
+ * continue.
*/
- public boolean hasSignallingTasks(ExecutionContext executionContext)
- {
+ public boolean hasSignallingTasks(ExecutionContext executionContext) {
return (getSignallingTasks(executionContext).size() > 0);
}
/**
- * is the collection of {@link TaskInstance}s for the given token that can trigger the token to continue.
+ * is the collection of {@link TaskInstance}s for the given token that can trigger the token to
+ * continue.
*/
- public Collection<TaskInstance> getSignallingTasks(ExecutionContext executionContext)
- {
- Collection<TaskInstance> signallingTasks = new ArrayList<TaskInstance>();
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance taskInstance = iter.next();
- if (taskInstance.isSignalling() && (executionContext.getToken().equals(taskInstance.getToken())))
- {
+ public Collection getSignallingTasks(ExecutionContext executionContext) {
+ Collection signallingTasks = new ArrayList();
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if (taskInstance.isSignalling()
+ && (executionContext.getToken().equals(taskInstance.getToken()))) {
signallingTasks.add(taskInstance);
}
}
@@ -494,106 +432,79 @@
}
/**
- * returns all the taskInstances for the this process instance. This includes task instances that have been completed
- * previously.
+ * returns all the taskInstances for the this process instance. This includes task instances that
+ * have been completed previously.
*/
- public Collection<TaskInstance> getTaskInstances()
- {
+ public Collection getTaskInstances() {
return taskInstances;
}
- public void addTaskInstance(TaskInstance taskInstance)
- {
- if (taskInstances == null)
- taskInstances = new HashSet<TaskInstance>();
+ public void addTaskInstance(TaskInstance taskInstance) {
+ if (taskInstances == null) taskInstances = new HashSet();
taskInstances.add(taskInstance);
taskInstance.setTaskMgmtInstance(this);
}
- public void removeTaskInstance(TaskInstance taskInstance)
- {
- if (taskInstances != null)
- {
+ public void removeTaskInstance(TaskInstance taskInstance) {
+ if (taskInstances != null) {
taskInstances.remove(taskInstance);
}
}
// swimlane instances ///////////////////////////////////////////////////////
- public Map<String, SwimlaneInstance> getSwimlaneInstances()
- {
+ public Map getSwimlaneInstances() {
return swimlaneInstances;
}
- public void addSwimlaneInstance(SwimlaneInstance swimlaneInstance)
- {
- if (swimlaneInstances == null)
- swimlaneInstances = new HashMap<String, SwimlaneInstance>();
+ public void addSwimlaneInstance(SwimlaneInstance swimlaneInstance) {
+ if (swimlaneInstances == null) swimlaneInstances = new HashMap();
swimlaneInstances.put(swimlaneInstance.getName(), swimlaneInstance);
swimlaneInstance.setTaskMgmtInstance(this);
}
- public SwimlaneInstance getSwimlaneInstance(String swimlaneName)
- {
- return swimlaneInstances != null ? swimlaneInstances.get(swimlaneName) : null;
+ public SwimlaneInstance getSwimlaneInstance(String swimlaneName) {
+ return swimlaneInstances != null ? (SwimlaneInstance) swimlaneInstances.get(swimlaneName)
+ : null;
}
- public SwimlaneInstance createSwimlaneInstance(String swimlaneName)
- {
- Swimlane swimlane = (taskMgmtDefinition != null ? taskMgmtDefinition.getSwimlane(swimlaneName) : null);
- if (swimlane != null)
- {
+ public SwimlaneInstance createSwimlaneInstance(String swimlaneName) {
+ Swimlane swimlane = (taskMgmtDefinition != null ? taskMgmtDefinition.getSwimlane(swimlaneName)
+ : null);
+ if (swimlane != null) {
return createSwimlaneInstance(swimlane);
}
- throw new JbpmException("couldn't create swimlane instance for non-existing swimlane " + swimlaneName);
+ throw new JbpmException("couldn't create swimlane instance for non-existing swimlane "
+ + swimlaneName);
}
- public SwimlaneInstance createSwimlaneInstance(Swimlane swimlane)
- {
- if (swimlaneInstances == null)
- swimlaneInstances = new HashMap<String, SwimlaneInstance>();
- SwimlaneInstance swimlaneInstance = new SwimlaneInstance(swimlane);
- try
- {
- swimlaneInstance.setTaskMgmtInstance(this);
- Class<?> persistentMapClass = swimlaneInstances.getClass();
- Field mapField = persistentMapClass.getDeclaredField("map");
- mapField.setAccessible(true);
- // TODO remove the size when we switch to hibernate 3.2.1 (it's a workaround for a bug)
- swimlaneInstances.size();
- swimlaneInstances.put(swimlaneInstance.getName(), swimlaneInstance);
+ public SwimlaneInstance createSwimlaneInstance(Swimlane swimlane) {
+ if (swimlaneInstances == null) {
+ swimlaneInstances = new HashMap();
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ SwimlaneInstance swimlaneInstance = new SwimlaneInstance(swimlane);
+ swimlaneInstance.setTaskMgmtInstance(this);
+ swimlaneInstances.put(swimlaneInstance.getName(), swimlaneInstance);
return swimlaneInstance;
}
// getters and setters //////////////////////////////////////////////////////
- public TaskMgmtDefinition getTaskMgmtDefinition()
- {
+ public TaskMgmtDefinition getTaskMgmtDefinition() {
return taskMgmtDefinition;
}
/**
* suspends all task instances for this process instance.
*/
- public void suspend(Token token)
- {
- if (token == null)
- {
+ public void suspend(Token token) {
+ if (token == null) {
throw new JbpmException("can't suspend task instances for token null");
}
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance taskInstance = iter.next();
- if ((token.equals(taskInstance.getToken())) && (taskInstance.isOpen()))
- {
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if ((token.equals(taskInstance.getToken())) && (taskInstance.isOpen())) {
taskInstance.suspend();
}
}
@@ -603,31 +514,23 @@
/**
* resumes all task instances for this process instance.
*/
- public void resume(Token token)
- {
- if (token == null)
- {
+ public void resume(Token token) {
+ if (token == null) {
throw new JbpmException("can't suspend task instances for token null");
}
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance taskInstance = iter.next();
- if ((token.equals(taskInstance.getToken())) && (taskInstance.isOpen()))
- {
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if ((token.equals(taskInstance.getToken())) && (taskInstance.isOpen())) {
taskInstance.resume();
}
}
}
}
- void notifyVariableUpdate(TaskInstance taskInstance)
- {
- if (taskInstanceVariableUpdates == null)
- {
- taskInstanceVariableUpdates = new HashSet<TaskInstance>();
+ void notifyVariableUpdate(TaskInstance taskInstance) {
+ if (taskInstanceVariableUpdates == null) {
+ taskInstanceVariableUpdates = new HashSet();
}
taskInstanceVariableUpdates.add(taskInstance);
}
@@ -635,24 +538,18 @@
/**
* returns the collection of task instance with variable updates.
*/
- public Collection<TaskInstance> getTaskInstancesWithVariableUpdates()
- {
+ public Collection getTaskInstancesWithVariableUpdates() {
return taskInstanceVariableUpdates;
}
/**
* convenience method to end all tasks related to a given process instance.
*/
- public void endAll()
- {
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance taskInstance = iter.next();
- if (!taskInstance.hasEnded())
- {
+ public void endAll() {
+ if (taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if (!taskInstance.hasEnded()) {
taskInstance.end();
}
}
@@ -662,16 +559,11 @@
/**
* removes signalling capabilities from all task instances related to the given token.
*/
- public void removeSignalling(Token token)
- {
- if (taskInstances != null)
- {
- Iterator<TaskInstance> iter = taskInstances.iterator();
- while (iter.hasNext())
- {
- TaskInstance taskInstance = iter.next();
- if ((token != null) && (token.equals(taskInstance.getToken())))
- {
+ public void removeSignalling(Token token) {
+ if (token != null && taskInstances != null) {
+ for (Iterator i = taskInstances.iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
+ if (token.equals(taskInstance.getToken())) {
taskInstance.setSignalling(false);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,32 +21,76 @@
*/
package org.jbpm.util;
+/**
+ * Various methods for manipulating arrays.
+ */
public class ArrayUtil {
private ArrayUtil() {
// hide default constructor to prevent instantiation
}
- public static String toString(Object[] array) {
- if (array==null) {
- return "null";
- } else {
- StringBuffer buffer = new StringBuffer();
- buffer.append("<[");
- for (int i=0; i<array.length; i++) {
- Object o = array[i];
- if (o!=null) {
- buffer.append(o);
- } else {
- buffer.append("null");
- }
- if (i!=array.length-1) {
- buffer.append("|");
- }
- }
- buffer.append("]>");
- return buffer.toString();
+ /**
+ * Returns a string representation of the contents of the specified array. If the array contains
+ * other arrays as elements, they are converted to strings by the {@link Object#toString} method
+ * inherited from <tt>Object</tt>, which describes their <i>identities</i> rather than their
+ * contents.
+ * <p>
+ * The value returned by this method is equal to the value that would be returned by
+ * <tt>Arrays.asList(a).toString()</tt>, unless <tt>a</tt> is <tt>null</tt>, in which case
+ * <tt>"null"</tt> is returned.
+ *
+ * @param a the array whose string representation to return
+ * @return a string representation of <tt>a</tt>
+ * @see <a
+ * href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#toString(Object[])">
+ * java.util.Arrays.toString(Object[])</a>
+ */
+ public static String toString(Object[] a) {
+ if (a == null) return "null";
+ if (a.length == 0) return "[]";
+
+ StringBuffer buf = new StringBuffer();
+
+ for (int i = 0; i < a.length; i++) {
+ if (i == 0)
+ buf.append('[');
+ else
+ buf.append(", ");
+
+ buf.append(String.valueOf(a[i]));
}
+
+ buf.append("]");
+ return buf.toString();
}
+ /**
+ * Returns a string representation of the contents of the specified array. The string
+ * representation consists of a list of the array's elements, enclosed in square brackets (
+ * <tt>"[]"</tt>). Adjacent elements are separated by the characters <tt>", "</tt> (a comma
+ * followed by a space). Elements are converted to strings as by <tt>String.valueOf(long)</tt>.
+ * Returns <tt>"null"</tt> if <tt>a</tt> is <tt>null</tt>.
+ *
+ * @param a the array whose string representation to return
+ * @return a string representation of <tt>a</tt>
+ * @see <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#toString(long[])">
+ * java.util.Arrays.toString(long[])</a>
+ */
+ public static String toString(long[] a) {
+ if (a == null) return "null";
+ if (a.length == 0) return "[]";
+
+ StringBuffer buf = new StringBuffer();
+ buf.append('[');
+ buf.append(a[0]);
+
+ for (int i = 1; i < a.length; i++) {
+ buf.append(", ");
+ buf.append(a[i]);
+ }
+
+ buf.append("]");
+ return buf.toString();
+ }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -27,9 +27,6 @@
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.instantiation.ProcessClassLoader;
-import org.jbpm.instantiation.ProcessClassLoaderFactory;
/**
* provides centralized classloader lookup.
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassUtil.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassUtil.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,88 @@
+/*
+ * 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.util;
+
+/**
+ * Helper methods for dealing with classes.
+ *
+ * @author Alejandro Guizar
+ */
+public class ClassUtil {
+
+ private ClassUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
+ /**
+ * Returns the simple name of the given class as specified in the source code. Returns an empty
+ * string if the underlying class is anonymous.
+ * <p>
+ * The simple name of an array is the simple name of the component type with "[]" appended. In
+ * particular the simple name of an array whose component type is anonymous is "[]".
+ *
+ * @return the simple name of the underlying class
+ * @see <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getSimpleName()">
+ * java.lang.Class.getSimpleName()</a>
+ */
+ public static String getSimpleName(Class clazz) {
+ if (clazz.isArray()) return getSimpleName(clazz.getComponentType()) + "[]";
+
+ String simpleName = getSimpleBinaryName(clazz);
+ if (simpleName == null) { // top level class
+ simpleName = clazz.getName();
+ return simpleName.substring(simpleName.lastIndexOf(".") + 1); // strip the package name
+ }
+
+ // Remove leading "\$[0-9]*" from the name
+ int length = simpleName.length();
+ if (length < 1 || simpleName.charAt(0) != '$') throw new InternalError("Malformed class name");
+ int index = 1;
+ while (index < length && isAsciiDigit(simpleName.charAt(index)))
+ index++;
+ // Eventually, this is the empty string iff this is an anonymous class
+ return simpleName.substring(index);
+ }
+
+ /**
+ * Returns the "simple binary name" of the given class, i.e., the binary name without the leading
+ * enclosing class name. Returns <tt>null</tt> if the underlying class is a top level class.
+ */
+ private static String getSimpleBinaryName(Class clazz) {
+ Class enclosingClass = clazz.getDeclaringClass();
+ if (enclosingClass == null) // top level class
+ return null;
+ // Otherwise, strip the enclosing class' name
+ try {
+ return clazz.getName().substring(enclosingClass.getName().length());
+ }
+ catch (IndexOutOfBoundsException ex) {
+ throw new InternalError("Malformed class name");
+ }
+ }
+
+ /**
+ * Character.isDigit answers <tt>true</tt> to some non-ascii digits. This one does not.
+ */
+ private static boolean isAsciiDigit(char c) {
+ return '0' <= c && c <= '9';
+ }
+}
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/CollectionUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/CollectionUtil.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/CollectionUtil.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,105 +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.util;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Alejandro Guizar
- */
-public class CollectionUtil {
-
- /** Indicates whether collection elements should be actually checked. */
- private static final boolean DEBUG = true;
-
- private CollectionUtil() {
- // hide default constructor to prevent instantiation
- }
-
- /**
- * Ensures that all elements of the given collection can be cast to a desired type.
- *
- * @param collection the collection to check
- * @param type the desired type
- * @return a collection of the desired type
- * @throws ClassCastException if an element cannot be cast to the desired type
- */
- @SuppressWarnings("unchecked")
- public static <E> Collection<E> checkCollection(Collection<?> collection, Class<E> type) {
- if (DEBUG) {
- for (Object element : collection) {
- type.cast(element);
- }
- }
- return (Collection<E>) collection;
- }
-
- /**
- * Ensures that all elements of the given list can be cast to a desired type.
- *
- * @param list the list to check
- * @param type the desired type
- * @return a list of the desired type
- * @throws ClassCastException if an element cannot be cast to the desired type
- */
- @SuppressWarnings("unchecked")
- public static <E> List<E> checkList(List<?> list, Class<E> type) {
- if (DEBUG) {
- for (Object element : list) {
- type.cast(element);
- }
- }
- return (List<E>) list;
- }
-
- /**
- * Ensures that all elements of the given set can be cast to a desired type.
- *
- * @param list the set to check
- * @param type the desired type
- * @return a set of the desired type
- * @throws ClassCastException if an element cannot be cast to the desired type
- */
- @SuppressWarnings("unchecked")
- public static <E> Set<E> checkSet(Set<?> set, Class<E> type) {
- if (DEBUG) {
- for (Object element : set) {
- type.cast(element);
- }
- }
- return (Set<E>) set;
- }
-
- @SuppressWarnings("unchecked")
- public static <K, V> Map<K, V> checkMap(Map<?, ?> map, Class<K> keyType, Class<V> valueType) {
- if (DEBUG) {
- for (Map.Entry<?, ?> entry : map.entrySet()) {
- keyType.cast(entry.getKey());
- valueType.cast(entry.getValue());
- }
- }
- return (Map<K, V>) map;
- }
-}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/Semaphore.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/Semaphore.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/Semaphore.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,59 @@
+package org.jbpm.util;
+
+import java.io.Serializable;
+
+/**
+ * Trivial semaphore which borrows the interface of java.util.concurrent.Semaphore.
+ */
+public class Semaphore implements Serializable {
+
+ private int permits;
+
+ private static final long serialVersionUID = 1L;
+
+ public Semaphore(int permits) {
+ this.permits = permits;
+ }
+
+ public void release() {
+ release(1);
+ }
+
+ public synchronized void release(int permits) {
+ this.permits += permits;
+ notifyAll();
+ }
+
+ public void acquire() throws InterruptedException {
+ acquire(1);
+ }
+
+ public synchronized void acquire(int permits) throws InterruptedException {
+ while (this.permits < permits) {
+ wait();
+ }
+ this.permits -= permits;
+ }
+
+ public boolean tryAcquire(long timeout) throws InterruptedException {
+ return tryAcquire(1, timeout);
+ }
+
+ public synchronized boolean tryAcquire(int permits, long timeout) throws InterruptedException {
+ long startTime = System.currentTimeMillis();
+ while (this.permits < permits && System.currentTimeMillis() - startTime < timeout) {
+ wait(timeout);
+ }
+ if (this.permits >= permits) {
+ this.permits -= permits;
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized int drainPermits() {
+ int permits = this.permits;
+ this.permits = 0;
+ return permits;
+ }
+}
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/StaticUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/StaticUtil.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/StaticUtil.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,96 +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.util;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class StaticUtil {
-
- /*
- public class MyClass ... {
- static AType aStaticInMyClass = null;
- static AnotherType anotherStaticInMyClass = null;
-
- static {
- new StaticUtil.Initializer(MyClass.class) {
- public void init() {
- // initialize static members here
- aStaticInMyClass = ...;
- anotherStaticInMyClass = ...;
- }
- };
- }
- ...
- }
- */
-
- static Map initializers = Collections.synchronizedMap(new HashMap());
-
- public abstract static class Initializer {
- public Initializer(Class clazz) {
- add(clazz, this);
- init();
- }
- public abstract void init();
- }
-
- /*
- public class MyClass ... {
- static AType aStaticInMyClass = null;
- static AnotherType anotherStaticInMyClass = null;
-
- static {
- new StaticUtil.Initializer(MyClass.class) {
- public void init() {
- // initialize static members here
- aStaticInMyClass = ...;
- anotherStaticInMyClass = ...;
- }
- };
- }
- ...
- }
- */
-
- private StaticUtil() {
- // hide default constructor to prevent instantiation
- }
-
- public static void add(Class clazz, Initializer initializer) {
- initializers.put(clazz, initializer);
- }
-
- public static void remove(Class clazz) {
- initializers.remove(clazz);
- }
-
- public static void reinitialize() {
- Iterator iter = initializers.values().iterator();
- while (iter.hasNext()) {
- Initializer initializer = (Initializer) iter.next();
- initializer.init();
- }
- }
-}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,111 +30,84 @@
public class SerializabilityTest extends AbstractJbpmTestCase {
- String testRootDir = FileDefinitionFileSystemConfigTest.class.getProtectionDomain().getCodeSource().getLocation().getFile().toString();
-
- static final String[] excusedClasses = {
- "org.jbpm.ant",
- "org.jbpm.context.exe.JbpmType",
- "org.jbpm.db.hibernate.ConverterEnumType",
- "org.jbpm.db.hibernate.Converters",
- "org.jbpm.db.hibernate.JbpmNamingStrategy",
- "org.jbpm.db.AbstractDbTestCase",
- "org.jbpm.db.ContextSession",
- "org.jbpm.db.FileSession",
- "org.jbpm.db.GraphSession",
- "org.jbpm.db.JbpmSession",
- "org.jbpm.db.JbpmSchema",
- "org.jbpm.db.JobSession",
- "org.jbpm.db.LoggingSession",
- "org.jbpm.db.SchedulerSession",
- "org.jbpm.db.TaskMgmtSession",
- "org.jbpm.db.compatibility.JbpmSchemaUpdate",
- "org.jbpm.graph.exe.ExecutionContext",
+ String testRootDir = FileDefinitionFileSystemConfigTest.class.getProtectionDomain()
+ .getCodeSource()
+ .getLocation()
+ .getFile()
+ .toString();
+
+ static final String[] excusedClasses = { "org.jbpm.ant", "org.jbpm.context.exe.JbpmType",
+ "org.jbpm.db.hibernate.ConverterEnumType", "org.jbpm.db.hibernate.Converters",
+ "org.jbpm.db.hibernate.JbpmNamingStrategy", "org.jbpm.db.AbstractDbTestCase",
+ "org.jbpm.db.ContextSession", "org.jbpm.db.FileSession", "org.jbpm.db.GraphSession",
+ "org.jbpm.db.JbpmSession", "org.jbpm.db.JbpmSchema", "org.jbpm.db.JobSession",
+ "org.jbpm.db.LoggingSession", "org.jbpm.db.SchedulerSession", "org.jbpm.db.TaskMgmtSession",
+ "org.jbpm.db.compatibility.JbpmSchemaUpdate", "org.jbpm.graph.exe.ExecutionContext",
"org.jbpm.instantiation.BeanInstantiator",
"org.jbpm.instantiation.ConfigurationPropertyInstantiator",
"org.jbpm.instantiation.ConstructorInstantiator",
- "org.jbpm.instantiation.DefaultInstantiator",
- "org.jbpm.instantiation.FieldInstantiator",
- "org.jbpm.instantiation.ProcessClassLoader",
- "org.jbpm.instantiation.XmlInstantiator",
- "org.jbpm.JbpmConfiguration",
- "org.jbpm.job.executor.JobExecutorThread",
- "org.jbpm.job.executor.LockMonitorThread",
- "org.jbpm.jpdl.convert.Converter",
- "org.jbpm.graph.action.ActionTypes",
- "org.jbpm.graph.node.Fork$ForkedToken",
- "org.jbpm.graph.node.InterleaveStart$DefaultInterleaver",
- "org.jbpm.graph.node.NodeTypes",
- "org.jbpm.graph.node.ProcessFactory",
- "org.jbpm.jpdl.par.FileArchiveParser",
- "org.jbpm.jpdl.par.JpdlArchiveParser",
- "org.jbpm.jpdl.par.ProcessArchive",
- "org.jbpm.jpdl.par.ProcessArchiveDeployer",
- "org.jbpm.jpdl.par.ProcessArchiveDeployerTask",
- "org.jbpm.jpdl.xml.JpdlXmlReader",
- "org.jbpm.jpdl.xml.JpdlXmlWriter",
- "org.jbpm.jpdl.el",
+ "org.jbpm.instantiation.DefaultInstantiator", "org.jbpm.instantiation.FieldInstantiator",
+ "org.jbpm.instantiation.ProcessClassLoader", "org.jbpm.instantiation.XmlInstantiator",
+ "org.jbpm.JbpmConfiguration", "org.jbpm.job.executor.JobExecutorThread",
+ "org.jbpm.job.executor.LockMonitorThread", "org.jbpm.jpdl.convert.Converter",
+ "org.jbpm.graph.action.ActionTypes", "org.jbpm.graph.node.Fork$ForkedToken",
+ "org.jbpm.graph.node.InterleaveStart$DefaultInterleaver", "org.jbpm.graph.node.NodeTypes",
+ "org.jbpm.graph.node.ProcessFactory", "org.jbpm.jpdl.par.FileArchiveParser",
+ "org.jbpm.jpdl.par.JpdlArchiveParser", "org.jbpm.jpdl.par.ProcessArchive",
+ "org.jbpm.jpdl.par.ProcessArchiveDeployer", "org.jbpm.jpdl.par.ProcessArchiveDeployerTask",
+ "org.jbpm.jpdl.xml.JpdlXmlReader", "org.jbpm.jpdl.xml.JpdlXmlWriter", "org.jbpm.jpdl.el",
"org.jbpm.security.authenticator.JBossAuthenticator",
"org.jbpm.security.authenticator.JbpmDefaultAuthenticator",
- "org.jbpm.security.authenticator.SubjectAuthenticator",
- "org.jbpm.security.Authorization",
+ "org.jbpm.security.authenticator.SubjectAuthenticator", "org.jbpm.security.Authorization",
"org.jbpm.security.authorizer.AccessControllerAuthorizer",
"org.jbpm.security.authorizer.JbpmIdentityAuthorizer",
"org.jbpm.security.authorizer.RolesAuthorizer",
"org.jbpm.security.filter.JbpmAuthenticationFilter",
- "org.jbpm.command.service.CommandServiceImpl",
- "org.jbpm.sim.",
- "org.jbpm.util.Clock",
- "org.jbpm.util.CustomLoaderObjectInputStream",
- "org.jbpm.web.JobExecutorLauncher",
- "org.jbpm.web.JbpmConfigurationCloser",
- "org.jbpm.JbpmContextTestHelper",
- "org.jbpm.EventCallback$1"
- };
+ "org.jbpm.command.service.CommandServiceImpl", "org.jbpm.sim.", "org.jbpm.util.Clock",
+ "org.jbpm.util.CustomLoaderObjectInputStream", "org.jbpm.web.JobExecutorLauncher",
+ "org.jbpm.web.JbpmConfigurationCloser", "org.jbpm.JbpmContextTestHelper",
+ "org.jbpm.EventCallback$1" };
public void testForNonSerializableClasses() {
- File jbpmRoot = new File(testRootDir+"../classes/");
+ File jbpmRoot = new File(testRootDir + "../classes/");
scanForClasses(jbpmRoot, "");
}
-
+
private void scanForClasses(File rootClassDir, String packageDir) {
- File packageDirFile = new File(rootClassDir.getPath()+"/"+packageDir);
+ File packageDirFile = new File(rootClassDir.getPath() + "/" + packageDir);
File[] files = packageDirFile.listFiles();
- for (int i=0; i<files.length; i++) {
+ for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
- String newPackageDir = ( "".equals(packageDir) ? files[i].getName() : packageDir+"/"+files[i].getName() );
+ String newPackageDir = ("".equals(packageDir) ? files[i].getName() : packageDir
+ + "/"
+ + files[i].getName());
// log.debug("descending into directory "+newPackageDir);
scanForClasses(rootClassDir, newPackageDir);
-
- } else if ( (files[i].isFile())
- && (files[i].getName().endsWith(".class"))
- ) {
+
+ }
+ else if ((files[i].isFile()) && (files[i].getName().endsWith(".class"))) {
// log.debug("found class file "+files[i].getName());
- String classFilePath = packageDir+"/"+files[i].getName();
+ String classFilePath = packageDir + "/" + files[i].getName();
String className = classFilePath.replace('/', '.');
- className = className.substring(0, className.length()-6);
+ className = className.substring(0, className.length() - 6);
assertSerializabilityOfClass(className);
}
}
}
private void assertSerializabilityOfClass(String className) {
- Class<?> clazz = ClassLoaderUtil.loadClass(className);
-
- if ( ! ( Serializable.class.isAssignableFrom(clazz)
- || Modifier.isAbstract(clazz.getModifiers())
- || isExcused(className)
- || clazz.getConstructors().length == 0
- )
- ) {
- fail(className+" is NOT Serializable");
+ Class clazz = ClassLoaderUtil.loadClass(className);
+
+ if (!(Serializable.class.isAssignableFrom(clazz)
+ || Modifier.isAbstract(clazz.getModifiers())
+ || isExcused(className) || clazz.getConstructors().length == 0)) {
+ fail(className + " is NOT Serializable");
}
}
boolean isExcused(String className) {
- for (String excusedClassName : excusedClasses) {
- if (className.startsWith(excusedClassName))
- return true;
+ for (int i = 0; i < excusedClasses.length; i++) {
+ if (className.startsWith(excusedClasses[i])) return true;
}
return false;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -17,25 +17,22 @@
*
* @author bernd.ruecker at camunda.com
*/
-public class ChangeProcessInstanceVersionCommandTest extends AbstractDbTestCase
-{
-
+public class ChangeProcessInstanceVersionCommandTest extends AbstractDbTestCase {
+
private ProcessDefinition pd1;
private ProcessDefinition pd2;
-
- @Override
- protected void tearDown() throws Exception
- {
- if (pd1!=null && pd2!=null) {
+
+ protected void tearDown() throws Exception {
+ if (pd1 != null && pd2 != null) {
newTransaction();
// IMPORTANT: The ProcessDefinitions have to be deleted in one transaction,
// in the right order (new definition with ProcessInstance first) or the
// ProcessInstance has to be deleted first independently.
-
+
// This is because Logs of the ProcessInstance point to both ProcessDefinitions
// (the old and the new one) but only with the new ProcessDefinition the
// ProcessInstance is deleted
-
+
// exceptions look like this: could not delete: [org.jbpm.graph.def.Transition#9]
// Integrity constraint violation FK_LOG_TRANSITION table: JBPM_LOG in statement [/* delete org.jbpm.graph.def.Transition */ delete from JBPM_TRANSITION where ID_=?]
// or hibernate batch failed
@@ -49,26 +46,26 @@
// Integrity constraint violation FK_TASKMGTINST_TMD table: JBPM_MODULEINSTANCE in statement [/* delete org.jbpm.taskmgmt.def.TaskMgmtDefinition */ delete from JBPM_MODULEDEFINITION where ID_=?]
jbpmContext.getGraphSession().deleteProcessDefinition(pd2.getId());
jbpmContext.getGraphSession().deleteProcessDefinition(pd1.getId());
- } else if (pd1!=null) {
+ }
+ else if (pd1 != null) {
newTransaction();
jbpmContext.getGraphSession().deleteProcessDefinition(pd1.getId());
- } else if (pd2!=null) {
+ }
+ else if (pd2 != null) {
newTransaction();
- jbpmContext.getGraphSession().deleteProcessDefinition(pd2.getId());
+ jbpmContext.getGraphSession().deleteProcessDefinition(pd2.getId());
}
-
- pd1=null;
- pd2=null;
+
+ pd1 = null;
+ pd2 = null;
super.tearDown();
}
/**
- * test easy version migration (no fork or other stuff)
- * but with name mapping (different state name in new process
- * definition)
+ * test easy version migration (no fork or other stuff) but with name mapping (different state
+ * name in new process definition)
*/
- public void testNameMapping() throws Exception
- {
+ public void testNameMapping() throws Exception {
String xmlVersion1 = //
"<process-definition name='TestChangeVersion'>" //
+ " <start-state name='start'>" //
@@ -114,20 +111,20 @@
pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
// now change all process instances to most current version
- try
- {
- new ChangeProcessInstanceVersionCommand().processName("TestChangeVersion").execute(jbpmContext);
+ try {
+ new ChangeProcessInstanceVersionCommand().processName("TestChangeVersion").execute(
+ jbpmContext);
fail("Exception expected, saying that state2 is missing in new version");
}
- catch (JbpmException ex)
- {
+ catch (JbpmException ex) {
assertEquals("node with name 'state2' not found in new process definition", ex.getMessage());
}
HashMap nameMap = new HashMap();
nameMap.put("state2", "state2b");
// now supply a mapping for the missing node
- new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processName("TestChangeVersion").execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processName(
+ "TestChangeVersion").execute(jbpmContext);
newTransaction();
pi1 = graphSession.loadProcessInstance(pi1.getId());
@@ -149,15 +146,14 @@
assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
assertTrue(pi1.hasEnded());
assertEquals(pd2.getNode("end").getId(), pi2.getRootToken().getNode().getId());
- assertTrue(pi2.hasEnded());
+ assertTrue(pi2.hasEnded());
}
/**
- * check that update of nodes work correctly if a fork was involved
- * and multiple child tokens exist
+ * check that update of nodes work correctly if a fork was involved and multiple child tokens
+ * exist
*/
- public void testSubTokensInFork() throws Exception
- {
+ public void testSubTokensInFork() throws Exception {
String xmlVersion1 = //
"<process-definition name='TestChangeVersion'>" //
+ " <start-state name='start'>" //
@@ -213,20 +209,19 @@
pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
// now change all process instances to most current version
- try
- {
+ try {
new ChangeProcessInstanceVersionCommand().processInstanceId(pi1.getId()).execute(jbpmContext);
fail("Exception expected, saying that phase2 is missing in new version");
}
- catch (JbpmException ex)
- {
+ catch (JbpmException ex) {
assertEquals("node with name 'path2' not found in new process definition", ex.getMessage());
}
HashMap nameMap = new HashMap();
nameMap.put("path2", "path2b");
// now supply a mapping for the missing node
- new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processInstanceId(pi1.getId()).execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processInstanceId(
+ pi1.getId()).execute(jbpmContext);
newTransaction();
@@ -244,43 +239,42 @@
assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
assertTrue(pi1.hasEnded());
}
-
- public void testTaskInFork() throws Exception
- {
+
+ public void testTaskInFork() throws Exception {
String xmlVersion1 = //
- "<process-definition name='TestChangeVersion'>" //
- + " <start-state name='start'>" //
- + " <transition to='fork' />" //
- + " </start-state>" //
- + " <fork name='fork'>" //
- + " <transition name='path1' to='task1' />" //
- + " <transition name='path2' to='task2' />" //
- + " </fork>" //
- + " <task-node name='task1'>" //
- + " <task name='theTask1' />" //
- + " <transition to='join' />" //
- + " </task-node>" //
- + " <task-node name='task2'>" //
- + " <task name='theTask2' />" //
- + " <transition to='join' />" //
- + " </task-node>" //
- + " <join name='join'>" //
- + " <transition to='end' />" //
- + " </join>" //
- + " <end-state name='end' />" //
- + "</process-definition>";
+ "<process-definition name='TestChangeVersion'>" //
+ + " <start-state name='start'>" //
+ + " <transition to='fork' />" //
+ + " </start-state>" //
+ + " <fork name='fork'>" //
+ + " <transition name='path1' to='task1' />" //
+ + " <transition name='path2' to='task2' />" //
+ + " </fork>" //
+ + " <task-node name='task1'>" //
+ + " <task name='theTask1' />" //
+ + " <transition to='join' />" //
+ + " </task-node>" //
+ + " <task-node name='task2'>" //
+ + " <task name='theTask2' />" //
+ + " <transition to='join' />" //
+ + " </task-node>" //
+ + " <join name='join'>" //
+ + " <transition to='end' />" //
+ + " </join>" //
+ + " <end-state name='end' />" //
+ + "</process-definition>";
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion1));
- pd1 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion1));
+ pd1 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
- // start instance
- ProcessInstance pi1 = jbpmContext.newProcessInstance("TestChangeVersion");
- pi1.signal();
- Token t1 = pi1.getRootToken().getChild("path1");
- Token t2 = pi1.getRootToken().getChild("path2");
+ // start instance
+ ProcessInstance pi1 = jbpmContext.newProcessInstance("TestChangeVersion");
+ pi1.signal();
+ Token t1 = pi1.getRootToken().getChild("path1");
+ Token t2 = pi1.getRootToken().getChild("path2");
- String xmlVersion2 = //
- "<process-definition name='TestChangeVersion'>" //
+ String xmlVersion2 = //
+ "<process-definition name='TestChangeVersion'>" //
+ " <start-state name='start'>" //
+ " <transition to='fork' />" //
+ " </start-state>" //
@@ -302,75 +296,72 @@
+ " <end-state name='end' />" //
+ "</process-definition>";
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion2));
- pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion2));
+ pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
- HashMap<String, String> nodeNameMap = new HashMap<String, String>();
- nodeNameMap.put("task1", "task1b");
- nodeNameMap.put("task2", "task2b");
- HashMap<String, String> taskNameMap = new HashMap<String, String>();
- taskNameMap.put("theTask1", "theTask1b");
- taskNameMap.put("theTask2", "theTask2b");
+ HashMap nodeNameMap = new HashMap();
+ nodeNameMap.put("task1", "task1b");
+ nodeNameMap.put("task2", "task2b");
+ HashMap taskNameMap = new HashMap();
+ taskNameMap.put("theTask1", "theTask1b");
+ taskNameMap.put("theTask2", "theTask2b");
- // now supply a mapping for the missing node
- new ChangeProcessInstanceVersionCommand()
- .nodeNameMapping(nodeNameMap)
- .taskNameMapping(taskNameMap)
- .processInstanceId(pi1.getId())
- .execute(jbpmContext);
+ // now supply a mapping for the missing node
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nodeNameMap).taskNameMapping(
+ taskNameMap).processInstanceId(pi1.getId()).execute(jbpmContext);
- newTransaction();
+ newTransaction();
- t1 = jbpmContext.loadTokenForUpdate(t1.getId());
- assertEquals(pd2.getNode("task1b").getId(), t1.getNode().getId());
-
- Iterator<TaskInstance> taskInstanceIter = t1.getProcessInstance().getTaskMgmtInstance().getTaskInstances().iterator();
- TaskInstance ti1 = taskInstanceIter.next();
- if ("theTask2b".equals(ti1.getTask().getName())) {
- // this was the wrong one
- ti1 = taskInstanceIter.next();
- }
- assertEquals("theTask1b", ti1.getTask().getName());
- assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask1b").getId(), ti1.getTask().getId());
+ t1 = jbpmContext.loadTokenForUpdate(t1.getId());
+ assertEquals(pd2.getNode("task1b").getId(), t1.getNode().getId());
- ti1.end();
-
- ///////
- newTransaction();
-
- t2 = graphSession.getToken(t2.getId());
- assertEquals(pd2.getNode("task2b").getId(), t2.getNode().getId());
+ Iterator taskInstanceIter = t1.getProcessInstance()
+ .getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator();
+ TaskInstance ti1 = (TaskInstance) taskInstanceIter.next();
+ if ("theTask2b".equals(ti1.getTask().getName())) {
+ // this was the wrong one
+ ti1 = (TaskInstance) taskInstanceIter.next();
+ }
+ assertEquals("theTask1b", ti1.getTask().getName());
+ assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask1b").getId(), ti1.getTask().getId());
- taskInstanceIter = t2.getProcessInstance().getTaskMgmtInstance().getTaskInstances().iterator();
- TaskInstance ti2 = taskInstanceIter.next();
- if ("theTask1b".equals(ti2.getTask().getName())) {
- // this was the wrong one
- ti2 = taskInstanceIter.next();
- }
- assertEquals("theTask2b", ti2.getTask().getName());
- assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask2b").getId(), ti2.getTask().getId());
+ ti1.end();
- ti2.end();
-
- newTransaction();
- pi1 = graphSession.loadProcessInstance(pi1.getId());
+ ///////
+ newTransaction();
- assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
- assertTrue(pi1.hasEnded());
- closeJbpmContext();
+ t2 = graphSession.getToken(t2.getId());
+ assertEquals(pd2.getNode("task2b").getId(), t2.getNode().getId());
+
+ taskInstanceIter = t2.getProcessInstance().getTaskMgmtInstance().getTaskInstances().iterator();
+ TaskInstance ti2 = (TaskInstance) taskInstanceIter.next();
+ if ("theTask1b".equals(ti2.getTask().getName())) {
+ // this was the wrong one
+ ti2 = (TaskInstance) taskInstanceIter.next();
+ }
+ assertEquals("theTask2b", ti2.getTask().getName());
+ assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask2b").getId(), ti2.getTask().getId());
+
+ ti2.end();
+
+ newTransaction();
+ pi1 = graphSession.loadProcessInstance(pi1.getId());
+
+ assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
+ assertTrue(pi1.hasEnded());
+ closeJbpmContext();
}
- public void testSubProcesses()
- {
+ public void testSubProcesses() {
}
/**
- * check, that TaskInstances work (TaskInstance reference to Task has
- * to be adjusted as will)
+ * check, that TaskInstances work (TaskInstance reference to Task has to be adjusted as will)
*/
- public void testTaskInstances() throws Exception
- {
+ public void testTaskInstances() throws Exception {
String xmlVersion1 = //
"<process-definition name='testTaskInstances'>" //
+ " <start-state name='start'>" //
@@ -420,36 +411,31 @@
pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("testTaskInstances");
// process instance 1 can me updated, state names haven't changed in this path:
- new ChangeProcessInstanceVersionCommand()
- .processInstanceId(pi1.getId())
- .execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().processInstanceId(pi1.getId()).execute(jbpmContext);
HashMap nameMap = new HashMap();
nameMap.put("task2", "task2b");
// now change all process instances to most current version
- try
- {
- new ChangeProcessInstanceVersionCommand()
- .nodeNameMapping(nameMap)
- .taskNameMapping(nameMap)
- .processName("testTaskInstances")
- .execute(jbpmContext);
+ try {
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processName("testTaskInstances")
+ .execute(jbpmContext);
// fail because task2 is not mapped
fail("Exception expected, saying that theTask2b is missing in new version");
}
- catch (JbpmException ex)
- {
- assertEquals("Task 'theTask2' for node 'task2b' not found in new process definition", ex.getMessage());
+ catch (JbpmException ex) {
+ assertEquals("Task 'theTask2' for node 'task2b' not found in new process definition",
+ ex.getMessage());
}
// now supply a mapping for the missing task
nameMap.put("theTask2", "theTask2b");
- new ChangeProcessInstanceVersionCommand()
- .nodeNameMapping(nameMap)
- .taskNameMapping(nameMap)
- .processName("testTaskInstances")
- .execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processName("testTaskInstances")
+ .execute(jbpmContext);
newTransaction();
@@ -459,8 +445,14 @@
assertEquals(pd2.getNode("task1").getId(), pi1.getRootToken().getNode().getId());
assertEquals(pd2.getNode("task2b").getId(), pi2.getRootToken().getNode().getId());
- TaskInstance ti1 = pi1.getTaskMgmtInstance().getTaskInstances().iterator().next();
- TaskInstance ti2 = pi2.getTaskMgmtInstance().getTaskInstances().iterator().next();
+ TaskInstance ti1 = (TaskInstance) pi1.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
+ TaskInstance ti2 = (TaskInstance) pi2.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask1").getId(), ti1.getTask().getId());
assertEquals(pd2.getTaskMgmtDefinition().getTask("theTask2b").getId(), ti2.getTask().getId());
@@ -475,25 +467,22 @@
}
/**
- * test if changing process version works correctly
- * if a timer is included in the process definition.
- *
- * Important: The timer itself IS NOT changed, so
- * e.g. used leaving transitions must be still existent
+ * test if changing process version works correctly if a timer is included in the process
+ * definition. Important: The timer itself IS NOT changed, so e.g. used leaving transitions must
+ * be still existent
*/
- public void testTimerInState() throws Exception
- {
+ public void testTimerInState() throws Exception {
String xmlVersion1 = //
"<process-definition name='TestChangeVersion'>" //
- + " <start-state name='start'>" //
- + " <transition to='timer1' />"//
- + " </start-state>" //
- + " <state name='timer1'>" //
- + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
- + " <transition name='end' to='end' />" //
- + " </state>" //
- + " <end-state name='end'/>" //
- + "</process-definition>";
+ + " <start-state name='start'>" //
+ + " <transition to='timer1' />"//
+ + " </start-state>" //
+ + " <state name='timer1'>" //
+ + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
+ + " <transition name='end' to='end' />" //
+ + " </state>" //
+ + " <end-state name='end'/>" //
+ + "</process-definition>";
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion1));
pd1 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
@@ -510,15 +499,15 @@
String xmlVersion2 = //
"<process-definition name='TestChangeVersion'>" //
- + " <start-state name='start'>" //
- + " <transition to='timer2' />"//
- + " </start-state>" //
- + " <state name='timer2'>" //
- + " <timer name='timer1' duedate='5 seconds' transition='end1' />" //
- + " <transition name='end' to='end' />" //
- + " </state>" //
- + " <end-state name='end'/>" //
- + "</process-definition>";
+ + " <start-state name='start'>" //
+ + " <transition to='timer2' />"//
+ + " </start-state>" //
+ + " <state name='timer2'>" //
+ + " <timer name='timer1' duedate='5 seconds' transition='end1' />" //
+ + " <transition name='end' to='end' />" //
+ + " </state>" //
+ + " <end-state name='end'/>" //
+ + "</process-definition>";
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion2));
pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
@@ -526,16 +515,14 @@
// change version
HashMap nameMap = new HashMap();
nameMap.put("timer1", "timer2");
- new ChangeProcessInstanceVersionCommand()
- .nodeNameMapping(nameMap)
- .processInstanceId(pi1.getId())
- .execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processInstanceId(
+ pi1.getId()).execute(jbpmContext);
// load changed stuff
- newTransaction();
+ newTransaction();
pi1 = graphSession.loadProcessInstance(pi1.getId());
timer = (Timer) session.createQuery("from org.jbpm.job.Timer").uniqueResult();
-
+
// and check again
assertEquals(pd2.getNode("timer2").getId(), pi1.getRootToken().getNode().getId());
assertEquals("timer1", timer.getName());
@@ -546,22 +533,21 @@
assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
assertTrue(pi1.hasEnded());
}
-
- public void testTimerInTask() throws Exception
- {
+
+ public void testTimerInTask() throws Exception {
String xmlVersion1 = //
"<process-definition name='TestChangeVersion'>" //
- + " <start-state name='start'>" //
- + " <transition to='timer1' />"//
- + " </start-state>" //
- + " <task-node name='timer1'>" //
- + " <task name='myTask'>" //
- + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
- + " </task>" //
- + " <transition name='end' to='end' />" //
- + " </task-node>" //
- + " <end-state name='end'/>" //
- + "</process-definition>";
+ + " <start-state name='start'>" //
+ + " <transition to='timer1' />"//
+ + " </start-state>" //
+ + " <task-node name='timer1'>" //
+ + " <task name='myTask'>" //
+ + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
+ + " </task>" //
+ + " <transition name='end' to='end' />" //
+ + " </task-node>" //
+ + " <end-state name='end'/>" //
+ + "</process-definition>";
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion1));
pd1 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
@@ -569,30 +555,34 @@
// start instance
ProcessInstance pi1 = jbpmContext.newProcessInstance("TestChangeVersion");
pi1.signal();
-// jbpmContext.getJobSession().deleteJobsForProcessInstance(processInstance);
-// NOT UNIQUE?!
+ // jbpmContext.getJobSession().deleteJobsForProcessInstance(processInstance);
+ // NOT UNIQUE?!
Timer timer = (Timer) session.createQuery("from org.jbpm.job.Timer").uniqueResult();
// check timer
assertNotNull("Timer is null", timer);
assertEquals("timer1", timer.getName());
- assertEquals(pd1.getTaskMgmtDefinition().getTask("myTask").getId(), timer.getGraphElement().getId());
- TaskInstance ti1 = pi1.getTaskMgmtInstance().getTaskInstances().iterator().next();
+ assertEquals(pd1.getTaskMgmtDefinition().getTask("myTask").getId(), timer.getGraphElement()
+ .getId());
+ TaskInstance ti1 = (TaskInstance) pi1.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
assertEquals(pd1.getTaskMgmtDefinition().getTask("myTask").getId(), ti1.getTask().getId());
String xmlVersion2 = //
"<process-definition name='TestChangeVersion'>" //
- + " <start-state name='start'>" //
- + " <transition to='timer2' />"//
- + " </start-state>" //
- + " <task-node name='timer2'>" //
- + " <task name='myTask2'>" //
- + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
- + " </task>" //
- + " <transition name='end' to='end' />" //
- + " </task-node>" //
- + " <end-state name='end'/>" //
- + "</process-definition>";
+ + " <start-state name='start'>" //
+ + " <transition to='timer2' />"//
+ + " </start-state>" //
+ + " <task-node name='timer2'>" //
+ + " <task name='myTask2'>" //
+ + " <timer name='timer1' duedate='5 seconds' transition='end' />" //
+ + " </task>" //
+ + " <transition name='end' to='end' />" //
+ + " </task-node>" //
+ + " <end-state name='end'/>" //
+ + "</process-definition>";
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(xmlVersion2));
pd2 = jbpmContext.getGraphSession().findLatestProcessDefinition("TestChangeVersion");
@@ -601,22 +591,22 @@
HashMap nameMap = new HashMap();
nameMap.put("timer1", "timer2");
nameMap.put("myTask", "myTask2");
- new ChangeProcessInstanceVersionCommand()
- .nodeNameMapping(nameMap)
- .taskNameMapping(nameMap)
- .processInstanceId(pi1.getId())
- .execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processInstanceId(pi1.getId())
+ .execute(jbpmContext);
// load changed stuff
- newTransaction();
+ newTransaction();
pi1 = graphSession.loadProcessInstance(pi1.getId());
timer = (Timer) session.createQuery("from org.jbpm.job.Timer").uniqueResult();
-
+
// and check again
assertEquals(pd2.getNode("timer2").getId(), pi1.getRootToken().getNode().getId());
assertEquals("timer1", timer.getName());
- assertEquals(pd2.getTaskMgmtDefinition().getTask("myTask2").getId(), timer.getGraphElement().getId());
- ti1 = pi1.getTaskMgmtInstance().getTaskInstances().iterator().next();
+ assertEquals(pd2.getTaskMgmtDefinition().getTask("myTask2").getId(), timer.getGraphElement()
+ .getId());
+ ti1 = (TaskInstance) pi1.getTaskMgmtInstance().getTaskInstances().iterator().next();
assertEquals(pd2.getTaskMgmtDefinition().getTask("myTask2").getId(), ti1.getTask().getId());
// and go on
@@ -624,20 +614,18 @@
assertEquals(pd2.getNode("end").getId(), pi1.getRootToken().getNode().getId());
assertTrue(pi1.hasEnded());
- }
-
- public void testTimerInProcessDefinition() throws Exception
- {
+ }
+
+ public void testTimerInProcessDefinition() throws Exception {
// TODO
}
/**
- * Asynchronous continuation is not affected by changing the version,
- * because a {@link Job} only holds {@link ProcessInstance}.id, {@link Token}.id
- * or {@link TaskInstance}.id. None of them are changed while version changes.
+ * Asynchronous continuation is not affected by changing the version, because a {@link Job} only
+ * holds {@link ProcessInstance}.id, {@link Token}.id or {@link TaskInstance}.id. None of them are
+ * changed while version changes.
*/
- public void notestAsync()
- {
+ public void notestAsync() {
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -9,127 +9,118 @@
import org.jbpm.graph.exe.Token;
/**
- * Tests for {@link Command}s working on {@link ProcessInstance}
+ * Tests for {@link Command}s working on {@link ProcessInstance}
*
* @author bernd.ruecker at camunda.com
*/
-public class ProcessInstanceCommandTest extends AbstractDbTestCase
-{
+public class ProcessInstanceCommandTest extends AbstractDbTestCase {
+
private ProcessDefinition processDefinition;
-
- @Override
- protected void tearDown() throws Exception
- {
- if (processDefinition!=null) {
+
+ protected void tearDown() throws Exception {
+ if (processDefinition != null) {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
- processDefinition=null;
-
+ processDefinition = null;
+
super.tearDown();
}
-
- public void testEmpty() {}
public void testCancelProcessInstanceCommand() throws Exception {
- String xml = //
- "<?xml version='1.0' encoding='UTF-8'?>" //
- +"<process-definition name='TestException'>" //
- +" <start-state name='start'>" //
- +" <transition to='fork' />" //
- +" </start-state>" //
- +" <fork name='fork'>" //
- +" <transition name='path1' to='path1' />" //
- +" <transition name='path2' to='path2' />" //
- +" </fork>" //
- +" <state name='path1'>" //
- +" <transition to='join' />" //
- +" </state>" //
- +" <state name='path2'>" //
- +" <transition to='join' />" //
- +" </state>" //
- +" <join name='join'>" //
- +" <transition to='end' />" //
- +" </join>" //
- +" <end-state name='end' />" //
- +"</process-definition>";
-
- processDefinition = ProcessDefinition.parseXmlString(xml);
+ String xml = "<process-definition name='TestException'>"
+ + " <start-state name='start'>"
+ + " <transition to='fork' />"
+ + " </start-state>"
+ + " <fork name='fork'>"
+ + " <transition name='path1' to='path1' />"
+ + " <transition name='path2' to='path2' />"
+ + " </fork>"
+ + " <state name='path1'>"
+ + " <transition to='join' />"
+ + " </state>"
+ + " <state name='path2'>"
+ + " <transition to='join' />"
+ + " </state>"
+ + " <join name='join'>"
+ + " <transition to='end' />"
+ + " </join>"
+ + " <end-state name='end' />"
+ + "</process-definition>";
+
+ processDefinition = ProcessDefinition.parseXmlString(xml);
jbpmContext.deployProcessDefinition(processDefinition);
ProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.getRootToken().signal();
processInstance = saveAndReload(processInstance);
-
+
assertFalse(processInstance.getRootToken().hasEnded());
assertEquals("fork", processInstance.getRootToken().getNode().getName());
- for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();)
- {
- Token childToken = (Token)iterator.next();
+ for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();) {
+ Token childToken = (Token) iterator.next();
assertFalse(childToken.hasEnded());
}
// execute CancelProcessInstanceCommand
new CancelProcessInstanceCommand(processInstance.getId()).execute(jbpmContext);
-
+
// and verify it is canceled
assertTrue(processInstance.getRootToken().hasEnded());
assertEquals("fork", processInstance.getRootToken().getNode().getName());
- for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();)
- {
- Token childToken = (Token)iterator.next();
+ for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();) {
+ Token childToken = (Token) iterator.next();
assertTrue(childToken.hasEnded());
}
}
-
+
public void testSuspendResumeProcessInstanceCommand() throws Exception {
String xml = //
- "<?xml version='1.0' encoding='UTF-8'?>" //
- +"<process-definition name='TestException'>" //
- +" <start-state name='start'>" //
- +" <transition to='fork' />" //
- +" </start-state>" //
- +" <fork name='fork'>" //
- +" <transition name='path1' to='path1' />" //
- +" <transition name='path2' to='path2' />" //
- +" </fork>" //
- +" <state name='path1'>" //
- +" <transition to='join' />" //
- +" </state>" //
- +" <state name='path2'>" //
- +" <transition to='join' />" //
- +" </state>" //
- +" <join name='join'>" //
- +" <transition to='end' />" //
- +" </join>" //
- +" <end-state name='end' />" //
- +"</process-definition>";
-
- processDefinition = ProcessDefinition.parseXmlString(xml);
+ "<?xml version='1.0' encoding='UTF-8'?>" //
+ + "<process-definition name='TestException'>" //
+ + " <start-state name='start'>" //
+ + " <transition to='fork' />" //
+ + " </start-state>" //
+ + " <fork name='fork'>" //
+ + " <transition name='path1' to='path1' />" //
+ + " <transition name='path2' to='path2' />" //
+ + " </fork>" //
+ + " <state name='path1'>" //
+ + " <transition to='join' />" //
+ + " </state>" //
+ + " <state name='path2'>" //
+ + " <transition to='join' />" //
+ + " </state>" //
+ + " <join name='join'>" //
+ + " <transition to='end' />" //
+ + " </join>" //
+ + " <end-state name='end' />" //
+ + "</process-definition>";
+
+ processDefinition = ProcessDefinition.parseXmlString(xml);
jbpmContext.deployProcessDefinition(processDefinition);
ProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.getRootToken().signal();
processInstance = saveAndReload(processInstance);
-
+
assertFalse(processInstance.isSuspended());
assertFalse(processInstance.getRootToken().isSuspended());
assertEquals("fork", processInstance.getRootToken().getNode().getName());
- for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();)
- {
- Token childToken = (Token)iterator.next();
+ for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();) {
+ Token childToken = (Token) iterator.next();
assertFalse(childToken.isSuspended());
}
// execute SuspendProcessInstanceCommand
- new SuspendProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(jbpmContext);
-
+ new SuspendProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(
+ jbpmContext);
+
// and verify
assertTrue(processInstance.isSuspended());
assertTrue(processInstance.getRootToken().isSuspended());
assertEquals("fork", processInstance.getRootToken().getNode().getName());
- for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();)
- {
- Token childToken = (Token)iterator.next();
+ for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();) {
+ Token childToken = (Token) iterator.next();
assertTrue(childToken.isSuspended());
-
+
try {
childToken.signal();
fail("signal should not be accepted on suspended token");
@@ -137,32 +128,32 @@
catch (Exception ex) {
assertEquals(JbpmException.class, ex.getClass());
// can't signal token 'path1' (5): it is suspended
- assertTrue("exception should be, that token is suspended", ex.getMessage().indexOf("it is suspended")>0);
+ assertTrue("exception should be, that token is suspended", ex.getMessage().indexOf(
+ "it is suspended") > 0);
}
}
-
+
// execute ResumeProcessInstanceCommand
- new ResumeProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(jbpmContext);
+ new ResumeProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(
+ jbpmContext);
// and verify
assertFalse(processInstance.isSuspended());
assertFalse(processInstance.getRootToken().isSuspended());
- for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();)
- {
- Token childToken = (Token)iterator.next();
+ for (Iterator iterator = processInstance.getRootToken().getChildren().values().iterator(); iterator.hasNext();) {
+ Token childToken = (Token) iterator.next();
assertFalse(childToken.isSuspended());
childToken.signal();
}
-
+
assertEquals("end", processInstance.getRootToken().getNode().getName());
assertTrue(processInstance.hasEnded());
// check db state
- processInstance = saveAndReload(processInstance);
+ processInstance = saveAndReload(processInstance);
assertEquals("end", processInstance.getRootToken().getNode().getName());
assertTrue(processInstance.hasEnded());
- }
-
+ }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/TokenVariableMapDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/TokenVariableMapDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/TokenVariableMapDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -31,8 +31,7 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
-public class TokenVariableMapDbTest extends AbstractDbTestCase
-{
+public class TokenVariableMapDbTest extends AbstractDbTestCase {
ProcessDefinition processDefinition;
ProcessInstance processInstance;
@@ -41,8 +40,7 @@
Map tokenVariableMaps;
TokenVariableMap tokenVariableMap;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
@@ -59,42 +57,37 @@
contextInstance.tokenVariableMaps = tokenVariableMaps;
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testTokenVariableMapContextInstance()
- {
+ public void testTokenVariableMapContextInstance() {
processInstance = saveAndReload(processInstance);
token = processInstance.getRootToken();
contextInstance = processInstance.getContextInstance();
tokenVariableMaps = contextInstance.tokenVariableMaps;
- tokenVariableMap = (TokenVariableMap)tokenVariableMaps.get(token);
+ tokenVariableMap = (TokenVariableMap) tokenVariableMaps.get(token);
assertSame(contextInstance, tokenVariableMap.getContextInstance());
}
- public void testTokenVariableMapToken()
- {
+ public void testTokenVariableMapToken() {
processInstance = saveAndReload(processInstance);
token = processInstance.getRootToken();
contextInstance = processInstance.getContextInstance();
tokenVariableMaps = contextInstance.tokenVariableMaps;
- tokenVariableMap = (TokenVariableMap)tokenVariableMaps.get(token);
+ tokenVariableMap = (TokenVariableMap) tokenVariableMaps.get(token);
assertSame(token, tokenVariableMap.getToken());
}
- public void testTokenVariableMapVariableInstances()
- {
- StringInstance stringVariable = (StringInstance)VariableInstance.create(token, "one", "hello");
+ public void testTokenVariableMapVariableInstances() {
+ StringInstance stringVariable = (StringInstance) VariableInstance.create(token, "one", "hello");
tokenVariableMap.addVariableInstance(stringVariable);
- stringVariable = (StringInstance)VariableInstance.create(token, "two", "world");
+ stringVariable = (StringInstance) VariableInstance.create(token, "two", "world");
tokenVariableMap.addVariableInstance(stringVariable);
processInstance = saveAndReload(processInstance);
@@ -102,12 +95,14 @@
token = processInstance.getRootToken();
contextInstance = processInstance.getContextInstance();
tokenVariableMaps = contextInstance.tokenVariableMaps;
- tokenVariableMap = (TokenVariableMap)tokenVariableMaps.get(processInstance.getRootToken());
+ tokenVariableMap = (TokenVariableMap) tokenVariableMaps.get(processInstance.getRootToken());
// System.out.println(tokenVariableMap.getVariable("one"));
// System.out.println(tokenVariableMap.getVariable("two"));
- assertEquals("hello", ((StringInstance)tokenVariableMap.variableInstances.get("one")).getValue());
- assertEquals("world", ((StringInstance)tokenVariableMap.variableInstances.get("two")).getValue());
+ assertEquals("hello",
+ ((StringInstance) tokenVariableMap.variableInstances.get("one")).getValue());
+ assertEquals("world",
+ ((StringInstance) tokenVariableMap.variableInstances.get("two")).getValue());
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableInstanceDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableInstanceDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableInstanceDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,6 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmException;
import org.jbpm.context.def.ContextDefinition;
import org.jbpm.db.AbstractDbTestCase;
@@ -36,15 +37,13 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.util.DateDbTestUtil;
-public class VariableInstanceDbTest extends AbstractDbTestCase
-{
+public class VariableInstanceDbTest extends AbstractDbTestCase {
ProcessDefinition processDefinition;
ProcessInstance processInstance;
ContextInstance contextInstance;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
@@ -55,25 +54,22 @@
contextInstance = processInstance.getContextInstance();
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testVariableInstanceString()
- {
+ public void testVariableInstanceString() {
contextInstance.setVariable("comment", "it's not the size that matters, it's how you use it.");
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
- assertEquals("it's not the size that matters, it's how you use it.", contextInstance.getVariable("comment"));
+ assertEquals("it's not the size that matters, it's how you use it.",
+ contextInstance.getVariable("comment"));
}
- public void testVariableInstanceLong()
- {
+ public void testVariableInstanceLong() {
contextInstance.setVariable("new salary", new Long(500000));
processInstance = saveAndReload(processInstance);
@@ -82,8 +78,7 @@
assertEquals(new Long(500000), contextInstance.getVariable("new salary"));
}
- public void testVariableInstanceByteArray()
- {
+ public void testVariableInstanceByteArray() {
String text = "oh, what a wonderfull world";
for (int i = 0; i < 10; i++)
text += text;
@@ -94,125 +89,122 @@
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
- bytes = (byte[])contextInstance.getVariable("a lot of bytes");
+ bytes = (byte[]) contextInstance.getVariable("a lot of bytes");
assertEquals(text, new String(bytes));
}
- public void testString()
- {
+ public void testString() {
contextInstance.setVariable("a", new String("3"));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals("3", contextInstance.getVariable("a"));
}
- public void testBoolean()
- {
+ public void testBoolean() {
contextInstance.setVariable("a", Boolean.TRUE);
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(Boolean.TRUE, contextInstance.getVariable("a"));
}
- public void testCharacter()
- {
+ public void testCharacter() {
contextInstance.setVariable("a", new Character('c'));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Character('c'), contextInstance.getVariable("a"));
}
- public void testFloat()
- {
+ public void testFloat() {
contextInstance.setVariable("a", new Float(3.3));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Float(3.3), contextInstance.getVariable("a"));
}
- public void testDouble()
- {
+ public void testDouble() {
contextInstance.setVariable("a", new Double(3.3));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Double(3.3), contextInstance.getVariable("a"));
}
- public static class MySerializableClass implements Serializable
- {
+ public static class MySerializableClass implements Serializable {
+
private static final long serialVersionUID = 1L;
int member;
- MySerializableClass(int member)
- {
+ MySerializableClass(int member) {
this.member = member;
}
- public boolean equals(Object o)
- {
- if (!(o instanceof MySerializableClass))
- return false;
- return (member == ((MySerializableClass)o).member);
+ public boolean equals(Object o) {
+ if (!(o instanceof MySerializableClass)) return false;
+ return (member == ((MySerializableClass) o).member);
}
}
- public void testCustomTypeSerializable()
- {
+ public void testCustomTypeSerializable() {
contextInstance.setVariable("a", new MySerializableClass(4));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new MySerializableClass(4), contextInstance.getVariable("a"));
}
- public void testLong()
- {
+ public void testLong() {
contextInstance.setVariable("a", new Long(3));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Long(3), contextInstance.getVariable("a"));
}
- public void testByte()
- {
+ public void testByte() {
contextInstance.setVariable("a", new Byte("3"));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Byte("3"), contextInstance.getVariable("a"));
}
- public void testShort()
- {
+ public void testShort() {
contextInstance.setVariable("a", new Short("3"));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Short("3"), contextInstance.getVariable("a"));
}
- public void testInteger()
- {
+ public void testInteger() {
contextInstance.setVariable("a", new Integer(3));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
assertEquals(new Integer(3), contextInstance.getVariable("a"));
}
- public void testDate()
- {
+ public void testDate() {
final Date now = Calendar.getInstance().getTime();
contextInstance.setVariable("a", now);
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
- final Date result = (Date)contextInstance.getVariable("a");
+ final Date result = (Date) contextInstance.getVariable("a");
// assertEquals(expected, result);
- log.info("Now: " + now + ", " + now.getTime() + ", " + DateDbTestUtil.getInstance().convertDateToSeconds(now));
- log.info("Now: " + result + ", " + result.getTime() + ", " + DateDbTestUtil.getInstance().convertDateToSeconds(result));
- assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now), DateDbTestUtil.getInstance().convertDateToSeconds(result));
- assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now), DateDbTestUtil.getInstance().convertDateToSeconds(result));
+ log.info("Now: "
+ + now
+ + ", "
+ + now.getTime()
+ + ", "
+ + DateDbTestUtil.getInstance().convertDateToSeconds(now));
+ log.info("Now: "
+ + result
+ + ", "
+ + result.getTime()
+ + ", "
+ + DateDbTestUtil.getInstance().convertDateToSeconds(result));
+ assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now),
+ DateDbTestUtil.getInstance().convertDateToSeconds(result));
+ assertEquals(DateDbTestUtil.getInstance().convertDateToSeconds(now),
+ DateDbTestUtil.getInstance().convertDateToSeconds(result));
}
- public void testNullUpdate()
- {
+ public void testNullUpdate() {
contextInstance.setVariable("a", "blablabla");
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
@@ -222,8 +214,7 @@
assertNull(contextInstance.getVariable("a"));
}
- public void testChangeTypeWithDeleteIsAllowed()
- {
+ public void testChangeTypeWithDeleteIsAllowed() {
contextInstance.setVariable("a", new String("3"));
processInstance = saveAndReload(processInstance);
contextInstance = processInstance.getContextInstance();
@@ -233,8 +224,7 @@
contextInstance.setVariable("a", new Integer(3));
}
- public void testSerializableCollection()
- {
+ public void testSerializableCollection() {
List l = new ArrayList();
l.add("one");
l.add("two");
@@ -245,16 +235,13 @@
assertEquals(l, contextInstance.getVariable("l"));
}
- public void testNonStorableType()
- {
+ public void testNonStorableType() {
contextInstance.setVariable("t", new Thread());
- try
- {
+ try {
jbpmContext.save(processInstance);
fail("expected exception");
}
- catch (JbpmException e)
- {
+ catch (JbpmException e) {
// OK
// let's make sure the auto flushing of hibernate doesn't explode
contextInstance.deleteVariable("t");
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableQueryDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableQueryDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/VariableQueryDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,10 +1,10 @@
package org.jbpm.context.exe;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.Query;
+
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
@@ -33,38 +33,32 @@
newTransaction();
+ Set expectedPids = new HashSet();
+ expectedPids.add(new Long(one.getId()));
+ expectedPids.add(new Long(two.getId()));
+
Query query = session.createQuery("select pi.id "
+ "from org.jbpm.context.exe.variableinstance.StringInstance si "
+ "join si.processInstance pi "
+ "where si.name = 'category'"
+ " and si.value like 'overpaid'");
+ Set retrievedPids = new HashSet(query.list());
- Set<Long> expectedPids = new HashSet<Long>();
- expectedPids.add(one.getId());
- expectedPids.add(two.getId());
-
- Set<Long> retrievedPids = new HashSet<Long>();
- for (Object result : query.list()) {
- retrievedPids.add((Long) result);
- }
-
assertEquals(expectedPids, retrievedPids);
newTransaction();
+ expectedPids.clear();
+ expectedPids.add(new Long(three.getId()));
+
query = session.createQuery("select pi.id "
+ "from org.jbpm.context.exe.variableinstance.StringInstance si "
+ "join si.processInstance pi "
+ "where si.name = 'category'"
+ " and si.value like 'underpaid'");
+ retrievedPids.clear();
+ retrievedPids.addAll(query.list());
- expectedPids = Collections.singleton(three.getId());
-
- retrievedPids = new HashSet<Long>();
- for (Object result : query.list()) {
- retrievedPids.add((Long) result);
- }
-
assertEquals(expectedPids, retrievedPids);
}
finally {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/log/VariableUpdateDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -35,14 +35,13 @@
import org.jbpm.logging.exe.LoggingInstance;
import org.jbpm.util.DateDbTestUtil;
-public class VariableUpdateDbTest extends AbstractDbTestCase
-{
+public class VariableUpdateDbTest extends AbstractDbTestCase {
+
private ProcessDefinition processDefinition;
private ProcessInstance processInstance;
private ContextInstance contextInstance;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
@@ -52,39 +51,37 @@
contextInstance = processInstance.getContextInstance();
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testVariableCreateLogs()
- {
+ public void testVariableCreateLogs() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
newTransaction();
List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- VariableCreateLog createLog = (VariableCreateLog)LoggingInstance.getLogs(logs, VariableCreateLog.class).get(0);
+ VariableCreateLog createLog = (VariableCreateLog) LoggingInstance.getLogs(logs,
+ VariableCreateLog.class).get(0);
assertEquals("a", createLog.getVariableInstance().getName());
}
- public void testByteArrayUpdateLog()
- {
+ public void testByteArrayUpdateLog() {
contextInstance.setVariable("a", "first value".getBytes());
jbpmContext.save(processInstance);
contextInstance.setVariable("a", "second value".getBytes());
VariableUpdateLog variableLog = saveAndReloadUpdateLog(processInstance);
- assertTrue(Arrays.equals("first value".getBytes(), ((ByteArray)variableLog.getOldValue()).getBytes()));
- assertTrue(Arrays.equals("second value".getBytes(), ((ByteArray)variableLog.getNewValue()).getBytes()));
+ assertTrue(Arrays.equals("first value".getBytes(),
+ ((ByteArray) variableLog.getOldValue()).getBytes()));
+ assertTrue(Arrays.equals("second value".getBytes(),
+ ((ByteArray) variableLog.getNewValue()).getBytes()));
}
- public void testDateUpdateLog()
- {
+ public void testDateUpdateLog() {
final Date now = Calendar.getInstance().getTime();
final Date future = new Date(now.getTime() + 5);
contextInstance.setVariable("a", now);
@@ -94,12 +91,13 @@
VariableUpdateLog variableLog = saveAndReloadUpdateLog(processInstance);
DateDbTestUtil dbUtilInst = DateDbTestUtil.getInstance();
- assertEquals(dbUtilInst.convertDateToSeconds(now), dbUtilInst.convertDateToSeconds((Date)variableLog.getOldValue()));
- assertEquals(dbUtilInst.convertDateToSeconds(future), dbUtilInst.convertDateToSeconds((Date)variableLog.getNewValue()));
+ assertEquals(dbUtilInst.convertDateToSeconds(now),
+ dbUtilInst.convertDateToSeconds((Date) variableLog.getOldValue()));
+ assertEquals(dbUtilInst.convertDateToSeconds(future),
+ dbUtilInst.convertDateToSeconds((Date) variableLog.getNewValue()));
}
- public void testDoubleUpdateLog()
- {
+ public void testDoubleUpdateLog() {
contextInstance.setVariable("a", new Double(3.3));
jbpmContext.save(processInstance);
contextInstance.setVariable("a", new Double(4.4));
@@ -110,8 +108,7 @@
assertEquals(new Double(4.4), variableLog.getNewValue());
}
- public void testLongUpdateLog()
- {
+ public void testLongUpdateLog() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
contextInstance.setVariable("a", new Integer(5));
@@ -122,8 +119,7 @@
assertEquals(new Long(5), variableLog.getNewValue());
}
- public void testStringUpdateLog()
- {
+ public void testStringUpdateLog() {
contextInstance.setVariable("a", "pope");
jbpmContext.save(processInstance);
contextInstance.setVariable("a", "me");
@@ -134,8 +130,7 @@
assertEquals("me", variableLog.getNewValue());
}
- public void testVariableDeleteLog()
- {
+ public void testVariableDeleteLog() {
contextInstance.setVariable("a", new Integer(3));
jbpmContext.save(processInstance);
contextInstance.deleteVariable("a");
@@ -143,16 +138,16 @@
jbpmContext.save(processInstance);
newTransaction();
List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- VariableDeleteLog deleteLog = (VariableDeleteLog)LoggingInstance.getLogs(logs, VariableDeleteLog.class).get(0);
+ VariableDeleteLog deleteLog = (VariableDeleteLog) LoggingInstance.getLogs(logs,
+ VariableDeleteLog.class).get(0);
assertEquals("a", deleteLog.getVariableInstance().getName());
}
- private VariableUpdateLog saveAndReloadUpdateLog(ProcessInstance processInstance)
- {
+ private VariableUpdateLog saveAndReloadUpdateLog(ProcessInstance processInstance) {
jbpmContext.save(processInstance);
newTransaction();
List logs = loggingSession.findLogsByToken(processInstance.getRootToken().getId());
- return (VariableUpdateLog)LoggingInstance.getLogs(logs, VariableUpdateLog.class).get(1);
+ return (VariableUpdateLog) LoggingInstance.getLogs(logs, VariableUpdateLog.class).get(1);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,10 +21,12 @@
*/
package org.jbpm.db;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.hibernate.cfg.Configuration;
+
import org.jbpm.AbstractJbpmTestCase;
/**
@@ -37,7 +39,6 @@
JbpmSchema jbpmSchema;
- @Override
protected void setUp() throws Exception {
super.setUp();
jbpmSchema = new JbpmSchema(new Configuration().configure());
@@ -45,26 +46,28 @@
public void testCreateSchema() {
jbpmSchema.createSchema();
- Set<String> existingTables = jbpmSchema.getExistingTables();
+ Set existingTables = jbpmSchema.getExistingTables();
assert existingTables.containsAll(jbpmSchema.getJbpmTables()) : existingTables;
}
public void testDropSchema() {
jbpmSchema.dropSchema();
- Set<String> existingTables = jbpmSchema.getExistingTables();
- for (String jbpmTable : jbpmSchema.getJbpmTables()) {
+ Set existingTables = jbpmSchema.getExistingTables();
+ for (Iterator i = jbpmSchema.getJbpmTables().iterator(); i.hasNext();) {
+ String jbpmTable = (String) i.next();
assert !existingTables.contains(jbpmTable) : existingTables;
}
}
public void testCleanSchema() {
jbpmSchema.cleanSchema();
- Map<String, Long> rowsPerTable = jbpmSchema.getRowsPerTable();
- Set<String> existingTables = jbpmSchema.getExistingTables();
+ Map rowsPerTable = jbpmSchema.getRowsPerTable();
+ Set existingTables = jbpmSchema.getExistingTables();
assert existingTables.containsAll(rowsPerTable.keySet()) : existingTables;
- for (long rowCount : rowsPerTable.values()) {
- assertEquals(0, rowCount);
+ for (Iterator i = rowsPerTable.values().iterator(); i.hasNext();) {
+ Long rowCount = (Long) i.next();
+ assertEquals(0, rowCount.longValue());
}
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/TaskMgmtSessionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/TaskMgmtSessionDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/db/TaskMgmtSessionDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -46,7 +46,7 @@
protected void setUp() throws Exception {
super.setUp();
-
+
processDefinition = new ProcessDefinition();
taskMgmtDefinition = new TaskMgmtDefinition();
processDefinition.addDefinition(taskMgmtDefinition);
@@ -54,12 +54,12 @@
taskMgmtDefinition.addTask(laundry);
dishes = new Task("dishes");
taskMgmtDefinition.addTask(dishes);
-
+
graphSession.saveProcessDefinition(processDefinition);
-
+
processInstance = new ProcessInstance(processDefinition);
processInstance = saveAndReload(processInstance);
-
+
processDefinition = processInstance.getProcessDefinition();
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
laundry = taskMgmtDefinition.getTask("laundry");
@@ -67,9 +67,7 @@
taskMgmtInstance = processInstance.getTaskMgmtInstance();
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
@@ -78,13 +76,13 @@
taskMgmtInstance.addTaskInstance(new TaskInstance("laundry", "me"));
taskMgmtInstance.addTaskInstance(new TaskInstance("dishes", "me"));
taskMgmtInstance.addTaskInstance(new TaskInstance("vacation", "the other guy"));
-
+
processInstance = saveAndReload(processInstance);
-
+
List taskInstances = taskMgmtSession.findTaskInstances("me");
assertEquals(2, taskInstances.size());
- TaskInstance taskInstanceOne = (TaskInstance)taskInstances.get(0);
- TaskInstance taskInstanceTwo = (TaskInstance)taskInstances.get(1);
+ TaskInstance taskInstanceOne = (TaskInstance) taskInstances.get(0);
+ TaskInstance taskInstanceTwo = (TaskInstance) taskInstances.get(1);
assertEquals("me", taskInstanceOne.getActorId());
assertEquals("me", taskInstanceTwo.getActorId());
assertNotSame(taskInstanceOne, taskInstanceTwo);
@@ -97,53 +95,50 @@
taskMgmtInstance.addTaskInstance(new TaskInstance("vacation", "the other guy"));
taskMgmtInstance.addTaskInstance(new TaskInstance("try", "a nobody"));
taskMgmtInstance.addTaskInstance(new TaskInstance("pretend", "a nobody"));
-
+
processInstance = saveAndReload(processInstance);
-
- List taskInstances = taskMgmtSession.findTaskInstances(new String[]{"me", "the other guy"});
+
+ List taskInstances = taskMgmtSession.findTaskInstances(new String[] { "me", "the other guy" });
assertEquals(4, taskInstances.size());
}
public void testLoadTaskInstance() {
TaskInstance taskInstance = new TaskInstance("laundry", "me");
taskMgmtInstance.addTaskInstance(taskInstance);
-
+
processInstance = saveAndReload(processInstance);
-
+
taskInstance = taskMgmtSession.loadTaskInstance(taskInstance.getId());
assertNotNull(taskInstance);
}
public void testTaskMgmtFinderMethods() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='searchable'>" +
- " <start-state>" +
- " <transition to='f'/>" +
- " </start-state>" +
- " <fork name='f'>" +
- " <transition name='washing' to='collectLaundry'/>" +
- " <transition name='cleaning' to='cleanToilets'/>" +
- " </fork>" +
- " <task-node name='collectLaundry'>" +
- " <task name='getLaundryFromBasket' />" +
- " <task name='askHusbandWhereHeDumpedHisClothes' />" +
- " <task name='lookUnderChildrensBeds' />" +
- " </task-node>" +
- " <task-node name='cleanToilets'>" +
- " <task name='cleanToilets'/>" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='searchable'>"
+ + " <start-state>"
+ + " <transition to='f'/>"
+ + " </start-state>"
+ + " <fork name='f'>"
+ + " <transition name='washing' to='collectLaundry'/>"
+ + " <transition name='cleaning' to='cleanToilets'/>"
+ + " </fork>"
+ + " <task-node name='collectLaundry'>"
+ + " <task name='getLaundryFromBasket' />"
+ + " <task name='askHusbandWhereHeDumpedHisClothes' />"
+ + " <task name='lookUnderChildrensBeds' />"
+ + " </task-node>"
+ + " <task-node name='cleanToilets'>"
+ + " <task name='cleanToilets'/>"
+ + " </task-node>"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
- try
- {
+ try {
newTransaction();
-
+
ProcessInstance processInstance = jbpmContext.newProcessInstance("searchable");
processInstance.signal();
-
+
processInstance = saveAndReload(processInstance);
-
+
List taskInstances = taskMgmtSession.findTaskInstancesByProcessInstance(processInstance);
Set collectedTaskInstanceNames = new HashSet();
Iterator iter = taskInstances.iterator();
@@ -151,15 +146,15 @@
TaskInstance taskInstance = (TaskInstance) iter.next();
collectedTaskInstanceNames.add(taskInstance.getName());
}
-
+
Set expectedTaskInstanceNames = new HashSet();
expectedTaskInstanceNames.add("getLaundryFromBasket");
expectedTaskInstanceNames.add("askHusbandWhereHeDumpedHisClothes");
expectedTaskInstanceNames.add("lookUnderChildrensBeds");
expectedTaskInstanceNames.add("cleanToilets");
-
+
assertEquals(expectedTaskInstanceNames, collectedTaskInstanceNames);
-
+
List nodes = graphSession.findActiveNodesByProcessInstance(processInstance);
Set collectedNodeNames = new HashSet();
iter = nodes.iterator();
@@ -167,17 +162,16 @@
Node node = (Node) iter.next();
collectedNodeNames.add(node.getName());
}
-
+
Set expectedNodeNames = new HashSet();
expectedNodeNames.add("collectLaundry");
expectedNodeNames.add("cleanToilets");
assertEquals(expectedNodeNames, collectedNodeNames);
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
+
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,13 +1,14 @@
package org.jbpm.graph.exe;
+import java.util.Iterator;
+
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class SubProcessCancellationTest extends AbstractDbTestCase
-{
- public void testWithSubProcess()
- {
+public class SubProcessCancellationTest extends AbstractDbTestCase {
+
+ public void testWithSubProcess() {
ProcessDefinition subProcess = ProcessDefinition.parseXmlString("<process-definition name='sub'>"
+ " <start-state>"
+ " <transition to='wait' />"
@@ -35,8 +36,7 @@
jbpmContext.deployProcessDefinition(superProcess);
newTransaction();
- try
- {
+ try {
ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("super");
pi.signal();
@@ -52,14 +52,13 @@
subPi = pi.getRootToken().getSubProcessInstance();
assertTrue(subPi.hasEnded());
- for (TaskInstance taskInstance : subPi.getTaskMgmtInstance().getTaskInstances())
- {
+ for (Iterator i = subPi.getTaskMgmtInstance().getTaskInstances().iterator(); i.hasNext();) {
+ TaskInstance taskInstance = (TaskInstance) i.next();
assertFalse(taskInstance.isSignalling());
assertFalse(taskInstance.hasEnded());
}
}
- finally
- {
+ finally {
graphSession.deleteProcessDefinition(superProcess.getId());
graphSession.deleteProcessDefinition(subProcess.getId());
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -28,58 +28,54 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.node.ProcessState;
-public class SubProcessPlusConcurrencyDbTest extends AbstractDbTestCase
-{
+public class SubProcessPlusConcurrencyDbTest extends AbstractDbTestCase {
void deployProcessDefinitions() {
- ProcessDefinition subProcess = ProcessDefinition.parseXmlString(
- "<process-definition name='sub'>" +
- " <start-state>" +
- " <transition to='wait' />" +
- " </start-state>" +
- " <state name='wait'>" +
- " <transition to='end' />" +
- " </state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition subProcess = ProcessDefinition.parseXmlString("<process-definition name='sub'>"
+ + " <start-state>"
+ + " <transition to='wait' />"
+ + " </start-state>"
+ + " <state name='wait'>"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(subProcess);
-
- ProcessDefinition superProcess = ProcessDefinition.parseXmlString(
- "<process-definition name='super'>" +
- " <start-state>" +
- " <transition name='without subprocess' to='fork' />" +
- " <transition name='with subprocess' to='subprocess' />" +
- " </start-state>" +
- " <process-state name='subprocess'>" +
- " <sub-process name='sub' />" +
- " <transition to='fork'/>" +
- " </process-state>" +
- " <fork name='fork'>" +
- " <transition name='a' to='join' />" +
- " <transition name='b' to='join' />" +
- " </fork>" +
- " <join name='join' lock='UPGRADE'>" +
- " <transition to='s' />" +
- " </join>" +
- " <state name='s'>" +
- " <event type='node-enter'>" +
- " <action class='org.jbpm.graph.exe.SubProcessPlusConcurrencyDbTest$EnterNodeS' />" +
- " </event>" +
- " </state>" +
- "</process-definition>"
- );
+
+ ProcessDefinition superProcess = ProcessDefinition.parseXmlString("<process-definition name='super'>"
+ + " <start-state>"
+ + " <transition name='without subprocess' to='fork' />"
+ + " <transition name='with subprocess' to='subprocess' />"
+ + " </start-state>"
+ + " <process-state name='subprocess'>"
+ + " <sub-process name='sub' />"
+ + " <transition to='fork'/>"
+ + " </process-state>"
+ + " <fork name='fork'>"
+ + " <transition name='a' to='join' />"
+ + " <transition name='b' to='join' />"
+ + " </fork>"
+ + " <join name='join' lock='UPGRADE'>"
+ + " <transition to='s' />"
+ + " </join>"
+ + " <state name='s'>"
+ + " <event type='node-enter'>"
+ + " <action class='org.jbpm.graph.exe.SubProcessPlusConcurrencyDbTest$EnterNodeS' />"
+ + " </event>"
+ + " </state>"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(superProcess);
-
+
newTransaction();
}
public void deleteProcessDefinitions() {
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("super");
Node node = processDefinition.getNode("subprocess");
- ProcessState processState = (ProcessState) session.load(ProcessState.class, node.getId());
+ ProcessState processState = (ProcessState) session.load(ProcessState.class, new Long(
+ node.getId()));
processState.setSubProcessDefinition(null);
-
+
newTransaction();
processDefinition = graphSession.findLatestProcessDefinition("sub");
@@ -94,18 +90,21 @@
}
public static class EnterNodeS implements ActionHandler {
+
private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
ContextInstance contextInstance = executionContext.getContextInstance();
Integer invocationCount = (Integer) contextInstance.getVariable("invocationCount");
- if (invocationCount==null) {
+ if (invocationCount == null) {
contextInstance.setVariable("invocationCount", new Integer(1));
- } else {
- contextInstance.setVariable("invocationCount", new Integer(invocationCount.intValue()+1));
}
+ else {
+ contextInstance.setVariable("invocationCount", new Integer(invocationCount.intValue() + 1));
+ }
}
}
-
+
public void testWithoutSubProcess() {
deployProcessDefinitions();
@@ -116,7 +115,8 @@
assertEquals(new Integer(1), pi.getContextInstance().getVariable("invocationCount"));
newTransaction();
- } finally {
+ }
+ finally {
deleteProcessDefinitions();
}
}
@@ -142,7 +142,8 @@
newTransaction();
- } finally {
+ }
+ finally {
deleteProcessDefinitions();
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,12 +29,13 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.URISyntaxException;
+import java.io.PrintWriter;
+import java.net.URI;
import java.net.URL;
import java.util.regex.Pattern;
import org.hibernate.LockMode;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.db.AbstractDbTestCase;
@@ -47,19 +48,15 @@
*/
public class JoinDbTest extends AbstractDbTestCase {
- @Override
protected JbpmConfiguration getJbpmConfiguration() {
if (jbpmConfiguration == null) {
URL cfgResource = getClass().getClassLoader().getResource("hibernate.cfg.xml");
try {
- OutputStream outStream = new FileOutputStream(new File(cfgResource.toURI().resolve(
- "hibernate.join.cfg.xml")));
- sed("Join.hbm.xml", "Join.lock.hbm.xml", cfgResource.openStream(), outStream);
+ OutputStream outStream = new FileOutputStream(new File(URI.create(cfgResource.toString())
+ .resolve("hibernate.join.cfg.xml")));
+ sed("Join\\.hbm\\.xml", "Join.lock.hbm.xml", cfgResource.openStream(), outStream);
outStream.close();
}
- catch (URISyntaxException e) {
- throw new AssertionError(e);
- }
catch (IOException e) {
throw new JbpmException("could not edit hibernate configuration", e);
}
@@ -70,35 +67,32 @@
return jbpmConfiguration;
}
- @Override
protected void tearDown() throws Exception {
super.tearDown();
jbpmConfiguration.close();
}
- private static void sed(String target, String replacement, InputStream inStream,
+ private static void sed(String regex, String replacement, InputStream inStream,
OutputStream outStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
- Writer writer = new OutputStreamWriter(outStream);
- Pattern pattern = Pattern.compile(target, Pattern.LITERAL);
+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(outStream));
+ Pattern pattern = Pattern.compile(regex);
for (String inLine; (inLine = reader.readLine()) != null;) {
String outLine = pattern.matcher(inLine).replaceAll(replacement);
- writer.write(outLine);
- writer.write('\n');
+ writer.println(outLine);
}
reader.close();
writer.flush();
}
public void testParentLockMode() {
- ProcessDefinition processDefinition = ProcessDefinition
- .parseXmlString("<process-definition name='"
- + getName()
- + "'>"
- + " <join name='read' lock='READ' />"
- + " <join name='nowait' lock='UPGRADE_NOWAIT' />"
- + " <join name='upgrade' lock='pessimistic' />"
- + "</process-definition>");
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='"
+ + getName()
+ + "'>"
+ + " <join name='read' lock='READ' />"
+ + " <join name='nowait' lock='UPGRADE_NOWAIT' />"
+ + " <join name='upgrade' lock='pessimistic' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -35,7 +35,6 @@
* Concurrent job executors can process the same job in parallel. The test simulates multiple nodes
* in the network processing a common job set. The key setting is to give each job executor a
* different name; normally, a job executor is named after the node's inet address
- *
* https://jira.jboss.org/jira/browse/JBPM-1072
*
* @author Jiri Pechanec
@@ -70,7 +69,6 @@
+ " <end-state name='end-state1' />"
+ "</process-definition>";
- @Override
protected void setUp() throws Exception {
super.setUp();
@@ -82,7 +80,6 @@
startJobExecutors();
}
- @Override
protected void tearDown() throws Exception {
stopJobExecutors();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -33,18 +33,16 @@
/**
* GetProcessInstancesCommand should use Query.setTimestamp instead of Query.setDate
- *
* https://jira.jboss.org/jira/browse/JBPM-1106
*
* @author Alejandro Guizar
*/
-public class JBPM1106Test extends AbstractDbTestCase
-{
+public class JBPM1106Test extends AbstractDbTestCase {
+
private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
private ProcessDefinition processDefinition;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition("Audit");
jbpmContext.deployProcessDefinition(processDefinition);
@@ -73,15 +71,12 @@
newTransaction();
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testStartDate()
- {
+ public void testStartDate() {
GetProcessInstancesCommand command = new GetProcessInstancesCommand();
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 8, 10, 9, 0);
@@ -89,12 +84,11 @@
calendar.add(Calendar.DAY_OF_MONTH, 1);
command.setUntilStartDate(calendar.getTime());
- List processInstances = (List)commandService.execute(command);
+ List processInstances = (List) commandService.execute(command);
assertEquals(2, processInstances.size());
}
- public void testStartTime()
- {
+ public void testStartTime() {
GetProcessInstancesCommand command = new GetProcessInstancesCommand();
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 8, 10, 9, 0);
@@ -102,7 +96,7 @@
calendar.set(Calendar.HOUR_OF_DAY, 12);
command.setUntilStartDate(calendar.getTime());
- List processInstances = (List)commandService.execute(command);
+ List processInstances = (List) commandService.execute(command);
assertEquals(1, processInstances.size());
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -27,19 +27,16 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
-/**
- * When a timer fires and another timer is created as part of its execution,
- * no exception should be thrown.
+/**
+ * When a timer fires and another timer is created as part of its execution, no exception should be
+ * thrown. https://jira.jboss.org/jira/browse/JBPM-1135
*
- * https://jira.jboss.org/jira/browse/JBPM-1135
- *
* @author Alejandro Guizar
*/
public class JBPM1135Test extends AbstractDbTestCase {
private long processDefinitionId;
- @Override
protected void setUp() throws Exception {
super.setUp();
@@ -51,7 +48,6 @@
startJobExecutor();
}
- @Override
protected void tearDown() throws Exception {
stopJobExecutor();
graphSession.deleteProcessDefinition(processDefinitionId);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,7 +29,6 @@
/**
* JbpmConfiguration assumes the object factory has a jbpm.job.executor entry
- *
* https://jira.jboss.org/jira/browse/JBPM-1452
*
* @author Alejandro Guizar
@@ -38,7 +37,6 @@
private long processDefinitionId;
- @Override
protected JbpmConfiguration getJbpmConfiguration() {
if (jbpmConfiguration == null) {
jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
@@ -48,7 +46,6 @@
return jbpmConfiguration;
}
- @Override
protected void setUp() throws Exception {
super.setUp();
ProcessDefinition processDefinition = new ProcessDefinition("Audit");
@@ -56,7 +53,6 @@
processDefinitionId = processDefinition.getId();
}
- @Override
protected void tearDown() throws Exception {
graphSession.deleteProcessDefinition(processDefinitionId);
super.tearDown();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,6 +1,7 @@
package org.jbpm.jbpm1755;
import org.hibernate.LockMode;
+
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.EventCallback;
@@ -10,7 +11,6 @@
/**
* Allow process author to set the parent token lock mode in the join token.
- *
* https://jira.jboss.org/jira/browse/JBPM-1755
*
* @author Alejandro Guizar
@@ -21,13 +21,11 @@
private static final int processInstanceCount = 5;
- @Override
protected void setUp() throws Exception {
super.setUp();
processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm1755/parallelprocess.xml");
}
- @Override
protected void tearDown() throws Exception {
graphSession.deleteProcessDefinition(processDefinition.getId());
EventCallback.clear();
@@ -73,7 +71,7 @@
for (int i = 0; i < processInstanceCount; i++) {
long processInstanceId = processInstanceIds[i];
- assertTrue("expected process instance " + processInstanceId + " to have ended",
+ assertTrue("expected process instance " + processInstanceId + " to have ended",
jbpmContext.loadProcessInstance(processInstanceId).hasEnded());
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1778/JBPM1778Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1778/JBPM1778Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1778/JBPM1778Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,6 +1,6 @@
package org.jbpm.jbpm1778;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.Map;
import org.jbpm.AbstractJbpmTestCase;
@@ -10,18 +10,16 @@
/**
* Empty map variables on process creation is set as null
- *
* https://jira.jboss.org/jira/browse/JBPM-1778
*
* @author Thomas.Diesler at jboss.com
*/
-public class JBPM1778Test extends AbstractJbpmTestCase
-{
- public void testEmptyMapVariables()
- {
- ProcessDefinition pd = getProcessDEfinition();
-
- ProcessInstance pi = pd.createProcessInstance(new HashMap<String, String>());
+public class JBPM1778Test extends AbstractJbpmTestCase {
+
+ public void testEmptyMapVariables() {
+ ProcessDefinition pd = getProcessDefinition();
+
+ ProcessInstance pi = pd.createProcessInstance(Collections.EMPTY_MAP);
TaskMgmtInstance tmi = pi.getTaskMgmtInstance();
tmi.createStartTaskInstance();
@@ -30,13 +28,10 @@
assertEquals("ProcessInstance vars empty", 0, piVars.size());
}
- public void testNonEmptyMapVariables()
- {
- ProcessDefinition pd = getProcessDEfinition();
-
- HashMap<String, String> vars = new HashMap<String, String>();
- vars.put("uno", "dos");
-
+ public void testNonEmptyMapVariables() {
+ ProcessDefinition pd = getProcessDefinition();
+
+ Map vars = Collections.singletonMap("uno", "dos");
ProcessInstance pi = pd.createProcessInstance(vars);
TaskMgmtInstance tmi = pi.getTaskMgmtInstance();
tmi.createStartTaskInstance();
@@ -46,18 +41,16 @@
assertEquals("ProcessInstance vars not empty", 1, piVars.size());
}
- private ProcessDefinition getProcessDEfinition()
- {
- ProcessDefinition pd = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='s' />" +
- " </start-state>" +
- " <state name='s'>" +
- " <transition to='end' />" +
- " </state>" +
- " <end-state name='end' />" +
- "</process-definition>");
+ private ProcessDefinition getProcessDefinition() {
+ ProcessDefinition pd = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='s' />"
+ + " </start-state>"
+ + " <state name='s'>"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
return pd;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -32,8 +32,10 @@
assertTrue("expected " + processInstance + " to have ended", processInstance.hasEnded());
ContextInstance contextInstance = processInstance.getContextInstance();
- assertEquals(1, contextInstance.getVariable("chaos"));
- assertEquals(1, contextInstance.getVariable("undead"));
+ Integer count = (Integer) contextInstance.getVariable("chaos");
+ assertEquals(1, count.intValue());
+ count = (Integer) contextInstance.getVariable("undead");
+ assertEquals(1, count.intValue());
}
finally {
graphSession.deleteProcessDefinition(processDefinition.getId());
@@ -67,14 +69,17 @@
}
public static class TimerAction implements ActionHandler {
+
private boolean leave;
private static final long serialVersionUID = 1L;
+ private static final Integer ONE = new Integer(1);
public void execute(ExecutionContext executionContext) throws Exception {
String timerName = executionContext.getTimer().getName();
- Integer executionCount = (Integer) executionContext.getVariable(timerName);
- executionContext.setVariable(timerName, executionCount != null ? executionCount + 1 : 1);
+ Integer count = (Integer) executionContext.getVariable(timerName);
+ executionContext.setVariable(timerName, count != null ? new Integer(count.intValue() + 1)
+ : ONE);
if (leave) executionContext.leaveNode();
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,14 +21,15 @@
*/
package org.jbpm.jbpm2094;
+import java.util.Iterator;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
+
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.util.CollectionUtil;
/**
* @author Alejandro Guizar
@@ -45,13 +46,15 @@
public void execute(ExecutionContext executionContext) throws Exception {
log.debug("simulating invocation of " + esbCategoryName + "::" + esbServiceName);
- for (Element bpmToEsbVar : CollectionUtil.checkList(bpmToEsbVars.elements(), Element.class)) {
+ for (Iterator i = bpmToEsbVars.elementIterator(); i.hasNext();) {
+ Element bpmToEsbVar = (Element) i.next();
String var = bpmToEsbVar.attributeValue("bpm");
Object value = executionContext.getVariable(var);
log.debug("read " + value + " from variable " + var);
}
Random random = new Random();
- for (Element esbToBpmVar : CollectionUtil.checkList(esbToBpmVars.elements(), Element.class)) {
+ for (Iterator i = esbToBpmVars.elementIterator(); i.hasNext();) {
+ Element esbToBpmVar = (Element) i.next();
String var = esbToBpmVar.attributeValue("bpm");
byte[] value = new byte[random.nextInt(2048)];
random.nextBytes(value);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -36,13 +36,11 @@
private static final int TIMEOUT = 60 * 1000;
private static final int INSTANCE_COUNT = 5;
- @Override
protected void setUp() throws Exception {
super.setUp();
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(4);
}
- @Override
protected void tearDown() throws Exception {
jbpmConfiguration.getJobExecutor().setNbrOfThreads(1);
super.tearDown();
@@ -50,10 +48,9 @@
public void testJobExecutorDeadlock() {
// Won't fix [JBPM-2094] unindexed foreign keys cause deadlocks in oracle
- if (getHibernateDialect().contains("HSQL")) return;
+ if (getHibernateDialect().indexOf("HSQL") != -1) return;
- ProcessDefinition processDefinition = ProcessDefinition
- .parseXmlResource("org/jbpm/jbpm2094/processdefinition.xml");
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm2094/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
@@ -120,7 +121,7 @@
public void testConcurrentJobs() throws Exception {
// Won't Fix [JBPM-983] concurrent process execution fails
- if (getHibernateDialect().contains("HSQL")) return;
+ if (getHibernateDialect().indexOf("HSQL") != -1) return;
// create test properties
Map testVariables = Collections.singletonMap("test", "true");
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,10 +1,10 @@
package org.jbpm.job.executor;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.Vector;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.Action;
@@ -18,17 +18,15 @@
static final int nbrOfConcurrentProcessExecutions = 20;
static final int timeout = 60000;
- static Set<String> collectedResults = Collections.synchronizedSet(new TreeSet<String>());
- static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
+ static Set collectedResults = Collections.synchronizedSet(new TreeSet());
+ static List allocatedProcessIds = new Vector();
- @Override
protected void setUp() throws Exception {
super.setUp();
- deployProcess();
+ deployProcess();
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(4);
}
- @Override
protected void tearDown() throws Exception {
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
deleteProcess();
@@ -106,8 +104,8 @@
}
}
- Set<String> createExpectedResults() {
- Set<String> expectedResults = new TreeSet<String>();
+ Set createExpectedResults() {
+ Set expectedResults = new TreeSet();
for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++) {
String prefix = (i < 10 ? "0" : "");
expectedResults.add(prefix + i + "a");
@@ -132,7 +130,7 @@
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
- Long id = executionContext.getProcessInstance().getId();
+ long id = executionContext.getProcessInstance().getId();
String procIndex = getProcessIndex(id);
String nodeName = executionContext.getNode().getName();
@@ -146,7 +144,7 @@
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
- Long id = executionContext.getProcessInstance().getId();
+ long id = executionContext.getProcessInstance().getId();
String procIndex = getProcessIndex(id);
Action action = executionContext.getAction();
@@ -155,13 +153,11 @@
}
}
- static synchronized String getProcessIndex(Long id) {
- if (allocatedProcessIds.contains(id) == false)
- allocatedProcessIds.add(id);
+ static synchronized String getProcessIndex(long id) {
+ Long identifier = new Long(id);
+ if (!allocatedProcessIds.contains(identifier)) allocatedProcessIds.add(identifier);
- int procIndex = allocatedProcessIds.indexOf(id);
- String prefix = (procIndex < 10 ? "0" : "");
-
- return prefix + procIndex;
+ int procIndex = allocatedProcessIds.indexOf(identifier);
+ return procIndex < 10 ? "0" + procIndex : Integer.toString(procIndex);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -12,20 +12,21 @@
import org.jbpm.util.ClassLoaderUtil;
/**
- * Test case for ProcessClassLoader hierarchy and setting the ContextClassLoader correctly.
+ * Test case for ProcessClassLoader hierarchy and setting the ContextClassLoader correctly. Relates
+ * to {@link ConfigurableClassloadersTest}.
*
- * Relates to {@link ConfigurableClassloadersTest}.
- *
- * @author Tom Baeyens, bernd.ruecker at camunda.com
- *
+ * @author Tom Baeyens
+ * @author bernd.ruecker at camunda.com
*/
public class ProcessClassLoaderTest extends AbstractJbpmTestCase {
-
+
public static class TestContextClassLoader extends ClassLoader {
+
public TestContextClassLoader(ClassLoader parent) {
super(parent);
}
- protected Class< ? > findClass(String name) throws ClassNotFoundException {
+
+ protected Class findClass(String name) throws ClassNotFoundException {
if ("TestContextClassLoader-knows-where-to-find-ContextLoadedAction".equals(name)) {
return getParent().loadClass(ContextLoadedAction.class.getName());
}
@@ -37,8 +38,8 @@
}
static int contextLoadedActionInvocations = 0;
- static ClassLoader originalClassLoader = null;
-
+ static ClassLoader originalClassLoader = null;
+
protected void setUp() throws Exception {
super.setUp();
contextLoadedActionInvocations = 0;
@@ -47,6 +48,8 @@
public static class DefaultLoadedAction implements ActionHandler {
+ private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
assertSame(ProcessClassLoader.class, contextClassLoader.getClass());
@@ -57,34 +60,35 @@
contextLoadedActionInvocations++;
}
}
-
- /** DOES NOT configure usage of the context classloader. So this tests the default (backwards compatible) behaviour.
- * so the classloading hierarchy of DefaultLoadedAction should be
- * ProcessClassloader -> jbpm-lib classloader */
+
+ /**
+ * DOES NOT configure usage of the context classloader. So this tests the default (backwards
+ * compatible) behaviour. so the classloading hierarchy of DefaultLoadedAction should be
+ * ProcessClassloader -> jbpm-lib classloader
+ */
public void testDefaultClassLoader() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state name='start'>" +
- " <transition to='state'>" +
- " <action class='org.jbpm.jpdl.par.ProcessClassLoaderTest$DefaultLoadedAction' />" +
- " </transition>" +
- " </start-state>" +
- " <state name='state'>" +
- " <transition to='end'/>" +
- " </state>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state name='start'>"
+ + " <transition to='state'>"
+ + " <action class='org.jbpm.jpdl.par.ProcessClassLoaderTest$DefaultLoadedAction' />"
+ + " </transition>"
+ + " </start-state>"
+ + " <state name='state'>"
+ + " <transition to='end'/>"
+ + " </state>"
+ + "</process-definition>");
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
- assertEquals(1, contextLoadedActionInvocations);
+
+ assertEquals(1, contextLoadedActionInvocations);
}
-
public static class ContextLoadedAction implements ActionHandler {
+ private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
ClassLoader processClassLoader = Thread.currentThread().getContextClassLoader();
assertSame(ProcessClassLoader.class, processClassLoader.getClass());
@@ -98,106 +102,103 @@
}
}
- /** configures usage of the context classloader
- * so the classloading hierarchy of ContextLoadedAction should be
- * ProcessClassloader -> TestContextClassLoader -> Thread.currentContextClassLoader */
+ /**
+ * configures usage of the context classloader so the classloading hierarchy of
+ * ContextLoadedAction should be ProcessClassloader -> TestContextClassLoader ->
+ * Thread.currentContextClassLoader
+ */
public void testContextClassLoader() {
-
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='jbpm.classLoader' value='context' />" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.classLoader' value='context' />"
+ + "</jbpm-configuration>");
+
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
- TestContextClassLoader testContextClassLoader = new TestContextClassLoader(originalClassLoader);
+ TestContextClassLoader testContextClassLoader = new TestContextClassLoader(
+ originalClassLoader);
Thread.currentThread().setContextClassLoader(testContextClassLoader);
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state name='start'>" +
- " <transition to='state'>" +
- " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedAction' />" +
- " </transition>" +
- " </start-state>" +
- " <state name='state'>" +
- " <transition to='end'/>" +
- " </state>" +
- "</process-definition>"
- );
-
+
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state name='start'>"
+ + " <transition to='state'>"
+ + " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedAction' />"
+ + " </transition>"
+ + " </start-state>"
+ + " <state name='state'>"
+ + " <transition to='end'/>"
+ + " </state>"
+ + "</process-definition>");
+
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
+
assertEquals(1, contextLoadedActionInvocations);
assertSame(testContextClassLoader, Thread.currentThread().getContextClassLoader());
-
- } finally {
+ }
+ finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
jbpmContext.close();
}
}
/**
- * a third test should set the testcontextClassLoader in the test and then
- * let the action throw an exception. Then it should be verified that the
- * original classloader is still restored correctly. Easiest is to start
- * from a copy of the testContextClassLoader
+ * a third test should set the testcontextClassLoader in the test and then let the action throw an
+ * exception. Then it should be verified that the original classloader is still restored
+ * correctly. Easiest is to start from a copy of the testContextClassLoader
*/
public static class ContextLoadedExceptionAction implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
public void execute(ExecutionContext executionContext) throws Exception {
ClassLoader processClassLoader = Thread.currentThread().getContextClassLoader();
assertSame(ProcessClassLoader.class, processClassLoader.getClass());
-
+
ClassLoader testContextClassLoader = processClassLoader.getParent();
assertSame(TestContextClassLoader.class, testContextClassLoader.getClass());
-
+
assertSame(originalClassLoader, testContextClassLoader.getParent());
-
+
contextLoadedActionInvocations++;
-
+
throw new Exception("simulate exception");
}
}
+
public void testContextClassLoaderException() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='jbpm.classLoader' value='context' />" +
- "</jbpm-configuration>"
- );
-
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
+ + " <string name='jbpm.classLoader' value='context' />"
+ + "</jbpm-configuration>");
+
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
TestContextClassLoader testContextClassLoader = new TestContextClassLoader(originalClassLoader);
try {
Thread.currentThread().setContextClassLoader(testContextClassLoader);
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state name='start'>" +
- " <transition to='state'>" +
- " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedExceptionAction' />" +
- " </transition>" +
- " </start-state>" +
- " <state name='state'>" +
- " <transition to='end'/>" +
- " </state>" +
- "</process-definition>"
- );
-
+
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state name='start'>"
+ + " <transition to='state'>"
+ + " <action class='TestContextClassLoader-knows-where-to-find-ContextLoadedExceptionAction' />"
+ + " </transition>"
+ + " </start-state>"
+ + " <state name='state'>"
+ + " <transition to='end'/>"
+ + " </state>"
+ + "</process-definition>");
+
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
- } catch(Exception ex) {
+ }
+ catch (Exception ex) {
assertEquals(1, contextLoadedActionInvocations);
assertEquals("simulate exception", ex.getMessage());
assertSame(testContextClassLoader, Thread.currentThread().getContextClassLoader());
-
- } finally {
+ }
+ finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
jbpmContext.close();
}
- }
+ }
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/xml/AbstractXmlTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/xml/AbstractXmlTestCase.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/xml/AbstractXmlTestCase.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -22,7 +22,7 @@
package org.jbpm.jpdl.xml;
import java.io.StringWriter;
-import java.util.HashMap;
+import java.util.Collections;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -31,46 +31,36 @@
import org.jbpm.graph.def.ProcessDefinition;
public abstract class AbstractXmlTestCase extends AbstractJbpmTestCase {
-
- // private static final String JPDL_NAMESPACE = "http://jbpm.org/3/jpdl";
- static Element toXmlAndParse(ProcessDefinition processDefinition, String xpathExpression) throws Exception {
+ static Element toXmlAndParse(ProcessDefinition processDefinition, String xpathExpression)
+ throws Exception {
Element element = toXmlAndParse(processDefinition);
return (Element) element.selectSingleNode(xpathExpression);
}
-
- static Element toXmlAndParse(ProcessDefinition processDefinition, String xpathExpression, String namespace) throws Exception {
- Element element = toXmlAndParseWithNamespace(processDefinition);
- XPath xpath = DocumentHelper.createXPath(xpathExpression);
- HashMap m = new HashMap();
- m.put("", namespace);
-
- xpath.setNamespaceURIs( m );
- return (Element) xpath.selectSingleNode( element );
- }
+ static Element toXmlAndParse(ProcessDefinition processDefinition, String xpathExpression,
+ String namespace) throws Exception {
+ Element element = toXmlAndParseWithNamespace(processDefinition);
+ XPath xpath = DocumentHelper.createXPath(xpathExpression);
+ xpath.setNamespaceURIs(Collections.singletonMap("", namespace));
+ return (Element) xpath.selectSingleNode(element);
+ }
static Element toXmlAndParse(ProcessDefinition processDefinition) throws Exception {
+ String xml = JpdlXmlWriter.toString(processDefinition);
+ return DocumentHelper.parseText(xml).getRootElement();
+ }
+
+ static Element toXmlAndParseWithNamespace(ProcessDefinition processDefinition) throws Exception {
StringWriter stringWriter = new StringWriter();
JpdlXmlWriter jpdlWriter = new JpdlXmlWriter(stringWriter);
- jpdlWriter.write( processDefinition );
+ jpdlWriter.setUseNamespace(true);
+ jpdlWriter.write(processDefinition);
String xml = stringWriter.toString();
- return DocumentHelper.parseText( xml ).getRootElement();
+ return DocumentHelper.parseText(xml).getRootElement();
}
-
- static Element toXmlAndParseWithNamespace(ProcessDefinition processDefinition) throws Exception {
- StringWriter stringWriter = new StringWriter();
- JpdlXmlWriter jpdlWriter = new JpdlXmlWriter(stringWriter);
- jpdlWriter.setUseNamespace( true );
- jpdlWriter.write( processDefinition );
- String xml = stringWriter.toString();
- return DocumentHelper.parseText( xml ).getRootElement();
- }
-
+
static void printXml(ProcessDefinition processDefinition) {
- StringWriter stringWriter = new StringWriter();
- JpdlXmlWriter jpdlWriter = new JpdlXmlWriter(stringWriter);
- jpdlWriter.write( processDefinition );
- // System.out.println( stringWriter.toString() );
+ System.out.println(JpdlXmlWriter.toString(processDefinition));
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,6 +1,7 @@
package org.jbpm.logging.exe;
import org.hibernate.Query;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
@@ -8,7 +9,6 @@
public class LoggingConfigDbTest extends AbstractDbTestCase {
- @Override
protected JbpmConfiguration getJbpmConfiguration() {
if (jbpmConfiguration == null) {
jbpmConfiguration = JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
@@ -16,7 +16,6 @@
return jbpmConfiguration;
}
- @Override
protected void tearDown() throws Exception {
super.tearDown();
jbpmConfiguration.close();
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,159 +0,0 @@
-package org.jbpm.optimisticlocking;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.Semaphore;
-
-import org.hibernate.Query;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.Comment;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * Possible problem in concurrent signalling from multiple threads
- *
- * https://jira.jboss.org/jira/browse/JBPM-1071
- */
-public class LockingTest extends AbstractDbTestCase {
-
- private long processDefinitionId;
-
- static final int nbrOfThreads = 5;
- static final int nbrOfIterations = 20;
-
- protected void setUp() throws Exception {
- super.setUp();
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='lockprocess'>"
- + " <start-state name='start'>"
- + " <transition to='end'/>"
- + " </start-state>"
- + " <end-state name='end' />"
- + "</process-definition>");
- jbpmContext.deployProcessDefinition(processDefinition);
- newTransaction();
- processDefinitionId = processDefinition.getId();
- }
-
- protected void tearDown() throws Exception {
- graphSession.deleteProcessDefinition(processDefinitionId);
- super.tearDown();
- }
-
- public void testLocking() {
- // the process will be executed in 2 separate transactions:
- // Transaction 1 will create the process instance and position
- // the root token in the start state
- // Transaction 2 will signal the process instance while it is in the
- // start state, and that signal will bring the process to it's end state.
- // multiple competing threads will be set up for the second transaction
-
- ProcessDefinition processDefinition = graphSession.loadProcessDefinition(processDefinitionId);
- for (int i = 0; i < nbrOfIterations; i++) {
- ProcessInstance processInstance = new ProcessInstance(processDefinition);
- jbpmContext.save(processInstance);
-
- newTransaction();
-
- // create a bunch of threads that will all wait on the
- // semaphore before they will try to signal the same process instance
- long processInstanceId = processInstance.getId();
- Semaphore semaphore = new Semaphore(0);
- List threads = startThreads(semaphore, processInstanceId);
-
- // release all the threads
- semaphore.release(nbrOfThreads);
-
- // wait for all threads to finish
- joinAllThreads(threads);
-
- // check that only 1 of those threads committed
- Query query = session.createQuery("from org.jbpm.graph.exe.Comment");
- List results = query.list();
- assertEquals(results.toString(), 1, results.size());
-
- // delete the comment
- session.delete(results.get(0));
-
- // check that the process instance has ended
- processInstance = jbpmContext.loadProcessInstance(processInstanceId);
- assertTrue(processInstance.hasEnded());
- }
- }
-
- private List startThreads(Semaphore semaphore, long processInstanceId) {
- JbpmConfiguration jbpmConfiguration = getJbpmConfiguration();
-
- List threads = new ArrayList();
- for (int i = 0; i < nbrOfThreads; i++) {
- Thread thread = new LockThread(jbpmConfiguration, semaphore, processInstanceId);
- threads.add(thread);
- thread.start();
- }
- return threads;
- }
-
- private void joinAllThreads(List threads) {
- Iterator iter = threads.iterator();
- while (iter.hasNext()) {
- Thread thread = (Thread) iter.next();
- try {
- thread.join(10000);
- }
- catch (InterruptedException e) {
- fail("join interrupted");
- }
- }
- }
-
- static class LockThread extends Thread {
-
- Semaphore semaphore;
- long processInstanceId;
- JbpmConfiguration jbpmConfiguration;
-
- public LockThread(JbpmConfiguration jbpmConfiguration, Semaphore semaphore, long processInstanceId) {
- this.semaphore = semaphore;
- this.processInstanceId = processInstanceId;
- this.jbpmConfiguration = jbpmConfiguration;
- }
-
- public void run() {
- try {
- // first wait until the all threads are released at once in the
- // method testLocking
- semaphore.acquire();
-
- // after a thread is released (=notified), it will try to load the
- // process instance,
- // signal it and then commit the transaction
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
- processInstance.signal();
- jbpmContext.save(processInstance);
-
- // add a comment in the same transaction so that we can see which
- // thread won
- Comment comment = new Comment(getName() + " committed");
- jbpmContext.getSession().save(comment);
- }
- catch (RuntimeException e) {
- jbpmContext.setRollbackOnly();
- }
- finally {
- jbpmContext.close();
- }
- }
- catch (InterruptedException e) {
- fail("semaphore waiting got interrupted");
- }
- catch (RuntimeException e) {
- // ignore other exceptions
- }
- }
- }
-}
Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java (from rev 4691, jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/optimisticlocking/LockingTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,161 @@
+package org.jbpm.optimisticlocking;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.Comment;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.persistence.JbpmPersistenceException;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
+import org.jbpm.svc.Services;
+import org.jbpm.util.Semaphore;
+
+/**
+ * Possible problem in concurrent signalling from multiple threads
+ * https://jira.jboss.org/jira/browse/JBPM-1071
+ */
+public class LockingTest extends AbstractDbTestCase {
+
+ private long processDefinitionId;
+
+ static final int nbrOfThreads = 4;
+ static final int nbrOfIterations = 20;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='lockprocess'>"
+ + " <start-state name='start'>"
+ + " <transition to='end'/>"
+ + " </start-state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+ newTransaction();
+ processDefinitionId = processDefinition.getId();
+ }
+
+ protected void tearDown() throws Exception {
+ graphSession.deleteProcessDefinition(processDefinitionId);
+ super.tearDown();
+ }
+
+ public void testLocking() {
+ // the process will be executed in 2 separate transactions:
+ // Transaction 1 will create the process instance and position
+ // the root token in the start state
+ // Transaction 2 will signal the process instance while it is in the
+ // start state, and that signal will bring the process to it's end state.
+ // multiple competing threads will be set up for the second transaction
+
+ ProcessDefinition processDefinition = graphSession.loadProcessDefinition(processDefinitionId);
+ for (int i = 0; i < nbrOfIterations; i++) {
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+ jbpmContext.save(processInstance);
+
+ newTransaction();
+
+ // create a bunch of threads that will all wait on the
+ // semaphore before they will try to signal the same process instance
+ long processInstanceId = processInstance.getId();
+ Semaphore semaphore = new Semaphore(0);
+ List threads = startThreads(semaphore, processInstanceId);
+
+ // release all the threads
+ semaphore.release(nbrOfThreads);
+
+ // wait for all threads to finish
+ joinAllThreads(threads);
+
+ // check that only 1 of those threads committed
+ List results = session.createCriteria(Comment.class).list();
+ assertEquals(results.toString(), 1, results.size());
+
+ // delete the comment
+ session.delete(results.get(0));
+
+ // check that the process instance has ended
+ processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+ assertTrue(processInstance.hasEnded());
+ }
+ }
+
+ private List startThreads(Semaphore semaphore, long processInstanceId) {
+ List threads = new ArrayList();
+ for (int i = 0; i < nbrOfThreads; i++) {
+ Thread thread = new LockThread(semaphore, processInstanceId);
+ threads.add(thread);
+ thread.start();
+ }
+ return threads;
+ }
+
+ private void joinAllThreads(List threads) {
+ for (Iterator i = threads.iterator(); i.hasNext();) {
+ Thread thread = (Thread) i.next();
+ try {
+ thread.join(10000);
+ }
+ catch (InterruptedException e) {
+ fail("join interrupted");
+ }
+ }
+ }
+
+ class LockThread extends Thread {
+
+ final Semaphore semaphore;
+ final long processInstanceId;
+
+ public LockThread(Semaphore semaphore, long processInstanceId) {
+ this.semaphore = semaphore;
+ this.processInstanceId = processInstanceId;
+ }
+
+ public void run() {
+ try {
+ // first wait until the all threads are released at once in the
+ // method testLocking
+ semaphore.acquire();
+ }
+ catch (InterruptedException e) {
+ fail("semaphore waiting got interrupted");
+ }
+
+ // after a thread is released (=notified), it will try to load the process instance,
+ // signal it and then commit the transaction
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+ processInstance.signal();
+ jbpmContext.save(processInstance);
+
+ // add a comment in the same transaction so that we can see which thread won
+ Comment comment = new Comment(getName() + " committed");
+ jbpmContext.getSession().save(comment);
+ }
+ catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
+ finally {
+ try {
+ jbpmContext.close();
+ }
+ catch (JbpmPersistenceException e) {
+ // if this is a stale object exception, keep it quiet
+ if (Services.isCausedByStaleState(e)) {
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
+ .error(getName() + " rolled back");
+ }
+ else {
+ throw e;
+ }
+ }
+ }
+ }
+ }
+}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,13 +21,12 @@
*/
package org.jbpm.perf;
-import java.util.concurrent.Semaphore;
-
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.util.Semaphore;
/**
* This test creates a number of process instances. Every instance has a call to an ActionHandler.
@@ -47,7 +46,6 @@
private ProcessDefinition processDefinition;
- @Override
protected void setUp() throws Exception {
super.setUp();
@@ -68,7 +66,6 @@
startJobExecutor();
}
- @Override
protected void tearDown() throws Exception {
stopJobExecutor();
@@ -118,6 +115,7 @@
}
public static class AsyncSignalAction implements ActionHandler {
+
private static final long serialVersionUID = -8617329370138396271L;
public void execute(final ExecutionContext executionContext) throws Exception {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/TaskWithVariablesTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/TaskWithVariablesTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/TaskWithVariablesTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
@@ -34,55 +35,47 @@
import org.jbpm.taskmgmt.exe.Assignable;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class TaskWithVariablesTest extends AbstractDbTestCase
-{
+public class TaskWithVariablesTest extends AbstractDbTestCase {
- public static class ErnieAssignmentHandler implements AssignmentHandler
- {
+ public static class ErnieAssignmentHandler implements AssignmentHandler {
+
private static final long serialVersionUID = 1L;
- public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception
- {
+ public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
assignable.setActorId("manager");
}
}
-
+
ProcessDefinition processDefinition;
-
- @Override
- protected void setUp() throws Exception
- {
+
+ protected void setUp() throws Exception {
super.setUp();
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='states'>" +
- " <start-state>" +
- " <transition to='one' />" +
- " </start-state>" +
- " <task-node name='one'>" +
- " <task name='one'>" +
- " <assignment class='org.jbpm.perf.TaskWithVariablesTest$ErnieAssignmentHandler' />" +
- " </task>" +
- " <transition to='two' />" +
- " </task-node>" +
- " <task-node name='two'>" +
- " <task name='two'>" +
- " <assignment class='org.jbpm.perf.TaskWithVariablesTest$ErnieAssignmentHandler' />" +
- " </task>" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition name='states'>"
+ + " <start-state>"
+ + " <transition to='one' />"
+ + " </start-state>"
+ + " <task-node name='one'>"
+ + " <task name='one'>"
+ + " <assignment class='org.jbpm.perf.TaskWithVariablesTest$ErnieAssignmentHandler' />"
+ + " </task>"
+ + " <transition to='two' />"
+ + " </task-node>"
+ + " <task-node name='two'>"
+ + " <task name='two'>"
+ + " <assignment class='org.jbpm.perf.TaskWithVariablesTest$ErnieAssignmentHandler' />"
+ + " </task>"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
-
+
public void testStates() {
log.info("");
log.info("=== CREATING PROCESS INSTANCE =======================================================");
@@ -97,7 +90,7 @@
processInstance.signal();
newTransaction();
-
+
log.info("");
log.info("=== PERFORMING TASK ONE =======================================================");
log.info("");
@@ -108,7 +101,7 @@
taskInstance.end();
newTransaction();
-
+
log.info("");
log.info("=== PERFORMING TASK TWO =======================================================");
log.info("");
@@ -118,6 +111,6 @@
taskInstance.setVariable("delivery address", "829 maple street");
taskInstance.end();
}
-
+
private static final Log log = LogFactory.getLog(TaskWithVariablesTest.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -7,16 +7,14 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.job.executor.JobExecutor;
+public class JobExecutorCustomizationTest extends AbstractDbTestCase {
-public class JobExecutorCustomizationTest extends AbstractDbTestCase {
-
public static List jobEvents = new ArrayList();
-
+
protected String getJbpmTestConfig() {
return "org/jbpm/seam/custom.job.executor.jbpm.cfg.xml";
}
- @Override
protected void tearDown() throws Exception {
super.tearDown();
jbpmConfiguration.close();
@@ -25,45 +23,47 @@
public void testCustomJobExecutor() {
JobExecutor jobExecutor = getJbpmConfiguration().getJobExecutor();
assertEquals(CustomJobExecutor.class, jobExecutor.getClass());
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='customjobexecution' initial='start'>" +
- " <node name='start'>" +
- " <transition to='end'>" +
- " <action async='true' class='"+AsyncAction.class.getName()+"' />" +
- " </transition>" +
- " </node>" +
- " <state name='end' />" +
- "</process-definition>"
- );
+
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='customjobexecution' initial='start'>"
+ + " <node name='start'>"
+ + " <transition to='end'>"
+ + " <action async='true' class='"
+ + AsyncAction.class.getName()
+ + "' />"
+ + " </transition>"
+ + " </node>"
+ + " <state name='end' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
long processDefinitionId = processDefinition.getId();
try {
-
+
newTransaction();
-
+
jbpmContext.newProcessInstanceForUpdate("customjobexecution");
-
+
newTransaction();
-
+
jobExecutor.start();
try {
waitForJobs(20000);
- } finally {
+ }
+ finally {
jobExecutor.stop();
}
- } finally {
+ }
+ finally {
newTransaction();
-
+
graphSession.deleteProcessDefinition(processDefinitionId);
}
-
+
List expectedJobEvents = new ArrayList();
expectedJobEvents.add("before");
expectedJobEvents.add("execute action");
expectedJobEvents.add("after");
-
+
assertEquals(expectedJobEvents, jobEvents);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/SwimlaneDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/SwimlaneDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/SwimlaneDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -33,10 +33,10 @@
Swimlane buyer;
Task laundry;
Task dishes;
-
+
protected void setUp() throws Exception {
super.setUp();
-
+
processDefinition = new ProcessDefinition();
taskMgmtDefinition = new TaskMgmtDefinition();
processDefinition.addDefinition(taskMgmtDefinition);
@@ -44,10 +44,8 @@
laundry = new Task("laundry");
dishes = new Task("dishes");
}
-
- @Override
- protected void tearDown() throws Exception
- {
+
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
@@ -55,11 +53,11 @@
public void testSwimlaneAddTask() {
buyer.addTask(laundry);
buyer.addTask(dishes);
-
+
processDefinition = saveAndReload(processDefinition);
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
-
- assertEquals(2,buyer.getTasks().size());
+
+ assertEquals(2, buyer.getTasks().size());
assertTrue(buyer.getTasks().contains(laundry));
assertTrue(buyer.getTasks().contains(dishes));
}
@@ -67,42 +65,40 @@
public void testSwimlaneAddTaskInverseReference() {
buyer.addTask(laundry);
buyer.addTask(dishes);
-
+
processDefinition = saveAndReload(processDefinition);
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
-
+
assertSame(buyer, laundry.getSwimlane());
assertSame(buyer, dishes.getSwimlane());
}
-
+
public void testTriangularRelation() {
buyer.addTask(laundry);
taskMgmtDefinition.addTask(laundry);
taskMgmtDefinition.addSwimlane(buyer);
-
+
processDefinition = saveAndReload(processDefinition);
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
laundry = taskMgmtDefinition.getTask("laundry");
- assertEquals(1,taskMgmtDefinition.getTasks().size());
- assertEquals(1,buyer.getTasks().size());
+ assertEquals(1, taskMgmtDefinition.getTasks().size());
+ assertEquals(1, buyer.getTasks().size());
assertEquals("laundry", laundry.getName());
assertSame(laundry, taskMgmtDefinition.getSwimlane("buyer").getTasks().iterator().next());
assertSame(taskMgmtDefinition, laundry.getTaskMgmtDefinition());
assertSame(taskMgmtDefinition.getSwimlane("buyer"), laundry.getSwimlane());
}
-
+
public void testSwimlaneAssignment() {
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <swimlane name='boss'>" +
- " <assignment class='org.jbpm.TheOneAndOnly' />" +
- " </swimlane>" +
- "</process-definition>"
- );
-
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <swimlane name='boss'>"
+ + " <assignment class='org.jbpm.TheOneAndOnly' />"
+ + " </swimlane>"
+ + "</process-definition>");
+
processDefinition = saveAndReload(processDefinition);
-
+
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
Swimlane boss = taskMgmtDefinition.getSwimlane("boss");
assertNotNull(boss);
@@ -114,16 +110,14 @@
}
public void testSwimlaneTaskMgmtTest() {
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <swimlane name='boss'>" +
- " <assignment class='org.jbpm.TheOneAndOnly' />" +
- " </swimlane>" +
- "</process-definition>"
- );
-
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <swimlane name='boss'>"
+ + " <assignment class='org.jbpm.TheOneAndOnly' />"
+ + " </swimlane>"
+ + "</process-definition>");
+
processDefinition = saveAndReload(processDefinition);
-
+
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
Swimlane boss = taskMgmtDefinition.getSwimlane("boss");
assertNotNull(boss);
@@ -131,26 +125,24 @@
}
public void testTaskToSwimlane() {
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <swimlane name='boss'>" +
- " <assignment class='org.jbpm.TheOneAndOnly' />" +
- " </swimlane>" +
- " <task-node name='work'>" +
- " <task name='manage' swimlane='boss' />" +
- " </task-node>" +
- "</process-definition>"
- );
-
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <swimlane name='boss'>"
+ + " <assignment class='org.jbpm.TheOneAndOnly' />"
+ + " </swimlane>"
+ + " <task-node name='work'>"
+ + " <task name='manage' swimlane='boss' />"
+ + " </task-node>"
+ + "</process-definition>");
+
processDefinition = saveAndReload(processDefinition);
-
+
taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
-
+
TaskNode work = (TaskNode) processDefinition.getNode("work");
Task manage = work.getTask("manage");
assertNotNull(manage);
assertSame(taskMgmtDefinition.getTask("manage"), manage);
-
+
assertNotNull(manage.getSwimlane());
assertSame(taskMgmtDefinition.getSwimlane("boss"), manage.getSwimlane());
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/TaskMgmtDefinitionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/TaskMgmtDefinitionDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/def/TaskMgmtDefinitionDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -24,8 +24,7 @@
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
-public class TaskMgmtDefinitionDbTest extends AbstractDbTestCase
-{
+public class TaskMgmtDefinitionDbTest extends AbstractDbTestCase {
ProcessDefinition processDefinition;
TaskMgmtDefinition taskMgmtDefinition;
@@ -34,8 +33,7 @@
Task laundry;
Task dishes;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
@@ -47,15 +45,12 @@
dishes = new Task("dishes");
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testTaskMgmtDefinitionAddSwimlanes()
- {
+ public void testTaskMgmtDefinitionAddSwimlanes() {
taskMgmtDefinition.addSwimlane(buyer);
taskMgmtDefinition.addSwimlane(seller);
@@ -67,8 +62,7 @@
assertEquals("seller", taskMgmtDefinition.getSwimlane("seller").getName());
}
- public void testTaskMgmtDefinitionAddSwimlaneInverseReference()
- {
+ public void testTaskMgmtDefinitionAddSwimlaneInverseReference() {
taskMgmtDefinition.addSwimlane(buyer);
taskMgmtDefinition.addSwimlane(seller);
@@ -79,8 +73,7 @@
assertSame(taskMgmtDefinition, taskMgmtDefinition.getSwimlane("seller").getTaskMgmtDefinition());
}
- public void testTaskMgmtDefinitionAddTasks()
- {
+ public void testTaskMgmtDefinitionAddTasks() {
taskMgmtDefinition.addTask(laundry);
taskMgmtDefinition.addTask(dishes);
@@ -92,8 +85,7 @@
assertEquals("dishes", taskMgmtDefinition.getTask("dishes").getName());
}
- public void testTaskMgmtDefinitionAddTasksInverseReference()
- {
+ public void testTaskMgmtDefinitionAddTasksInverseReference() {
taskMgmtDefinition.addTask(laundry);
taskMgmtDefinition.addTask(dishes);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskMgmtInstanceDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskMgmtInstanceDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskMgmtInstanceDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,8 +30,7 @@
import org.jbpm.taskmgmt.def.Task;
import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
-public class TaskMgmtInstanceDbTest extends AbstractDbTestCase
-{
+public class TaskMgmtInstanceDbTest extends AbstractDbTestCase {
ProcessDefinition processDefinition;
TaskMgmtDefinition taskMgmtDefinition;
@@ -43,8 +42,7 @@
ProcessInstance processInstance;
TaskMgmtInstance taskMgmtInstance;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
processDefinition = new ProcessDefinition();
@@ -73,15 +71,12 @@
taskMgmtInstance = processInstance.getTaskMgmtInstance();
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testTaskMgmtInstanceTaskInstances()
- {
+ public void testTaskMgmtInstanceTaskInstances() {
taskMgmtInstance.createTaskInstance(laundry, processInstance.getRootToken());
taskMgmtInstance.createTaskInstance(dishes, processInstance.getRootToken());
@@ -90,8 +85,7 @@
assertEquals(2, taskMgmtInstance.getTaskInstances().size());
}
- public void testTaskMgmtInstanceSwimlaneInstances()
- {
+ public void testTaskMgmtInstanceSwimlaneInstances() {
SwimlaneInstance swimlaneInstance = taskMgmtInstance.createSwimlaneInstance(buyer);
swimlaneInstance.setActorId("john doe");
@@ -104,12 +98,11 @@
assertEquals(2, taskMgmtInstance.getSwimlaneInstances().size());
}
- public static class MultipleAssignmentHandler implements AssignmentHandler
- {
+ public static class MultipleAssignmentHandler implements AssignmentHandler {
+
private static final long serialVersionUID = 1L;
- public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception
- {
+ public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
assignable.setPooledActors(new String[] { "me", "you", "them" });
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -37,6 +37,7 @@
static int counter = 0;
public static class PlusPlus implements ActionHandler {
+
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
@@ -102,11 +103,11 @@
newTransaction();
- List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
+ List taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
.getId());
assertEquals(1, taskInstances.size());
- TaskInstance taskInstance = taskInstances.get(0);
+ TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
taskInstance.end();
jbpmContext.save(taskInstance);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,17 +29,15 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
-public class TaskVariablesDbTest extends AbstractDbTestCase
-{
- public void testDefaultVariablePersistence()
- {
+public class TaskVariablesDbTest extends AbstractDbTestCase {
+
+ public void testDefaultVariablePersistence() {
ProcessDefinition processDefinition = ProcessDefinition.createNewProcessDefinition();
processDefinition.setName("default variable persistence");
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createTaskInstance(
processInstance.getRootToken());
@@ -49,14 +47,12 @@
assertNotNull(taskInstance);
assertEquals("value", taskInstance.getVariable("key"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testSetOnTaskInstanceGetOnProcess()
- {
+ public void testSetOnTaskInstanceGetOnProcess() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set on task get on process'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -68,19 +64,18 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
processInstance = saveAndReload(processInstance);
ContextInstance contextInstance = processInstance.getContextInstance();
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
- Map<String, Object> expectedVariables = new HashMap<String, Object>();
+ Map expectedVariables = new HashMap();
assertEquals(expectedVariables, taskInstance.getVariables());
assertFalse(taskInstance.hasVariable("a"));
@@ -99,14 +94,12 @@
assertEquals("1", taskInstance.getVariable("a"));
assertEquals("1", contextInstance.getVariable("a"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testSetOnProcessGetOnTaskInstance()
- {
+ public void testSetOnProcessGetOnTaskInstance() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set on process get on task'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -118,21 +111,20 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
processInstance = saveAndReload(processInstance);
ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("a", "1");
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
taskInstance = saveAndReload(taskInstance);
- Map<String, Object> expectedVariables = new HashMap<String, Object>();
+ Map expectedVariables = new HashMap();
expectedVariables.put("a", "1");
assertEquals(expectedVariables, taskInstance.getVariables());
@@ -143,14 +135,12 @@
assertEquals("1", taskInstance.getVariable("a"));
assertEquals("1", contextInstance.getVariable("a"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testSetLocally()
- {
+ public void testSetLocally() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set locally'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -162,11 +152,10 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
@@ -174,7 +163,7 @@
taskInstance = saveAndReload(taskInstance);
ContextInstance contextInstance = taskInstance.getContextInstance();
- Map<String, Object> expectedVariables = new HashMap<String, Object>();
+ Map expectedVariables = new HashMap();
assertEquals(expectedVariables, taskInstance.getVariables());
assertFalse(taskInstance.hasVariable("a"));
assertNull(taskInstance.getVariable("a"));
@@ -192,14 +181,12 @@
assertEquals("1", taskInstance.getVariable("a"));
assertNull(contextInstance.getVariable("a"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testCopyWithController()
- {
+ public void testCopyWithController() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='copy with controller'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -216,8 +203,7 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("a", "1");
@@ -225,14 +211,14 @@
contextInstance.setVariable("c", "3");
processInstance.signal();
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
taskInstance = saveAndReload(taskInstance);
- Map<String, Object> expectedVariables = new HashMap<String, Object>();
+ Map expectedVariables = new HashMap();
expectedVariables.put("a", "1");
expectedVariables.put("b", "2");
expectedVariables.put("c", "3");
@@ -259,14 +245,12 @@
expectedVariables.put("c", "3 modified");
assertEquals(expectedVariables, contextInstance.getVariables());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testOverwriteNullValue()
- {
+ public void testOverwriteNullValue() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='overwrite-null-value'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -282,13 +266,12 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
processInstance = saveAndReload(processInstance);
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
@@ -299,14 +282,12 @@
taskInstance = saveAndReload(taskInstance);
assertEquals("facelets is great", taskInstance.getVariable("v"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public void testNewTaskInstanceVariablesWithoutController()
- {
+ public void testNewTaskInstanceVariablesWithoutController() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='task variables without controller'>"
+ " <start-state>"
+ " <transition to='t' />"
@@ -320,12 +301,11 @@
jbpmContext.deployProcessDefinition(processDefinition);
newTransaction();
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ TaskInstance taskInstance = (TaskInstance) processInstance.getTaskMgmtInstance()
.getTaskInstances()
.iterator()
.next();
@@ -352,8 +332,7 @@
assertEquals("value-a", contextInstance.getVariable("a"));
assertEquals("value-b", contextInstance.getVariable("b"));
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/log/SwimlaneLogDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/log/SwimlaneLogDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/taskmgmt/log/SwimlaneLogDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -24,46 +24,40 @@
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.taskmgmt.exe.SwimlaneInstance;
-public class SwimlaneLogDbTest extends AbstractDbTestCase
-{
+public class SwimlaneLogDbTest extends AbstractDbTestCase {
SwimlaneInstance swimlaneInstance = null;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
swimlaneInstance = new SwimlaneInstance();
session.save(swimlaneInstance);
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
session.delete(swimlaneInstance);
super.tearDown();
}
- public void testSwimlaneCreateLog()
- {
+ public void testSwimlaneCreateLog() {
SwimlaneCreateLog slLog = new SwimlaneCreateLog(swimlaneInstance, "you");
session.save(slLog);
newTransaction();
- slLog = (SwimlaneCreateLog)session.load(SwimlaneCreateLog.class, new Long(slLog.getId()));
+ slLog = (SwimlaneCreateLog) session.load(SwimlaneCreateLog.class, new Long(slLog.getId()));
assertNotNull(slLog);
assertNotNull(slLog.getSwimlaneInstance());
session.delete(slLog);
}
- public void testSwimlaneAssignLog()
- {
+ public void testSwimlaneAssignLog() {
SwimlaneAssignLog slLog = new SwimlaneAssignLog(swimlaneInstance, "me", "toyou");
session.save(slLog);
newTransaction();
- slLog = (SwimlaneAssignLog)session.load(SwimlaneAssignLog.class, new Long(slLog.getId()));
+ slLog = (SwimlaneAssignLog) session.load(SwimlaneAssignLog.class, new Long(slLog.getId()));
assertNotNull(slLog);
assertNotNull(slLog.getSwimlaneInstance());
assertEquals("me", (slLog.getSwimlaneOldActorId()));
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/context/exe/CustomSerializable.zip
===================================================================
(Binary files differ)
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/db/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/db/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/db/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/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"/>
-</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/db/.project
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/db/.project 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/db/.project 2009-05-04 09:33:28 UTC (rev 4706)
@@ -6,18 +6,12 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/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"/>
-</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.project
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.project 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/.project 2009-05-04 09:33:28 UTC (rev 4706)
@@ -6,18 +6,12 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/pom.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/pom.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -154,11 +154,6 @@
<artifactId>ant</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.birt</groupId>
- <artifactId>report-engine</artifactId>
- <type>zip</type>
- </dependency>
- <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
@@ -166,8 +161,6 @@
<groupId>izpack</groupId>
<artifactId>standalone-compiler</artifactId>
</dependency>
-
- <!-- Database Drivers -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@@ -176,6 +169,8 @@
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
+
+ <!-- Database Drivers -->
</dependencies>
<!-- Plugins -->
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/ant-actions-spec.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/ant-actions-spec.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/ant-actions-spec.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,11 +1,11 @@
<antactions>
- <pack name="Download JBoss-5.0.0">
+ <pack name="Download JBoss-5.0.1">
<antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
<property name="install.path" value="$INSTALL_PATH"/>
<target name="download-jboss"/>
</antcall>
</pack>
- <pack name="Download Eclipse-3.4.0">
+ <pack name="Download Eclipse-3.4.2">
<antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
<property name="install.path" value="$INSTALL_PATH"/>
<target name="download-eclipse"/>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/auto-install-template.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/auto-install-template.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/auto-install-template.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -9,8 +9,8 @@
<pack name="JSF-Console" index="2" selected="true"/>
<pack name="GWT-Console" index="3" selected="true"/>
<pack name="Optional Components" index="4" selected="false"/>
- <pack name="Download JBoss-5.0.0" index="5" selected="false"/>
- <pack name="Download Eclipse-3.4.0" index="6" selected="false"/>
+ <pack name="Download JBoss-5.0.1" index="5" selected="false"/>
+ <pack name="Download Eclipse-3.4.2" index="6" selected="false"/>
</com.izforge.izpack.panels.TreePacksPanel>
<com.izforge.izpack.panels.UserInputPanel>
<userInput>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/download-helper.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/download-helper.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/download-helper.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -13,11 +13,11 @@
<project>
<target name="download-jboss">
- <get src="http://downloads.sourceforge.net/jboss/jboss-5.0.0.GA.zip?modtime=1228452561&big_mirror=1" dest="${install.path}/Uninstaller/jboss-5.0.0.GA.zip" usetimestamp="true"/>
- <unzip src="${install.path}/Uninstaller/jboss-5.0.0.GA.zip" dest="${install.path}"/>
+ <get src="http://downloads.sourceforge.net/jboss/jboss-5.0.1.GA.zip" dest="${install.path}/Uninstaller/jboss-5.0.1.GA.zip" usetimestamp="true"/>
+ <unzip src="${install.path}/Uninstaller/jboss-5.0.1.GA.zip" dest="${install.path}"/>
</target>
<target name="download-eclipse">
- <get src="http://download.eclipse.org/technology/epp/downloads/release/ganymede/R/eclipse-java-ganymede-linux-gtk.tar.gz"
+ <get src="http://mirrors.ibiblio.org/pub/mirrors/eclipse/technology/epp/downloads/release/ganymede/SR2/eclipse-java-ganymede-SR2-linux-gtk.tar.gz"
dest="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" usetimestamp="true"/>
<untar src="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" dest="${install.path}" compression="gzip"/>
</target>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/install-definition.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/install-definition.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -38,32 +38,32 @@
<!-- Variables -->
<variables>
- <variable name="jboss422.home" value="@{jboss422.home}" />
+ <variable name="jboss405.home" value="@{jboss405.home}" />
<variable name="jboss423.home" value="@{jboss423.home}" />
- <variable name="jboss500.home" value="@{jboss500.home}" />
+ <variable name="jboss501.home" value="@{jboss501.home}" />
</variables>
<!-- Dynamic Variables -->
<dynamicvariables>
- <variable name="jboss.home" value="${jboss422.home}" condition="isJBoss422" />
+ <variable name="jboss.home" value="${jboss405.home}" condition="isJBoss405" />
<variable name="jboss.home" value="${jboss423.home}" condition="isJBoss423" />
- <variable name="jboss.home" value="${jboss500.home}" condition="isJBoss500" />
+ <variable name="jboss.home" value="${jboss501.home}" condition="isJBoss501" />
</dynamicvariables>
<!-- Conditions -->
<conditions>
<!-- Target Server Conditions -->
- <condition type="variable" id="isJBoss422">
+ <condition type="variable" id="isJBoss405">
<name>jbossSelection</name>
- <value>jboss422</value>
+ <value>jboss405</value>
</condition>
<condition type="variable" id="isJBoss423">
<name>jbossSelection</name>
<value>jboss423</value>
</condition>
- <condition type="variable" id="isJBoss500">
+ <condition type="variable" id="isJBoss501">
<name>jbossSelection</name>
- <value>jboss500</value>
+ <value>jboss501</value>
</condition>
<!-- Target Database Conditions -->
@@ -322,16 +322,16 @@
<description>Optional jBPM3 Components</description>
</pack>
- <!-- JBoss-5.0.0 -->
- <pack name="Download JBoss-5.0.0" required="no" parent="Optional Components" preselected="no">
- <description>Download and Install JBoss-5.0.0</description>
+ <!-- JBoss-5.0.1 -->
+ <pack name="Download JBoss-5.0.1" required="no" parent="Optional Components" preselected="no">
+ <description>Download and Install JBoss-5.0.1</description>
<!-- http://jira.codehaus.org/browse/IZPACK-158 -->
<file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/Uninstaller"/>
</pack>
- <!-- Eclipse-3.4.0 -->
- <pack name="Download Eclipse-3.4.0" required="no" parent="Optional Components" preselected="no">
- <description>Download and Install Eclipse-3.4.0</description>
+ <!-- Eclipse-3.4.2 -->
+ <pack name="Download Eclipse-3.4.2" required="no" parent="Optional Components" preselected="no">
+ <description>Download and Install Eclipse-3.4.2</description>
<!-- http://jira.codehaus.org/browse/IZPACK-158 -->
<file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/Uninstaller"/>
</pack>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/user-input-spec.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/user-input-spec.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/distribution/src/main/resources/installer/user-input-spec.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,9 +4,9 @@
<field type="radio" variable="jbossSelection">
<description align="left" txt="Please choose your target server" />
<spec>
- <choice txt="JBoss-5.0.0" value="jboss500" set="true"/>
+ <choice txt="JBoss-5.0.1" value="jboss501" set="true"/>
<choice txt="JBoss-4.2.3" value="jboss423"/>
- <choice txt="JBoss-4.2.2" value="jboss422"/>
+ <choice txt="JBoss-4.0.5" value="jboss405"/>
</spec>
</field>
<field type="text" variable="jbossTargetServer">
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,7 +4,7 @@
<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.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/pom.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/pom.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -43,16 +43,11 @@
<!-- Provided Dependencies -->
<dependency>
- <groupId>javax.ejb</groupId>
- <artifactId>ejb-api</artifactId>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>provided</scope>
@@ -62,8 +57,6 @@
<artifactId>hibernate</artifactId>
<scope>provided</scope>
</dependency>
-
- <!-- Test Dependencies -->
<dependency>
<groupId>org.apache.cactus</groupId>
<artifactId>cactus.core.framework.wrapper.javaEE.14</artifactId>
@@ -91,16 +84,8 @@
<artifactId>jbossall-client</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.bpm</groupId>
- <artifactId>bpm-spec-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
+
+ <!-- Test Dependencies -->
</dependencies>
<!-- Plugins -->
@@ -326,12 +311,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- [JBPM-1818] Use Sybase instance that supports XA Transaction -->
- <exclude>org/jbpm/enterprise/deployment/DeploymentPARTest.java</exclude>
- </excludes>
- </configuration>
</plugin>
</plugins>
</build>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -23,7 +23,6 @@
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.Arrays;
import java.util.List;
import javax.jms.Destination;
@@ -35,6 +34,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
import org.jbpm.db.JobSession;
@@ -42,9 +42,11 @@
import org.jbpm.msg.jms.JmsMessageService;
import org.jbpm.msg.jms.JmsMessageServiceFactory;
import org.jbpm.svc.Services;
+import org.jbpm.util.ArrayUtil;
/**
* Individual job processing command.
+ *
* @author Alejandro Guizar
*/
public class ExecuteJobCommand implements Command {
@@ -85,9 +87,9 @@
exclusiveJob.setLockOwner(lockOwner);
exclusiveJobIds[i] = exclusiveJob.getId();
}
- log.debug("locking jobs " + Arrays.toString(exclusiveJobIds));
+ log.debug("locking jobs " + ArrayUtil.toString(exclusiveJobIds));
// execute exclusive jobs in separate transaction
- postJobsExecution(jbpmContext, exclusiveJobIds);
+ postJobsExecution(jbpmContext, exclusiveJobIds);
}
else {
// lock job to prevent others from deleting it
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobsCommand.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,18 +21,20 @@
*/
package org.jbpm.ejb.impl;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
import org.jbpm.job.Job;
+import org.jbpm.util.ArrayUtil;
/**
* Batch job processing command.
+ *
* @author Alejandro Guizar
*/
public class ExecuteJobsCommand implements Command {
@@ -47,7 +49,7 @@
}
public Object execute(JbpmContext jbpmContext) throws Exception {
- log.debug("executing jobs " + Arrays.toString(jobIds));
+ log.debug("executing jobs " + ArrayUtil.toString(jobIds));
List jobs = jbpmContext.getJobSession().loadJobs(jobIds);
for (Iterator i = jobs.iterator(); i.hasNext();) {
Job job = (Job) i.next();
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ArchiveDeployer.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ArchiveDeployer.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ArchiveDeployer.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,43 @@
+/*
+ * 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.enterprise;
+
+import java.net.URL;
+
+/**
+ * An archive deployer
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 16-May-2006
+ */
+public interface ArchiveDeployer {
+
+ /**
+ * Deploy the given archive
+ */
+ void deploy(URL archive) throws Exception;
+
+ /**
+ * Undeploy the given archive
+ */
+ void undeploy(URL archive) throws Exception;
+}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestHelper.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestHelper.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,169 @@
+/*
+ * 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.enterprise;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.management.JMException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jbpm.JbpmException;
+
+/**
+ * An integration test helper that deals with test deployment/undeployment, etc.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestHelper {
+
+ private String testResourcesDir;
+ private String testArchiveDir;
+ private String integrationTarget;
+
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+
+ private static MBeanServerConnection server;
+
+ public String getTestResourcesDir() {
+ if (testResourcesDir == null) {
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
+ }
+ return testResourcesDir;
+ }
+
+ /** Try to discover the File for the test resource */
+ public File getResourceFile(String resource) {
+ File file = new File(resource);
+ if (file.exists()) return file;
+
+ file = new File(getTestResourcesDir() + "/" + resource);
+ if (file.exists()) return file;
+
+ throw new IllegalArgumentException("Cannot obtain '"
+ + getTestResourcesDir()
+ + "/"
+ + resource
+ + "'");
+ }
+
+ public String getTestArchiveDir() {
+ if (testArchiveDir == null) {
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+ }
+ return testArchiveDir;
+ }
+
+ /** Try to discover the File for the deployment archive */
+ public File getTestArchiveFile(String archive) {
+ File file = new File(archive);
+ if (file.exists()) return file;
+
+ file = new File(getTestArchiveDir() + "/" + archive);
+ if (file.exists()) return file;
+
+ String notSet = getTestArchiveDir() == null ? " System property '"
+ + SYSPROP_TEST_ARCHIVE_DIRECTORY
+ + "' not set." : "";
+ throw new IllegalArgumentException("Cannot obtain '"
+ + getTestArchiveDir()
+ + "/"
+ + archive
+ + "'."
+ + notSet);
+ }
+
+ public void deploy(String archive) throws Exception {
+ URL url = getTestArchiveFile(archive).toURI().toURL();
+ deploy(url);
+ }
+
+ public void deploy(URL archive) throws Exception {
+ getDeployer().deploy(archive);
+ }
+
+ public void undeploy(String archive) throws Exception {
+ URL url = getTestArchiveFile(archive).toURI().toURL();
+ undeploy(url);
+ }
+
+ public void undeploy(URL archive) throws Exception {
+ getDeployer().undeploy(archive);
+ }
+
+ public String getIntegrationTarget() {
+ if (integrationTarget == null) {
+ String jbossVersion;
+ try {
+ ObjectName oname = ObjectNameFactory.create("jboss.system:type=Server");
+ jbossVersion = (String) getServer().getAttribute(oname, "Version");
+ }
+ catch (JMException e) {
+ throw new JbpmException("cannot obtain jboss version", e);
+ }
+ catch (IOException e) {
+ throw new JbpmException("cannot obtain jboss version", e);
+ }
+
+ if (jbossVersion.startsWith("5.0.1"))
+ integrationTarget = "jboss501";
+ if (jbossVersion.startsWith("5.0.0"))
+ integrationTarget = "jboss500";
+ else if (jbossVersion.startsWith("4.2.3"))
+ integrationTarget = "jboss423";
+ else if (jbossVersion.startsWith("4.2.2"))
+ integrationTarget = "jboss422";
+ else if (jbossVersion.startsWith("4.0.5"))
+ integrationTarget = "jboss405";
+ else
+ throw new JbpmException("unsupported jboss version: " + jbossVersion);
+ }
+ return integrationTarget;
+ }
+
+ public MBeanServerConnection getServer() {
+ if (server == null) {
+ Hashtable jndiEnv = null;
+ try {
+ InitialContext iniCtx = new InitialContext();
+ jndiEnv = iniCtx.getEnvironment();
+ server = (MBeanServerConnection) iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex) {
+ throw new RuntimeException("Cannot obtain MBeanServerConnection using jndi props: "
+ + jndiEnv, ex);
+ }
+ }
+ return server;
+ }
+
+ private ArchiveDeployer getDeployer() {
+ return new JBossArchiveDeployer(getServer());
+ }
+}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestSetup.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestSetup.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/IntegrationTestSetup.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,120 @@
+/*
+ * 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.enterprise;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+
+import junit.extensions.TestSetup;
+import junit.framework.TestSuite;
+
+/**
+ * A test setup that deploys/undeploys archives
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestSetup extends TestSetup {
+
+ private IntegrationTestHelper delegate = new IntegrationTestHelper();
+ private String[] archives = new String[0];
+ private ClassLoader originalClassLoader;
+
+ public IntegrationTestSetup(Class testClass, String archiveList) {
+ super(new TestSuite(testClass));
+ getArchiveArray(archiveList);
+ }
+
+ public File getArchiveFile(String archive) {
+ return delegate.getTestArchiveFile(archive);
+ }
+
+ public URL getArchiveURL(String archive) throws MalformedURLException {
+ return delegate.getTestArchiveFile(archive).toURI().toURL();
+ }
+
+ public MBeanServerConnection getServer() {
+ return delegate.getServer();
+ }
+
+ private void getArchiveArray(String archiveList) {
+ if (archiveList != null) {
+ StringTokenizer st = new StringTokenizer(archiveList, ", ");
+ archives = new String[st.countTokens()];
+
+ for (int i = 0; i < archives.length; i++)
+ archives[i] = st.nextToken();
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ List clientJars = new ArrayList();
+ for (int i = 0; i < archives.length; i++) {
+ String archive = archives[i];
+ try {
+ delegate.deploy(archive);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ delegate.undeploy(archive);
+ }
+
+ if (archive.endsWith("-client.jar")) {
+ URL archiveURL = getArchiveURL(archive);
+ clientJars.add(archiveURL);
+ }
+ }
+
+ ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ originalClassLoader = parent;
+
+ // add client jars to the class loader
+ if (!clientJars.isEmpty()) {
+ URL[] urls = new URL[clientJars.size()];
+ clientJars.toArray(urls);
+ URLClassLoader cl = new URLClassLoader(urls, parent);
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ try {
+ for (int i = 0; i < archives.length; i++) {
+ String archive = archives[archives.length - i - 1];
+ delegate.undeploy(archive);
+ }
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
+ }
+ super.tearDown();
+ }
+}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/JBossArchiveDeployer.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/JBossArchiveDeployer.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/JBossArchiveDeployer.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,57 @@
+/*
+ * 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.enterprise;
+
+import java.net.URL;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+/**
+ * An archive deployer that deals with test deployment/undeployment, etc.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class JBossArchiveDeployer implements ArchiveDeployer {
+
+ private MBeanServerConnection server;
+
+ private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
+
+ public JBossArchiveDeployer(MBeanServerConnection server) {
+ this.server = server;
+ }
+
+ public void deploy(URL url) throws Exception {
+ invokeMainDeployer("deploy", url);
+ }
+
+ public void undeploy(URL url) throws Exception {
+ invokeMainDeployer("undeploy", url);
+ }
+
+ private void invokeMainDeployer(String methodName, URL url) throws Exception {
+ server.invoke(new ObjectName(MAIN_DEPLOYER), methodName, new Object[] { url },
+ new String[] { "java.net.URL" });
+ }
+}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ObjectNameFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ObjectNameFactory.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ObjectNameFactory.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,63 @@
+/*
+ * 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.enterprise;
+
+import java.util.Hashtable;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * A simple factory for creating safe object names.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 08-May-2006
+ */
+public class ObjectNameFactory {
+
+ public static ObjectName create(String name) {
+ try {
+ return new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + name + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, String key, String value) {
+ try {
+ return new ObjectName(domain, key, value);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, Hashtable table) {
+ try {
+ return new ObjectName(domain, table);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
+ }
+ }
+}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/AppServerConfigurationsTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -24,49 +24,51 @@
import junit.framework.Test;
import org.apache.cactus.ServletTestCase;
+
import org.jbpm.JbpmConfiguration;
-import org.jboss.bpm.api.test.IntegrationTestSetup;
+import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.msg.jms.JmsMessageServiceFactory;
import org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory;
import org.jbpm.scheduler.ejbtimer.EntitySchedulerServiceFactory;
import org.jbpm.svc.Services;
-public class AppServerConfigurationsTest extends ServletTestCase
-{
+public class AppServerConfigurationsTest extends ServletTestCase {
+
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- public static Test suite() throws Exception
- {
- return new IntegrationTestSetup(AppServerConfigurationsTest.class, "enterprise-test.war");
+ public static Test suite() throws Exception {
+ return new IntegrationTestSetup(AppServerConfigurationsTest.class, "enterprise-test.war");
}
-
- public void testUnavailabilityOfTheJobExecutor()
- {
+
+ public void testUnavailabilityOfTheJobExecutor() {
assertNull(jbpmConfiguration.getJobExecutor());
}
- public void testJtaDbPersistenceFactoryConfiguration()
- {
+ public void testJtaDbPersistenceFactoryConfiguration() {
String expService = JtaDbPersistenceServiceFactory.class.getName();
- String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE).getClass().getName();
+ String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE)
+ .getClass()
+ .getName();
assertEquals(expService, wasService);
-
- JtaDbPersistenceServiceFactory persistenceServiceFactory = (JtaDbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+
+ JtaDbPersistenceServiceFactory persistenceServiceFactory = (JtaDbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
assertFalse(persistenceServiceFactory.isTransactionEnabled());
assertTrue(persistenceServiceFactory.isCurrentSessionEnabled());
}
- public void testJmsMessageServiceFactoryConfiguration()
- {
+ public void testJmsMessageServiceFactoryConfiguration() {
String expService = JmsMessageServiceFactory.class.getName();
- String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_MESSAGE).getClass().getName();
+ String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_MESSAGE)
+ .getClass()
+ .getName();
assertEquals(expService, wasService);
}
- public void testEjbSchedulerServiceFactoryConfiguration()
- {
+ public void testEjbSchedulerServiceFactoryConfiguration() {
String expService = EntitySchedulerServiceFactory.class.getName();
- String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_SCHEDULER).getClass().getName();
+ String wasService = jbpmConfiguration.getServiceFactory(Services.SERVICENAME_SCHEDULER)
+ .getClass()
+ .getName();
assertEquals(expService, wasService);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/ContainerProvidedJarsTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/ContainerProvidedJarsTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/config/ContainerProvidedJarsTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -21,20 +21,19 @@
*/
package org.jbpm.enterprise.config;
-// $Id$
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import javax.management.ObjectName;
import junit.framework.TestCase;
-import org.jboss.bpm.api.model.ObjectNameFactory;
-import org.jboss.bpm.api.test.IntegrationTestHelper;
+import org.jbpm.enterprise.IntegrationTestHelper;
+import org.jbpm.enterprise.ObjectNameFactory;
/**
* Test that there are jars deployed which should in fact be provided by the container
@@ -42,58 +41,38 @@
* @author thomas.diesler at jboss.com
* @since 23-Sep-2008
*/
-public class ContainerProvidedJarsTest extends TestCase
-{
+public class ContainerProvidedJarsTest extends TestCase {
+
IntegrationTestHelper delegate = new IntegrationTestHelper();
-
- public void testDependencies() throws Exception
- {
- String targetContainer = null;
- if (delegate.isTargetJBoss422())
- {
- targetContainer = "jboss422";
- }
- else if (delegate.isTargetJBoss423())
- {
- targetContainer = "jboss423";
- }
- else if (delegate.isTargetJBoss500())
- {
- targetContainer = "jboss500";
- }
- assertNotNull("System property 'target.container' not null", targetContainer);
- assertTrue("Supported target.container: " + targetContainer, "jboss422,jboss423,jboss500".indexOf(targetContainer) >= 0);
+ public void testDependencies() throws Exception {
+ String targetContainer = delegate.getIntegrationTarget();
File jbossJars = delegate.getResourceFile(targetContainer + "-dependencies.txt");
assertTrue("JBoss jar fixture exists: " + jbossJars, jbossJars.exists());
// Read the JBoss ServerHomeDir
ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
- File serverHomeDir = (File)delegate.getServer().getAttribute(oname, "ServerHomeDir");
- if (serverHomeDir == null)
- throw new IllegalStateException("Cannot obtain jboss home dir");
+ File serverHomeDir = (File) delegate.getServer().getAttribute(oname, "ServerHomeDir");
+ if (serverHomeDir == null) throw new IllegalStateException("Cannot obtain jboss home dir");
File jbpmDir = new File(serverHomeDir + "/deploy/jbpm");
assertTrue("jBPM dir exists: " + jbpmDir, jbpmDir.exists());
-
- List<String> deployedJars = getDeployedJars(jbpmDir);
+ List deployedJars = getDeployedJars(jbpmDir);
+
// Iterate over the known server provided jars
- List<String> matchingJars = new ArrayList<String>();
+ List matchingJars = new ArrayList();
BufferedReader br = new BufferedReader(new FileReader(jbossJars));
String jbossJar = br.readLine();
- while (jbossJar != null)
- {
- if (jbossJar.length() == 0 || jbossJar.startsWith("#"))
- {
+ while (jbossJar != null) {
+ if (jbossJar.length() == 0 || jbossJar.startsWith("#")) {
jbossJar = br.readLine();
continue;
}
- for (String deployedJar : deployedJars)
- {
- if (deployedJar.startsWith(jbossJar))
- matchingJars.add(deployedJar);
+ for (Iterator i = deployedJars.iterator(); i.hasNext();) {
+ String deployedJar = (String) i.next();
+ if (deployedJar.startsWith(jbossJar)) matchingJars.add(deployedJar);
}
jbossJar = br.readLine();
}
@@ -101,20 +80,19 @@
assertEquals("Invalid deployed jars: " + matchingJars, 0, matchingJars.size());
}
- private List<String> getDeployedJars(File subdir)
- {
- List<String> deployedJars = new ArrayList<String>();
- for (File file : subdir.listFiles())
- {
- if (file.isDirectory())
- {
+ private List getDeployedJars(File subdir) {
+ List deployedJars = new ArrayList();
+ File[] files = subdir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (file.isDirectory()) {
deployedJars.addAll(getDeployedJars(file));
continue;
}
-
+
String fileName = file.getName();
- if (fileName.endsWith(".jar") && !fileName.startsWith("jbpm") && !fileName.startsWith("jboss-bpm"))
- {
+ if (fileName.endsWith(".jar")
+ && !fileName.startsWith("jbpm")) {
deployedJars.add(fileName);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -32,13 +32,14 @@
import org.apache.cactus.ServletTestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmContext;
-import org.jboss.bpm.api.test.IntegrationTestSetup;
import org.jbpm.command.Command;
import org.jbpm.command.DeployProcessCommand;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.EventCallback;
import org.jbpm.graph.def.ProcessDefinition;
@@ -272,7 +273,7 @@
private ProcessInstance launchProcess(String processName) throws RemoteException {
StartProcessInstanceCommand command = new StartProcessInstanceCommand();
- command.setProcessName(processName);
+ command.setProcessDefinitionName(processName);
command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
return (ProcessInstance) commandService.execute(command);
}
@@ -306,7 +307,7 @@
private static final long serialVersionUID = 1L;
public Object execute(JbpmContext jbpmContext) throws Exception {
- return jbpmContext.loadProcessInstance(processId).hasEnded();
+ return Boolean.valueOf(jbpmContext.loadProcessInstance(processId).hasEnded());
}
});
return isFinished.booleanValue();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jbpm1903/JBPM1903Test.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -37,13 +37,14 @@
import org.apache.cactus.ServletTestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.api.test.IntegrationTestSetup;
+
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
import org.jbpm.command.DeployProcessCommand;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.util.IoUtil;
@@ -61,7 +62,6 @@
return new IntegrationTestSetup(JBPM1903Test.class, "enterprise-test.war");
}
- @Override
protected void setUp() throws Exception {
if (commandServiceHome == null) {
Context initialContext = new InitialContext();
@@ -76,7 +76,6 @@
log.info("### " + getName() + " started ###");
}
- @Override
protected void tearDown() throws Exception {
log.info("### " + getName() + " done ###");
commandService = null;
@@ -118,6 +117,7 @@
private Object getVariable(final long processInstanceId, final String variableName) {
return commandService.execute(new Command() {
+
private static final long serialVersionUID = 1L;
public Object execute(JbpmContext jbpmContext) throws Exception {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -32,13 +32,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.Environment;
-import org.jboss.bpm.api.test.IntegrationTestSetup;
+
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
import org.jbpm.command.DeployProcessCommand;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.EventCallback;
import org.jbpm.graph.def.ProcessDefinition;
@@ -52,10 +53,8 @@
*
* @author Alejandro Guizar
*/
-public class JmsMessageTest extends ServletTestCase
-{
- private static Log log = LogFactory.getLog(JmsMessageTest.class);
-
+public class JmsMessageTest extends ServletTestCase {
+
private LocalCommandService commandService;
private static LocalCommandServiceHome commandServiceHome;
@@ -63,22 +62,19 @@
static final int processExecutionCount = 5;
static final int maxWaitTime = 10 * 1000;
- public static Test suite() throws Exception
- {
+ private static final Log log = LogFactory.getLog(JmsMessageTest.class);
+
+ public static Test suite() throws Exception {
return new IntegrationTestSetup(JmsMessageTest.class, "enterprise-test.war");
}
- protected void setUp() throws Exception
- {
- if (commandServiceHome == null)
- {
+ protected void setUp() throws Exception {
+ if (commandServiceHome == null) {
Context initialContext = new InitialContext();
- try
- {
- commandServiceHome = (LocalCommandServiceHome)initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
+ try {
+ commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/CommandServiceBean");
}
- finally
- {
+ finally {
initialContext.close();
}
}
@@ -86,15 +82,13 @@
log.info("### " + getName() + " started ###");
}
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
log.info("### " + getName() + " done ###");
commandService = null;
EventCallback.clear();
}
- public void testAsyncNode()
- {
+ public void testAsyncNode() {
deployProcess("<process-definition name='node'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
@@ -107,14 +101,13 @@
+ " </node>"
+ " <end-state name='end' />"
+ "</process-definition>");
-
+
long processId = launchProcess("node").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
assertTrue("Process has ended", hasProcessEnded(processId));
}
- public void testAsyncAction()
- {
+ public void testAsyncAction() {
deployProcess("<process-definition name='action'>"
+ " <start-state name='start'>"
+ " <transition to='a' />"
@@ -132,7 +125,7 @@
+ " </node>"
+ " <end-state name='end' />"
+ "</process-definition>");
-
+
long processId = launchProcess("action").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_LEAVE);
@@ -140,8 +133,7 @@
assertTrue("Process has ended", hasProcessEnded(processId));
}
- public void testAsyncSequence()
- {
+ public void testAsyncSequence() {
deployProcess("<process-definition name='sequence'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}'/>"
@@ -166,17 +158,15 @@
+ " </node>"
+ " <end-state name='end' />"
+ "</process-definition>");
-
+
long processId = launchProcess("sequence").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
assertTrue("Process has ended", hasProcessEnded(processId));
}
- public void testAsyncFork() throws Exception
- {
+ public void testAsyncFork() throws Exception {
// [JBPM-1811] JmsMessageTest fails intermittently on HSQLDB
- if (getHibernateDialect().indexOf("HSQL") != -1)
- {
+ if (getHibernateDialect().indexOf("HSQL") != -1) {
return;
}
@@ -214,28 +204,25 @@
+ " </join>"
+ " <end-state name='end' />"
+ "</process-definition>");
-
+
long processId = launchProcess("fork").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
assertTrue("Process has ended", hasProcessEnded(processId));
}
- private String getHibernateDialect()
- {
- return (String)commandService.execute(new Command()
- {
+ private String getHibernateDialect() {
+ return (String) commandService.execute(new Command() {
+
private static final long serialVersionUID = 1L;
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
- DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory)jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
return factory.getConfiguration().getProperty(Environment.DIALECT);
}
});
}
- public void testAsyncExecutions()
- {
+ public void testAsyncExecutions() {
deployProcess("<process-definition name='execution'>"
+ " <event type='process-end'>"
+ " <action expression='#{eventCallback.processEnd}' />"
@@ -266,10 +253,9 @@
+ " </node>"
+ " <end-state name='end' />"
+ "</process-definition>");
-
+
long[] processIds = new long[processExecutionCount];
- for (int i = 0; i < processExecutionCount; i++)
- {
+ for (int i = 0; i < processExecutionCount; i++) {
processIds[i] = launchProcess("execution").getId();
EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
}
@@ -277,36 +263,30 @@
EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_NODE_LEAVE);
EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_PROCESS_END);
- for (int i = 0; i < processExecutionCount; i++)
- {
+ for (int i = 0; i < processExecutionCount; i++) {
long processId = processIds[i];
- assertTrue("expected process " + processId + " to have ended",
- hasProcessEnded(processId));
+ assertTrue("expected process " + processId + " to have ended", hasProcessEnded(processId));
}
}
- private ProcessDefinition deployProcess(String xml)
- {
+ private ProcessDefinition deployProcess(String xml) {
return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
}
- private ProcessInstance launchProcess(String processName)
- {
+ private ProcessInstance launchProcess(String processName) {
StartProcessInstanceCommand command = new StartProcessInstanceCommand();
command.setProcessDefinitionName(processName);
command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
- return (ProcessInstance)commandService.execute(command);
+ return (ProcessInstance) commandService.execute(command);
}
- private boolean hasProcessEnded(final long processId)
- {
- Boolean isFinished = (Boolean)commandService.execute(new Command()
- {
+ private boolean hasProcessEnded(final long processId) {
+ Boolean isFinished = (Boolean) commandService.execute(new Command() {
+
private static final long serialVersionUID = 1L;
- public Object execute(JbpmContext jbpmContext) throws Exception
- {
- return jbpmContext.loadProcessInstance(processId).hasEnded();
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ return Boolean.valueOf(jbpmContext.loadProcessInstance(processId).hasEnded());
}
});
return isFinished.booleanValue();
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,15 +29,15 @@
import junit.framework.Test;
import org.apache.cactus.ServletTestCase;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
-import org.jboss.bpm.api.test.IntegrationTestSetup;
+import org.jbpm.enterprise.IntegrationTestSetup;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.persistence.jta.JtaDbPersistenceService;
-public class JtaDbPersistenceTest extends ServletTestCase
-{
+public class JtaDbPersistenceTest extends ServletTestCase {
private JbpmConfiguration jbpmConfiguration;
private UserTransaction tx;
@@ -45,38 +45,32 @@
private static long definitionId;
- public static Test suite() throws Exception
- {
+ public static Test suite() throws Exception {
return new IntegrationTestSetup(JtaDbPersistenceTest.class, "enterprise-test.war");
}
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
jbpmConfiguration = JbpmConfiguration.getInstance();
}
- public void testUserTx() throws Exception
- {
+ public void testUserTx() throws Exception {
tx = getUserTransaction();
testServiceTx();
}
- public void testUserTxRollback() throws Exception
- {
+ public void testUserTxRollback() throws Exception {
tx = getUserTransaction();
testServiceTxRollback();
}
- public void testServiceTx() throws Exception
- {
+ public void testServiceTx() throws Exception {
long definitionId = deployProcess();
long instanceId = launchProcess(definitionId);
signal(instanceId);
assertTrue(hasEnded(instanceId));
}
- public void testServiceTxRollback() throws Exception
- {
+ public void testServiceTxRollback() throws Exception {
rollback = true;
long definitionId = deployProcess();
long instanceId = launchProcess(definitionId);
@@ -84,177 +78,134 @@
assertFalse(hasEnded(instanceId));
}
- private long deployProcess() throws Exception
- {
- if (definitionId == 0)
- {
- try
- {
- if (tx != null)
- tx.begin();
+ private long deployProcess() throws Exception {
+ if (definitionId == 0) {
+ try {
+ if (tx != null) tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- ProcessDefinition definition = ProcessDefinition.parseXmlString(
- "<process-definition name='tx'>" +
- " <start-state name='start'>" +
- " <transition to='midway' />" +
- " </start-state>" +
- " <state name='midway'>" +
- " <transition to='end' />" +
- " </state>" +
- " <end-state name='end' />" +
- "</process-definition>");
+ ProcessDefinition definition = ProcessDefinition.parseXmlString("<process-definition name='tx'>"
+ + " <start-state name='start'>"
+ + " <transition to='midway' />"
+ + " </start-state>"
+ + " <state name='midway'>"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(definition);
definitionId = definition.getId();
}
- catch (RuntimeException e)
- {
- if (tx == null)
- jbpmContext.setRollbackOnly();
+ catch (RuntimeException e) {
+ if (tx == null) jbpmContext.setRollbackOnly();
throw e;
}
- finally
- {
+ finally {
jbpmContext.close();
}
- if (tx != null)
- tx.commit();
+ if (tx != null) tx.commit();
}
- catch (Exception e)
- {
- if (tx != null)
- tx.rollback();
+ catch (Exception e) {
+ if (tx != null) tx.rollback();
throw e;
}
}
return definitionId;
}
- private long launchProcess(long definitionId) throws Exception
- {
- try
- {
- if (tx != null)
- tx.begin();
+ private long launchProcess(long definitionId) throws Exception {
+ try {
+ if (tx != null) tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
ProcessInstance instance;
- try
- {
+ try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
- ProcessDefinition definition = jbpmContext.getGraphSession().loadProcessDefinition(definitionId);
+ ProcessDefinition definition = jbpmContext.getGraphSession().loadProcessDefinition(
+ definitionId);
instance = new ProcessInstance(definition);
instance.signal();
jbpmContext.save(instance);
}
- catch (RuntimeException e)
- {
- if (tx == null)
- jbpmContext.setRollbackOnly();
+ catch (RuntimeException e) {
+ if (tx == null) jbpmContext.setRollbackOnly();
throw e;
}
- finally
- {
+ finally {
jbpmContext.close();
}
- if (tx != null)
- tx.commit();
+ if (tx != null) tx.commit();
return instance.getId();
}
- catch (Exception e)
- {
- if (tx != null)
- tx.rollback();
+ catch (Exception e) {
+ if (tx != null) tx.rollback();
throw e;
}
}
- private void signal(long instanceId) throws Exception
- {
- try
- {
- if (tx != null)
- tx.begin();
+ private void signal(long instanceId) throws Exception {
+ try {
+ if (tx != null) tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
ProcessInstance instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
instance.signal();
- if (rollback && tx == null)
- jbpmContext.setRollbackOnly();
+ if (rollback && tx == null) jbpmContext.setRollbackOnly();
}
- catch (RuntimeException e)
- {
- if (tx == null)
- jbpmContext.setRollbackOnly();
+ catch (RuntimeException e) {
+ if (tx == null) jbpmContext.setRollbackOnly();
throw e;
}
- finally
- {
+ finally {
jbpmContext.close();
}
- if (tx != null)
- {
+ if (tx != null) {
if (rollback)
tx.rollback();
else
tx.commit();
}
}
- catch (Exception e)
- {
- if (tx != null)
- tx.rollback();
+ catch (Exception e) {
+ if (tx != null) tx.rollback();
throw e;
}
}
- private boolean hasEnded(long instanceId) throws Exception
- {
- try
- {
- if (tx != null)
- tx.begin();
+ private boolean hasEnded(long instanceId) throws Exception {
+ try {
+ if (tx != null) tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
ProcessInstance instance;
- try
- {
+ try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
}
- catch (RuntimeException e)
- {
- if (tx == null)
- jbpmContext.setRollbackOnly();
+ catch (RuntimeException e) {
+ if (tx == null) jbpmContext.setRollbackOnly();
throw e;
}
- finally
- {
+ finally {
jbpmContext.close();
}
- if (tx != null)
- tx.commit();
+ if (tx != null) tx.commit();
return instance.hasEnded();
}
- catch (Exception e)
- {
- if (tx != null)
- tx.rollback();
+ catch (Exception e) {
+ if (tx != null) tx.rollback();
throw e;
}
}
- private boolean isTxCreatedByService(JbpmContext jbpmContext)
- {
- JtaDbPersistenceService persistenceService = (JtaDbPersistenceService)jbpmContext.getServices().getPersistenceService();
+ private boolean isTxCreatedByService(JbpmContext jbpmContext) {
+ JtaDbPersistenceService persistenceService = (JtaDbPersistenceService) jbpmContext.getServices()
+ .getPersistenceService();
return persistenceService.isJtaTxCreated();
}
- private static UserTransaction getUserTransaction() throws NamingException
- {
+ private static UserTransaction getUserTransaction() throws NamingException {
Context initial = new InitialContext();
- return (UserTransaction)initial.lookup("java:comp/UserTransaction");
+ return (UserTransaction) initial.lookup("java:comp/UserTransaction");
}
}
Added: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/resources/jboss405-dependencies.txt
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/resources/jboss405-dependencies.txt (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/resources/jboss405-dependencies.txt 2009-05-04 09:33:28 UTC (rev 4706)
@@ -0,0 +1,72 @@
+# This file shows jboss-4.0.5.GA thirdparty dependencies. It was produced running the following command
+#
+# (ls -1 lib; ls -1 lib/endorsed; ls -1 server/default/lib/) | grep jar | sed s/.jar// | sort -u
+#
+activation
+antlr-2.7.6
+autonumber-plugin
+bcel
+bindingservice-plugin
+bsf
+bsh-1.3.0
+bsh-deployer
+cglib
+commons-collections
+commons-httpclient
+commons-logging
+concurrent
+dom4j
+getopt
+hibernate3
+hsqldb
+hsqldb-plugin
+javassist
+javax.servlet
+javax.servlet.jsp
+jaxen
+jboss
+jboss-backport-concurrent
+jboss-common
+jboss-common-jdbc-wrapper
+jboss-hibernate
+jboss-j2ee
+jboss-jaxrpc
+jboss-jca
+jboss-jmx
+jboss-jsr77
+jboss-jsr88
+jboss-management
+jboss-monitoring
+jbossmq
+jboss-remoting
+jboss-remoting-int
+jbossretro-rt
+jboss-saaj
+jboss-serialization
+jboss-srp
+jbosssx
+jboss-system
+jboss-transaction
+jboss-xml-binding
+jmx-adaptor-plugin
+jnpserver
+joesnmp
+jpl-pattern
+jpl-util
+log4j
+log4j-boot
+log4j-snmp-appender
+mail
+mail-plugin
+namespace
+properties-plugin
+resolver
+scheduler-plugin
+scheduler-plugin-example
+serializer
+webdavlib
+wsdl4j
+xalan
+xercesImpl
+xml-apis
+xmlentitymgr
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -2,7 +2,7 @@
<classpath>
<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.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -43,17 +43,16 @@
/**
* This example shows how to invoke JBoss Rules from an AssignmentHandler.
*/
-public class RulesAssignmentTest extends TestCase
-{
+public class RulesAssignmentTest extends TestCase {
+
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
JbpmContext jbpmContext;
long processInstanceId;
- public void setUp()
- {
+ public void setUp() {
dbPersistenceServiceFactory.createSchema();
loadIdentities();
@@ -61,62 +60,50 @@
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- protected void tearDown()
- {
+ protected void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- public void deployProcess()
- {
+ public void deployProcess() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("assignment/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void loadIdentities()
- {
+ public void loadIdentities() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
Entity[] entities = IdentityXmlParser.parseEntitiesResource("assignment/identity.db.xml");
IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
- for (int i = 0; i < entities.length; i++)
- {
+ for (int i = 0; i < entities.length; i++) {
identitySession.saveEntity(entities[i]);
}
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void newTransaction()
- {
+ public void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void testRulesAssignment()
- {
+ public void testRulesAssignment() {
// start process
newTransaction();
processInstanceId = createNewProcessInstance();
- assertNotNull(processInstanceId);
// perform task
newTransaction();
long taskInstanceId = acquireTask("tom");
- assertNotNull(taskInstanceId);
newTransaction();
completeTask(taskInstanceId);
@@ -134,8 +121,7 @@
}
- public long createNewProcessInstance()
- {
+ public long createNewProcessInstance() {
String processDefinitionName = "RulesAssignment";
ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(processDefinitionName);
long id = processInstance.getId();
@@ -148,16 +134,14 @@
return id;
}
- public long acquireTask(String actorId)
- {
- List<TaskInstance> tasklist = getTaskList(actorId);
+ public long acquireTask(String actorId) {
+ List tasklist = getTaskList(actorId);
Iterator taskIterator = tasklist.iterator();
TaskInstance taskInstance = null;
long taskInstanceId = 0;
- while (taskIterator.hasNext())
- {
- taskInstance = (TaskInstance)taskIterator.next();
+ while (taskIterator.hasNext()) {
+ taskInstance = (TaskInstance) taskIterator.next();
taskInstanceId = taskInstance.getId();
taskInstance.start();
@@ -165,22 +149,18 @@
return taskInstanceId;
}
- public void completeTask(long taskInstanceId)
- {
+ public void completeTask(long taskInstanceId) {
TaskInstance taskInstance = jbpmContext.getTaskInstance(taskInstanceId);
taskInstance.end();
}
- public List<TaskInstance> getTaskList(String actorId)
- {
+ public List getTaskList(String actorId) {
newTransaction();
- List<TaskInstance> taskList = jbpmContext.getTaskList(actorId);
- return taskList;
+ return jbpmContext.getTaskList(actorId);
}
- public ProcessInstance getProcessInstance(long processInstanceId)
- {
- ProcessInstance processInstance = (ProcessInstance)jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
+ public ProcessInstance getProcessInstance(long processInstanceId) {
+ ProcessInstance processInstance = (ProcessInstance) jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
return processInstance;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/businesstrip/BusinessTripRequestTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/businesstrip/BusinessTripRequestTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/businesstrip/BusinessTripRequestTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -8,6 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.exe.ContextInstance;
@@ -18,12 +19,12 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
-public class BusinessTripRequestTest extends TestCase
-{
+public class BusinessTripRequestTest extends TestCase {
+
Log log = LogFactory.getLog(this.getClass());
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
JbpmContext jbpmContext;
@@ -32,42 +33,35 @@
TaskMgmtInstance taskMgmtInstance;
long processInstanceId = -1;
- public void setUp()
- {
+ public void setUp() {
dbPersistenceServiceFactory.createSchema();
deployProcess();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void tearDown()
- {
+ public void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- private void newTransaction()
- {
+ private void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- private void deployProcess()
- {
+ private void deployProcess() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("businesstrip/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- private TaskInstance createNewProcessInstance()
- {
+ private TaskInstance createNewProcessInstance() {
processInstance = jbpmContext.newProcessInstanceForUpdate("business trip request");
processInstanceId = processInstance.getId();
contextInstance = processInstance.getContextInstance();
@@ -75,47 +69,47 @@
return processInstance.getTaskMgmtInstance().createStartTaskInstance();
}
- public void testTaskParameters()
- {
+ public void testTaskParameters() {
TaskInstance taskInstance = createNewProcessInstance();
assertEquals("submit business trip request", taskInstance.getName());
assertEquals(0, taskInstance.getVariables().size());
}
- public void testSubmitRaiseRequestTask()
- {
+ public void testSubmitRaiseRequestTask() {
jbpmContext.setActorId("employee");
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("purpose", "Conference in MIT");
- taskVariables.put("description", "This conference is mainly to highlight to impact of ESB technologies on the current industries");
- taskVariables.put("allocated budget", 3000);
+ taskVariables.put("description",
+ "This conference is mainly to highlight to impact of ESB technologies on the current industries");
+ taskVariables.put("allocated budget", "3000");
taskVariables.put("start date", "8/12/2009");
taskVariables.put("end date", "8/21/2009");
taskInstance.addVariables(taskVariables);
taskInstance.end();
assertEquals("Conference in MIT", contextInstance.getVariable("purpose"));
- assertEquals("This conference is mainly to highlight to impact of ESB technologies on the current industries", contextInstance.getVariable("description"));
- assertEquals(3000, contextInstance.getVariable("allocated budget"));
+ assertEquals(
+ "This conference is mainly to highlight to impact of ESB technologies on the current industries",
+ contextInstance.getVariable("description"));
+ assertEquals("3000", contextInstance.getVariable("allocated budget"));
assertEquals("8/12/2009", contextInstance.getVariable("start date"));
assertEquals("8/21/2009", contextInstance.getVariable("end date"));
assertEquals("employee", taskMgmtInstance.getSwimlaneInstance("employee").getActorId());
}
- @SuppressWarnings("unchecked")
- public void testRejectBusinessTripRequest()
- {
+ public void testRejectBusinessTripRequest() {
// Employee submits a business trip request
jbpmContext.setActorId("employee");
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("purpose", "Conference in MIT");
- taskVariables.put("description", "This conference is mainly to highlight to impact of ESB technologies on the current industries");
- taskVariables.put("allocated budget", 3000);
+ taskVariables.put("description",
+ "This conference is mainly to highlight to impact of ESB technologies on the current industries");
+ taskVariables.put("allocated budget", "3000");
taskVariables.put("start date", "8/12/2009");
taskVariables.put("end date", "8/21/2009");
@@ -126,28 +120,26 @@
// Manager rejects the raise request
newTransaction();
- log.info(jbpmContext.getTaskMgmtSession().findTaskInstancesByProcessInstance(processInstance).size());
- List<TaskInstance> managerTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasksList.size());
- TaskInstance managerTask = managerTasksList.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasksList.get(0);
managerTask.addComment("Conference theme doesn't align with company's current focus");
managerTask.end("reject");
assertEquals("manager", managerTask.getActorId());
}
- @SuppressWarnings("unchecked")
- public void testAcceptBusinessTripRequest()
- {
+ public void testAcceptBusinessTripRequest() {
// Employee submits a raise request
jbpmContext.setActorId("employee");
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("purpose", "Conference in MIT");
- taskVariables.put("description", "This conference is mainly to highlight to impact of ESB technologies on the current industries");
- taskVariables.put("allocated budget", 3000);
+ taskVariables.put("description",
+ "This conference is mainly to highlight to impact of ESB technologies on the current industries");
+ taskVariables.put("allocated budget", new Long(3000));
taskVariables.put("start date", "8/12/2009");
taskVariables.put("end date", "8/21/2009");
taskVariables.put("country", "USA");
@@ -159,19 +151,19 @@
// Manager rejects the raise request
newTransaction();
- List<TaskInstance> managerTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasksList.size());
- TaskInstance managerTask = managerTasksList.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasksList.get(0);
managerTask.addComment("Business trip approved");
managerTask.end("approve");
assertEquals("manager", managerTask.getActorId());
jbpmContext.save(managerTask);
newTransaction();
- List<TaskInstance> accountantTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
+ List accountantTasksList = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
assertEquals(1, accountantTasksList.size());
- TaskInstance accountantTask = accountantTasksList.get(0);
+ TaskInstance accountantTask = (TaskInstance) accountantTasksList.get(0);
accountantTask.end();
jbpmContext.save(accountantTask);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/raise/RaiseRequestTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/raise/RaiseRequestTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/raise/RaiseRequestTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -8,6 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.exe.ContextInstance;
@@ -18,12 +19,12 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
-public class RaiseRequestTest extends TestCase
-{
+public class RaiseRequestTest extends TestCase {
+
Log log = LogFactory.getLog(this.getClass());
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
JbpmContext jbpmContext;
@@ -32,42 +33,35 @@
TaskMgmtInstance taskMgmtInstance = null;
long processInstanceId = -1;
- public void setUp()
- {
+ public void setUp() {
dbPersistenceServiceFactory.createSchema();
deployProcess();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void tearDown()
- {
+ public void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- private void newTransaction()
- {
+ private void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- private void deployProcess()
- {
+ private void deployProcess() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("raise/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- private TaskInstance createNewProcessInstance()
- {
+ private TaskInstance createNewProcessInstance() {
processInstance = jbpmContext.newProcessInstanceForUpdate("raise request");
processInstanceId = processInstance.getId();
contextInstance = processInstance.getContextInstance();
@@ -75,75 +69,69 @@
return processInstance.getTaskMgmtInstance().createStartTaskInstance();
}
- public void testTaskParameters()
- {
+ public void testTaskParameters() {
TaskInstance taskInstance = createNewProcessInstance();
assertEquals("submit raise request", taskInstance.getName());
assertEquals(0, taskInstance.getVariables().size());
}
- public void testSubmitRaiseRequestTask()
- {
+ public void testSubmitRaiseRequestTask() {
jbpmContext.setActorId("employee");
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("reason", "I need to buy a jet");
- taskVariables.put("amount", 600);
+ taskVariables.put("amount", "600");
taskInstance.addVariables(taskVariables);
taskInstance.end();
assertEquals("I need to buy a jet", contextInstance.getVariable("reason"));
- assertEquals(600, contextInstance.getVariable("amount"));
+ assertEquals("600", contextInstance.getVariable("amount"));
assertEquals("employee", taskMgmtInstance.getSwimlaneInstance("employee").getActorId());
}
- @SuppressWarnings("unchecked")
- public void testManagerEvaluationReject()
- {
+ public void testManagerEvaluationReject() {
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("reason", "I need to buy a jet");
- taskVariables.put("amount", 600);
+ taskVariables.put("amount", "600");
taskInstance.addVariables(taskVariables);
taskInstance.end();
jbpmContext.save(processInstance);
newTransaction();
- List<TaskInstance> managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasks.size());
- TaskInstance managerTask = managerTasks.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasks.get(0);
managerTask.end("reject");
- List<TaskInstance> foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
+ List foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
assertEquals(0, foTasks.size());
}
- @SuppressWarnings("unchecked")
- public void testManagerEvaluationAcceptFOReject()
- {
+ public void testManagerEvaluationAcceptFOReject() {
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("reason", "I need to buy a jet");
- taskVariables.put("amount", 600);
+ taskVariables.put("amount", "600");
taskInstance.addVariables(taskVariables);
taskInstance.end();
jbpmContext.save(processInstance);
newTransaction();
- List<TaskInstance> managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasks.size());
- TaskInstance managerTask = managerTasks.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasks.get(0);
managerTask.start();
managerTask.end("accept");
newTransaction();
- List<TaskInstance> foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
+ List foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
assertEquals(1, foTasks.size());
- TaskInstance foTask = foTasks.get(0);
+ TaskInstance foTask = (TaskInstance) foTasks.get(0);
foTask.start();
foTask.addComment("Justify two consecutive raises");
foTask.end("reject");
@@ -152,66 +140,62 @@
assertEquals(0, managerTasks.size());
}
- @SuppressWarnings("unchecked")
- public void testManagerEvaluationAcceptFOAccpet()
- {
+ public void testManagerEvaluationAcceptFOAccpet() {
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("reason", "I need to buy a jet");
- taskVariables.put("amount", 600);
+ taskVariables.put("amount", "600");
taskInstance.addVariables(taskVariables);
taskInstance.end();
jbpmContext.save(processInstance);
newTransaction();
- List<TaskInstance> managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasks.size());
- TaskInstance managerTask = managerTasks.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasks.get(0);
managerTask.start();
managerTask.end("accept");
newTransaction();
- List<TaskInstance> foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
+ List foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
assertEquals(1, foTasks.size());
- TaskInstance foTask = foTasks.get(0);
+ TaskInstance foTask = (TaskInstance) foTasks.get(0);
foTask.start();
foTask.addComment("Justify two consecutive raises");
foTask.end("accept");
newTransaction();
- List<TaskInstance> accountantTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
+ List accountantTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
assertEquals(1, accountantTasks.size());
- TaskInstance accountantTask = accountantTasks.get(0);
+ TaskInstance accountantTask = (TaskInstance) accountantTasks.get(0);
accountantTask.start();
accountantTask.addComment("ERP updated");
accountantTask.end("terminate");
}
- @SuppressWarnings("unchecked")
- public void testManagerEvaluationAcceptFOMultipleIterationsAccpet()
- {
+ public void testManagerEvaluationAcceptFOMultipleIterationsAccpet() {
TaskInstance taskInstance = createNewProcessInstance();
- Map<String, Object> taskVariables = new HashMap<String, Object>();
+ Map taskVariables = new HashMap();
taskVariables.put("reason", "I need to buy a jet");
- taskVariables.put("amount", 600);
+ taskVariables.put("amount", "600");
taskInstance.addVariables(taskVariables);
taskInstance.end();
jbpmContext.save(processInstance);
newTransaction();
- List<TaskInstance> managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
+ List managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasks.size());
- TaskInstance managerTask = managerTasks.get(0);
+ TaskInstance managerTask = (TaskInstance) managerTasks.get(0);
managerTask.start();
managerTask.end("accept");
newTransaction();
- List<TaskInstance> foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
+ List foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
assertEquals(1, foTasks.size());
- TaskInstance foTask = foTasks.get(0);
+ TaskInstance foTask = (TaskInstance) foTasks.get(0);
foTask.start();
foTask.addComment("Justify two consecutive raises");
foTask.end("more justification required");
@@ -220,7 +204,7 @@
managerTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
assertEquals(1, managerTasks.size());
- managerTask = managerTasks.get(0);
+ managerTask = (TaskInstance) managerTasks.get(0);
managerTask.start();
managerTask.addComment("The guy exceeds all the expectations");
managerTask.end("accept");
@@ -229,16 +213,16 @@
foTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("fo");
assertEquals(1, foTasks.size());
- foTask = foTasks.get(0);
+ foTask = (TaskInstance) foTasks.get(0);
foTask.start();
foTask.addComment("justification accepted");
foTask.end("accept");
newTransaction();
- List<TaskInstance> accountantTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
+ List accountantTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("accountant");
assertEquals(1, accountantTasks.size());
- TaskInstance accountantTask = accountantTasks.get(0);
+ TaskInstance accountantTask = (TaskInstance) accountantTasks.get(0);
accountantTask.start();
accountantTask.addComment("ERP updated");
accountantTask.end("terminate");
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/rulesaction/RulesActionTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/rulesaction/RulesActionTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/rulesaction/RulesActionTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -30,63 +30,54 @@
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Services;
-import org.jbpm.graph.exe.Token;
/**
* This example shows how to invoke JBoss Drools from an ActionHandler.
*/
-public class RulesActionTest extends TestCase
-{
+public class RulesActionTest extends TestCase {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
JbpmContext jbpmContext;
long processInstanceId;
- public void setUp()
- {
+ public void setUp() {
dbPersistenceServiceFactory.createSchema();
deployProcess();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void tearDown()
- {
+ public void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- public void newTransaction()
- {
+ public void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void deployProcess()
- {
+ public void deployProcess() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("rulesaction/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void testRulesAssignment()
- {
+ public void testRulesAssignment() {
// start process
newTransaction();
processInstanceId = createNewProcessInstance();
- assertNotNull(processInstanceId);
newTransaction();
ProcessInstance processInstance = getProcessInstance(processInstanceId);
@@ -95,13 +86,12 @@
Date processEnd = processInstance.getEnd();
assertNotNull(processEnd);
- String shipper = (String)processInstance.getContextInstance().getVariable("shipper");
+ String shipper = (String) processInstance.getContextInstance().getVariable("shipper");
assertEquals("shipper is FEDX", shipper, "FEDX");
}
- public long createNewProcessInstance()
- {
+ public long createNewProcessInstance() {
String processDefinitionName = "RulesAction";
ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(processDefinitionName);
long id = processInstance.getId();
@@ -116,9 +106,8 @@
return id;
}
- public ProcessInstance getProcessInstance(long processInstanceId)
- {
- ProcessInstance processInstance = (ProcessInstance)jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
+ public ProcessInstance getProcessInstance(long processInstanceId) {
+ ProcessInstance processInstance = (ProcessInstance) jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
return processInstance;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -29,6 +29,7 @@
import org.hibernate.Query;
import org.hibernate.Session;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.exe.ContextInstance;
@@ -45,8 +46,7 @@
/**
* This example shows how to extend the TaskInstance by adding a custom property.
*/
-public class CustomTaskInstanceTest extends TestCase
-{
+public class CustomTaskInstanceTest extends TestCase {
JbpmConfiguration jbpmConfiguration = null;
// JbpmConfiguration.getInstance();
@@ -61,14 +61,13 @@
ContextInstance contextInstance = null;
- public void setUp()
- {
+ public void setUp() {
// the jbpm.cfg.xml file is modified to add the CustomTaskInstanceFactory
// so we will read in the file from the config directory of this example
jbpmConfiguration = JbpmConfiguration.parseResource("taskinstance/jbpm.cfg.xml");
- dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
// the CustomTaskInstance mapping file reference
// <mapping resource="org/jbpm/taskinstance/CustomTaskInstance.hbm.xml"/>
@@ -83,63 +82,51 @@
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void tearDown()
- {
+ public void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- public void newTransaction()
- {
+ public void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void deployProcess()
- {
+ public void deployProcess() {
jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("taskinstance/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void loadIdentities()
- {
+ public void loadIdentities() {
jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
Entity[] entities = IdentityXmlParser.parseEntitiesResource("identity.db.xml");
IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
- for (int i = 0; i < entities.length; i++)
- {
+ for (int i = 0; i < entities.length; i++) {
identitySession.saveEntity(entities[i]);
}
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void testCustomTaskInstance()
- {
+ public void testCustomTaskInstance() {
// create processInstance
newTransaction();
long processInstanceId = createNewProcessInstance();
- assertNotNull(processInstanceId);
assertFalse("ProcessInstanceId is 0", processInstanceId == 0);
// perform the task
newTransaction();
long taskInstanceId = acquireTask();
- assertNotNull(taskInstanceId);
assertFalse("TaskInstanceId is 0", taskInstanceId == 0);
newTransaction();
@@ -158,8 +145,7 @@
assertNotNull(processEnd);
}
- public long createNewProcessInstance()
- {
+ public long createNewProcessInstance() {
String processDefinitionName = "CustomTaskInstance";
processInstance = jbpmContext.newProcessInstanceForUpdate(processDefinitionName);
long processInstanceId = processInstance.getId();
@@ -172,17 +158,15 @@
}
- public long acquireTask()
- {
+ public long acquireTask() {
- List<CustomTaskInstance> tasklist = findPooledTaskListByCustomId("reviewers", "abc");
+ List tasklist = findPooledTaskListByCustomId("reviewers", "abc");
Iterator taskIterator = tasklist.iterator();
CustomTaskInstance taskInstance = null;
long taskInstanceId = 0;
- while (taskIterator.hasNext())
- {
- taskInstance = (CustomTaskInstance)taskIterator.next();
+ while (taskIterator.hasNext()) {
+ taskInstance = (CustomTaskInstance) taskIterator.next();
taskInstanceId = taskInstance.getId();
taskInstance.start();
taskInstance.setActorId("tom");
@@ -192,23 +176,24 @@
return taskInstanceId;
}
- public void completeTask(long taskInstanceId)
- {
+ public void completeTask(long taskInstanceId) {
s = jbpmContext.getSession();
- CustomTaskInstance taskInstance = (CustomTaskInstance)s.load(CustomTaskInstance.class, new Long(taskInstanceId));
+ CustomTaskInstance taskInstance = (CustomTaskInstance) s.load(CustomTaskInstance.class,
+ new Long(taskInstanceId));
taskInstance.end();
}
- private static final String findPooledTaskInstancesByCustomId =
- "select distinct ti " + "from " + CustomTaskInstance.class.getName() + " ti " +
- " join ti.pooledActors pooledActor where pooledActor.actorId = :pooledActorId and ti.actorId is null and ti.end is null " +
- " and ti.isCancelled = false and ti.customId = :customId";
+ private static final String findPooledTaskInstancesByCustomId = "select distinct ti "
+ + "from "
+ + CustomTaskInstance.class.getName()
+ + " ti "
+ + " join ti.pooledActors pooledActor where pooledActor.actorId = :pooledActorId and ti.actorId is null and ti.end is null "
+ + " and ti.isCancelled = false and ti.customId = :customId";
- public List<CustomTaskInstance> findPooledTaskListByCustomId(String actorId, String customId)
- {
- List<CustomTaskInstance> taskList = null;
+ public List findPooledTaskListByCustomId(String actorId, String customId) {
+ List taskList = null;
s = jbpmContext.getSession();
Query query = s.createQuery(findPooledTaskInstancesByCustomId);
query.setString("pooledActorId", actorId);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/identity/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/identity/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/identity/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,7 +4,7 @@
<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.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/assignment/ExpressionAssignmentHandlerTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/assignment/ExpressionAssignmentHandlerTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/assignment/ExpressionAssignmentHandlerTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -35,8 +35,7 @@
import org.jbpm.taskmgmt.exe.SwimlaneInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class ExpressionAssignmentHandlerTest extends IdentityDbTestCase
-{
+public class ExpressionAssignmentHandlerTest extends IdentityDbTestCase {
ExpressionAssignmentHandler expressionAssignmentHandler;
TaskInstance assignable = new TaskInstance();
@@ -47,9 +46,8 @@
Membership membershipJohn, membershipBill;
Group hellsangels;
User john, bill;
-
- public void setUp() throws Exception
- {
+
+ public void setUp() throws Exception {
super.setUp();
expressionAssignmentHandler = new ExpressionAssignmentHandler();
setUpProcessInstance();
@@ -58,9 +56,7 @@
jbpmContext.setActorId("bill");
}
- @Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
deleteUser(john.getId());
deleteUser(bill.getId());
deleteGroup(hellsangels.getId());
@@ -68,8 +64,7 @@
super.tearDown();
}
- private void setUpUserData()
- {
+ private void setUpUserData() {
john = new User("john");
bill = new User("bill");
hellsangels = new Group("hellsangels", "hierarchy");
@@ -83,30 +78,25 @@
identitySession.saveMembership(membershipBill);
}
- private void setUpProcessInstance()
- {
+ private void setUpProcessInstance() {
processDefinition = ProcessDefinition.parseXmlString("<process-definition/>");
graphSession.saveProcessDefinition(processDefinition);
processInstance = new ProcessInstance(processDefinition);
jbpmContext.save(processInstance);
}
-
- @Override
- protected void newTransaction()
- {
+
+ protected void newTransaction() {
super.newTransaction();
executionContext = new ExecutionContext(processInstance.getRootToken());
}
-
- public void testFirstTermPrevious()
- {
+
+ public void testFirstTermPrevious() {
expressionAssignmentHandler.expression = "previous";
expressionAssignmentHandler.assign(assignable, executionContext);
assertEquals("bill", assignable.getActorId());
}
- public void testFirstTermSwimlane()
- {
+ public void testFirstTermSwimlane() {
expressionAssignmentHandler.expression = "swimlane(boss)";
SwimlaneInstance swimlaneInstance = new SwimlaneInstance(new Swimlane("boss"));
swimlaneInstance.setActorId("john");
@@ -115,30 +105,25 @@
assertEquals("john", assignable.getActorId());
}
- public void testFirstTermSwimlaneUnexisting()
- {
+ public void testFirstTermSwimlaneUnexisting() {
expressionAssignmentHandler.expression = "swimlane(sillywoman)";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
- public void testFirstTermVariableString()
- {
+ public void testFirstTermVariableString() {
expressionAssignmentHandler.expression = "variable(actoridstringvariable)";
processInstance.getContextInstance().setVariable("actoridstringvariable", "john");
expressionAssignmentHandler.assign(assignable, executionContext);
assertEquals("john", assignable.getActorId());
}
- public void testFirstTermVariableUser()
- {
+ public void testFirstTermVariableUser() {
expressionAssignmentHandler.expression = "variable(uservariable)";
User john = identitySession.getUserByName("john");
processInstance.getContextInstance().setVariable("uservariable", john);
@@ -146,115 +131,95 @@
assertEquals("john", assignable.getActorId());
}
- public void testFirstTermVariableGroup()
- {
+ public void testFirstTermVariableGroup() {
expressionAssignmentHandler.expression = "variable(groupvariable)";
Group hellsangels = identitySession.getGroupByName("hellsangels");
processInstance.getContextInstance().setVariable("groupvariable", hellsangels);
expressionAssignmentHandler.assign(assignable, executionContext);
Set pooledActors = assignable.getPooledActors();
- PooledActor pooledActor = (PooledActor)pooledActors.iterator().next();
+ PooledActor pooledActor = (PooledActor) pooledActors.iterator().next();
assertEquals("hellsangels", pooledActor.getActorId());
}
- public void testFirstTermVariableUnexisting()
- {
+ public void testFirstTermVariableUnexisting() {
expressionAssignmentHandler.expression = "variable(unexistingvariablename)";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
- public void testFirstTermUser()
- {
+ public void testFirstTermUser() {
expressionAssignmentHandler.expression = "user(john)";
expressionAssignmentHandler.assign(assignable, executionContext);
assertEquals("john", assignable.getActorId());
}
- public void testFirstTermUserUnexisting()
- {
+ public void testFirstTermUserUnexisting() {
expressionAssignmentHandler.expression = "user(idontexist)";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
- public void testFirstTermGroup()
- {
+ public void testFirstTermGroup() {
expressionAssignmentHandler.expression = "group(hellsangels)";
expressionAssignmentHandler.assign(assignable, executionContext);
Set pooledActors = assignable.getPooledActors();
- PooledActor pooledActor = (PooledActor)pooledActors.iterator().next();
+ PooledActor pooledActor = (PooledActor) pooledActors.iterator().next();
assertEquals("hellsangels", pooledActor.getActorId());
}
- public void testFirstTermGroupUnexisting()
- {
+ public void testFirstTermGroupUnexisting() {
expressionAssignmentHandler.expression = "group(wedontexist)";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
- public void testWrongFirstTerm()
- {
+ public void testWrongFirstTerm() {
expressionAssignmentHandler.expression = "wrong-first-term";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
- public void testNextTermGroup()
- {
+ public void testNextTermGroup() {
expressionAssignmentHandler.expression = "user(john) --> group(hierarchy)";
expressionAssignmentHandler.assign(assignable, executionContext);
Set pooledActors = assignable.getPooledActors();
- PooledActor pooledActor = (PooledActor)pooledActors.iterator().next();
+ PooledActor pooledActor = (PooledActor) pooledActors.iterator().next();
assertEquals("hellsangels", pooledActor.getActorId());
}
- public void testNextTermMember()
- {
+ public void testNextTermMember() {
expressionAssignmentHandler.expression = "group(hellsangels) --> member(leaderofthegang)";
expressionAssignmentHandler.assign(assignable, executionContext);
assertEquals("john", assignable.getActorId());
}
- public void testWrongNextTerm()
- {
+ public void testWrongNextTerm() {
expressionAssignmentHandler.expression = "user(john) --> wrong-second-term";
- try
- {
+ try {
expressionAssignmentHandler.assign(assignable, executionContext);
fail("expected exception");
}
- catch (ExpressionAssignmentException e)
- {
+ catch (ExpressionAssignmentException e) {
// OK
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/hibernate/UserDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/hibernate/UserDbTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/test/java/org/jbpm/identity/hibernate/UserDbTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -31,11 +31,9 @@
import org.jbpm.identity.Membership;
import org.jbpm.identity.User;
-public class UserDbTest extends IdentityDbTestCase
-{
+public class UserDbTest extends IdentityDbTestCase {
- public void testUser()
- {
+ public void testUser() {
User user = new User("johndoe");
user = saveAndReload(user);
assertEquals("johndoe", user.getName());
@@ -43,8 +41,7 @@
deleteUser(user.getId());
}
- public void testUserMemberships()
- {
+ public void testUserMemberships() {
User john = new User("johndoe");
Group qaTeam = new Group("qa team", "hierarchy");
Group marketingTeam = new Group("marketing team", "hierarchy");
@@ -65,8 +62,7 @@
deleteUser(john.getId());
}
- public void testUserPermissions()
- {
+ public void testUserPermissions() {
User user = new User("johndoe");
user.addPermission(new NetPermission("connect", "9001"));
user.addPermission(new AllPermission("all", "everything"));
@@ -80,33 +76,26 @@
deleteUser(user.getId());
}
- public void testVerifyWrongUser()
- {
+ public void testVerifyWrongUser() {
assertNull(identitySession.verify("unexisting-user", "wrong password"));
}
- public void testVerifyValidPwd()
- {
+ public void testVerifyValidPwd() {
User user = new User("johndoe");
user.setPassword("johnspwd");
user = saveAndReload(user);
- try
- {
- assertEquals(user.getId(), identitySession.verify("johndoe", "johnspwd"));
+ try {
+ assertEquals(new Long(user.getId()), identitySession.verify("johndoe", "johnspwd"));
}
- finally
- {
+ finally {
deleteUser(user.getId());
}
}
- private boolean containsGroup(Set groups, String groupName)
- {
- Iterator iter = groups.iterator();
- while (iter.hasNext())
- {
- if (groupName.equals(((Group)iter.next()).getName()))
- {
+ private boolean containsGroup(Set groups, String groupName) {
+ for (Iterator i = groups.iterator(); i.hasNext();) {
+ Group group = (Group) i.next();
+ if (groupName.equals(group.getName())) {
return true;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,7 +4,7 @@
<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.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/jpdl/SimulationDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/jpdl/SimulationDefinition.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/jpdl/SimulationDefinition.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -8,6 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.Transition;
import org.jbpm.module.def.ModuleDefinition;
@@ -23,48 +24,41 @@
* this object is populated during instrumentation (see SimulationTestCase)
*
* @author bernd.ruecker at camunda.com
- */
+ */
public class SimulationDefinition extends ModuleDefinition {
private static final long serialVersionUID = 1L;
-
+
private static Log log = LogFactory.getLog(SimulationDefinition.class);
-
+
// Map<Object (process elements), Object (any simulation configuration information)>
// Map simulationConfiguration;
-
+
/**
- * Map containing pool definitions.
- * The pool name is the key, the value is an Object array
- * with the first element: size as Integer,
- * and the second element: costsPerTimeUnit as Double
+ * Map containing pool definitions. The pool name is the key, the value is an Object array with
+ * the first element: size as Integer, and the second element: costsPerTimeUnit as Double
*/
private Map resourcePoolDefinitions = new HashMap();
-
+
private List distributions = new ArrayList();
-
+
/**
- * maps for process elements which distribution to use
- * The key is the process element, the value the distribution name
+ * maps for process elements which distribution to use The key is the process element, the value
+ * the distribution name
*/
- private Map distributionMap = new HashMap();
+ private Map distributionMap = new HashMap();
/**
- * Map which contains a list of resource requirements for
- * process elements (for example Task's or State's)
- *
- * It is a Map<Object, List>
+ * Map which contains a list of resource requirements for process elements (for example Task's or
+ * State's) It is a Map<Object, List>
*/
- private Map resourceRequirements = new HashMap();
-
+ private Map resourceRequirements = new HashMap();
+
/**
- * Map which contains configured probabilities
- * for Transitions
- *
- * It is a Map<Transition, Double>
+ * Map which contains configured probabilities for Transitions It is a Map<Transition, Double>
*/
- private Map transitionProbabilities = new HashMap();
-
+ private Map transitionProbabilities = new HashMap();
+
private Map dataSources = new HashMap();
private Map dataFilters = new HashMap();
@@ -74,26 +68,40 @@
}
/**
- * adds a resource pool. If the pool already exists, the bigger pool
- * size is taken.
+ * adds a resource pool. If the pool already exists, the bigger pool size is taken.
*
* @param poolName
* @param poolSize
*/
public void addResourcePool(String poolName, Integer poolSize, Double costPerTimeUnit) {
- if (resourcePoolDefinitions.containsKey(poolName)) {
- Integer otherPoolSize = (Integer)((Object[])resourcePoolDefinitions.get(poolName))[0];
- if (poolSize.intValue() > otherPoolSize.intValue() ) {
- resourcePoolDefinitions.put(poolName, new Object[] {poolSize, costPerTimeUnit});
- log.warn("resource pool '" + poolName + "' redefined in process '"+ getProcessDefinition().getName() +"' with the bigger poolsize " + poolSize + ", was " + otherPoolSize + " before" );
+ if (resourcePoolDefinitions.containsKey(poolName)) {
+ Integer otherPoolSize = (Integer) ((Object[]) resourcePoolDefinitions.get(poolName))[0];
+ if (poolSize.intValue() > otherPoolSize.intValue()) {
+ resourcePoolDefinitions.put(poolName, new Object[] { poolSize, costPerTimeUnit });
+ log.warn("resource pool '"
+ + poolName
+ + "' redefined in process '"
+ + getProcessDefinition().getName()
+ + "' with the bigger poolsize "
+ + poolSize
+ + ", was "
+ + otherPoolSize
+ + " before");
}
- else if (poolSize.intValue() < otherPoolSize.intValue() )
- log.warn("resource pool '" + poolName + "' redefined in process '"+ getProcessDefinition().getName() +"' with the smaler poolsize " + poolSize + " which is ignored. Poolsize still is " + otherPoolSize);
+ else if (poolSize.intValue() < otherPoolSize.intValue())
+ log.warn("resource pool '"
+ + poolName
+ + "' redefined in process '"
+ + getProcessDefinition().getName()
+ + "' with the smaler poolsize "
+ + poolSize
+ + " which is ignored. Poolsize still is "
+ + otherPoolSize);
}
else
- resourcePoolDefinitions.put(poolName, new Object[] {poolSize, costPerTimeUnit});
+ resourcePoolDefinitions.put(poolName, new Object[] { poolSize, costPerTimeUnit });
}
-
+
/**
* adds a resource pool. If the pool already exists it is overwritten
*
@@ -101,24 +109,24 @@
* @param poolSize
*/
public void overwriteResourcePool(String poolName, Integer poolSize, Double costPerTimeUnit) {
- resourcePoolDefinitions.put(poolName, new Object[] {poolSize, costPerTimeUnit});
- }
-
+ resourcePoolDefinitions.put(poolName, new Object[] { poolSize, costPerTimeUnit });
+ }
+
public void addResourceRequirement(Object processElement, String poolName, int amount) {
List reqList = (List) resourceRequirements.get(processElement);
if (reqList == null) {
reqList = new ArrayList();
resourceRequirements.put(processElement, reqList);
}
- reqList.add( new ResourceRequirement(poolName, amount) );
- }
+ reqList.add(new ResourceRequirement(poolName, amount));
+ }
/**
* adds a distribution.
*
* @param distDef
*/
- public void addDistribution(DistributionDefinition distDef) {
+ public void addDistribution(DistributionDefinition distDef) {
distributions.add(distDef);
}
@@ -131,8 +139,7 @@
// delete all distributions with that name
for (Iterator iterator = new ArrayList(distributions).iterator(); iterator.hasNext();) {
DistributionDefinition dd = (DistributionDefinition) iterator.next();
- if (dd.getName().equals(distDef.getName()))
- distributions.remove(dd);
+ if (dd.getName().equals(distDef.getName())) distributions.remove(dd);
}
// and add the new one
distributions.add(distDef);
@@ -144,8 +151,8 @@
private void addToDistributionMap(Object key, String distributionName) {
distributionMap.put(key, distributionName);
- }
-
+ }
+
public void setStartDistribution(String distributionName) {
addToDistributionMap(processDefinition, distributionName);
}
@@ -167,7 +174,7 @@
}
public void addTransitionProbability(Transition trans, double prob) {
- transitionProbabilities.put(trans, Double.valueOf(prob));
+ transitionProbabilities.put(trans, new Double(prob));
}
public Map getTransitionProbabilities() {
@@ -188,7 +195,7 @@
public ProcessDataSource getDataSource(String name) {
ProcessDataSource result = (ProcessDataSource) dataSources.get(name);
- if (result==null)
+ if (result == null)
throw new ExperimentConfigurationException("data source '" + name + "' not configured");
return result;
}
@@ -199,7 +206,7 @@
public ProcessDataFilter getDataFilter(String name) {
ProcessDataFilter result = (ProcessDataFilter) dataFilters.get(name);
- if (result==null)
+ if (result == null)
throw new ExperimentConfigurationException("data filter '" + name + "' not configured");
return result;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/report/ScenarioReport.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/report/ScenarioReport.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/main/java/org/jbpm/sim/report/ScenarioReport.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -6,8 +6,7 @@
import java.util.Map;
import org.dom4j.Document;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
+
import org.jbpm.sim.def.DistributionDefinition;
import org.jbpm.sim.report.dto.BaseResult;
import org.jbpm.sim.report.dto.CountResult;
@@ -17,22 +16,20 @@
import org.jbpm.sim.report.dto.ValueStatisticResult;
/**
- * This class holds simulation run details
- * (as simple POJOs) for a special scenario
+ * This class holds simulation run details (as simple POJOs) for a special scenario
*
* @author bernd.ruecker at camunda.com
*/
public class ScenarioReport {
-
+
private String scenarioName;
- private double simulationRunTime;
+ private double simulationRunTime;
- private double resetTime;
+ private double resetTime;
/**
- * all ValueStatisticResult objects for waiting time
- * before states / tasks.
+ * all ValueStatisticResult objects for waiting time before states / tasks.
*/
private Map stateWaitingTimes = new HashMap();
@@ -40,7 +37,7 @@
* all ValueStatisticResult objects for process cycle times
*/
private Map cycleTimesValueStatistics = new HashMap();
-
+
/**
* other ValueStatisticResult objects
*/
@@ -51,9 +48,9 @@
private Map miscQueueStatistics = new HashMap();
private Map resourcePoolTimeSeries = new HashMap();
-
+
private Map distributionDefinitions = new HashMap();
-
+
private Map businessFigureValues = new HashMap();
private Map processEndCounts = new HashMap();
@@ -70,30 +67,29 @@
}
public void addMiscValueStatistics(ValueStatisticResult vsr) {
- miscValueStatistics.put(vsr.getName(), vsr);
+ miscValueStatistics.put(vsr.getName(), vsr);
}
-
+
public void addResourcePoolWaitingTimes(QueueStatisticsResult qsr) {
resourcePoolWaitingTimes.put(qsr.getName(), qsr);
}
public void addMiscQueueStatistics(QueueStatisticsResult qsr) {
miscQueueStatistics.put(qsr.getName(), qsr);
- }
+ }
-
public void addResourcePoolUtilization(BaseResult usr) {
- resourcePoolUtilizations.put(usr.getName(), usr);
+ resourcePoolUtilizations.put(usr.getName(), usr);
}
-
+
public void addResourcePoolTimeSeries(TimeSeriesResult timeSeriesReport) {
resourcePoolTimeSeries.put(timeSeriesReport.getName(), timeSeriesReport);
- }
+ }
public void addDistributionDefinition(DistributionDefinition o) {
distributionDefinitions.put(o.getName(), o);
}
-
+
public void addProcessEndCount(CountResult countResult) {
processEndCounts.put(countResult.getName(), countResult);
}
@@ -114,44 +110,45 @@
public Document createDocument() {
//Document document = DocumentHelper.createDocument();
//Element reportRoot = document.addElement( "root" );
-
+
// TODO: Implement or maybe skip :-)
throw new RuntimeException("create xml document of simulation statistics not yet implemented");
-
+
// return document;
}
public String getScenarioName() {
return scenarioName;
}
-
+
public void addBusinessFigure(String type, double sum) {
- businessFigureValues.put(type, Double.valueOf(sum));
+ businessFigureValues.put(type, new Double(sum));
}
public void calculateResourceCosts(double unutilizedTimeCostFactor) {
for (Iterator iterator = getResourcePoolUtilizations().iterator(); iterator.hasNext();) {
UtilizationStatisticsResult util = (UtilizationStatisticsResult) iterator.next();
util.calculateCosts(unutilizedTimeCostFactor, simulationRunTime);
- }
- }
+ }
+ }
public Collection getBusinessFigureTypes() {
return businessFigureValues.keySet();
}
public double getBusinessFigureValue(String type) {
- return ((Double)businessFigureValues.get(type)).doubleValue();
+ return ((Double) businessFigureValues.get(type)).doubleValue();
}
/**
* Convenience method after removing typo
- * @deprecated
+ *
+ * @deprecated
*/
public double getCost() {
return getCosts();
}
-
+
/**
* @return costs (resource costs and business figures of type costs)
*/
@@ -161,10 +158,10 @@
String type = (String) iterator.next();
if ("costs".equals(type)) {
result += getBusinessFigureValue(type);
- }
+ }
}
return result;
- }
+ }
/**
* @return resource costs
@@ -176,11 +173,11 @@
UtilizationStatisticsResult util = (UtilizationStatisticsResult) iterator.next();
result += util.getCosts();
}
-
+
// TODO: add other costs
// calculate additional "business" costs
// maybe this should be calculated earlier and just be written as results here
-
+
return result;
}
@@ -188,7 +185,7 @@
QueueStatisticsResult result = null;
for (Iterator iterator = getResourcePoolWaitingTimes().iterator(); iterator.hasNext();) {
QueueStatisticsResult stat = (QueueStatisticsResult) iterator.next();
- if (result==null || stat.getAverageWaitTime() > result.getAverageWaitTime()) {
+ if (result == null || stat.getAverageWaitTime() > result.getAverageWaitTime()) {
result = stat;
}
}
@@ -205,7 +202,7 @@
}
return utilization / observations;
}
-
+
public int getResourceAmount() {
int result = 0;
for (Iterator iterator = getResourcePoolUtilizations().iterator(); iterator.hasNext();) {
@@ -213,7 +210,7 @@
result += util.getPoolSize();
}
return result;
- }
+ }
public DistributionDefinition getDistributionDefinition(String name) {
return (DistributionDefinition) distributionDefinitions.get(name);
@@ -230,7 +227,7 @@
public Collection getStateWaitingTimes() {
return stateWaitingTimes.values();
}
-
+
public ValueStatisticResult getStateWaitingTimes(String name) {
return (ValueStatisticResult) stateWaitingTimes.get(name);
}
@@ -253,7 +250,7 @@
public Collection getDistributionDefinitions() {
return distributionDefinitions.values();
- }
+ }
public Collection getResourcePoolWaitingTimes() {
return resourcePoolWaitingTimes.values();
@@ -289,11 +286,11 @@
public TimeSeriesResult getResourcePoolTimeSeriesResult(String poolName) {
TimeSeriesResult result = (TimeSeriesResult) resourcePoolTimeSeries.get(poolName);
- if (result==null)
+ if (result == null)
return new TimeSeriesResult(poolName, scenarioName, new double[0], new double[0]);
return result;
}
-
+
public Map getProcessEndCounts() {
return processEndCounts;
}
@@ -304,11 +301,11 @@
public Map getProcessStartCounts() {
return processStartCounts;
- }
+ }
public CountResult getProcessStartCount(String name) {
return (CountResult) processStartCounts.get(name);
- }
+ }
public double getResetTime() {
return resetTime;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/BusinessFiguresTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/BusinessFiguresTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/BusinessFiguresTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,131 +1,135 @@
package org.jbpm.sim;
-import java.util.Date;
+import junit.framework.TestCase;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.sim.def.JbpmSimulationExperiment;
-import org.jbpm.sim.def.JbpmSimulationScenario;
import org.jbpm.sim.exe.ExperimentReader;
import org.jbpm.sim.kpi.BusinessFigureCalculator;
import org.jbpm.sim.report.ScenarioReport;
-import org.jbpm.sim.report.dto.ValueStatisticResult;
-import junit.framework.TestCase;
-
public class BusinessFiguresTest extends TestCase {
-
- private String testProcessXml =
- "<process-definition name='test' start-distribution='startDist'>" +
- " <start-state name='start'>" +
- " <transition to='node1' />" +
- " </start-state>" +
-
- " <node name='node1'>" +
- " <transition to='end'>" +
- " <simulation-action class='org.jbpm.sim.kpi.BusinessFigureAction'>" +
- " <name>testFigure</name> " +
- " </simulation-action>" +
- " </transition>" +
- " </node>" +
+ private String testProcessXml = "<process-definition name='test' start-distribution='startDist'>"
+ +
- " <end-state name='end'/>" +
+ " <start-state name='start'>"
+ + " <transition to='node1' />"
+ + " </start-state>"
+ +
- "</process-definition>" ;
+ " <node name='node1'>"
+ + " <transition to='end'>"
+ + " <simulation-action class='org.jbpm.sim.kpi.BusinessFigureAction'>"
+ + " <name>testFigure</name> "
+ + " </simulation-action>"
+ + " </transition>"
+ + " </node>"
+ +
- private String experimentConfiguration =
- "<experiment name='MySimulationExperiment'" +
- " run-time='100'" +
- " real-start-time='01.01.1970 01:00:00:002'" +
- " time-unit='minute'>" +
- " <scenario name ='test'>" +
- " <distribution name='startDist' sample-type='real' type='constant' value='20' /> " +
- " <sim-process name='test' />" +
- " <business-figure name='testFigure' type='costs' " +
- " automatic-calculation='none'" + // | process - start | process -end"
- " handler='org.jbpm.sim.BusinessFiguresTest$BusinessFigureHandler' />" +
- " </scenario>" +
- "</experiment>";
-
- public static class BusinessFigureHandler implements BusinessFigureCalculator{
+ " <end-state name='end'/>"
+ +
+
+ "</process-definition>";
+
+ private String experimentConfiguration = "<experiment name='MySimulationExperiment'"
+ + " run-time='100'"
+ + " real-start-time='01.01.1970 01:00:00:002'"
+ + " time-unit='minute'>"
+ + " <scenario name ='test'>"
+ + " <distribution name='startDist' sample-type='real' type='constant' value='20' /> "
+ + " <sim-process name='test' />"
+ + " <business-figure name='testFigure' type='costs' "
+ + " automatic-calculation='none'"
+ + // | process - start | process -end"
+ " handler='org.jbpm.sim.BusinessFiguresTest$BusinessFigureHandler' />"
+ + " </scenario>"
+ + "</experiment>";
+
+ public static class BusinessFigureHandler implements BusinessFigureCalculator {
+
public Number calculate(ExecutionContext executionContext) {
- return Double.valueOf(10);
+ return new Double(10);
}
}
-
+
public void testBusinessFigureConfiguredInProcess() {
ExperimentReader reader = new ExperimentReader(experimentConfiguration);
// inject process definition
- reader.addProcessDefinition("test", testProcessXml );
-
+ reader.addProcessDefinition("test", testProcessXml);
+
JbpmSimulationExperiment experiment = reader.readExperiment();
experiment.run();
-
+
ScenarioReport report = experiment.getScenario("test").getScenarioReport();
-
+
assertEquals(1, report.getBusinessFigureTypes().size());
assertEquals("costs", report.getBusinessFigureTypes().iterator().next());
- assertEquals(
- 40d, //
+ assertEquals(40d, //
report.getBusinessFigureValue("costs"), //
0.1);
}
-
+
/**
- * and now the same with the usage of the figure configured in the
- * experiment, no change in the process definition required
+ * and now the same with the usage of the figure configured in the experiment, no change in the
+ * process definition required
*/
-
- private String testProcessXml2 =
- "<process-definition name='test' start-distribution='startDist'>" +
- " <start-state name='start'>" +
- " <transition to='node1' />" +
- " </start-state>" +
-
- " <node name='node1'>" +
- " <transition to='end' />" +
- " </node>" +
+ private String testProcessXml2 = "<process-definition name='test' start-distribution='startDist'>"
+ +
- " <end-state name='end'/>" +
+ " <start-state name='start'>"
+ + " <transition to='node1' />"
+ + " </start-state>"
+ +
- "</process-definition>" ;
+ " <node name='node1'>"
+ + " <transition to='end' />"
+ + " </node>"
+ +
- private String experimentConfiguration2 =
- "<experiment name='MySimulationExperiment'" +
- " run-time='100'" +
- " real-start-time='01.01.1970 01:00:00:002'" +
- " time-unit='minute'>" +
- " <scenario name ='test'>" +
- " <distribution name='startDist' sample-type='real' type='constant' value='20' /> " +
+ " <end-state name='end'/>"
+ +
- " <business-figure name='testFigure' type='costs' " +
- " automatic-calculation='none'" + // | process - start | process -end"
- " handler='org.jbpm.sim.BusinessFiguresTest$BusinessFigureHandler' />" +
+ "</process-definition>";
- " <sim-process name='test'>" +
- " <node-overwrite node-name='node1'>" +
- " <calculate-business-figure name='testFigure' /> " +
- " </node-overwrite> " +
- " </sim-process>" +
-
- " </scenario>" +
- "</experiment>";
-
+ private String experimentConfiguration2 = "<experiment name='MySimulationExperiment'"
+ + " run-time='100'"
+ + " real-start-time='01.01.1970 01:00:00:002'"
+ + " time-unit='minute'>"
+ + " <scenario name ='test'>"
+ + " <distribution name='startDist' sample-type='real' type='constant' value='20' /> "
+ +
+
+ " <business-figure name='testFigure' type='costs' "
+ + " automatic-calculation='none'"
+ + // | process - start | process -end"
+ " handler='org.jbpm.sim.BusinessFiguresTest$BusinessFigureHandler' />"
+ +
+
+ " <sim-process name='test'>"
+ + " <node-overwrite node-name='node1'>"
+ + " <calculate-business-figure name='testFigure' /> "
+ + " </node-overwrite> "
+ + " </sim-process>"
+ +
+
+ " </scenario>"
+ + "</experiment>";
+
public void testBusinessFigureConfiguredInExperiment() {
ExperimentReader reader = new ExperimentReader(experimentConfiguration);
// inject process definition
- reader.addProcessDefinition("test", testProcessXml );
-
+ reader.addProcessDefinition("test", testProcessXml);
+
JbpmSimulationExperiment experiment = reader.readExperiment();
experiment.run();
-
+
ScenarioReport report = experiment.getScenario("test").getScenarioReport();
-
+
assertEquals(1, report.getBusinessFigureTypes().size());
assertEquals("costs", report.getBusinessFigureTypes().iterator().next());
- assertEquals(
- 40d, //
+ assertEquals(40d, //
report.getBusinessFigureValue("costs"), //
0.1);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/VariableSourceAndFilterTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/VariableSourceAndFilterTest.java 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/simulation/src/test/java/org/jbpm/sim/VariableSourceAndFilterTest.java 2009-05-04 09:33:28 UTC (rev 4706)
@@ -4,7 +4,6 @@
import junit.framework.TestCase;
-import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.sim.datasource.ProcessDataFilter;
@@ -14,166 +13,152 @@
import org.jbpm.sim.exe.ExperimentReader;
public class VariableSourceAndFilterTest extends TestCase {
-
- private String testProcessXml =
- "<process-definition name='test' start-distribution='startDist'>" +
- " <start-state name='start'>" +
- " <transition to='change order' />" +
- " </start-state>" +
-
- " <task-node name='change order'>" +
- " <task name='change order' swimlane='clerk' />" +
- " <transition to='end' />" +
- " </task-node>" +
+ private String testProcessXml = "<process-definition name='test' start-distribution='startDist'>"
+ + " <start-state name='start'>"
+ + " <transition to='change order' />"
+ + " </start-state>"
+ + " <task-node name='change order'>"
+ + " <task name='change order' swimlane='clerk' />"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end'/>"
+ + "</process-definition>";
- " <end-state name='end'/>" +
+ private String experimentConfiguration = "<experiment name='MySimulationExperiment'"
+ + " run-time='100'"
+ + " real-start-time='01.01.1970 01:00:00:002'"
+ + " time-unit='minute'>"
+ + " <scenario name ='test'>"
+ + " <distribution name='startDist' sample-type='real' type='constant' value='20' /> "
+ + " <distribution name='taskDist' sample-type='real' type='constant' value='20' /> "
+ + " <resource-pool name='clerk' pool-size='1'/> "
+ + " <data-source name='orders' "
+ + " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableSource' /> "
+ + " <data-filter name='orders' "
+ + " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableFilter' /> "
+ + " <sim-process name='test'>"
+ + " <process-overwrite start-distribution='startDist'> "
+ + " <use-data-source name='orders' /> "
+ + " </process-overwrite> "
+ + " <task-overwrite task-name='change order' time-distribution='taskDist'>"
+ + " <use-data-filter name='orders' /> "
+ + " </task-overwrite> "
+ + " </sim-process>"
+ + " </scenario>"
+ + "</experiment>";
- "</process-definition>" ;
-
-
- private String experimentConfiguration =
- "<experiment name='MySimulationExperiment'" +
- " run-time='100'" +
- " real-start-time='01.01.1970 01:00:00:002'" +
- " time-unit='minute'>" +
- " <scenario name ='test'>" +
- " <distribution name='startDist' sample-type='real' type='constant' value='20' /> " +
- " <distribution name='taskDist' sample-type='real' type='constant' value='20' /> " +
-
- " <resource-pool name='clerk' pool-size='1'/> " +
-
- " <data-source name='orders' " +
- " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableSource' /> " +
- " <data-filter name='orders' " +
- " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableFilter' /> " +
-
- " <sim-process name='test'>" +
- " <process-overwrite start-distribution='startDist'> " +
- " <use-data-source name='orders' /> " +
- " </process-overwrite> " +
- " <task-overwrite task-name='change order' time-distribution='taskDist'>" +
- " <use-data-filter name='orders' /> " +
- " </task-overwrite> " +
- " </sim-process>" +
-
- " </scenario>" +
- "</experiment>";
-
-//" <event type='node-enter'><action class='org.jbpm.sim.datasource.UseDataSourceAction'> " +
-//" <name>orders</name>" +
-//" </action></event>" +
-//" <event type='node-enter'><action class='org.jbpm.sim.datasource.UseDataFilterAction'> " +
-//" <name>orders</name>" +
-//" </action></event>" +
-
private static boolean dataSourceIsCalled = false;
private static boolean dataFilterIsCalled = false;
-
+
public static class TestProcessVariableSource implements ProcessDataSource {
+
public void addNextData(ExecutionContext ctx) {
dataSourceIsCalled = true;
ctx.getContextInstance().createVariable("test", "Hello Bernd");
}
+
public boolean hasNext() {
return true;
}
+
public void reset() {
}
}
-
+
public static class TestProcessVariableFilter implements ProcessDataFilter {
+
public void changeProcessData(ExecutionContext ctx) {
dataFilterIsCalled = true;
String test = (String) ctx.getContextInstance().getVariable("test");
test += ", how are you?";
ctx.getContextInstance().setVariable("test", test);
}
+
public void reset() {
}
}
-
+
public void testSourceAndFilter() {
ExperimentReader reader = new ExperimentReader(experimentConfiguration);
// inject process definition
- reader.addProcessDefinition("test", testProcessXml );
-
+ reader.addProcessDefinition("test", testProcessXml);
+
JbpmSimulationExperiment experiment = reader.readExperiment();
experiment.setRememberEndedProcessInstances(true);
experiment.run();
-
+
assertTrue(dataSourceIsCalled);
assertTrue(dataFilterIsCalled);
JbpmSimulationScenario scenario = experiment.getScenario("test");
ProcessInstance pi = (ProcessInstance) scenario.getEndedProcessInstances().iterator().next();
-
+
assertEquals("Hello Bernd, how are you?", pi.getContextInstance().getVariable("test"));
-
+
// simulation runs till the end
- assertEquals(100, scenario.getScenarioReport().getSimulationRunTime(), 0.001);
- }
-
- private String experimentConfiguration2 =
- "<experiment name='MySimulationExperiment'" +
- " run-time='100'" +
- " real-start-time='01.01.1970 01:00:00:002'" +
- " time-unit='minute'>" +
- " <scenario name ='test'>" +
- " <distribution name='startDist' sample-type='real' type='constant' value='20' /> " +
- " <distribution name='taskDist' sample-type='real' type='constant' value='20' /> " +
+ assertEquals(100, scenario.getScenarioReport().getSimulationRunTime(), 0.001);
+ }
- " <resource-pool name='clerk' pool-size='1'/> " +
+ private String experimentConfiguration2 = "<experiment name='MySimulationExperiment'"
+ + " run-time='100'"
+ + " real-start-time='01.01.1970 01:00:00:002'"
+ + " time-unit='minute'>"
+ + " <scenario name ='test'>"
+ + " <distribution name='startDist' sample-type='real' type='constant' value='20' /> "
+ + " <distribution name='taskDist' sample-type='real' type='constant' value='20' /> "
+ + " <resource-pool name='clerk' pool-size='1'/> "
+ + " <data-source name='orders' "
+ + " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableSourceExhausting' /> "
+ + " <sim-process name='test'>"
+ + " <process-overwrite start-distribution='startDist'> "
+ + " <use-data-source name='orders' /> "
+ + " </process-overwrite> "
+ + " <task-overwrite task-name='change order' time-distribution='taskDist' />"
+ + " </sim-process>"
+ + " </scenario>"
+ + "</experiment>";
- " <data-source name='orders' " +
- " handler='org.jbpm.sim.VariableSourceAndFilterTest$TestProcessVariableSourceExhausting' /> " +
-
- " <sim-process name='test'>" +
- " <process-overwrite start-distribution='startDist'> " +
- " <use-data-source name='orders' /> " +
- " </process-overwrite> " +
- " <task-overwrite task-name='change order' time-distribution='taskDist' />" +
- " </sim-process>" +
-
- " </scenario>" +
- "</experiment>";
-
private static int calledCount = 0;
-
+
public static class TestProcessVariableSourceExhausting implements ProcessDataSource {
- public void addNextData(ExecutionContext ctx) {
+
+ public void addNextData(ExecutionContext ctx) {
calledCount++;
- ctx.getContextInstance().createVariable("test", Integer.valueOf(calledCount));
+ ctx.getContextInstance().createVariable("test", new Integer(calledCount));
}
+
public boolean hasNext() {
- return (calledCount<3);
+ return (calledCount < 3);
}
+
public void reset() {
}
}
-
+
/**
- * use a data source which provides data only three times, the simulation should be
- * ended after the third query, at this time two processes are ended
+ * use a data source which provides data only three times, the simulation should be ended after
+ * the third query, at this time two processes are ended
*/
-
public void testSimulationStopIfSourceIsExhausted() {
ExperimentReader reader = new ExperimentReader(experimentConfiguration2);
// inject process definition
- reader.addProcessDefinition("test", testProcessXml );
-
+ reader.addProcessDefinition("test", testProcessXml);
+
JbpmSimulationExperiment experiment = reader.readExperiment();
experiment.setRememberEndedProcessInstances(true);
experiment.run();
-
+
JbpmSimulationScenario scenario = experiment.getScenario("test");
List processes = scenario.getEndedProcessInstances();
-
+
assertEquals(3, calledCount);
assertEquals(2, processes.size());
-
- assertEquals(Integer.valueOf(1), ((ProcessInstance)processes.get(0)).getContextInstance().getVariable("test"));
- assertEquals(Integer.valueOf(2), ((ProcessInstance)processes.get(1)).getContextInstance().getVariable("test"));
+ assertEquals(new Integer(1), ((ProcessInstance) processes.get(0)).getContextInstance()
+ .getVariable("test"));
+ assertEquals(new Integer(2), ((ProcessInstance) processes.get(1)).getContextInstance()
+ .getVariable("test"));
+
// after two processes the simulation should end, this is 60 time units
assertEquals(60, scenario.getScenarioReport().getSimulationRunTime(), 0.001);
}
Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.classpath 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.classpath 2009-05-04 09:33:28 UTC (rev 4706)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <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"/>
-</classpath>
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.project
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.project 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/userguide/.project 2009-05-04 09:33:28 UTC (rev 4706)
@@ -6,18 +6,12 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Modified: jbpm3/branches/jbpm-3.2.5.SP/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/pom.xml 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/pom.xml 2009-05-04 09:33:28 UTC (rev 4706)
@@ -47,7 +47,6 @@
<apache.cactus.version>1.8.0</apache.cactus.version>
<apache.jackrabbit.version>1.4.5</apache.jackrabbit.version>
<birt.version>2.2.2</birt.version>
- <bpm.spec.version>1.0.0-Alpha1</bpm.spec.version>
<bsh.version>1.3.0</bsh.version>
<commons.fileupload.version>1.2.1</commons.fileupload.version>
<commons.io.version>1.4</commons.io.version>
@@ -57,32 +56,23 @@
<drools.version>4.0.7</drools.version>
<dumbster.version>1.6</dumbster.version>
<hibernate.version>3.2.6.ga</hibernate.version>
- <hibernate.validator.version>3.0.0.ga</hibernate.validator.version>
<izpack.version>4.1.0</izpack.version>
<jasper.reports.version>3.0.0</jasper.reports.version>
- <javax.ejb.version>3.0</javax.ejb.version>
<javax.el.version>1.2</javax.el.version>
<javax.faces.version>1.2_03</javax.faces.version>
<javax.jcr.version>1.0.1</javax.jcr.version>
- <javax.jms.version>1.1</javax.jms.version>
- <javax.jws.version>1.0-MR1</javax.jws.version>
<javax.mail.version>1.4</javax.mail.version>
<javax.servlet.version>2.5</javax.servlet.version>
- <javax.persistence.version>1.0</javax.persistence.version>
- <javax.jaxb.version>2.1</javax.jaxb.version>
<jaxen.version>1.1.1</jaxen.version>
+ <jboss.j2ee.version>4.0.2</jboss.j2ee.version>
<jbpm.designer.version>3.1.7</jbpm.designer.version>
- <jbpm.jsf-console.version>3.2.6.SP2</jbpm.jsf-console.version>
- <jboss.client.version>4.2.2.GA</jboss.client.version>
+ <jbpm.jsf-console.version>3.2.6.SP3</jbpm.jsf-console.version>
+ <jboss.client.version>4.0.5.GA</jboss.client.version>
<jboss.gravel.version>1.0.0.GA</jboss.gravel.version>
- <jboss.seam.version>2.0.2.GA</jboss.seam.version>
<jdocbook.version>2.1.2</jdocbook.version>
<junit.version>3.8.1</junit.version>
- <oscache.version>2.4</oscache.version>
- <poi.version>3.0.2-FINAL</poi.version>
<richfaces.ui.version>3.2.1.GA</richfaces.ui.version>
<report-server.version>1.0.0.Beta1</report-server.version>
- <slf4j.version>1.5.5</slf4j.version>
<sun.facelets.version>1.1.14</sun.facelets.version>
<!-- Database Driver Versions -->
@@ -124,13 +114,6 @@
<type>war</type>
</dependency>
- <!-- BPM Spec Dependencies-->
- <dependency>
- <groupId>org.jboss.bpm</groupId>
- <artifactId>bpm-spec-api</artifactId>
- <version>${bpm.spec.version}</version>
- </dependency>
-
<!-- Thirdparty Dependencies -->
<dependency>
<groupId>bsh</groupId>
@@ -138,12 +121,6 @@
<version>${bsh.version}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.birt</groupId>
- <artifactId>report-engine</artifactId>
- <type>zip</type>
- <version>${birt.version}</version>
- </dependency>
- <dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${sun.facelets.version}</version>
@@ -194,11 +171,6 @@
<version>${jaxen.version}</version>
</dependency>
<dependency>
- <groupId>javax.ejb</groupId>
- <artifactId>ejb-api</artifactId>
- <version>${javax.ejb.version}</version>
- </dependency>
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>${javax.el.version}</version>
@@ -219,41 +191,21 @@
<version>${javax.jcr.version}</version>
</dependency>
<dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- <version>${javax.jms.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.jws</groupId>
- <artifactId>jsr181-api</artifactId>
- <version>${javax.jws.version}</version>
- </dependency>
- <dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>${javax.persistence.version}</version>
- </dependency>
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>${javax.jaxb.version}</version>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>${jboss.j2ee.version}</version>
</dependency>
<dependency>
- <groupId>opensymphony</groupId>
- <artifactId>oscache</artifactId>
- <version>${oscache.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>${apache.ant.version}</version>
@@ -289,11 +241,6 @@
<version>${hibernate.version}</version>
</dependency>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>${hibernate.validator.version}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.client</groupId>
<artifactId>jbossall-client</artifactId>
<version>${jboss.client.version}</version>
@@ -304,74 +251,11 @@
<version>${jboss.gravel.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam</artifactId>
- <version>${jboss.seam.version}</version>
- <type>ejb</type>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-debug</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-ioc</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-mail</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-pdf</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-remoting</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam-ui</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>${richfaces.ui.version}</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
- <groupId>poi</groupId>
- <artifactId>poi</artifactId>
- <version>${poi.version}</version>
- </dependency>
- <dependency>
- <groupId>poi</groupId>
- <artifactId>poi-contrib</artifactId>
- <version>${poi.version}</version>
- </dependency>
- <dependency>
- <groupId>poi</groupId>
- <artifactId>poi-scratchpad</artifactId>
- <version>${poi.version}</version>
- </dependency>
-
- <!-- Database Driver Versions -->
- <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
@@ -386,6 +270,8 @@
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
+
+ <!-- Database Driver Versions -->
</dependencies>
</dependencyManagement>
@@ -416,9 +302,10 @@
</pluginManagement>
<plugins>
<plugin>
- <artifactId>maven-surefire-plugin</artifactId>
+ <artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <testFailureIgnore>false</testFailureIgnore>
+ <source>1.4</source>
+ <target>1.4</target>
</configuration>
</plugin>
</plugins>
Modified: jbpm3/branches/jbpm-3.2.5.SP/profiles.xml.example
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/profiles.xml.example 2009-05-04 06:24:34 UTC (rev 4705)
+++ jbpm3/branches/jbpm-3.2.5.SP/profiles.xml.example 2009-05-04 09:33:28 UTC (rev 4706)
@@ -11,9 +11,9 @@
</property>
</activation>
<properties>
- <jboss422.home>/home/tdiesler/svn/jbossas/tags/JBoss_4_2_2_GA/build/output/jboss-4.2.2.GA</jboss422.home>
- <jboss423.home>/home/tdiesler/svn/jbossas/tags/JBoss_4_2_3_GA/build/output/jboss-4.2.3.GA</jboss423.home>
- <jboss500.home>/home/tdiesler/svn/jbossas/tags/JBoss_5_0_0_GA/build/output/jboss-5.0.0.GA</jboss500.home>
+ <jboss405.home>${user.home}/Downloads/jboss/jboss-4.0.5.GA</jboss405.home>
+ <jboss423.home>${user.home}/Downloads/jboss/jboss-4.2.3.GA</jboss423.home>
+ <jboss501.home>${user.home}/Downloads/jboss/jboss-5.0.1.GA</jboss501.home>
<!--
<jdbc.mysql.server>localhost</jdbc.mysql.server>
More information about the jbpm-commits
mailing list