Author: eschabell
Date: 2010-04-20 14:27:47 -0400 (Tue, 20 Apr 2010)
New Revision: 6264
Added:
projects/exception_framework/trunk/pom.xml
projects/exception_framework/trunk/src/
projects/exception_framework/trunk/src/main/
projects/exception_framework/trunk/src/main/config/
projects/exception_framework/trunk/src/main/config/hibernate.cfg.hsqldb.xml
projects/exception_framework/trunk/src/main/config/hibernate.cfg.xml
projects/exception_framework/trunk/src/main/config/jbpm-hsqldb-ds.xml
projects/exception_framework/trunk/src/main/config/jbpm.cfg.xml
projects/exception_framework/trunk/src/main/config/jbpm.mail.templates.xml
projects/exception_framework/trunk/src/main/config/log4j.properties
projects/exception_framework/trunk/src/main/config/version.info.xml
projects/exception_framework/trunk/src/main/java/
projects/exception_framework/trunk/src/main/java/org/
projects/exception_framework/trunk/src/main/java/org/jboss/
projects/exception_framework/trunk/src/main/java/org/jboss/handler/
projects/exception_framework/trunk/src/main/java/org/jboss/handler/AbstractExceptionActionHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/handler/DetermineExceptionHandlingHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/handler/HumanTaskHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/handler/RetryHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/handler/StartExceptionFrameworkHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/handler/TriggerOriginatingProcessHandler.java
projects/exception_framework/trunk/src/main/java/org/jboss/util/
projects/exception_framework/trunk/src/main/java/org/jboss/util/ThreadPoolSingleton.java
projects/exception_framework/trunk/src/main/jpdl/
projects/exception_framework/trunk/src/main/jpdl/process/
projects/exception_framework/trunk/src/main/jpdl/process/gpd.xml
projects/exception_framework/trunk/src/main/jpdl/process/processdefinition.xml
projects/exception_framework/trunk/src/main/jpdl/process/processimage.jpg
projects/exception_framework/trunk/src/test/
projects/exception_framework/trunk/src/test/java/
projects/exception_framework/trunk/src/test/java/org/
projects/exception_framework/trunk/src/test/java/org/jboss/
projects/exception_framework/trunk/src/test/java/org/jboss/handler/
projects/exception_framework/trunk/src/test/java/org/jboss/handler/ExceptionThrowingHandler.java
projects/exception_framework/trunk/src/test/java/org/jboss/test/
projects/exception_framework/trunk/src/test/java/org/jboss/test/TestForNodeExceptionHandling.java
projects/exception_framework/trunk/src/test/java/org/jboss/util/
projects/exception_framework/trunk/src/test/java/org/jboss/util/ProcessDefinitionReference.java
projects/exception_framework/trunk/src/test/java/org/jboss/util/TaskCallback.java
Modified:
projects/exception_framework/trunk/
projects/exception_framework/trunk/readme.txt
Log:
Initial project code commit, working node unit test that makes use of an exception
framework, see readme for details.
Property changes on: projects/exception_framework/trunk
___________________________________________________________________
Name: svn:ignore
+ .settings
bin
target
.classpath
.project
Added: projects/exception_framework/trunk/pom.xml
===================================================================
--- projects/exception_framework/trunk/pom.xml (rev 0)
+++ projects/exception_framework/trunk/pom.xml 2010-04-20 18:27:47 UTC (rev 6264)
@@ -0,0 +1,70 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>exception_framework</groupId>
+ <artifactId>exception_framework</artifactId>
+ <name>Exception Framework</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <description>A generic jBPM exception framework.</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>surefire-report-maven-plugin</artifactId>
+ <version>2.0-beta-1</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <name>Maven Repository jboss</name>
+ <layout>default</layout>
+ <
url>http://repository.jboss.com/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm3</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>3.2.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.15</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <version>1.1</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mod4j.org.apache.commons</groupId>
+ <artifactId>lang</artifactId>
+ <version>2.1.0</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Modified: projects/exception_framework/trunk/readme.txt
===================================================================
--- projects/exception_framework/trunk/readme.txt 2010-04-20 17:54:48 UTC (rev 6263)
+++ projects/exception_framework/trunk/readme.txt 2010-04-20 18:27:47 UTC (rev 6264)
@@ -1,5 +1,16 @@
Project space to put together the results of a generic exception framework
-example for jBPM v3.2.x. Coming soon...
+example based on jBPM version 3.2.5.SP5.
+Currently only running a test to show simple node failing, then passing exception and
+all process context over to the Exception Framework. This framework defaults currently
+to a Human Task for processing the error. In our test we end this task to continue
+processing and go back to the originating process.
+
+TODO: State node failure example via unit test class.
+
+With my thanks to Maurice de Chateau for his contributions.
+
+Regards,
Eric D. Schabell
-
+eric(a)schabell.org
+erics(a)redhat.com
\ No newline at end of file
Added: projects/exception_framework/trunk/src/main/config/hibernate.cfg.hsqldb.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/hibernate.cfg.hsqldb.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/hibernate.cfg.hsqldb.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,263 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!-- hibernate dialect -->
+ <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+
+ <!-- JDBC connection properties (begin) -->
+ <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:jbpm</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <!-- JDBC connection properties (end) -->
+
+ <!-- DataSource properties (begin) ===
+ <property
name="hibernate.connection.datasource">java:comp/env/jdbc/JbpmDataSource</property>
+ ==== DataSource properties (end) -->
+
+ <!-- JTA transaction properties (begin) ===
+ <property
name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+ <property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ ==== JTA transaction properties (end) -->
+
+ <!-- CMT transaction properties (begin) ===
+ <property
name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
+ <property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ ==== CMT transaction properties (end) -->
+
+ <!-- ################################### -->
+ <!-- # common settings # -->
+ <!-- ################################### -->
+
+ <!-- Automatic schema creation (begin) -->
+ <property name="hibernate.hbm2ddl.auto">create</property>
+ <!-- Automatic schema creation (end) -->
+
+ <!-- Simple memory-only cache -->
+ <property
name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
+ <!-- SQL rendering properties -->
+ <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.use_sql_comments">true</property>
+
+ <!-- ############################################ -->
+ <!-- # mapping files with external dependencies # -->
+ <!-- ############################################ -->
+
+ <!-- Additional mappings defined per module go here -->
+ <!--mapping resource="hibernate.extra.hbm.xml" /-->
+ <!--mapping resource="hibernate.identity.hbm.xml" /-->
+
+ <!-- ###################### -->
+ <!-- # jbpm mapping files # -->
+ <!-- ###################### -->
+
+ <!-- hql queries -->
+ <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml" />
+
+ <!-- type mappings -->
+ <mapping resource="org/jbpm/db/hibernate.types.hbm.xml" />
+
+ <!-- hql queries used in simulation for querying historical data.
+ uncomment if you want to use the GetSimulationInputCommand
+ or you want to use the queries directly.
+ beware: the queries need the stddev function to be enabled in your dialect.
+ for more information, visit:
+
http://www.camunda.com/business_process_simulation_news/mysql_and_stddev....
-->
+ <!--
+ <mapping resource="org/jbpm/sim/bam/hibernate.queries.hbm.xml" />
+ -->
+
+ <!-- graph.action mapping files -->
+ <mapping resource="org/jbpm/graph/action/MailAction.hbm.xml"/>
+
+ <!-- graph.def mapping files -->
+ <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>
+ <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>
+
+ <!-- ########################################### -->
+ <!-- # mapping file with external dependencies # -->
+ <!-- ########################################### -->
+ <!-- the following mapping file has a dependency on 'bsh-{version}.jar'.
+ uncomment this if bsh is not in your classpath.
+ the script element will not be available in process definition files.
+ note: this mapping must appear below org/jbpm/graph/def/Action.hbm.xml -->
+ <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>
+
+ <!-- graph.node mapping files -->
+ <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/MailNode.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>
+
+ <!-- context.def mapping files -->
+ <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>
+
+ <!-- bytes mapping files -->
+ <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>
+
+ <!-- module.def mapping files -->
+ <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>
+
+ <!-- file.def mapping files -->
+ <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>
+
+ <!-- taskmgmt.def mapping files -->
+ <mapping
resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>
+
+ <!-- scheduler.def mapping files -->
+ <mapping
resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>
+ <mapping
resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>
+
+ <!-- graph.exe mapping files -->
+ <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>
+
+ <!-- module.exe mapping files -->
+ <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>
+
+ <!-- context.exe mapping files -->
+ <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
+
+ <!-- job mapping files -->
+ <mapping resource="org/jbpm/job/Job.hbm.xml"/>
+ <mapping resource="org/jbpm/job/Timer.hbm.xml"/>
+ <mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/>
+ <mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/>
+ <mapping resource="org/jbpm/job/CleanUpProcessJob.hbm.xml"/>
+
+ <!-- taskmgmt.exe mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>
+
+ <!-- logging mapping files -->
+ <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>
+
+ <!-- ################## -->
+ <!-- # cache settings # -->
+ <!-- ##################-->
+
+ <!-- strategy="nonstrict-read-write" can be used with
HashtableCacheProvider -->
+
+ <class-cache class="org.jbpm.bytes.ByteArray"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.bytes.ByteArray.byteBlocks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.context.def.VariableAccess"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.file.def.FileDefinition.processFiles"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.action.Script.variableAccesses"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Action"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Event"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Event.actions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.ExceptionHandler"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ExceptionHandler.actions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Node"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Node.events"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Node.exceptionHandlers"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Node.leavingTransitions"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Node.arrivingTransitions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.ProcessDefinition"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.exceptionHandlers"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.nodes"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.actions"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.definitions"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.graph.def.SuperState.nodes"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Transition"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Transition.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Transition.exceptionHandlers"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.node.Decision.decisionConditions"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.node.ProcessState.variableAccesses"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.graph.node.TaskNode.tasks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.instantiation.Delegation"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.module.def.ModuleDefinition"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.taskmgmt.def.Swimlane.tasks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.taskmgmt.def.TaskController"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskController.variableAccesses"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.taskmgmt.def.Task"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.taskmgmt.def.Task.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.Task.exceptionHandlers"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.swimlanes"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.tasks"
usage="nonstrict-read-write" />
+ </session-factory>
+</hibernate-configuration>
Property changes on:
projects/exception_framework/trunk/src/main/config/hibernate.cfg.hsqldb.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/hibernate.cfg.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/hibernate.cfg.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/hibernate.cfg.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,265 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!-- hibernate dialect -->
+ <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+
+ <!-- JDBC connection properties (begin) -->
+ <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:jbpm</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <!-- JDBC connection properties (end) -->
+
+ <!-- DataSource properties (begin) ===
+ <property
name="hibernate.connection.datasource">java:comp/env/jdbc/JbpmDataSource</property>
+ ==== DataSource properties (end) -->
+
+ <!-- JTA transaction properties (begin) ===
+ <property
name="jta.UserTransaction">UserTransaction</property>
+ <property
name="hibernate.current_session_context_class">jta</property>
+ <property
name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+ <property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ ==== JTA transaction properties (end) -->
+
+ <!-- CMT transaction properties (begin) ===
+ <property
name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
+ <property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ ==== CMT transaction properties (end) -->
+
+ <!-- ################################### -->
+ <!-- # common settings # -->
+ <!-- ################################### -->
+
+ <!-- Automatic schema creation (begin) -->
+ <property name="hibernate.hbm2ddl.auto">create</property>
+ <!-- Automatic schema creation (end) -->
+
+ <!-- Simple memory-only cache -->
+ <property
name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
+ <!-- SQL rendering properties -->
+ <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.use_sql_comments">true</property>
+
+ <!-- ############################################ -->
+ <!-- # mapping files with external dependencies # -->
+ <!-- ############################################ -->
+
+ <!-- Additional mappings defined per module go here -->
+ <!-- mapping resource="hibernate.extra.hbm.xml" /-->
+ <!--mapping resource="hibernate.identity.hbm.xml" /-->
+
+ <!-- ###################### -->
+ <!-- # jbpm mapping files # -->
+ <!-- ###################### -->
+
+ <!-- hql queries -->
+ <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml" />
+
+ <!-- type mappings -->
+ <mapping resource="org/jbpm/db/hibernate.types.hbm.xml" />
+
+ <!-- hql queries used in simulation for querying historical data.
+ uncomment if you want to use the GetSimulationInputCommand
+ or you want to use the queries directly.
+ beware: the queries need the stddev function to be enabled in your dialect.
+ for more information, visit:
+
http://www.camunda.com/business_process_simulation_news/mysql_and_stddev....
-->
+ <!--
+ <mapping resource="org/jbpm/sim/bam/hibernate.queries.hbm.xml" />
+ -->
+
+ <!-- graph.action mapping files -->
+ <mapping resource="org/jbpm/graph/action/MailAction.hbm.xml"/>
+
+ <!-- graph.def mapping files -->
+ <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>
+ <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>
+
+ <!-- ########################################### -->
+ <!-- # mapping file with external dependencies # -->
+ <!-- ########################################### -->
+ <!-- the following mapping file has a dependency on 'bsh-{version}.jar'.
+ uncomment this if bsh is not in your classpath.
+ the script element will not be available in process definition files.
+ note: this mapping must appear below org/jbpm/graph/def/Action.hbm.xml -->
+ <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>
+
+ <!-- graph.node mapping files -->
+ <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/MailNode.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>
+
+ <!-- context.def mapping files -->
+ <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>
+
+ <!-- bytes mapping files -->
+ <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>
+
+ <!-- module.def mapping files -->
+ <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>
+
+ <!-- file.def mapping files -->
+ <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>
+
+ <!-- taskmgmt.def mapping files -->
+ <mapping
resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>
+
+ <!-- scheduler.def mapping files -->
+ <mapping
resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>
+ <mapping
resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>
+
+ <!-- graph.exe mapping files -->
+ <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>
+
+ <!-- module.exe mapping files -->
+ <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>
+
+ <!-- context.exe mapping files -->
+ <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
+
+ <!-- job mapping files -->
+ <mapping resource="org/jbpm/job/Job.hbm.xml"/>
+ <mapping resource="org/jbpm/job/Timer.hbm.xml"/>
+ <mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/>
+ <mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/>
+ <mapping resource="org/jbpm/job/CleanUpProcessJob.hbm.xml"/>
+
+ <!-- taskmgmt.exe mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>
+
+ <!-- logging mapping files -->
+ <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>
+
+ <!-- ################## -->
+ <!-- # cache settings # -->
+ <!-- ##################-->
+
+ <!-- strategy="nonstrict-read-write" can be used with
HashtableCacheProvider -->
+
+ <class-cache class="org.jbpm.bytes.ByteArray"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.bytes.ByteArray.byteBlocks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.context.def.VariableAccess"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.file.def.FileDefinition.processFiles"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.action.Script.variableAccesses"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Action"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Event"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Event.actions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.ExceptionHandler"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ExceptionHandler.actions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Node"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Node.events"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Node.exceptionHandlers"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Node.leavingTransitions"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Node.arrivingTransitions"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.ProcessDefinition"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.exceptionHandlers"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.nodes"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.actions"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.ProcessDefinition.definitions"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.graph.def.SuperState.nodes"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.graph.def.Transition"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.graph.def.Transition.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.graph.def.Transition.exceptionHandlers"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.node.Decision.decisionConditions"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.graph.node.ProcessState.variableAccesses"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.graph.node.TaskNode.tasks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.instantiation.Delegation"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.module.def.ModuleDefinition"
usage="nonstrict-read-write" />
+
+ <collection-cache collection="org.jbpm.taskmgmt.def.Swimlane.tasks"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.taskmgmt.def.TaskController"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskController.variableAccesses"
usage="nonstrict-read-write" />
+
+ <class-cache class="org.jbpm.taskmgmt.def.Task"
usage="nonstrict-read-write" />
+ <collection-cache collection="org.jbpm.taskmgmt.def.Task.events"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.Task.exceptionHandlers"
usage="nonstrict-read-write" />
+
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.swimlanes"
usage="nonstrict-read-write" />
+ <collection-cache
collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.tasks"
usage="nonstrict-read-write" />
+ </session-factory>
+</hibernate-configuration>
Property changes on: projects/exception_framework/trunk/src/main/config/hibernate.cfg.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/jbpm-hsqldb-ds.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/jbpm-hsqldb-ds.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/jbpm-hsqldb-ds.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+ <local-tx-datasource>
+ <jndi-name>JbpmDS</jndi-name>
+
+
<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}jbpmDB</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+
+ <!-- disable idle connection removal, hsqldb does not reap threads on closed
connections -->
+ <idle-timeout-minutes>0</idle-timeout-minutes>
+ <!-- check all statements are closed when the connection is returned to the pool
-->
+ <track-statements />
+ <!-- hsqldb benefits from prepared statement caching -->
+ <prepared-statement-cache-size>32</prepared-statement-cache-size>
+
+ <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+ <type-mapping>Hypersonic SQL</type-mapping>
+
+ <!-- ensure the datasource is not initialized before the database itself -->
+ <depends>jboss:service=Hypersonic,database=jbpmDB</depends>
+ </local-tx-datasource>
+
+ <!-- for hsqldb accessed from jboss only, in-process (standalone) mode -->
+ <mbean code="org.jboss.jdbc.HypersonicDatabase"
name="jboss:service=Hypersonic,database=jbpmDB">
+ <attribute name="Database">jbpmDB</attribute>
+ <attribute name="InProcessMode">true</attribute>
+ </mbean>
+
+</datasources>
Property changes on:
projects/exception_framework/trunk/src/main/config/jbpm-hsqldb-ds.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/jbpm.cfg.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/jbpm.cfg.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/jbpm.cfg.xml 2010-04-20 18:27:47
UTC (rev 6264)
@@ -0,0 +1,9 @@
+<jbpm-configuration>
+
+ <!--
+ The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
+ Those configurations can be overwritten by putting this file called
+ jbpm.cfg.xml on the root of the classpath and put in the customized values.
+ -->
+
+</jbpm-configuration>
Property changes on: projects/exception_framework/trunk/src/main/config/jbpm.cfg.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/jbpm.mail.templates.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/jbpm.mail.templates.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/jbpm.mail.templates.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,24 @@
+<mail-templates>
+
+ <variable name="BaseTaskListURL"
value="http://localhost:8080/jbpm/home?taskId=" />
+
+ <mail-template name='task-assign'>
+ <actors>#{taskInstance.actorId}</actors>
+ <subject>Task '#{taskInstance.name}'</subject>
+ <text><![CDATA[Hi,
+Task '#{taskInstance.name}' has been assigned to you.
+Go for it: #{BaseTaskListURL}#{taskInstance.id}
+Thanks.
+---powered by JBoss jBPM---]]></text>
+ </mail-template>
+
+ <mail-template name='task-reminder'>
+ <actors>#{taskInstance.actorId}</actors>
+ <subject>Task '#{taskInstance.name}' !</subject>
+ <text><![CDATA[Hey,
+Don't forget about #{BaseTaskListURL}#{taskInstance.id}
+Get going !
+---powered by JBoss jBPM---]]></text>
+ </mail-template>
+
+</mail-templates>
Property changes on:
projects/exception_framework/trunk/src/main/config/jbpm.mail.templates.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/log4j.properties
===================================================================
--- projects/exception_framework/trunk/src/main/config/log4j.properties
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/log4j.properties 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,36 @@
+# Set root logger level to DEBUG and its only appender to CONSOLE.
+log4j.rootLogger=DEBUG, CONSOLE
+
+# CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %C{1} : %m%n
+
+# LIMIT CATEGORIES:
+log4j.logger.org.jbpm=ERROR
+log4j.logger.org.jbpm.graph=ERROR
+
+# Hibernate debugging levels and their output
+log4j.logger.org.hibernate=ERROR
+#Log all SQL DML statements as they are executed
+#log4j.logger.org.hibernate.SQL=DEBUG
+#Log all JDBC parameters
+#log4j.logger.org.hibernate.type=DEBUG
+#Log all SQL DDL statements as they are executed
+#log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG
+#Log the state of all entities (max 20 entities) associated with the session at flush
time
+#log4j.logger.org.hibernate.pretty=DEBUG
+#Log all second-level cache activity
+#log4j.logger.org.hibernate.cache=DEBUG
+#Log transaction related activity
+#log4j.logger.org.hibernate.transaction=DEBUG
+#Log all JDBC resource acquisition
+#log4j.logger.org.hibernate.jdbc=TRACE
+#Log HQL and SQL ASTs and other information about query parsing
+#log4j.logger.org.hibernate.hql.ast=DEBUG
+#Log all JAAS authorization requests
+#log4j.logger.org.hibernate.secure=DEBUG
+#Log everything (a lot of information, but very useful for troubleshooting)
+#log4j.logger.org.hibernate=DEBUG
+#log4j.logger.org.hibernate.tools=DEBUG
+
Property changes on: projects/exception_framework/trunk/src/main/config/log4j.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/exception_framework/trunk/src/main/config/version.info.xml
===================================================================
--- projects/exception_framework/trunk/src/main/config/version.info.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/config/version.info.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,21 @@
+<jbpm-version-info name="jBPM3"
namespace="urn:jbpm.org:jpdl-3.2">
+
+ <classpathentry path="lib/jbpm-jpdl.jar"
src="src/jbpm-jpdl-sources.jar" />
+ <classpathentry path="lib/jbpm-identity.jar"
src="src/jbpm-identity-sources.jar" />
+
+ <classpathentry path="lib/antlr.jar" />
+ <classpathentry path="lib/asm.jar"/>
+ <classpathentry path="lib/bsh.jar"/>
+ <classpathentry path="lib/cglib.jar"/>
+ <classpathentry path="lib/commons-collections.jar"/>
+ <classpathentry path="lib/commons-logging.jar"/>
+ <classpathentry path="lib/dom4j.jar"/>
+ <classpathentry path="lib/hibernate.jar"/>
+ <classpathentry path="lib/hsqldb.jar"/>
+ <classpathentry path="lib/junit.jar"/>
+ <classpathentry path="lib/log4j.jar"/>
+
+ <config path="config"/>
+ <examples path="examples" />
+
+</jbpm-version-info>
Property changes on: projects/exception_framework/trunk/src/main/config/version.info.xml
___________________________________________________________________
Name: svn:executable
+ *
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/AbstractExceptionActionHandler.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/handler/AbstractExceptionActionHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/AbstractExceptionActionHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,208 @@
+package org.jboss.handler;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jboss.util.ThreadPoolSingleton;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.Token;
+import org.jbpm.graph.node.State;
+import org.jbpm.instantiation.ProcessClassLoader;
+import org.jbpm.util.ClassLoaderUtil;
+
+/**
+ * Base class for ActionHandler which call services.
+ */
+public abstract class AbstractExceptionActionHandler implements ActionHandler {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 1L;
+
+ public static final String EXCEPTION_ORIGINATING_NODE_NAME_KEY =
"EXCEPTION_ORIGINATING_NODE_NAME";
+
+ private String transitionName;
+
+ /** False means you are using our exception framework handling of exceptions. */
+ private boolean useJbpmExceptionHandler = false;
+
+ private boolean signalAfterException = false;
+
+ protected final String getCurrentAction() {
+ return "action handling";
+ }
+
+ /** Logging facility. */
+ private static final Logger LOGGER =
Logger.getLogger(AbstractExceptionActionHandler.class);
+
+
+ public final void execute(ExecutionContext executionContext) throws Exception {
+
+ getLogger().info("Start AbstractExceptionActionHanlder.");
+
+ ExecutionContext.pushCurrentContext(executionContext);
+ try {
+ if (executionContext.getNode() instanceof State) {
+ // Asynchronous handling.
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Scheduling async job [" + getClass().getName() +
"] for process instance " + executionContext.getProcessInstance().getId());
+ }
+
+ // Dig into Hibernate here to accomplish transaction isolation.
+ executionContext.getJbpmContext().getSession().getTransaction().registerSynchronization(
+ new ServiceRunner(executionContext.getToken().getId(), getClass().getName()));
+ } else {
+ try {
+ // Synchronous handling: Perform the action directly.
+ getLogger().debug("Performing action on Node with id: " +
executionContext.getProcessInstance().getId());
+ doPerformAction(executionContext);
+ } catch (Exception ex) {
+ getLogger().error("Handler threw exception.", ex);
+ getLogger().debug("Using jBPMExceptionHandler for exception caught on Node with
id: " + executionContext.getProcessInstance().getId());
+ executionContext.getNode().raiseException(ex, executionContext);
+ }
+ }
+ } catch (Exception ex) {
+ if (getLogger().isInfoEnabled()) {
+ getLogger().info(("Exception caught during
AbstractExceptionActionHandling."), ex);
+ }
+ } finally {
+ ExecutionContext.popCurrentContext(executionContext);
+ }
+
+ getLogger().info("Ended AbstractExceptionActionHanlder.");
+ }
+
+
+ /**
+ * Implement this method for processing a single node.
+ *
+ * @param executionContext An execution context.
+ * @throws Exception For all unexpected errors.
+ */
+ public abstract void doPerformAction(ExecutionContext executionContext) throws
Exception;
+
+ /**
+ * Set this flag when it is required to have the process signalled 'normally'
in case an exception is caught (and handled)
+ * within the asynchronous part of the handling.
+ * <p>
+ * The default behaviour is that no signalling takes place; this puts the
responsibility of the progress of the process in the
+ * hands of the mechanism handling the exception.
+ *
+ * @param signal Whether signalling is to take place after exception handling.
+ */
+ protected final void setSignalAfterException(final boolean signal) {
+ signalAfterException = signal;
+ }
+
+ /**
+ * Set the transition to be taken for an asynchronous execution.
+ *
+ * @param transitionName The name of the transition.
+ */
+ protected void setTransition(String transitionName) {
+ this.transitionName = transitionName;
+ }
+
+ /**
+ * Set whether the 'standard' jBPM <exception-handler> construct in the
+ * process definition is to be used for the exception handling for an
+ * asynchronous execution.
+ * <p>
+ * The default behaviour for this class is to handle it implicitly and
+ * redirect the flow towards an exception handling node, which is required
+ * to be present in the definition (and its name in the context).
+ *
+ * @param useJbpmExceptionHandler
+ * Indicating whether (or not) to use the jBPM mechanism. By
+ * default this value is <code>false</code>.
+ */
+ protected final void useJbpmExceptionHandler(
+ final boolean useJbpmExceptionHandler) {
+ this.useJbpmExceptionHandler = useJbpmExceptionHandler;
+ }
+
+
+ /**
+ * Inner class which performs the actual action handling for asynchronous
+ * State nodes.
+ */
+ class ServiceRunner implements Runnable, Synchronization {
+ private long tokenId;
+ private String handlerClassName;
+
+ public ServiceRunner(long tokenId, String handlerClassName) {
+ this.tokenId = tokenId;
+ this.handlerClassName = handlerClassName;
+ }
+
+ /** {@inheritDoc} */
+ public void run() {
+ JbpmContext jbpmCtx = JbpmConfiguration.getInstance().createJbpmContext();
+ try {
+ // Get the token in which the process is waiting.
+ final Token token = jbpmCtx.getTokenForUpdate(tokenId);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ // Perform the action in the concrete subclass.
+ ExecutionContext.pushCurrentContext(executionContext);
+ AbstractExceptionActionHandler currentHandler = null;
+ boolean exceptionCaught = false;
+ try {
+ ClassLoader cl = AccessController.doPrivileged(new
PrivilegedAction<ProcessClassLoader>() {
+ public ProcessClassLoader run() {
+ return new ProcessClassLoader(ClassLoaderUtil.class.getClassLoader(),
token.getProcessInstance().getProcessDefinition());
+ }
+ });
+ currentHandler = (AbstractExceptionActionHandler) cl.loadClass(
+ handlerClassName).newInstance();
+ currentHandler.doPerformAction(executionContext);
+ } catch (Exception ex) {
+ getLogger().error("Handler threw exception.", ex);
+ executionContext.getNode().raiseException(ex, executionContext);
+ exceptionCaught = true;
+ } finally {
+ ExecutionContext.popCurrentContext(executionContext);
+ }
+
+ // Move the process along, if applicable.
+ if (!exceptionCaught || !useJbpmExceptionHandler || signalAfterException) {
+ if (!StringUtils.isBlank(transitionName) &&
executionContext.getNode().hasLeavingTransition(transitionName)) {
+ token.signal(transitionName);
+ } else {
+ // Use the default transition.
+ token.signal();
+ }
+ }
+ } finally {
+ jbpmCtx.close();
+ }
+ }
+
+ /** Inherited method not used here. */
+ public void beforeCompletion() {
+ // Not used here.
+ }
+
+ public void afterCompletion(int status) {
+ if (getLogger().isDebugEnabled()
+ && status != Status.STATUS_COMMITTED && status !=
Status.STATUS_ROLLEDBACK) {
+ getLogger().debug("Attempting to start asynchronous action handling while tx
status was " + status);
+ }
+
+ // The original transaction is completed, a new one can be started.
+ ThreadPoolSingleton.INSTANCE.executeServiceCall(this);
+ }
+ }
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/DetermineExceptionHandlingHandler.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/handler/DetermineExceptionHandlingHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/DetermineExceptionHandlingHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,50 @@
+package org.jboss.handler;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.node.DecisionHandler;
+
+/**
+ * Handler for deciding whether it is applicable to automatically have the
+ * Exception throwing node retry its business.
+ */
+public class DetermineExceptionHandlingHandler implements DecisionHandler {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 1L;
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger
+ .getLogger(DetermineExceptionHandlingHandler.class);
+
+ private static final String DROPOUT_TRANSITION_NAME = "No";
+ private static final String RETRY_TRANSITION_NAME = "Yes";
+
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+
+ public String decide(ExecutionContext executionContext) throws Exception {
+ // TODO Auto-generated method stub
+ // check for our path of execution in exception handling.
+ String transition = null;
+ if
(executionContext.getContextInstance().getVariable("take_exception_transtion")
!= null) {
+ getLogger().debug("Determined that context variable with name: "
+ +
executionContext.getContextInstance().getVariable("take_exception_transtion")
+ + " exists!");
+ transition = (String)
executionContext.getContextInstance().getVariable("take_exception_transtion");
+ }
+
+ // TODO: Determine from configuration data whether the Exception that is
+ // handled here is applicable to be retried automatically.
+
+ if ( StringUtils.isNotBlank(transition) && StringUtils.equals(transition,
"retry")) {
+ getLogger().debug("Determine Exception Handling Handler choosing transition:
" + RETRY_TRANSITION_NAME);
+ return RETRY_TRANSITION_NAME;
+ }
+
+ getLogger().debug("Determine Exception Handling Handler choosing transition:
" + DROPOUT_TRANSITION_NAME);
+ return DROPOUT_TRANSITION_NAME;
+ }
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/HumanTaskHandler.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/handler/HumanTaskHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/HumanTaskHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,51 @@
+package org.jboss.handler;
+
+import org.apache.log4j.Logger;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.exe.ExecutionContext;
+
+/**
+ * Handler for preparing before and following up after a manual human task.
+ */
+public class HumanTaskHandler extends AbstractExceptionActionHandler {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 1L;
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(HumanTaskHandler.class);
+
+ // Transition names.
+ private static final String RETRY_TRANSITION_NAME = "Retry";
+
+ public void doPerformAction(ExecutionContext executionContext) throws Exception {
+ if (Event.EVENTTYPE_NODE_LEAVE.equals(executionContext.getEvent().getEventType())
&& RETRY_TRANSITION_NAME.equals(executionContext.getTransition().getName())) {
+ getLogger().debug("Have EVENTTYPE_NODE_LEAVE so updating retry transistions
before going further!");
+ getLogger().debug("Picked up event type " +
executionContext.getEvent().getEventType() + " and transition name is " +
executionContext.getTransition().getName());
+ updateRetryTransition(executionContext);
+ }
+ }
+
+ /**
+ * Point the retry transition to the Node from which the Exception
+ * originated.
+ *
+ * @param executionContext The current jBPM context.
+ */
+ private void updateRetryTransition(ExecutionContext executionContext) {
+ String name = (String)
executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_NAME_KEY);
+ Node originatingNode = executionContext.getProcessDefinition().getNode(name);
+ getLogger().debug("updateRetryTranisition EXCEPTION_ORIGINATING_NODE_NAME_KEY is:
" + name);
+ if (originatingNode == null) {
+ String msg = "No originating node available for retry after exception
handling.";
+ LOGGER.error(msg);
+ throw new IllegalStateException(msg);
+ }
+
+ executionContext.getNode().getLeavingTransition(RETRY_TRANSITION_NAME).setTo(originatingNode);
+ }
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/RetryHandler.java
===================================================================
--- projects/exception_framework/trunk/src/main/java/org/jboss/handler/RetryHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/RetryHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,47 @@
+package org.jboss.handler;
+
+import org.apache.log4j.Logger;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ExecutionContext;
+
+/**
+ * Handler for retrying a node that threw an Exception before, after the waiting
+ * period configured for the specific situation.
+ */
+public class RetryHandler extends AbstractExceptionActionHandler {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 1L;
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(RetryHandler.class);
+
+ public void doPerformAction(ExecutionContext executionContext) throws Exception {
+ // TODO: Determine the waiting period from the configuration.
+
+ // TODO: Wait the applicable period.
+
+ // Check whether a leaving transition is available.
+ Transition transition = executionContext.getNode().getDefaultLeavingTransition();
+ getLogger().debug("Default leaving transition from RetryHandler is: " +
transition);
+ if (transition == null) {
+ // Create a transition.
+ transition = new Transition();
+ executionContext.getNode().addLeavingTransition(transition);
+ getLogger().debug("Leaving transition from RetryHandler has been set to: " +
transition);
+ }
+ // Set the transition to the originating node.
+ Node originatingNode =
executionContext.getProcessDefinition().getNode(EXCEPTION_ORIGINATING_NODE_NAME_KEY);
+ if (originatingNode == null) {
+ String msg = "No originating node available for retry after exception
handling.";
+ LOGGER.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ getLogger().debug("Transition from RetryHandler is being set to: " +
originatingNode);
+ transition.setTo(originatingNode);
+ }
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/StartExceptionFrameworkHandler.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/handler/StartExceptionFrameworkHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/StartExceptionFrameworkHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,90 @@
+package org.jboss.handler;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+
+public class StartExceptionFrameworkHandler implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Context variable keys for storing exception information. */
+ public static final String EXCEPTION_ORIGINATING_NODE_NAME_KEY =
"EXCEPTION_ORIGINATING_NODE_NAME";
+ public static final String EXCEPTION_ORIGINATING_PROCESS_NAME_KEY =
"EXCEPTION_ORIGINATING_PROCESS_NAME";
+ public static final String EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY =
"EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST";
+ public static final String EXCEPTION_ORIGINATING_PROCESS_ID_KEY =
"EXCEPTION_ORIGINATING_PROCESS_ID";
+ public static final String EXCEPTION_FRAMEWORK_PROCESS_ID_KEY =
"EXCEPTION_FRAMEWORK_PROCESS_ID";
+
+ /** Exception framework process name. */
+ public static final String EXCEPTION_FRAMEWORK_PROCESS_NAME_KEY = "Exception
Framework";
+
+ /** Logging facility. */
+ private static final Logger LOGGER =
Logger.getLogger(StartExceptionFrameworkHandler.class);
+
+ /** Holds our process instance. */
+ private ProcessInstance processInstance;
+
+ /**
+ * Handler starts the exception framework.
+ */
+ public final void execute(ExecutionContext executionContext) throws Exception {
+
+ getLogger().info("Start StartExceptionFrameworkHanlder.");
+
+ try {
+ // get new instance of exception framework and start processing!
+ List<ProcessDefinition> listProcs =
executionContext.getJbpmContext().getGraphSession().findAllProcessDefinitions();
+
+ if (getLogger().isDebugEnabled()) {
+ for (ProcessDefinition processDefinition : listProcs) {
+ getLogger().debug("Process definition is: " + processDefinition + "
with version: " + processDefinition.getVersion() + ".");
+ }
+ }
+ processInstance =
executionContext.getJbpmContext().newProcessInstance(EXCEPTION_FRAMEWORK_PROCESS_NAME_KEY);
+ if (getLogger().isDebugEnabled()) {
+ if (processInstance == null) {
+ getLogger().debug("Process instance of exception framework was not
created.");
+ }
+ getLogger().debug("Passing the process instance of exception framework to
be signaled.");
+ }
+
+ // push the exception framework process id into the context.
+ executionContext.setVariable(EXCEPTION_FRAMEWORK_PROCESS_ID_KEY,
processInstance.getRootToken().getId());
+
+ // push originating stuff.
+
processInstance.getContextInstance().setVariable(EXCEPTION_ORIGINATING_NODE_NAME_KEY,
executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_NAME_KEY));
+
processInstance.getContextInstance().setVariable(EXCEPTION_ORIGINATING_PROCESS_NAME_KEY,
executionContext.getVariable(EXCEPTION_ORIGINATING_PROCESS_NAME_KEY));
+
processInstance.getContextInstance().setVariable(EXCEPTION_ORIGINATING_PROCESS_ID_KEY,
executionContext.getVariable(EXCEPTION_ORIGINATING_PROCESS_ID_KEY));
+
processInstance.getContextInstance().setVariable(EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY,
executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY));
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Set variable " +
EXCEPTION_ORIGINATING_NODE_NAME_KEY + " for process instance with value :" +
executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_NAME_KEY));
+ getLogger().debug("Set variable " +
EXCEPTION_ORIGINATING_PROCESS_NAME_KEY + " for process instance with value :" +
executionContext.getVariable(EXCEPTION_ORIGINATING_PROCESS_NAME_KEY));
+ getLogger().debug("Set variable " +
EXCEPTION_ORIGINATING_PROCESS_ID_KEY + " for process instance with value :" +
executionContext.getVariable(EXCEPTION_ORIGINATING_PROCESS_ID_KEY));
+ getLogger().debug("Set variable " +
EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY + " for process instance with value
:" + executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY));
+ }
+
+
+ processInstance.signal();
+ } catch (Exception ex) {
+ if (getLogger().isInfoEnabled()) {
+ getLogger().info(("Exception caught during
StartExceptionFrameworkHandler."), ex);
+ }
+ }
+
+ getLogger().info("Ended StartExceptionFrameworkHandler.");
+ }
+
+ protected String getCurrentAction() {
+ return "starting exception framework process";
+ }
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/handler/TriggerOriginatingProcessHandler.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/handler/TriggerOriginatingProcessHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/handler/TriggerOriginatingProcessHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,92 @@
+package org.jboss.handler;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+
+public class TriggerOriginatingProcessHandler implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Context variable keys for storing exception information. */
+ public static final String EXCEPTION_ORIGINATING_PROCESS_ID_KEY =
"EXCEPTION_ORIGINATING_PROCESS_ID";
+ public static final String EXCEPTION_ORIGINATING_NODE_LEAVE_TRANSITION_KEY =
"EXCEPTION_ORIGINATING_NODE_LEAVE_TRANSITION";
+
+ private String transitionName;
+
+ private ProcessInstance originatorProcInst;
+
+ /** Logging facility. */
+ private static final Logger LOGGER =
Logger.getLogger(TriggerOriginatingProcessHandler.class);
+
+ public final void execute(ExecutionContext executionContext) throws Exception {
+ getLogger().info("Start TriggerOriginatingProcessHandler.");
+
+ try {
+ JbpmConfiguration jbpmConf = JbpmConfiguration.getInstance();
+ JbpmContext jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ // Get our process instance back.
+ originatorProcInst = jbpmCtx.getProcessInstance((Long)
executionContext.getVariable(EXCEPTION_ORIGINATING_PROCESS_ID_KEY));
+
+ if (getLogger().isDebugEnabled()) {
+ if (originatorProcInst == null) {
+ getLogger().debug("Process instance of exception framework was not
created.");
+ }
+ }
+
+ // Determine from the context variable (see ContextConstants) which transition to
take
+ // when we go back to the originating node. It should always be set to
something, but we
+ // will take the default if it is null and log it as an error.
+ transitionName = (String)
executionContext.getVariable(EXCEPTION_ORIGINATING_NODE_LEAVE_TRANSITION_KEY);
+
+ if (StringUtils.isBlank(transitionName)) {
+ // Leave the node through the default transition, nothing to do just log this as
an error as
+ // should never have to happen.
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Leaving transition not set in the context,
leaving over the default transition.");
+ }
+ } else {
+ // Leave the node through the given transition we need to get out of the context
variable if it exists,
+ // so checking it.
+ if
(originatorProcInst.getRootToken().getNode().hasLeavingTransition(transitionName)) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Leaving node over the given transition
" + transitionName);
+ }
+ } else {
+ // given non-existing transition, take default and log error.
+ getLogger().error("Leaving transition not set in the context, leaving over
the default transition.");
+ transitionName = null;
+ }
+ }
+
+ if (StringUtils.isBlank(transitionName)) {
+ originatorProcInst.getRootToken().signal();
+ } else {
+ originatorProcInst.getRootToken().signal(transitionName);
+ }
+ executionContext.leaveNode();
+ } finally {
+ jbpmCtx.close();
+ }
+ } catch (Exception ex) {
+ if (getLogger().isInfoEnabled()) {
+ getLogger().info(("Exception caught during
TriggerOriginatingProcessHandler."), ex);
+ }
+ }
+ getLogger().info("Ended TriggerOriginatingProcessHandler.");
+ }
+
+
+ protected String getCurrentAction() {
+ return "signaling originating process";
+ }
+
+ protected Logger getLogger() {
+ return LOGGER;
+ }
+}
Added:
projects/exception_framework/trunk/src/main/java/org/jboss/util/ThreadPoolSingleton.java
===================================================================
---
projects/exception_framework/trunk/src/main/java/org/jboss/util/ThreadPoolSingleton.java
(rev 0)
+++
projects/exception_framework/trunk/src/main/java/org/jboss/util/ThreadPoolSingleton.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,78 @@
+package org.jboss.util;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.concurrent.Executor;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Ensures this is a singleton implementation of the ThreadPool for service calls.
+ */
+public enum ThreadPoolSingleton {
+ /** The Threadpool singleton instance. */
+ INSTANCE;
+
+ private static final Logger LOGGER = Logger.getLogger(ThreadPoolSingleton.class);
+
+ private final Integer numberThreads = 10;
+ private Executor exec = new HandleableThreadPoolExecutor();
+
+ private UncaughtExceptionHandler handler;
+
+ /**
+ * This is what we do!
+ *
+ * @param command
+ * The runnable command.
+ */
+ public void executeServiceCall(Runnable command) {
+ exec.execute(command);
+ }
+
+ /**
+ * @param ueh
+ * A handler that is going to catch the uncaught exceptions instead of the
default handler (e.g. for testing
+ * purposes).
+ */
+ public void setUncaughtExceptionHandler(UncaughtExceptionHandler ueh) {
+ handler = ueh;
+ }
+
+ /**
+ * ThreadPoolExecutor that allows for setting an
<code>UncaughtExceptionHandler</code> to each thread that is used to execute
a
+ * given <code>Runnable</code>.
+ */
+ private class HandleableThreadPoolExecutor extends ThreadPoolExecutor {
+ /** Default constructor that creates a 'fixed thread pool'. */
+ HandleableThreadPoolExecutor() {
+ super(numberThreads, numberThreads, 0L, TimeUnit.MILLISECONDS, new
LinkedBlockingQueue<Runnable>());
+ setRejectedExecutionHandler(new DefaultRejectedExecutionHandler());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void beforeExecute(Thread t, Runnable r) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Starting task " + r + " in thread " +
t);
+ }
+ if (handler != null) {
+ t.setUncaughtExceptionHandler(handler);
+ }
+ }
+ }
+
+ /**
+ * Default implementation for the <code>RejectedExecutionHandler</code>.
+ */
+ private static class DefaultRejectedExecutionHandler implements
RejectedExecutionHandler {
+ public void rejectedExecution(Runnable r, ThreadPoolExecutor tpe) {
+ LOGGER.error(tpe + " unable to handle task " + r);
+ throw new RejectedExecutionException();
+ }
+ }
+}
Added: projects/exception_framework/trunk/src/main/jpdl/process/gpd.xml
===================================================================
--- projects/exception_framework/trunk/src/main/jpdl/process/gpd.xml
(rev 0)
+++ projects/exception_framework/trunk/src/main/jpdl/process/gpd.xml 2010-04-20 18:27:47
UTC (rev 6264)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="Exception Framework" width="1315"
height="512">
+ <node name="start" x="188" y="18"
width="140" height="40">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="Determine Exception Handling" x="150"
y="107" width="225" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="Human Task" x="55" y="186"
width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="Retry" x="336" y="190"
width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="Trigger Originating Process" x="142"
y="279" width="247" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="end" x="181" y="364" width="140"
height="40"/>
+ <deployment serverName="" serverPort=""
serverDeployer="/gpd-deployer/upload">
+ <classesAndResources/>
+ <filesAndFolders>
+ <element
value="/exception_framework/src/main/jpdl/process/gpd.xml"/>
+ <element
value="/exception_framework/src/main/jpdl/process/processdefinition.xml"/>
+ <element
value="/exception_framework/src/main/jpdl/process/processimage.jpg"/>
+ </filesAndFolders>
+ </deployment>
+</root-container>
Added: projects/exception_framework/trunk/src/main/jpdl/process/processdefinition.xml
===================================================================
--- projects/exception_framework/trunk/src/main/jpdl/process/processdefinition.xml
(rev 0)
+++
projects/exception_framework/trunk/src/main/jpdl/process/processdefinition.xml 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Exception
Framework">
+
+ <start-state name="start">
+ <transition to="Determine Exception Handling" />
+ </start-state>
+
+ <decision name="Determine Exception Handling">
+ <handler class="org.jboss.handler.DetermineExceptionHandlingHandler"
/>
+ <transition to="Human Task" name="No" />
+ <transition to="Retry" name="Yes" />
+ </decision>
+
+ <task-node name="Human Task">
+ <task name="Technical dropout">
+ <assignment actor-id="EXPERT" />
+ </task>
+ <event type="node-enter">
+ <action class="org.jboss.handler.HumanTaskHandler"></action>
+ </event>
+ <event type="node-leave">
+ <action class="org.jboss.handler.HumanTaskHandler" />
+ </event>
+ <transition to="Trigger Originating Process"></transition>
+ </task-node>
+
+ <state name="Retry">
+ <event type="node-enter">
+ <action class="org.jboss.handler.RetryHandler" />
+ </event>
+ <transition to="Trigger Originating Process" />
+ </state>
+
+ <node name="Trigger Originating Process">
+ <action class="org.jboss.handler.TriggerOriginatingProcessHandler"
/>
+ <transition to="end" />
+ </node>
+
+ <end-state name="end" />
+
+</process-definition>
\ No newline at end of file
Added: projects/exception_framework/trunk/src/main/jpdl/process/processimage.jpg
===================================================================
(Binary files differ)
Property changes on:
projects/exception_framework/trunk/src/main/jpdl/process/processimage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
projects/exception_framework/trunk/src/test/java/org/jboss/handler/ExceptionThrowingHandler.java
===================================================================
---
projects/exception_framework/trunk/src/test/java/org/jboss/handler/ExceptionThrowingHandler.java
(rev 0)
+++
projects/exception_framework/trunk/src/test/java/org/jboss/handler/ExceptionThrowingHandler.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,200 @@
+package org.jboss.handler;
+
+import java.util.Date;
+import java.util.Iterator;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jbpm.graph.def.Action;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.instantiation.Delegation;
+import org.jbpm.job.ExecuteActionJob;
+import org.jbpm.msg.MessageService;
+import org.jbpm.svc.ServiceFactory;
+import org.jbpm.svc.Services;
+
+public class ExceptionThrowingHandler implements ActionHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Context variable keys for storing exception information. */
+ public static final String EXCEPTION_ORIGINATING_NODE_NAME_KEY =
"EXCEPTION_ORIGINATING_NODE_NAME";
+ public static final String EXCEPTION_ORIGINATING_PROCESS_NAME_KEY =
"EXCEPTION_ORIGINATING_PROCESS_NAME";
+ public static final String EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY =
"EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST";
+ public static final String EXCEPTION_ORIGINATING_PROCESS_ID_KEY =
"EXCEPTION_ORIGINATING_PROCESS_ID";
+
+ private boolean leaveNode = true;
+
+ private String transitionName;
+
+ private static String retryTransitionName = "Retry";
+
+ /** Set to false to use custom exception framework. */
+ private boolean useJbpmExceptionHandler = false;
+
+ /** Conditional error throwing variable. **/
+ private static final String EXCEPTION_THROWN = "EXCEPTION_THROWN";
+
+ /** Logging facility. */
+ private static final Logger LOGGER = Logger.getLogger(ExceptionThrowingHandler.class);
+
+
+ /**
+ * Our execution method where the work is done!
+ *
+ * @param executionContext Current execution context.
+ */
+ public void execute(ExecutionContext executionContext) throws Exception {
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Starting jBPM custom exception framework.");
+ }
+
+ ExecutionContext.pushCurrentContext(executionContext);
+
+ try {
+ try {
+ // Perform the action.
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Performing action for process instance with
id: " + executionContext.getProcessInstance().getId());
+ }
+ doPerformAction(executionContext);
+
+ if (leaveNode) {
+ // Leave the node through the given transition.
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Leaving node over "
+ + (StringUtils.isBlank(transitionName) ? "default
transition." : "transition: "
+ + transitionName));
+ }
+
+ // When leaving the node we can either have set a transition to take
while in the doPerformAction via the
+ // setTransition method or leave it to the default transition, here
we decide what has happened.
+ if (StringUtils.isBlank(transitionName)) {
+ executionContext.getNode().leave(executionContext);
+ } else {
+ executionContext.getNode().leave(executionContext,
transitionName);
+ }
+ }
+ } catch (Exception ex) {
+ if (useJbpmExceptionHandler) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug(
+ "Using jBPMExceptionHandler for exception caught in
process instance with id: "
+ +
executionContext.getProcessInstance().getId());
+ }
+ executionContext.getNode().raiseException(ex, executionContext);
+ } else {
+ if (getLogger().isDebugEnabled()) {
+ getLogger()
+ .debug(
+ "Using handleException (custom) for
exception caught in process instance with id: "
+ +
executionContext.getProcessInstance().getId()
+ + " and pushing exception to context
with setException.");
+ }
+ executionContext.setException(ex);
+
+ handleException(executionContext);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Exception passed to framework, now we
wait.");
+ }
+ }
+ }
+ } catch (Exception ex) {
+ if (getLogger().isInfoEnabled()) {
+ getLogger().info(("Exception caught during jBPM custom framework
execution"), ex);
+ }
+ } finally {
+ ExecutionContext.popCurrentContext(executionContext);
+ }
+ }
+
+
+ /**
+ * This method is used to handle exceptions.
+ *
+ * @param executionContext Current execution context.
+ */
+ private void handleException(ExecutionContext executionContext) {
+ getLogger().info("Start exception handling for custom jBPM exception
framework.");
+
+ // Save the current node in the context to make a retry possible.
+ executionContext.setVariable(EXCEPTION_ORIGINATING_NODE_NAME_KEY,
executionContext.getNode().getName());
+ executionContext.setVariable(EXCEPTION_ORIGINATING_PROCESS_NAME_KEY,
executionContext.getProcessDefinition().getName());
+ executionContext.setVariable(EXCEPTION_ORIGINATING_PROCESS_ID_KEY,
executionContext.getProcessInstance().getId());
+
+ // Also save the transitions that we will want to provide a choice of (all
outgoing transitions
+ // plus a retry transition that loops back to the same node. First we add the
loopback transition
+ // to the existing list (note, adding to back of list, do not want it to become
the default!).
+ Transition retryTransition = new Transition();
+ retryTransition.setName(retryTransitionName);
+ retryTransition.setTo(executionContext.getNode());
+ executionContext.getNode().addLeavingTransition(retryTransition);
+ executionContext.setVariable(EXCEPTION_ORIGINATING_NODE_TRANSITION_LIST_KEY,
executionContext.getNode().getLeavingTransitions());
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("The EXCEPTION_ORIGINATING_NODE_NAME_KEY is set to:
" + executionContext.getNode().getName());
+ getLogger().debug("The EXCEPTION_ORIGINATING_PROCESS_NAME_KEY is set to:
" + executionContext.getProcessDefinition().getName());
+ getLogger().debug("The EXCEPTION_ORIGINATING_PROCESS_ID_KEY is set to:
" + executionContext.getProcessInstance().getId());
+ getLogger().debug("The following transitions have been pushed into the
context: ");
+ int i = 0;
+ for (Iterator iterator =
executionContext.getNode().getLeavingTransitions().iterator(); iterator.hasNext();) {
+ Transition transition = (Transition) iterator.next();
+ getLogger().debug("Transition " + i + " called " +
transition.getName());
+ i++;
+ }
+ }
+
+ // Pass the context off to the exception framework process.
+ ServiceFactory serviceFactory =
executionContext.getJbpmContext().getServiceFactory(Services.SERVICENAME_MESSAGE);
+ if (serviceFactory != null) {
+ MessageService messageService = (MessageService)
serviceFactory.openService();
+ Action action = new Action(new
Delegation(StartExceptionFrameworkHandler.class.getName()));
+ ExecuteActionJob job = new ExecuteActionJob(executionContext.getToken());
+ job.setAction(action);
+ job.setDueDate(new Date());
+
+ // have to explicitly save the action context.
+ executionContext.getJbpmContext().getSession().saveOrUpdate(action);
+ messageService.send(job);
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Scheduled job with jobExecuter and waiting for it to
run...");
+ }
+ }
+
+ getLogger().info("Ended exception handling for jBPM custom exception
framework.");
+ }
+
+ /**
+ * The action for this handler with the sole purpose of throwing an exception.
+ *
+ * @param executionContext Current execution context.
+ * @throws Exception
+ */
+ public void doPerformAction(ExecutionContext executionContext) throws Exception {
+
+ // ensuring that the exception is thrown only once.
+ if (StringUtils.isEmpty((String) executionContext.getVariable(EXCEPTION_THROWN))) {
+ // mark the exception as being thrown once and only once!
+ if (getLogger().isDebugEnabled()) {
+ LOGGER.debug("ExceptionThrowningHandler ==> throwing in the kitchen sink
now...");
+ }
+
+ executionContext.setVariable(EXCEPTION_THROWN, "kitchen_sink");
+ throw new IllegalStateException("Creating a problem.");
+ }
+
+ // reset the error variable.
+ executionContext.setVariable(EXCEPTION_THROWN, null);
+ }
+
+ /** The logger. */
+ protected Logger getLogger() {
+ return LOGGER;
+
+ }
+
+}
Added:
projects/exception_framework/trunk/src/test/java/org/jboss/test/TestForNodeExceptionHandling.java
===================================================================
---
projects/exception_framework/trunk/src/test/java/org/jboss/test/TestForNodeExceptionHandling.java
(rev 0)
+++
projects/exception_framework/trunk/src/test/java/org/jboss/test/TestForNodeExceptionHandling.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,239 @@
+package org.jboss.test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.log4j.Appender;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jboss.util.ProcessDefinitionReference;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.db.GraphSession;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for the Abstract Action Handler.
+ */
+public class TestForNodeExceptionHandling {
+
+ /** The global jBPM configuration. */
+ private static JbpmConfiguration jbpmConf = JbpmConfiguration.getInstance();
+
+ /** Variables for Tasks. */
+ private static final String ACTOR_ID = "EXPERT";
+ private static final String TASK_NAME = "Technical dropout";
+ private static final Set<String> POOLED_ACTORS = null;
+ private static final String SWIMLANE = null;
+
+ public static final String ORIGINATING_PROCESS_NAME = "Originator Process";
+ public static final String EXCEPTION_FRAMEWORK_PROCESS_NAME = "Exception
Framework";
+
+ /**
+ * Fix the standard logging setup to work better within the IDE console,
+ * just comment out to use and COMMENT OUT BEFORE CHECKIN.
+ */
+ @BeforeClass
+ public static final void oneTimeSetupExceptionFrameworkTesting() {
+ // Turn on for logging in console to be within my IDE window size.
+ //((PatternLayout) ((Appender)
Logger.getRootLogger().getAllAppenders().nextElement()).getLayout()).setConversionPattern("%r
[%t] %p %c %x -%n%n %m%n%n");
+
+
+ // Start the JobExecutor for async continuations within the test environment.
+ jbpmConf.startJobExecutor();
+
+ // Initialize logging.
+ BasicConfigurator.configure();
+ // - Remove the superfluous appender.
+ Logger.getRootLogger().removeAppender((Appender)
Logger.getRootLogger().getAllAppenders().nextElement());
+ // Adjust levels:
+ Logger.getRootLogger().setLevel(Level.ERROR);
+ Logger.getLogger("org.jboss").setLevel(Level.DEBUG);
+ Logger.getLogger("org.jbpm.graph").setLevel(Level.DEBUG);
+
+ // Deploy my exception framework too.
+ try {
+ deployExceptionFramework();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Called once after all test runs, stops the JobExecutor.
+ *
+ * @throws Exception When something unexpected goes wrong.
+ */
+ @AfterClass
+ public static final void oneTimeTearDown() throws Exception {
+ // End the JobExecutor thread.
+ jbpmConf.getJobExecutor().stop();
+ }
+
+ /**
+ * The main test we want to run here to throw an exception in the Node of our
+ * test process and handle it through our Exception Framework.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testRun() throws Exception {
+ // deploy process first.
+ JbpmContext jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ // Create an instance of the jBPM process.
+ ProcessDefinition procDef = getTestProcess().parseAndDeployProcess();
+ ProcessInstance procInst = new ProcessInstance(procDef);
+ jbpmCtx.save(procInst);
+ } finally {
+ // Close the transaction.
+ jbpmCtx.close();
+ }
+
+ // signal process to start.
+ jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ long processInstanceId = getProcessId(ORIGINATING_PROCESS_NAME);
+ ProcessInstance procInst = jbpmCtx.getProcessInstance(processInstanceId);
+ assertThat("No exception process instance returned.", procInst,
is(not(nullValue())));
+ procInst.signal();
+ } finally {
+ jbpmCtx.close();
+ }
+
+ Thread.sleep(5000);
+
+ // In Human Task and need to end which will cause the flow to signal back
+ // to the originating process.
+ endTask();
+
+ // Test that originating process is in end state.
+ jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ long processInstanceId = getProcessId(ORIGINATING_PROCESS_NAME);
+ ProcessInstance procInst = jbpmCtx.getProcessInstance(processInstanceId);
+ assertThat("No exception process instance returned.", procInst,
is(not(nullValue())));
+ assertThat("Exception process not ended.", procInst.hasEnded(), is(true));
+ } finally {
+ jbpmCtx.close();
+ }
+
+ // Test that it is in end state now for exception framework.
+ jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ long processInstanceId = getProcessId(EXCEPTION_FRAMEWORK_PROCESS_NAME);
+ ProcessInstance procInst = jbpmCtx.getProcessInstance(processInstanceId);
+ assertThat("No exception process instance returned.", procInst,
is(not(nullValue())));
+ assertThat("Exception process in unexpected state.", procInst.hasEnded(),
is(true));
+ } finally {
+ jbpmCtx.close();
+ }
+ }
+
+ /**
+ * Gives you the test process definition.
+ */
+ protected ProcessDefinitionReference getTestProcess() throws Exception {
+ String testProcDef = "<process-definition
xmlns=\"urn:jbpm.org:jpdl-3.1\" name=\"" + ORIGINATING_PROCESS_NAME +
"\">"
+ + "<start-state name=\"start\">"
+ + "<transition to=\"node1\" />"
+ + "</start-state>"
+ + "<node name=\"node1\" async=\"true\">"
+ + "<action
class=\"org.jboss.handler.ExceptionThrowingHandler\" />"
+ + "<transition to=\"end\" name=\"node_to_end\"
/>"
+ + "</node>"
+ + "<end-state name=\"end\" />"
+ + "</process-definition>";
+ return new ProcessDefinitionReference(testProcDef);
+ }
+
+ private static void deployExceptionFramework() throws Exception {
+ // Open the transaction.
+ JbpmContext jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ // Create an instance of the jBPM exception framework process.
+ String frameworkXml = "process/processdefinition.xml";
+ ProcessDefinition procDef = ProcessDefinition.parseXmlResource(frameworkXml);
+ jbpmCtx.deployProcessDefinition(procDef);
+ } finally {
+ // Close the transaction.
+ jbpmCtx.close();
+ }
+ }
+
+ private void endTask() {
+ // Open the transaction.
+ JbpmContext jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ long processInstanceId = getProcessId(EXCEPTION_FRAMEWORK_PROCESS_NAME);
+ ProcessInstance procInst = jbpmCtx.getProcessInstance(processInstanceId);
+ assertThat("No exception process instance returned.", procInst,
is(not(nullValue())));
+
+ Collection<TaskInstance> taskInsts =
procInst.getTaskMgmtInstance().getUnfinishedTasks(procInst.getRootToken());
+ assertThat("No task instances found.", taskInsts, is(not(nullValue())));
+
+ TaskInstance taskInst = getIndicatedTaskInstance(taskInsts, ACTOR_ID, TASK_NAME,
POOLED_ACTORS, SWIMLANE);
+ if (taskInst != null) {
+ // End the task instance.
+ taskInst.end();
+ }
+ } finally {
+ // Tear down the pojo persistence context.
+ jbpmCtx.close();
+ }
+ }
+
+
+ private long getProcessId (String processName) {
+ long procId;
+
+ // Open the transaction.
+ JbpmContext jbpmCtx = jbpmConf.createJbpmContext();
+ try {
+ // Get our process instance back.
+ GraphSession graphSession = jbpmCtx.getGraphSession();
+ ProcessDefinition processDefinition =
graphSession.findLatestProcessDefinition(processName);
+ assertThat("No process definition found.", processDefinition,
is(not(nullValue())));
+
+ // Now, we search for all process instances of this process definition.
+ List processInstances =
graphSession.findProcessInstances(processDefinition.getId());
+ ProcessInstance procInst = (ProcessInstance) processInstances.get(0);
+ procId = procInst.getId();
+ } finally {
+ // Tear down the pojo persistence context.
+ jbpmCtx.close();
+ }
+
+ return procId;
+ }
+
+ private TaskInstance getIndicatedTaskInstance(Collection<TaskInstance>
taskInsts, final String actorId, final String taskName,
+ final Set<String> pooledActors, final String swimlane) {
+ TaskInstance indicated = null;
+ for (TaskInstance taskInst : taskInsts) {
+ if ((actorId == null || actorId.equals(taskInst.getActorId()))
+ && (taskName == null ||
taskName.equals(taskInst.getTask().getName()))
+ && (pooledActors == null ||
CollectionUtils.isSubCollection(pooledActors, taskInst.getPooledActors()))
+ && (swimlane == null ||
swimlane.equals(taskInst.getSwimlaneInstance().getName()))) {
+ indicated = taskInst;
+ break;
+ }
+ }
+ return indicated;
+ }
+
+}
Added:
projects/exception_framework/trunk/src/test/java/org/jboss/util/ProcessDefinitionReference.java
===================================================================
---
projects/exception_framework/trunk/src/test/java/org/jboss/util/ProcessDefinitionReference.java
(rev 0)
+++
projects/exception_framework/trunk/src/test/java/org/jboss/util/ProcessDefinitionReference.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,88 @@
+package org.jboss.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * Container for a process definition reference, with the possibility to include
+ * a list of these containers for the subprocesses.
+ */
+public class ProcessDefinitionReference {
+ private static final Logger LOGGER =
Logger.getLogger(ProcessDefinitionReference.class);
+
+ private static final JbpmConfiguration JBPM_CONF = JbpmConfiguration.getInstance();
+
+ /** The String containing an XML process definition or the name of a parsable resource.
*/
+ private String procDefString;
+
+ /** The list of subprocesses. */
+ private List<ProcessDefinitionReference> subprocs = new
ArrayList<ProcessDefinitionReference>();
+
+ /**
+ * Constructor for process definition <code>String</code>s.
+ *
+ * @param procDefString
+ * The process definition, in one of the following formats:
+ * <ul>
+ * <li>An XML format string containing the definition.
+ * <li>The file pathname for the process archive resource (ending
+ * in '.par') containing the definition.
+ * <li>The file pathname for the resource containing the
+ * definition.
+ * </ul>
+ */
+ public ProcessDefinitionReference(final String procDefString) {
+ this.procDefString = procDefString;
+ }
+
+ /**
+ * Chainable convenience method for adding subprocesses.
+ *
+ * @param ref The reference object for the subprocess definition to be added.
+ * @return A reference to the process to which the subprocess was just added.
+ */
+ public ProcessDefinitionReference addSubproc(ProcessDefinitionReference ref) {
+ subprocs.add(ref);
+ return this;
+ }
+
+ /**
+ * @return The reference to the top-level process definition, which is
+ * deployed along with all of its nested subprocesses.
+ */
+ public ProcessDefinition parseAndDeployProcess() {
+ // First do the subprocesses (recursively).
+ for (ProcessDefinitionReference subProcRef : subprocs) {
+ subProcRef.parseAndDeployProcess();
+ }
+
+ // Then do this process itself.
+ // - Parse.
+ ProcessDefinition procDef = null;
+ if (procDefString.endsWith("</process-definition>")) {
+ // It's a process definition XML String.
+ procDef = ProcessDefinition.parseXmlString(procDefString);
+ } else if (procDefString.endsWith(".par")) {
+ // It's a process archive.
+ try {
+ procDef = ProcessDefinition.parseParResource(procDefString);
+ } catch (IOException ioEx) {
+ LOGGER.error("Cannot parse .par file as a resource.", ioEx);
+ }
+ } else {
+ // Assume it's a definition in a resource on the classpath.
+ procDef = ProcessDefinition.parseXmlResource(procDefString);
+ }
+ // - Deploy.
+ if (procDef != null) {
+ JBPM_CONF.getCurrentJbpmContext().deployProcessDefinition(procDef);
+ }
+
+ return procDef;
+ }
+}
Added: projects/exception_framework/trunk/src/test/java/org/jboss/util/TaskCallback.java
===================================================================
--- projects/exception_framework/trunk/src/test/java/org/jboss/util/TaskCallback.java
(rev 0)
+++
projects/exception_framework/trunk/src/test/java/org/jboss/util/TaskCallback.java 2010-04-20
18:27:47 UTC (rev 6264)
@@ -0,0 +1,15 @@
+package org.jboss.util;
+
+import org.jbpm.graph.exe.ExecutionContext;
+
+/** Interface for implementation of Task performing during tests. */
+public interface TaskCallback {
+ /**
+ * Called to allow for performing work to mimic a manual task.
+ *
+ * @param executionContext
+ * The jBPM execution context for the transaction in which the
+ * work can be done.
+ */
+ void performTask(ExecutionContext executionContext);
+}