[jbpm-commits] JBoss JBPM SVN: r4133 - in jbpm4/branches: tbaeyens and 376 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 4 05:30:10 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-03-04 05:30:07 -0500 (Wed, 04 Mar 2009)
New Revision: 4133

Added:
   jbpm4/branches/tbaeyens/
   jbpm4/branches/tbaeyens/.project
   jbpm4/branches/tbaeyens/build.xml
   jbpm4/branches/tbaeyens/eclipse/
   jbpm4/branches/tbaeyens/eclipse/jbpm.code.templates.xml
   jbpm4/branches/tbaeyens/eclipse/jbpm.profile.xml
   jbpm4/branches/tbaeyens/eclipse/readme.txt
   jbpm4/branches/tbaeyens/hudson/
   jbpm4/branches/tbaeyens/hudson/ant.properties.example
   jbpm4/branches/tbaeyens/hudson/apache-tomcat/
   jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/
   jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/server.xml
   jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/tomcat-users.xml
   jbpm4/branches/tbaeyens/hudson/build.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/
   jbpm4/branches/tbaeyens/hudson/hudson-home/command.sh
   jbpm4/branches/tbaeyens/hudson/hudson-home/config.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Mailer.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Maven.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Container-Matrix/
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Database-Matrix/
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Database-Matrix/config.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.5/
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.5/config.xml
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.6/
   jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.6/config.xml
   jbpm4/branches/tbaeyens/hudson/jboss/
   jbpm4/branches/tbaeyens/hudson/jboss/bin/
   jbpm4/branches/tbaeyens/hudson/jboss/bin/http-spider.sh
   jbpm4/branches/tbaeyens/hudson/jboss/bin/jboss.sh
   jbpm4/branches/tbaeyens/hudson/jboss/bin/runjboss.sh
   jbpm4/branches/tbaeyens/hudson/jbpm4-base.sh
   jbpm4/branches/tbaeyens/hudson/jbpm4-db.sh
   jbpm4/branches/tbaeyens/hudson/jbpm4-load.sh
   jbpm4/branches/tbaeyens/hudson/profiles.xml.local.qa
   jbpm4/branches/tbaeyens/modules/
   jbpm4/branches/tbaeyens/modules/api/
   jbpm4/branches/tbaeyens/modules/api/.classpath
   jbpm4/branches/tbaeyens/modules/api/.project
   jbpm4/branches/tbaeyens/modules/api/pom.xml
   jbpm4/branches/tbaeyens/modules/api/src/
   jbpm4/branches/tbaeyens/modules/api/src/main/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Configuration.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Deployment.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Execution.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/HistoryService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/IdentityService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JbpmException.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JobQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ManagementService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Problem.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessEngine.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityBehaviour.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ExternalActivityBehaviour.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientExecution.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessDefinition.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessInstance.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/Command.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/CommandService.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Context.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Environment.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/EnvironmentFactory.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Transaction.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/environment.gif
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstance.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstanceQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstanceQuery.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/Group.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/User.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Job.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Message.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Timer.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/jpdl/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListener.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Activity.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Comment.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/CompositeElement.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Condition.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Discussable.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Event.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ExecutionKeyGenerator.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/IdGenerator.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ObservableElement.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenExecution.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenProcessDefinition.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Transition.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/DbSession.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/MessageSession.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TimerSession.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/package.html
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Assigner.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/GroupRef.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Participant.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Swimlane.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Task.java
   jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/UserRef.java
   jbpm4/branches/tbaeyens/modules/api/src/main/resources/
   jbpm4/branches/tbaeyens/modules/api/src/main/resources/cfg.xsd
   jbpm4/branches/tbaeyens/modules/api/src/main/resources/jpdl.xsd
   jbpm4/branches/tbaeyens/modules/config/
   jbpm4/branches/tbaeyens/modules/config/pom.xml
   jbpm4/branches/tbaeyens/modules/config/scripts/
   jbpm4/branches/tbaeyens/modules/config/scripts/antrun-package-config.xml
   jbpm4/branches/tbaeyens/modules/config/src/
   jbpm4/branches/tbaeyens/modules/config/src/main/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/build.properties
   jbpm4/branches/tbaeyens/modules/config/src/main/files/build.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/filter.properties
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cache/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cache/hashtable.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part1.jbpm.hibernate.cfg.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part2.jbpm.hibernate.cfg.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/db2.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/mysql.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/oracle.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/postgresql.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/sybase.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/db2.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/hsqldb.inmemory.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/mysql.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/oracle.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/postgresql.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/sybase.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.definition.hbm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.execution.hbm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.history.hbm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.jpdl.hbm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.task.hbm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.exclude.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.include.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/pvm.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.exclude.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.include.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part1.persistence.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part2.persistence.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/jbpm.identity.cfg.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-hsqldb-ds.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-mysql-ds.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-oracle-ds.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-postgresql-ds.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-sybase-ds.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/cfg/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cache.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.task.lifecycle.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.variable.types.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.exclude.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.include.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml
   jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part2.jbpm.wire.bindings.xml
   jbpm4/branches/tbaeyens/modules/db/
   jbpm4/branches/tbaeyens/modules/db/.classpath
   jbpm4/branches/tbaeyens/modules/db/.project
   jbpm4/branches/tbaeyens/modules/db/README.txt
   jbpm4/branches/tbaeyens/modules/db/jbpm4-db.iml
   jbpm4/branches/tbaeyens/modules/db/pom.xml
   jbpm4/branches/tbaeyens/modules/db/src/
   jbpm4/branches/tbaeyens/modules/db/src/main/
   jbpm4/branches/tbaeyens/modules/db/src/main/ant/
   jbpm4/branches/tbaeyens/modules/db/src/main/ant/build.schema.xml
   jbpm4/branches/tbaeyens/modules/db/src/main/resources/
   jbpm4/branches/tbaeyens/modules/db/src/test/
   jbpm4/branches/tbaeyens/modules/db/src/test/resources/
   jbpm4/branches/tbaeyens/modules/db/src/test/resources/antrun-create_drop.xml
   jbpm4/branches/tbaeyens/modules/devguide/
   jbpm4/branches/tbaeyens/modules/devguide/.project
   jbpm4/branches/tbaeyens/modules/devguide/pom.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/diagrams.mdzip
   jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/images.ppt
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/apis.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch04.execution.states.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch09.persistent.process.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.definition.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.execution.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/composite.node.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait1.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait2.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait3.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.concurrency.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.archive.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.end.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.evaluate.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/initial.in.composite.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/interceptors.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.db.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.execution.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.ab.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.anatomy.classes.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.automatic.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.loan.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.propagate.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.structure.classes.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/self.transition.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transactions.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.inheritence.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.into.composite.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.out.of.composite.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.inner.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.outer.png
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/master.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch01-Introduction.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-Environments.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch03-Architecture.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch05-ProcessAnatomy.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch06-ImplementingAdvancedActivities.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch07-Variables.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch08-Timers.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch09-AsynchronousContinuations.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch10-SoftwareLogging.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch11-History.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-DelegationClasses.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Environment.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Persistence.xml
   jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-ProcessLanguages.xml
   jbpm4/branches/tbaeyens/modules/distro/
   jbpm4/branches/tbaeyens/modules/distro/.project
   jbpm4/branches/tbaeyens/modules/distro/.settings/
   jbpm4/branches/tbaeyens/modules/distro/.settings/attachedFile.properties
   jbpm4/branches/tbaeyens/modules/distro/pom.xml
   jbpm4/branches/tbaeyens/modules/distro/scripts/
   jbpm4/branches/tbaeyens/modules/distro/scripts/antrun-installer.xml
   jbpm4/branches/tbaeyens/modules/distro/scripts/assembly-deploy-artifacts.xml
   jbpm4/branches/tbaeyens/modules/distro/src/
   jbpm4/branches/tbaeyens/modules/distro/src/main/
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/examples-hibernate.cfg.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/ant-actions-spec.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/auto-install-template.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/download-helper.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/install-definition.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/target-panel-dir.txt
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/user-input-spec.xml
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/jboss.eula.txt
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/license.txt
   jbpm4/branches/tbaeyens/modules/distro/src/main/resources/readme.html
   jbpm4/branches/tbaeyens/modules/enterprise/
   jbpm4/branches/tbaeyens/modules/enterprise/.classpath
   jbpm4/branches/tbaeyens/modules/enterprise/.project
   jbpm4/branches/tbaeyens/modules/enterprise/README.txt
   jbpm4/branches/tbaeyens/modules/enterprise/jbpm4-enterprise.iml
   jbpm4/branches/tbaeyens/modules/enterprise/pom.xml
   jbpm4/branches/tbaeyens/modules/enterprise/scripts/
   jbpm4/branches/tbaeyens/modules/enterprise/scripts/antrun-test-jars.xml
   jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-config.xml
   jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-test-dependencies.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandReceiverMDB.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbLocalCommandService.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/ExecuteTimerCmd.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutor.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutorHome.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimer.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimerHome.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutor.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutorHome.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/TimerEB.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbLocalCommandServiceBinding.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbTimerSessionBinding.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/CommandDelegate.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ManagementFactoryImpl.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ServiceLocator.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/ejb-jar.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jboss.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jbosscmp-jdbc.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/services/
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/services/org.jboss.bpm.console.server.integration.ManagementFactory
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jboss-service.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-destinations-service.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-roles.properties
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-users.properties
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.enterprise.wire.bindings.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/HappyListener.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/NoisyListener.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ArchiveDeployer.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/EnvironmentServletTestCase.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestHelper.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestSetup.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/JBossArchiveDeployer.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ObjectNameFactory.java
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/META-INF/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/META-INF/application.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/jboss-web.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/web.xml
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/cactus.properties
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/jndi.properties
   jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/log4j.xml
   jbpm4/branches/tbaeyens/modules/examples/
   jbpm4/branches/tbaeyens/modules/examples/.classpath
   jbpm4/branches/tbaeyens/modules/examples/.project
   jbpm4/branches/tbaeyens/modules/examples/jbpm4-examples.iml
   jbpm4/branches/tbaeyens/modules/examples/pom.xml
   jbpm4/branches/tbaeyens/modules/examples/src/
   jbpm4/branches/tbaeyens/modules/examples/src/eclipse/
   jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.classpath
   jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.project
   jbpm4/branches/tbaeyens/modules/examples/src/test/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/graphbased/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/graphbased/ConcurrencyGraphBasedTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/multiple/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/state/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/JbpmMockCourier.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/hql/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JavaInstantiateTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JohnDoe.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/expression/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/expression/ScriptExpressionTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/Person.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/ScriptTextTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/sql/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/choice/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/sequence/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/sequence/StateSequenceTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/states/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/task/
   jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/graphbased/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/graphbased/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/state/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/esb/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/esb/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/hql/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/java/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/java/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/expression/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/expression/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/text/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/text/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/sql/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/choice/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/sequence/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/sequence/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/states/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/task/
   jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/task/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/integration/
   jbpm4/branches/tbaeyens/modules/integration/integration.iml
   jbpm4/branches/tbaeyens/modules/integration/jboss5/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/integration-jboss5.iml
   jbpm4/branches/tbaeyens/modules/integration/jboss5/pom.xml
   jbpm4/branches/tbaeyens/modules/integration/jboss5/scripts/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/scripts/assembly-config.xml
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeployer.java
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeploymentMetaData.java
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMMetaDataDeployer.java
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-deployers-jboss-beans.xml
   jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-service-jboss-beans.xml
   jbpm4/branches/tbaeyens/modules/integration/pom.xml
   jbpm4/branches/tbaeyens/modules/integration/spi/
   jbpm4/branches/tbaeyens/modules/integration/spi/integration-spi.iml
   jbpm4/branches/tbaeyens/modules/integration/spi/pom.xml
   jbpm4/branches/tbaeyens/modules/integration/spi/src/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/spi/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/spi/JBPMService.java
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelAwareSPIFactory.java
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelLocator.java
   jbpm4/branches/tbaeyens/modules/integration/spi/src/main/resources/
   jbpm4/branches/tbaeyens/modules/jpdl/
   jbpm4/branches/tbaeyens/modules/jpdl/.classpath
   jbpm4/branches/tbaeyens/modules/jpdl/.project
   jbpm4/branches/tbaeyens/modules/jpdl/pom.xml
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-jbpm-config.xml
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-patch-hsql-properties.xml
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/assembly-config.xml
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/build-jars-jpdl.xml
   jbpm4/branches/tbaeyens/modules/jpdl/scripts/build.schema.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndCancelBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndErrorBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBuilder.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveConditionActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveExpressionActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveHandlerActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivityBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlExternalActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/deploy/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/deploy/ParseJpdlDeployer.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlProcessDefinition.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/Activities.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ActivitiesParser.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ParseJpdlBinding.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/StartActivities.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransition.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransitions.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.common.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.db2.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.derby.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.firebird.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.ingres.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.interbase.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mckoi.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mssql.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mysql.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.oracle.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.postgresql.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sapdb.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sybase.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-mysql-ds.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-oracle-ds.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-postgresql-ds.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-sybase-ds.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.wire.bindings.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/DbGenTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/extended.jpdl.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/invalid.jpdl.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/nonamespace.jpdl.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/valid.jpdl.xml
   jbpm4/branches/tbaeyens/modules/log/
   jbpm4/branches/tbaeyens/modules/log/.classpath
   jbpm4/branches/tbaeyens/modules/log/.project
   jbpm4/branches/tbaeyens/modules/log/pom.xml
   jbpm4/branches/tbaeyens/modules/log/src/
   jbpm4/branches/tbaeyens/modules/log/src/main/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ConsoleHandler.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ErrorTriggeredFileHandler.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14Log.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14LogFactory.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLog.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLogFactory.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFactory.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFormatter.java
   jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/log/
   jbpm4/branches/tbaeyens/modules/pvm/
   jbpm4/branches/tbaeyens/modules/pvm/.classpath
   jbpm4/branches/tbaeyens/modules/pvm/.project
   jbpm4/branches/tbaeyens/modules/pvm/build.xml
   jbpm4/branches/tbaeyens/modules/pvm/pom.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/config/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/config/build.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/jobexecutor.ppt
   jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.build.uml
   jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.dependencies.uml
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBehaviourBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ObservableBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ProcessDefinitionBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/TimerBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/UnresolvedFlow.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendar.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Day.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/DayPart.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Holiday.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandException.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/EndProcessInstance.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionsCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByKeyCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetAttachment.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/QueryCommand.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/AssignFileTypeDeployer.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/Deployer.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/DeployerManager.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveDeployer.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Authentication.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/AuthenticationFilter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/BasicEnvironment.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentDefaults.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionEnvironment.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ExecutionType.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateJobDbSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/PvmNamingStrategy.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionFilter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateGroup.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateMembership.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateUser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteGroup.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteUser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/FindGroupsByUserNameAndGroupType.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetGroups.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetUsers.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionResource.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JbpmIdentityStore.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobAddedNotification.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobDbSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorMessageSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThreadPool.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobHistoryEntry.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategy.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBinary.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyChopped.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BytesChop.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/CharChop.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Chop.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategy.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyChopped.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyClob.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyText.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerSynchronization.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObjectReference.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessModificationsImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AvgDurationPerActivityQueryCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ChoiceDistributionQueryCmd.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/WriteBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandService.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationInterceptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationSession.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DefaultCommandService.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Interceptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleParser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskExecution.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/TransactionException.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/DefaultTypeSet.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Matcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Type.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeMapping.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeSet.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/ClassNameMatcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateIdMatcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateLongIdMatcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateStringIdMatcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/SerializableMatcher.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DateVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DoubleVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateLongVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateStringVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/LongVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/NullVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/StringVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/UnpersistableVariable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ArrayUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Closable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DOMWriter.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DefaultObservable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/FilterListener.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/IoUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Listener.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Observable.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Priority.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/TagBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/UrlEntity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/Descriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireException.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireObjectEventInfo.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AsyncCommandServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AuthorizationInterceptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BasicTypeBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ByteBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CharBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ClassBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ContextRefBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DoubleBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvRefBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentFactoryRefBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FalseBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FieldBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FloatBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionFactoryBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IntBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JndiBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobDbSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobExecutorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobTestHelperBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/LongBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/NullBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ProcessServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertyBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PvmDbSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ScriptManagerBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SeamHibernateSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SetBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ShortBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StringBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskDbSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionRefBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TrueBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireDescriptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireInterceptorBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireOperationBinding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/AbstractDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ArgDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BooleanHelper.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BusinessCalendarDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ByteDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassLoaderDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextTypeRefDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DeployerManagerDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DescriptorException.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentFactoryDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FalseDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateConfigurationDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateJobDbSessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernatePvmDbSessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionFactoryDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ListDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PropertiesDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ProvidedObjectDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SeamHibernateSessionDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SetDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TransactionRefDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TrueDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TypesDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/UrlDescriptor.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/InvokeOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/MethodInvokerListener.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/Operation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/PropertyOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/SubscribeOperation.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/package.html
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/wirecontext.gif
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Binding.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Bindings.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Entity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
   jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/model/
   jbpm4/branches/tbaeyens/modules/pvm/src/main/resources/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/AutomaticActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/DisplaySource.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLn.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLnBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsole.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsoleTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/BuilderTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestBehaviourBuilder.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/identity/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/identity/IdentityTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/util/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/util/FileUtil.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ConcurrentWiringTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DelayedInitTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DependencyTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EagerInitTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/HibernateSessionFactoryWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SubscriptionTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/TypeLookupTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/println/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/println/PrintlnTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/spring/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/spring/SpringTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentDbTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentFactoryTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentTestCase.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/tx/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/META-INF/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/META-INF/persistence.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cache.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.definition.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.execution.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.hibernate.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.history.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.identity.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.lifecycle.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.variable.types.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/Dummy.java
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/continuation/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/continuation/ContinuationTest.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/custom/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/Loan.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/model/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/model/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/mappings.hbm.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/type/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/type/environment.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/file.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/resource.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/url.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/dombuildertest.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/schematest.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/spring/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/spring/spring.beans.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/variables/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/file.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/resource.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/url.properties
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/dombuildertest.xml
   jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/schematest.xml
   jbpm4/branches/tbaeyens/modules/test-base/
   jbpm4/branches/tbaeyens/modules/test-base/.classpath
   jbpm4/branches/tbaeyens/modules/test-base/.project
   jbpm4/branches/tbaeyens/modules/test-base/pom.xml
   jbpm4/branches/tbaeyens/modules/test-base/src/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/Db.java
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
   jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/MessageFinder.java
   jbpm4/branches/tbaeyens/modules/test-db/
   jbpm4/branches/tbaeyens/modules/test-db/.classpath
   jbpm4/branches/tbaeyens/modules/test-db/.project
   jbpm4/branches/tbaeyens/modules/test-db/.settings/
   jbpm4/branches/tbaeyens/modules/test-db/.settings/org.eclipse.jdt.core.prefs
   jbpm4/branches/tbaeyens/modules/test-db/jbpm4-test-db.iml
   jbpm4/branches/tbaeyens/modules/test-db/pom.xml
   jbpm4/branches/tbaeyens/modules/test-db/src/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/cfg/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/AvgDurationTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ChoiceDistributionTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/EndProcessInstanceTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/mgmt/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessAttachmentsTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java
   jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/
   jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/test-load/
   jbpm4/branches/tbaeyens/modules/test-load/.classpath
   jbpm4/branches/tbaeyens/modules/test-load/.project
   jbpm4/branches/tbaeyens/modules/test-load/pom.xml
   jbpm4/branches/tbaeyens/modules/test-load/src/
   jbpm4/branches/tbaeyens/modules/test-load/src/main/
   jbpm4/branches/tbaeyens/modules/test-load/src/main/parked/
   jbpm4/branches/tbaeyens/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/main/scripts/
   jbpm4/branches/tbaeyens/modules/test-load/src/main/scripts/ant.properties.ant.xml
   jbpm4/branches/tbaeyens/modules/test-load/src/test/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/AutomaticActivity.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ContinuationTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveTestCommand.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/GenerateExceptionTestCommand.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/JobExecutorTestCase.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/Recorder.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/Automatic.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/ProcessExecutionTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.cfg.xml
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.load.hbm.xml
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/executions/
   jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/executions/process.jpdl.xml
   jbpm4/branches/tbaeyens/modules/test-pojo/
   jbpm4/branches/tbaeyens/modules/test-pojo/.classpath
   jbpm4/branches/tbaeyens/modules/test-pojo/.project
   jbpm4/branches/tbaeyens/modules/test-pojo/pom.xml
   jbpm4/branches/tbaeyens/modules/test-pojo/src/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/resources/
   jbpm4/branches/tbaeyens/modules/test-pojo/src/main/resources/logging.properties
   jbpm4/branches/tbaeyens/modules/userguide/
   jbpm4/branches/tbaeyens/modules/userguide/.project
   jbpm4/branches/tbaeyens/modules/userguide/.settings/
   jbpm4/branches/tbaeyens/modules/userguide/.settings/attachedFile.properties
   jbpm4/branches/tbaeyens/modules/userguide/pom.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/bpmn/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/bpmn/loan.process.bpm
   jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/diagrams.mdzip
   jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/images.ppt
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.executions.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.definition.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.instance.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.multiple.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.state.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.esb.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.exclusive.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.hql.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.java.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.script.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.choice.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.sequence.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.task.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/show.view.data.source.explorer.png
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/master.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml
   jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch08-Identity.xml
   jbpm4/branches/tbaeyens/pom.xml
   jbpm4/branches/tbaeyens/profiles.xml.example
Log:
creating personal tbaeyens branch

Added: jbpm4/branches/tbaeyens/.project
===================================================================
--- jbpm4/branches/tbaeyens/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jbpm4</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/build.xml
===================================================================
--- jbpm4/branches/tbaeyens/build.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/build.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,134 @@
+<project name="jbpm4" default="install" basedir=".">
+  
+  <!-- This ant build only serves as IDE integration to run maven jobs.
+       Now in eclipse it's possible to open the ant view and double click 
+       the targets in this ant build that will just delegate to the maven 
+       build.  Also, if there are html results being produced by a target, 
+       they are opened in a browser.
+  --> 
+  
+  <!-- Overwrite property values in your local 
+       file ${user.home}/.jbpm4/ant.properties 
+  -->
+  <property file="${user.home}/.jbpm4/ant.properties" />
+  
+  <property name="mvn.executable" value="mvn.bat" />
+  
+  <!-- BROWSER PROPERTIES -->
+  <!-- <property name="windows.browser" value="C:/Program Files/Internet Explorer/IEXPLORE.EXE" /> -->
+  <property name="windows.browser" value="C:/Program Files/Mozilla Firefox/firefox.exe" />
+  <property name="macos.browser" value="/usr/bin/open" />
+  <property name="linux.browser" value="mozilla" />
+
+  <property name="distro.installation.dir" value="c:/software" />
+  <property name="distro.version" value="4.0.0-SNAPSHOT" />
+  <property name="distro.jboss.version" value="5.0.0.GA" />
+  <property name="distro.eclipse" value="c:/downloads/eclipse/eclipse-jee-ganymede-SR1-win32.zip" />
+  <property name="distro.jboss" value="c:/downloads/jboss/jboss-${distro.jboss.version}.zip" />
+  <property name="distro.gef" value="c:/downloads/eclipse/GEF-runtime-3.4.1.zip" />
+
+  <target name="clean">
+    <exec executable="${mvn.executable}">
+      <arg line="clean" />
+    </exec>
+  </target>
+
+  <target name="install">
+    <exec executable="${mvn.executable}" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="-DskipTests install" />
+    </exec>
+  </target>
+  
+  <target name="javadoc">
+    <exec executable="${mvn.executable}" dir="modules/api" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="javadoc:javadoc" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="modules/api/target/site/apidocs/index.html"/>
+    </antcall>
+  </target>
+
+  <target name="test.pvm">
+    <exec dir="modules/pvm" executable="${mvn.executable}" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="${mvn.executable} surefire-report:report" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="modules/pvm/target/site/surefire-report.html"/>
+    </antcall>
+  </target>
+
+  <target name="distro.package">
+    <exec executable="${mvn.executable}" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="-DskipTests package assembly:assembly" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="target/"/>
+    </antcall>
+  </target>
+
+  <target name="distro.install" >
+    <delete dir="${distro.installation.dir}/jbpm-${distro.version}" />
+    <unzip src="${distro.jboss}" dest="${distro.installation.dir}/jbpm-${distro.version}" />
+    <java jar="modules/distro/target/jbpm-installer-${distro.version}.jar" fork="true"/>
+    <unzip src="${distro.eclipse}" dest="${distro.installation.dir}/jbpm-${distro.version}" />
+    <exec executable="cmd" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="/C start &quot;${distro.installation.dir}/jbpm-${distro.version}/eclipse/eclipse.exe&quot; &quot;-data&quot; &quot;${distro.installation.dir}/jbpm-${distro.version}/workspace&quot;" />
+    </exec>
+    <exec executable="cmd" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="/C start &quot;${windows.browser}&quot; &quot;file://${distro.installation.dir}/jbpm-${distro.version}&quot;" />
+    </exec>
+  </target>
+
+  <target name="distro.eclipse.install">
+    <unzip src="${distro.eclipse}" dest="${distro.installation.dir}/jbpm-${distro.version}" />
+  </target>
+
+  <target name="distro.eclipse.start">
+    <exec executable="cmd" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg line="/C start &quot;${distro.installation.dir}/jbpm-${distro.version}/eclipse/eclipse.exe&quot; &quot;-data&quot; &quot;${distro.installation.dir}/jbpm-${distro.version}/workspace&quot;" />
+    </exec>
+  </target>
+
+  <target name="schemadocs">
+    <exec executable="${mvn.executable}" dir="modules/api">
+      <arg line="-Pschemadocs package" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="modules/api/target/doc/schemadoc/index.html"/>
+    </antcall>
+  </target>
+    
+  <target name="devguide">
+    <exec executable="${mvn.executable}" dir="modules/devguide">
+      <arg line="jdocbook:resources jdocbook:generate" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="modules/devguide/target/docbook/publish/en/html_single/index.html"/>
+    </antcall>
+  </target>
+
+  <target name="userguide">
+    <exec executable="${mvn.executable}" dir="modules/userguide">
+      <arg line="jdocbook:resources jdocbook:generate" />
+    </exec>
+    <antcall target="show.html">
+      <param name="page" value="modules/userguide/target/docbook/publish/en/html_single/index.html"/>
+    </antcall>
+  </target>
+
+
+  <!-- HTML -->
+  <target name="show.html">
+    <fail message="property page has to be specified to use this target" unless="page" />
+    <exec executable="cmd" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
+      <arg value="/C start &quot;${windows.browser}&quot; &quot;file://${basedir}/${page}&quot;" />
+    </exec>
+    <exec executable="${macos.browser}" os="Mac OS X">
+      <arg value="file://${basedir}/${page}" />
+    </exec>
+    <exec executable="${linux.browser}" os="Linux">
+      <arg value="file://${basedir}/${page}" />
+    </exec>
+  </target>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/eclipse/jbpm.code.templates.xml
===================================================================
--- jbpm4/branches/tbaeyens/eclipse/jbpm.code.templates.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/eclipse/jbpm.code.templates.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?><templates><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment"></template><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment"></template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment"></template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**
+ * @author Tom Baeyens
+ */</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment"></template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment"></template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment"></template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment"></template><template autoinsert="false" context="newtype_context" deleted="false" !
 description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">${filecomment}
+${package_declaration}
+
+${typecomment}
+${type_declaration}</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody">
+</template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody">
+</template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody">
+</template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody">
+</template><template autoinsert="false" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock">${exception_var}.printStackTrace();</template><template autoinsert="false" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody">${body_statement}</template><template autoinsert="false" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement}</template><template autoinsert="true" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody">return ${field};</template><template autoinsert="!
 true" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param};</template><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter function" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
+ * @return the ${bare_field_name}
+ */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter function" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.settercomment" name="settercomment">/**
+ * @param ${param} the ${bare_field_name} to set
+ */</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
+ * ${tags}
+ */</template><template autoinsert="true" context="filecomment_context" deleted="false" description="Comment for created JavaScript files" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.filecomment" name="filecomment">/**
+ * 
+ */</template><template autoinsert="true" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.typecomment" name="typecomment">/**
+ * @author ${user}
+ *
+ * ${tags}
+ */</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for vars" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
+ * 
+ */</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="Comment for non-overriding function" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
+ * ${tags}
+ */</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="Comment for overriding functions" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Jsdoc)
+ * ${see_to_overridden}
+ */</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate functions" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
+ * ${tags}
+ * ${see_to_target}
+ */</template><template autoinsert="true" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.newtype" name="newtype">${filecomment}
+${package_declaration}
+
+${typecomment}
+${type_declaration}</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.classbody" name="classbody">
+</template><template autoinsert="false" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.catchblock" name="catchblock">${exception_var}.printStackTrace();</template><template autoinsert="false" context="methodbody_context" deleted="false" description="Code in created function stubs" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.methodbody" name="methodbody">${body_statement}</template><template autoinsert="false" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement}</template><template autoinsert="true" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.getterbody" name="getterbody">return ${field};</template>!
 <template autoinsert="true" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.wst.jsdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param};</template></templates>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/eclipse/jbpm.profile.xml
===================================================================
--- jbpm4/branches/tbaeyens/eclipse/jbpm.profile.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/eclipse/jbpm.profile.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,267 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles version="11">
+<profile kind="CodeFormatterProfile" name="jbpm profile" version="11">
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="160"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+</profile>
+</profiles>

Added: jbpm4/branches/tbaeyens/eclipse/readme.txt
===================================================================
--- jbpm4/branches/tbaeyens/eclipse/readme.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/eclipse/readme.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,26 @@
+#
+# $Id: $ 
+#
+
+1. Edit your subversion config ~/.subversion/config and set the following in each section:
+
+[miscellany]
+enable-auto-props = yes
+
+[auto-props]
+*.bat = svn:keywords=Id Revision;svn:eol-style=LF
+*.java = svn:keywords=Id Revision;svn:eol-style=LF
+*.sh = svn:keywords=Id Revision;svn:eol-style=LF
+*.txt = svn:keywords=Id Revision;svn:eol-style=LF
+*.wsdl = svn:keywords=Id Revision;svn:eol-style=LF
+*.xml = svn:keywords=Id Revision;svn:eol-style=LF
+*.xsd = svn:keywords=Id Revision;svn:eol-style=LF
+
+2. If you are using an IDE, make sure that it refers to the same config. So, 
+for example, if you are using Eclipse with Subclipse on windows, you need to
+set Team->SVN->Configuration Location to:
+
+/home/<your user name>/.subversion
+
+3. If you are using Eclipse, set your code style to jbpm.code.templates.xml with 
+Window --> Preferences --> Java --> Code Style --> Formatter --> Import 

Added: jbpm4/branches/tbaeyens/hudson/ant.properties.example
===================================================================
--- jbpm4/branches/tbaeyens/hudson/ant.properties.example	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/ant.properties.example	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+#
+# A sample ant properties file
+#
+# $Id: ant.properties.example 3995 2007-07-26 08:52:45Z thomas.diesler at jboss.com $
+
+# JBoss remote repository
+jboss.repository=http://repository.jboss.org
+
+# The JBoss settings
+jboss.server.instance=default
+jboss.bind.address=127.0.0.1
+
+# JDK settings  (Mac OS /Library/Java/Home/)
+java.home.jdk15=/usr/java/jdk1.5.0_15
+java.home.jdk16=/usr/java/jdk1.6.0_06
+
+# Hudson QA Environment
+hudson.username=changeme
+hudson.password=changeme
+
+catalina.executable=catalina.sh
+
+hudson.maven.path=/usr/java/apache-maven-2.0.9
+
+hudson.root=/home/hudson/workspace
+
+hudson.maven.profile=$JBPMDIR/hudson/profiles.xml.local.qa
+
+hudson.host=jbpm.dyndns.org
+hudson.admin.port=8150
+hudson.http.port=8180
+
+#hudson.jboss422.zip=file:///home/hudson/download/java/jboss/jboss-4.2.2.GA.zip
+#hudson.jboss423.zip=file:///home/hudson/download/java/jboss/jboss-4.2.3.GA.zip
+#hudson.jboss500.zip=file:///home/hudson/download/java/jboss/jboss-5.0.0.GA.zip
+
+#
+# Proprietary jdbc drivers
+#
+# if you don't provide them locally,
+# they'll be pulled from http://www.qa.jboss.com/jdbc-drivers/maven2
+#
+oracle.version=10.0.2.0
+oracle.jar=file:///home/hudson/download/jdbc/ojdbc14.jar
+
+hudson.mail.recipients=
+hudson.smtp.host=localhost
+
+# Hudson (1.270)
+apache-tomcat=5.5.20
+sun-hudson=2402/122511

Added: jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/server.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/server.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/server.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+
+<Server port="@hudson.admin.port@" shutdown="SHUTDOWN">
+  
+  <!-- Comment these entries out to disable JMX MBeans support used for the 
+  administration web application -->
+  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
+  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
+  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
+  
+  <!-- Global JNDI resources -->
+  <GlobalNamingResources>
+    
+    <!-- Test entry for demonstration purposes -->
+    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
+    
+    <!-- Editable user database that can also be used by
+    UserDatabaseRealm to authenticate users -->
+    <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"
+      factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"/>
+    
+  </GlobalNamingResources>
+  
+  <!-- Define the Tomcat Stand-Alone Service -->
+  <Service name="Catalina">
+    
+    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
+    <Connector port="@hudson.http.port@" maxHttpHeaderSize="8192" maxThreads="150" 
+      minSpareThreads="25" maxSpareThreads="75" 
+      enableLookups="false" redirectPort="8443" acceptCount="100"
+      connectionTimeout="20000" disableUploadTimeout="true"/>
+    
+    <!-- Define the top level container in our container hierarchy -->
+    <Engine name="Catalina" defaultHost="localhost">
+      
+      <!-- This Realm uses the UserDatabase configured in the global JNDI
+      resources under the key "UserDatabase".  Any edits
+      that are performed against this UserDatabase are immediately
+      available for use by the Realm.  -->
+      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
+      
+      <!-- Define the default virtual host
+      Note: XML Schema validation will not work with Xerces 2.2.
+      -->
+      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
+        
+        <Context path="/hudson">
+          <Environment description="" name="HUDSON_HOME" type="java.lang.String" value="@hudson.home@"/>
+        </Context>
+        
+      </Host>
+      
+    </Engine>
+    
+  </Service>
+  
+</Server>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/tomcat-users.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/tomcat-users.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/apache-tomcat/conf/tomcat-users.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+<?xml version='1.0' encoding='utf-8'?>
+<tomcat-users>
+  <role rolename="admin"/>
+  <user username="@hudson.username@" password="@hudson.password@" roles="admin"/>
+</tomcat-users>

Added: jbpm4/branches/tbaeyens/hudson/build.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/build.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/build.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: build.xml 3259 2008-12-08 08:42:06Z thomas.diesler at jboss.com $ -->
+
+<project>
+  
+  <property name="hudson.dir" value="${basedir}"/>
+  <property name="hudson.target.dir" value="${hudson.dir}/target"/>
+  
+  <!-- ================================================================== -->
+  <!-- Initialization                                                     -->
+  <!-- ================================================================== -->
+  
+  <target name="init">
+    <!-- Check if ant.properties is available -->
+    <available property="ant.properties.available" file="${basedir}/ant.properties"/>
+    <fail message="Cannot find ant.properties. Did you copy/edit ant.properties.example?" unless="ant.properties.available"/>
+    
+    <property file="${basedir}/ant.properties"/>
+    
+    <xmlproperty file="${basedir}/../pom.xml"/>
+    <property name="version.id" value="${project.version}"/>
+    <property name="repository.id" value="${project.version}"/>
+    
+    <echo message="version.id=${version.id}"/>
+    <echo message="repository.id=${repository.id}"/>
+  </target>
+  
+  <target name="init-hudson" depends="init">
+    <property name="hudson.base" value="${hudson.root}/jbpm-hudson-${version.id}"/>
+    <property name="hudson.tomcat" value="${hudson.base}/apache-tomcat"/>
+    <property name="hudson.home" value="${hudson.base}/hudson-home"/>
+    <property name="hudson.jboss" value="${hudson.base}/jboss"/>
+    
+    <echo/>
+    <echo message="hudson.root = ${hudson.root}"/>
+    <echo message="hudson.home = ${hudson.home}"/>
+    <echo/>
+    
+    <available file="${hudson.root}" property="hudson.root.available"/>
+    <available file="${hudson.tomcat}" property="hudson.tomcat.available"/>
+    <fail message="Hudson root not available" unless="hudson.root.available"/>
+    
+    <property name="hudson.username.${hudson.username}" value="true"/>
+    <fail message="Cannot use default hudson username: ${hudson.username}" if="hudson.username.changeme"/>
+    <property name="hudson.password.${hudson.password}" value="true"/>
+    <fail message="Cannot use default hudson password: ${hudson.password}" if="hudson.password.changeme"/>
+  </target>
+  
+  <target name="init-thirdparty" depends="init-hudson">
+    <property name="thirdparty.dir" value="${hudson.target.dir}/thirdparty"/>
+    <mkdir dir="${thirdparty.dir}"/>
+    <available property="apache.tomcat.available" file="${thirdparty.dir}/apache-tomcat.zip"/>
+    <available property="sun.hudson.available" file="${thirdparty.dir}/hudson.war"/>
+    <available property="jboss422.available" file="${thirdparty.dir}/jboss-4.2.2.GA.zip"/>
+    <available property="jboss423.available" file="${thirdparty.dir}/jboss-4.2.3.GA.zip"/>
+    <available property="jboss500.available" file="${thirdparty.dir}/jboss-5.0.0.GA.zip"/>
+    <available property="oracle.available" file="${thirdparty.dir}/ojdbc14-${oracle.version}.jar"/>
+  </target>
+	
+  <!-- 
+    Get thirdparty dependencies 
+  -->
+  <target name="thirdparty" depends="init-thirdparty,get-tomcat,get-hudson,get-jboss422,get-jboss423,get-jboss500,get-oracle">
+    <copy todir="${hudson.base}/jboss" file="${thirdparty.dir}/jboss-4.2.2.GA.zip"/>
+    <copy todir="${hudson.base}/jboss" file="${thirdparty.dir}/jboss-4.2.3.GA.zip"/>
+    <copy todir="${hudson.base}/jboss" file="${thirdparty.dir}/jboss-5.0.0.GA.zip"/>
+    <copy todir="${hudson.base}/jdbc" file="${thirdparty.dir}/ojdbc14.jar"/>
+  </target>
+  <target name="get-tomcat" depends="init-thirdparty" unless="apache.tomcat.available">
+    <get src="${jboss.repository}/apache-tomcat/${apache-tomcat}/lib/apache-tomcat.zip" dest="${thirdparty.dir}/apache-tomcat.zip" usetimestamp="true" verbose="true"/>
+  </target>
+  <target name="get-hudson" depends="init-thirdparty" unless="sun.hudson.available">
+    <get src="https://hudson.dev.java.net/files/documents/${sun-hudson}/hudson.war" dest="${thirdparty.dir}/hudson.war" usetimestamp="true" verbose="true"/>
+  </target>
+  <target name="get-jboss422" depends="init-thirdparty" unless="jboss422.available">
+    <property name="hudson.jboss422.zip" value="http://downloads.sourceforge.net/jboss/jboss-4.2.2.GA.zip"/>
+    <get src="${hudson.jboss422.zip}" dest="${thirdparty.dir}/jboss-4.2.2.GA.zip" usetimestamp="true" verbose="true"/>
+  </target>
+  <target name="get-jboss423" depends="init-thirdparty" unless="jboss423.available">
+    <property name="hudson.jboss423.zip" value="http://downloads.sourceforge.net/jboss/jboss-4.2.3.GA.zip"/>
+    <get src="${hudson.jboss423.zip}" dest="${thirdparty.dir}/jboss-4.2.3.GA.zip" usetimestamp="true" verbose="true"/>
+  </target>
+  <target name="get-jboss500" depends="init-thirdparty" unless="jboss500.available">
+    <property name="hudson.jboss500.zip" value="http://downloads.sourceforge.net/jboss/jboss-5.0.0.GA.zip"/>
+    <get src="${hudson.jboss500.zip}" dest="${thirdparty.dir}/jboss-5.0.0.GA.zip" usetimestamp="true" verbose="true"/>
+  </target>
+  <target name="get-oracle" depends="init-thirdparty" unless="oracle.available">
+    <property name="oracle.jar" value="http://www.qa.jboss.com/jdbc-drivers/maven2/com/oracle/ojdbc14/${oracle.version}/ojdbc14-${oracle.version}.jar"/>
+    <get src="${oracle.jar}" dest="${thirdparty.dir}/ojdbc14.jar" usetimestamp="true" verbose="true"/>
+  </target>
+  
+  <!--
+    Setup the Hudson Tomcat instance 
+  -->
+  <target name="hudson-tomcat-setup" depends="thirdparty" unless="hudson.tomcat.available">
+    
+    <!-- Install Tomcat -->
+    <mkdir dir="${hudson.root}"/>
+    <unzip src="${thirdparty.dir}/apache-tomcat.zip" dest="${hudson.root}"/>
+    <move file="${hudson.root}/apache-tomcat-${apache-tomcat}" tofile="${hudson.tomcat}"/>
+    <chmod perm="+x">
+      <fileset dir="${hudson.tomcat}/bin">
+        <include name="*.sh"/>
+      </fileset>
+    </chmod>
+    
+    <!-- Install Hudson -->
+    <copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/hudson.war"/>
+    
+  </target>
+  
+  <!-- 
+    Update the Hudson version
+  -->
+  <target name="hudson-update" depends="init-thirdparty">
+    <get src="https://hudson.dev.java.net/files/documents/${sun-hudson}/hudson.war" dest="${thirdparty.dir}/hudson.war" usetimestamp="false" verbose="true"/>
+    <delete dir="${hudson.tomcat}/webapps/hudson"/>
+    <copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/hudson.war"/>
+  </target>
+
+  <!-- 
+    Setup the Hudson QA environment
+  -->
+  <target name="hudson-setup" depends="init-hudson,hudson-tomcat-setup"  description="Setup the Hudson QA environment">
+    
+    <!-- get the svn url -->
+    <exec dir="${hudson.dir}/.." executable="svn" failonerror="true" output="${hudson.target.dir}/svn-info.xml">
+      <arg line="info"/>
+      <arg line="--xml"/>
+    </exec>
+    <xmlproperty file="${hudson.target.dir}/svn-info.xml"/>
+    <property name="hudson.jbpm.url" value="${info.entry.url}"/>
+    
+    <!-- Configure Tomcat -->
+    <copy todir="${hudson.tomcat}" overwrite="true">
+      <fileset dir="${hudson.dir}/apache-tomcat">
+        <include name="**/*.xml"/>
+      </fileset>
+      <filterset>
+        <filtersfile file="${hudson.dir}/ant.properties"/>
+        <filter token="hudson.home" value="${hudson.home}"/>
+      </filterset>
+    </copy>
+    
+    <!-- Configure Hudson -->
+    <copy todir="${hudson.home}" overwrite="true">
+      <fileset dir="${hudson.dir}/hudson-home">
+        <include name="jobs/*/config.xml"/>
+        <include name="command.sh"/>
+        <include name="*.xml"/>
+      </fileset>
+      <filterset>
+        <filter token="hudson.jbpm.url" value="${hudson.jbpm.url}"/>
+        <filter token="hudson.base" value="${hudson.base}"/>
+        <filter token="hudson.home" value="${hudson.home}"/>
+        <filter token="version.id" value="${version.id}"/>
+        <filtersfile file="${hudson.dir}/ant.properties"/>
+      </filterset>
+    </copy>
+
+    <echo/>
+    <echo message="*************************************"/>
+    <echo message="* Hudson setup successfully         *"/>
+    <echo message="* ant hudson-start                  *"/>
+    <echo message="*************************************"/>
+    <echo/>
+
+  </target>
+  
+  <target name="hudson-stop" depends="init-hudson" description="Stops the Hudson QA environment">
+    
+    <exec executable="${hudson.tomcat}/bin/${catalina.executable}" failonerror="true">
+      <arg line="stop"/>
+    </exec>
+
+    <echo/>
+    <echo message="*************************************"/>
+    <echo message="* Hudson stopped successfully       *"/>
+    <echo message="* ant hudson-start                  *"/>
+    <echo message="*************************************"/>
+    <echo/>
+
+  </target>
+  
+  <target name="hudson-start" depends="init-hudson" description="Start the Hudson QA environment">
+    
+    <property environment="env"/>
+    <fail message="unset JBOSS_REPOSITORY=${env.JBOSS_REPOSITORY}" if="env.JBOSS_REPOSITORY"/>
+
+    <exec executable="${hudson.tomcat}/bin/${catalina.executable}" failonerror="true" output="${hudson.target.dir}/hudson.log">
+      <env key="CATALINA_OPTS" value="-Xmx512m -Djava.awt.headless=true"/>
+      <arg line="start"/>
+    </exec>
+
+    <echo/>
+    <echo message="*************************************"/>
+    <echo message="* Hudson started successfully       *"/>
+    <echo message="* http://localhost:${hudson.http.port}/hudson      *"/>
+    <echo message="*************************************"/>
+    <echo/>
+
+  </target>
+  
+</project>

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/command.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/command.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/command.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container 
+#
+# $Id: command.sh 3630 2009-01-12 08:55:44Z thomas.diesler at jboss.com $
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+DISTRODIR=$JBPMDIR/modules/distro/target
+
+case "$CONTAINER" in
+  jboss422*)
+    JBOSS_BUILD=jboss-4.2.2.GA
+  ;;
+
+  jboss423*)
+    JBOSS_BUILD=jboss-4.2.3.GA
+  ;;
+
+  jboss500*)
+    JBOSS_BUILD=jboss-5.0.0.GA
+  ;;
+esac
+
+#
+# Unzip the JBoss build
+#
+rm -rf $JBOSS_BUILD
+unzip -q $HUDSON_BASE/jboss/$JBOSS_BUILD.zip
+
+JBOSS_HOME=$WORKSPACE/$JBOSS_BUILD
+ENVIRONMENT="-Ddatabase=$DATABASE -Djbpm.target.container=$CONTAINER -Djboss.home=$JBOSS_HOME -Djboss.bind.address=$JBOSS_BINDADDR"
+
+#
+# proprietary jdbc drivers
+#
+cp $HUDSON_BASE/jdbc/ojdbc14.jar $JBOSS_HOME/server/default/lib/
+
+#
+# Build distro
+#
+cd $JBPMDIR
+MVN_CMD="mvn -U $ENVIRONMENT -Pdistro clean install"
+echo $MVN_CMD; $MVN_CMD; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+  echo maven exit status $MVN_STATUS
+  exit 1
+fi
+
+#
+# build the tests
+#
+MVN_CMD="mvn -o $ENVIRONMENT process-test-classes"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+  echo maven exit status $MVN_STATUS
+  exit 1
+fi
+
+#
+# Deploy distro
+#
+AUTO_INSTALL=modules/distro/target/resources/auto-install-template.xml; cat $AUTO_INSTALL;
+JAVA_CMD="java -jar $DISTRODIR/jbpm-installer-$JBPM_VERSION.jar $AUTO_INSTALL"
+echo $JAVA_CMD; $JAVA_CMD 
+
+# FIXME: Autoinstall does not respect conditions
+# http://jira.codehaus.org/browse/IZPACK-153
+rm $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-*-ds.xml
+rm $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml
+cp $JBOSS_HOME/docs/examples/jbpm/jbpm-$DATABASE-ds.xml $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-$DATABASE-ds.xml
+cp $JBOSS_HOME/docs/examples/jbpm/hibernate.cfg.$DATABASE.xml $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml
+
+#if [ $CONTAINER = "jboss500" ]; then
+#  rm $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-service.sar/slf4j-api.jar
+#fi
+
+# FIXME: find out whether jTDS can be made to work with XA data source
+# https://jira.jboss.org/jira/browse/JBPM-1818
+SYBASE_JDBC_DRIVER=~/.m2/repository/com/sybase/jconnect/6.0.5/jconnect-6.0.5.jar
+if [ -f $SYBASE_JDBC_DRIVER ]; then
+  echo "cp $SYBASE_JDBC_DRIVER $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-service.sar"
+  cp $SYBASE_JDBC_DRIVER $JBOSS_HOME/server/$JBOSS_SERVER/deploy/jbpm/jbpm-service.sar
+fi
+
+#
+# start jbossas
+#
+$JBPMDIR/hudson/jboss/bin/jboss.sh $JBOSS_HOME start $JBOSS_BINDADDR
+
+# Was it successfully started?
+$JBPMDIR/hudson/jboss/bin/http-spider.sh $JBOSS_BINDADDR:8080 $WORKSPACE
+if [ -e $WORKSPACE/spider.failed ]; then
+  echo "JBoss could not be started:"
+  cat $WORKSPACE/spider.failed
+  tail -n 100 $JBOSS_HOME/server/$JBOSS_SERVER/log/server.log
+  $JBPMDIR/hudson/jboss/bin/jboss.sh $JBOSS_HOME stop $JBOSS_BINDADDR
+  exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o $ENVIRONMENT dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute tests
+#
+MVN_CMD="mvn -o -fae $ENVIRONMENT test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.log
+cat $WORKSPACE/tests.log | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt
+cat $WORKSPACE/fixme.txt | egrep "\[\S*]" > $WORKSPACE/errata-$CONTAINER.txt || :
+
+#
+# stop jbossas
+#
+$JBPMDIR/hudson/jboss/bin/jboss.sh $JBOSS_HOME stop
+cp $JBOSS_HOME/server/$JBOSS_SERVER/log/boot.log $WORKSPACE/jboss-boot.log
+cp $JBOSS_HOME/server/$JBOSS_SERVER/log/server.log $WORKSPACE/jboss-server.log

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/config.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<hudson>
+  <numExecutors>2</numExecutors>
+  <mode>NORMAL</mode>
+  <useSecurity>true</useSecurity>
+  <authorizationStrategy class="hudson.security.LegacyAuthorizationStrategy"/>
+  <securityRealm class="hudson.security.LegacySecurityRealm"/>
+  <systemMessage>
+    
+  <![CDATA[
+  <h2>jBPM- at version.id@ QA Environment</h2>
+
+  <table>
+  <tr align="left"><th>SVN</th><td>@hudson.jbpm.url@</td></tr>
+  <tr align="left"><th>Bind Addr</th><td>@jboss.bind.address@</td></tr>
+  </table>
+]]>
+  </systemMessage>
+  <jdks>
+    <jdk>
+      <name>jdk1.5</name>
+      <javaHome>@java.home.jdk15@</javaHome>
+    </jdk>
+    <jdk>
+      <name>jdk1.6</name>
+      <javaHome>@java.home.jdk16@</javaHome>
+    </jdk>
+  </jdks>
+  <clouds/>
+  <slaves/>
+  <quietPeriod>5</quietPeriod>
+  <views>
+    <hudson.model.AllView>
+      <owner class="hudson" reference="../../.."/>
+      <name>All</name>
+    </hudson.model.AllView>
+  </views>
+  <primaryView>All</primaryView>
+  <slaveAgentPort>0</slaveAgentPort>
+  <label></label>
+</hudson>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Mailer.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Mailer.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Mailer.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<hudson.tasks.Mailer-DescriptorImpl>
+  <defaultSuffix></defaultSuffix>
+  <hudsonUrl>http://@hudson.host@:@hudson.http.port@/hudson/</hudsonUrl>
+  <adminAddress>hbraun at jboss.com</adminAddress>
+  <smtpHost>@hudson.smtp.host@</smtpHost>
+</hudson.tasks.Mailer-DescriptorImpl>
+

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Maven.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Maven.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/hudson.tasks.Maven.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<hudson.tasks.Maven_-DescriptorImpl>
+  <installations>
+    <hudson.tasks.Maven_-MavenInstallation>
+      <name>apache-maven</name>
+      <mavenHome>@hudson.maven.path@</mavenHome>
+    </hudson.tasks.Maven_-MavenInstallation>
+  </installations>
+</hudson.tasks.Maven_-DescriptorImpl>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Container-Matrix/config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,101 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<matrix-project>
+  <actions class="java.util.concurrent.CopyOnWriteArrayList"/>
+  <description></description>
+  <keepDependencies>false</keepDependencies>
+  <properties/>
+  <scm class="hudson.scm.SubversionSCM">
+    <locations>
+      <hudson.scm.SubversionSCM_-ModuleLocation>
+        <remote>@hudson.jbpm.url@</remote>
+        <local>jbpm4</local>
+      </hudson.scm.SubversionSCM_-ModuleLocation>
+    </locations>
+    <useUpdate>true</useUpdate>
+    <browser class="hudson.scm.browsers.FishEyeSVN">
+      <url>http://fisheye.jboss.com/browse/JbpmSvn/</url>
+      <rootModule></rootModule>
+    </browser>
+  </scm>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <triggers class="vector">
+    <hudson.triggers.TimerTrigger>
+      <spec>5 4 * * *</spec>
+    </hudson.triggers.TimerTrigger>
+  </triggers>
+  <axes>
+    <axis>
+      <name>CONTAINER</name>
+      <values>
+        <string>jboss422</string>
+        <string>jboss423</string>
+        <string>jboss500</string>
+      </values>
+    </axis>
+    <axis>
+      <name>DATABASE</name>
+      <values>
+        <string>hsqldb</string>
+        <string>mysql</string>
+        <string>oracle</string>
+      </values>
+    </axis>
+    <axis>
+      <name>jdk</name>
+      <values>
+        <string>jdk1.6</string>
+        <string>jdk1.5</string>
+      </values>
+    </axis>
+  </axes>
+  <builders>
+    <hudson.tasks.Shell>
+<command>
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+
+export HUDSON_BASE=@hudson.base@
+export JBPM_VERSION=@version.id@
+export JBOSS_SERVER=@jboss.server.instance@
+export JBOSS_BINDADDR=@jboss.bind.address@
+
+#
+# copy the maven profile
+#
+cp $JBPMDIR/hudson/profiles.xml.local.qa $JBPMDIR/profiles.xml
+
+#
+# create the database tables
+#
+cd $JBPMDIR/modules/db
+mvn -Pcreate-tables -Ddatabase=$DATABASE install
+
+#
+# call command.sh
+#
+cd $WORKSPACE
+/bin/sh $JBPMDIR/hudson/hudson-home/command.sh
+
+#
+# drop the database tables (cleanup)
+#
+cd $JBPMDIR/modules/db
+mvn -Pdrop-tables -Ddatabase=$DATABASE install
+
+cd $WORKSPACE      
+</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers>
+    <hudson.tasks.junit.JUnitResultArchiver>
+      <testResults>jbpm4/modules/**/target/surefire-reports/TEST-*.xml</testResults>
+    </hudson.tasks.junit.JUnitResultArchiver>
+    <hudson.tasks.Mailer>
+      <recipients>hbraun at redhat.com</recipients>
+      <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
+      <sendToIndividuals>false</sendToIndividuals>
+    </hudson.tasks.Mailer>
+  </publishers>
+  <buildWrappers/>
+</matrix-project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Database-Matrix/config.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Database-Matrix/config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-Database-Matrix/config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<matrix-project>
+  <actions class="java.util.concurrent.CopyOnWriteArrayList"/>
+  <description></description>
+  <keepDependencies>false</keepDependencies>
+  <properties/>
+  <scm class="hudson.scm.SubversionSCM">
+    <locations>
+      <hudson.scm.SubversionSCM_-ModuleLocation>
+        <remote>@hudson.jbpm.url@</remote>
+        <local>jbpm4</local>
+      </hudson.scm.SubversionSCM_-ModuleLocation>
+    </locations>
+    <useUpdate>true</useUpdate>
+    <browser class="hudson.scm.browsers.FishEyeSVN">
+      <url>http://fisheye.jboss.com/browse/JbpmSvn/</url>
+      <rootModule></rootModule>
+    </browser>
+  </scm>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <triggers class="vector">
+    <hudson.triggers.TimerTrigger>
+      <spec>5 6 * * *</spec>
+    </hudson.triggers.TimerTrigger>
+  </triggers>
+  <axes>
+    <axis>
+      <name>CONTAINER</name>
+      <values>
+        <string>jboss500</string>
+      </values>
+    </axis>
+    <axis>
+      <name>DATABASE</name>
+      <values>
+        <string>hsqldb</string>
+        <string>mysql</string>
+        <string>oracle</string>
+      </values>
+    </axis>
+    <axis>
+      <name>jdk</name>
+      <values>
+        <string>jdk1.6</string>
+        <string>jdk1.5</string>
+      </values>
+    </axis>
+  </axes>
+  <builders>
+    <hudson.tasks.Shell>
+<command>
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+
+export HUDSON_BASE=@hudson.base@
+export JBPM_VERSION=@version.id@
+export JBOSS_SERVER=@jboss.server.instance@
+export JBOSS_BINDADDR=@jboss.bind.address@
+
+#
+# copy the maven profile
+#
+cp $JBPMDIR/hudson/profiles.xml.local.qa $JBPMDIR/profiles.xml
+
+#
+# create the database tables
+#
+cd $JBPMDIR/modules/db
+mvn -Pcreate-tables -Ddatabase=$DATABASE install
+
+#
+# call command.sh
+#
+cd $WORKSPACE
+/bin/sh $JBPMDIR/hudson/hudson-home/command.sh
+
+#
+# drop the database tables (cleanup)
+#
+cd $JBPMDIR/modules/db
+mvn -Pdrop-tables -Ddatabase=$DATABASE install
+
+cd $WORKSPACE              
+</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers>
+    <hudson.tasks.junit.JUnitResultArchiver>
+      <testResults>jbpm4/modules/**/target/surefire-reports/TEST-*.xml</testResults>
+    </hudson.tasks.junit.JUnitResultArchiver>
+    <hudson.tasks.Mailer>
+      <recipients>hbraun at redhat.com</recipients>
+      <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
+      <sendToIndividuals>false</sendToIndividuals>
+    </hudson.tasks.Mailer>
+  </publishers>
+  <buildWrappers/>
+</matrix-project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.5/config.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.5/config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.5/config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<matrix-project>
+  <actions class="java.util.concurrent.CopyOnWriteArrayList"/>
+  <description></description>
+  <keepDependencies>false</keepDependencies>
+  <properties/>
+  <scm class="hudson.scm.SubversionSCM">
+    <locations>
+      <hudson.scm.SubversionSCM_-ModuleLocation>
+        <remote>@hudson.jbpm.url@</remote>
+        <local>jbpm4</local>
+      </hudson.scm.SubversionSCM_-ModuleLocation>
+    </locations>
+    <useUpdate>true</useUpdate>
+    <browser class="hudson.scm.browsers.FishEyeSVN">
+      <url>http://fisheye.jboss.com/browse/JbpmSvn/</url>
+      <rootModule></rootModule>
+    </browser>
+  </scm>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <triggers class="vector"/>
+  <axes>
+    <axis>
+      <name>DATABASE</name>
+      <values>
+        <string>hsqldb</string>
+      </values>
+    </axis>
+    <axis>
+      <name>CONTAINER</name>
+      <values>
+        <string>jboss500</string>
+      </values>
+    </axis>
+    <axis>
+      <name>jdk</name>
+      <values>
+        <string>jdk1.5</string>
+      </values>
+    </axis>
+  </axes>
+  <builders>
+    <hudson.tasks.Shell>
+<command>
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+
+export HUDSON_BASE=@hudson.base@
+export JBPM_VERSION=@version.id@
+export JBOSS_SERVER=@jboss.server.instance@
+export JBOSS_BINDADDR=@jboss.bind.address@
+
+#
+# copy the maven profile
+#
+cp $JBPMDIR/hudson/profiles.xml.local.qa $JBPMDIR/profiles.xml
+
+#
+# create the database tables
+#
+cd $JBPMDIR/modules/db
+mvn -Pcreate-tables -Ddatabase=$DATABASE install
+
+#
+# call command.sh
+#
+cd $WORKSPACE
+/bin/sh $JBPMDIR/hudson/hudson-home/command.sh
+
+#
+# drop the database tables (cleanup)
+#
+cd $JBPMDIR/modules/db
+mvn -Pdrop-tables -Ddatabase=$DATABASE install
+
+cd $WORKSPACE      
+</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers>
+    <hudson.tasks.junit.JUnitResultArchiver>
+      <testResults>jbpm4/modules/**/target/surefire-reports/TEST-*.xml</testResults>
+    </hudson.tasks.junit.JUnitResultArchiver>
+  </publishers>
+  <buildWrappers/>
+</matrix-project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.6/config.xml
===================================================================
--- jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.6/config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/hudson-home/jobs/jBPM4-JDK1.6/config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<matrix-project>
+  <actions class="java.util.concurrent.CopyOnWriteArrayList"/>
+  <description></description>
+  <keepDependencies>false</keepDependencies>
+  <properties/>
+  <scm class="hudson.scm.SubversionSCM">
+    <locations>
+      <hudson.scm.SubversionSCM_-ModuleLocation>
+        <remote>@hudson.jbpm.url@</remote>
+        <local>jbpm4</local>
+      </hudson.scm.SubversionSCM_-ModuleLocation>
+    </locations>
+    <useUpdate>true</useUpdate>
+    <browser class="hudson.scm.browsers.FishEyeSVN">
+      <url>http://fisheye.jboss.com/browse/JbpmSvn/</url>
+      <rootModule></rootModule>
+    </browser>
+  </scm>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <triggers class="vector"/>
+  <axes>
+    <axis>
+      <name>database</name>
+      <values>
+        <string>hsqldb</string>
+      </values>
+    </axis>
+    <axis>
+      <name>container</name>
+      <values>
+        <string>jboss500</string>
+      </values>
+    </axis>
+    <axis>
+      <name>jdk</name>
+      <values>
+        <string>jdk1.6</string>
+      </values>
+    </axis>
+  </axes>
+    <builders>
+    <hudson.tasks.Shell>
+<command>
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+
+export HUDSON_BASE=@hudson.base@
+export JBPM_VERSION=@version.id@
+export JBOSS_SERVER=@jboss.server.instance@
+export JBOSS_BINDADDR=@jboss.bind.address@
+
+#
+# copy the maven profile
+#
+cp $JBPMDIR/hudson/profiles.xml.local.qa $JBPMDIR/profiles.xml
+
+#
+# create the database tables
+#
+cd $JBPMDIR/modules/db
+mvn -Pcreate-tables -Ddatabase=$DATABASE install
+
+#
+# call command.sh
+#
+cd $WORKSPACE
+/bin/sh $JBPMDIR/hudson/hudson-home/command.sh
+
+#
+# drop the database tables (cleanup)
+#
+cd $JBPMDIR/modules/db
+mvn -Pdrop-tables -Ddatabase=$DATABASE install
+
+cd $WORKSPACE
+</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers>
+    <hudson.tasks.junit.JUnitResultArchiver>
+      <testResults>jbpm4/modules/**/target/surefire-reports/TEST-*.xml</testResults>
+    </hudson.tasks.junit.JUnitResultArchiver>
+  </publishers>
+  <buildWrappers/>
+</matrix-project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/hudson/jboss/bin/http-spider.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jboss/bin/http-spider.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jboss/bin/http-spider.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+#############################################################
+#
+# Simple helper that checks if an HTTP host is available.
+# (Relies on wget)
+# 
+# Within hudson it can be used to test if the AS instance
+# has successfully booted.
+#
+# @author Heiko.Braun at jboss.com
+#
+# $Id: http-spider.sh 3680 2009-01-20 07:30:46Z thomas.diesler at jboss.com $
+#
+#############################################################
+
+TIMEOUT=2             # wget timeout in sec
+SLEEP_TIME=10		      # the actual sleep time in between test
+NUM_RETRIES=18 		    # equals 180 seconds before exit
+WGET="/usr/bin/wget"  # the default unix wget location
+
+
+if [ "x$1" = "x" -o "x$2" = "x" ]; then
+	echo "Usage: http-spider.sh <hostname:port> <output_dir>"		
+fi
+
+# cleanup
+rm $2/spider.success 2&>1 /dev/null
+rm $2/spider.failed 2&>1 /dev/null
+
+echo "Check HTTP connection on $1"
+
+COUNTER=0
+while [  $COUNTER -lt $NUM_RETRIES ]; do
+  if wget --spider --timeout=$TIMEOUT --tries=1 $1 &> /dev/null; then
+    touch $2/spider.success
+    echo "Try $COUNTER: '$1' is available"  > $2/spider.success
+    exit 0
+  else
+    echo "Try $COUNTER: '$1' does not respond, wait another $SLEEP_TIME seconds"
+  fi
+  sleep $SLEEP_TIME
+  let COUNTER=COUNTER+1
+done
+
+touch $2/spider.failed
+echo "Unable to connect to $1, exiting..." > $2/spider.failed
+exit 0
+
+

Added: jbpm4/branches/tbaeyens/hudson/jboss/bin/jboss.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jboss/bin/jboss.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jboss/bin/jboss.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+JBOSS_HOME="$1"
+BINDADDR="$3"
+CMD="$2"
+
+export JBOSS_HOME
+
+#
+# Helper to complain.
+#
+warn() {
+   echo "$PROGNAME: $*"
+}
+
+if [ ! -f "$JBOSS_HOME/bin/run.sh" ]; then
+   warn "Cannot find: $JBOSS_HOME/bin/run.sh"
+   exit 1
+fi
+
+case "$CMD" in
+start)
+    # This version of run.sh obtains the pid of the JVM and saves it as jboss.pid
+    # It relies on bash specific features
+    # Do you want to hide jboss output?
+    echo "Starting jboss w. bind address: $BINDADDR"
+    /bin/bash $DIRNAME/runjboss.sh -b $BINDADDR &
+    ;;
+stop)
+    pidfile="$JBOSS_HOME/bin/jboss.pid"
+    if [ -f "$pidfile" ]; then
+       pid=`cat "$pidfile"`
+       echo "kill pid: $pid"
+       kill $pid
+       if [ "$?" -eq 0 ]; then
+         # process exists, wait for it to die, and force if not
+         sleep 20
+         kill -9 $pid &> /dev/null
+       fi
+       rm "$pidfile"
+    else
+       warn "No pid found, using shutdown"
+       $JBOSS_HOME/bin/shutdown.sh -S > /dev/null &
+    fi
+    ;;
+restart)
+    $0 stop
+    $0 start
+    ;;
+*)
+    echo "usage: $0 jboss_instance (start|stop|restart|help)"
+esac

Added: jbpm4/branches/tbaeyens/hudson/jboss/bin/runjboss.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jboss/bin/runjboss.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jboss/bin/runjboss.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,184 @@
+#!/bin/bash
+### ====================================================================== ###
+##                                                                          ##
+##  JBoss Bootstrap Script                                                  ##
+##                                                                          ##
+### ====================================================================== ###
+
+### $Id: runjboss.sh 1435 2008-07-01 12:26:28Z thomas.diesler at jboss.com $ ###
+
+DIRNAME=`dirname $0`
+PROGNAME=`basename $0`
+GREP="grep"
+
+# Use the maximum available, or set MAX_FD != -1 to use that
+MAX_FD="maximum"
+
+#
+# Helper to complain.
+#
+warn() {
+    echo "${PROGNAME}: $*"
+}
+
+#
+# Helper to puke.
+#
+die() {
+    warn $*
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+darwin=false;
+linux=false;
+case "`uname`" in
+    CYGWIN*)
+        cygwin=true
+        ;;
+
+    Darwin*)
+        darwin=true
+        ;;
+
+    Linux)
+        linux=true
+        ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+    [ -n "$JBOSS_HOME" ] &&
+        JBOSS_HOME=`cygpath --unix "$JBOSS_HOME"`
+    [ -n "$JAVA_HOME" ] &&
+        JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+    [ -n "$JAVAC_JAR" ] &&
+        JAVAC_JAR=`cygpath --unix "$JAVAC_JAR"`
+fi
+
+# Setup JBOSS_HOME
+if [ "x$JBOSS_HOME" = "x" ]; then
+    # get the full path (without any relative bits)
+    JBOSS_HOME=`cd $DIRNAME/..; pwd`
+fi
+export JBOSS_HOME
+
+# Read an optional running configuration file
+if [ "x$RUN_CONF" = "x" ]; then
+    RUN_CONF="$JBOSS_HOME/bin/run.conf"
+fi
+if [ -r "$RUN_CONF" ]; then
+    . "$RUN_CONF"
+fi
+
+# Setup the JVM
+if [ "x$JAVA" = "x" ]; then
+    if [ "x$JAVA_HOME" != "x" ]; then
+	JAVA="$JAVA_HOME/bin/java"
+    else
+	JAVA="java"
+    fi
+fi
+
+# Setup the classpath
+runjar="$JBOSS_HOME/bin/run.jar"
+if [ ! -f "$runjar" ]; then
+    die "Missing required file: $runjar"
+fi
+JBOSS_BOOT_CLASSPATH="$runjar"
+
+# Tomcat uses the JDT Compiler
+# Only include tools.jar if someone wants to use the JDK instead.
+# compatible distribution which JAVA_HOME points to
+if [ "x$JAVAC_JAR" = "x" ]; then
+    JAVAC_JAR_FILE="$JAVA_HOME/lib/tools.jar"
+else
+    JAVAC_JAR_FILE="$JAVAC_JAR"
+fi
+if [ ! -f "$JAVAC_JAR_FILE" ]; then
+   # MacOSX does not have a seperate tools.jar
+   if [ "$darwin" != "true" -a "x$JAVAC_JAR" != "x" ]; then
+      warn "Missing file: JAVAC_JAR=$JAVAC_JAR"
+      warn "Unexpected results may occur."
+   fi
+   JAVAC_JAR_FILE=
+fi
+
+if [ "x$JBOSS_CLASSPATH" = "x" ]; then
+    JBOSS_CLASSPATH="$JBOSS_BOOT_CLASSPATH:$JAVAC_JAR"
+else
+    JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_BOOT_CLASSPATH:$JAVAC_JAR"
+fi
+
+# If -server not set in JAVA_OPTS, set it, if supported
+SERVER_SET=`echo $JAVA_OPTS | $GREP "\-server"`
+if [ "x$SERVER_SET" = "x" ]; then
+
+    # Check for SUN(tm) JVM w/ HotSpot support
+    if [ "x$HAS_HOTSPOT" = "x" ]; then
+	HAS_HOTSPOT=`"$JAVA" -version 2>&1 | $GREP -i HotSpot`
+    fi
+
+    # Enable -server if we have Hotspot, unless we can't
+    if [ "x$HAS_HOTSPOT" != "x" ]; then
+    JAVA_OPTS="-server $JAVA_OPTS"
+    fi
+fi
+
+# Setup JBosst Native library path
+JBOSS_NATIVE_DIR="$JBOSS_HOME/bin/native"
+if [ -d "$JBOSS_NATIVE_DIR" ]; then
+    if [ "x$LD_LIBRARY_PATH" = "x" ]; then
+        LD_LIBRARY_PATH="$JBOSS_NATIVE_DIR"
+    else
+        LD_LIBRARY_PATH="$JBOSS_NATIVE_DIR:$LD_LIBRARY_PATH"
+    fi
+    export LD_LIBRARY_PATH
+    if [ "x$JAVA_OPTS" = "x" ]; then
+        JAVA_OPTS="-Djava.library.path=$JBOSS_NATIVE_DIR"
+    else
+        JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$JBOSS_NATIVE_DIR"
+    fi
+fi
+
+#JPDA options. Uncomment and modify as appropriate to enable remote debugging .
+#JAVA_OPTS="-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n $JAVA_OPTS"
+
+# Setup JBoss sepecific properties
+JAVA_OPTS="-Dprogram.name=$PROGNAME $JAVA_OPTS"
+
+# Setup the java endorsed dirs
+JBOSS_ENDORSED_DIRS="$JBOSS_HOME/lib/endorsed"
+
+# Display our environment
+echo "========================================================================="
+echo ""
+echo "  JBoss Bootstrap Environment"
+echo ""
+echo "  JBOSS_HOME: $JBOSS_HOME"
+echo ""
+echo "  JAVA: $JAVA"
+echo ""
+echo "  JAVA_OPTS: $JAVA_OPTS"
+echo ""
+echo "  CLASSPATH: $JBOSS_CLASSPATH"
+echo ""
+echo "========================================================================="
+echo ""
+# enable monitor mode (job control needed)
+set -m
+STATUS=10
+while [ $STATUS -eq 10 ]
+do
+# Execute the JVM
+   "$JAVA" $JAVA_OPTS \
+      -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
+      -classpath "$JBOSS_CLASSPATH" \
+      org.jboss.Main "$@" &> /dev/null &
+      echo $! > $JBOSS_HOME/bin/jboss.pid
+      fg
+   STATUS=$?
+   # if it doesn't work, you may want to take a look at this:
+   #    http://developer.java.sun.com/developer/bugParade/bugs/4465334.html
+done

Added: jbpm4/branches/tbaeyens/hudson/jbpm4-base.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jbpm4-base.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jbpm4-base.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container 
+#
+# $Id: jbpm4-base.sh 3842 2009-02-11 21:16:41Z heiko.braun at jboss.com $
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+DISTRODIR=$JBPMDIR/modules/distro/target
+
+#
+# default environment settings
+#
+if [ ! -f $JBPMDIR/profiles.xml ]; then
+  echo "WARN: $JBPMDIR/profiles.xml is missing!"
+  exit 1
+fi
+
+#
+# build the tests
+#
+cd $JBPMDIR
+MVN_CMD="mvn -U -DskipTests clean install"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+  echo maven exit status $MVN_STATUS
+  exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute tests
+#
+MVN_CMD="mvn -o -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.log
+cat $WORKSPACE/tests.log | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt

Added: jbpm4/branches/tbaeyens/hudson/jbpm4-db.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jbpm4-db.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jbpm4-db.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container 
+#
+# $Id: jbpm4-db.sh 3842 2009-02-11 21:16:41Z heiko.braun at jboss.com $
+
+set -x
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+
+#
+# default environment settings
+#
+if [ ! -f $JBPMDIR/profiles.xml ]; then
+  echo "WARN: $JBPMDIR/profiles.xml is missing!"
+  exit 1
+fi
+
+#
+# build the tests
+#
+cd $JBPMDIR
+MVN_CMD="mvn -U -DskipTests clean install"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+  echo maven exit status $MVN_STATUS
+  exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute example tests
+#
+cd $JBPMDIR/modules/examples
+MVN_CMD="mvn -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.examples.log
+
+#
+# execute database tests
+#
+cd $JBPMDIR/modules/test-db
+MVN_CMD="mvn -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.test-db.log
+
+cat $WORKSPACE/tests.examples.log $WORKSPACE/tests.test-db.log  | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt

Added: jbpm4/branches/tbaeyens/hudson/jbpm4-load.sh
===================================================================
--- jbpm4/branches/tbaeyens/hudson/jbpm4-load.sh	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/jbpm4-load.sh	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container 
+#
+# $Id: jbpm4-load.sh 3842 2009-02-11 21:16:41Z heiko.braun at jboss.com $
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+DISTRODIR=$JBPMDIR/modules/distro/target
+
+#
+# default environment settings
+#
+if [ ! -f $JBPMDIR/profiles.xml ]; then
+  echo "WARN: $JBPMDIR/profiles.xml is missing!"
+  exit 1
+fi
+
+#
+# build the tests
+#
+cd $JBPMDIR
+MVN_CMD="mvn -U -DskipTests clean install"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+  echo maven exit status $MVN_STATUS
+  exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute tests
+#
+cd modules/test-load
+MVN_CMD="mvn -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.log
+cat $WORKSPACE/tests.log | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt

Added: jbpm4/branches/tbaeyens/hudson/profiles.xml.local.qa
===================================================================
--- jbpm4/branches/tbaeyens/hudson/profiles.xml.local.qa	                        (rev 0)
+++ jbpm4/branches/tbaeyens/hudson/profiles.xml.local.qa	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+<profilesXml 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/xsd/profiles-1.0.0.xsd">
+
+  <profiles>
+
+    <!-- This profile can also be defined in ~/.m2/settings.xml -->
+
+    <profile>
+      <id>jboss-home-profile</id>
+      <activation>
+        <property>
+          <name>user.name</name>
+        </property>
+      </activation>
+      <properties>
+
+        <!--
+           JBOSS_HOME FOR INTEGRATION TESTS
+        -->
+
+        <jboss422.home>/Users/hbraun/dev/prj/jboss/tags/JBoss_4_2_2_GA/build/output/jboss-4.2.2.GA</jboss422.home>
+        <jboss423.home>/Users/hbraun/dev/prj/jboss/tags/JBoss_4_2_3_GA/build/output/jboss-4.2.3.GA</jboss423.home>
+        <jboss500.home>/Users/hbraun/dev/prj/jboss/tags/JBoss_5_0_0_GA/build/output/jboss-5.0.0.GA</jboss500.home>
+
+        <!--
+          DEFAULT CONNECTION SETTINGS FOR THE JBPM QA ENV
+        -->
+
+        <jdbc.mysql.server>localhost</jdbc.mysql.server>
+        <jdbc.mysql.port>3306</jdbc.mysql.port>
+        <jdbc.mysql.database>jbpm4</jdbc.mysql.database>
+        <jdbc.mysql.url>jdbc:mysql://${jdbc.mysql.server}:${jdbc.mysql.port}/${jdbc.mysql.database}</jdbc.mysql.url>
+        <jdbc.mysql.username>jbpmtest</jdbc.mysql.username>
+        <jdbc.mysql.password></jdbc.mysql.password>
+
+        <jdbc.postgresql.server>localhost</jdbc.postgresql.server>
+        <jdbc.postgresql.port>5432</jdbc.postgresql.port>
+        <jdbc.postgresql.database>jbpm4</jdbc.postgresql.database>
+        <jdbc.postgresql.url>jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/${jdbc.postgresql.database}</jdbc.postgresql.url>
+        <jdbc.postgresql.username>jbpmtest</jdbc.postgresql.username>
+        <jdbc.postgresql.password></jdbc.postgresql.password>
+
+        <jdbc.sybase.server>localhost</jdbc.sybase.server>
+        <jdbc.sybase.port>5000</jdbc.sybase.port>
+        <jdbc.sybase.database>jbpm4</jdbc.sybase.database>
+        <jdbc.sybase.url>jdbc:sybase:Tds:${jdbc.sybase.server}:${jdbc.sybase.port}/${jdbc.sybase.database}</jdbc.sybase.url>
+        <jdbc.sybase.username>jbpmtest</jdbc.sybase.username>
+        <jdbc.sybase.password>jbpmtest</jdbc.sybase.password>
+        <jdbc.sybase.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.sybase.driver>
+        <jdbc.sybase.datasource>com.sybase.jdbc3.jdbc.SybXADataSource</jdbc.sybase.datasource>
+
+        <jdbc.oracle.server>localhost</jdbc.oracle.server>
+        <jdbc.oracle.port>1521</jdbc.oracle.port>
+        <jdbc.oracle.database>XE</jdbc.oracle.database>
+        <jdbc.oracle.username>jbpmtest</jdbc.oracle.username>
+        <jdbc.oracle.password>jbpmtest</jdbc.oracle.password>
+        <jdbc.oracle.url>jdbc:oracle:thin:${jdbc.oracle.username}/${jdbc.oracle.password}@${jdbc.oracle.server}:${jdbc.oracle.port}:${jdbc.oracle.database}</jdbc.oracle.url>
+                                 
+      </properties>
+    </profile>
+
+  </profiles>
+
+</profilesXml>

Added: jbpm4/branches/tbaeyens/modules/api/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+  <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/api/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>api</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/api/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3182 2008-12-03 13:48:29Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - API</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-api</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Properties -->
+  <properties>
+  </properties>
+  
+  <!-- DependencyManagement -->
+  <dependencyManagement>
+    <dependencies>
+    </dependencies>
+  </dependencyManagement>
+  
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-j2ee</artifactId>
+    </dependency>
+  </dependencies>
+  
+  <!-- Plugins -->
+  <build>
+    <plugins>
+    </plugins>
+  </build>
+  
+  <!-- Reporting -->
+  <reporting>
+    <plugins>
+    </plugins>
+  </reporting>
+
+  <profiles>
+    <profile>
+      <id>distro</id>
+      <properties>
+        <xsddocs>true</xsddocs>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>package</phase>
+                <goals>
+                  <goal>javadoc</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <show>public</show>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>xsddocs</id>
+      <activation>
+        <os>
+          <family>Windows</family>
+        </os>
+        <property>
+          <name>xsddocs</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>generate-schemadocs</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <tasks>
+                    <echo message="basedir: ${basedir}" />
+                    <mkdir dir="target/schemadocs" />
+                    <taskdef name="xsddoc" classname="net.sf.xframe.xsddoc.Task" classpathref="maven.plugin.classpath" />
+                    <xsddoc out="${basedir}/target/schemadocs" title="jBPM 4 Schema's" verbose="false">
+                      <fileset dir="src/main/resources" />
+                    </xsddoc>
+                  </tasks>
+                </configuration>
+              </execution>
+            </executions>
+            <dependencies>
+              <dependency>
+                <groupId>xsddoc</groupId>
+                <artifactId>xsddoc</artifactId>
+                <version>1.0</version>
+              </dependency>
+              <dependency>
+                <groupId>xalan</groupId>
+                <artifactId>xalan</artifactId>
+                <version>2.7.0</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Configuration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Configuration.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Configuration.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.xml.sax.InputSource;
+
+/**
+ * process engine configuration.
+ *         
+ * @author Tom Baeyens
+ */
+public class Configuration {
+  
+  static Map<String, String> implementationClassNames = null;
+
+  Configuration impl;
+ 
+  public Configuration() {
+    this((String)null);
+  }
+
+  public Configuration(String type) {
+    String implementationClassName = getImplementationClassName(type);
+    if (implementationClassName==null) {
+      throw new JbpmException("type is null");
+    }
+    impl = instantiate(implementationClassName);
+  }
+  
+  protected Configuration(Configuration base){
+  }
+  
+  private synchronized String getImplementationClassName(String type) {
+    if (implementationClassNames==null) {
+      implementationClassNames = new HashMap<String, String>();
+      // null represents the default configuration (== the JbpmConfiguration)
+      implementationClassNames.put(null, "org.jbpm.pvm.internal.cfg.JbpmConfiguration");
+      // TODO 
+      // implementationClasses.put("spring", "org.jbpm.pvm.internal.cfg.SpringConfiguration");
+      // implementationClasses.put("mc", "org.jbpm.pvm.internal.cfg.McConfiguration");
+      // implementationClasses.put("programatic", "org.jbpm.pvm.internal.cfg.ProgramaticConfiguration");
+    }
+    String implementationClassName = implementationClassNames.get(type);
+    if (implementationClassName==null) {
+      implementationClassName = type;
+    }
+    return implementationClassName;
+  }
+
+  protected Configuration instantiate(String className) {
+    ClassLoader classLoader = getClassLoader();
+    Configuration implementation;
+    try {
+      Class<?> implementationClass = classLoader.loadClass(className);
+      implementation = (Configuration) implementationClass.newInstance();
+    } catch (Exception e) {
+      throw new JbpmException("couldn't instantiate configuration of type "+className, e);
+    }
+    return implementation;
+  }
+
+  protected ClassLoader getClassLoader() {
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  public Configuration setXmlString(String xmlString) {
+    impl.setXmlString(xmlString);
+    return impl;
+  }
+
+  public Configuration setResource(String resource) {
+    impl.setResource(resource);
+    return impl;
+  }
+
+  public Configuration setInputStream(InputStream inputStream) {
+    impl.setInputStream(inputStream);
+    return impl;
+  }
+
+  public Configuration setInputSource(InputSource inputSource) {
+    impl.setInputSource(inputSource);
+    return impl;
+  }
+
+  public Configuration setUrl(URL url) {
+    impl.setUrl(url);
+    return impl;
+  }
+
+  public Configuration setFile(File file) {
+    impl.setFile(file);
+    return impl;
+  }
+
+  public ProcessEngine buildProcessEngine() {
+    return impl.buildProcessEngine();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Deployment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Deployment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Deployment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.List;
+import java.util.zip.ZipInputStream;
+
+
+/** a deployment unit, containing all information in source format from which 
+ * a process definition will be created and stored in the process repository.
+ *  
+ * <p>A deployment takes a bunch of files as input.  Files must have a name 
+ * and optionally they can have a type.  During deployment, the type can be 
+ * deducted from the filename automatically.  Use the <code>addXxxx</code>-methods
+ * to add files to the deployment.  Use {@link #setFileType(String, String)} to 
+ * set the file type programmatically.
+ * </p>
+ * 
+ * <p>The deployment also manages a map of objects.  The deployers will typically 
+ * generate those objects based on the corresponding file contents.  E.g. the
+ * jpdl deployer will produce a  <code>order.jpdl.xml</code> 
+ * {@link ProcessDefinition}-object from the <code>order.jpdl.xml</code> file.
+ * </p>
+ * 
+ * <p>Typically, a deployer will save the created objects into the database.
+ * </p>
+ * 
+ * <p>Users can also supply objects programmatically with {@link #addObject(String, Object)}. 
+ * </p>
+ * 
+ * @author Tom Baeyens
+ */
+public interface Deployment extends Serializable {
+  
+  Deployment setName(String name);
+
+  Deployment addResource(String resource);
+  Deployment addFile(File file);
+  Deployment addUrl(URL url);
+  Deployment addInputStream(String name, InputStream inputStream);
+  Deployment addString(String name, String string);
+  Deployment addArchiveResource(String resource);
+  Deployment addArchiveFile(File file);
+  Deployment addArchiveUrl(URL url);
+  Deployment addArchive(ZipInputStream zipInputStream);
+  Deployment addDirectory(String directory);
+  Deployment addDirectoryCanonical(String directory);
+  Deployment addDirectory(File directory);
+  Deployment addDirectoryCanonical(File directory);
+  Deployment addObject(String name, Object object);
+  
+  Deployment setFileType(String fileName, String fileType);
+
+  Deployment deploy();
+
+  /** the deployed process definitions. */
+  List<ProcessDefinition> getProcessDefinitions();
+  /** the problems encountered during deployment */
+  List<Problem> getProblems(); 
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Execution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Execution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Execution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.io.Serializable;
+
+/** a runtime path of execution.
+ * 
+ * <h3 id="state">State of an execution</h3>
+ * 
+ * <p>The state of an execution is either active or locked.  An active execution is either 
+ * executing or waiting for an external trigger.  If an execution is not in {@link #STATE_ACTIVE},
+ * then it is locked.  A locked execution is read only.  
+ * </p>
+ * 
+ * <p>When a new execution is created, it is in {@link #STATE_ACTIVE}.  To change 
+ * the state to a locked state, use {@link #lock(String)}.  
+ * {@link #STATE_ACTIVE Some STATE_* constants} are provided that represent the 
+ * most commonly used locked states.  But the state '...' in the picture indicates 
+ * that any string can be provided as the state in the lock method.
+ * </p>
+ * 
+ * <p>If an execution is locked, methods that change the execution will throw
+ * a {@link JbpmException} and the message will reference the actual locking state.
+ * {@link #fire(String, ObservableElement) Firing events}, 
+ * {@link #setVariable(String, Object) updating variables}, 
+ * {@link #setPriority(int) updating priority} and 
+ * {@link #createComment(String) adding comments} are not considered to change an 
+ * execution.  Also {@link #createProcessInstance(String) creation} and 
+ * {@link #removeExecution(Execution) removal} of child executions are unchecked, 
+ * which means that those methods can be invoked by external API clients and 
+ * activity behaviour methods, even while the execution is in a locked state. 
+ * </p>    
+ * 
+ * <p>Make sure that comparisons between {@link #getState()} and the 
+ * {@link #STATE_ACTIVE STATE_* constants} are  
+ * done with .equals and not with '==' because if executions are 
+ * loaded from persistent storage, a new string is created instead 
+ * of the constants.
+ * </p>
+ * 
+ * <h3>Comments</h3>
+ * 
+ * @author Tom Baeyens
+ */
+public interface Execution extends Serializable {
+
+  /** between {@link ClientProcessDefinition#createProcessInstance() creation of 
+   * a new process instance} and the {@link ClientExecution#start() start} of that 
+   * process instance.  The motivation of this state is that variables can be 
+   * set programmatically on the process instance so that they can be used during 
+   * initializations of variables and timers */
+  String STATE_CREATED = "created";
+  
+  /** either executing or in a wait state waiting for a signal.
+   * This is the normal state of an execution and the initial state 
+   * when creating a new execution. Make sure that comparisons are 
+   * done with .equals and not with '==' because if executions are 
+   * loaded from persistent storage, a new string is created instead 
+   * of the constants. */
+  String STATE_ACTIVE = "active";
+  
+  /** parents with concurrent child executions are inactive.  
+   * When an execution has concurrent child executions, it implies that 
+   * this execution can't be active.  For example, at a fork, the parent
+   * execution can wait inactively in the fork being till all the
+   * child executions are joined.  Only leaves of the
+   * execution tree can be active. Make sure that comparisons are 
+   * done with .equals and not with '==' because if executions are 
+   * loaded from persistent storage, a new string is created instead 
+   * of the constants. */
+  String STATE_INACTIVE = "inactive";
+  
+  /** this execution has ended. Make sure that comparisons are 
+   * done with .equals and not with '==' because if executions are 
+   * loaded from persistent storage, a new string is created instead 
+   * of the constants. */
+  String STATE_ENDED = "ended";
+  
+  /** indicates that this execution is temporary suspended with the
+   * {@link #suspend()} method.  Human tasks of a suspended execution
+   * shouldn't show up in people's task list and timers of suspended
+   * executions shouldn't fire and the execution is locked. Make sure that comparisons are 
+   * done with .equals and not with '==' because if executions are 
+   * loaded from persistent storage, a new string is created instead 
+   * of the constants. */
+  String STATE_SUSPENDED = "suspended";
+  
+  /** indicates that this execution is doing an asynchronous continuation. */
+  String STATE_ASYNC = "async";
+
+  /** this execution has been cancelled before it came to completion.
+   * Only history executions might expose this state.  This state can be 
+   * passed in {@link ExecutionService#endProcessInstance(String, String)}.
+   * Make sure that comparisons are 
+   * done with .equals and not with '==' because if executions are 
+   * loaded from persistent storage, a new string is created instead 
+   * of the constants. */
+  String STATE_CANCELLED = "cancelled";
+
+
+  long getDbid();
+  /** the externally given name or id of this execution. The id of a main 
+   * path of execution is null.   Can be used to differentiate concurrent 
+   * paths of execution e.g. the shipping and billing paths.  */
+  String getName();
+
+  /** the optional user provided business key that is unique within one 
+   * process definition.  This could be for instance the order number.  
+   * It's a user defined identifier for one execution within the scope of 
+   * a single process definition. */
+  String getKey();
+  
+  /** a globally unique identifier for this execution. */
+  String getId();
+  
+  /** represents the current position in the process by indicating the 
+   * name of the current activity. */
+  String getActivityName();
+
+  /** the <a href="#state">state</a> of this execution.  */
+  String getState();
+
+  /** is this a process instance */
+  boolean isProcessInstance();
+
+  /** is this execution active ? This is the inverse of {@link #isLocked()}. */
+  boolean isActive();
+
+  /** is this execution {@link #lock(String) locked} ? This is the inverse of {@link #isActive()}. */
+  boolean isLocked();
+
+  /** is this execution ended */
+  boolean isEnded();
+
+  /** is this execution suspended ? */
+  boolean isSuspended();
+
+  /** indicates low priorities with negative values and high priorities 
+   * with positive values.  The default priority is 0, which means 
+   * NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), 
+   * LOW (-1) and LOWEST (-2). For the rest, the user can set any other 
+   * priority integer value, but then, the UI will have to display it as 
+   * an integer and not the named value.*/
+  int getPriority();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ExecutionQuery {
+  
+  String PROPERTY_KEY = "key";
+  
+  ExecutionQuery processDefinitionNameLike(String processDefinitionName);
+  ExecutionQuery processDefinitionKeyLike(String processDefinitionKey);
+  ExecutionQuery processDefinitionId(String processDefinitionId);
+
+  ExecutionQuery processInstanceId(String processInstanceId);
+
+  ExecutionQuery orderAsc(String property);
+  ExecutionQuery orderDesc(String property);
+
+  ExecutionQuery page(int firstResult, int maxResults);
+
+  List<Execution> execute();
+  Execution executeUniqueResult();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+/** manages runtime process executions.
+ *
+ * @author Tom Baeyens
+ */
+public interface ExecutionService {
+
+  /** starts a new process instance for the ProcessDefinition with the given processDefinitionDbid.
+   * @param processDefinitionId the {@link ProcessDefinition#getId() unique id} of the process definition. */
+  Execution startProcessInstanceById(String processDefinitionId);
+
+  /** starts a new process instance for the ProcessDefinition with the given processDefinitionDbid. 
+   * @param processDefinitionId the {@link ProcessDefinition#getId() unique id} of the process definition.
+   * @param executionKey is a user provided reference for the new execution that must be unique over all 
+   *    process versions with the same name. */
+  Execution startProcessInstanceById(String processDefinitionId, String executionKey);
+
+  /** starts a new process instance for the ProcessDefinition with the given processDefinitionDbid. 
+   * @param processDefinitionId the {@link ProcessDefinition#getId() unique id} of the process definition.
+   * @param variables are the initial values of the process variables that will be set before the execution starts. */
+  Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables);
+
+  /** starts a new process instance for the ProcessDefinition with the given processDefinitionDbid.
+   * @param processDefinitionId the {@link ProcessDefinition#getId() unique id} of the process definition.
+   * @param variables are the initial values of the process variables that will be set before the execution starts.
+   * @param executionKey is a user provided reference for the new execution that must be unique over all 
+   *    process versions with the same name. */
+  Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables, String executionKey);
+
+  /** starts a new process instance in the latest version of the given process definition.
+   * @param processDefinitionKey is the key of the process definition for which the latest version will be taken. */
+  Execution startProcessInstanceByKey(String processDefinitionKey);
+
+  /** starts a new process instance in the latest version of the given processDefinitionName.
+   * @param processDefinitionKey is the key of the process definition
+   *   for which the latest version will be taken.
+   * @param executionKey is a user provided reference for the new execution
+   *   that must be unique over all process versions with the same name. */
+  Execution startProcessInstanceByKey(String processDefinitionKey, String executionKey);
+
+  /** starts a new process instance in the latest version of the given processDefinitionName.
+   * @param processDefinitionKey is the key of the process definition
+   *   for which the latest version will be taken.
+   * @param variables are the initial values of the process variables that
+   *   will be set before the execution starts (read: before the initial
+   *   activity is executed). */
+  Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables);
+
+  /** starts a new process instance in the latest version of the given processDefinitionName.
+   * @param processDefinitionKey is the key of the process definition for which the latest version will be taken.
+   * @param variables are the initial values of the process variables that will be set before the execution starts.
+   * @param executionKey is a user provided reference for the new execution that must be unique over all
+   *    process versions with the same name. */
+  Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String executionKey);
+
+  /** the execution that is uniquely defined by the process definition and the business key. */
+  Execution findExecution(String processDefinitionName, String executionKey);
+
+  /** the execution that is uniquely defined by the process definition and the business key. */
+  Execution findExecution(String executionId);
+
+  /** this method returns this execution and all its child executions recursively. */
+  List<Execution> findExecutions(String executionId);
+
+  /** provides an external trigger to an execution. */
+  Execution signalExecutionById(String executionId);
+
+  /** provides a named external trigger to an execution. */
+  Execution signalExecutionById(String executionId, String signalName);
+
+  /** provides a named external trigger to an execution with parameters. */
+  Execution signalExecutionById(String executionId, String signalName, Map<String, Object> parameters);
+
+  /** provides a external trigger to an execution with parameters. */
+  Execution signalExecutionById(String executionId, Map<String, Object> parameters);
+
+
+  /** provides a named external trigger to an execution. */
+  Execution signalExecutionByKey(String processDefinitionKey, String executionKey);
+
+  /** provides a named external trigger to an execution. */
+  Execution signalExecutionByKey(String processDefinitionKey, String executionKey, String signalName);
+
+  /** provides a named external trigger to an execution with parameters. */
+  Execution signalExecutionByKey(String processDefinitionKey, String executionKey, Map<String, Object> parameters);
+
+  /** provides a named external trigger to an execution with parameters. */
+  Execution signalExecutionByKey(String processDefinitionKey, String executionKey, String signalName, Map<String, Object> parameters);
+
+  /** search for executions with criteria */
+  ExecutionQuery createExecutionQuery();
+
+  /** search for process instances with criteria */
+  ExecutionQuery createProcessInstanceQuery();
+
+  /** creates or overwrites a variable value on the referenced execution */
+  Execution setVariable(String executionId, String name, Object value);
+
+  /** creates or overwrites the variable values on the referenced execution */
+  Execution setVariables(String executionId, Map<String, Object> variables);
+
+  /** retrieves a variable */
+  Object getVariable(String executionId, String variableName);
+
+  /** all the variables visible in the given execution scope */
+  Set<String> getVariableNames(String executionId);
+
+  /** retrieves a map of variables */
+  Map<String, Object> getVariables(String executionId, Set<String> variableNames);
+  
+  /** end a process instance */
+  void endProcessInstance(String processInstanceId, String state);
+
+  /** delete a process instance */
+  void deleteProcessInstance(String processInstanceId);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/HistoryService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/HistoryService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/HistoryService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.Map;
+
+import org.jbpm.history.HistoryActivityInstanceQuery;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryService {
+
+  /** search for process instances in the history */
+  HistoryProcessInstanceQuery createHistoryProcessInstanceQuery();
+
+  /** search in history activity instance information for a given processDefinition */ 
+  HistoryActivityInstanceQuery createHistoryActivityInstanceQuery(String processDefinitionId);
+
+  /** returns the average duration in milliseconds for each activity in the given process definition */
+  Map<String, Long> avgDurationPerActivity(String processDefinitionId);
+  
+  /** returns for each transitionName, the number of times that transition was taken */
+  Map<String, Integer> choiceDistribution(String processDefinitionId, String activityName);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/IdentityService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/IdentityService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/IdentityService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface IdentityService {
+  
+  void createUser(String userName, String givenName, String familyName);
+  void deleteUser(String userName);
+
+  void createGroup(String groupName, String groupType);
+  void createGroup(String groupName, String groupType, String parentgroupName);
+
+  void createMembership(String userName, String groupName, String groupType, String role);
+
+  List<User> getUsers();
+
+  List<Group> getGroups();
+  
+  List<Group> findGroupsByUserAndGroupType(String userName, String groupType);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JbpmException.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JbpmException.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JbpmException.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+public class JbpmException extends RuntimeException {
+
+  private static final long serialVersionUID = 1L;
+
+  public JbpmException() {
+    super();
+  }
+  public JbpmException(String msg, Throwable cause) {
+    super(msg);
+    super.initCause(cause);
+  }
+  public JbpmException(String msg) {
+    super(msg);
+  }
+  public JbpmException(Throwable cause) {
+    super();
+    super.initCause(cause);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JobQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JobQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/JobQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+import org.jbpm.job.Job;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface JobQuery {
+
+  JobQuery messages();
+  JobQuery timers();
+  
+  JobQuery processInstanceId(String processInstanceId);
+  
+  JobQuery exception();
+
+  JobQuery orderAsc(String property);
+  JobQuery orderDesc(String property);
+
+  JobQuery page(int firstResult, int maxResults);
+
+  List<Job> execute();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ManagementService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ManagementService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ManagementService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+
+
+/** operations targeted to system operators that need to keep 
+ * the process engine up and running.  This functionality is typically 
+ * exposed through a management web console. 
+ * 
+ * @author Tom Baeyens
+ */
+public interface ManagementService {
+
+  /** resets the retry count, clears the exception and executes the job. 
+   * An exception is thrown out of this method in case the execution 
+   * of the job fails.  In case the async command executor is configured 
+   * for this service, failing job execution will not result into an 
+   * exception coming out of this method. */
+  void executeJob(long jobDbid);
+
+  /** search for jobs */
+  JobQuery createJobQuery();
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Problem.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Problem.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/Problem.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Problem {
+
+  public abstract Throwable getCause();
+
+  public abstract int getColumn();
+
+  public abstract int getLine();
+
+  public abstract String getMsg();
+
+  public abstract String getResource();
+
+  public abstract String getSeverity();
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.io.Serializable;
+
+
+/** a graphical process which is deployed in the {@ ProcessService}.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ProcessDefinition extends Serializable {
+
+  /** the optional package name of this process.  This can be used to create 
+   * hierarchy of process categories for easy lookup.   This is a 
+   * similar way of grouping and creating a structure as in Java. 
+   * We recommend the same conventions as with Java package names. */
+  String getPackageName();
+
+  /** the short display name given to this process definition. 
+   * Multiple process definitions can have the same as long 
+   * as they are given a different {@link #version}.  */
+  String getName();
+
+  /** the user defined short representation of the name. Just 
+   * like the name, multiple versions of a process definition 
+   * can have the same key. */
+  String getKey();
+
+  /** the unique id for this process definition. */
+  String getId();
+
+  /** automatically assigned during deployment of a process that 
+   * represents the sequence number for process definitions with 
+   * the same {@link ObservableElement#getName() name}. */ 
+  int getVersion();
+
+  /** the description name given to this process definition. 
+   * Multiple process definitions can have the same */
+  String getDescription();
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ProcessDefinitionQuery {
+
+  String PROPERTY_NAME = "name";
+  String PROPERTY_KEY = "key";
+  String PROPERTY_PACKAGENAME = "packageName";
+  String PROPERTY_VERSION = "version";
+  String PROPERTY_DEPLOYMENTTIME = "deploymentTime";
+
+  ProcessDefinitionQuery nameLike(String name);
+  ProcessDefinitionQuery keyLike(String key);
+
+  ProcessDefinitionQuery orderAsc(String property);
+  ProcessDefinitionQuery orderDesc(String property);
+  
+  List<ProcessDefinition> execute();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessEngine.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessEngine.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessEngine.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.Map;
+
+/** central starting point for all process engine API
+ * interactions. 
+ * 
+ * @author Tom Baeyens
+ */
+public interface ProcessEngine {
+
+  /** the {@link ProcessService process service} that provides access
+   * to the process repository. */ 
+  ProcessService getProcessService();
+
+  /** the {@link ProcessService process service} and supply some 
+   * transactional resources.  The given transactional resources will only 
+   * be associated to the returned process service.  */ 
+  ProcessService getProcessService(Map<String, Object> txResources);
+
+  /** the {@link ExecutionService execution service} that provides access
+   * to the runtime executions repository. */ 
+  ExecutionService getExecutionService();
+
+  /** the {@link ExecutionService execution service} and supply some 
+   * transactional resources.  The given transactional resources will only 
+   * be associated to the returned execution service.  */ 
+  ExecutionService getExecutionService(Map<String, Object> txResources);
+
+  /** the {@link HistoryService history service} that provides access
+   * to the history executions repository. */ 
+  HistoryService getHistoryService();
+
+  /** the {@link HistoryService history service} that provides access
+   * to the history executions repository. The given transactional resources will only 
+   * be associated to the returned history service.  */ 
+  HistoryService getHistoryService(Map<String, Object> txResources);
+
+  /** the {@link TaskService task service} that exposes the 
+   * runtime human task lists. */ 
+  TaskService getTaskService();
+
+  /** the {@link TaskService task service} and supply some 
+   * transactional resources.  The given transactional resources will only 
+   * be associated to the returned task service.  */ 
+  TaskService getTaskService(Map<String, Object> txResources);
+
+  /** the {@link ManagementService management service} that exposes the 
+   * management operations to operators that have to keep the jBPM system 
+   * up and running. */ 
+  ManagementService getManagementService();
+
+  /** the {@link ManagementService management service} and supply some 
+   * transactional resources.  The given transactional resources will only 
+   * be associated to the returned management service. */ 
+  ManagementService getManagementService(Map<String, Object> txResources);
+
+  /** retrieve and object defined in the process engine by type */
+  <T> T get(Class<T> type);
+
+  /** retrieve and object defined in the process engine by name */
+  Object get(String name);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+
+/** a process definition repository.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ProcessService {
+  
+  /** start a deployment */
+  Deployment createDeployment();
+
+  /** all deployed process definition keys. */
+  List<String> findProcessDefinitionKeys();
+
+  /** all versions of the given process. 
+   * @return the process definitions in descending version order.  So you get the 
+   * highest version number as the first. */
+  List<ProcessDefinition> findProcessDefinitionsByKey(String processDefinitionKey);
+
+  /** latest version of the processDefinition with the given key. */
+  ProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
+
+  /** specific version of a named processDefinition. */
+  ProcessDefinition findProcessDefinitionById(String processDefinitionId);
+  
+  /** search for process definitions */
+  ProcessDefinitionQuery createProcessDefinitionQuery();
+
+  /** deletes process definition if there are no existing executions. 
+   * @throws JbpmException if there are existing executions or history. */
+  void deleteProcessDefinition(String processDefinitionId);
+
+  /** deletes process definition, the existing executions and the history. */
+  void deleteProcessDefinitionCascade(String processDefinitionId);
+  
+  /** retrieves an attachment of a process definition */
+  byte[] getAttachment(String processDefinitionId, String name);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TaskQuery {
+  
+  public static final String PROPERTY_NAME = "name";
+  public static final String PROPERTY_ASSIGNEE = "assignee";
+  public static final String PROPERTY_CREATEDATE = "create";
+  public static final String PROPERTY_DUEDATE = "dueDate";
+  public static final String PROPERTY_PRIORITY = "priority";
+  public static final String PROPERTY_PROGRESS = "progress";
+
+  TaskQuery assignee(String assignee);
+  
+  TaskQuery page(int firstResult, int maxResults);
+  TaskQuery orderAsc(String property);
+  TaskQuery orderDesc(String property);
+  
+  List<Task> execute();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/TaskService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm;
+
+import java.util.List;
+
+import org.jbpm.model.Comment;
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+import org.jbpm.task.UserRef;
+
+/**
+ * Human task management facility.
+ * @author Alejandro Guizar
+ */
+public interface TaskService {
+
+  /** Creates a task.
+   * The returned task will be transient.
+   * Use {@link #saveTask(Task)} to persist the task. Only 
+   * after the invocation of {@link #saveTask(Task)}, the 
+   * {@link Task#getDbid()} property will be initialized. */
+  Task newTask();
+
+  /** Creates a new subtask for the given task.
+   * Make sure that the parent task is saved before the 
+   * {@link Task#getDbid() dbid} is taken.
+   * The returned task will be transient.
+   * Use {@link #saveTask(Task)} to persist the task. */
+  Task newTask(long parentTaskDbid);
+
+  /** Saves the given task to persistent storage. */
+  void saveTask(Task task);
+
+  /** Retrieves the task with the given identifier from persistent storage. 
+   * If no task with the given identifier exists, 
+   * the call returns <code>null</code>. */
+  Task getTask(long taskDbid);
+
+  /** Marks the task with the given identifier as completed.
+   * This operation may result in a process instance being resumed. */
+  void submitTask(long taskDbid);
+
+  /** Removes the task with the given identifier from persistent storage. */
+  void deleteTask(long taskDbid);
+  
+  
+
+  /** add a role to a given task.
+   * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}  
+   * @param participation specifies the kind of involvement of the participant 
+   * in this task. see {@link Participant} for default constants. */
+  void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+
+    
+  /** get roles related to a given task. */
+  List<Participant> getTaskParticipants(long taskDbid);
+  
+  /** removes a role to a given task.  Nothing happens (no exception) if 
+   * the role does not exist.
+   * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}  
+   * @param participation specifies the kind of involvement of the participant 
+   * in this task. see {@link Participant} for default constants. */
+  void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+  
+  /** add a role from a given swimlane.
+   * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}  
+   * @param participation specifies the kind of involvement of the participant 
+   * in this swimlane. see {@link Participant} for default constants. */
+  void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation);
+
+  /** get roles related to a given swimlane. */
+  List<Participant> getSwimlaneParticipants(long szimlaneDbid);
+
+  /** remove a role from a given swimlane.
+   * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}  
+   * @param participation specifies the kind of involvement of the participant 
+   * in this swimlane. see {@link Participant} for default constants. */
+  void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation);
+
+
+  TaskQuery createTaskQuery();
+
+  /** retrieves the personal task of the given user, which might be different 
+   * then the current authenticated user.  E.g. when a manager wants to 
+   * look at a subordinate's task list. */
+  List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults);
+
+  /** retrieves the group task of the given user.
+   * The user id will be resolved to a set of candidate identities
+   * by the identity spi. */
+  List<Task> getGroupTaskList(String userId, int firstResult, int maxResults);
+
+  /** get the subtasks for this task.  Only goes one level deep at a time. */
+  List<Task> getSubTasks(long taskDbid);
+
+  /** add a comment to a task */
+  Comment addTaskComment(long taskDbid, String message);
+
+  /** get the list of comments made to a task.  this will 
+   * fetch all the comments and recursively all replies to those 
+   * comments. */
+  List<Comment> getTaskComments(long taskDbid);
+
+  /** add a reply to another comment */
+  Comment addReplyComment(long commentDbid, String message);
+
+  /** delete a comment.
+   * this will recursively delete all replies to this comment. */
+  void deleteComment(long commentDbid);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityBehaviour.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityBehaviour.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityBehaviour.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.activity;
+
+import java.io.Serializable;
+
+/** piece of Java code that is to be included in a process as the runtime 
+ * activity behaviour or as a hidden listener to process events.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ActivityBehaviour extends Serializable {
+  
+  /** piece of Java code that is to be included in a process as activity behaviour 
+   * or as a hidden listener to process events.
+   * 
+   * <p>ActivityBehaviour's can be used to implement the behaviour of activities, in 
+   * which case this behaviour is associated to a graphical activity in the diagram.
+   * </p>
+   * 
+   * <p>An ActivityBehaviour can control the propagation 
+   * of execution.  ActivityBehaviour's can become external activities when they 
+   * invoke {@link ActivityExecution#waitForSignal()}.  That means the 
+   * activity will become a wait state.  In that case, {@link ExternalActivityBehaviour} 
+   * should be implemented to also handle the external triggers. 
+   * </p>
+   */
+  void execute(ActivityExecution execution) throws Exception;
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.activity;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Activity;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+import org.jbpm.session.PvmDbSession;
+
+
+/** view upon an {@link Execution path of execution} exposed to 
+ * {@link ActivityBehaviour} implementations.
+ *  
+ * @author Tom Baeyens
+ */
+public interface ActivityExecution extends OpenExecution {
+  
+  // wait state behaviour /////////////////////////////////////////////////////
+  
+  /** makes this execution wait in the current activity until an external trigger is given 
+   * with one of the {@link #signal()} methods. */
+  void waitForSignal();
+
+  // taking a transition //////////////////////////////////////////////////////
+  
+  /** takes the default transition.  
+   * 
+   * <p>This method can only be called from inside
+   * {@link ExternalActivityBehaviour} implementations and in rare occasions also from outside 
+   * of the execution (from an external client while the process is in a wait state).
+   * For external clients, it is more normal to use the {@link #signal()} 
+   * method as in that case, it's the current activity (hence the process language)that 
+   * will decide how to interpret the signal.
+   * </p>
+   * 
+   * @throws JbpmException in case there is no default transition in the current activity 
+   * or in case this method is called from inside an {@link ActivityBehaviour} */
+  void takeDefaultTransition();
+
+  /** takes the outgoing transition with the given name. 
+   * 
+   * <p>This method can only be called 
+   * from inside {@link ExternalActivityBehaviour} implementations and in rare occasions also from 
+   * outside of the execution (from an external client while the process is in a wait state).
+   * For external clients, it is more normal to use the {@link #signal(String)} 
+   * method as in that case, it's the current activity (hence the process language)that 
+   * will decide how to interpret the signal.</p>
+   * 
+   * <p>Transitions will be looked up recursively starting from the 
+   * {@link #getActivity() current activity} and then up the {@link Activity#getParent() activity-parent-hierarchy} </p>
+   * 
+   * @param transitionName is the name of the transition to take.  A null value will 
+   * match the first unnamed transition.
+   *   
+   * @throws JbpmException in case no such transition is found in {@link #getActivity() the current activity} 
+   * or in case this method is called from inside an {@link ActivityBehaviour}.*/
+  void take(String transitionName);
+
+  /** takes the given outgoing transition.  
+   * 
+   * <p>This method can only be called 
+   * from inside {@link ExternalActivityBehaviour} implementations and in rare occasions also from 
+   * outside of the execution (from an external client while the process is in a wait state).
+   * For external clients, it is more normal to use the {@link #signal(String)} 
+   * method as in that case, it's the current activity (hence the process language)that 
+   * will decide how to interpret the signal.</p>
+   * 
+   * <p>CAUTION: It's up to the client to make sure 
+   * that this transition makes sense as there is no check whether the given transition 
+   * is an outgoing transition of the current activity.  The motivation for that is 
+   * that in case of superstates, that check can become too 'expensive'. </p> */
+  void take(Transition transition);
+
+  /** let's the given execution take the transition.
+   * @throws JbpmException if the execution is not part of this process instance. */
+  void take(Transition transition, Execution execution);
+  
+  // execute a child activity /////////////////////////////////////////////////////
+  
+  /** executes the given nested activity. 
+   * 
+   * <p>The activityName is looked up in the current activity's nested activities.</p>
+   * 
+   * <p>This method can only be called 
+   * from inside {@link ExternalActivityBehaviour} implementations and in rare occasions also from 
+   * outside of the execution (from an external client while the process is in a wait state).
+   * For external clients, it is more normal to use the {@link #signal(String)} 
+   * method as in that case, it's the current activity (hence the process language)that 
+   * will decide how to interpret the signal.</p> */
+  void execute(String activityName);
+  
+  /** executes the given activity. 
+   * 
+   * <p>This method can only be called 
+   * from inside {@link ExternalActivityBehaviour} implementations and in rare occasions also from 
+   * outside of the execution (from an external client while the process is in a wait state).
+   * For external clients, it is more normal to use the {@link #signal(String)} 
+   * method as in that case, it's the current activity (hence the process language)that 
+   * will decide how to interpret the signal.</p>
+   */
+  void execute(Activity activity);
+  
+  // reposition the execution in another activity /////////////////////////////////
+
+  /** position this execution in the destination activity. */
+  void setActivity(Activity destination);
+
+  /** position the given execution in the destination activity */
+  void setActivity(Activity destination, Execution execution);
+  
+  // managing the parent-child relation ///////////////////////////////////////
+
+  /** creates a child execution.  See 
+   * {@link #createExecution(Execution, String)} for more information. */
+  Execution createExecution();
+
+  /** creates a child execution with the given name.  See 
+   * {@link #createExecution(Execution, String)} for more information. */
+  Execution createExecution(String name);
+
+  /** creates a new child execution under the given parent.  See 
+   * {@link #createExecution(Execution, String)} for more information. 
+   * @throws JbpmException if the given parent is not in this execution's 
+   * process instance. */
+  Execution createExecution(Execution parent);
+
+  /** creates a new child execution under the given parent with the given name.
+   * Only leaf executions can be active.  So creating the first child execution
+   * will {@link Execution#STATE_INACTIVE inactivate} the parent execution 
+   * automatically. 
+   * @throws JbpmException if the given parent is not in this execution's 
+   * process instance. */
+  Execution createExecution(String name, Execution parent);
+
+  /** removes the child execution from this execution.  Removing the last 
+   * child execution of a parent will cause the parent's state to become 
+   * {@link Execution#STATE_ACTIVE active}. */
+  void removeExecution(Execution child);
+
+  /** removes the child execution from the given parent.  Removing the last 
+   * child execution of a parent will cause the parent's state to become 
+   * {@link Execution#STATE_ACTIVE active}. */
+  void removeExecution(Execution child, Execution parent);
+
+  // create sub process execution /////////////////////////////////////////////
+  
+  /** creates a sub process related to this path of execution. 
+   * ProcessDefinitions can be obtained from the {@link PvmDbSession}
+   * in the {@link Environment}. */
+  ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition);
+
+  /** creates a sub process related to this path of execution. 
+   * ProcessDefinitions can be obtained from the {@link PvmDbSession}
+   * in the {@link Environment}. */
+  ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition, String key);
+
+  /** creates and begins a sub process related to this path of execution. 
+   * ProcessDefinitions can be obtained from the {@link PvmDbSession}
+   * in the {@link Environment}. */
+  ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition);
+
+  /** creates and begins a sub process related to this path of execution. 
+   * ProcessDefinitions can be obtained from the {@link PvmDbSession}
+   * in the {@link Environment}. */
+  ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition, String key);
+
+  // ending an execution //////////////////////////////////////////////////////
+  
+  /** ends this execution and all of its child executions.
+   * 
+   * <p>The execution will be removed from it's parent.  Potentially this can cause 
+   * a parent execution to start executing in case this is the last concurrent 
+   * execution for which the parent is waiting.</p> 
+   */
+  void end();
+
+  /** ends this execution and all it's child executions with a user defined 
+   * status.  
+   * 
+   * <p>It is not recommended to use any of 
+   * {@link #STATE_ACTIVE the defined statuses} as that may case unpredictable 
+   * side effects.</p>
+   *  
+   * <p>The execution will be removed from it's parent.</p> */
+  void end(String state);
+  
+  /** ends the given execution and all it's child executions. */
+  void end(OpenExecution executionToEnd);
+
+  /** ends the given execution and all it's child executions with a user defined 
+   * status. */
+  void end(OpenExecution executionToEnd, String state);
+
+  // firing events ////////////////////////////////////////////////////////////
+  
+  /** fires the event on the given eventSource and then propagates the event 
+   * up to the eventSource's parent chain.  All the actions will see the given 
+   * eventSource in {@link #getEventSource()}, event if the events are 
+   * registered to parent's of the given eventSource. */
+  void fire(String eventName, ObservableElement eventSource);
+  
+  // extra state information methods //////////////////////////////////////////
+  
+  /** the current transition indicating the position in the process definition graph.
+   * Can be null in case this execution is not taking a transition. */
+  Transition getTransition();
+  
+  // extensions //////////////////////////////////////////////////////////////
+
+  /** way to access process language extensions in the execution without 
+   * having to cast.  Casting can be problematic for persistence. */
+  <T> T getExtension(Class<T> extensionClass);
+  
+  /** setter for the priority.  The default priority is 0, which means 
+   * NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), 
+   * LOW (-1) and LOWEST (-2). For the rest, the user can set any other 
+   * priority integer value, but then, the UI will have to display it as 
+   * an integer and not the named value.*/
+  void setPriority(int priority);
+
+  
+  // previous methods /////////////////////////////////////////////////////////
+  
+  // TODO evaluate the previous methods (JBPM-)
+  // these methods are kind of performance optimisations.  a sequence and 
+  // some other specific control flow implementations can be optimised if they 
+  // have access to the previous activity or transition.
+  // Those activities could also be implemented by letting the activities store 
+  // the contextual information in process variables or some other execution 
+  // context.  But with the previous properties as done now, these control flow 
+  // activities can be implemented without storing an extra record.  It's only a property
+  // that is only updated when the activity configuration indicates that it's needed.
+  // (see also Activity.isPreviousNeeded())
+  
+  /** returns the previously executed activity only if {@link Activity#isPreviousNeeded()}
+   * is set to true. */  
+  Activity getPreviousActivity();
+  
+  /** returns the previously taken transition only if {@link Activity#isPreviousNeeded()}
+   * is set to true. */  
+  Transition getPreviousTransition();
+
+  /** record history event that specifies for an exclusive activity which transition 
+   * has been taken. */
+  void historyExclusive(String transitionName);
+
+  /** records the end of an automatic event.  This should be called at the end of 
+   * the activity.  Before the activity's execute method is invoked, the start time 
+   * is automatically recorded.  And invocation of this historyAutomatic will 
+   * capture the end time. */
+  void historyAutomatic();
+
+  /** marks the start of an activity for history purposes. */
+  void historyActivityStart();
+
+  /** marks the end of an activity for history purposes. */
+  void historyActivityEnd();
+
+  /** marks the end of an activity with a specific transitionName for history purposes. */
+  void historyActivityEnd(String transitionName);
+
+  /** marks the start of a user task for history purposes. */
+  void historyTaskStart(String assignee);
+
+  /** marks the end of a user task for history purposes. */
+  void historyTaskEnd(String outcome);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ExternalActivityBehaviour.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ExternalActivityBehaviour.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/ExternalActivityBehaviour.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.activity;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+
+
+/** extends {@link ActivityBehaviour} for handling external triggers after a wait state.
+ * 
+ * <p>Process languages will provide a set of these activity implementations. But 
+ * languages like jPDL even allow users to provide their own activity behaviour with 
+ * this interface.
+ * </p> 
+ * 
+ * @author Tom Baeyens
+ */
+public interface ExternalActivityBehaviour extends ActivityBehaviour {
+  
+  /** handles an external trigger.  
+   * 
+   * <p>An external trigger that comes into an execution 
+   * through one of the {@link Execution#signal()} methods, will be delegated to 
+   * the activity in which the execution is positioned when it receives the external 
+   * trigger.
+   * </p>  
+   * 
+   * <p>The signal method implements how the
+   * activity will react on that signal.  For example, the outgoing transition 
+   * could be taken that corresponds with the given signal.   
+   * </p>
+   * 
+   * @param execution the {@link Execution} for which the signal is given
+   * 
+   * @param signalName is an abstract text that can be associated with a signal.  this 
+   *   corresponds to e.g. a method name in a java class interface.  The implementation 
+   *   can decide e.g. to use the signal to identify the outgoing transition.
+   *   
+   * @param parameters is extra information that can be provided with a signal.
+   *   In this way, it is somewhat similar to the parameters that can be fed into a method 
+   *   invocation through reflection.
+   *   
+   * @throws Exception to indicate any kind of failure.  Note that exceptions are 
+   *   considered non recoverable.  After an Exception, the execution should not be 
+   *   used any more and if this is during a transaction, the transaction should be 
+   *   rolled back. */
+  void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception;
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/activity/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<body>interfaces for implementing 
+{@link org.jbpm.pvm.activity.Activity activities}, which represent the 
+runtime behaviour of activities.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.client;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.model.OpenExecution;
+
+/** view upon an {@link Execution path of execution} exposed to 
+ * external clients.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ClientExecution extends OpenExecution {
+  
+  // ending an execution //////////////////////////////////////////////////////
+  
+  /** ends this execution and all of its child executions.
+   * 
+   * <p>All child executions will be ended and removed.  This execution
+   * will not be removed from its parent.</p>
+   * 
+   * <p>This method should not be called in {@link ActivityBehaviour}s.  It can be called from 
+   * outside the process execution and in {@link ExternalActivityBehaviour}s. </p> */
+  void end();
+
+  /** ends this execution and all it's child executions with a user defined 
+   * status. */
+  void end(String state);
+
+  // signal ///////////////////////////////////////////////////////////////////
+
+  /** feeds a external trigger into this execution.
+   * 
+   * <p>Typically a signal causes the execution to proceed, but that doesn't necessarily 
+   * has to be the case .  The {@link ExternalActivityBehaviour} is responsible for interpreting 
+   * the signal and acting upon it.
+   * </p>
+   * 
+   * <p>A signal can optionally be given {@link #signal(String) a signal name}, 
+   * {@link #signal(Map) a map of parameters} or {@link #signal(String, Map) both}.
+   * </p>
+   * 
+   * <p>Since it's an external trigger, this method requires that this execution is 
+   * waiting for an external trigger.  So this method must be called as an external client
+   * and can not be called while this execution is executing.  In an {@link ActivityBehaviour} for 
+   * example you're not allowed to call the signal on the execution cause it is executing.  
+   * But you are allowed to invoke this method on any other execution (at least, if that 
+   * one is waiting for an external trigger).</p>
+   * 
+   * <p>Typically a signal will cause the execution to start executing, but that is 
+   * not a must.  What happens with this signal is defined in the 
+   * {@link ExternalActivityBehaviour#signal(Execution, String, Map)} of 
+   * the {@link #getActivity() current activity}. </p>
+   *  
+   * @see #signal(String) */
+  void signal();
+  
+  /** feeds a named {@link #signal() external trigger} into the execution.
+   * 
+   * <p>In each state, a number of things can happen.  The signal parameter specifies 
+   * which of these things is happening.  It's somewhat similar to a method name in 
+   * the invocation of an object.
+   * </p>
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(String signalName);
+
+  /** feeds {@link #signal() an external trigger} into the execution with parameters.
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(Map<String, Object> parameters);
+
+  /** feeds a named {@link #signal() external trigger} into the execution with parameters.
+   *
+   * <p>In each state, a number of things can happen.  The signal parameter specifies 
+   * which of these things is happening.  It's somewhat similar to a method name in 
+   * the invocation of an object.
+   * </p>
+   * 
+   * <p>The parameters parameter provide extra information to the signal.
+   * Typically, the parameters are set as variables but 
+   * the process language can overwrite that behaviour in the current activity.  
+   * See {@link ExternalActivityBehaviour#signal(Execution, String, Map)} for more information. 
+   * </p>
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(String signalName, Map<String, Object> parameters);
+
+  /** feeds a external trigger into the given execution.
+   * 
+   * <p>Typically a signal causes the execution to proceed, but that doesn't necessarily 
+   * has to be the case .  The {@link ExternalActivityBehaviour} is responsible for interpreting 
+   * the signal and acting upon it.
+   * </p>
+   * 
+   * <p>A signal can optionally be given {@link #signal(String) a signal name}, 
+   * {@link #signal(Map) a map of parameters} or {@link #signal(String, Map) both}.
+   * </p>
+   * 
+   * <p>Since it's an external trigger, this method requires that this execution is 
+   * waiting for an external trigger.  So this method must be called as an external client
+   * and can not be called while this execution is executing.  In an {@link ActivityBehaviour} for 
+   * example you're not allowed to call the signal on the execution cause it is executing.  
+   * But you are allowed to invoke this method on any other execution (at least, if that 
+   * one is waiting for an external trigger).</p>
+   * 
+   * <p>Typically a signal will cause the execution to start executing, but that is 
+   * not a must.  What happens with this signal is defined in the 
+   * {@link ExternalActivityBehaviour#signal(Execution, String, Map)} of 
+   * the {@link #getActivity() current activity}. </p>
+   *  
+   * @see #signal(String) */
+  void signal(Execution execution);
+  
+  /** feeds a named {@link #signal() external trigger} into a given execution.
+   * 
+   * <p>In each state, a number of things can happen.  The signal parameter specifies 
+   * which of these things is happening.  It's somewhat similar to a method name in 
+   * the invocation of an object.
+   * </p>
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(String signalName, Execution execution);
+
+  /** feeds {@link #signal() an external trigger} into a given execution with parameters.
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(Map<String, Object> parameters, Execution execution);
+
+  /** feeds a named {@link #signal() external trigger} into a given execution with parameters.
+   *
+   * <p>In each state, a number of things can happen.  The signal parameter specifies 
+   * which of these things is happening.  It's somewhat similar to a method name in 
+   * the invocation of an object.
+   * </p>
+   * 
+   * <p>The parameters parameter provide extra information to the signal.
+   * Typically, the parameters are set as variables but 
+   * the process language can overwrite that behaviour in the current activity.  
+   * See {@link ExternalActivityBehaviour#signal(Execution, String, Map)} for more information. 
+   * </p>
+   * 
+   * @see #signal() See the unnamed signal for more information
+   */
+  void signal(String signalName, Map<String, Object> parameters, Execution execution);
+
+  
+  /** suspends this execution and all it's child executions.  Human tasks 
+   * of a suspended execution shouldn't show up in people's task list and 
+   * timers of suspended executions shouldn't fire. 
+   * @throws JbpmException if this execution is already suspended. */   
+  void suspend();
+
+  /** resumes an execution.  Inverse of {@link #suspend()}. 
+   * @throws JbpmException if this execution is not suspended. */ 
+  void resume();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessDefinition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessDefinition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.client;
+
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.OpenProcessDefinition;
+
+
+/** adds factory methods for creating and beginning new process instances.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ClientProcessDefinition extends OpenProcessDefinition {
+
+  /** creates a new process instances. The returned process instance 
+   * is not started yet.  This way, 
+   * {@link OpenExecution#setVariable(String, Object) variables can be set} 
+   * before execution is started.  Invoke {@link ClientProcessInstance#start()} 
+   * to start execution of the process. */
+  ClientProcessInstance createProcessInstance();
+  
+  /** creates a new process instances with a given key. The returned process instance 
+   * is not started yet.  This way, 
+   * {@link OpenExecution#setVariable(String, Object) variables can be set} 
+   * before execution is started.  Invoke {@link ClientProcessInstance#start()} 
+   * to start execution of the process. 
+   * @param key is a user provided reference that uniquely identifies this 
+   * process instance in the scope of the process name. */
+  ClientProcessInstance createProcessInstance(String key);
+
+  /** creates the process instance and immediately start its execution. */
+  ClientExecution startProcessInstance();
+  
+  /** creates the process instance with the given key and immediately start its 
+   * execution.
+   * @param key is a user provided reference that uniquely identifies this 
+   * process instance in the scope of the process name. */
+  ClientExecution startProcessInstance(String key);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessInstance.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessInstance.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/ClientProcessInstance.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.client;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ClientProcessInstance extends ClientExecution {
+
+  // start ////////////////////////////////////////////////////////////////////
+
+  /** starts this process instance */
+  void start();
+
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/client/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>for clients that want direct programmatic access to the execution 
+object like e.g. in unit tests.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/Command.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/Command.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/Command.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+package org.jbpm.cmd;
+
+import java.io.Serializable;
+
+import org.jbpm.env.Environment;
+
+public interface Command<T> extends Serializable {
+  
+  T execute(Environment environment) throws Exception;
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/CommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/CommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/cmd/CommandService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,22 @@
+package org.jbpm.cmd;
+
+import org.jbpm.JbpmException;
+
+/**
+ * abstract extensible session facade.  Developers can use this directly or 
+ * extend one of the implementations with custom methods.
+ * Developers should be encouraged to use this interface as it will 
+ * be kept more stable then direct usage of the API (which is still 
+ * allowed).
+ * All the method implementations should be based on commands.
+ * Each of the method implementations will have a environment block.
+ * Then the command is executed and the environment is passed into the 
+ * command.
+ */
+public interface CommandService {
+
+  /**
+   * @throws JbpmException if command throws an exception.
+   */
+  <T> T execute(Command<T> command);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Context.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Context.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Context.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.env;
+
+import java.util.Set;
+
+/**
+ * a group of named objects in an {@link Environment} that have a similar lifespan.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Context {
+
+  /** key of the process-engine context in the environment */
+  String CONTEXTNAME_PROCESS_ENGINE = "process-engine";
+  
+  /** key of the block context in the environment */
+  String CONTEXTNAME_TRANSACTION = "transaction";
+  
+  String getName();
+
+  Object get(String key);
+  <T> T get(Class<T> type);
+
+  boolean has(String key);
+  Object set(String key, Object value);
+  Set<String> keys();
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Environment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Environment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Environment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,268 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.env;
+
+import java.io.Serializable;
+import java.util.Stack;
+
+import org.jbpm.JbpmException;
+
+
+/**
+ * maintains contextual information for a thread in a set of
+ * {@link Context}s.
+ * 
+ * <h3>Introduction</h3>
+ * 
+ * <p>Objects have different lifecycles and different context's (aka scopes).  An 
+ * environment provides the structure to easily manage objects with different 
+ * contexts.
+ * </p>
+ * 
+ * <p>Examples of contexts are: 
+ * <ul>
+ *   <li><b>process-engine</b>: The process-engine context is used to store e.g. data sources,
+ *     session factories and other static resources needed by an application.
+ *     The process-engine context lives for the complete duration of the {@link EnvironmentFactory}.  
+ *     So if the {@link EnvironmentFactory} is maintained in a static member field, the 
+ *     process-engine context lives for the duration of the application.
+ *     The same process-engine context is shared for all the Environments produced by one 
+ *     EnvironmentFactory.</li>
+ *   <li><b>environment</b>: The environment context is used for e.g. a transaction 
+ *     and transactional resources, user authentication.  This results in an efficient and 
+ *     configurable use of transactional resources that need to be lazily initialized.</li>
+ *   <li>The environment can accomodate other contexts as well.  They can be added 
+ *     and removed dynamically.  Examples of other potential contexts are web-request, web-session, 
+ *     web-application, business processDefinition, jobImpl, ... </li>
+ * </ul>    
+ *      
+ * <center><img src="environment.gif"/></center>
+ * 
+ * <p>An environment is typically installed like this
+ * </p>
+ * 
+ * <b><pre>static EnvironmentFactory environmentFactory = new DefaultEnvironmentFactory();
+ * 
+ * ...
+ * 
+ * Environment environment = environmentFactory.openEnvironment();
+ * try {
+ * 
+ *   ... everything available in this block ... 
+ * 
+ * } finally {
+ *   environment.close();
+ * }
+ * </pre></b>
+ *
+ * <h3>Purpose</h3>
+ * 
+ * <p>The first purpose of the environment is to separate the application from the 
+ * environment.  Standard Java and Enterprise Java are quite different and an environment 
+ * abstraction like this allows for the development of applications that can run in 
+ * both Standard and Enterprise environments.  Also test environments are easier to 
+ * tweak this way. 
+ * </p>
+ * 
+ * <p>A second purpose of the environment is to enable specific to global searching 
+ * of resources.  E.g. you could search for an 'adminEmailAddress' in the contexts
+ * 'execution', 'transaction' and 'process-engine' in the given order.
+ * That way, a global adminEmailAddress can be specified in the process-engine context 
+ * and it can be refined in more specific contexts.
+ * </p>
+ * 
+ * <h3>Search order</h3>
+ * 
+ * <p>To find an object in the environment, a searchOrder can be specified.  A 
+ * search order is an sequence that specifies the order in which the contexts should
+ * be searched.
+ * </p>
+ * 
+ * <p>The default search order is the inverse sequence of how the contexts are 
+ * added to the environment.  This is because in general, we can assume that the 
+ * more recent a context was added, the more specific it is. 
+ * </p>
+ *
+ * <h3>Transaction, username and classloader</h3>
+ * 
+ * <p>Three objects are used so frequently in an environment that they get 
+ * special treatment:
+ * </p>
+ * 
+ * <ul>
+ *   <li><b>Transaction</b>: an abstraction for marking a transaction with 
+ *   setRollbackOnly.</li>
+ *   <li><b>Classloader</b>: the current class loader.</li>
+ *   <li><b>Username</b>: the name of the currently authenticated user.</li>
+ * </ul>
+ * 
+ * <p>For these special properties, setters are also available.  That is to support 
+ * programmatic injection into the environment.  Alternatively, they can be configured
+ * in one of the contexts. 
+ * </p>
+ * 
+ * 
+ * @see EnvironmentFactory
+ * @author Tom Baeyens
+ */
+public abstract class Environment implements Serializable {
+
+  /**
+   * searches a named object in all the contexts in the default search order. 
+   * @return the object if it exists in the environment, <code>null</code> if there is no object with the given name in the environment.
+   */
+  public abstract Object get(String name);
+
+  /**
+   * searches a named object in all the contexts in the given search order.  The given 
+   * search order doesn't have to include all contexts.  It can be a subset of the 
+   * contexts available. 
+   * @param searchOrder list of contexts names. The object will be searched in these contexts, in the given order.
+   * @return the object if it exists in the environment, <code>null</code> if there is no object with the given name in the specified searchOrder contexts.
+   */
+  public abstract Object get(String name, String[] searchOrder);
+
+  /** searches an object based on type.  The search doesn take superclasses of the context elements 
+   * into account.
+   * @return the first object of the given type or null in case no such element was found.  
+   */
+  public abstract <T> T get(Class<T> type);
+
+  
+  /** searches an object based on type.  The search doesn take superclasses of the context elements 
+   * into account.
+   * @return the first object of the given type or null in case no such element was found.  
+   */
+  public abstract <T> T get(Class<T> type, String[] searchOrder);
+
+  /** get the authenticated user id */
+  public abstract String getUserId();
+  
+  /** set the authenticated user id */
+  public abstract void setUserId(String userId);
+
+  /**
+   * closes the Environment by removing all its contexts.
+   */
+  public abstract void close();
+
+  public abstract Context getContext(String contextName);
+  public abstract void addContext(Context context);
+  public abstract void removeContext(Context context);
+  
+  public abstract ClassLoader getClassLoader();
+  public abstract void setClassLoader(ClassLoader classLoader);
+
+  // current environment //////////////////////////////////////////////////////
+  /** the current environment is maintained in the currentEnvironment thread local */
+  static ThreadLocal<Environment> currentEnvironment = new ThreadLocal<Environment>();
+
+  /** in case of nested environments, the current environment stack maintains the outer environments */
+  static ThreadLocal<Stack<Environment>> currentEnvironmentStack = new ThreadLocal<Stack<Environment>>();
+
+  /** gets the most inner open environment. */
+  public static Environment getCurrent() {
+    return currentEnvironment.get();
+  }
+  
+  public static <T> T getFromCurrent(Class<T> type) {
+    return getFromCurrent(type, true);
+  }
+
+  public static <T> T getFromCurrent(Class<T> type, boolean required) {
+    Environment environment = getCurrent();
+    if (environment==null) {
+      if (required) {
+        throw new JbpmException("no environment to get "+type.getName());
+      }
+      return null;
+    }
+    T object = environment.get(type);
+    if (object==null) {
+      if (required) {
+        throw new JbpmException("no "+type.getName()+" in current environment");
+      }
+      return null;
+    }
+    return object;
+  }
+
+  public static Object getFromCurrent(String name) {
+    return getFromCurrent(name, true);
+  }
+
+  public static Object getFromCurrent(String name, boolean required) {
+    Environment environment = getCurrent();
+    if (environment==null) {
+      if (required) {
+        throw new JbpmException("no environment to get '"+name+"'");
+      }
+      return null;
+    }
+    Object object = environment.get(name);
+    if (object==null) {
+      if (required) {
+        throw new JbpmException("no '"+name+"' in current environment");
+      }
+      return null;
+    }
+    return object;
+  }
+
+  static Stack<Environment> getStack() {
+    // lazy initialize the current environment stack
+    Stack<Environment> stack = currentEnvironmentStack.get();
+    if (stack==null) {
+      stack = new Stack<Environment>();
+      currentEnvironmentStack.set(stack);
+    }
+    return stack;
+  }
+
+
+  /** pops the closing context from the stack of current contexts.  This 
+   * is the first thing that needs to be done when an environment is closed.
+   * @see EnvironmentFactory#push(Environment) */ 
+  public static synchronized Environment popEnvironment() {
+    Environment popped = currentEnvironment.get();
+    currentEnvironment.set(null);
+    Stack<Environment> stack = currentEnvironmentStack.get();
+    if ( (stack!=null)
+         && (! stack.isEmpty())
+       ) {
+      currentEnvironment.set(stack.pop());
+    }
+    return popped;
+  }
+
+  /** after opening of a new environment succeeded, the environment 
+   * must be pushed in the stack of current environments.
+   * 
+   * @see Environment#pop() */
+  public static synchronized void pushEnvironment(Environment environment) {
+    Environment current = currentEnvironment.get();
+    if (current!=null) {
+      getStack().push(current);
+    }
+    currentEnvironment.set(environment);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/EnvironmentFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/EnvironmentFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/EnvironmentFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.env;
+
+import java.io.InputStream;
+import java.io.Serializable;
+
+import org.xml.sax.InputSource;
+
+/**
+ * factory for {@link Environment}s.  
+ * 
+ * <p>Default implementation is 
+ * {@link PvmEnvironmentFactory}. EnvironmentFactory is thread safe, you 
+ * should use one environment factory for all your threads.
+ * </p>
+ * 
+ * <p>Easiest way to obtain an EnvironmentFactory is with
+ * <ul>
+ *   <li>{@link #parseResource(String)}</li>
+ *   <li>{@link #parseInputStream(InputStream)}</li> 
+ *   <li>{@link #parseInputSource(InputSource)}</li>
+ *   <li>{@link #parseXmlString(String)}</li>
+ * </ul>
+ * </p>
+ * 
+ * <p>For the default parser's XML schema, see {@link PvmEnvironmentFactoryParser}.</p>
+ * 
+ * @author Tom Baeyens
+ */
+public interface EnvironmentFactory extends Context, Serializable {
+  
+  /**
+   * open a new Environment.  The client is responsible for 
+   * closing the environment with {@link Environment#close()}.
+   */
+  Environment openEnvironment();
+  
+  /**
+   * closes this environment factory and cleans any allocated 
+   * resources.
+   */
+  void close();
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Transaction.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Transaction.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/Transaction.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.env;
+
+import javax.transaction.Synchronization;
+
+
+/** provides access to the transaction in the environment.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Transaction {
+
+  /** marks a transaction for rollback only. 
+   * The transaction will be rolled back upon closing the environment. */
+  void setRollbackOnly();
+
+  /** is this transaction marked for rollback only ? */
+  boolean isRollbackOnly();
+  
+  /** register a transaction listener. This method will have no 
+   * effect if the transactionListener is null. */
+  void registerSynchronization(Synchronization synchronization);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/environment.gif
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/environment.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/env/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>a layer that abstracts the engine and activities from the concrete environment 
+in which the Process Virtual Machine runs.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstance.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstance.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstance.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.history;
+
+import java.util.Date;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryActivityInstance {
+
+  String getActivityName();
+
+  Date getStartTime();
+
+  Date getEndTime();
+
+  long getDuration();
+
+  String getExecutionId();
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstanceQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstanceQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryActivityInstanceQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.history;
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryActivityInstanceQuery {
+  
+  String PROPERTY_STARTTIME = "startTime";
+  String PROPERTY_ENDTIME = "endTime";
+  String PROPERTY_EXECUTIONID = "executionId";
+  String PROPERTY_ACTIVITYNAME = "activityName";
+  String PROPERTY_DURATION = "duration";
+
+  HistoryActivityInstanceQuery processDefinitionId(String processDefinitionId);
+  HistoryActivityInstanceQuery executionId(String executionId);
+
+  HistoryActivityInstanceQuery startedAfter(Date time);
+  HistoryActivityInstanceQuery startedBefore(Date time);
+
+  HistoryActivityInstanceQuery activityName(String activityName);
+
+  HistoryActivityInstanceQuery tookLongerThen(long durationInMillis);
+  HistoryActivityInstanceQuery tookLessThen(long durationInMillis);
+
+  HistoryActivityInstanceQuery orderAsc(String property);
+  HistoryActivityInstanceQuery orderDesc(String property);
+
+  HistoryActivityInstanceQuery page(int firstResult, int maxResults);
+
+  List<HistoryActivityInstance> execute(); 
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.history;
+
+import java.util.Date;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryProcessInstance {
+  
+  String STATE_ENDED = "ended";
+  String STATE_ACTIVE = "active";
+
+  String getProcessInstanceId();
+
+  String getProcessDefinitionId();
+
+  String getKey();
+
+  String getState();
+
+  Date getStartTime();
+
+  Date getEndTime();
+
+  long getDuration();
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstanceQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstanceQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.history;
+
+import java.util.List;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryProcessInstanceQuery {
+  
+  String PROPERTY_STARTTIME = "startTime";
+  String PROPERTY_ENDTIME = "endTime";
+  String PROPERTY_ID = "id";
+  String PROPERTY_STATE = "state";
+  String PROPERTY_DURATION = "duration";
+
+  HistoryProcessInstanceQuery processInstanceId(String processInstanceId);
+  HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId);
+  HistoryProcessInstanceQuery state(String state);
+
+  HistoryProcessInstanceQuery orderAsc(String property);
+  HistoryProcessInstanceQuery orderDesc(String property);
+
+  HistoryProcessInstanceQuery page(int firstResult, int maxResults);
+
+  List<HistoryProcessInstance> execute();
+  HistoryProcessInstance executeUniqueResult();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/Group.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/Group.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/Group.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.identity;
+
+
+/** a group.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Group {
+  
+  String TYPE_ORGANISATION_UNIT = "ORGANIZATION_UNIT";
+
+  String getName();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/User.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/User.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/identity/User.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.identity;
+
+
+/** a user
+ * @author Tom Baeyens
+ */
+public interface User {
+
+  String getName();
+  
+  String getGivenName();
+  String getFamilyName();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Job.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Job.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Job.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.job;
+
+import java.util.Date;
+
+import org.jbpm.Execution;
+
+/** base class for timers and messages.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Job {
+
+  long getDbid();
+
+  String getLockOwner();
+
+  boolean isSuspended();
+
+  Date getDueDate();
+
+  String getException();
+
+  int getRetries();
+
+  boolean isExclusive();
+
+  Execution getExecution();
+
+  Execution getProcessInstance();
+
+  Date getLockExpirationTime();
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Message.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Message.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Message.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.job;
+
+/** an asynchronous message.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Message extends Job {
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Timer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/Timer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.job;
+
+
+/** a timer.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Timer extends Job {
+
+  String getSignalName();
+
+  String getEventName();
+
+  String getRepeat();
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/job/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+<body>timers and asynchronous messages</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/jpdl/ExclusiveHandler.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl;
+
+import org.jbpm.model.OpenExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ExclusiveHandler {
+
+  /** the name of the selected outgoing transition */ 
+  String select(OpenExecution execution);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.listener;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface EventListener extends Serializable {
+  
+  void notify(EventListenerExecution execution) throws Exception;
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.listener;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.model.Event;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+
+
+/** view upon an {@link Execution path of execution} exposed to 
+ * {@link EventListener} implementations.
+ * 
+ * @author Tom Baeyens
+ */
+public interface EventListenerExecution extends OpenExecution {
+  
+
+  /** the original object that fired the event, part of the current position in the 
+   * process graph.  Can be null in case no event is being fired. This is mostly the 
+   * object that is listened to with an {@link ActivityBehaviour}, but the eventSource can also 
+   * be a child of the object to which is listened in case of event propagation. */
+  ObservableElement getEventSource();
+  
+  /** the event that is being fired, part of the current position in the process 
+   * graph.  Can be null in case no event is being fired. */
+  Event getEvent();
+
+  // extra state information methods //////////////////////////////////////////
+  
+  /** the current transition indicating the position in the process definition graph.
+   * Can be null in case this execution is not taking a transition. */
+  Transition getTransition();
+  
+  /** fires the event on the given eventSource and then propagates the event 
+   * up to the eventSource's parent chain.  All the actions will see the given 
+   * eventSource in {@link #getEventSource()}, event if the events are 
+   * registered to parent's of the given eventSource. */
+  void fire(String eventName, ObservableElement eventSource);
+
+  // extensions //////////////////////////////////////////////////////////////
+
+  /** way to access process language extensions in the execution without 
+   * having to cast.  Casting can be problematic for persistence. */
+  <T> T getExtension(Class<T> extensionClass);
+  
+  
+  /** setter for the priority.  The default priority is 0, which means 
+   * NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), 
+   * LOW (-1) and LOWEST (-2). For the rest, the user can set any other 
+   * priority integer value, but then, the UI will have to display it as 
+   * an integer and not the named value.*/
+  void setPriority(int priority);
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/listener/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<body>interfaces for implementing 
+{@link org.jbpm.pvm.listener.EventListener event listeners}, which represent 
+runtime behaviour that can be associated as listeners to process events.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Activity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Activity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Activity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.Execution;
+
+
+/**
+ * a activity in a {@link OpenProcessDefinition} graph.
+ * 
+ * <p>The activity supports both graph based process models as well as 
+ * block structured (tree based) process models.  First we describe 
+ * tranisions that can be used to form graph based process structures 
+ * and then we'll describe activity composition to form block structured
+ * process models.  Both models can be combined as well.
+ * </p>
+ * 
+ * <p>Activities have {@link #getIncomingTransitions() incoming}
+ * and {@link #getOutgoingTransitions() outgoing transitions}.
+ * These are lists of transitions.
+ * </p>
+ * 
+ * <p>Optionally, transitions can have names.  In that case the 
+ * transition {@link #getOutgoingTransition(String) names are associated 
+ * to activity's outgoing transitions}.  The {@link #getOutgoingTransitionsMap() map 
+ * of outgoing transitions} provides easy access to the named transitions.
+ * </p> 
+ *   
+ * <p>One of the outgoing transitions can optionally be marked as 
+ * {@link #getDefaultTransition() the default transition}.
+ * </p>
+ * 
+ * <p>Block structured process languages have composite activities that can be 
+ * modeled with the {@link #getParent() parent}-{@link #getActivities() child} 
+ * relation.
+ * </p> 
+ * 
+ * @author Tom Baeyens
+ */
+public interface Activity extends CompositeElement {
+
+  /** the list of outgoing transitions.
+   * Caution: the actual member is returned.  No copy is made. */
+  List<Transition> getOutgoingTransitions();
+
+  /** the default outgoing transition. */
+  Transition getDefaultTransition();
+
+  /** the first leaving transition with the given name or null of no
+   * such leaving transition exists. If the multiple transitions have 
+   * the given transition name, the first (in order of {@link #getOutgoingTransitions()})
+   * will be returned.
+   *  
+   * @param transitionName is the name of the transition to take.  A null value will 
+   * match the first unnamed transition. */
+  Transition getOutgoingTransition(String transitionName);
+
+  /** indicates if a leaving transition with the given transitionName exists. 
+   * A null value matches an unnamed transition. */
+  boolean hasOutgoingTransition(String transitionName);
+
+  /** indicates if this activity has leaving transitions */
+  boolean hasOutgoingTransitions();
+
+  /** the leaving transitions, keyed by transition name.  If a transition with 
+   * the same name occurs mutltiple times, the first one is returned.
+   * Leaving transitions with a null value for their name are not included 
+   * in the map.
+   * Beware: the actual member is returned.  No copy is made.  In fact, the 
+   * returned map is maintained as a cache.  So updates to the map will 
+   * influence subsequent retrievals of outgoing transitions by name. */
+  Map<String, Transition> getOutgoingTransitionsMap();
+  
+  /** searches for the given transitionName in this activity and then up the 
+   * parent chain. Returns null if no such transition is found. */
+  Transition findOutgoingTransition(String transitionName);
+
+  /** the list of arriving transitions.
+   * Beware: the actual member is returned.  No copy is made. */
+  List<Transition> getIncomingTransitions();
+
+  /** indicates if this activity has arriving transitions */
+  boolean hasIncomingTransitions();
+  
+  /** retrieve the parent activity in the composite activity structure.  This is 
+   * different from {@link ObservableElement#getParent()} in that it is restricted 
+   * to the parent activities.  It doesn't take into account the process definition. */ 
+  Activity getParentActivity();
+
+  /** indicates if this activity should be executed 
+   * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a>. */
+  boolean isExecutionAsync();
+
+  /** indicates if signals should be processed  
+   * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a>. */
+  boolean isSignalAsync();
+
+  /** indicates if execution should proceed  
+   * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a> 
+   * when this activity is left over any of the outgoing transitions. */
+  boolean isLeaveAsync();
+
+  /** indicates if this activity behaviour needs to know 
+   * {@link Execution#getPreviousActivity() the previous activity} or 
+   * {@link Execution#getPreviousTransition() previous transition}. 
+   * If this property is set to true, the properties {@link Execution#getPreviousActivity()}
+   * and {@link Execution#getPreviousTransition()} will be available to the 
+   * activity behaviour when it is executed or signalled. */
+  boolean isPreviousNeeded();
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Comment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Comment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Comment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.Execution;
+
+/** a free text comment that can be made to an {@link Execution} 
+ * or a task.  
+ * 
+ * This class also supports threaded discussions with the 
+ * {@link #getParent() parent}-{@link #getComments() child} 
+ * relation.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Comment extends Discussable {
+
+  /** the meaningless database primary key */
+  long getDbid();
+
+  /** the id of the user that made this comment.  The term actorId is an abstract 
+   * reference to an entity in an external identity component. */
+  String getUserId();
+
+  /** the actual message.  Both plain text as well as HTML can be stored 
+   * as the message. */
+  String getMessage();
+
+  /** time that specifies when the comment was made */
+  Date getTime();
+  
+  /** threaded replies to this comment */
+  List<Comment> getComments();
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/CompositeElement.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/CompositeElement.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/CompositeElement.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.List;
+import java.util.Map;
+
+
+
+/** activity container base class for {@link OpenProcessDefinition} and {@link Activity}.
+ * 
+ * @author Tom Baeyens
+ */
+public interface CompositeElement extends ObservableElement {
+
+  /** indicates if this processDefinition has activities. */
+  boolean hasActivities();
+
+  /** the list of direct composite activities.  Recursively contained 
+   * activities are not included in the list. 
+   * Beware: the actual member is returned.  No copy is made. */
+  List<Activity> getActivities();
+
+  /** indicates if an activity with the given name exists directly in 
+   * this element.  Only the direct contained activities are 
+   * searched.  No recursive search is made. */
+  boolean hasActivity(String activityName);
+
+  /** the first composite activity with the given name or null of no
+   * such activity exists. Only the direct contained activities are 
+   * searched.  No recursive search is made. */
+  Activity getActivity(String activityName);
+
+  /** searches for the given activity in this element recursively, 
+   * including this activity and all child activities.  The search 
+   * is done depth-first. A null value for activityName matches a activity 
+   * without a name. */
+  Activity findActivity(String activityName);
+
+  /** the composite activities, keyed by activity name.  If an activity 
+   * with the same name occurs mutltiple times, the first in the list
+   * is included in the map. Activities with a null value for their name 
+   * are not included in the map. 
+   * Beware: the actual member is returned.  No copy is made. In fact, the 
+   * returned map is maintained as a cache.  So updates to the map will 
+   * influence subsequent retrievals of activities by name.*/
+  Map<String, Activity> getActivitiesMap();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Condition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Condition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Condition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.io.Serializable;
+
+/** user code that reflects a runtime calculation of a boolean value.
+ * Used for {@link Transition#getCondition() transition guard conditions} and 
+ * {@link Transition#getWaitCondition() transition wait states}.
+ * 
+ * @see Transition
+ * 
+ * @author Tom Baeyens
+ */
+public interface Condition extends Serializable {
+
+  /** evaluates this condition in the context of the given execution. */ 
+  boolean evaluate(OpenExecution execution);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Discussable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Discussable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Discussable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Discussable {
+
+  /** all comments. */
+  List<Comment> getComments();
+  
+  /** create a comment */
+  Comment createComment(String message);
+  
+  /** remove a comment */
+  void removeComment(Comment comment);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Event.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Event.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Event.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+
+/** event constants.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Event {
+
+  /** fired when a transition is being taken */
+  String TAKE = "take";
+  /** fired when a process or an activity starts */
+  String START = "start";
+  /** fired when a process or an activity ends */
+  String END = "end";
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ExecutionKeyGenerator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ExecutionKeyGenerator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ExecutionKeyGenerator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface ExecutionKeyGenerator {
+
+  String createKey(ProcessDefinition processDefinition, Execution execution, String executionRef);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/IdGenerator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/IdGenerator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/IdGenerator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface IdGenerator {
+
+  /** generates a unique id for the given execution. */
+  String createId(ProcessDefinition processDefinition, Execution parent, Execution execution);
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ObservableElement.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ObservableElement.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/ObservableElement.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.Set;
+
+
+/** a super class for process elements that have events.
+ * 
+ * @author Tom Baeyens
+ */
+public interface ObservableElement {
+  
+  /** the meaningless database primary key */
+  long getDbid();
+
+  /** the short display name given to this element. */
+  String getName();
+
+  /** the process definition to which this process element belongs */
+  OpenProcessDefinition getProcessDefinition();
+
+  /** the property value for the given key or null if no such 
+   * configuration key is present.
+   * 
+   * This is extra static configuration information that can be 
+   * associated to a process element.  Process languages can use this 
+   * to store configuration properties for extensions in it.  That way, 
+   * these extensions can be added without changing the process model 
+   * or the database schema. Examples of extensions that may use these 
+   * configuration properties are simulation, predictive scheduling, 
+   * graphical information,... */
+  Object getProperty(String key);
+  
+  /** the set of available property keys or an empty set in case 
+   * there are no keys. */
+  Set<String> getPropertyKeys();
+
+  /** indicates if the given event is defined no this element.
+   * This method only looks in this observable element and it will not 
+   * search the parent hierarchy for the given event. */
+  boolean hasEvent(String eventName);
+  
+  /** the enclosing activity or the process definition */
+  ObservableElement getParent();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.job.Timer;
+
+
+/** execution that opens up access to the related 
+ * objects in the execution and process definition 
+ * model.
+ * 
+ * This execution exposes the execution hierarchy,
+ * variable access and associated timers.
+ * 
+ * This is an execution that can be used backed by 
+ * an open persistence session.  Typically inside of 
+ * an environment block.  Navigation over the 
+ * related model objects will load the related objects
+ * transparantly with lazy loading.
+ * 
+ * @author Tom Baeyens
+ */
+public interface OpenExecution extends Execution, Discussable {
+  
+  /** the process definition for this execution.*/
+  OpenProcessDefinition getProcessDefinition();
+  
+  /** the current activity */
+  Activity getActivity();
+  
+  /** update the state */
+  void setState(String state);
+
+  /** the related sub process execution. */
+  OpenExecution getSubProcessInstance();
+  
+  // variable access //////////////////////////////////////////////////////////
+
+  /** retrieve the value for the given key.
+   * The value can be null.
+   * If there is no value for the given key, the returned 
+   * value will also be null.  The value for key <code>null</code>
+   * will always be null as null keys are not allowed. */  
+  Object getVariable(String key);
+
+  /** updates or creates a variable for the given value.
+   * Values are allowed to be null.
+   * @throws JbpmException if key is null. */
+  void setVariable(String key, Object value);
+
+  /** {@link #setVariable(String, Object) sets} all given variables.
+   * Existing key-value pairs for which there is no key in the provided 
+   * variables will <b>not</b> be removed. 
+   * @throws JbpmException is variables is not null and if null is present 
+   * as a key in the provided variables map. */
+  void setVariables(Map<String, Object> variables);
+
+  /** indicates presenve of the given key. 
+   * No exception will be thrown if key is null. 
+   * @return true if the key is present and false if the key doesn't exist 
+   * or if key is null. */
+  boolean hasVariable(String key);
+  
+  /** remove the key-value pair for the given key from this scope.
+   * No exception will be thrown when the variable is not present.
+   * @returns whether a variable was actually found and removed. */
+  boolean removeVariable(String key);
+  
+  /** removes all variables in this scope */
+  void removeVariables();
+
+  /** indicates if there are keys in this scope. */ 
+  boolean hasVariables();
+  
+  /** a non-null set that contains all the keys present in this scope.
+   * Even if there are no variable keys, an empty, non-null set will 
+   * be returned. */
+  Set<String> getVariableKeys();
+  
+  /** a non-null map containing all the key-value pairs in this scope. 
+   * Even if there are no variable keys, an empty, non-null map will 
+   * be returned. */
+  Map<String, Object> getVariables();
+  
+  /** create a new variable in this execution scope and determine 
+   * the type automagically. */
+  void createVariable(String key, Object value);
+
+  /** create a new variable in this execution scope with  
+   * the given type name. */
+  void createVariable(String key, Object value, String typeName);
+  
+  // execution hierarchy access ///////////////////////////////////////////////
+  
+  /** the main path of execution in the <a href="package-summary.html#basicexecutionstructure">execution 
+   * structure</a>.  Null will be returned in case this execution itself is the 
+   * main execution path.  */
+  OpenExecution getProcessInstance();
+
+  /** the parent execution in the <a href="package-summary.html#basicexecutionstructure">execution 
+   * structure</a>.  Null will be returned in case this execution itself is the 
+   * main execution path. */ 
+  OpenExecution getParent();
+
+  /** the child executions in the <a href="package-summary.html#basicexecutionstructure">execution 
+   * structure</a>.  Can be null and can be an empty collection. */ 
+  Collection<OpenExecution> getExecutions();
+  
+  /** maps child execution names to execution objects.  In case multiple executions 
+   * have the same name, the first one is taken.  Can be null or can be an empty 
+   * map.  The first execution without a name is also included with null as the key.
+   */ 
+  Map<String, OpenExecution> getExecutionsMap();
+  
+  /** the child execution for the given name or null in case such execution doesn't exist. */ 
+  OpenExecution getExecution(String name);
+  
+  /** indicates if this execution has a child execution with the given executionName */
+  boolean hasExecution(String executionName);
+
+  // timer access /////////////////////////////////////////////////////////////
+
+  /** indicates if this execution scope has timers */
+  boolean hasTimers();
+  
+  /** timers for this execution scope */
+  Set<Timer> getTimers();
+
+  // priority /////////////////////////////////////////////////////////////////
+  
+  /** setter for the priority.  The default priority is 0, which means 
+   * NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), 
+   * LOW (-1) and LOWEST (-2). For the rest, the user can set any other 
+   * priority integer value, but then, the UI will have to display it as 
+   * an integer and not the named value.*/
+  void setPriority(int priority);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenProcessDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenProcessDefinition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/OpenProcessDefinition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import org.jbpm.ProcessDefinition;
+
+
+
+/**
+ * a graph (or tree) structure that can be executed.
+ * 
+ * <h2>Purpose</h2>
+ * <p>ProcessDefinition is a base implementation that can be leveraged to build 
+ * graph based execution languages.  While the ProcessDefinition class is concrete and 
+ * can be used as-is (e.g. by aggregation), most likely processDefinition languages
+ * will inherit from this ProcessDefinition and create more specialized implementations.  
+ * </p>
+ * 
+ * <p>The specialized processDefinition language classes can extend this ProcessDefinition  
+ * with new datastructures relevant for that perticular processDefinition language.
+ * </p>
+ * 
+ * <h2>Structure</h2>
+ * <p>A processDefinition contains a set of activities.  Activities can be connected with 
+ * transitions or activities can have nested activities.  But the transitions and 
+ * nested activities can be combined.
+ * </p>
+ * 
+ * <h2>Execution</h2>
+ * <p>To create a new execution for a given processDefinition, see {@link #startExecution()}.
+ * </p>
+ * 
+ * @author Tom Baeyens
+ */
+public interface OpenProcessDefinition extends ProcessDefinition, CompositeElement {
+  
+  /** the initial activity of this process definition */
+  Activity getInitial();
+
+  /** retrieves an attachment of a process definition */
+  byte[] getAttachment(String name);
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Transition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Transition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/Transition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.model;
+
+import java.util.Set;
+
+
+/**
+ * a transition in a {@link OpenProcessDefinition} graph.
+ * 
+ * <h3 id="guardconditions">Guard conditions</h3>
+ * <p>TODO</p>
+ * 
+ * <h3 id="transitionsaswaitstates">Transitions as wait states</h3>
+ * <p>A wait condition indicates wether a transition is to be taken synchronously
+ * or wether the transition will behave as a wait state.
+ * </p>
+ * 
+ * <p>Transitions that are wait states can occur when an analyst has 
+ * an actual state (e.g. 'making loss') and a desired state (e.g. 'making profit')
+ * and models a transition between those states.  In that case the transition 
+ * might take a long time and hence it results into a wait state for the system.
+ * </p>
+ * 
+ * <p>If the wait condition is null or if it returns false, then the transition 
+ * will be taking synchronously.  Otherwise the transition will behave as 
+ * a wait state and wait for a signal on the execution.
+ * </p>
+ * 
+ * <p>Transitions as wait states has every thing to do with matching the 
+ * process graph to transactions on the server.  If the transition is taken 
+ * in one (the current) transaction, then the async condition should be empty 
+ * or evaluate to false.  If the arrival of the execution in the destination 
+ * activity should occur in a separate execution 
+ * 
+ * @author Tom Baeyens
+ */
+public interface Transition extends ObservableElement {
+  
+  /** the activity from which this transition leaves. */
+  Activity getSource();
+
+  /** the activity in which this transition arrives. */ 
+  Activity getDestination();
+  
+  /** the general purpose condition that can be used in various ways by the 
+   * activities. */
+  Condition getCondition();
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/model/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+<body>common model base classes for the client, activity and event listener API's
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+<body>the primary facade interfaces to 
+{@link org.jbpm.pvm.ProcessService the process repository}, 
+{@link org.jbpm.pvm.ExecutionService the execution repository} 
+and {@link org.jbpm.pvm.ManagementService the management functionalities}.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/DbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/DbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/DbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.session;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface DbSession {
+
+  void save(Object entity);
+  void merge(Object entity);
+  <T> T get(Class<T> entityClass, Object primaryKey);
+  void delete(Object entity);
+
+  void flush();
+  void forceVersionUpdate(Object entity);
+  void lockPessimistically(Object entity);
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/MessageSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/MessageSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/MessageSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.session;
+
+import org.jbpm.job.Message;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface MessageSession {
+
+  void send(Message message);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.session;
+
+import java.util.List;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.job.Job;
+import org.jbpm.job.Message;
+import org.jbpm.job.Timer;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface PvmDbSession extends DbSession {
+  
+  // process definition queries ///////////////////////////////////////////////
+
+  /** all deployed process names. */
+  List<String> findProcessDefinitionKeys();
+
+  /** latest version of the processDefinition for the given key. */
+  ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
+
+  /** all versions of the processDefinition for the given key. */
+  List<ClientProcessDefinition> findProcessDefinitionsByKey(String processDefinitionKey);
+
+  /** the process definition uniquely identified by the given 
+   * processDefinition id. */
+  ClientProcessDefinition findProcessDefinitionById(String processDefinitionId);
+
+  /** the first key for an existing process definition with the given processDefinitionName
+  * @returns null in case no such processDefinitionName exists */
+  String findProcessDefinitionKeyByName(String processDefinitionName);
+
+  /** the first name for an existing process definition with the given processDefinitionKey 
+   * @returns null in case no such processDefinitionKey exists */
+  String findProcessDefinitionNameByKey(String processDefinitionKey);
+
+  /** delete process definition */
+  void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory);
+
+  // process execution queries ////////////////////////////////////////////////
+
+  /** the execution uniquely identified by the given executionKey. */ 
+  ClientExecution findExecutionById(String executionId);
+
+  /** the process instance uniquely identified by the given executionKey. */ 
+  ClientExecution findProcessInstanceById(String processInstanceId);
+
+  /** the execution uniquely identified by the given processDefinition name 
+   * and the execution key. */
+  ClientExecution findExecutionByKey(String processDefinitionName, String executionKey);
+  
+  /* find ids for all process instances for a given process definition. */
+  List<String> findProcessInstanceIds(String processDefinitionId);
+
+  /** delete the process instance including the history. */
+  void deleteProcessInstance(String processInstanceId);
+
+  /** delete the process instance and optionally deletes the history. */
+  void deleteProcessInstance(String processInstanceId, boolean deleteHistory);
+
+  // job queries //////////////////////////////////////////////////////////////
+
+  /** timers */
+  List<Timer> findTimers(int firstResult, int maxResults);
+  
+  /** timers */
+  List<Message> findMessages(int firstResult, int maxResults);
+  
+  /** the jobs for which all the retries have failed and which will not be 
+   * picked up any more by the jobImpl executor */
+  public List<Job> findJobsWithException(int firstResult, int maxResults);
+
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.session;
+
+import org.jbpm.task.Task;
+
+/** 
+ * Persistence interface for tasks.
+ * @author Alejandro Guizar
+ */
+public interface TaskDbSession extends DbSession {
+
+  Task findTaskByDbid(long taskDbid);
+
+  void saveTask(Task task);
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TimerSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TimerSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/TimerSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.session;
+
+import org.jbpm.job.Timer;
+
+/**
+ * @author Tom Baeyens, Pascal Verdage
+ */
+public interface TimerSession {
+
+	/**
+	 * Schedule the execution of a timer.
+	 * @param timerImpl the timer to be executed.
+	 * @throws IllegalArgumentException if the timer is null
+	 * or if its activity is null or if its dueDate is null
+	 * or if its dueDate is negative or if its dueDate is past
+	 * or if its dueDate is equals to Long.MAX_VALUE
+	 */
+	public void schedule(Timer timer);
+
+	/**
+	 * Cancels a timer.
+	 * <br />
+	 * If a transaction is in progress, the cancellation will be effective
+	 * at the end of the transaction.
+	 * If the timer has been created in the same transaction or
+	 * if there is no transaction, the cancellation is immediately effective.
+	 * <br />
+	 * If the timer is executing when the cancellation becomes effective,
+	 * the execution in progress will not be stopped.
+	 * @param timerImpl the timer to be cancelled.
+	 */
+	public void cancel(Timer timer);
+	
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>interfaces to pluggable transactional resources to be used by 
+activity implementations.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Assigner.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Assigner.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Assigner.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+import java.io.Serializable;
+
+
+/** interface to delegate {@link Task} or {@link Swimlane} assignment.
+ * @author Tom Baeyens
+ */
+public interface Assigner extends Serializable {
+
+  /** sets the actorId and candidates for the given task. */
+  void assign(Task task) throws Exception;
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/GroupRef.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/GroupRef.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/GroupRef.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroupRef extends IdentityRef {
+
+  private static final long serialVersionUID = 1L;
+  
+  public GroupRef(String groupId) {
+    super(groupId);
+  }
+  
+  public String toString() {
+    return "GroupRef("+id+")";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/IdentityRef.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/IdentityRef.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class IdentityRef implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String id;
+
+  public IdentityRef(String id) {
+    if (id==null) {
+      throw new JbpmException("id is null");
+    }
+    this.id = id;
+  }
+
+  public String getId() {
+    return id;
+  }
+
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((id == null) ? 0 : id.hashCode());
+    return result;
+  }
+
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    IdentityRef other = (IdentityRef) obj;
+    if (!id.equals(other.id))
+      return false;
+    return true;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Participant.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Participant.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Participant.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+/** a link to a participant (user or group) and the type of 
+ * involvement of that participant.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Participant {
+
+  /** alternative owner, but as long as this person is not the owner. 
+   * This person is allowed to make comments, but nothing else. */
+  String CANDIDATE = "candidate";
+
+  /** the person with ultimate responsibility over a task. */
+  String OWNER = "owner";
+
+  /** person that will be using the result of this task.  This person is 
+   * allowed to make comments, but nothing else. */
+  String CLIENT = "client";
+
+  /** person that is allowed to watch-but-not-touch this task */
+  String VIEWER = "viewer";
+
+  /** a person that was assigned to a task, but got replaced because of 
+   * absence or another reason. This way, a trace can be left in case 
+   * this person returns and wants to take back his tasks that got 
+   * reassigned. */
+  String REPLACED_ASSIGNEE = "replaced-assignee";
+
+  long getDbid();
+
+  IdentityRef getIdentityRef();
+  
+  /** see contants for default particpations */
+  String getParticipation();
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Swimlane.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Swimlane.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Swimlane.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+import java.io.Serializable;
+
+/** a runtime process role that can store an assignment so that 
+ * multiple related tasks are assigned to the same actor.
+ *  
+ * @author Tom Baeyens
+ */
+public interface Swimlane extends Serializable {
+
+  long getDbid();
+
+  String getName();
+
+  String getAssignee();
+  void setAssignee(String assignee);
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Task.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Task.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/Task.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/** runtime task.
+ * 
+ * @author Tom Baeyens
+ */
+public interface Task extends Serializable {
+  
+  long getDbid();
+
+  String getName();
+  void setName(String name);
+
+  String getDescription();
+  void setDescription(String description);
+
+  String getAssignee();
+  void setAssignee(String assignee);
+
+  Date getCreate();
+
+  Date getDueDate();
+  void setDueDate(Date dueDate);
+
+  int getPriority();
+  void setPriority(int priority);
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/UserRef.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/UserRef.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/task/UserRef.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserRef extends IdentityRef {
+  
+  private static final long serialVersionUID = 1L;
+
+  public UserRef(String userId) {
+    super(userId);
+  }
+  
+  public String toString() {
+    return "UserRef("+id+")";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/api/src/main/resources/cfg.xsd
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/resources/cfg.xsd	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/resources/cfg.xsd	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+        targetNamespace="http://jbpm.org/4/cfg"
+        xmlns:tns="http://jbpm.org/4/cfg"
+        elementFormDefault="qualified">
+        
+  <annotation>
+    <documentation>Schema for the jBPM configuration file; configuration
+    is the top level element.
+    </documentation>
+  </annotation>
+
+  <!-- ### ELEMENTS ######################################################## -->
+
+  <element name="business-calendar">
+    <annotation><documentation>A BusinessCalendar that knows about working hours</documentation></annotation>
+    <complexType>
+      <sequence>
+        <element name="monday"    type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="tuesday"   type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="wednesday" type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="thursday"  type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="friday"    type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="saturday"  type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="sunday"    type="tns:businessCalendarDayType" minOccurs="0"/>
+        <element name="holiday" minOccurs="0" maxOccurs="unbounded">
+          <complexType>
+            <attribute name="period">
+              <annotation><documentation>Two dates in date-format, separated by 
+              a dash that specify a holiday period.  If it's just one day, a single day 
+              is also valid.</documentation></annotation>
+            </attribute>
+          </complexType>
+        </element>
+      </sequence>
+      <attribute name="timezone" type="string">
+        <annotation><documentation>Optional specification of the timezone as specified by 
+        java.util.TimeZone.getTimeZone(String)</documentation></annotation>
+      </attribute>
+      <attribute name="hour-format" type="string" default="HH:mm">
+        <annotation><documentation>Indicates how to interpret the hour specifications 
+        in this business calendar in java.text.SimpleDateFormat(String)</documentation></annotation>
+      </attribute>
+      <attribute name="date-format" type="string" default="dd/MM/yyyy">
+        <annotation><documentation>Indicates how to interpret the date specifications 
+        in this business calendar in java.text.SimpleDateFormat(String)</documentation></annotation>
+      </attribute>
+    </complexType>
+  </element>
+
+  <element name="byte">
+    <annotation><documentation>A java.lang.Byte</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" type="byte" use="required" />
+	  </complexType>
+  </element>
+
+  <element name="char">
+    <annotation><documentation>A java.lang.Character</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" use="required">
+	      <simpleType>
+	        <restriction base="string">
+	          <maxLength value="1" />
+	        </restriction>
+	      </simpleType>
+	    </attribute>
+	  </complexType>
+  </element>
+  
+  <element name="class">
+    <annotation><documentation>A java.lang.Class</documentation></annotation>
+		<complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+		  <attribute name="init" type="tns:initType" default="lazy">
+		    <annotation><documentation>Specifies when and how this object should be 
+		    created and initialized. Default is lazy.</documentation></annotation>
+		  </attribute>
+		  <attribute name="class-name" use="required" type="string">
+		    <annotation><documentation>A fully qualified name of a
+		      class that can be found on the wire context classpath or 
+		      (if that is not specified) on the current thread's context 
+		      classpath.  
+		    </documentation></annotation>
+		  </attribute>
+		</complexType>
+  </element>
+  
+  <element name="context-ref">
+    <annotation><documentation>The context.  This refers to
+    the contexts transaction or process-engine.
+    </documentation></annotation>
+    <complexType>
+      <attribute name="context-name" type="string">
+        <annotation><documentation>The name of the context in the current 
+        environment.  If this attribute is omitted, the enclosing 
+        context will be given. 
+        </documentation></annotation>
+      </attribute>
+    </complexType>
+  </element>
+
+  <element name="jbpm-configuration">
+    <annotation><documentation>Defines an environment factory and 
+    an environment.
+    </documentation></annotation>
+    <complexType>
+      <sequence>
+        <element ref="tns:process-engine-context" />
+        <element ref="tns:environment" />
+      </sequence>
+    </complexType>
+  </element>
+
+  <element name="process-engine-context" type="tns:contextType">
+    <annotation><documentation>Defines the environment factory 
+    context.  (Aka application context)
+    </documentation></annotation>
+  </element>
+
+  <element name="environment" type="tns:contextType">
+    <annotation><documentation>Defines the environment 
+    context.  This context exists stretches for the duration of 
+    an Environment try-finally block.
+    </documentation></annotation>
+  </element>
+
+  <element name="deployer-manager">
+    <annotation><documentation>Has a list of deployers (org.jbpm.pvm.internal.deploy.Deployer)
+    for handling deployments.  
+    </documentation></annotation>
+	  <complexType>
+      <choice maxOccurs="unbounded">
+        <group ref="tns:deployers" />
+      </choice>
+	  </complexType>
+  </element>
+
+  <element name="double">
+    <annotation><documentation>A java.lang.Double</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" type="double" use="required" />
+	  </complexType>
+  </element>
+
+  <element name="env-ref">
+    <annotation><documentation>Obtains the current environment.  The environment 
+    is only available in objects declared inside the environment context.  So it 
+    can't be used inside the session-factory context. 
+    </documentation></annotation>
+  </element>
+
+  <element name="process-engine-ref">
+    <annotation><documentation>Obtains the current environment.  The environment 
+    is only available in objects declared inside the environment context.  So it 
+    can't be used inside the session-factory context. 
+    </documentation></annotation>
+  </element>
+
+  <element name="false">
+    <annotation><documentation>java.lang.Boolean.FALSE 
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="float">
+    <annotation><documentation>A java.lang.Float
+    </documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" type="float" use="required" />
+	  </complexType>
+  </element>
+  
+  <element name="hibernate-configuration" type="tns:hibernateConfigurationType">
+    <annotation><documentation>A hibernate Configuration to be used in the 
+    process-engine context</documentation></annotation>
+  </element>
+  
+  <element name="hibernate-session">
+    <annotation><documentation>A hibernate Session to be used in the 
+    environment context</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>Optional name of this hibernate session.
+	      Typically a session is looked up by type.  Only if multiple sessions 
+	      are declared, a name can be used to distinct them. 
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="factory" type="string">
+	      <annotation><documentation>Optional name referring to the session-factory.
+	      If no factory name is provided, the SessionFactory is looked up by type.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="tx" type="tns:booleanValueType">
+	      <annotation><documentation>Indicates if a hibernate transaction should 
+	      be started and ended in this environment.  Default is true.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="current" type="tns:booleanValueType">
+	      <annotation><documentation>Indicates if the SessionFactory.getCurrentSession()
+	      should be used instead of opening and closing a new session.  Default is false.
+	      If 'current' is set to true, then the default of 'close' will be set to false. 
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="close" type="tns:booleanValueType">
+	      <annotation><documentation>Indicates if the session should be closed when the
+	      environment closes.  The default is true (unless 'current' is set to true) 
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="standard-transaction" type="string">
+	      <annotation><documentation>Optional name of the standard transaction.
+	      If 'tx' is set to true, a StandardTransaction needs to be found to enlist 
+	      this hibernate session.  By default, the lookup of the StandardTransaction 
+	      is done by type.  But this attribute allows to refer to the standard 
+	      transaction by name.   
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="connection" type="string">
+	      <annotation><documentation>Optional name of the JDBC connection to use 
+	      when creating this hibernate session.  If no connection name is specified,
+	      the creation of the connection is left to the hibernate session.
+	      </documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+  
+  <element name="hibernate-session-factory">
+    <annotation><documentation>A hibernate SessionFactory to be used in the 
+    process-engine context.  The hibernate Configuration can be inlined in this 
+    'session-factory', it can be refered by type or referred by name.
+    </documentation></annotation>
+	  <complexType>
+	    <complexContent>
+	      <extension base="tns:hibernateConfigurationType">
+	        <attribute name="configuration" type="string">
+			      <annotation><documentation>The name of the configuration to use to build 
+			      this hibernate SessionFactory.  This is optional as the alternative methods 
+			      to specify a configuration are just inlining it here in this hibernate 
+			      session-factory element or looking up the hibernate Configuration by type.
+			      </documentation></annotation>
+			    </attribute>
+	      </extension>
+	    </complexContent>
+	  </complexType>
+  </element>
+  
+  <element name="int">
+    <annotation><documentation>A java.lang.Integer
+    </documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" type="int" use="required"/>
+	  </complexType>
+  </element>
+  
+  <element name="jndi">
+    <annotation><documentation>A lookup from JNDI through the InitialContext
+    </documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="jndi-name" type="string" use="required" />
+	  </complexType>
+  </element>
+  
+  <element name="job-db-session">
+    <annotation><documentation>A hibernate based JobDbSession</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="session" type="string" />
+	  </complexType>
+  </element>
+  
+  <element name="job-executor">
+    <annotation><documentation>The default component for executing timers and messages.
+    A job-executor requires a CommandService.  
+    </documentation></annotation>
+		<complexType>
+		  <attribute name="name" type="string">
+		    <annotation><documentation>Optional name of this object used to look up 
+		    this object from the environment.  This name (along with ip-address) is 
+        used as the basis for the names of the threads in the job executor's thread 
+		    pool.  So when you're running more then one job-executor on the same 
+		    machine, you should be specifying custom job executor names.</documentation></annotation>
+		  </attribute>
+		  <attribute name="init" type="tns:initType" default="lazy">
+		    <annotation><documentation>Specifies when and how this object should be 
+		    initialized. Default is lazy.</documentation></annotation>
+		  </attribute>
+		  <attribute name="command-service" type="string">
+		    <annotation><documentation>Optional name of the command service to use.  If 
+		    this attribute is not present, the command service will be looked up 
+		    by type.</documentation></annotation>
+		  </attribute>
+		  <attribute name="threads" type="int">
+		    <annotation><documentation>Number of worker threads.  One extra thread will 
+		    be created for scanning and acquisition of jobs (DispatcherThread).</documentation></annotation>
+		  </attribute>
+		  <attribute name="idle" type="int">
+		    <annotation><documentation>Number of milliseconds the dispatcher thread  
+		    will normally wait inbetween checks for new jobs.  Each time an exception
+		    occurs, the idle period will be doubled until the 'idle-max' is reached.
+		    This is a back-off mechanism in case the job executor can't access the 
+		    database. 
+		    </documentation></annotation>
+		  </attribute>
+		  <attribute name="idle-max" type="int">
+		    <annotation><documentation>Maxumum number of milliseconds the dispatcher thread  
+		    will wait inbetween checks for new jobs.  
+		    </documentation></annotation>
+		  </attribute>
+		  <attribute name="history" type="int">
+		    <annotation><documentation>Number of history records of job executions that will be 
+		    kept in memory.</documentation></annotation>
+		  </attribute>
+		  <attribute name="lock" type="int">
+		    <annotation><documentation>Number of milliseconds that a job will be locked at 
+		    acquisition time.  When a job is acquired, the job executor will write it's name 
+		    in the lock owner field of the job and the lockExpirationTime
+		    will be set to the current time plus 'lock' milliseconds.  The lock by that thread should 
+		    be considered as released if the lockExpirationTime has passed.  This prevents starvation 
+		    in case one of more JobExecutors in a cluster would die.</documentation></annotation>
+		  </attribute>
+		  <attribute name="auto-start" type="tns:booleanValueType">
+		    <annotation><documentation>Indicates if the job-executor should be started when it 
+		    is created.  Default is true.  If the job-executor is not auto-started, it can be 
+		    started programmatically with the start method on the JobExecutor.</documentation></annotation>
+		  </attribute>
+		</complexType>
+  </element>
+
+  <element name="job-test-helper">
+    <annotation><documentation>A test helper for controlling job executions</documentation></annotation>
+  </element>
+
+  <element name="list">
+    <annotation><documentation>A java.util.List</documentation></annotation>
+	  <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <group ref="tns:persistableDescriptors" />
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      created and initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="class" type="string" default="java.util.ArrayList">
+	      <annotation><documentation>Implementation class for this list.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="synchronized" type="tns:booleanValueType" default="false">
+	      <annotation><documentation>Indicates if this collection should be synchronized
+	      with Collections.synchronizedList(List)</documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+  
+  <element name="long">
+    <annotation><documentation>A java.lang.Long</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="value" type="long" use="required"/>
+	  </complexType>
+  </element>
+  
+  <element name="map">
+    <annotation><documentation>A java.util.Map</documentation></annotation>
+	  <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <element name="entry">
+	        <complexType>
+	          <choice minOccurs="0">
+	            <element name="key" minOccurs="0">
+	              <complexType>
+	                <group ref="tns:persistableDescriptors" />
+	              </complexType>
+	            </element>
+	            <element name="value" minOccurs="0">
+	              <complexType>
+	                <group ref="tns:persistableDescriptors" />
+	              </complexType>
+	            </element>
+	          </choice>
+	        </complexType>
+	      </element>
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      created and initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="class" type="string" default="java.util.HashMap">
+	      <annotation><documentation>Implementation class for this map.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="synchronized" type="tns:booleanValueType" default="false">
+	      <annotation><documentation>Indicates if this collection should be synchronized
+	      with Collections.synchronizedMap(Map)</documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+  
+  <element name="message-session">
+    <annotation><documentation>Specifies an implementation of the MessageSession 
+    interface that sends messages to the JobExecutor.  The main usage of MessageSession 
+    is by the PVM implementation for asynchronous continuations.  The PVM will look 
+    up the message session by type.  All message-session implementations depend on a 
+    DbSession like e.g. the 'pvm-db-session'.  A DbSession will be looked up by type.
+    </documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="target" type="tns:messageSessionTargetType" default="job-executor">
+	      <annotation><documentation>
+	      <p>Specifies the implementation of the message session.
+	      </p>  
+	      <p><code><b>job-executor</b></code>: Is the default and sends to messages to the 
+	      job-executor.  In this case the message session has a dependency on 
+	      a DbSession (like the PvmDbSession) and a Transaction to which the 
+	      message session will register a listener to notify the job executor upon 
+	      successfull completion.
+	      </p>
+	      <p><code><b>jms</b></code>: Sends the messages over JMS and a JMS listener is assumed 
+	      (like the command executor MDB) that executes the message.  If 'jms' is specified, 
+	      attributes 'session-jndi' and 'destination-jndi' become required.
+	      </p>
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="session-jndi" type="string" use="optional">
+	      <annotation><documentation>The JNDI name of the JMS Session.  Only used in case of
+	      target <b>jms</b>. </documentation></annotation>
+	    </attribute>
+	    <attribute name="destination-jndi" type="string" use="optional">
+	      <annotation><documentation>The JNDI name of the Queue destination to use. Only used 
+	      in case of target <b>jms</b>.</documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+
+  <element name="null">
+    <annotation><documentation>the null value 
+    </documentation></annotation>
+  </element>
+  
+  <element name="object">
+    <annotation><documentation>Any java object that will be created by reflection.                                                                        .
+    <p>There are three main ways to create an object: by constructor or by a factory 
+    object or a static factory method.</p>
+    <p><b>Using the constructor</b>: Then the <code>class</code> attribute must provide the 
+    fully qualified class name.  In case another constructor then the default is 
+    targetted, a <code>constructor</code> child element can be provided.
+    The <code>factory</code> attribute should not be provided for using a constructor. 
+    </p>
+    <p><b>Using a factory</b>: Then the <code>factory</code> attribute or one 
+    <code>factory</code> element must be provided along with the attribute 
+    <code>method</code>. 
+    </p>
+    <p><b>Using a static factory method</b>: Then the <code>class</code> and 
+    <code>method</code> attributes should be specified.  There should be no 
+    reference to a <code>factory</code> attribute of element. 
+    </p>
+    <p><b>Construction and initialization</b>: all objects (constructor and factory)
+    are build in two phases: construction and initialisation phase.  During construction
+    all is done until a pointer is obtained to the object.  In initialisation, operations 
+    are applied to the object until it is ready to be used.  The separation between 
+    construction and initialisation is made to allow for bidirectional references.  In 
+    that case, at least one of both ends can not be fully initialised before it is injected 
+    into the other end.
+    </p>
+    <p><b>Operations</b>: after construction, various operations can be applied to objects 
+    like e.g. direct field injection, injection through setters, method invocation, 
+    enlist with the standard transaction, subscribe the object as a listener to an observable  
+    </p>
+    <p><b>Arguments</b>: There are two different places for arguments.  The <code>arg</code> 
+    elements for the factory method invocation should be placed as child elements under the 
+    <code>object</code> element.  The <code>arg</code> elements for the constructor should be 
+    placed as child elements under the <code>constructor</code> element.    
+    </p>
+    </documentation></annotation>
+	  <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <element name="factory">
+	        <annotation><documentation>Contains one element that describes the factory object.</documentation></annotation>
+	        <complexType>
+	          <group ref="tns:persistableDescriptors" />
+	        </complexType>
+	      </element>
+	      <element name="constructor">
+	        <annotation><documentation>Specifies the arguments to use for a non-default constructor.</documentation></annotation>
+	        <complexType>
+	          <choice maxOccurs="unbounded">
+	            <element name="arg" type="tns:argType" />
+	          </choice>
+	        </complexType>
+	      </element>
+	      <element name="arg" type="tns:argType">
+	        <annotation><documentation>The factory method arguments.</documentation></annotation>
+	      </element>
+	      <group ref="tns:operations" />
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="class" type="string">
+	      <annotation><documentation>The fully qualified class name</documentation></annotation>
+	    </attribute>
+	    <attribute name="factory" type="string">
+	      <annotation><documentation>The name of the factory object</documentation></annotation>
+	    </attribute>
+	    <attribute name="method" type="string">
+	      <annotation><documentation>The factory method name</documentation></annotation>
+	    </attribute>
+	    <attribute name="auto-wire" type="string">
+	      <annotation><documentation>Indicates if the member fields and setter properties 
+	      should be automatically wired based on matching the property names and types with the 
+	      object names and types</documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+
+  <element name="process-service">
+    <annotation><documentation>The default process service implementation 
+    that delegates method implementations to a CommandService.  process-service 
+    depends on a command service.
+    </documentation></annotation>
+  </element>
+  
+  <element name="properties">
+    <annotation><documentation>A java.util.Properties</documentation></annotation>
+	  <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <element name="property">
+	        <complexType>
+	          <attribute name="name" type="string" use="required" />
+	          <attribute name="value" type="string" use="required" />
+	        </complexType>
+	      </element>
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="file" type="string">
+	      <annotation><documentation>A file on the file system</documentation></annotation>
+	    </attribute>
+	    <attribute name="resource" type="string">
+	      <annotation><documentation>A file as a resource in the classpath</documentation></annotation>
+	    </attribute>
+	    <attribute name="url" type="string">
+	      <annotation><documentation>the contents is fetched by loading a url</documentation></annotation>
+	    </attribute>
+	    <attribute name="is-xml" type="tns:booleanValueType">
+	      <annotation><documentation>optionally indicates if the content of referenced file in attributes
+	      'file', 'resource' or 'url' is XML.  The default is the 
+	      plain properties format with a space or the equals character (=) separating key and value on 
+	      each line.</documentation></annotation>
+	    </attribute>
+	  </complexType>
+  </element>
+
+  <element name="pvm-db-session">
+    <annotation><documentation>A hibernate based PvmDbSession</documentation></annotation>
+	  <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="session" type="string" />
+	  </complexType>
+  </element>
+
+  <element name="ref">
+    <annotation><documentation>A reference to another object by name</documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="object" type="string" use="required">
+	      <annotation><documentation>The name of the referred object</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="set">
+    <annotation><documentation>A java.util.Set 
+    </documentation></annotation>
+    <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <group ref="tns:persistableDescriptors" />
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="class" type="string" default="java.util.HashList">
+	      <annotation><documentation>Implementation class for this set.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="synchronized" type="tns:booleanValueType" default="false">
+	      <annotation><documentation>Indicates if this collection should be synchronized
+	      with Collections.synchronizedSet(Set)</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="short">
+    <annotation><documentation>a java.lang.Short
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+      <attribute name="value" type="short" use="required"/>
+    </complexType>
+  </element>
+
+  <element name="command-service">
+    <annotation><documentation>The command service for usage in standard  
+    Java environments.
+    </documentation></annotation>
+    <complexType>
+	    <choice minOccurs="0" maxOccurs="unbounded">
+	      <group ref="tns:interceptors" />
+	    </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="string">
+    <annotation><documentation>a java.lang.String 
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+    <attribute name="value" type="string" use="required"/>
+    </complexType>
+  </element>
+
+  <element name="timer-session">
+    <annotation><documentation>A timer session is used during process execution to create 
+    timers.  Different implementations of the timer service make the process portable 
+    over different environments. 
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="target" default="job-executor">
+	      <annotation><documentation>Specifies the target implementation.  Use 
+	      <code>job-executor</code> when the job executor is responsible for executing the 
+	      timers (default).  Use <code>ejb</code> in case the EJB Timer Service should be used.
+	      If the target is job-executor, there is a dependency on the transaction, the job-executor
+	      and a job-db-session. 
+	      </documentation></annotation>
+	      <simpleType>
+	        <restriction base="string">
+	          <enumeration value="job-executor" />
+	          <enumeration value="ejb" />
+	        </restriction>
+	      </simpleType>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="transaction">
+    <annotation><documentation>The transaction binding.  Specifies how the transaction in the 
+    pvm environment gets bound to the actual transaction in the real environment.  
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="target" default="standard">
+	      <annotation><documentation>The real transaction to be wrapped.  Use <code>standard</code>
+	      in standard environments and enterprise in enterprise environments.  In case of the 
+	      <code>enterprise</code> target, the <code>jndi</code> name of the user transaction and 
+	      the <code>manage</code> attribute can optionally be specified. 
+	      </documentation></annotation>
+	      <simpleType>
+	        <restriction base="string">
+	          <enumeration value="standard" />
+	          <enumeration value="enterprise" />
+	        </restriction>
+	      </simpleType>
+	    </attribute>
+	    <attribute name="jndi" type="string" default="java:comp/UserTransaction">
+	      <annotation><documentation>The jndi name of the user transaction  
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="manage" type="tns:booleanValueType" default="false">
+	      <annotation><documentation>Indicates if the user transaction be controlled (=managed) 
+	      by the environment.  
+	      </documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="transaction-ref">
+    <annotation><documentation>Reference to the org.jbpm.pvm.api.env.Transaction in the 
+    current environment. 
+    </documentation></annotation>
+  </element>
+
+  <element name="true">
+    <annotation><documentation>java.lang.Boolean.TRUE 
+    </documentation></annotation>
+    <complexType>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <element name="types">
+    <annotation><documentation>Specifies automatic variable type resolution, transforming 
+    variable values of any java class into their persistable format.  When the 
+    type of a variable needs to be automatically detected.  Each of the type elements will 
+    be scanned in order.  When the type matches, it is used to store the value. 
+    </documentation></annotation>
+    <complexType>
+      <choice minOccurs="0" maxOccurs="unbounded">
+        <element name="type">
+          <complexType>
+            <choice>
+              <element name="matcher">
+                <annotation><documentation>Alternative to the <code>class</code> attribute to 
+                specify the matcher for this type.</documentation></annotation>
+                <complexType>
+          	      <group ref="tns:allDescriptors" />
+                </complexType>
+              </element>
+            </choice>
+				    <attribute name="name" type="string">
+				      <annotation><documentation>The name of the type is optional.  It's used when 
+				      users declare variables in the process.</documentation></annotation>
+				    </attribute>
+				    <attribute name="class" type="string">
+				      <annotation><documentation>Specifies a matcher based on the class of the 
+				      object.  The java class name of the values that will be 
+				      stored in this type.  Apart from Java class names following literals can be 
+				      used as well:
+				      <p><b><code>persistable</code></b>: Matches when the class of the object is 
+				      known by the hibernate-session-factory so that a generic reference (any-mapping)
+				      can be created to the persistable object.  If <code>class="persistable"</code>
+				      the attribute <code>id-type</code> becomes required. 
+				      </p>
+				      <p><b><code>serializable</code></b>: Matches if the object implements the 
+				      java.io.Serializable interface. 
+				      </p>
+				      <p>If no <code>class</code> is provided, a matcher can also be specified 
+				      as a separate child element.</p>
+				      </documentation></annotation>
+				    </attribute>
+				    <attribute name="hibernate-session-factory" type="string">
+				      <annotation><documentation>The name of the hibernate-session-factory. Only 
+				      required if <code>class="persistable"</code> is used and if there is more then 
+				      one hibernate session factory specified in the environment.
+				      </documentation></annotation>
+				    </attribute>
+				    <attribute name="id-type">
+				      <annotation><documentation>The type of the id property in the persistable object. 
+				      </documentation></annotation>
+				      <simpleType>
+				        <restriction base="string">
+				          <enumeration value="long" />
+				          <enumeration value="string" />
+				        </restriction>
+				      </simpleType>
+				    </attribute>
+				    <attribute name="converter" type="string">
+				      <annotation><documentation>The class name of the converter.  The converter must implement 
+				      the Converter interface and have a default constructor</documentation></annotation>
+				    </attribute>
+				    <attribute name="variable-class" type="string" use="required">
+				      <annotation><documentation>The class name of the variable class.  The variable class must be 
+				      a sub class of Variable and must have a default constructor.</documentation></annotation>
+				    </attribute>
+          </complexType>
+        </element>
+      </choice>
+	    <attribute name="name" type="string">
+	      <annotation><documentation>The name of the object.  It's optional and serves 
+	      as an id to refer to this object from other object declarations.  This name can 
+	      also be used lookup the object programmatically.</documentation></annotation>
+	    </attribute>
+	    <attribute name="init" type="tns:initType" default="lazy">
+	      <annotation><documentation>Specifies when and how this object should be 
+	      initialized. Default is lazy.</documentation></annotation>
+	    </attribute>
+	    <attribute name="file" type="string">
+	      <annotation><documentation>Imports variable types from a file.  All the 
+	      top level elements of the root document element are imported.</documentation></annotation>
+	    </attribute>
+	    <attribute name="url" type="string">
+	      <annotation><documentation>Imports variable types from a URL.  All the 
+	      top level elements of the root document element are imported.</documentation></annotation>
+	    </attribute>
+	    <attribute name="resource" type="string">
+	      <annotation><documentation>Imports variable types from a resource.  All the 
+	      top level elements of the root document element are imported.</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+
+  <!-- ### COMPLEX TYPES ################################################### -->
+
+  <complexType name="argType">
+    <annotation><documentation>The method arguments.
+    Each 'arg' element should have exactly one child element 
+    that represents the value of the argument.
+    </documentation></annotation>
+    <attribute name="type" type="string">
+      <annotation><documentation>The java class name representing 
+      the type of the method.  This is optional and can be used to 
+      indicate the appropriate method in case of method overloading. 
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+  
+  <complexType name="contextType">
+    <annotation><documentation>A context is a set of object 
+    descriptions.
+    </documentation></annotation>
+    <choice minOccurs="0" maxOccurs="unbounded">
+      <group ref="tns:allDescriptors" />
+    </choice>
+  </complexType>
+
+  <complexType name="hibernateConfigurationType">
+    <choice minOccurs="0" maxOccurs="unbounded">
+      <element name="mapping">
+        <annotation><documentation>Imports a hibernate mapping file</documentation></annotation>
+        <complexType>
+          <attribute name="resource" type="string">
+            <annotation><documentation>Adds the referenced resource file as a mapping 
+            file to the hibernate configuration</documentation></annotation>
+          </attribute>
+          <attribute name="file" type="string">
+            <annotation><documentation>Adds the referenced file as a mapping 
+            file to the hibernate configuration</documentation></annotation>
+          </attribute>
+          <attribute name="class" type="string">
+            <annotation><documentation>Adds the resource file that matches the given class 
+            name as a mapping file to the hibernate configuration. Matching means 
+            .hbm.xml instead of .java</documentation></annotation>
+          </attribute>
+          <attribute name="url" type="string">
+            <annotation><documentation>Adds file supplied by the URL as a mapping 
+            file to the hibernate configuration</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+      <element ref="tns:properties" />
+      <element name="cache-configuration">
+        <complexType>
+          <choice minOccurs="0" maxOccurs="unbounded">
+            <element name="class-cache">
+              <annotation><documentation>Persistent class for which hibernate should 
+              activate its second level cache</documentation></annotation>
+              <complexType>
+                <attribute name="class">
+                  <annotation><documentation>Fully qualified classname</documentation></annotation>
+                </attribute>
+              </complexType>
+            </element>
+            <element name="collection-cache">
+              <annotation><documentation>Persistent collection for which hibernate should 
+              activate its second level cache</documentation></annotation>
+              <complexType>
+                <attribute name="collection">
+                  <annotation><documentation>Fully qualified classname, a dot (.) and 
+                  then the property name of the collection</documentation></annotation>
+                </attribute>
+              </complexType>
+            </element>
+          </choice>
+          <attribute name="usage" type="tns:hibernateCacheUsageType">
+            <annotation><documentation>The caching strategy. see hibernate 
+            docs for more info.</documentation></annotation>
+          </attribute>
+          <attribute name="file" type="string">
+            <annotation><documentation>Import source for class-cache elements</documentation></annotation>
+          </attribute>
+          <attribute name="resource" type="string">
+            <annotation><documentation>Import source for class-cache elements</documentation></annotation>
+          </attribute>
+          <attribute name="url" type="string">
+            <annotation><documentation>Import source for class-cache elements</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+    </choice>
+    <attribute name="name" type="string">
+      <annotation><documentation>Optional name of this hibernate session factory.
+      Typically a session factory is looked up by type.  Only if multiple sessions 
+      are declared, a name can be used to distinct them. 
+      </documentation></annotation>
+    </attribute>
+    <attribute name="init" type="tns:initType" default="lazy">
+      <annotation><documentation>Specifies when and how this object should be 
+      initialized. Default is lazy.</documentation></annotation>
+    </attribute>
+    <attribute name="annotations">
+      <annotation><documentation>Indicates if annotations should be enabled or 
+      disabled.</documentation></annotation>
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="enabled" />
+          <enumeration value="disabled" />
+        </restriction>
+      </simpleType>
+    </attribute>
+  </complexType>
+
+  <complexType name="businessCalendarDayType">
+    <attribute name="hours" type="string">
+      <annotation><documentation>The working hours of this day.  Day parts are separated 
+      with 'and'.  Begin and end hours are separated by '-'.  E.g:
+      9:00-12:00 and 12:30-17:00
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+  
+
+
+  <!-- ### SIMPLE VALUE TYPES ############################################## -->
+
+  <simpleType name="booleanValueType">
+    <restriction base="string">
+      <enumeration value="true" />
+      <enumeration value="on" />
+      <enumeration value="enabled" />
+      <enumeration value="false" />
+      <enumeration value="off" />
+      <enumeration value="disabled" />
+    </restriction>
+  </simpleType>
+
+  <simpleType name="hibernateSchemaOperationType">
+    <restriction base="string">
+      <enumeration value="update" />
+      <enumeration value="create" />
+    </restriction>
+  </simpleType>
+  
+  <simpleType name="hibernateCacheUsageType">
+    <restriction base="string">
+      <enumeration value="read-only" />
+      <enumeration value="nonstrict-read-write" />
+      <enumeration value="read-write" />
+      <enumeration value="transactional" />
+    </restriction>
+  </simpleType>
+  
+  <simpleType name="initType">
+    <annotation><documentation>Specifies when and how this object should be 
+      initialized. Default is lazy.
+      
+      <p><code><b>lazy</b></code>: The object is only created when it is asked for.  
+        In case of transitive dependencies, the object might not yet be initialized.
+      </p>
+         
+      <p><code><b>eager</b></code>: The object is created when the context is created.  
+        In case of transitive dependencies, the object might not yet be initialized.
+      </p>
+        
+      <p><code><b>eager</b></code>: The object is created when the context is created.  
+        In case of transitive dependencies, the initialization is also mandatory.
+      </p>
+        
+      <p><code><b>eager</b></code>: The object is only created when it is asked for.  
+        In case of transitive dependencies, initialization is mandatory.  
+      </p>
+     </documentation></annotation>
+    <restriction base="string">
+      <enumeration value="lazy" />
+      <enumeration value="eager" />
+      <enumeration value="immediate" />
+      <enumeration value="required" />
+    </restriction>
+  </simpleType>
+
+  <simpleType name="messageSessionTargetType">
+    <restriction base="string">
+      <enumeration value="job-executor" />
+      <enumeration value="jms" />
+      <enumeration value="test" />
+    </restriction>
+  </simpleType>
+  
+  
+  <!-- ### GROUPS ########################################################## -->
+
+  <group name="persistableDescriptors">
+    <choice>
+      <element ref="tns:byte" />
+      <element ref="tns:char" />
+      <element ref="tns:class" />
+      <element ref="tns:context-ref" />
+      <element ref="tns:double" />
+      <element ref="tns:env-ref" />
+      <element ref="tns:process-engine-ref" />
+      <element ref="tns:false" />
+      <element ref="tns:float" />
+      <element ref="tns:int" />
+      <element ref="tns:jndi" />
+      <element ref="tns:list" />
+      <element ref="tns:long" />
+      <element ref="tns:map" />
+      <element ref="tns:message-session" />
+      <element ref="tns:null" />
+      <element ref="tns:object" />
+      <element ref="tns:pvm-db-session" />
+      <element ref="tns:properties" />
+      <element ref="tns:ref" />
+      <element ref="tns:set" />
+      <element ref="tns:short" />
+      <element ref="tns:string" />
+      <element ref="tns:timer-session" />
+      <element ref="tns:transaction-ref" />
+      <element ref="tns:true" />
+    </choice>
+  </group>
+  
+  <group name="allDescriptors">
+    <choice>
+      <group ref="tns:persistableDescriptors" />
+      <element ref="tns:business-calendar" />
+      <element ref="tns:process-service" />
+      <element ref="tns:deployer-manager" />
+      <element ref="tns:hibernate-configuration" />
+      <element ref="tns:hibernate-session-factory" />
+      <element ref="tns:hibernate-session" />
+      <element ref="tns:job-executor" />
+      <element ref="tns:job-test-helper" />
+      <element ref="tns:command-service" />
+      <element ref="tns:transaction" />
+      <element ref="tns:types" />
+    </choice>
+  </group>
+  
+  <group name="interceptors">
+    <choice>
+		  <element name="environment-interceptor">
+		    <annotation><documentation>Interceptor that can be used as part of declaring 
+		    a command service. 
+		    </documentation></annotation>
+		  </element>
+		  <element name="retry-interceptor">
+		    <annotation><documentation>Interceptor that retries the method invocation in 
+		    case of exceptions. 
+		    </documentation></annotation>
+		    <complexType>
+		      <attribute name="retries" default="3">
+		        <annotation><documentation>Max number of attempts before giving up</documentation></annotation>
+		      </attribute>
+		      <attribute name="delay" default="50">
+		        <annotation><documentation>Delay in milliseconds after the first exception</documentation></annotation>
+		      </attribute>
+		      <attribute name="delay-factor" default="4">
+		        <annotation><documentation>Factor with which the delay is multiplied after subsequent 
+		        failed attempts.  This enables back-off to reduce load in case of repetitive failures.
+		        </documentation></annotation>
+		      </attribute>
+		    </complexType>
+		  </element>
+		  <element name="transaction-interceptor">
+		    <annotation><documentation>Interceptor that will make sure the transaction is initialized before each 
+		    invocation and it will issue a setRollbackOnly on the transaction in case an exception occors. 
+		    </documentation></annotation>
+		  </element>
+    </choice>
+  </group>
+
+  <group name="deployers">
+    <choice>
+      <element name="create-process">
+        <annotation><documentation>Deployer that can instantiate the 
+	      process definition of a given type. 
+	      </documentation></annotation>
+	      <complexType>
+  		    <attribute name="name" type="string" />
+	  	    <attribute name="class" type="string" use="required"/>
+		    </complexType>
+      </element>
+      <element name="check-version">
+        <annotation><documentation>Deployer checks if the version of the 
+        deployed process is exactly 1 more then the last version of the same 
+        process.   If a version already exists, it is left untouched.  
+        If no version exists, by default, this deployer will assign 
+        a version to the process definition that is 1 higher then the 
+        highest deployed version in the DB for that process name.  This 
+        default can be overridden by the 'assign' attribute. 
+        </documentation></annotation>
+        <complexType>
+          <attribute name="assign" default="true">
+            <annotation><documentation>In case there the process definition 
+            has not be given a version explicitely, this attribute specifies 
+            if this deployer should assign a version.  The assigned version 
+            will be 1 higher then the highest version in the db for processes
+            with the same name.  Starting with 1 if no similarly named procses 
+            definitions are found.  
+            </documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+      <element name="create-id">
+        <annotation><documentation>Deployer verifies if the version of the 
+        deployed process is exactly 1 more then the last version of the same 
+        process. 
+        </documentation></annotation>
+      </element>
+      <element name="save-process">
+        <annotation><documentation>Deployer that saves the process with
+        the PvmDbSession. 
+	      </documentation></annotation>
+      </element>
+    </choice>
+  </group>
+
+  <group name="operations">
+    <choice>
+      <element name="enlist">
+        <annotation><documentation>Enlists this object (assumes a org.jbpm.tx.Resource) with the current org.jbpm.tx.StandardTransaction</documentation></annotation>
+        <complexType>
+			    <attribute name="transaction" type="string">
+			      <annotation><documentation>Optional reference to the name of the 
+			      standard transaction.  If no transaction name is specified, the transaction 
+			      is looked up by type in the environment.
+			      </documentation></annotation>
+			    </attribute>
+        </complexType>
+      </element>
+      <element name="field">
+        <annotation><documentation>Injects a value into a member field of this object.
+        Exactly one child element must specify the value.
+        </documentation></annotation>
+        <complexType>
+          <group ref="tns:persistableDescriptors" />
+          <attribute name="name">
+            <annotation><documentation>The member field name</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+		  <element name="invoke">
+		    <annotation><documentation>Invokes a method</documentation></annotation>
+			  <complexType>
+			    <choice minOccurs="0" maxOccurs="unbounded">
+			      <element name="arg" type="tns:argType" />
+			    </choice>
+			    <attribute name="method" type="string" use="required">
+			      <annotation><documentation>the method name</documentation></annotation>
+			    </attribute>
+			  </complexType>
+		  </element>
+		  <element name="subscribe">
+		    <annotation><documentation>Subscribes this object to an observable</documentation></annotation>
+			  <complexType>
+			    <choice minOccurs="0" maxOccurs="unbounded">
+			      <element name="arg" type="tns:argType" />
+			    </choice>
+			    <attribute name="context" type="string">
+			      <annotation><documentation>The context in which to find the observable.  If not specified, 
+			      the context of this object will be taken.  If no observable object names are specified, the 
+			      context object itself will be used as the observable.</documentation></annotation>
+			    </attribute>
+			    <attribute name="to" default="object-events">
+			      <annotation><documentation>Indicates if this object is interested in the events fired by 
+			      the object itself (object-events) or in the wire events fired by the wire context 
+			      (wire-events).</documentation></annotation>
+			      <simpleType>
+			        <restriction base="string">
+			          <enumeration value="wire-events" />
+			          <enumeration value="object-events" />
+			        </restriction>
+			      </simpleType>
+			    </attribute>
+			    <attribute name="event" type="string">
+			      <annotation><documentation>A single event.  See 'events' for more information.</documentation></annotation>
+			    </attribute>
+			    <attribute name="events" type="string">
+			      <annotation><documentation>Comma separated list of events to listen to, filtering out all other events.  
+			      If no events are specified or if the '*' wildcard is specified, the object will be notified of all events.
+			      </documentation></annotation>
+			    </attribute>
+			    <attribute name="object" type="string">
+			      <annotation><documentation>A single object name.  See 'objects' for more information.</documentation></annotation>
+			    </attribute>
+			    <attribute name="objects" type="string">
+			      <annotation><documentation>Comma separated list of object names to listen to.  
+			      If no objects are specified the specified context will be used as the observable.
+			      </documentation></annotation>
+			    </attribute>
+			    <attribute name="method" type="string">
+			      <annotation><documentation>Name of the method to invoke.  If no method is specified, it is assumed that the 
+			      object implements the Listener interface.  Nested 'arg' elements can be used to provide arguments
+			      in the method invocation. 
+			      </documentation></annotation>
+			    </attribute>
+			  </complexType>
+		  </element>
+    </choice>
+  </group>
+
+</schema>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/api/src/main/resources/jpdl.xsd
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/resources/jpdl.xsd	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/resources/jpdl.xsd	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,836 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+        targetNamespace="http://jbpm.org/4/jpdl"
+        xmlns:tns="http://jbpm.org/4/jpdl"
+        elementFormDefault="qualified"
+        attributeFormDefault="unqualified">
+        
+        
+  <annotation>
+    <documentation>Schema for jPDL 4 process descriptions; 
+    element process is the top level element.
+      
+      TODO: Add activity pluggability.  (add the proper any's and 
+            anyAttributes)
+    
+      TODO: Pull up expression.  The expression element in the 
+            delegation group can be pulled up as an expression 
+            attribute in each use case of the delegationGroup
+    
+      TODO: Should automatic activities have timers?  That makes sense
+            in a transient scenario, but not in a transactional scenario.
+            Same comment holds for asynchronous continuations
+    
+      TODO: Is it a good idea to move blocking and signalling to the API ?
+    
+      TODO: Figure out task reuse (requires templating and parameters) 
+            and dynamic task creation (requires tasks to be declared by name
+            in the process definition and that from the API tasks can be 
+            easily instantiated.   
+            
+      TODO: Investigate if object-refs to centrally defined objects would 
+            add value over inline defined objects.
+    </documentation>
+  </annotation>
+
+  <!-- ### PROCESS DEFINITION ############################################# -->
+
+  <element name="process">
+    <annotation><documentation>A jPDL process definition description; This 
+    is the top level element in a jPDL process file.</documentation></annotation>
+    <complexType>
+      <sequence minOccurs="0" maxOccurs="unbounded">
+        <group ref="tns:activityGroup" minOccurs="0" maxOccurs="unbounded" />
+      </sequence>
+      <attribute name="name" use="required" type="string">
+        <annotation>
+          <documentation>
+            The process name. Multiple processes can be deployed with the same name, as long as they have a different
+            version.
+          </documentation>
+        </annotation>
+      </attribute>
+      <attribute name="key" type="string">
+        <annotation>
+          <documentation>
+            The key can be used to provide a short acronym that will replace the name as the basis for the generated
+            process definition id
+          </documentation>
+        </annotation>
+      </attribute>
+      <attribute name="version" type="int">
+        <annotation>
+          <documentation>
+            Indicates the sequence number of this version for all processes with the same name. By specifying a version
+            automatic deployment can figure out if this process is already deployed or not.
+          </documentation>
+        </annotation>
+      </attribute>
+      <anyAttribute processContents="skip">
+        <annotation><documentation>for extensibility
+        </documentation></annotation>
+      </anyAttribute>
+    </complexType>
+  </element>
+  
+  <!-- ### ACTIVITIES ##################################################### -->
+  
+  <group name="activityGroup">
+    <choice>
+      <!-- ~~~ START ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <element name="start">
+        <annotation><documentation>Start event
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+
+      <!-- ~~~ END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <element name="end">
+        <annotation><documentation>End event.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+          <attribute name="ends" default="process-instance">
+            <simpleType>
+              <restriction base="string">
+                <enumeration value="execution"/>
+                <enumeration value="process-instance"/>
+              </restriction>
+            </simpleType>
+          </attribute>
+          <attribute name="state" default="ended" type="string">
+            <annotation><documentation>sets the state of the execution explicitely</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+
+      <element name="end-cancel">
+        <annotation><documentation>End cancel event.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+          <attribute name="ends" default="process-instance">
+            <simpleType>
+              <restriction base="string">
+                <enumeration value="execution"/>
+                <enumeration value="process-instance"/>
+              </restriction>
+            </simpleType>
+          </attribute>
+        </complexType>
+      </element>
+
+      <element name="end-error">
+        <annotation><documentation>End cancel event.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+          <attribute name="ends" default="process-instance">
+            <simpleType>
+              <restriction base="string">
+                <enumeration value="execution"/>
+                <enumeration value="process-instance"/>
+              </restriction>
+            </simpleType>
+          </attribute>
+        </complexType>
+      </element>
+      
+      <!-- ~~~ STATE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <element name="state">
+        <annotation><documentation>A wait state.  When an execution arrives in this 
+        activity, the execution will wait until an external trigger is received 
+        with execution.signal() or execution.getActivityInstance().signal()
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+
+      <!-- ~~~ EXCLUSIVE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+      <element name="exclusive">
+        <annotation><documentation>Exclusive gateway: selects one path out of many alternatives.  
+        When an execution comes in, exactly one outgoing transition is taken.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element name="handler" minOccurs="0" type="tns:wireObjectType" />
+            <element name="transition" minOccurs="0" maxOccurs="unbounded">
+              <complexType>
+                <complexContent>
+                  <extension base="tns:transitionType">
+                    <sequence>
+                      <element name="condition" minOccurs="0" maxOccurs="unbounded">
+                        <complexType>
+                          <attribute name="expr" type="string">
+                            <annotation><documentation>The script text that will be evaluated.  
+                            </documentation></annotation>
+                          </attribute>
+                          <attribute name="lang" type="string">
+                            <annotation><documentation>Identification of the scripting language 
+                            to use.</documentation></annotation>
+                          </attribute>
+                        </complexType>
+                      </element>
+                    </sequence>
+                  </extension>
+                </complexContent>
+              </complexType>
+              <!-- TODO add conditions -->
+            </element>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+          <attribute name="expr" type="string">
+            <annotation><documentation>The script that will be evaluated and resolve to 
+            the name of the outgoing transition.
+            </documentation></annotation>
+          </attribute>
+          <attribute name="lang" type="string">
+            <annotation><documentation>Identification of the scripting language 
+            to use for the expr attribute.</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+
+      <element name="fork">
+        <annotation><documentation>Spawns multiple concurrent paths of 
+        execution.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+    
+      <element name="join">
+        <annotation><documentation>Spawns multiple concurrent paths of 
+        execution.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+
+      <element name="script">
+        <annotation><documentation>Evaluates a piece of text as a script
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:scriptType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+
+      <element name="hql">
+        <annotation><documentation>Performs a hibernate query
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:qlType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+
+      <element name="sql">
+        <annotation><documentation>Performs a hibernate SQL query
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:qlType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+
+      <element name="java">
+        <annotation><documentation>Invokes a method on a java object.  
+        Either the java class is instantiated with reflection, or the 
+        java object is fetched from the environment.  Then values from the 
+        environment are injected into the fields and a method is executed.
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:javaType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+
+      <element name="esb">
+        <annotation><documentation>Invokes a service over the ESB.  
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:esbType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+
+      <element name="task">
+        <annotation><documentation>Creates a task in the task component.  
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+          <attribute name="assignee" type="string" use="required">
+            <annotation><documentation>User id to whom this task should be assigned.
+            </documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+      
+      <!-- 
+      <element name="process-state">
+        <annotation><documentation>Waits while a sub process instance is 
+        being executed and continues when the sub process instance ends.
+        </documentation></annotation>
+        < ! - - take into account the following situation:
+        Unlike in jBPM 3, a process-state should not signal the newly created 
+        process instance.  The signal in jBPM 3 is probably historically there 
+        because in the beginning there was no initial attribute on the process
+        definition.
+        - - >
+        <complexType>
+          <sequence>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+              <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+            </element>
+            <element ref="tns:timer" minOccurs="0" maxOccurs="unbounded"/>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+
+      <element name="super-state">
+        <annotation><documentation>Scope enclosing a number of activities.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <group ref="tns:activityGroup" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+              <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+            </element>
+            <element ref="tns:timer" minOccurs="0" maxOccurs="unbounded"/>
+          </sequence>
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+    
+      <element name="activity">
+        <annotation><documentation>Executes an activity implementation.
+        </documentation></annotation>
+        <complexType>
+          <sequence>
+            <group ref="tns:delegationGroup"/>
+            <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+            <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+              <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+            </element>
+          </sequence> 
+          <attributeGroup ref="tns:activityAttributes" />
+        </complexType>
+      </element>
+      
+      <element name="email">
+        <annotation><documentation>Sends an email
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:emailType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+                <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+                  <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+                </element>
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+      
+      <element name="task">
+        <annotation><documentation>Creates a human task
+        </documentation></annotation>
+        <complexType>
+          <complexContent>
+            <extension base="tns:taskType">
+              <sequence>
+                <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+                <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+                  <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+                </element>
+                <element ref="tns:timer" minOccurs="0" maxOccurs="unbounded"/>
+              </sequence>
+              <attributeGroup ref="tns:activityAttributes" />
+            </extension>
+          </complexContent>
+        </complexType>
+      </element>
+      -->
+    </choice>
+  </group>
+  
+  <group name="wireObjectGroup">
+    <choice>
+      <element name="string">
+        <complexType>
+          <attribute name="name">
+            <annotation><documentation>the name of the string object</documentation></annotation>
+          </attribute>
+          <attribute name="value">
+            <annotation><documentation>the actual string value</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+      <element name="object" type="tns:wireObjectType" />
+    </choice>
+  </group>
+  
+  <complexType name="wireObjectType">
+    <sequence>
+      <element name="field" minOccurs="0" maxOccurs="unbounded">
+        <annotation><documentation>Field injections from the environment 
+        invocation.</documentation></annotation>
+        <complexType >
+          <group ref="tns:wireObjectGroup" />
+        </complexType>
+      </element>
+    </sequence>
+    <attribute name="object" type="string">
+      <annotation><documentation>Name of the object in the environment 
+      </documentation></annotation>
+    </attribute>
+    <attribute name="class" type="string">
+      <annotation><documentation>The class to instantiate.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="name" type="string">
+      <annotation><documentation>The name of this object.
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+
+  <complexType name="javaType">
+    <sequence>
+      <element name="field" minOccurs="0" maxOccurs="unbounded">
+        <annotation><documentation>Field injections from the environment 
+        invocation.</documentation></annotation>
+      </element>
+      <element name="arg" minOccurs="0" maxOccurs="unbounded">
+        <annotation><documentation>Method arguments.</documentation></annotation>
+      </element>
+    </sequence>
+    <attribute name="object" type="string">
+      <annotation><documentation>Name of the object in the environment 
+      </documentation></annotation>
+    </attribute>
+    <attribute name="method" type="string" use="required">
+      <annotation><documentation>The name of the method to invoke.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="class" type="string">
+      <annotation><documentation>The class to instantiate.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="var" type="string">
+      <annotation><documentation>The variable name to store the return value
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+
+  <complexType name="scriptType">
+    <sequence>
+      <element name="text" type="string" minOccurs="0">
+        <annotation><documentation>The content of this expression element 
+        is the script text that will be evaluated.  This is mutually 
+        exclusive with the expression attribute.</documentation></annotation>
+      </element>
+    </sequence>
+    <attribute name="expr" type="string">
+      <annotation><documentation>The script text that will be evaluated.  This 
+      is mutually exclusive with the expression element.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="lang" type="string">
+      <annotation><documentation>Identification of the scripting language 
+      to use.</documentation></annotation>
+    </attribute>
+    <attribute name="var" type="string">
+      <annotation><documentation>Name of the variable in which the result 
+      of the script evaluation will be stored</documentation></annotation>
+    </attribute>
+  </complexType>
+  
+  <complexType name="qlType">
+    <sequence>
+      <element name="query" type="string">
+        <annotation><documentation>The query text.</documentation></annotation>
+      </element>
+      <element name="parameters" minOccurs="0">
+        <annotation><documentation>Query parameters.</documentation></annotation>
+        <complexType>
+          <sequence>
+            <group ref="tns:wireObjectGroup" maxOccurs="unbounded" />
+          </sequence>
+        </complexType>
+      </element>
+    </sequence>
+    <attribute name="var" type="string">
+      <annotation><documentation>Name of the variable in which the result 
+      of the script evaluation will be stored</documentation></annotation>
+    </attribute>
+    <attribute name="unique" type="string">
+      <annotation><documentation>Does this query return a unique result or a list
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+  
+  <complexType name="esbType">
+    <sequence>
+      <element name="part" minOccurs="0" maxOccurs="unbounded">
+        <annotation><documentation>The content of this expression element 
+        is the script text that will be evaluated.  This is mutually 
+        exclusive with the expression attribute.</documentation></annotation>
+        <complexType>
+          <choice minOccurs="0">
+            <group ref="tns:wireObjectGroup" />
+          </choice>
+          <attribute name="name" type="string">
+            <annotation><documentation>The name of the message body part.
+            </documentation></annotation>
+          </attribute>
+          <attribute name="expr" type="string">
+            <annotation><documentation>The script text that will be evaluated and 
+            used and the object in this message body part.
+            </documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+    </sequence>
+    <attribute name="category" type="string">
+      <annotation><documentation>The category of the service in the esb.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="service" type="string">
+      <annotation><documentation>The name of the service in the esb.
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+  
+  <attributeGroup name="activityAttributes">
+    <attribute name="name" type="string">
+      <annotation><documentation>The id of this activity.  The name should be unique
+      in the complete scope of the process.</documentation></annotation>
+    </attribute>
+    <attribute name="g" type="string">
+      <annotation><documentation>Graphical information used by process designer tool.
+      </documentation></annotation>
+    </attribute>
+  </attributeGroup>
+  
+  <complexType name="transitionType">
+    <annotation><documentation>The outgoing transitions.  The first in the list 
+      will be the default outgoing transition.
+    </documentation></annotation>
+    <!-- 
+    <sequence>
+      <group ref="tns:eventListenerGroup" />
+    </sequence>
+    -->
+    <attribute name="name" type="string">
+      <annotation><documentation>Name of this outgoing transition</documentation></annotation>
+    </attribute>
+    <attribute name="to" type="string">
+      <annotation><documentation>Name of the destination activity of this transition. 
+      </documentation></annotation>
+    </attribute>
+    <attribute name="g" type="string">
+      <annotation><documentation>Graphical information used by process designer tool.
+      </documentation></annotation>
+    </attribute>
+  </complexType>
+  
+  <element name="transition" type="tns:transitionType">
+    <annotation><documentation>A transition from one activity to another.</documentation></annotation>
+  </element>
+  
+  <element name="on">
+    <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+    <complexType>
+      <!-- 
+      <sequence>
+        <group ref="tns:eventListenerGroup" minOccurs="0" maxOccurs="unbounded">
+          <annotation><documentation>A list of event listeners that will 
+          be notified when the event is fired</documentation></annotation>
+        </group>
+      </sequence>
+      -->
+      <attribute name="event" type="string">
+        <annotation><documentation>The event identification
+        </documentation></annotation>
+      </attribute>
+    </complexType>
+  </element>
+  
+  <!-- 
+
+  <group name="eventListenerGroup">
+    <choice>
+      <element name="notify">
+        <annotation><documentation>Calls the notify method on an 
+        EventListener.
+        </documentation></annotation>
+        <complexType>
+          <group ref="tns:delegationGroup" />
+          <attribute name="object" type="string">
+            <annotation><documentation>The reference to an object that is declared 
+            in the objects section of this process definition.
+            </documentation></annotation>
+          </attribute>
+          <attribute name="expr" type="string">
+            <annotation><documentation>The expression that will resolve to 
+            an Activity implementation.</documentation></annotation>
+          </attribute>
+        </complexType>
+      </element>
+      <element name="invoke" type="tns:invokeType">
+        <annotation><documentation>Invokes a method on a Java object
+        through reflection.  The return value can be captured in a 
+        process variable.
+        </documentation></annotation>
+      </element>
+      <element name="script" type="tns:scriptType">
+        <annotation><documentation>Evaluates a piece of text as a script
+        </documentation></annotation>
+      </element>
+      <element name="email" type="tns:emailType">
+        <annotation><documentation>Sends an email
+        </documentation></annotation>
+      </element>
+      <element ref="tns:timer">
+        <annotation><documentation>Creates a timer.
+        </documentation></annotation>
+      </element>
+    </choice>
+  </group>
+
+  <complexType name="scriptType">
+    <sequence>
+      <element name="expr" type="string">
+        <annotation><documentation>The content of this expression element 
+        is the script text that will be evaluated.  This is mutually 
+        exclusive with the expression attribute.</documentation></annotation>
+      </element>
+    </sequence>
+    <attribute name="expr" type="string">
+      <annotation><documentation>The script text that will be evaluated.  This 
+      is mutually exclusive with the expression element.
+      </documentation></annotation>
+    </attribute>
+    <attribute name="lang" type="string">
+      <annotation><documentation>Identification of the scripting language 
+      to use.</documentation></annotation>
+    </attribute>
+  </complexType>
+
+  <complexType name="emailType">
+    <sequence>
+      <element name="property">
+        <annotation><documentation>Template property value</documentation></annotation>
+        <complexType>
+          <attribute name="name" type="string" />
+          <attribute name="value" type="string" />
+        </complexType>
+      </element>
+    </sequence>
+    <attribute name="to" type="string" />
+    <attribute name="type" type="string">
+      <annotation><documentation>Reference to the email template</documentation></annotation>
+    </attribute>
+  </complexType>
+
+  <element name="timer">
+    <annotation><documentation>A timer that will be bound to the most inner enclosing scope.
+    Timers can give a signal to an activity instance.  The signal will correspond to a transition 
+    or to an event being fired.
+    </documentation></annotation>
+    <complexType>
+      <choice minOccurs="0" maxOccurs="unbounded">
+        <group ref="tns:eventListenerGroup">
+          <annotation><documentation>An inline list of event listeners 
+          on a timer is a short cut for defining the event separately.
+          </documentation></annotation>
+        </group>
+      </choice>
+      <attribute name="duedate" type="string" use="required" />
+      <attribute name="signal" type="string"  use="required">
+        <annotation><documentation>Refers to the signal that will be used.
+        If inline event listeners are declared, the signal name can not be 
+        the same as an event that is declared in this scope.
+        </documentation></annotation>
+      </attribute>
+      <attribute name="repeat" type="string" />
+    </complexType>
+  </element>
+
+  <complexType name="taskType">
+    <sequence>
+      <element ref="tns:assignment" />
+      <element name="reminder">
+        <complexType>
+          <attribute name="duedate" type="string" use="required" />
+          <attribute name="repeat" type="string" />
+        </complexType>
+      </element>
+      <element ref="tns:subtask" />
+    </sequence>
+    <attribute name="title" type="string">
+    </attribute>
+    <attribute name="form" type="string">
+    </attribute>
+    <attribute name="swimlane" type="string">
+    </attribute>
+    <attribute name="description" type="string" />
+    <attribute name="duedate" type="string" />
+    <attribute name="priority" type="tns:priorityType" default="normal" />
+    <attribute name="notify" type="boolean" default="false"/>
+    <attribute name="dynamic" type="boolean" default="true">
+      <annotation><documentation>Is dynamic creation of subtasks 
+      allowed ?</documentation></annotation>
+    </attribute>
+    <attribute name="subtasksync">
+      <simpleType>
+        <union>
+          <simpleType>
+            <restriction base="string">
+              <enumeration value="last">
+                <annotation><documentation>When the last subtask completes,
+                this task is completed.</documentation></annotation>
+              </enumeration>
+              <enumeration value="first">
+                <annotation><documentation>When the first subtask completes,
+                this task is completed.</documentation></annotation>
+              </enumeration>
+            </restriction>
+          </simpleType>
+          <simpleType>
+            <restriction base="int">
+              <annotation><documentation>The number of subtasks that 
+              have to complete before this task is considered 
+              completed.</documentation></annotation>
+            </restriction>
+          </simpleType>
+        </union>
+      </simpleType>
+    </attribute>
+  </complexType>
+  
+  <simpleType name="priorityType">
+    <restriction base="string">
+      <enumeration value="highest"/>
+      <enumeration value="high"/>
+      <enumeration value="normal"/>
+      <enumeration value="low"/>
+      <enumeration value="lowest"/>
+    </restriction>
+  </simpleType>
+
+  <element name="subtask" type="tns:taskType">
+    <annotation><documentation>Subtask in a task activity.</documentation></annotation>
+  </element>
+  
+  <element name="swimlane">
+    <annotation><documentation>A process role.</documentation></annotation>
+    <complexType>
+      <sequence>
+        <element ref="tns:assignment"/>
+      </sequence>
+      <attribute name="name" type="string" use="required" />
+    </complexType>
+  </element>
+  
+  <element name="assignment">
+    <annotation><documentation>Specifies how a task or a swimlane should be assigned 
+    to a specific user or who will be identified as a candidate for it.</documentation></annotation>
+    <complexType>
+      <sequence minOccurs="0">
+        <group ref="tns:delegationGroup">
+          <annotation><documentation>An object that implements the 
+          Assigner interface.
+          </documentation></annotation>
+        </group>
+      </sequence>
+	    <attribute name="assignee" type="string">
+	      <annotation><documentation>User ID of the person to which the task
+	      or swimlane will be assigned.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="assignee-expr" type="string">
+	      <annotation><documentation>Expression that resolves to a 
+	      User ID to which the task or swimlane will be assigned.
+	      </documentation></annotation>
+	    </attribute>
+	    <attribute name="candidates" type="string">
+	      <annotation><documentation>Comma separated list of User ID's 
+	      or Group ID's.  All the referred people will be candidates to 
+	      take the task or swimlane.</documentation></annotation>
+	    </attribute>
+	    <attribute name="candidate-expr" type="string">
+	      <annotation><documentation>Expression that resolves to a 
+	      comma separated list of User ID's or Group ID's.  All the 
+	      referred people will be candidates to 
+	      take the task or swimlane.</documentation></annotation>
+	    </attribute>
+    </complexType>
+  </element>
+  -->  
+  
+</schema>

Added: jbpm4/branches/tbaeyens/modules/config/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 4057 2009-02-27 08:19:30Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Config Tool</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-config</artifactId>
+  <packaging>pom</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>package.config</id>
+            <phase>package</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <!-- property name="user.home" value="${user.home}" /-->
+                <property name="version" value="${version}" />
+                <ant antfile="scripts/antrun-package-config.xml" target="package.config" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-artifacts</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attach-artifact</goal>
+            </goals>
+            <configuration>
+              <artifacts>
+                <artifact>
+                  <file>target/jbpm-config-${version}.zip</file>
+                  <type>zip</type>
+                </artifact>
+              </artifacts>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/scripts/antrun-package-config.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/scripts/antrun-package-config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/scripts/antrun-package-config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="package.config" basedir=".">
+	
+  <target name="package.config">
+    <delete dir="target" />
+    <mkdir dir="target" />
+    <copy todir="target/files">
+      <fileset dir="src/main/files">
+        <include name="*/**" />
+      </fileset>
+    </copy>
+  	<replace file="target/files/build.properties" token="../../../" value="" />
+  	<zip destfile="target/jbpm-config-${version}.zip">
+  		<fileset dir="target/files" />
+  	</zip>
+  </target>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/build.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/build.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/build.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+jbpm.config.dest.dir=../../../target/configfiles
+jbpm.config.tmp.dir=../../../target/filtered
+jbpm.config.hibernate.cache=hashtable
+jbpm.config.hibernate.connection.type=jdbc
+jbpm.config.hibernate.database=hsqldb.inmemory
+jbpm.config.hibernate.format.sql=include
+jbpm.config.hibernate.jpdl=include
+jbpm.config.identity=include

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/build.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/build.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/build.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="generate.jbpm.configuration" basedir=".">
+	
+	<property file="build.properties" />
+	
+  <target name="generate" description="generates a full jbpm configuration">
+    <delete dir="${jbpm.config.dest.dir}" />
+    <antcall target="jbpm.hibernate.cfg.xml" />
+    <antcall target="hibernate.mapping.files" />
+  	<condition property="is.identity.included">
+  		<equals arg1="${jbpm.config.identity}" arg2="include" />
+  	</condition>
+  	<antcall target="identity.config.files" />
+  	<antcall target="jbpm.configuration.files" />
+  </target>
+
+	<target name="jbpm.hibernate.cfg.xml">
+		<mkdir dir="${jbpm.config.dest.dir}" />
+    <mkdir dir="${jbpm.config.tmp.dir}" />
+    <filter filtersfile="filter.properties" />
+		<copy todir="${jbpm.config.tmp.dir}" filtering="true" overwrite="true">
+			<fileset dir=".">
+				<include name="*/**" />
+		  </fileset>
+	  </copy>
+		<concat destfile="${jbpm.config.dest.dir}/jbpm.hibernate.cfg.xml">
+			<filelist dir=".">
+				<file name="${jbpm.config.tmp.dir}/hibernate/cfg/part1.jbpm.hibernate.cfg.xml" />
+			  <file name="${jbpm.config.tmp.dir}/hibernate/${jbpm.config.hibernate.connection.type}/${jbpm.config.hibernate.database}.xml"/>
+        <file name="${jbpm.config.tmp.dir}/hibernate/other/format.sql.${jbpm.config.hibernate.format.sql}.xml"/>
+        <file name="${jbpm.config.tmp.dir}/hibernate/mapping.references/pvm.xml"/>
+        <file name="${jbpm.config.tmp.dir}/hibernate/mapping.references/jpdl.${jbpm.config.hibernate.jpdl}.xml"/>
+        <file name="${jbpm.config.tmp.dir}/hibernate/cfg/part2.jbpm.hibernate.cfg.xml" />
+			</filelist>
+		</concat>
+	</target>
+
+  <target name="identity.config.files"
+  	      if="is.identity.included">
+	  <copy file="identity/jbpm.identity.cfg.xml" todir="${jbpm.config.dest.dir}" overwrite="true" />
+  	<mkdir dir="${jbpm.config.dest.dir}/META-INF" />
+    <concat destfile="${jbpm.config.dest.dir}/META-INF/persistence.xml">
+      <filelist dir=".">
+        <file name="${jbpm.config.tmp.dir}/identity/META-INF/part1.persistence.xml" />
+        <file name="${jbpm.config.tmp.dir}/hibernate/${jbpm.config.hibernate.connection.type}/${jbpm.config.hibernate.database}.xml"/>
+        <file name="${jbpm.config.tmp.dir}/identity/META-INF/part2.persistence.xml"/>
+      </filelist>
+    </concat>
+  </target>
+
+  <target name="hibernate.mapping.files">
+  	<copy todir="${jbpm.config.dest.dir}">
+  		<fileset dir="${jbpm.config.tmp.dir}/hibernate/mapping.files" />
+  	</copy>
+	</target>
+
+  <target name="jbpm.configuration.files">
+    <copy todir="${jbpm.config.dest.dir}">
+      <fileset dir="jbpm">
+      	<include name="*.xml" />
+      </fileset>
+    </copy>
+    <concat destfile="${jbpm.config.dest.dir}/jbpm.wire.bindings.xml">
+      <filelist dir=".">
+        <file name="${jbpm.config.tmp.dir}/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml" />
+        <file name="${jbpm.config.tmp.dir}/jbpm/wire.bindings/jpdl.${jbpm.config.hibernate.jpdl}.xml"/>
+        <file name="${jbpm.config.tmp.dir}/jbpm/wire.bindings/part2.jbpm.wire.bindings.xml" />
+      </filelist>
+    </concat>
+  </target>
+	
+  <target name="clean">
+    <delete dir="${jbpm.config.tmp.dir}" />
+    <delete dir="${jbpm.config.dest.dir}" />
+  </target>
+
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/filter.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/filter.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/filter.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+jdbc.mysql.server=localhost
+jdbc.mysql.port=3306
+jdbc.mysql.database=jbpm
+jdbc.mysql.url=jdbc:mysql://localhost:3306/jbpm
+jdbc.mysql.username=jbpm
+jdbc.mysql.password=jbpm
+
+jdbc.postgresql.server=localhost
+jdbc.postgresql.port=5432
+jdbc.postgresql.database=jbpm
+jdbc.postgresql.url=jdbc:postgresql://localhost:5432/jbpm
+jdbc.postgresql.username=jbpm
+jdbc.postgresql.password=jbpm
+
+jdbc.sybase.server=localhost
+jdbc.sybase.port=5000
+jdbc.sybase.database=jbpm
+jdbc.sybase.url=jdbc:sybase:Tds:localhost:5000/jbpm
+jdbc.sybase.username=jbpm
+jdbc.sybase.password=jbpm
+jdbc.sybase.driver=com.sybase.jdbc3.jdbc.SybDriver
+jdbc.sybase.datasource=com.sybase.jdbc3.jdbc.SybXADataSource
+
+jdbc.oracle.server=localhost
+jdbc.oracle.port=1521
+jdbc.oracle.database=XE
+jdbc.oracle.username=jbpm
+jdbc.oracle.password=jbpm
+jdbc.oracle.url=jdbc:oracle:thin:@localhost:1521:XE

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cache/hashtable.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cache/hashtable.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cache/hashtable.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+      <property name="hibernate.cache.use_second_level_cache" value="true" />
+      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part1.jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part1.jbpm.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part1.jbpm.hibernate.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?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>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part2.jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part2.jbpm.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/cfg/part2.jbpm.hibernate.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+  </session-factory>
+</hibernate-configuration>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/db2.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/db2.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/db2.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
+      <property name="hibernate.connection.datasource">java:JbpmDS</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="jta.UserTransaction">UserTransaction</property>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/mysql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/mysql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/mysql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
+      <property name="hibernate.connection.datasource">java:JbpmDS</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="jta.UserTransaction">UserTransaction</property>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/oracle.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/oracle.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/oracle.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
+      <property name="hibernate.connection.datasource">java:JbpmDS</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="jta.UserTransaction">UserTransaction</property>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/postgresql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/postgresql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/postgresql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
+      <property name="hibernate.connection.datasource">java:JbpmDS</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="jta.UserTransaction">UserTransaction</property>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/sybase.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/sybase.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/datasource/sybase.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.SybaseDialect" />
+      <property name="hibernate.connection.datasource">java:JbpmDS</property>
+      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+      <property name="jta.UserTransaction">UserTransaction</property>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/db2.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/db2.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/db2.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
+      <property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
+      <property name="hibernate.connection.url" value="@jdbc.db2.url@" />
+      <property name="hibernate.connection.username" value="@jdbc.db2.username@" />
+      <property name="hibernate.connection.password" value="@jdbc.db2.password@" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/hsqldb.inmemory.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/hsqldb.inmemory.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/hsqldb.inmemory.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,6 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
+      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
+      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:." />
+      <property name="hibernate.connection.username" value="sa" />
+      <property name="hibernate.connection.password" value="" />
+      <property name="hibernate.hbm2ddl.auto" value="create-drop" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/mysql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/mysql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/mysql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
+      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
+      <property name="hibernate.connection.url" value="@jdbc.mysql.url@" />
+      <property name="hibernate.connection.username" value="@jdbc.mysql.username@" />
+      <property name="hibernate.connection.password" value="@jdbc.mysql.password@" />
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/oracle.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/oracle.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/oracle.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,6 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
+      <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
+      <property name="hibernate.connection.url" value="@jdbc.oracle.url@" />
+      <property name="hibernate.connection.username" value="@jdbc.oracle.username@" />
+      <property name="hibernate.connection.password" value="@jdbc.oracle.password@" />
+      <property name="hibernate.query.substitutions" value="true 1, false 0" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/postgresql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/postgresql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/postgresql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
+      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
+      <property name="hibernate.connection.url" value="@jdbc.postgresql.url@" />
+      <property name="hibernate.connection.username" value="@jdbc.postgresql.username@" />
+      <property name="hibernate.connection.password" value="@jdbc.postgresql.password@" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/sybase.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/sybase.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/jdbc/sybase.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+      <property name="hibernate.dialect" value="org.hibernate.dialect.SybaseDialect" />
+      <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver" />
+      <property name="hibernate.connection.url" value="@jdbc.sybase.url@" />
+      <property name="hibernate.connection.username="@jdbc.sybase.username@" />
+      <property name="hibernate.connection.password" value="@jdbc.sybase.password@" />
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.definition.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.definition.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.definition.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,641 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.model" default-access="field">
+
+  <!-- ### PROCESS DEFINITION ############################################# -->
+  <class name="ProcessDefinitionImpl" table="JBPM_PROCESS">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_PROCDEF_PROPS"
+                 index="IDX_PROCDEF_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_PROCESS">
+        <column name="PROCESS_" index="IDX_EXHDLR_PROCESS"/>
+      </key>
+      <index column="PROCESS_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl"/>
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <property name="description" column="DESCR_" />
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_PROCESS">
+        <column name="PROCESS_" index="IDX_EVENT_PROCESS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl"/>
+    </map>
+
+    <!-- CompositeElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <list name="activities" cascade="all" inverse="false">
+      <key foreign-key="FK_ACTS_PROCESS">
+        <column name="ACTSPROCESS_" index="IDX_ACTS_PROCESS"/>
+      </key>
+      <list-index column="ACTSPROCESS_IDX_" />
+      <one-to-many class="ActivityImpl" />
+    </list>
+    <property name="hasVariableDefinitions" column="HAS_VAR_DEF_" />
+    <list name="variableDefinitions" cascade="all">
+      <key foreign-key="FK_VARDEF_PROCESS">
+        <column name="PROCESS_" index="IDX_VARDEF_PROCESS"/>
+      </key>
+      <index column="PROCESS_IDX_" />
+      <one-to-many class="VariableDefinitionImpl" />
+    </list>
+    <property name="hasTimerDefinitions" column="HAS_TIMER_DEF_" />
+    <set name="timerDefinitions" cascade="all">
+      <key foreign-key="FK_TMRDEF_PROCESS">
+        <column name="PROCESS_" index="IDX_TMRDEF_PROCESS"/>
+      </key>
+      <one-to-many class="TimerDefinitionImpl" />
+    </set>
+
+    <!-- ProcessDefinitionImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="key" column="KEY_" />
+    <property name="id" column="ID_" unique="true" />
+
+    <property name="packageName" column="PACKAGE_" />
+    <property name="version" column="VERSION_" />
+    <property name="deploymentTime" column="DEPLOYED_" />
+    <many-to-one name="initial" 
+                 column="INITIAL_"
+                 class="ActivityImpl"
+                 cascade="all" 
+                 foreign-key="FK_PROCDEF_INITIAL"
+                 index="IDX_PROCDEF_INIT"
+                 fetch="select" />
+
+    <map name="attachments" cascade="all-delete-orphan">
+      <key foreign-key="FK_LOB_PROCESS">
+        <column name="PROCESS_" index="IDX_LOB_PROCESS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.lob.Lob"/>
+    </map>
+  </class>
+
+  <!-- ### Activity ############################################################## -->
+  <class name="ActivityImpl" table="JBPM_ACTIVITY">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESS_" 
+                 foreign-key="FK_ACT_PROCESS"
+                 index="IDX_ACT_PROCESS" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_ACT_PROPS"
+                 index="IDX_ACT_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_ACT">
+        <column name="ACT_" index="IDX_EXHDLR_ACT"/>
+      </key>
+      <index column="ACT_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_ACT">
+        <column name="ACT_" index="IDX_EVENT_ACT" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl" />
+    </map>
+
+    <!-- CompositeElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <list name="activities" cascade="all" inverse="false">
+      <key column="PARENT_" foreign-key="none" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="ActivityImpl" />
+    </list>
+    <property name="hasVariableDefinitions" column="HAS_VAR_DEF_" />
+    <list name="variableDefinitions" cascade="all">
+      <key foreign-key="FK_VARDEF_ACT">
+        <column name="ACT_" index="IDX_VARDEF_ACT"/>
+      </key>
+      <index column="ACT_IDX_" />
+      <one-to-many class="VariableDefinitionImpl" />
+    </list>
+    <property name="hasTimerDefinitions" column="HAS_TIMER_DEF_" />
+    <set name="timerDefinitions" cascade="all">
+      <key foreign-key="FK_TMRDEF_ACT">
+        <column name="ACT_" index="IDX_TMRDEF_ACT"/>
+      </key>
+      <one-to-many class="TimerDefinitionImpl" />
+    </set>
+
+    <!-- ActivityImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="isLocalScope" column="LOCAL_SCOPE_" />
+    <property name="isExecutionAsync" column="EXEC_ASYNC_" />
+    <property name="isSignalAsync" column="SIGNAL_ASYNC_" />
+    <property name="isPreviousNeeded" column="PREV_NEEDED_" />
+
+    <many-to-one name="parentActivity" 
+                 column="PARENT_"
+                 class="ActivityImpl"
+                 cascade="all"
+                 foreign-key="FK_ACT_PARENT" 
+                 index="IDX_ACT_PARENT" />
+
+    <many-to-one name="defaultTransition"
+                 column="DEFTRANS_" 
+                 class="TransitionImpl"
+                 fetch="select"
+                 foreign-key="FK_ACT_DEFTRANS" 
+                 index="IDX_ACT_DEFTRANS" />
+
+    <list name="incomingTransitions" inverse="false">
+      <key column="DESTINATION_" />
+      <index column="IN_IDX_" />
+      <one-to-many class="TransitionImpl" />
+    </list>
+
+    <list name="outgoingTransitions" inverse="false" cascade="all">
+      <key column="SOURCE_" />
+      <index column="OUT_IDX_" />
+      <one-to-many class="TransitionImpl" />
+    </list>
+
+    <component name="behaviourReference" class="ObjectReference">
+      <many-to-one name="descriptor"
+                   column="BEHAV_DESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_NODE_BEHAV_DESCR"
+                   index="IDX_NODE_BEHAV_DESCR" />
+      <any name="object" id-type="long" cascade="all">
+        <!--  TODO: Specify names for classes -->
+        <!--        <meta-value value="bpel::activity" class="org.jbpm.pvm.bpel.BpelActivity"/> -->
+        <column name="BEHAV_CLASS_" />
+        <column name="BEHAV_ID_" />
+      </any>
+    </component>
+  </class>
+
+  <!-- ### TRANSITION ##################################################### -->
+  <class name="TransitionImpl" table="JBPM_TRANSITION">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESS_" 
+                 foreign-key="FK_TRANS_PROCDEF"
+                 index="IDX_TRANS_PROCDEF" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_TRANS_PROPS"
+                 index="IDX_TRANS_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_TRANS">
+        <column name="TRANSITION_" index="IDX_EXHDLR_TRANS" />
+      </key>
+      <index column="TRANSITION_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <property name="description" column="DESCR_" />
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_TRANS">
+        <column name="TRANSITION_" index="IDX_EVENT_TRANS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl" />
+    </map>
+    
+    <!-- TransitionImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <many-to-one name="source"
+                 column="SRC_" 
+                 class="ActivityImpl" 
+                 fetch="select" 
+                 foreign-key="FK_TRANS_SRC" 
+                 index="IDX_TRANS_SRC" />
+
+    <many-to-one name="destination"
+                 column="DEST_" 
+                 class="ActivityImpl" 
+                 fetch="select"
+                 cascade="all"
+                 foreign-key="FK_TRANS_DST" 
+                 index="IDX_TRANS_DST" />
+
+    <many-to-one name="conditionDescriptor" 
+                 column="COND_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_TRANS_COND"
+                 index="IDX_TRANS_COND" />
+                 
+    <!-- 
+    <many-to-one name="waitConditionDescriptor" 
+                 column="WAIT_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_TRANS_WAIT_DESCR" 
+                 index="IDX_TRANS_WAIT_DESCR" />
+    -->
+    
+    <property name="isTakeAsync" column="TAKEASYNC_" />
+  </class>
+
+  <!-- ### EVENT ########################################################## -->
+  <class name="EventImpl" table="JBPM_EVENT">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESSDEF_" 
+                 foreign-key="FK_EVENT_PROCDEF" 
+                 index="IDX_EVENT_PROCDEF" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_EVENT_PROPS"
+                 index="IDX_EVENT_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_EVENT">
+        <column name="EVENT_" index="IDX_EXHDLR_EVENT"/>
+      </key>
+      <index column="EVENT_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- EventImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <list name="listenerReferences" table="JBPM_OBJECTREFERENCES" cascade="all-delete-orphan">
+      <key foreign-key="FK_OBJECTREF_EVENT">
+        <column name="EVENT_" index="IDX_OBJREF_EVENT"/>
+      </key>
+      <list-index column="EVENT_IDX_" />
+      <one-to-many class="EventListenerReference" />
+    </list>
+  </class>
+  
+  <!-- ### EXCEPTION HANDLER ############################################## -->
+  <class name="ExceptionHandlerImpl" table="JBPM_EXCEPTHNDLR">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="exceptionClassName" column="EXCEPT_CLASS_" />
+    <property name="isTransactional" column="TRANSACT_" />
+    <property name="isRethrowMasked" column="RETHROW_MASKED_"/>
+    <property name="transitionName" column="TRANSITIONNAME_" />
+    <property name="activityName" column="NODENAME_" />
+    <list name="eventListenerReferences" 
+          inverse="false"
+          cascade="all-delete-orphan"
+          table="JBPM_OBJECTREFERENCES">
+      <key foreign-key="FK_OBJREF_EXHNDLR" not-null="false">
+        <column name="EXHNDLR_" index="IDX_OBJREF_EXHNDLR" />
+      </key>
+      <list-index column="EXHNDLR_IDX_" />
+      <one-to-many class="ObjectReference" />
+    </list>
+  </class>
+  
+  <!-- ### OBJECT REFERENCE ############################################### -->
+  <class name="ObjectReference" discriminator-value="objref" table="JBPM_OBJECTREF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="descriptor"
+                 column="OBJ_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_OBJREF_EVENT" 
+                 index="IDX_OBJREF_EVENT"/>
+    <any name="object" id-type="long" cascade="all">
+      <!--  TODO: Specify names for classes -->
+      <column name="OBJ_CLASS_" />
+      <column name="OBJ_ID_" />
+    </any>
+    <property name="expression" column="OBJ_EXPRESSION_"/>
+    <property name="expressionLanguage" column="OBJ_EXPRLANG_"/>
+    
+    <subclass name="EventListenerReference" discriminator-value="evtlis">
+      <property name="isPropagationEnabled" column="PROPAGATE_" />
+    </subclass>
+        
+  </class>
+
+  <!-- ### VARIABLE DEFINITION ############################################ -->
+  <class name="VariableDefinitionImpl" table="JBPM_VARIABLEDEF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="name" column="NAME_"/>
+    <property name="typeName" column="TYPE_"/>
+    
+    <property name="inVariableName" column="INVAR_" />
+    <property name="inExpression" column="INEXPR_" />
+    <many-to-one name="inDescriptor" 
+                 column="INDESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_VARDEF_INDES" 
+                 index="IDX_VARDEF_INDES"/>
+    <property name="outVariableName" column="OUTVAR_" />
+    <property name="outExpression" column="OUTEXPR_" />
+  </class>
+
+  <!-- ### TIMER DEFINITION ############################################### -->
+  <class name="TimerDefinitionImpl" table="JBPM_TIMERDEF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="dueDateDescription" column="DUEDATEDESCR_"/>
+    <property name="repeat" column="REPEAT_"/>
+    <property name="isExclusive" column="ISEXCL_"/>
+    <property name="retries" column="RETRIES_"/>
+    <property name="eventName" column="EVENT_"/>
+    <property name="signalName" column="SIGNAL_"/>
+    <property name="dueDate" column="DUEDATE_" type="timestamp"/>
+  </class>
+  
+  <!-- ### DESCRIPTORS #################################################### -->
+  <class name="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" table="JBPM_DESCRIPTOR" abstract="true"
+    discriminator-value="abstract">
+    <!--
+    byte     : ByteDescriptor 
+    string   : StringDescriptor
+    char     : CharacterDescriptor
+    class    : ClassDescriptor
+    double   : DoubleDescriptor
+    expr     : ExpressionDescriptor
+    float    : FloatDescriptor 
+    long     : LongDescriptor
+    int      : IntegerDescriptor
+    short    : ShortDescriptor
+    coll     : CollectionDescriptor 
+    map      : MapDescriptor
+    list     : ListDescriptor
+    set      : SetDescriptor
+    object   : ObjectDescriptor
+    ref      : ReferenceDescriptor
+    null     : NullDescriptor
+    true     : TrueDescriptor
+    false    : FalseDescriptor
+    provided : ProvidedObjectDescriptor
+    -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="name" column="NAME_" />
+    <property name="init" column="INIT_" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.NullDescriptor" discriminator-value="null_" />
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor" discriminator-value="true" />
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor" discriminator-value="false" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.StringDescriptor" discriminator-value="string">
+      <property name="text" column="TEXT_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.CharacterDescriptor" discriminator-value="char">
+      <property name="text" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor" discriminator-value="class">
+      <property name="text" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor" discriminator-value="ref">
+      <property name="text" column="TEXT_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.DoubleDescriptor" discriminator-value="double">
+      <property name="doubleVal" column="DOUBLEVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.FloatDescriptor" discriminator-value="float">
+      <property name="doubleVal" column="DOUBLEVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.LongDescriptor" discriminator-value="long">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor" discriminator-value="int">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ShortDescriptor" discriminator-value="short">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ByteDescriptor" discriminator-value="byte">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor" discriminator-value="coll">
+      <property name="className" column="CLASSNAME_" />
+      <list name="valueDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_DESCR_VALDESCR">
+          <column name="VALUEDESCR_" index="IDX_DESCR_VALDESCR" />
+        </key>
+        <list-index column="VALUEDESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+      </list>
+
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.MapDescriptor" discriminator-value="map">
+        <list name="keyDescriptors" cascade="all-delete-orphan">
+          <key column="KEYDESCR_" foreign-key="FK_DESCR_KEYDESCR" />
+          <list-index column="KEYDESCR_IDX_" />
+          <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+        </list>
+      </subclass>
+
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor" discriminator-value="list" />
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.SetDescriptor" discriminator-value="set" />
+    </subclass>
+
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor" discriminator-value="object">
+      <property name="className" column="TEXT_" />
+      <property name="methodName" column="METHOD_" />
+      <property name="isAutoWireEnabled" column="BOOLVAL_" />
+      <property name="factoryObjectName" column="FACTORYNAME_" />
+
+      <many-to-one name="factoryDescriptor" class="AbstractDescriptor" column="FACTORYDESCR_"
+        foreign-key="FK_DESCR_ARG_REF" index="IDX_DESCR_ARG_REF" cascade="all" />
+
+      <list name="argDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_OBJARG_DESCR">
+          <column name="OBJARG_DESCR_" index="IDX_OBJARG_DESCR" />
+        </key>
+        <list-index column="OBJARG_DESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" />
+      </list>
+
+      <list name="operations" cascade="all-delete-orphan">
+        <key foreign-key="FK_OBJOPER_DESCR">
+          <column name="OBJOPER_DESCR_" index="IDX_OBJOPER_DESCR" />
+        </key>
+        <list-index column="OBJOPER_DESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.operation.AbstractOperation" />
+      </list>
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ExpressionDescriptor" discriminator-value="expr">
+      <property name="expr" column="TEXT_" />
+      <property name="lang" column="METHOD_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor" discriminator-value="provided">
+      <any name="providedObject" id-type="long" cascade="all">
+        <column name="TEXT_" />
+        <column name="LONGVAL_" />
+      </any>
+      <property name="exposeType" column="BOOLVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.EnvDescriptor" discriminator-value="env">
+      <property name="objectName" column="TEXT_" />
+      <property name="typeName" column="CLASSNAME_" />
+    </subclass>
+
+  </class>
+
+  <!-- ### OPERATIONS ##################################################### -->
+  <class name="org.jbpm.pvm.internal.wire.operation.AbstractOperation" abstract="true"
+    table="JBPM_OPERATION" discriminator-value="oper">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.FieldOperation"
+      discriminator-value="field">
+      <property name="fieldName" column="TEXT_" />
+      <many-to-one name="descriptor" column="DESCR_" cascade="all" 
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+        foreign-key="FK_OPER_DESC" index="IDX_OPER_DESC" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.PropertyOperation"
+      discriminator-value="prop">
+      <property name="setterName" column="TEXT_" />
+      <many-to-one name="descriptor" column="DESCR_" cascade="all" 
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.InvokeOperation"
+      discriminator-value="invoke">
+      <property name="methodName" column="TEXT_" />
+      <list name="argDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_ARGDSCR_OPER">
+          <column name="OPER_" index="IDX_ARGDSCR_OPER" />
+        </key>
+        <list-index column="OPER_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" />
+      </list>
+    </subclass>
+  </class>
+
+  <!-- ### ARG DESCRIPTOR ################################################# -->
+  <class name="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" table="JBPM_ARGDESCRIPTOR">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="typeName" column="TYPENAME_" />
+    <many-to-one name="descriptor" column="DESCRIPTOR_" 
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+      foreign-key="FK_ARGDESCR_DESCR" index="IDX_ARGDESCR_DESCR" cascade="all" />
+  </class>
+
+  <!-- ### PROPERTIES ##################################################### -->
+  <class name="org.jbpm.pvm.internal.model.WireProperties" table="JBPM_WIREPROPS">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <component name="wireContext" class="org.jbpm.pvm.internal.wire.WireContext">
+      <component name="wireDefinition" class="org.jbpm.pvm.internal.wire.WireDefinition">
+        <map name="descriptors" cascade="all-delete-orphan" lazy="false">
+          <key foreign-key="FK_DESCR_PROPS">
+            <column name="PROPS_" index="IDX_DESCR_PROPS" />
+          </key>
+          <map-key type="string" column="NAME_" />
+          <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+        </map>
+      </component>
+    </component>
+  </class>
+  
+  
+  <!-- ### QUERIES ######################################################## -->
+  
+  <query name="findProcessDefinitionKeys">
+    <![CDATA[
+     select distinct process.key
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     order by process.key asc
+    ]]>
+  </query>
+
+  <query name="findProcessDefinitionsByKey">
+    <![CDATA[
+     select process
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.key = :key
+     order by process.version desc    
+    ]]>
+  </query>
+
+  <query name="findProcessDefinitionById">
+    <![CDATA[
+     select process
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.id = :id
+    ]]>
+  </query>
+  
+  <query name="findProcessDefinitionKeysByName">
+    <![CDATA[
+     select process.key
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.name = :name
+    ]]>
+  </query>
+  
+  <query name="findProcessDefinitionNamesByKey">
+    <![CDATA[
+     select process.name
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.key = :key
+    ]]>
+  </query>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.execution.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.execution.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,379 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.model" default-access="field">
+
+  <!-- ### PROCESS DEFINITION ############################################# -->
+  <class name="ExecutionImpl" table="JBPM_EXECUTION">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <many-to-one name="activity" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="ACT_"
+                 lazy="false"
+                 foreign-key="FK_EXEC_ACT"
+                 index="IDX_EXEC_ACT" />
+
+    <property name="hasVariables" column="HASVARS_" />
+    <map name="variables"
+         cascade="all-delete-orphan"
+         table="JBPM_VARIABLE">
+      <key foreign-key="FK_VAR_EXECUTION">
+         <column name="EXECUTION_" index="IDX_VAR_EXECUTION"/>
+      </key>
+      <map-key type="string" column="KEY_" />
+      <one-to-many class="org.jbpm.pvm.internal.type.Variable" />
+    </map>
+    
+    <property name="hasTimers" column="HASTIMERS_" />
+    <set name="timers"
+         cascade="all-delete-orphan">
+      <key foreign-key="FK_TMR_EXECUTION">
+         <column name="EXECUTION_" />
+      </key>
+      <one-to-many class="org.jbpm.pvm.internal.job.TimerImpl" />
+    </set>
+
+    <property name="name" column="NAME_" />
+    <property name="key" column="KEY_" />
+    <property name="id" column="ID_" unique="true" />
+
+    <property name="state" column="STATE_" />
+
+    <property name="priority" column="PRIORITY_" />
+    <property name="historyActivityInstanceDbid" column="HISACTINST_" />
+
+    <many-to-one name="processDefinition"
+                 class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" 
+                 column="PROCESS_"
+                 foreign-key="FK_EXEC_PROCESS" 
+                 index="IDX_EXEC_PROCESS" />
+
+    <many-to-one name="transition" column="TRANSITION_" class="TransitionImpl" />
+
+    <many-to-one name="transitionOrigin" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="TRANSORIG_"
+                 foreign-key="FK_EXEC_TRANSORIG"
+                 index="IDX_EXEC_TRANSORIG" />
+
+    <list name="executions" 
+          cascade="all-delete-orphan"
+          inverse="false">
+      <key column="PARENT_" foreign-key="FK_EXEC_PARENT" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="ExecutionImpl" />
+    </list>
+
+    <many-to-one name="parent"
+                 column="PARENT_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_PARENT"
+                 index="IDX_EXEC_PARENT" />
+
+    <many-to-one name="processInstance"
+                 class="ExecutionImpl" 
+                 column="INSTANCE_"
+                 foreign-key="FK_EXEC_INSTANCE"
+                 index="IDX_EXEC_INSTANCE" />
+
+    <many-to-one name="superProcessExecution"
+                 column="SUPEREXEC_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUPEREXEC"
+                 index="IDX_EXEC_SUPEREXEC" />
+  </class>
+
+  <!-- ### COMMENTS ####################################################### -->
+  <class name="CommentImpl" table="JBPM_COMMENT">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="userId" column="USERID_" />
+    <property name="time" column="TIME_" />
+    <property name="message" column="MESSAGE_" />
+
+    <list name="comments" 
+          cascade="all-delete-orphan"
+          inverse="false">
+      <key column="PARENT_" foreign-key="none" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="CommentImpl" />
+    </list>
+  </class>
+  
+  <!-- ### VARIABLE ####################################################### -->
+  
+  <typedef name="converter" class="org.jbpm.pvm.internal.hibernate.ConverterType">
+    <param name="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter"    >bool-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.ByteToLongConverter"         >byte-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter"  >char-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DateToLongConverter"         >date-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DateToStringConverter"       >date-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DoubleToStringConverter"     >double-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter"      >float-double</param>
+    <param name="org.jbpm.pvm.internal.type.converter.FloatToStringConverter"      >float-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter"      >int-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter">ser-bytes</param>
+    <param name="org.jbpm.pvm.internal.type.converter.ShortToLongConverter"        >short-long</param>
+  </typedef>
+  
+  
+  <class name="org.jbpm.pvm.internal.type.Variable" abstract="true" discriminator-value=" " table="JBPM_VARIABLE">
+    <!-- discriminator values:
+    date   : org.jbpm.pvm.internal.type.variable.DateVariable
+    double : org.jbpm.pvm.internal.type.variable.DoubleVariable
+    hibl   : org.jbpm.pvm.internal.type.variable.HibernateLongVariable
+    long   : org.jbpm.pvm.internal.type.variable.LongVariable
+    hibs   : org.jbpm.pvm.internal.type.variable.HibernateStringVariable
+    string : org.jbpm.pvm.internal.type.variable.StringVariable
+    null   : org.jbpm.pvm.internal.type.variable.NullVariable
+    blob   : org.jbpm.pvm.internal.type.variable.BlobVariable
+    clob   : org.jbpm.pvm.internal.type.variable.ClobVariable
+    -->
+  
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="key" column="KEY_"/>
+    <property name="queryText" column="QUERYTEXT_" />
+    <property name="converter" type="converter" column="CONVERTER_" />
+    <many-to-one name="processInstance"
+                 column="PROCINST_" 
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"
+                 foreign-key="FK_VAR_PROCINST"
+                 index="IDX_VAR_PROCINST"/>
+  </class>
+
+  <subclass name="org.jbpm.pvm.internal.type.variable.DateVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="T">
+    <property name="date" column="DATE_VALUE_" type="timestamp"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.DoubleVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="D">
+    <property name="d" column="DOUBLE_VALUE_" type="double"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="l">
+    <property name="hibernatable" column="LONG_VALUE_" type="long"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.LongVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="L">
+    <property name="l" column="LONG_VALUE_" type="long"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="s">
+    <property name="hibernatable" column="STRING_VALUE_" type="string"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.StringVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="S">
+    <property name="string" column="STRING_VALUE_" type="string"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.NullVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="N">
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.BlobVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="B">
+    <many-to-one name="lob"
+                 column="LOB_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.lob.Lob"
+                 foreign-key="FK_VAR_LOB"
+                 index="IDX_VAR_LOB" />
+  </subclass>
+
+  <subclass name="org.jbpm.pvm.internal.type.variable.ClobVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="C">
+    <many-to-one name="lob"
+                 column="LOB_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.lob.Lob"
+                 foreign-key="none"/>
+  </subclass>
+  
+  <!-- ### LOB ############################################################ -->
+  <class name="org.jbpm.pvm.internal.lob.Lob" table="JBPM_LOB">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="blob" type="blob" column="BLOB_VALUE_" />
+    <property name="bytes" type="binary" column="BINARY_VALUE_"/>
+    <property name="clob" type="clob" column="CLOB_VALUE_" />
+    <property name="text" type="text" column="TEXT_VALUE_"/>
+  </class>
+  
+    <class name="org.jbpm.pvm.internal.job.JobImpl" table="JBPM_JOB" discriminator-value="Job">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="dueDate" column="DUEDATE_" type="timestamp" index="IDX_JOBDUEDATE"  />
+    <property name="isSuspended" column="ISSUSPENDED_" />
+    <property name="isExclusive" column="ISEXCLUSIVE_" />
+    <property name="lockOwner" column="LOCKOWNER_" />
+    <property name="lockExpirationTime" column="LOCKEXPTIME_" index="IDX_JOBLOCKEXP" />
+    <property name="info" column="INFO_" />
+    <property name="exception" column="EXCEPTION_" type="text" />
+    <property name="retries" column="RETRIES_" index="IDX_JOBRETRIES" />
+    
+    <many-to-one name="processInstance"   
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"   
+                 column="PROCESSINSTANCE_" 
+                 cascade="none"
+                 foreign-key="FK_JOB_PRINST"
+                 index="IDX_JOB_PRINST"/>
+    <many-to-one name="execution"
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"   
+                 column="EXECUTION_" 
+                 cascade="none"
+                 foreign-key="FK_JOB_EXE"
+                 index="IDX_JOB_EXE"/>
+    <many-to-one name="commandDescriptor"
+                 column="CMDDESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" 
+                 cascade="all"
+                 foreign-key="FK_JOB_CMDDESCR"
+                 index="IDX_JOB_CMDDESCR"/>
+
+    <subclass name="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="Msg">
+      <subclass name="org.jbpm.pvm.internal.model.op.ExecuteActivityMessage" discriminator-value="ExeActivityMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.SignalMessage" discriminator-value="SignalMsg">
+        <property name="signalName" column="SIGNAL_" />
+        <many-to-one name="activity"   
+                     column="NODE_" 
+                     cascade="none"
+                     foreign-key="FK_JOB_NODE"/>
+      </subclass>
+      <subclass name="org.jbpm.pvm.internal.model.op.TakeTransitionMessage" discriminator-value="TakeTrMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.ProceedToDestinationMessage" discriminator-value="ProceedDestMsg" />
+      <subclass name="org.jbpm.pvm.internal.job.CommandMessage" discriminator-value="CmdMsg" />
+    </subclass>
+    
+    <subclass name="org.jbpm.pvm.internal.job.TimerImpl" discriminator-value="Timer">
+      <property name="signalName" column="SIGNAL_" />
+      <property name="eventName" column="EVENT_" />
+      <property name="repeat" column="REPEAT_" />
+    </subclass>
+     
+  </class>
+
+  <!-- ### HibernatePvmDbSession QUERIES ################################## -->
+
+  <query name="findTimers">
+    <![CDATA[
+     select t
+     from org.jbpm.pvm.internal.job.TimerImpl as t
+     order by dueDate asc
+    ]]>
+  </query>
+
+  <query name="findMessages">
+    <![CDATA[
+     select m
+     from org.jbpm.pvm.internal.job.MessageImpl as m
+    ]]>
+  </query>
+
+  <query name="findJobsWithException">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.retries = 0 
+     order by dueDate asc
+    ]]>
+  </query>
+
+  <!-- ### HibernateJobDbSession QUERIES ################################## -->
+
+  <query name="findFirstAcquirableJob">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where ( ( (job.lockExpirationTime is null)
+               or (job.lockExpirationTime <= :now) 
+             )
+             and 
+             ( (job.dueDate is null)
+               or (job.dueDate <= :now) 
+             ) 
+             and 
+             ( job.retries > 0 ) 
+           )
+     order by job.dueDate asc
+    ]]>
+  </query>
+
+  <query name="findExclusiveJobs">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.lockOwner is null
+       and job.processInstance = :processInstance 
+       and job.isExclusive = true 
+       and job.retries > 0 
+       and ( (job.dueDate is null)
+             or (job.dueDate <= :now) 
+           )
+     order by job.dueDate asc
+    ]]>
+  </query>
+  
+  <query name="findFirstDueJob">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.lockOwner is null
+       and job.retries > 0 
+     order by job.dueDate asc
+    ]]>
+  </query>
+  
+
+  <!-- ### HibernatePvmDbSession QUERIES ############################################# -->
+
+  <query name="findExecutionById">
+    <![CDATA[
+     select execution
+     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
+     where execution.id = :id
+    ]]>
+  </query>
+
+  <query name="findProcessInstanceById">
+    <![CDATA[
+     select processInstance
+     from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+     where processInstance.id = :processInstanceId
+       and processInstance.parent is null
+    ]]>
+  </query>
+
+  <query name="findExecutionByKey">
+    <![CDATA[
+     select execution
+     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
+     where execution.key = :executionKey
+       and execution.processDefinition.name = :processDefinitionName
+    ]]>
+  </query>
+  
+  <query name="findProcessInstanceIds">
+    <![CDATA[
+     select processInstance.id
+     from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+     where processInstance.processDefinition.id = :processDefinitionId
+       and processInstance.parent is null
+    ]]>
+  </query>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.history.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.history.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.history.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.history.model" default-access="field">
+
+  <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+  <class name="HistoryProcessInstanceImpl" table="JBPM_HIST_PROCINST">
+    <id name="processInstanceId" column="ID_">
+      <generator class="assigned" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="processDefinitionId" column="PROCDEFID_" />
+    <property name="key" column="KEY_" />
+    <property name="startTime" column="START_" type="timestamp" />
+    <property name="endTime" column="END_" type="timestamp" />
+    <property name="duration" column="DURATION_" />
+    <property name="state" column="STATE_" />
+    <property name="endActivityName" column="ENDACTIVITY_" />
+
+    <many-to-one name="processDefinition" 
+                 class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" 
+                 column="PROCDEF_"
+                 foreign-key="FK_HISTPI_PROCDEF"
+                 index="IDX_HISTPI_PROCDEF" />
+                 
+    <set name="historyActivityInstances"
+         cascade="all">
+      <key>
+         <column name="HPI_" />
+      </key>
+      <one-to-many class="HistoryActivityInstanceImpl" />
+    </set>
+                 
+  </class>
+
+  <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+  <class name="HistoryActivityInstanceImpl" table="JBPM_HIST_ACTINST" discriminator-value="ACT">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <many-to-one name="historyProcessInstance" 
+                 class="HistoryProcessInstanceImpl" 
+                 column="HPI_"
+                 foreign-key="FK_HAI_HPI"
+                 index="IDX_HAI_HPI" />
+
+    <many-to-one name="activity" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="ACTIVITY_"
+                 foreign-key="FK_HISTAI_ACT"
+                 index="IDX_HISTAI_ACT" />
+
+    <property name="executionId" column="EXECUTION_" />
+    <property name="activityName" column="ACTIVITY_NAME_" />
+    <property name="startTime" column="START_" type="timestamp" />
+    <property name="endTime" column="END_" type="timestamp" />
+    <property name="duration" column="DURATION_" />
+    <property name="transitionName" column="TRANSITION_" />
+
+    <subclass name="HistoryAutomaticInstanceImpl" discriminator-value="AUT">
+      <subclass name="HistoryExclusiveInstanceImpl" discriminator-value="EXCL" />
+    </subclass>
+    
+    <subclass name="HistoryTaskInstanceImpl" discriminator-value="TASK">
+      <property name="assignee" column="ASSIGNEE_" />
+    </subclass>
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.jpdl.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.jpdl.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlProcessDefinition" table="JBPM_JPDL_PROCDEF"  extends="org.jbpm.pvm.internal.model.ProcessDefinitionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlExecution" table="JBPM_JPDL_EXECUTION" extends="org.jbpm.pvm.internal.model.ExecutionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <class name="org.jbpm.jpdl.internal.activity.JpdlActivity" table="JBPM_JPDL_ACTIVITY"  abstract="true" discriminator-value="X">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <subclass name="org.jbpm.jpdl.internal.activity.StartActivity" discriminator-value="start" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveConditionActivity" discriminator-value="excl-cond" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveExpressionActivity" discriminator-value="excl-expr">
+      <property name="expr" column="TEXT_" />
+      <property name="lang" column="TEXT2_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler">
+      <property name="exclusiveHandlerName" column="TEXT_" />
+      <many-to-one name="exclusiveHandlerDescriptor"
+                   column="EXCLDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_EXCLDESCR"
+                   index="IDX_ACT_EXCLDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.StateActivity" discriminator-value="state" />
+    <subclass name="org.jbpm.jpdl.internal.activity.EndActivity" discriminator-value="end">
+      <property name="endProcessInstance" column="ENDPI_" />
+      <property name="state" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ForkActivity" discriminator-value="fork" />
+    <subclass name="org.jbpm.jpdl.internal.activity.JoinActivity" discriminator-value="join" />
+    <subclass name="org.jbpm.jpdl.internal.activity.HqlActivity" discriminator-value="hql">
+      <property name="query" column="TEXT_" />
+      <property name="resultVariableName" column="TEXT2_" />
+      <property name="isResultUnique" column="ISUNIQ_" />
+      <many-to-one name="parametersDescriptor"
+                   column="PARAMDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+                   foreign-key="FK_ACT_PARAMDESCR"
+                   index="IDX_ACT_PARAMDESCR" />
+      
+      <subclass name="org.jbpm.jpdl.internal.activity.SqlActivity" discriminator-value="sql" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.JavaActivity" discriminator-value="java">
+      <property name="methodName" column="TEXT_" />
+      <property name="variableName" column="TEXT2_" />
+      <many-to-one name="descriptor"
+                   column="JAVADESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_JAVADESCR"
+                   index="IDX_ACT_JAVADESCR" />
+      <many-to-one name="invokeOperation"
+                   column="INVOPER_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.operation.InvokeOperation"
+                   foreign-key="FK_ACT_INVKOPER"
+                   index="IDX_ACT_INVKOPER" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ScriptActivity" discriminator-value="script">
+      <property name="script" column="TEXT_" />
+      <property name="language" column="TEXT2_" />
+      <property name="variableName" column="TEXT3_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.EsbActivity" discriminator-value="esb">
+      <property name="service" column="TEXT_" />
+      <property name="category" column="TEXT2_" />
+      <many-to-one name="partsListDescriptor"
+               column="PARTSDESCR_" 
+               cascade="all"
+               class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+               foreign-key="FK_ACT_PARTSDESCR"
+               index="IDX_ACT_PARTSDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.TaskActivity" discriminator-value="task">
+      <property name="assignee" column="TEXT_" />
+    </subclass>
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.task.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.files/jbpm.task.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,174 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping auto-import="false" package="org.jbpm.pvm.internal.task" default-access="field">
+
+  <!-- ### TASK DEFINITION ################################################ -->
+  <class name="TaskDefinitionImpl" discriminator-value="T">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator type="char" column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+
+    <property name="priority" column="PRIORITY_"/>
+    <property name="dueDateDuration" column="DUEDATE_"/>
+    <property name="isBlocking" column="BLOCK_"/>
+    <property name="isSignalling" column="SIGNAL_"/>
+    <property name="assigneeExpression" column="ASSIGNEE_EXPR_"/>
+    <property name="candidatesExpression" column="CANDIDATES_EXPR_"/>
+
+    <many-to-one name="assignerDescriptor"
+                 column="ASSIGNER_DESCR_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 foreign-key="FK_TSK_ASIG_DESCR"
+                 index="IDX_TSK_ASIG_DESCR" />
+
+    <many-to-one name="swimlaneDefinition"
+                 column="SWIMLANE_DEF_" 
+                 cascade="all"
+                 class="SwimlaneDefinitionImpl"
+                 foreign-key="FK_TSK_SWIML_DEF"
+                 index="IDX_TSK_SWIML_DEF" />
+
+		<list name="subTaskDefinitions" cascade="all-delete-orphan">
+			<key column="TASKDEF_" />
+			<list-index column="TASKDEF_IDX_" />
+			<one-to-many class="TaskDefinitionImpl" />
+		</list>
+  </class>
+  
+  <!-- ### TASK ########################################################### -->
+  <class name="TaskImpl" 
+         discriminator-value="T">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator type="char" column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="id" column="ID_" unique="true" />
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+    <property name="assignee" column="ASSIGNEE_"/>
+    
+    <set name="participants" cascade="all-delete-orphan">
+      <key column="TASK_" />
+      <one-to-many class="ParticipantImpl" />
+    </set>
+    
+    <property name="priority" column="PRIORITY_"/>
+    <property name="create" column="CREATE_"/>
+    <property name="dueDate" column="DUEDATE_"/>
+    <property name="progress" column="PROGRESS_"/>
+    
+    <!-- 
+    <many-to-one name="variableMap"
+                 class="org.jbpm.pvm.impl.VariableMap" 
+                 column="VARMAP_" 
+                 foreign-key="FK_TASK_VARMAP"
+                 cascade="all" />
+    -->
+
+    <many-to-one name="superTask"
+                 class="TaskImpl" 
+                 column="SUPERTASK_" 
+                 foreign-key="FK_TASK_SUPERTASK" 
+                 index="IDX_TASK_SUPERTASK" />
+
+    <many-to-one name="execution"
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl" 
+                 column="EXECUTION_" 
+                 foreign-key="FK_TASK_EXEC" />
+
+    <many-to-one name="swimlane"
+                 class="SwimlaneImpl" 
+                 column="SWIMLANE_" 
+                 foreign-key="FK_TASK_SWIML" />
+
+		<list name="comments" cascade="all-delete-orphan">
+			<key column="TASK_" />
+			<list-index column="TASK_IDX_" />
+			<one-to-many class="org.jbpm.pvm.internal.model.CommentImpl" />
+		</list>
+
+    <set name="subTasks" cascade="all-delete-orphan">
+      <key column="SUPERTASK_" />
+      <one-to-many class="TaskImpl" />
+    </set>
+    
+  </class>
+  
+  <!-- ### PARTICIPANT #################################################### -->
+  <class name="ParticipantImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="identityType" column="IDENTITYTYPE_"/>
+    <property name="identityId" column="IDENTITYID_"/>
+    <property name="participation" column="PARTICIPATION_" />
+
+    <many-to-one name="task"
+                 class="TaskImpl" 
+                 column="TASK_" 
+                 index="IDX_PART_TASK"
+                 foreign-key="FK_PART_TASK" />
+
+    <many-to-one name="swimlane"
+                 class="SwimlaneImpl" 
+                 column="SWIMLANE_" 
+                 foreign-key="FK_PART_SWIMLANE" />
+
+  </class>
+  
+  <!-- ### SWIMLANE DEFINITION ############################################ -->
+  <class name="SwimlaneDefinitionImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="name" column="NAME_"/>
+  </class>
+
+
+  <!-- ### SWIMLANE ####################################################### -->
+  <class name="SwimlaneImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="name" column="NAME_"/>
+    <property name="assignee" column="ASSIGNEE_"/>
+
+    <many-to-one name="swimlaneDefinition"
+                 class="SwimlaneDefinitionImpl" 
+                 column="SWIMLANEDEF_" 
+                 foreign-key="FK_SWIMLANE_DEF" />
+
+    <set name="participants" cascade="all-delete-orphan">
+      <key column="SWIMLANE_" />
+      <one-to-many class="ParticipantImpl" />
+    </set>
+    
+  </class>
+  
+  
+  <!-- ### QUERIES ######################################################## -->
+
+  <query name="findTasks">
+    <![CDATA[
+     select task
+     from org.jbpm.pvm.internal.task.TaskImpl as task
+    ]]>
+  </query>
+
+</hibernate-mapping>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.exclude.xml
===================================================================

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.include.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.include.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/jpdl.include.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+      <mapping resource="jbpm.jpdl.hbm.xml" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/pvm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/pvm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/mapping.references/pvm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+      <mapping resource="jbpm.definition.hbm.xml" />
+      <mapping resource="jbpm.execution.hbm.xml" />
+      <mapping resource="jbpm.history.hbm.xml" />
+      <mapping resource="jbpm.task.hbm.xml" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.exclude.xml
===================================================================

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.include.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.include.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/hibernate/other/format.sql.include.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+      <property name="hibernate.format_sql" value="true" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part1.persistence.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part1.persistence.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part1.persistence.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+             http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+             version="1.0">
+
+  <persistence-unit name="jboss-identity-jbpm" transaction-type="RESOURCE_LOCAL">
+
+    <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
+
+    <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    
+    <properties>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part2.persistence.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part2.persistence.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/META-INF/part2.persistence.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+    </properties>
+
+  </persistence-unit>
+
+</persistence>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/jbpm.identity.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/jbpm.identity.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/identity/jbpm.identity.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
+                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
+  <realms>
+    <realm>
+      <id>realm://jbpm-identity</id>
+      <repository-id-ref>jBPM Identity DB</repository-id-ref>
+      <identity-type-mappings>
+        <identity-mapping>IDENTITY</identity-mapping>
+      </identity-type-mappings>
+    </realm>
+  </realms>
+
+  <repositories>
+    <repository>
+      <id>jBPM Identity DB</id>
+      <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+      <external-config/>
+      <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+      <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+      <options>
+        <option>
+          <name>allowNotDefinedAttributes</name>
+          <value>true</value>
+        </option>
+      </options>
+    </repository>
+  </repositories>
+
+  <stores>
+    <attribute-stores/>
+    <identity-stores>
+      <identity-store>
+        <id>Hibernate Identity Store</id>
+        <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+        <external-config/>
+        <supported-relationship-types>
+          <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+          <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+        </supported-relationship-types>
+        <supported-identity-object-types>
+          <identity-object-type>
+            <name>IDENTITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>OFFICE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>SECURITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>PROJECT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>PEOPLE</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials>
+              <credential-type>PASSWORD</credential-type>
+            </credentials>
+            <attributes>
+              <attribute>
+                <name>picture</name>
+                <mapping>user.picture</mapping>
+                <type>binary</type>
+                <isRequired>false</isRequired>
+                <isMultivalued>false</isMultivalued>
+                <isReadOnly>false</isReadOnly>
+              </attribute>
+            </attributes>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ORGANIZATION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DIVISION</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ORGANIZATION_UNIT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DIVISION</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>OFFICE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>PEOPLE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>PROJECT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>DIVISION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>DEPARTMENT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>PROJECT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>PEOPLE</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ADMINISTRATION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>COMMUNITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>OFFICE</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>SECURITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>SYSTEM</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>SECURITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+        </supported-identity-object-types>
+        <options>
+          <option>
+            <name>persistenceUnit</name>
+            <value>jboss-identity-jbpm</value>
+          </option>
+          <option>
+            <name>populateRelationshipTypes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>populateIdentityObjectTypes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>allowNotDefinedAttributes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>isRealmAware</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>allowNotDefinedAttributes</name>
+            <value>true</value>
+          </option>
+        </options>
+      </identity-store>
+    </identity-stores>
+  </stores>
+</jboss-identity>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-hsqldb-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-hsqldb-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-hsqldb-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+<?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@/@jbpm4DB</connection-url>    
+    <driver-class>org.hsqldb.jdbcDriver</driver-class>
+    <user-name>sa</user-name>
+    <password></password>
+
+    <!-- connection pool parameters -->
+    <min-pool-size>1</min-pool-size>
+    <max-pool-size>5</max-pool-size>
+
+    <!-- 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 -->
+    <metadata>
+      <type-mapping>Hypersonic SQL</type-mapping>
+    </metadata>
+
+    <!-- ensure the datasource is not initialized before the database itself -->
+    <depends>jboss:service=Hypersonic,database=jbpm4DB</depends>
+  </local-tx-datasource>
+
+  <mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=Hypersonic,database=jbpm4DB">
+    <attribute name="Database">jbpm4DB</attribute>
+    <attribute name="InProcessMode">true</attribute>
+  </mbean>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-mysql-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-mysql-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-mysql-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+
+    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+    <xa-datasource-property name="ServerName">@jdbc.mysql.server@</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">@jdbc.mysql.port@</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">@jdbc.mysql.database@</xa-datasource-property>
+    <user-name>@jdbc.mysql.username@</user-name>
+    <password>@jdbc.mysql.password@</password>
+
+    <!-- reduce isolation from the default level (repeatable read) -->
+    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
+    <!-- separate connections used with and without JTA transaction -->
+    <no-tx-separate-pools />
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <!-- leverage mysql integration features -->
+    <exception-sorter-class-name>
+      com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
+    </exception-sorter-class-name>
+    <valid-connection-checker-class-name>
+      com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
+    </valid-connection-checker-class-name>
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>mySQL</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-oracle-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-oracle-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-oracle-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  JBoss Server Configuration                                           -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: jbpm-oracle-ds.xml 4070 2009-02-27 16:29:03Z tom.baeyens at jboss.com $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION:  DO NOT FORGET TO SET Pad=true IN transaction-service.xml  -->
+<!-- ===================================================================== -->
+
+<datasources>
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+    <!-- uncomment to enable interleaving <interleaving/> -->
+    <isSameRM-override-value>false</isSameRM-override-value>
+    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+    <xa-datasource-property name="URL">@jdbc.oracle.url@</xa-datasource-property>
+    <xa-datasource-property name="User">@jdbc.oracle.username@</xa-datasource-property>
+    <xa-datasource-property name="Password">@jdbc.oracle.password@</xa-datasource-property>
+    <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+    <!-- Checks the Oracle error codes and messages for fatal errors -->
+    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+    <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+    <no-tx-separate-pools/>
+
+      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+      <metadata>
+         <type-mapping>Oracle9i</type-mapping>
+      </metadata>
+  </xa-datasource>
+
+  <mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" 
+         name="jboss.jca:service=OracleXAExceptionFormatter">
+    <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
+  </mbean>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-postgresql-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-postgresql-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-postgresql-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+
+    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+    <xa-datasource-property name="ServerName">@jdbc.postgresql.server@</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">@jdbc.postgresql.port@</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">@jdbc.postgresql.database@</xa-datasource-property>
+    <user-name>@jdbc.postgresql.username@</user-name>
+    <password>@jdbc.postgresql.password@</password>
+
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>PostgreSQL 8.0</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-sybase-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-sybase-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jboss/datasource/jbpm-sybase-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+    
+    <xa-datasource-class>@jdbc.sybase.datasource@</xa-datasource-class>
+    <xa-datasource-property name="ServerName">@jdbc.sybase.server@</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">@jdbc.sybase.port@</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">@jdbc.sybase.database@</xa-datasource-property>
+    <user-name>@jdbc.sybase.username@</user-name>
+    <password>@jdbc.sybase.password@</password>
+
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <exception-sorter-class-name>
+      org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter
+    </exception-sorter-class-name>
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>Sybase</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cache.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cache.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cache.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+<hibernate-cache>
+
+  <class-cache class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ActivityImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.TransitionImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.EventImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ExceptionHandlerImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ObjectReference" />
+  <class-cache class="org.jbpm.pvm.internal.model.VariableDefinitionImpl" />
+  <class-cache class="org.jbpm.pvm.internal.model.TimerDefinitionImpl" />
+  <class-cache class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.events" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.activities" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.variableDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.timerDefinitions" />
+  <collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.attachments" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.events" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.activities" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.variableDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.timerDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.incomingTransitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.outgoingTransitions" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.TransitionImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.TransitionImpl.events" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.EventImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.EventImpl.listenerReferences" />
+	  
+	<collection-cache collection="org.jbpm.pvm.internal.model.ExceptionHandlerImpl.eventListenerReferences" />
+
+  <collection-cache collection="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.argDescriptors" />
+  <collection-cache collection="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.operations" />
+	
+</hibernate-cache>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <process-service />
+    <execution-service />
+    <history-service />
+    <management-service />
+    <identity-service />
+    <task-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration cfg="jbpm.hibernate.cfg.xml">     
+      <cache-configuration resource="jbpm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+
+    <hibernate-session-factory />
+
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+
+    <script-manager default-expression-language="juel"
+                    default-script-language="juel"
+                    read-contexts="execution, environment, process-engine"
+                    write-context="">
+        <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+    </script-manager>
+
+    <job-executor auto-start="false" />
+
+    <id-generator />
+    <types resource="jbpm.variable.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <task-db-session />
+    <message-session />
+    <timer-session />
+    <history-session />
+    <identity-session realm="realm://jbpm-identity" />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.task.lifecycle.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.task.lifecycle.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.task.lifecycle.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,13 @@
+<task-lifecycle initial="open">
+  <state name="open">
+    <transition name="complete" to="completed" />
+    <transition name="suspend" to="suspended" />
+    <transition name="cancel" to="cancelled" />
+  </state>
+  <state name="suspended">
+    <transition name="resume" to="open" />
+    <transition name="cancel" to="cancelled" />
+  </state>
+  <state name="cancelled" />
+  <state name="completed" />
+</task-lifecycle>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.variable.types.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.variable.types.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/jbpm.variable.types.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+<types>
+
+  <!-- types stored in a native column -->
+  <type name="string" class="java.lang.String" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="long"   class="java.lang.Long" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="double" class="java.lang.Double" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+  <!-- types converted to a string -->
+  <type name="date"    class="java.util.Date" converter="org.jbpm.pvm.internal.type.converter.DateToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="boolean" class="java.lang.Boolean" converter="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="char"    class="java.lang.Character" converter="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+
+  <!-- types converted to a long -->
+  <type name="byte"    class="java.lang.Byte" converter="org.jbpm.pvm.internal.type.converter.ByteToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="short"   class="java.lang.Short" converter="org.jbpm.pvm.internal.type.converter.ShortToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="integer" class="java.lang.Integer" converter="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+
+  <!-- types converted to a double -->
+  <type name="float" class="java.lang.Float" converter="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+  <!-- byte[] and char[] -->
+  <type name="byte[]" class="[B" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+  <type name="char[]" class="[C" variable-class="org.jbpm.pvm.internal.type.variable.ClobVariable" />
+
+  <type name="hibernate-long-id"   class="hibernate" id-type="long" variable-class="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" />
+  <type name="hibernate-string-id" class="hibernate" id-type="string" variable-class="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" />
+
+  <type name="serializable" class="serializable" converter="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+
+  <!-- TODO: add ejb3 entity bean support -->
+  <!-- TODO: add JCR activity support -->
+  <!-- TODO: add collection support -->
+  
+</types>

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.exclude.xml
===================================================================

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.include.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.include.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/jpdl.include.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+  <!-- jpdl bindings -->
+  <binding class="org.jbpm.jpdl.internal.xml.ParseJpdlBinding" />

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part1.jbpm.wire.bindings.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,88 @@
+<wire-bindings>
+
+  <!-- ########################### -->
+  <!-- ### Descriptor bindings ### -->
+  <!-- ########################### -->
+  <!-- basic types -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.TrueBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FalseBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CharBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.DoubleBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FloatBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IntBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ShortBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ByteBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.LongBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.StringBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.NullBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ClassBinding" />
+  <!-- object and ref --> 
+  <binding class="org.jbpm.pvm.internal.wire.binding.ObjectBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.RefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JndiBinding" />
+  <!-- collections -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.ListBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SetBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MapBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.PropertiesBinding" />
+  <!-- environment refs -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentFactoryRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ContextRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TransactionRefBinding" />
+  <!-- various specials -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.TransactionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobExecutorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobTestHelperBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ScriptManagerBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
+  <!-- hibernate bindings -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateSessionFactoryBinding" />
+  <!-- sessions -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.MessageSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TimerSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionFactoryBinding" />
+  <!-- db sessions -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobDbSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TaskDbSessionBinding" />
+  
+  <!-- dynamic type mapping configuration  -->    
+  <binding class="org.jbpm.pvm.internal.wire.binding.TypesBinding" />
+  <!-- services  -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.StandardCommandServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AsyncCommandServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ProcessServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ExecutionServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ManagementServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentityServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HistoryServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TaskServiceBinding" />
+  
+  <!-- deployers -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.DeployerManagerBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AssignFileTypesBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CheckProcessBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CheckProblemsBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SaveBinding" />
+
+  <!-- interceptors -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AuthorizationInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.RetryInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.StandardTransactionInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnlistBinding" />
+
+  <!-- operation -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.PropertyBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FieldBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.InvokeBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SubscribeBinding" />
+

Added: jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part2.jbpm.wire.bindings.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part2.jbpm.wire.bindings.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/config/src/main/files/jbpm/wire.bindings/part2.jbpm.wire.bindings.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+
+</wire-bindings>

Added: jbpm4/branches/tbaeyens/modules/db/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/db/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>db</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/db/README.txt
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/README.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/README.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,32 @@
+module/db
+---------
+Utitlity module to create/drop the jBPM4 database schema.
+
+Usage
+-----
+Database creation can be triggered through the maven command line
+usally as part of the test preparation:
+
+	mvn -P<drop|create>-tables -Ddatabase=<database> install
+
+Supported databases
+-------------------
+
+- hsqldb
+- mysql
+- postgresql
+- oracle
+- sybase
+
+
+FAQ
+---
+
+1.) How is the default hypersonic database created?
+
+The default hypersonic is created within the jpdl module, as part of the jpdl test execution.
+See the connetion URL 'jdbc:hsqldb:file:@project.build.directory@/hypersonic/jbpm4DB' whereas
+'project.build.directory' in that case is 'modules/jpdl/target'
+
+
+

Added: jbpm4/branches/tbaeyens/modules/db/jbpm4-db.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/jbpm4-db.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/jbpm4-db.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,433 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="toplevel" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.0.1B:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax-api:jar:1.0.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.4.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: mysql:mysql-connector-java:jar:5.0.8:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/mysql/mysql-connector-java/5.0.8/mysql-connector-java-5.0.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: net.sourceforge.jtds:jtds:jar:1.2.2:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/net/sourceforge/jtds/jtds/1.2.2/jtds-1.2.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: postgresql:postgresql:jar:8.3-603.jdbc3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/postgresql/postgresql/8.3-603.jdbc3/postgresql-8.3-603.jdbc3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/db/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3010 2008-11-20 08:30:16Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - DB</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-db</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-base</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+    <!-- Database Driver Versions  -->
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.jtds</groupId>
+      <artifactId>jtds</artifactId>
+    </dependency>   
+
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+        <filtering>true</filtering>
+      </testResource>
+    </testResources>
+
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack.jbpm.db</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jbpm.jbpm4</groupId>
+                  <artifactId>jbpm-jpdl</artifactId>
+                  <classifier>config</classifier>
+                  <overWrite>true</overWrite>
+                </artifactItem>
+              </artifactItems>
+              <excludeTransitive>true</excludeTransitive>
+              <outputDirectory>target/jpdl-config</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>install.hibernate.database.properties</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <copy file="target/jpdl-config/hibernate.cfg.${database}.xml"
+                      tofile="target/test-classes/hibernate.cfg.xml"
+                      overwrite="true" />
+              </tasks>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-db-scripts</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+                <ant antfile="src/main/ant/build.schema.xml" target="create-schema" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>drop-tables</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>create-drop-tables</id>
+                <phase>pre-integration-test</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <tasks>
+                    <!-- Implicit reference to all command line switches, i.e. -Ddatabase=xyz -->
+                    <property name="compile_classpath" refid="maven.compile.classpath"/>
+                    <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+                    <property name="test_classpath" refid="maven.test.classpath"/>
+                    <property name="plugin_classpath" refid="maven.plugin.classpath"/>
+
+                    <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+                    <ant antfile="target/test-classes/antrun-create_drop.xml" target="drop-tables" />
+                  </tasks>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <profile>
+      <id>create-tables</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>create-drop-tables</id>
+                <phase>pre-integration-test</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <tasks>
+                    <!-- Implicit reference to all command line switches, i.e. -Ddatabase=xyz -->
+                    <property name="compile_classpath" refid="maven.compile.classpath"/>
+                    <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+                    <property name="test_classpath" refid="maven.test.classpath"/>
+                    <property name="plugin_classpath" refid="maven.plugin.classpath"/>
+
+                    <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+                    <ant antfile="target/test-classes/antrun-create_drop.xml" target="create-tables" />                    
+                  </tasks>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!-- -Ddatabase=oracle -->
+    <profile>
+      <id>oracle</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>oracle</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.oracle</groupId>
+          <artifactId>ojdbc14</artifactId>
+          <version>${oracle.version}</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+      <repositories>
+        <repository>
+          <id>qa.jboss.com</id>
+          <url>http://www.qa.jboss.com/jdbc-drivers/maven2</url>
+        </repository>
+      </repositories>
+    </profile>
+  </profiles>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/db/src/main/ant/build.schema.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/src/main/ant/build.schema.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/src/main/ant/build.schema.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: antrun-jbpmschema.xml 2999 2008-11-19 16:16:01Z thomas.diesler at jboss.com $ -->
+
+<project>
+
+  <!-- ================================================================== -->
+  <!-- jBPM Database schema                                               -->
+  <!-- ================================================================== -->
+
+  <target name="create-schema">
+    <echo message="${maven.runtime.classpath}"/>
+
+    <taskdef name="schemaexport"
+             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
+      <classpath path="${maven.runtime.classpath}"/>
+    </taskdef>
+
+    <mkdir dir="target/classes/create"/>
+    <mkdir dir="target/classes/drop"/>
+
+    <!-- HsqlDB -->
+    <create-ddl db="hsqldb"/>
+
+    <!-- MySQL -->
+    <create-ddl db="mysql"/>
+    <!--TODO: https://jira.jboss.org/jira/browse/JBPM-2071 -->
+    <replace file="target/classes/create/jbpm.mysql.create.sql" token="BLOB_VALUE_ blob" value="BLOB_VALUE_ longblob" />
+
+    <!-- Oracle -->
+    <create-ddl db="oracle"/>
+
+    <!-- PostgreSQL -->
+    <create-ddl db="postgresql"/>
+
+    <!-- Sybase -->
+    <create-ddl db="sybase"/>
+    
+  </target>
+
+  <!--
+     ============================================
+     Macro defs, no need to change anything below
+     ============================================
+  -->
+
+  <macrodef name="create-ddl">
+    <attribute name="db"/>
+
+    <sequential>
+      <echo></echo>
+      <echo>=====================</echo>
+      <echo>Create DDL @{db}</echo>
+      
+      <schemaexport output="target/classes/create/jbpm.@{db}.create.sql"
+                    create="yes" drop="no"
+                    config="target/jpdl-config/hibernate.cfg.@{db}.xml"
+                    text="yes" delimiter=";"
+                    quiet="yes"/>
+      <schemaexport output="target/classes/drop/jbpm.@{db}.drop.sql"
+                    create="no" drop="yes"
+                    config="target/jpdl-config/hibernate.cfg.@{db}.xml"
+                    text="yes" delimiter=";"
+                    quiet="yes"/>
+
+      <echo>Done.</echo>
+      <echo>=====================</echo>
+    </sequential>
+  </macrodef>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/db/src/test/resources/antrun-create_drop.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/db/src/test/resources/antrun-create_drop.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/db/src/test/resources/antrun-create_drop.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: antrun-jbpmschema.xml 2999 2008-11-19 16:16:01Z thomas.diesler at jboss.com $ -->
+
+<project>
+
+  <!--
+    ==================================================================
+    Create / Drop jBPM Database tables
+    NOTE: Depends on the connection settings ${project.home}/profiles.xml     
+    ==================================================================
+  -->
+
+  <condition property="database.is.hsqldb">
+    <equals arg1="${database}" arg2="hsqldb"/>
+  </condition>
+  <condition property="database.is.mysql">
+    <equals arg1="${database}" arg2="mysql"/>
+  </condition>
+  <condition property="database.is.postgresql">
+    <equals arg1="${database}" arg2="postgresql"/>
+  </condition>
+  <condition property="database.is.sybase">
+    <equals arg1="${database}" arg2="sybase"/>
+  </condition>
+  <condition property="database.is.oracle">
+    <equals arg1="${database}" arg2="oracle"/>
+  </condition>
+
+  <!-- aggregate tasks -->
+
+  <target name="create-tables"
+          depends="create-mysql,create-postgresql,create-sybase,create-oracle"/>
+  <target name="drop-tables"
+          depends="drop-mysql,drop-postgresql,drop-sybase,drop-oracle"/>
+
+
+  <!-- MySQL -->
+  <target name="create-mysql" if="database.is.mysql">
+    <execute-sql
+        db="mysql" action="create"
+        driver="com.mysql.jdbc.Driver"
+        url="${jdbc.mysql.url}"
+        user="${jdbc.mysql.username}"
+        pass="${jdbc.mysql.password}"/>
+  </target>
+
+  <target name="drop-mysql" if="database.is.mysql">
+    <execute-sql
+        db="mysql" action="drop"
+        driver="com.mysql.jdbc.Driver"
+        url="${jdbc.mysql.url}"
+        user="${jdbc.mysql.username}"
+        pass="${jdbc.mysql.password}"/>
+  </target>
+
+  <!--
+    hsqldb
+
+    HsqlDB is created as part of the modules/jpdl build.
+    It will create a hypersonic database in jpdl/target/hypersonic
+    that can be shipped with the distribution.
+
+    Doing an 'mvn clean' will 'drop' the db in that case.    
+    -->
+
+
+
+  <!-- postgresql -->
+  <target name="create-postgresql" if="database.is.postgresql">
+    <execute-sql
+        db="postgresql" action="create"
+        driver="org.postgresql.Driver"
+        url="${jdbc.postgresql.url}"
+        user="${jdbc.postgresql.username}"
+        pass="${jdbc.postgresql.password}"/>
+  </target>
+
+  <target name="drop-postgresql" if="database.is.postgresql">
+    <execute-sql
+        db="postgresql" action="drop"
+        driver="com.postgresql.jdbc.Driver"
+        url="${jdbc.postgresql.url}"
+        user="${jdbc.postgresql.username}"
+        pass="${jdbc.postgresql.password}"/>
+  </target>
+
+   <!-- oracle -->
+  <target name="create-oracle" if="database.is.oracle">
+    <execute-sql
+        db="oracle" action="create"
+        driver="oracle.jdbc.driver.OracleDriver"
+        url="${jdbc.oracle.url}"
+        user="${jdbc.oracle.username}"
+        pass="${jdbc.oracle.password}"/>
+  </target>
+
+  <target name="drop-oracle" if="database.is.oracle">
+    <execute-sql
+        db="oracle" action="drop"
+        driver="oracle.jdbc.driver.OracleDriver"
+        url="${jdbc.oracle.url}"
+        user="${jdbc.oracle.username}"
+        pass="${jdbc.oracle.password}"/>
+  </target>
+
+   <!-- sybase -->
+  <target name="create-sybase" if="database.is.sybase">
+    <execute-sql
+        db="sybase" action="create"
+        driver="net.sourceforge.jtds.jdbc.Driver"
+        url="${jdbc.sybase.url}"
+        user="${jdbc.sybase.username}"
+        pass="${jdbc.sybase.password}"/>
+  </target>
+
+  <target name="drop-sybase" if="database.is.sybase">
+    <execute-sql
+        db="sybase" action="drop"
+        driver="net.sourceforge.jtds.jdbc.Driver"
+        url="${jdbc.sybase.url}"
+        user="${jdbc.sybase.username}"
+        pass="${jdbc.sybase.password}"/>
+  </target>
+
+  <!--
+     ============================================
+     Macro defs, no need to change anything below
+     ============================================
+  -->
+
+  <macrodef name="execute-sql">
+    <attribute name="db"/>
+    <attribute name="action"/>
+    <attribute name="driver"/>
+    <attribute name="url"/>
+    <attribute name="user"/>
+    <attribute name="pass"/>
+
+    <sequential>
+      <echo>=====================</echo>
+      <echo>@{action} tables @{db}</echo>
+      <echo>URL: @{url}</echo>
+      <echo>=====================</echo>
+
+      <sql
+          driver="@{driver}"
+          url="@{url}"
+          userid="@{user}"
+          password="@{pass}"
+          onerror="continue">
+        <transaction
+            src="${project.build.directory}/classes/@{action}/jbpm.@{db}.@{action}.sql"/>
+        <classpath>
+          <pathelement path="${test_classpath}"/>
+        </classpath>
+      </sql>
+    </sequential>
+  </macrodef>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>devguide</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/devguide/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+  <!-- ====================================================================== -->
+  <!--                                                                        -->
+  <!--  JBoss, the OpenSource J2EE webOS                                      -->
+  <!--                                                                        -->
+  <!--  Distributable under LGPL license.                                     -->
+  <!--  See terms of license at http://www.gnu.org.                           -->
+  <!--                                                                        -->
+  <!-- ====================================================================== -->
+
+  <!-- $Id: pom.xml 2693 2008-10-31 09:12:32Z tom.baeyens at jboss.com $ -->
+
+<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>
+
+  <name>jBPM 4 - Developers Guide</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-devguide</artifactId>
+  <packaging>pom</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <dependencies>
+    <!-- 
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>
+    -->
+  </dependencies>
+
+  <build>
+    <!-- ### PLUGINS ###################################################### -->
+    <plugins>
+
+      <plugin>
+        <groupId>org.jboss.maven.plugins</groupId>
+        <artifactId>maven-jdocbook-plugin</artifactId>
+        <version>2.1.2</version>
+        <extensions>true</extensions>
+
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>resources</goal>
+              <goal>generate</goal>
+            </goals>
+          </execution>
+         </executions>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jbossorg-docbook-xslt</artifactId>
+            <version>1.1.0</version>
+          </dependency>
+          <dependency>
+            <groupId>org.jbpm.jbpm4</groupId>
+            <artifactId>docbook-style</artifactId>
+            <version>1.0.0</version>
+            <type>jdocbook-style</type>
+          </dependency>
+        </dependencies>
+
+        <configuration>
+          <sourceDocumentName>master.xml</sourceDocumentName>
+          <masterTranslation>en</masterTranslation>
+          <imageResource>
+            <directory>${basedir}/src/main/docbook/en</directory>
+            <includes>
+              <include>images/*.png</include>
+            </includes>
+          </imageResource>
+          <formats>
+            <format>
+              <formatName>html_single</formatName>
+              <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+              <finalName>index.html</finalName>
+            </format>
+          </formats>
+        </configuration>
+
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/diagrams.mdzip
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/diagrams.mdzip
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/images.ppt
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/diagrams/images.ppt
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/apis.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/apis.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch04.execution.states.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch04.execution.states.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch09.persistent.process.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/ch09.persistent.process.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.definition.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.definition.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.execution.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/class.diagram.process.execution.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/composite.node.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/composite.node.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait1.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait1.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait2.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait2.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait3.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.automatic.wait3.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.concurrency.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.concurrency.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.archive.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.archive.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.end.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.end.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.evaluate.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/execution.loan.evaluate.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/initial.in.composite.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/initial.in.composite.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/interceptors.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/interceptors.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.db.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.db.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.execution.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/loan.execution.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.ab.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.ab.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.anatomy.classes.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.anatomy.classes.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.automatic.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.automatic.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.loan.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.loan.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.propagate.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.propagate.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.structure.classes.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/process.structure.classes.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/self.transition.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/self.transition.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transactions.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transactions.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.inheritence.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.inheritence.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.into.composite.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.into.composite.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.out.of.composite.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.out.of.composite.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.inner.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.inner.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.outer.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/images/transition.to.outer.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/master.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/master.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE book [
+  <!ENTITY ch01-Introduction                   SYSTEM "modules/ch01-Introduction.xml">
+  <!ENTITY ch02-ExecutionModes                 SYSTEM "modules/ch02-ExecutionModes.xml">
+  <!ENTITY ch03-Architecture                   SYSTEM "modules/ch03-Architecture.xml">
+  <!ENTITY ch04-ImplementingBasicActivities    SYSTEM "modules/ch04-ImplementingBasicActivities.xml">
+  <!ENTITY ch05-ProcessAnatomy                 SYSTEM "modules/ch05-ProcessAnatomy.xml">
+  <!ENTITY ch06-ImplementingAdvancedActivities SYSTEM "modules/ch06-ImplementingAdvancedActivities.xml">
+  <!ENTITY ch07-Variables                      SYSTEM "modules/ch07-Variables.xml">
+  <!ENTITY ch08-Timers                         SYSTEM "modules/ch08-Timers.xml">
+  <!ENTITY ch09-AsynchronousContinuations      SYSTEM "modules/ch09-AsynchronousContinuations.xml">
+  <!ENTITY ch10-SoftwareLogging                SYSTEM "modules/ch10-SoftwareLogging.xml">
+  <!ENTITY ch11-History                        SYSTEM "modules/ch11-History.xml">
+]>
+
+<book lang="en">
+
+  <bookinfo>
+    <title>jBPM Developers Guide</title>
+  </bookinfo>
+
+  <toc />
+
+  &ch01-Introduction;
+  &ch02-ExecutionModes;
+  &ch03-Architecture;
+  &ch04-ImplementingBasicActivities;
+  &ch05-ProcessAnatomy;
+  &ch06-ImplementingAdvancedActivities;
+  &ch07-Variables;
+  &ch08-Timers;
+  &ch09-AsynchronousContinuations;
+  &ch10-SoftwareLogging;
+  &ch11-History;
+
+</book>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch01-Introduction.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch01-Introduction.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch01-Introduction.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,131 @@
+<chapter id="introduction">
+  <title>Introduction</title>
+  
+  <section>
+    <title>License and EULA</title>
+    <para>The Process Virtual Machine component is distributed under the terms of the 
+    GNU Lesser General Public License (LGPL) and the JBoss End User License Agreement (EULA).  
+    See <ulink url="../../../lgpl.html">the full LGPL license text</ulink> and <ulink url="../../../JBossORG-EULA.txt">the 
+    full End User License Agreement</ulink>. 
+    </para>
+  </section>
+
+  <section>
+    <title>Sources</title>
+    <para>The source code for this component can be found in the jBPM SVN repository:
+    </para>
+    <ulink url="https://anonsvn.jboss.org/repos/jbpm/jbpm4/pvm/">https://anonsvn.jboss.org/repos/jbpm/jbpm4/pvm/</ulink>
+  </section>
+
+  <section>
+    <title>JVM version</title>
+    <para>jbpm-pvm.jar requires a JVM version 5 or higher.
+    </para>
+  </section>
+
+  <section>
+    <title>Library dependencies</title>
+    <para>For building and executing processes the jbpm-pvm.jar does not have any other 
+    dependencies then on the JVM.  If you're using DB persistence, then there is a dependency
+    on hibernate and it's dependencies.  More information about the optional depedencies can
+    be found in the <ulink url="../../lib/optional-dependencies.html">lib directory</ulink>. 
+    </para>
+  </section>
+
+  <section>
+    <title>What is it</title>
+    <para>In essence, the Process Virtual Machine is a framework specifying executable 
+    graphs.  A process definition represents an execution flow and has a structure that 
+    be represented graphically as a diagram.    
+    </para>  
+    <figure id="example.process.graph">
+      <title>Example process definition</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.loan.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Typically, process definitions are static.  A process definition is composed of 
+    activities and transitions.  The runtime behaviour of a activity is encapsulated in a so called 
+    Activity and it's decoupled from the process graph structure.  
+    </para>
+    <figure id="class.diagram.process.definition">
+      <title>Process structure class diagram</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/class.diagram.process.definition.png"/></imageobject></mediaobject>
+    </figure>
+    <para>The Process Virtual 
+    Machine doesn't contain any such activity implementations.  It only provides the 
+    execution environment and an activity API to write <literal>Activity</literal> 
+    implementations as Java components.  Activities can also be wait states.  This means 
+    that the activity control flow goes outside the process system. For example a human task 
+    or invoking an service asynchronously.
+    </para>
+    <para>Many executions can be started for one process definition. An execution is a pointer 
+    that keeps track of the current activity.
+    </para>
+    <figure id="example.execution">
+      <title>Example execution</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/loan.execution.png"/></imageobject></mediaobject>
+    </figure>
+    <para>To represent concurrent paths of execution, there is 
+    a hierarchical parent-child relation between so that one process instance can cope with concurrent 
+    paths of execution.
+    </para>
+    <figure id="class.diagram.process.execution">
+      <title>Execution class diagram</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/class.diagram.process.execution.png"/></imageobject></mediaobject>
+    </figure>
+  </section>
+    
+  <section>
+    <title>Features</title>
+    <para>The key features of this library are
+    <itemizedlist>
+      <listitem>Create executable processes that are based on a diagram structure</listitem>
+      <listitem>Runtime behaviour of the activities can be provided as Activity implementations</listitem>
+      <listitem>Activities can be wait states</listitem>
+      <listitem>There are no constraints on the process graph structure</listitem>
+      <listitem>Processes diagrams can be based on composition (aka block structured)</listitem>
+      <listitem>Processes diagrams can be a mix of graph based and composition</listitem>
+      <listitem>During wait states, the runtime state of a process execution can be persisted</listitem>
+      <listitem>Persistence is optional</listitem>
+    </itemizedlist>
+    </para>
+  </section>
+  
+  <section>
+    <title>Purpose</title>
+    <para>The Process Virtual Machine is designed in such a way that it's easy to build 
+    workflow, BPM, orchestration and other graph based execution langauges on top 
+    of it.  Examples of languages that have been built on top of this library:
+    </para>
+    <itemizedlist>
+      <listitem>jPDL: Workflow language that combines powerful human task capabilities with easy binding to Java.</listitem>
+      <listitem>BPEL: Web-Service orchestration (to be exact for the purists: BPEL is a WSDL service orchestration language)</listitem>
+      <listitem>Pageflow: To describe navigation handling in a web application, pages can be seen as activities and the nagivation between the pages as transitions.</listitem>
+      <listitem>XPDL: A graph based process language standardized by the Workflow Management Coalition (WfMC)</listitem>
+    </itemizedlist>
+    <para>Even while the nature of these languages is already very diverse, these are 
+    all examples of general purpose workflow languages.  The real power of the 
+    Process Virtual Machine is that it's very easy to build Domain Specific Languages (DSL)
+    with it.  For instance, it's very easy to build a very simple (and dedicated) workflow 
+    language to specify approvals related to documents in a document management system.
+    </para>
+    <para>BPM as a discipline refers to the management level effort to optimise efficiency
+    of an organisation by analysing and optimising the procedures of how people and systems 
+    work together. In designing the Process Virtual Machine and the jPDL language 
+    in particular, we have spend great care on facilitating the link between BPM analysis 
+    notations and executable process languages.  Here are the most known modeling notations: 
+    </para>
+    <itemizedlist>
+      <listitem>BPMN: OMG latest notation for modeling business processes.  
+      This is a modeling notation that is targetted explicitely to be bound 
+      to executable processes.
+      </listitem>
+      <listitem>UML activity diagrams: OMG notation for modeling business 
+      processes.  Mostly used in business context.</listitem>
+      <listitem>UML state diagrams: OMG modeling notation for defining technical 
+      state machines.  More used in a technical context.</listitem>
+      <listitem>EPC: Event driven process chains.  Rich notation for modeling 
+      business processes driven by SAP and IDS Scheer.</listitem>
+    </itemizedlist>
+  </section>
+    
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-Environments.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-Environments.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-Environments.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,20 @@
+<chapter id="environments">
+  <title>Environments</title>
+  
+  <para>This chapter describes the support for other environments then the ones
+  described in the userguide.
+  </para>
+  
+  <section id="spring">
+    <title>Spring</title>
+    <para>TODO
+    </para>
+  </section>
+
+  <section id="osgi">
+    <title>OSGi</title>
+    <para>TODO 
+    </para>
+  </section>
+
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,404 @@
+<chapter id="executionmodes">
+  <title>Execution modes</title>
+  
+  <para>There are basically three process execution modes: object, persistent 
+  and embedded.  For the persistent and embedded execution modes, the process 
+  execution has to participate in a transaction.  In that case, the process 
+  execution has to take place inside of an Environment.  The environment will be 
+  used to bind process execution updates to a transaction in the application 
+  transaction.  The environment can be used to bind  to e.g. a JDBC connection, 
+  JTA, BMT, Spring transactions and so on.  
+  </para>
+
+  <section id="objectexecutionmode">
+    <title>Object execution mode</title>
+    <para>Object execution mode is the simplest form of working with the Process
+    Virtual Machine.  This means working with the process definition and execution 
+    objects directly through the client API. Let's show this by an example.  We 
+    start by creating a <literal>ClientProcessDefinition</literal> that looks like this: 
+    </para>
+  
+    <para>Object execution mode is the simplest form of working with the Process
+    Virtual Machine.  This means working with the process definition and execution 
+    objects directly through the client API. Let's show this by an example.  We 
+    start by creating a <literal>ClientProcessDefinition</literal> that looks like this: 
+    </para>
+    <figure id="loan.process">
+      <title>The loan process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.loan.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+  .activity("submit loan request").initial().behaviour(AutomaticActivity.class)
+    .transition().to("evaluate")
+  .activity("evaluate").behaviour(WaitState.class)
+    .transition("approve").to("wire money")
+    .transition("reject").to("end")
+  .activity("wire money").behaviour(AutomaticActivity.class)
+    .transition().to("archive")
+  .activity("archive").behaviour(WaitState.class)
+    .transition().to("end")
+  .activity("end").behaviour(WaitState.class)
+.done();</programlisting>
+      <para>The <literal>ProcessFactory</literal> is a helper class that provides convenience 
+      for building an object graph that represents a process definition.  
+      <literal>AutomaticActivity</literal> is a pass-through activity without anything 
+      happening and <literal>WaitState</literal> will wait until an external signal is given.  Both 
+      activity implementations will be covered in more depth later.
+      </para>
+      <para>The <literal>processDefinition</literal> object serves as a factory for process 
+      instance objects.  A process instance represents one execution of the process definition.
+      More precise, the process instance is the main path of execution.  
+      </para>
+      <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+      <para>A process instance 
+      itself is also an <literal>Execution</literal>.  Potentially, an execution can have 
+      child executions to represent concurrent paths of execution.
+      </para>  
+      <para>The <literal>execution</literal> can be seen as a state machine that operates as 
+      described in the process definition.  Starting a process 
+      instance means that the initial activity of the process definition is executed.
+      Since this is an automatic activity, the execution will proceed to the 
+      <literal>evaluate</literal> activity.  The <literal>evaluate</literal> activity is a wait state.
+      When the execution arrived at the evaluate activity, the method <literal>startProcessInstance</literal>
+      will return and waits until an external signal is provided with the <literal>signal</literal>
+      method.  So after the <literal>startProcessInstance</literal> we can verify if the 
+      execution is positioned in the evaluate activity. 
+      </para>
+      <programlisting>assertEquals("evaluate", execution.getActivityName());</programlisting>
+      <para>To make the process execute further, we provide an external trigger with the 
+      <literal>signal</literal> method.  The result of the evaluation will be given as the 
+      signalName parameter like this:
+      </para>
+      <programlisting>execution.signal("approve");</programlisting>
+      <para>The <literal>WaitState</literal> activity implementation will take the transition 
+      that corresponds to the given signalName.  So the execution will first execute 
+      the automatic activity <literal>wire money</literal> and then return after entering 
+      the next wait state <literal>archive</literal>.
+      </para>
+      <programlisting>assertEquals("archive", execution.getActivityName());</programlisting>
+      <para>When the execution is waiting in the archive activity, the default signal will
+      make it take the first unnamed transition.
+      </para>
+      <programlisting>execution.signal();
+assertEquals("end", execution.getActivityName());</programlisting>
+      <para>The process has executed in the thread of the client.  The 
+      <literal>startProcessInstance</literal> method only returned when the <literal>evaluate</literal> 
+      activity was reached.  In other words, the <literal>ClientProcessDefinition.startProcessInstance</literal>
+      and <literal>ClientExecution.signal</literal> methods are blocking until the next 
+      wait state is reached.
+      </para>
+    </section>
+    
+    <section id="persistentexecutionmode">
+      <title>Persistent execution mode</title>
+      <para>The Process Virtual Machine also contains the hibernate mappings to store the 
+      process definitions and executions in any database.  A special session facade called 
+      <literal>ExecutionService</literal> is provided for working with process executions 
+      in such a persistent environment. 
+      </para>
+      <para>Two configuration files should be available on the classpath: an environment 
+      configuration file and a <literal>hibernate.properties</literal> file.  A basic  
+      configuration for persistent execution mode in a standard Java environment looks 
+      like this:
+      </para>
+      <literal><emphasis role="bold">environment.cfg.xml</emphasis>:</literal>
+      <programlisting>&lt;jbpm-configuration xmlns=&quot;http://jbpm.org/xsd/cfg&quot;&gt;
+
+  &lt;process-engine-context&gt;
+  
+    &lt;deployer-manager&gt;
+      &lt;assign-file-type&gt;
+        &lt;file extension=&quot;.jpdl.xml&quot; type=&quot;jpdl&quot; /&gt;
+      &lt;/assign-file-type&gt;
+      &lt;parse-jpdl /&gt;
+      &lt;check-process /&gt;
+      &lt;check-problems /&gt;
+      &lt;save /&gt;
+    &lt;/deployer-manager&gt;
+    
+    &lt;process-service /&gt;
+    &lt;execution-service /&gt;
+    &lt;management-service /&gt;
+  
+    &lt;command-service&gt;
+      &lt;retry-interceptor /&gt;
+      &lt;environment-interceptor /&gt;
+      &lt;standard-transaction-interceptor /&gt;
+    &lt;/command-service&gt;
+    
+    &lt;hibernate-configuration&gt;
+      &lt;properties resource=&quot;hibernate.properties&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.typedefs.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.wire.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.definition.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.execution.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.variable.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.pvm.job.hbm.xml&quot; /&gt;
+      &lt;mapping resource=&quot;jbpm.jpdl.hbm.xml&quot; /&gt;
+      &lt;cache-configuration resource=&quot;jbpm.pvm.cache.xml&quot; 
+                           usage=&quot;nonstrict-read-write&quot; /&gt;
+    &lt;/hibernate-configuration&gt;
+    
+    &lt;hibernate-session-factory /&gt;
+    
+    &lt;id-generator /&gt;
+    &lt;types resource=&quot;jbpm.pvm.types.xml&quot; /&gt;
+    &lt;job-executor auto-start=&quot;false&quot; /&gt;
+  
+  &lt;/process-engine-context&gt;
+
+  &lt;transaction-context&gt;
+    &lt;hibernate-session /&gt;
+    &lt;transaction /&gt;
+    &lt;pvm-db-session /&gt;
+    &lt;job-db-session /&gt;
+    &lt;message-session /&gt;
+  &lt;/transaction-context&gt;
+
+&lt;/jbpm-configuration&gt;</programlisting>
+      <para>And next to it a hibernate.properties like this</para>
+      <literal>hibernate.properties:</literal>
+      <programlisting>hibernate.dialect                      org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class      org.hsqldb.jdbcDriver
+hibernate.connection.url               jdbc:hsqldb:mem:.
+hibernate.connection.username          sa
+hibernate.connection.password
+hibernate.hbm2ddl.auto                 create-drop
+hibernate.cache.use_second_level_cache true
+hibernate.cache.provider_class         org.hibernate.cache.HashtableCacheProvider
+# hibernate.show_sql                     true
+hibernate.format_sql                   true
+hibernate.use_sql_comments             true</programlisting>
+      <para>Then you can obtain the services from the environment factory like this:
+      </para>
+      <programlisting>EnvironmentFactory environmentFactory = new PvmEnvironmentFactory(&quot;environment.cfg.xml&quot;);
+
+ProcessService processService = environmentFactory.get(ProcessService.class);
+ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+ManagementService managementService = environmentFactory.get(ManagementService.class);</programlisting>
+      <para>The responsibility of the <literal>ProcessService</literal> is to manage
+      the repository of process definitions.  Before we can start a process execution, 
+      the process definition needs to be deployed into the process repository.
+      Process definitions can be supplied in various formats and process definition 
+      languages.  A deployment collects process definition information from various 
+      sources like a ZIP file, an XML file or a process definition object.
+      The method <literal>ProcessService.deploy</literal> will take a deployment 
+      through all the deployers that are configured in the configuration file.    
+      </para>
+      <para>In this example, we'll supply a process definition programmatically
+      for deployment.</para>
+      <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+  .activity("submit loan request").initial().behaviour(AutomaticActivity.class)
+    .transition().to("evaluate")
+  .activity("evaluate").behaviour(WaitState.class)
+    .transition("approve").to("wire money")
+    .transition("reject").to("end")
+  .activity("wire money").behaviour(AutomaticActivity.class)
+    .transition().to("archive")
+  .activity("archive").behaviour(WaitState.class)
+    .transition().to("end")
+  .activity("end").behaviour(WaitState.class)
+.done();
+
+Deployment deployment = new Deployment(processDefinition);
+processService.deploy(deployment);</programlisting>
+    <para>Now, a version of that process definition is stored in the database. 
+    The <literal>check-version</literal> deployer will have assigned version 1 
+    to the  stored process definition.  The <literal>create-id</literal> deployer 
+    will have distilled id <literal>loan:1</literal> from the process name and the 
+    assigned version.
+    </para>
+    <para>Deploying that process again will lead to a new process definition 
+    version being created in the database.  But an incremented version number will 
+    be assigned.  For the purpose of versioning, process definitions are considered 
+    equal if they have the same name.</para>
+    <para>It is recommended that a user provided key reference is supplied for 
+    all process executions.  Starting a new process execution goes like this:
+    </para>
+    <programlisting>Execution execution = executionService.startExecution("loan:1", "request7836");</programlisting>
+    <para>The return value is an execution interface, which prevents navigation of relations.  
+    That is because outside of the service methods, the transaction and hibernate session 
+    is not guaranteed to still be open.  In fact, the default configuration as given 
+    above will only keep the transaction and session open for the duration of the
+    service method.  So navigating the relations outside of the service methods might result 
+    into a hibernate <literal>LazyInitializationException</literal>.  But the 
+    current activity name can still be verified:
+    </para>
+    <programlisting>assertEquals("evaluate", execution.getActivityName());</programlisting>
+    <para>Also very important is the generated id that can be obtained.  The default 
+    <literal>id-generator</literal> will use the process definition id and the 
+    given key to make a unique id for the process execution like this:</para>
+    <programlisting>assertEquals("loan:1/request7836", execution.getId());</programlisting>
+    <para>That id must be when providing the subsequent external triggers to the 
+    process execution like this:
+    </para>
+    <programlisting>executionService.signalExecution("loan:1/request7836", "approve");</programlisting>
+    <para>More information about service interfaces to run in persistent 
+    mode can be found in package 
+    <ulink url="../../api/org/jbpm/pvm/package-summary.html"><literal>org.jbpm.pvm</literal> of the
+    api docs</ulink>. 
+    </para>
+  </section>
+
+  <section id="embeddedexecutionmode">
+    <title>Embedded execution mode</title>
+    <para>Embedded execution mode means that the state of a process is stored 
+    as a string column inside a user domain object like e.g. a loan.
+    </para>
+    <programlisting>public class Loan {
+
+  <emphasis role="bold">/** the loan process definition as a static resource */
+  private static final ClientProcessDefinition processDefinition = createLoanProcess();
+  
+  private static ClientProcessDefinition createLoanProcess() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build(&quot;loan&quot;)
+      .activity(&quot;submit loan request&quot;).initial().behaviour(AutomaticActivity.class)
+        .transition().to(&quot;evaluate&quot;)
+      .activity(&quot;evaluate&quot;).behaviour(WaitState.class)
+        .transition(&quot;approve&quot;).to(&quot;wire money&quot;)
+        .transition(&quot;reject&quot;).to(&quot;end&quot;)
+      .activity(&quot;wire money&quot;).behaviour(AutomaticActivity.class)
+        .transition().to(&quot;archive&quot;)
+      .activity(&quot;archive&quot;).behaviour(WaitState.class)
+        .transition().to(&quot;end&quot;)
+      .activity(&quot;end&quot;).behaviour(WaitState.class)
+    .done();
+    
+    return processDefinition;
+  }
+
+  /** exposes the process definition to the execution hibernate type */
+  private static ClientProcessDefinition getProcessDefinition() {
+    return processDefinition;
+  }
+  </emphasis>
+
+  long dbid;
+  String customer;
+  double amount;
+  <emphasis role="bold">ClientExecution execution;</emphasis>
+  
+  /** constructor for persistence */
+  protected Loan() {
+  }
+
+  public Loan(String customer, double amount) {
+    this.customer = customer;
+    this.amount = amount;
+    <emphasis role="bold">this.execution = processDefinition.startProcessInstance();</emphasis>
+  }
+
+  public void approve() {
+    <emphasis role="bold">execution.signal(&quot;approve&quot;);</emphasis>
+  }
+
+  public void reject() {
+    <emphasis role="bold">execution.signal(&quot;reject&quot;);</emphasis>
+  }
+
+  public void archiveComplete() {
+    <emphasis role="bold">execution.signal();</emphasis>
+  }
+
+  public String getState() {
+    return <emphasis role="bold">execution.getActivityName()</emphasis>;
+  }
+
+  ...getters...
+}</programlisting>
+    <para>If you ignore the bold parts for a second, you can see that this is a 
+    POJO without anything fancy.  It's just a bean that can be stored with hibernate. 
+    The bold part indicate that implementation part of the class that is related 
+    to process and execution.  Not that nothing of the process definition or 
+    execution is exposed to the user of the Loan class.
+    </para>
+    <para>Each <literal>Loan</literal> object corresponds to a <literal>loan</literal> 
+    process instance.  Some methods of the <literal>Loan</literal> class correspond 
+    to the external triggers that need to be given during the lifecycle of a
+    <literal>Loan</literal> object.
+    </para>
+    <para>Next we'll show how to use this class.  To get started we need a</para>
+    <emphasis role="bold"><literal>hibernate.cfg.xml:</literal></emphasis>
+    <programlisting>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+
+&lt;!DOCTYPE hibernate-configuration PUBLIC
+          &quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot;
+          &quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;
+
+&lt;hibernate-configuration&gt;
+  &lt;session-factory&gt;
+
+    &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.HSQLDialect&lt;/property&gt;
+    &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;org.hsqldb.jdbcDriver&lt;/property&gt;
+    &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc:hsqldb:mem:.&lt;/property&gt;
+    &lt;property name=&quot;hibernate.connection.username&quot;&gt;sa&lt;/property&gt;
+    &lt;property name=&quot;hibernate.connection.password&quot;&gt;&lt;/property&gt;
+    &lt;property name=&quot;hibernate.hbm2ddl.auto&quot;&gt;create&lt;/property&gt;
+    &lt;property name=&quot;hibernate.show_sql&quot;&gt;true&quot;&lt;/property&gt;
+    &lt;property name=&quot;hibernate.format_sql&quot;&gt;true&quot;&lt;/property&gt;
+    &lt;property name=&quot;hibernate.use_sql_comments&quot;&gt;true&quot;&lt;/property&gt;
+    
+    &lt;mapping resource=&quot;Loan.hbm.xml&quot;/&gt;
+    
+  &lt;/session-factory&gt;
+&lt;/hibernate-configuration&gt;</programlisting>
+    <para>And a</para>
+    <emphasis role="bold"><literal>Loan.hbm.xml:</literal></emphasis>
+    <programlisting>&lt;?xml version=&quot;1.0&quot;?&lt;
+
+&lt;!DOCTYPE hibernate-mapping PUBLIC 
+          &quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot; 
+          &quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&lt;
+
+&lt;hibernate-mapping package=&quot;org.jbpm.pvm.api.db.embedded&quot; default-access=&quot;field&quot;&lt;
+
+  &lt;typedef name=&quot;execution&quot; class=&quot;org.jbpm.pvm.internal.hibernate.ExecutionType&quot; /&lt;
+
+  &lt;class name=&quot;Loan&quot; table=&quot;LOAN&quot;&lt;
+
+    &lt;id name=&quot;dbid&quot;&lt;
+      &lt;generator class=&quot;sequence&quot;/&lt;
+    &lt;/id&lt;
+
+    &lt;property name=&quot;execution&quot; type=&quot;execution&quot; /&lt;
+    &lt;property name=&quot;customer&quot; /&lt;
+    &lt;property name=&quot;amount&quot; /&lt;
+    
+  &lt;/class&lt;
+
+&lt;/hibernate-mapping&lt;</programlisting>
+    <para>Then you can use the Loan class like this in a test</para>
+    <programlisting>Configuration configuration = new Configuration();
+configuration.configure();
+SessionFactory sessionFactory = configuration.buildSessionFactory();
+
+// start a session/transaction
+Session session = sessionFactory.openSession();
+Transaction transaction = session.beginTransaction();
+
+Loan loan = new Loan("john doe", 234.0);
+session.save(loan);
+assertEquals("evaluate", loan.getState());
+
+// start a new session/transaction
+transaction.commit();
+session.close();
+session = sessionFactory.openSession();
+transaction = session.beginTransaction();
+
+loan = (Loan) session.get(Loan.class, loan.getDbid());
+assertEquals("evaluate", loan.getState());
+loan.approve();
+assertEquals("archive", loan.getState());
+
+// start a new session/transaction
+transaction.commit();
+session.close();</programlisting>
+    <para>After executing this code snippet, this is the loan record in the DB:</para>
+    <figure id="loan.db">
+      <title>The loan record in the DB</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/loan.db.png"/></imageobject></mediaobject>
+    </figure>
+  </section>
+
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch03-Architecture.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch03-Architecture.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch03-Architecture.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,250 @@
+<chapter id="architecture">
+  <title>Architecture</title>
+  
+  <section id="apis">
+    <title>APIs</title>
+    <para>The Process Virtual Machine has 4 integrated API's that together 
+    offer a complete coverage of working with processes in the different execution modes.  
+    Each of the APIs has a specific purpose that fits within the following overall 
+    architecture.
+    </para>
+    <figure id="apis">
+      <title>The 4 API's of the Process Virtual Machine</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/apis.png"/></imageobject></mediaobject>
+    </figure>
+    <para>The services interfaces should be used from application code that wants to interact 
+    with the Process Virtual Machine which runs in transactional persistent mode, backed by a 
+    database.  This is the most typical way how users interact with the PVM as a workflow engine.
+    </para>
+    <para>To execute processes without persistence, the client API can be used to work with process 
+    and execution objects directly.  The client API expose the methods of the core model objects.
+    </para>
+    <para>The activity API is used to implement the runtime behaviour of activities.  So a activity 
+    type is in fact a component with at the core an implementation of the <literal>Activity</literal> 
+    interface.  Activity implementations can control the flow of execution.
+    </para>  
+    <para>The event listener API serves to write pieces of Java code that should be executed upon 
+    process events.  It's very similar to the activity API with that exception that event listeners
+    are not able to control the flow of execution. 
+    </para> 
+  </section>
+  
+  <section>
+    <title>Activity API</title>
+    <para>The activity API allows to implement the runtime activity behaviour in Java.
+    </para>
+    <programlisting>public interface Activity extends Serializable {
+  void execute(ActivityExecution execution) throws Exception;
+}</programlisting>
+    <para>An activity is the behaviour of the activity to which it is associated.
+    The provided execution is the execution that arrives in the activity.
+    The interface <literal>ActivityExecution</literal> exposes special 
+    methods to control the execution flow.
+    </para>
+    <programlisting>public interface ActivityExecution extends OpenExecution {
+
+  void waitForSignal();
+  void take(String transitionName);
+  void execute(String activityName);
+
+  ...
+
+}</programlisting>
+  </section>
+
+  <section>
+    <title>Event listener API</title>
+    <para>The event listener API allows for listeners to be developed in Java code 
+    and that are invoked on specific process events like entering a activity or leaving 
+    a activity.  It is very similar to the activity API, but the difference is  
+    that the propagation of the execution flow cannot be controlled.  E.g. when an execution 
+    is taking a transition, a listener to that event can be notified, but since the 
+    transition is already being taking, the execution flow cannot be changed 
+    by the event listeners.  
+    </para>
+    <programlisting>public interface EventListener extends Serializable {
+  
+  void notify(EventListenerExecution execution) throws Exception;
+
+}</programlisting>
+  </section>
+
+  <section>
+    <title>Client API</title>
+    <para>The client API was already introduced above in the object execution mode 
+    and embedded execution mode.  It's an interface that exposes the methods for 
+    managing executions on the plain process definition and execution objects directly. 
+    </para>
+    <para>At a minimal, the client API and the activity API are needed to create 
+    some a process definition with activities and execute it.
+    </para>
+  </section>
+
+  <section>
+    <title>Environment</title>
+    <para>In the persistent execution mode, the first purpose of the environment is 
+    to enable processes to be executed in different transactional environments like 
+    standard Java, enterprise Java, SEAM and Spring.
+    </para>
+    <para>The PVM code itself will only use transactional resources through self-defined 
+    interfaces.  For example, the PVM itself has interfaces for some methods on the hibernate 
+    session, a async messaging session and a timer session.
+    </para>
+    <para>The environment allows to configure the actual implementations, lazy 
+    initialization of the services on a request-basis and caching the service 
+    objects for the duration of the transaction. 
+    </para>
+    <para>An environment factory is static and one environment factory can serve 
+    all the threads in an application.
+    </para>
+    <programlisting>EnvironmentFactory environmentFactory = new PvmEnvironmentFactory("environment.cfg.xml");</programlisting>
+    <para>Environment blocks can surround persistent process operations 
+    like this:
+    </para>
+    <programlisting>Environment environment = environmentFactory.openEnvironment();
+try {
+
+  ... inside the environment block...
+
+} finally {
+  environment.close();
+}</programlisting>
+    <para>The PVM itself will fetch all it's transactional resources and configurations 
+    from the environment.  It's recommended that <literal>Activity</literal> implementations
+    do the same.
+    </para>
+  </section>
+
+  <section>
+    <title>Commands</title>
+    <para>Commands encapsulate operations that are to be executed within an environment 
+    block.  The main purpose for commands is to capture the logic of 
+    </para>
+    <programlisting>public interface Command&lt;T&gt; extends Serializable {
+
+  T execute(Environment environment) throws Exception;
+
+}</programlisting>
+    <para></para>
+  </section>
+
+  <section>
+    <title>Services</title>
+    <para>There are three services: <literal>ProcessService</literal>, 
+    <literal>ExecutionService</literal> and <literal>ManagementService</literal>.
+    In general, services are session facades that expose methods for persistent 
+    usage of the PVM. The next fragments show the essential methods as example 
+    to illustrate those services. 
+    </para>
+    <para>The <literal>ProcessService</literal> manages the repository of 
+    process definitions.
+    </para>
+    <programlisting>public interface ProcessService {
+
+  ProcessDefinition deploy(Deployment deployment);
+
+  ProcessDefinition findLatestProcessDefinition(String processDefinitionName);
+
+  ...
+
+}</programlisting>
+    <para>The <literal>ExecutionService</literal> manages the runtime 
+    executions.</para>
+    <programlisting>public interface ExecutionService {
+
+  Execution startExecution(String processDefinitionId, String executionKey);
+
+  Execution signalExecution(String executionId, String signalName);
+   
+  ...
+
+}</programlisting>
+    <para>The <literal>ManagementService</literal> groups all management operations
+    that are needed to keep the system up and running.
+    </para>
+    <programlisting>public interface ManagementService {
+
+  List&lt;Job&gt; getJobsWithException(int firstResult, int maxResults);
+
+  void executeJob(String jobId);
+  
+  ...
+  
+}</programlisting>
+    <para>The implementation of all these methods is encapsulated in 
+    <literal>Command</literal>s.  And the three services all delegate the 
+    execution of the commands to a <literal>CommandService</literal>:
+    </para>
+    <programlisting>public interface CommandService {
+
+  &lt;T&gt; T execute(Command&lt;T&gt; command);
+
+}</programlisting>
+    <para>The <literal>CommandService</literal> is configured in the 
+    environment.  A chain of CommandServices can act as interceptors 
+    around a command.  This is the core mechanism on how persistence and 
+    transactional support can be offered in a variety of environments.
+    </para>
+    <para>From the default configuration which is included in full above, 
+    here is the section that configures the services
+    </para>
+    <programlisting>&lt;jbpm-configuration xmlns=&quot;http://jbpm.org/xsd/cfg&quot;&gt;
+
+  &lt;process-engine&gt;
+  
+    &lt;process-service /&gt;
+    &lt;execution-service /&gt;
+    &lt;management-service /&gt;
+  
+    &lt;command-service&gt;
+      &lt;retry-interceptor /&gt;
+      &lt;environment-interceptor /&gt;
+      &lt;standard-transaction-interceptor /&gt;
+    &lt;/command-service&gt;
+    
+    ...
+    </programlisting>
+    <para>The three services <literal>process-service</literal>, <literal>execution-service</literal>
+    and <literal>management-service</literal> will look up the configured 
+    <literal>command-service</literal> by type.  The <literal>command-service</literal>
+    tag corresponds to the default command service that essentially does nothing else 
+    then just execute the command providing it the current environment.
+    </para>
+    <para>The configured <literal>command-service</literal> results into the following 
+    a chain of three interceptors followed by the default command executor. 
+    </para>
+    <figure id="interceptors">
+      <title>The CommandService interceptors</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/interceptors.png"/></imageobject></mediaobject>
+    </figure>
+    <para>The retry interceptor is the first in the chain and that one that will be exposed as the 
+    <literal>CommandService.class</literal> from the environment.  So the retry interceptor 
+    will be given to the respective services <literal>process-service</literal>, <literal>execution-service</literal>
+    and <literal>management-service</literal>.  
+    </para>
+    <para>The <literal>retry-interceptor</literal> will catch hibernate StaleObjectExceptions 
+    (indicating optimistic locking failures) and retry to execute the command.
+    </para>
+    <para>The <literal>environment-interceptor</literal> will put an environment block 
+    around the execution of the command.
+    </para>
+    <para>The <literal>standard-transaction-interceptor</literal> will initialize a 
+    <literal>StandardTransaction</literal>.  The hibernate session/transaction will be 
+    enlisted as a resource with this standard transaction.
+    </para>
+    <para>Different configurations of this interceptor stack will also enable to 
+    </para>
+    <itemizedlist>
+      <listitem>delegate execution to a local ejb command service so that an container 
+      managed transaction is started.
+      </listitem>
+      <listitem>delegate to a remote ejb command service so that the command actually 
+      gets executed on a different JVM.
+      </listitem>
+      <listitem>package the command as an asynchronous message so that the command gets 
+      executed asynchronously in a different transaction.
+      </listitem>
+    </itemizedlist>
+  </section>
+
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch04-ImplementingBasicActivities.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,490 @@
+<chapter id="implementingbasicactivities">
+  <title>Implementing basic activities</title>
+  
+  <para>This chapter explains the basics of process definitions, the features offered by 
+  the Process Virtual Machine and how activity implementations can be build.   At the same 
+  time the client API is shown to execute processes with those activity implementations.  
+  </para>
+
+  <!-- ### Activity ####################################################### -->
+  <section id="activity">
+    <title>Activity</title>
+    <para>The PVM library doesn't have a fixed set of process constructs. 
+    Instead, runtime behaviour of a activity is delegated to an <literal>Activity</literal>.  
+    In other words, <literal>Activity</literal> is an interface to implement the runtime 
+    behaviour of process constructs in plain Java.
+    </para>
+    <programlisting>public <emphasis role="bold">interface Activity</emphasis> extends Serializable {
+    
+  void <emphasis role="bold">execute</emphasis>(ActivityExecution execution) throws Exception;
+  
+}</programlisting>
+    <para>When an activity is used as the activity behaviour, it is in full control of the further 
+    propagation of the execution.  In other words, a activity behaviour can decide what the execution 
+    should do next.  For example, it can take a transition with 
+    <literal>execution.take(Transition)</literal> or go into a wait state with 
+    <literal>execution.waitForSignal()</literal>.  In case the activity behaviour does not invoke 
+    any of the above execution propagation methods, the execution will 
+    <link linkend="implicitproceedbehaviour">proceed in a default way</link>.
+    </para>
+  </section>
+
+  <!-- ### Activity example ############################################### -->
+  <section id="activityexample">
+    <title>Activity example</title>
+    <para>We'll start with a very original hello world example.  A Display 
+    activity will print a message to the console:
+    </para>
+    <programlisting>public <emphasis role="bold">class Display</emphasis> implements <emphasis role="bold">Activity</emphasis> {
+
+  String message;
+
+  public Display(String message) {
+    this.message = message;
+  }
+
+  public void execute(ActivityExecution execution) {
+    <emphasis role="bold">System.out.println(message);</emphasis>
+  }
+}</programlisting>
+    <para>Let' build our first process definition with this activity:</para>
+    <figure id="activity.example">
+      <title>Display example process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.ab.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build()
+    .<emphasis role="bold">activity("a").initial()</emphasis>.behaviour(<emphasis role="bold">new Display("hello")</emphasis>)
+      .transition().to("b")
+    .<emphasis role="bold">activity("b")</emphasis>.behaviour(<emphasis role="bold">new Display("world")</emphasis>)
+.done();</programlisting>
+    <para>Now we can execute this process as follows:</para>
+    <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
+    <para>The invocation of <literal>startExecution</literal> will print hello world to the console:</para>
+    <programlisting>hello
+world</programlisting>
+    <para>One thing already worth noticing is that activities can be configured 
+    with properties.  In the Display example, you can see that the message property 
+    is configured differently in the two usages.  With configuration properties 
+    it becomes possible to write reusable activities. They can then be configured 
+    differently each time they are used in a process.  That is an essential part of 
+    how process languages can be build on top of the Process Virtual Machine.
+    </para>
+    <para>The other part that needs explanation is that this activity 
+    implementation does not contain any instructions for the propagation of the
+    execution.  When a new process instance is started, the execution is positioned
+    in the initial activity and that activity is executed.  The method 
+    <literal>Display.execute</literal> makes use of what is called implicit propagation 
+    of execution.  Concretely this means that the activity itself does not 
+    invoke any of the methods on the execution to propagate it.  In that case 
+    implicit propagation kicks in.  Implicit propagation will take the first 
+    transition if there is one.  If not, it will end the execution.  This explains 
+    why both activities <literal>a</literal> and <literal>b</literal> are executed and that 
+    the execution stops after activity <literal>b</literal> is executed. 
+    </para>
+    <para>More details about the implicit proceed behaviour can be found 
+    in <xref linkend="implicitproceedbehaviour" /></para>
+  </section>
+    
+  <!-- ### ExternalActivity ############################################### -->
+  <section id="externalactivity">
+    <title>ExternalActivity</title>
+    <para>External activities are activities for which the responsibility for proceeding 
+    the execution is transferred externally, meaning outside the process system. This 
+    means that for the system that is executing the process, it's a wait state.  The 
+    execution will wait until an external trigger is given.  
+    </para>
+    <para>For dealing with external triggers, <literal>ExternalActivity</literal> 
+    adds two methods to the <literal>Activity</literal>:</para>
+    <programlisting>public <emphasis role="bold">interface ExternalActivity</emphasis> extends <emphasis role="bold">Activity</emphasis> {
+
+  void <emphasis role="bold">signal</emphasis>(Execution execution,
+              String signal, 
+              Map&lt;String, Object&gt; parameters) throws Exception;
+              
+}</programlisting>
+    <para>Just like with plain activities, when an execution arrives in a activity, the 
+    <literal>execute</literal>-method of the activity behaviour is invoked.
+    In external activities, the execute method typically does something to 
+    transfer the responsibility to another system and then enters a wait 
+    state by invoking <literal>execution.waitForSignal()</literal>.  For 
+    example in the execute method, responsibility could be transferred to a 
+    person by creating a task entry in a task management system and then
+    wait until the person completes the task.
+    </para>
+    <para>In case a activity behaves as a wait state, then the execution will 
+    wait in that activity until the execution's <literal>signal</literal> method 
+    is invoked.  The execution will delegate that signal to the behaviour Activity 
+    of the current activity.
+    </para>
+    <para>So the Activity's <literal>signal</literal>-method is invoked 
+    when the execution receives an external trigger during the wait state.  With the 
+    signal method, responsibility is transferred back to the process execution. For 
+    example, when a person completes a task, the task management system calls the 
+    signal method on the execution.
+    </para>  
+    <para>A signal can optionally have a signal name and a map of parameters.  Most 
+    common way on how activity behaviours interprete the signal and parameters is that 
+    the signal relates to the outgoing transition that needs to be taken and that the 
+    parameters are set as variables on the execution. But those are just examples, it 
+    is up to the activity to use the signal and the parameters as it pleases.
+    </para>
+  </section>
+  
+  <!-- ### ExternalActivity example ####################################### -->
+  <section id="externalactivityexample">
+    <title>ExternalActivity example</title>
+    <para>Here's a first example of a simple wait state implementation:
+    </para>
+    <programlisting>public <emphasis role="bold">class WaitState</emphasis> implements <emphasis role="bold">ExternalActivity</emphasis> {
+
+  public void execute(ActivityExecution execution) {
+    <emphasis role="bold">execution.waitForSignal();</emphasis>
+  }
+
+  public void signal(ActivityExecution execution, 
+                     String signalName, 
+                     Map&lt;String, Object&gt; parameters) {
+    <emphasis role="bold">execution.take(signalName);</emphasis>
+  }
+}</programlisting>
+    <para>The <literal>execute</literal>-method calls 
+    <literal>execution.waitForSignal()</literal>.  The invocation of 
+    <literal>execution.waitForSignal()</literal> will bring the process execution 
+    into a wait state until an external trigger is given. 
+    </para>
+    <para><literal>signal</literal>-method takes the transition with 
+    the signal parameter as the transition name.  So when an execution receives an 
+    external trigger, the signal name is interpreted as the name of an outgoing
+    transition and the execution will be propagated over that transition.
+    </para>
+    <para>Here's the same simple process that has a transition from a to b.  This 
+    time, the behaviour of the two activities will be WaitState's.
+    </para>
+    <figure id="process.diagram">
+      <title>The external activity example process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.ab.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build()
+    <emphasis role="bold">.activity("a").initial().behaviour(new WaitState())</emphasis>
+      .transition().to("b")
+    <emphasis role="bold">.activity("b").behaviour(new WaitState())</emphasis>
+.done();</programlisting>
+    <para>Let's start a new process instance for this process definition:</para>
+    <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+    <para>Starting this process will execute the <literal>WaitState</literal> activity 
+    in activity <literal>a</literal>.  <literal>WaitState.execute</literal> will invoke 
+    <literal>ActivityExecution.waitForSignal</literal>.  So when the 
+    <literal>processDefinition.startProcessInstance()</literal> returns, the execution 
+    will still be positioned in activity a.  
+    </para>
+    <programlisting>assertEquals("a", execution.getActivityName());</programlisting>
+    <para>Then we provide the external trigger by calling the <literal>signal</literal> 
+    method.
+    </para>
+    <programlisting>execution.signal();</programlisting>
+    <para>The <literal>execution.signal()</literal> will delegate to the activity 
+    of the current activity.  So in this case that is the <literal>WaitState</literal>
+    activity in activity <literal>a</literal>.  The <literal>WaitState.signal</literal>
+    will invoke the <literal>ActivityExecution.take(String transitionName)</literal>.
+    Since we didn't supply a signalName, the first transition with name <literal>null</literal>
+    will be taken.  The only transition we specified out of activity <literal>a</literal> 
+    didn't get a name so that one will be taken.  And that transition points to activity 
+    <literal>b</literal>.  When the execution arrives in activity <literal>b</literal>,
+    the <literal>WaitState</literal> in activity <literal>b</literal> is executed. 
+    Similar as we saw above, the execution will wait in activity <literal>b</literal>
+    and this time the <literal>signal</literal> method will return, leaving the 
+    execution positioned in activity <literal>b</literal>.  
+    </para>
+    <programlisting>assertEquals("b", execution.getActivityName());</programlisting>
+  </section>
+  
+  <!-- ### BASIC PROCESS EXECUTION ######################################## -->
+  <section id="basicprocessexecution">
+    <title>Basic process execution</title>
+    <para>In this next example, we'll combine automatic activities and wait states.
+    This example builds upon the loan approval process with the <literal>WaitState</literal>
+    and <literal>Display</literal> activities that we've just created.  Graphically,
+    the loan process looks like this:  
+    </para>
+    <figure id="basicprocessexecution.loan.process">
+      <title>The loan process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.loan.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Building process graphs in Java code can be tedious because you have to keep track of all the 
+    references in local variables.  To resolve that, the Process Virtual Machine comes with a 
+    ProcessFactory.  The ProcessFactory is a kind of domain specific language (DSL) that is embedded 
+    in Java and eases the construction of process graphs.  This pattern is also known as 
+    a <ulink url="http://martinfowler.com/bliki/FluentInterface.html">fluent 
+    interface</ulink>.    
+    </para>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+  .activity(<emphasis role="bold">"submit loan request"</emphasis>).initial().behaviour(new Display("loan request submitted"))
+    .transition().to("evaluate")
+  <emphasis role="bold">.activity("evaluate").behaviour(new WaitState())</emphasis>
+    .transition("approve").to("wire money")
+    .transition("reject").to("end")
+  <emphasis role="bold">.activity("wire money").behaviour(new Display("wire the money"))</emphasis>
+    .transition().to("archive")
+  <emphasis role="bold">.activity("archive").behaviour(new WaitState())</emphasis>
+    .transition().to("end")
+  <emphasis role="bold">.activity("end").behaviour(new WaitState())</emphasis>
+.done();</programlisting>
+    <para>For more details about the ProcessFactory, see <ulink url="../../api/org/jbpm/pvm/package-summary.html">the
+    api docs</ulink>.  An alternative for 
+    the ProcessFactory would be to create an XML language and an XML parser for expressing 
+    processes.  The XML parser can then instantiate the classes of package 
+    <literal>org.jbpm.pvm.internal.model</literal> directly. That approach is typically taken by 
+    process languages.  
+    </para>
+    <para>The initial activity <literal>submit loan request</literal> and the activity 
+    <literal>wire the money</literal> are automatic activities.  In this example, 
+    the <literal>Display</literal> implementation of activity 
+    <literal>wire the money</literal> uses the Java API's to just print a 
+    message to the console.  But the witty reader can imagine an alternative 
+    <literal>Activity</literal> implementation that uses the Java API of a payment 
+    processing library to make a real automatic payment.  
+    </para>
+    <para>A new execution for the process above can be started like this
+    </para>
+    <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+    <para>When the <literal>startExecution</literal>-method returns, the activity 
+    <literal>submit loan request</literal> will be executed and the execution will be 
+    positioned in the activity <literal>evaluate</literal>.
+    </para>
+    <figure id="execution.loan.evaluate">
+      <title>Execution positioned in the 'evaluate' activity</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.loan.evaluate.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Now, the execution is at an interesting point.  There are two transitions out of 
+    the state <literal>evaluate</literal>.  One transition is called <literal>approve</literal> 
+    and one transition is called <literal>reject</literal>.  As we explained above, the WaitState
+    implementation will take the transition that corresponds to the signal that is given.  
+    Let's feed in the 'approve' signal like this:
+    </para>
+    <programlisting>execution.signal("approve");</programlisting>
+    <para>The <literal>approve</literal> signal will cause the execution to take the <literal>approve</literal>
+    transition and it will arrive in the activity <literal>wire money</literal>.
+    </para>
+    <para>In activity <literal>wire money</literal>, the message will be printed to the console.
+    Since, the <literal>Display</literal> activity didn't invoke the 
+    <literal>execution.waitForSignal()</literal>, nor any of the other execution propagation 
+    methods, the implicit proceed behaviour will just make the execution continue 
+    over the outgoing transition to activity <literal>archive</literal>, which is again 
+    a <literal>WaitState</literal>.
+    </para>
+    <figure id="execution.loan.archive">
+      <title>Execution positioned in 'archive' activity</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.loan.archive.png"/></imageobject></mediaobject>
+    </figure>
+    <para>So only when the <literal>archive</literal> wait state is reached, 
+    the <literal>signal("approve")</literal> returns.   
+    </para>
+    <para>Another signal like this:</para>
+    <programlisting>execution.signal("approve");</programlisting>
+    <para>will bring the execution eventually in the end state.</para>
+    <figure id="execution.loan.end">
+      <title>Execution positioned in the 'end' activity</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.loan.end.png"/></imageobject></mediaobject>
+    </figure>
+  </section>
+
+  <!-- ### EVENTS ######################################################### -->
+  <section id="events">
+    <title>Events</title>
+    <para>Events are points in the process definition to which a list of 
+    <literal>EventListener</literal>s can be subscribed. 
+    </para>
+    <programlisting>public interface EventListener extends Serializable {
+  
+  void notify(EventListenerExecution execution) throws Exception;
+
+}</programlisting>
+    <para>The motivation for events is to allow for 
+    developers to add programming logic to a process without changing the process diagram.  
+    This is a very valuable instrument in facilitating the collaboration between business analysts 
+    and developers.  Business analysts
+    are responsible for expressing the requirements.  When they use a process graph to document 
+    those requirements, developers can take this diagram and make it executable.  Events can 
+    be a very handy to insert technical details into a process (like e.g. some database insert) 
+    in which the business analyst is not interested.   
+    </para>
+    <para>Most common events are fired by the execution automatically:
+    </para>
+    <para>TODO: explain events in userguide</para>
+    <para>Events are identified by the combination of a process element 
+    and an event name.  Users and process languages can also fire events 
+    programmatically with the fire method on the Execution:
+    </para>
+    <programlisting>public interface Execution extends Serializable {
+  ...
+  void fire(String eventName, ProcessElement eventSource);
+  ...
+}</programlisting>
+    
+    <para>A list of <literal>EventListeners</literal> can be associated to an 
+    event. But event listeners can not influence the control flow of the execution since 
+    they are merely listeners to an execution which is already in progress.  This is different from 
+    activities that serve as the behaviour for activities.  Activity behaviour activities are responsible 
+    for propagating the execution. 
+    </para>
+    <para>We'll create a <literal>PrintLn</literal> event listener which is 
+    very similar to the <literal>Display</literal> activity from above.
+    </para>
+    <programlisting>public class PrintLn implements EventListener {
+  
+  String message;
+  
+  public PrintLn(String message) {
+    this.message = message;
+  }
+
+  public void notify(EventListenerExecution execution) throws Exception {
+    System.out.println("message");
+  }
+}</programlisting>
+    <para>Several <literal>PrintLn</literal> listeners will be subscribed to events in 
+    the process.</para>
+    <figure id="action.process">
+      <title>The PrintLn listener process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.ab.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build()
+  .activity("a").initial().behaviour(new AutomaticActivity())
+    <emphasis role="bold">.event("end")
+      .listener(new PrintLn("leaving a"))
+      .listener(new PrintLn("second message while leaving a"))</emphasis>
+    .transition().to("b")
+      <emphasis role="bold">.listener(new PrintLn("taking transition"))</emphasis>
+  .activity("b").behaviour(new WaitState())
+    .event("start")
+      <emphasis role="bold">.listener(new PrintLn("entering b"))</emphasis>
+.done();</programlisting>
+     <para>The first event shows how to register multiple listeners to the same 
+     event.  They will be notified in the order as they are specified.
+     </para>
+     <para>Then, on the transition, there is only one type of event.  So in that case,
+     the event type must not be specified and the listeners can be added directly on 
+     the transition.
+     </para>
+     <para>A listeners will be called each time an execution fires the event to 
+     which the listener is subscribed.  The execution will be provided in the activity 
+     interface as a parameter and can be used by listeners except for the methods that
+     control the propagation of execution.
+     </para>   
+   </section>
+
+  <!-- ### EVENT PROPAGATION ############################################## -->
+  <section>
+    <title>Event propagation</title>
+    <para>Events are by default propagated to enclosing process elements.  The motivation 
+    is to allow for listeners on process definitions or composite activities that get executed
+    for all events that occur within that process element.  For example this feature 
+    allows to register an event listener on a process definition or a composite activity on 
+    <literal>end</literal> events.  Such action will be executed if that activity is 
+    left.  And if that event listener is registered on a composite activity, it will also be executed 
+    for all activities that are left within that composite activity. 
+    </para>
+    <para>To show this clearly, we'll create a <literal>DisplaySource</literal> event listener
+    that will print the message <literal>leaving</literal> and the source of the event
+    to the console.
+    </para>
+    <programlisting>public class <emphasis role="bold">DisplaySource</emphasis> implements EventListener {
+    
+  public void execute(EventListenerExecution execution) {
+    <emphasis role="bold">System.out.println("leaving "+execution.getEventSource());</emphasis>
+  }
+}</programlisting>
+    <para>Note that the purpose of event listeners is not to be visible, that's why the event listener 
+    itself should not be displayed in the diagram. A <literal>DisplaySource</literal> event listener
+    will be added as a listener to the event <literal>end</literal> on the composite activity.  
+    </para>
+    <para>The next process shows how the <literal>DisplaySource</literal> event listener is registered 
+    as a listener to to the 'end' event on the <literal>composite</literal> activity:</para>
+    <figure id="process.propagate">
+      <title>A process with an invisible event listener on a end event on a composite activity.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.propagate.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>TODO update code snippet</programlisting>
+    <para>Next we'll start an execution.</para>
+    <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+    <para>After starting a new execution, the execution will be in activity <literal>a</literal> as 
+    that is the initial activity.  No activities have been left so no message is logged.  Next a signal 
+    will be given to the execution, causing it to take the transition from <literal>a</literal>
+    to <literal>b</literal>.
+    </para>
+    <programlisting>execution.signal();</programlisting>  
+    <para>When the signal method returns, the execution will have taken the transition and 
+    the <literal>end</literal> event will be fired on activity <literal>a</literal>.  That 
+    event will be propagated to the 
+    composite activity and to the process definition.  Since our <literal>DisplaySource</literal> 
+    event listener is placed 
+    on the <literal>composite</literal> activity, it will receive the event and print the following 
+    message on the console:
+    </para>
+    <programlisting>leaving activity(a)</programlisting>
+    <para>Another</para>
+    <programlisting>execution.signal();</programlisting>
+    <para>will take the transition from b to c.  That will fire two activity-leave events.  One on  
+    activity b and one on activity composite.  So the following lines will be appended to the console 
+    output:</para>  
+    <programlisting>leaving activity(b)
+leaving activity(composite)</programlisting>
+    <para>Event propagation is build on the hierarchical composition structure of the process 
+    definition.  The top level element is always the process definition.  The process 
+    definition contains a list of activities.  Each activity can be a leaf activity or it can be a 
+    composite activity, which means that it contains a list of nested activities.  Nested activities 
+    can be used for e.g. super states or composite activities in nested process languages like BPEL.    
+    </para>
+    <para>So the even model also works similarly for composite activities as it did for the process 
+    definition above.  Suppose that 'Phase one' models 
+    a super state as in state machines.  Then event propagation allows to subscribe to all events 
+    within that super state.  The idea is that the hierarchical composition corresponds to 
+    diagram representation. If an element 'e' is drawn inside another element 'p', then p 
+    is the parent of e. A process definition has a set of top level activities.  Every activity can have 
+    a set of nested activities.  The parent of a transition is considered as the first common 
+    parent for it's source and destination.  
+    </para>
+    <para>If an event listener is not interested in propagated events, propagation can be disabled 
+    with <literal>propagationDisabled()</literal> while building the process with the 
+    <literal>ProcessFactory</literal>.  The next process is the same process 
+    as above except that propagated events will be disabled on the event listener.  The graph diagram
+    remains the same.
+    </para>
+    <figure id="process.propagate.propagation.disabled">
+      <title>A process with an event listener to 'end' events with propagation disabled.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.propagate.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Building the process with the process factory:
+    </para>
+    <programlisting>TODO update code snippet</programlisting>
+    <para>So when the first signal is given for this process, again the <literal>end</literal> 
+    event will be fired on activity <literal>a</literal>, but now the event listener on the composite 
+    activity will not be executed cause 
+    propagated events have been disabled.  Disabling propagation is a property on the individual 
+    event listener and doesn't influence the other listeners.  The event will always be fired and 
+    propagated over the whole parent hierarchy.
+    </para>
+    <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+    <para>The first signal will take the process from <literal>a</literal> to 
+    <literal>b</literal>.  No messages will be printed to the console.
+    </para>
+    <programlisting>execution.signal();</programlisting>
+    <para>Next, the second signal will take the transition from b to c.  
+    </para>
+    <programlisting>execution.signal()</programlisting>
+    <para>Again two <literal>end</literal>
+    events are fired just like above on activities <literal>b</literal> and <literal>composite</literal> 
+    respectively.  The first event 
+    is the <literal>end</literal> event on activity <literal>b</literal>.  That will be propagated 
+    to the <literal>composite</literal> activity.  So the event 
+    listener will not be executed for this event cause it has propagation disabled.  But the 
+    event listener will be executed for the <literal>end</literal> event on the 
+    <literal>composite</literal> activity.  That is not 
+    propagated, but fired directly on the <literal>composite</literal> activity.  So the event 
+    listener will now be executed 
+    only once for the composite activity as shown in the following console output: 
+    </para>
+    <programlisting>leaving activity(composite)</programlisting>
+  </section>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch05-ProcessAnatomy.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch05-ProcessAnatomy.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch05-ProcessAnatomy.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+<chapter id="processanatomy">
+  <title>Process anatomy</title>
+  
+  <para>Above we already touched briefly on the two main process constructs: 
+  Activities, transitions and activity composition.  This chapter explores in full 
+  all the possibilities of the process definition structures.
+  </para>
+  
+  <para>There are basically two forms of process languages: graph based and composite 
+  process languages.  First of all, the process supports both.  Even graph based execution 
+  and activity composition can be used in combination to implement something like UML super states.
+  Furthermore, automatic functional activities can be implemented so that they can be 
+  used with transitions as well as with activity composition.
+  </para>
+
+  <figure id="process.anatomy">
+    <title>UML class diagram of the logical process structure</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/process.anatomy.classes.png"/></imageobject></mediaobject>
+  </figure>
+  
+  <para>Next we'll show a series of example diagram structures that can be formed 
+  with the PVM process model.
+  </para>
+  
+  <figure id="transition">
+    <title>Any two activities can be connected with a transition.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.png"/></imageobject></mediaobject>
+  </figure>
+
+  <figure id="self.transition">
+    <title>A self transition.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/self.transition.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="composite.activity">
+    <title>Composite activity is a list of nested activities.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/composite.activity.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="transition.into.composite">
+    <title>Transition to a activity inside a composite.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.into.composite.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="transition.out.of.composite">
+    <title>Transition from a activity inside a composite to a activity outside the composite.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.out.of.composite.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="transition.inheritence">
+    <title>Transition of composite activities are inherited.  The activity inside can take the transition of the composite activity.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.inheritence.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="transition.to.outer">
+    <title>Transition from a activity to an outer composite.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.outer.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="transition.to.inner">
+    <title>Transition from a composite activity to an inner composed activity.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.inner.png"/></imageobject></mediaobject>
+  </figure>
+  <figure id="initial.in.composite">
+    <title>An initial activity inside a composite activity.</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/initial.in.composite.png"/></imageobject></mediaobject>
+  </figure>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch06-ImplementingAdvancedActivities.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch06-ImplementingAdvancedActivities.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch06-ImplementingAdvancedActivities.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,393 @@
+<chapter id="advancedgraphexecution">
+  <title>Advanced graph execution</title>
+
+  <!-- ### LOOPS ########################################################## -->
+  <section>
+    <title>Loops</title>
+    <para>Activities can implement loops based on transitions or on activity composition.  
+    Loops can contain wait states.    
+    </para>
+    <para>To support high numbers of automatic loop executions, the Process Virtual Machine 
+    tranformed the propagation of execution from tail recursion to a while loop.
+    </para>
+  </section>
+
+  <!-- ### SUB PROCESSES ################################################## -->
+  <section>
+    <title>Sub processes</title>
+    <para>TODO: sub processes</para>
+  </section>
+  
+  <!-- ### DEFAULT PROCEED BEHAVIOUR ###################################### -->
+  <section id="implicitproceedbehaviour">
+    <title>Implicit proceed behaviour</title>
+    <para>When an <literal>Activity</literal> is used as activity behaviour, it can 
+    explicitely propagate the execution with following methods:
+    </para>
+    <itemizedlist>
+      <listitem><literal>waitForSignal()</literal></listitem>
+      <listitem><literal>take(Transition)</literal></listitem>
+      <listitem><literal>end(*)</literal></listitem>
+      <listitem><literal>execute(Activity)</literal></listitem>
+      <listitem><literal>createExecution(*)</literal></listitem>
+    </itemizedlist>
+    <para>When <literal>Activity</literal> implementations used for activity behviour 
+    don't call any of the following execution propagation methods, then, after 
+    the activity is executed, the execution will apply the implicit proceed behaviour. 
+    </para>
+    <para>The implicit proceed behaviour is defined as follows:</para>
+    <itemizedlist>
+      <listitem>If the current activity has a default outgoing transition, take it.</listitem>
+      <listitem>If the current activity has a parent activity, move back to the parent activity.</listitem>
+      <listitem>Otherwise, end this execution.</listitem>
+    </itemizedlist>
+    <para>Process languages can overwrite the implicit proceed behaviour 
+    by overriding the <literal>proceed</literal> method in 
+    <literal>ExecutionImpl</literal>.
+    </para>
+  </section>
+
+  <!-- ### FUNCTIONAL ACTIVITIES ################################ -->
+  <section id="functionalactivities">
+    <title>Functional activities</title>
+    <para>Activities that also can be used as event listeners are called functional 
+    activities. Examples of automatic activities are sending an email, doing a database 
+    update, generating a pdf, calculating an average, etc.  All of these are automatic 
+    activities that do not change the execution flow.  Here's how such activities can 
+    be implemented:  
+    </para>
+    <programlisting>public class FunctionalActivity implements Activity, EventListener {
+    public void execute(ActivityExecution execution) {
+      perform(execution);
+    }
+    public void notify(EventListenerExecution execution) {
+      perform(execution);
+    }
+    void perform(OpenExecution execution) {
+      ...do functional work...
+    }
+  }</programlisting>
+    <para>The <literal>perform</literal> method takes an <literal>OpenExecution</literal>, 
+    which is the supertype of both <literal>ActivityExecution</literal> and 
+    <literal>EventListenerExecution</literal>.  <literal>OpenExecution</literal>
+    does not allow any of the specific purpose methods, but still 
+    the current state and the process definition can be inspected as well 
+    as the variables, which contain the context information for the process 
+    execution.
+    </para>
+    <para>None of these methods actually invoke execution propagation methods.
+    So after the perform method is completed, the execution will
+    <link linkend="implicitproceedbehaviour">proceed in the default way</link>.
+    </para>
+  </section>
+    
+
+  <!-- ### EXECUTION AND THREADS ########################################## -->
+  <section id="executionandthreads">
+    <title>Execution and threads</title>
+    <para>This section explains how the Process Virtual Machine boroughs the thread
+    from the client to bring an execution from one wait state to another.
+    </para>
+    <para>When a client invokes a method (like e.g. the signal method) on an execution, 
+    by default, the Process Virtual Machine will use that thread to progress the execution
+    until it reached a wait state.  Once the next wait state has been reached, the 
+    method returns and the client gets the thread back.  This is the default way 
+    for the Process Virtual Machine to operate.  Two more levels of asynchonous 
+    execution complement this default behaviour: 
+    <link linkend="asynchronouscontinuations">Asynchronous continuations</link>
+    and the <link linkend="architecture">asynchronous command service</link>.
+    </para>
+    <para>The next process will show the basics concretely.  It has three wait states 
+    and four automatic activities.
+    </para>
+    <figure id="process.automatic">
+      <title>Process with many sequential automatic activities.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.automatic.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Here's how to build the process:</para>
+    <programlisting>ClientProcessDefinition processDefinition = ProcessFactory.build("automatic")
+    .<emphasis role="bold">activity("wait 1").initial()</emphasis>.behaviour(new <emphasis role="bold">WaitState</emphasis>())
+      .transition().to("automatic 1")
+    .<emphasis role="bold">activity("automatic 1")</emphasis>.behaviour(new <emphasis role="bold">Display("one")</emphasis>)
+      .transition().to("wait 2")
+    .<emphasis role="bold">activity("wait 2")</emphasis>.behaviour(new <emphasis role="bold">WaitState</emphasis>())
+      .transition().to("automatic 2")
+    .<emphasis role="bold">activity("automatic 2")</emphasis>.behaviour(new <emphasis role="bold">Display("two")</emphasis>)
+      .transition().to("automatic 3")
+    .<emphasis role="bold">activity("automatic 3")</emphasis>.behaviour(new <emphasis role="bold">Display("three")</emphasis>)
+      .transition().to("automatic 4")
+    .<emphasis role="bold">activity("automatic 4")</emphasis>.behaviour(new <emphasis role="bold">Display("four")</emphasis>)
+      .transition().to("wait 3")
+    .<emphasis role="bold">activity("wait 3")</emphasis>.behaviour(new <emphasis role="bold">WaitState</emphasis>())
+.done();</programlisting>
+    <para>Let's walk you through one execution of this process.  
+    </para>
+    <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
+    <para>Starting a new execution means that the initial activity is executed.  So if an automatic 
+    activity is the initial activity, this means that immediately the first unnamed outgoing transition 
+    is taken.  This happens all inside of the invocation of <literal>startProcessInstance</literal>.
+    </para>
+    <para>In this case however, the initial activity is a wait state.  So 
+    the method <literal>startProcessInstance</literal> returns immediately and the execution will be 
+    positioned in the initial activity 'wait 1'.
+    </para>
+    <figure id="execution.automatic.wait1">
+      <title>A new execution will be positioned in 'wait 1'.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.automatic.wait1.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Then an external trigger is given with the signal method.</para>
+    <programlisting>execution.signal();</programlisting>
+    <para>As explained above when <link linkend="externalactivityexample">introducing the WaitState</link>, 
+    that signal will cause the default transition to be taken.  The 
+    transition will move the execution to activity <literal>automatic 1</literal> and execute it.  
+    The execute method of the <literal>Display</literal> activity in <literal>automatic 1</literal> 
+    print a line to the console and it will <emphasis role="bold">not</emphasis> call 
+    <literal>execution.waitForSignal()</literal>.  Therefore, the execution will proceed by 
+    taking the default transition out of <literal>automatic 1</literal>.  At this stage, the 
+    signal method is still blocking.  Another way to think about it is that the execution 
+    methods like <literal>signal</literal> will use the thread of the client to interpret 
+    the process definition until a wait state is reached.   
+    </para>
+    <para>Then the execution arrives in <literal>wait 2</literal> and executes 
+    the <literal>WaitState</literal> activity.  That method will invoke 
+    the <literal>execution.waitForSignal()</literal>, which will cause the signal method 
+    to return.  That is when the thread is given back to the client that invoked the 
+    <literal>signal</literal> method.
+    </para>
+    <para>So when the signal method returns, the execution is positioned in <literal>wait 2</literal>.</para>
+    <figure id="execution.automatic.wait2">
+      <title>One signal brought the execution from 'initial' to 'wait 2'.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.automatic.wait2.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Then the execution is now waiting for an external trigger just as an object 
+    (more precisely an object graph) in memory until the next external trigger is given 
+    with the signal method.
+    </para>
+    <programlisting>execution.signal();</programlisting>
+    <para>This second invocation of signal will take the execution similarly all the 
+    way to <literal>wait 3</literal> before it returns.
+    </para>
+    <figure id="automatic.wait3">
+      <title>The second signal brought the execution all the way to 'wait 3'.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/ch04.automatic.wait3.png"/></imageobject></mediaobject>
+    </figure>
+    <para>The benefits of using this paradigm is that the same process definition 
+    can be executed in <link linkend="clientexecutionmode">client execution mode</link> 
+    (in-memory without persistence) as well as in <link linkend="persistentexecutionmode">
+    persistent execution mode</link>, depending on the application and on the environment.
+    </para>
+    <para>When executing a process in persistent mode, this is how you typically want 
+    to bind that process execution to transactions of the database:
+    </para>
+    <figure id="transactions.png">
+      <title>Transactions over time in persistent execution mode.</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/transactions.png"/></imageobject></mediaobject>
+    </figure>
+    <para>In most situations, the computational work that needs to be done as part of 
+    the process after an external trigger (the red pieces) is pretty minimal.  Typically 
+    transactions combining the process execution and processing the request from the 
+    UI takes typically less then a second.  Whereas the wait state in business processes 
+    typically can span for hours, days or even years.  The clue is to clearly distinct 
+    when a wait state starts so that only the computational work done before the start 
+    of that wait state should be included in the transaction.  
+    </para>
+    <para>Think of 
+    it this way: &quot;When an approval arrives, what are all the automated processing that 
+    needs to be done before the process system needs to wait for another external 
+    trigger?&quot;  Unless pdf's need to be generated or mass emails need to be send,
+    the amount of time that this takes is usually neglectable.  That is why in the 
+    default persistent execution mode, the process work is executed in the thread 
+    of the client.
+    </para>
+    <para>This reasoning even holds in case of concurrent paths of execution.  
+    When a single path of execution splits into concurrent paths of execution,
+    the process overhead of calculating that is neglectable.  So that is why it 
+    makes sense for a fork or split activity implementation that targets persistent 
+    execution mode to spawn the concurrent paths sequentially in the same thread.
+    Basically it's all just computational work as part of the same transaction.
+    This can only be done because the fork/split knows that each concurrent path 
+    of execution will return whenever a wait state is encountered. 
+    </para>
+    <para>Since this is a difficult concept to grasp, I'll explain it again with other 
+    words.  Look at it from the overhead that is produced by the process execution 
+    itself in persistent execution mode.  If in a transaction, an execution is given 
+    an external trigger and that causes the execution to split into multiple concurrent 
+    paths of execution.  Then the process overhead of calculating this is neglectable. 
+    Also the overhead of the generated SQL is neglectable.  And since all the work done 
+    in the concurrent branches must be done inside that single transaction, there is 
+    typically no point in having fork/split implementations spawn the concurrent 
+    paths of execution in multiple threads. 
+    </para>
+    <para>To make executable processes, developers need to know exactly what the automatic activities
+    are, what the wait states are and which threads will be allocated to the process execution.  
+    For business analysts that draw the analysis process, things are a bit simpler.   For the  
+    activities they draw, they usually know whether it's a human or a system that is responsible.
+    But they typically don't not how this translates to threads and transactions.
+    </para>
+    <para>So for the developer, the first job is to analyse what needs to be executed 
+    within the thread of control of the process and what is outside.  Looking for the external 
+    triggers can be a good start to find the wait states in a process, just like verbs and nouns 
+    can be the rule of thumb in building UML class diagrams. 
+    </para>
+  </section>
+  
+  <!-- ### PROCESS CONCURRENCY ############################################ -->
+  <section>
+    <title>Process concurrency</title>
+    <para>To model process concurrency, there is a parent-child tree structure on the 
+    execution. The idea is that the main path of execution is the root of that tree.
+    The main path of execution is also called the process instance.  It is the execution 
+    that is created when starting or creating a new process instance for a given  
+    process definition. 
+    </para>
+    <para>Now, because the main path of execution is the same object as the 
+    process instance, this keeps the usage simple in case of simple processes 
+    without concurrency. 
+    </para>
+    <figure id="execution.structure">
+      <title>UML class diagram of the basic execution structure</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/class.diagram.process.execution.png"/></imageobject></mediaobject>
+    </figure>
+    <para>To establish multiple concurrent paths of execution, activity implementations 
+    like a fork or split can create child executions with method 
+    <literal>ActivityExecution.createExecution</literal>.  Activity implementations 
+    like join or merge can stop these concurrent paths of execution by calling 
+    method <literal>stop</literal> on the concurrent execution.  
+    </para>
+    <para>Only leaf executions can be active.  Non-leave executions should be 
+    inactive.  This tree structure of executions doesn't enforce a particular type of 
+    concurrency or join behaviour.  It's up to the forks or and-splits and to the joins 
+    or and-merges to use the execution tree structure in any way they want to define 
+    the wanted concurrency behaviour.  Here you see an example 
+    of concurrent executions. 
+    </para>
+    <figure id="concurrency">
+      <title>Concurrent paths of execution</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/execution.concurrency.png"/></imageobject></mediaobject>
+    </figure>
+    <para>There is a billing and a shipping path of execution.  In this case, the 
+    flat bar activities represent activities that fork and join.  The execution shows a three 
+    executions.  The main path of execution is inactive (represented as gray) and the 
+    billing and shipping paths of execution are active and point to the activity 
+    <literal>bill</literal> and <literal>ship</literal> respectively.
+    </para>
+    <para>It's up to the activity behaviour implementations how they want to use this 
+    execution structure.  Suppose that multiple tasks have to be completed before the 
+    execution is to proceed.  The activity behaviour can spawn a series of child executions 
+    for this.  Or alternatively, the task component could support task groups that 
+    are associated to one single execution.  In that case, the task component becomes
+    responsible for synchronizing the tasks, thereby moving this responsibility 
+    outside the scope of the execution tree structure.
+    </para>
+  </section>
+
+  <!-- ### EXCEPTION HANDLERS ############################################# -->
+  <section>
+    <title>Exception handlers</title>
+    <para>In all the code that is associated to a process
+    like <literal>Activity</literal>s, <literal>EventListeners</literal> and 
+    <literal>Condition</literal>s, it's possible to associate exception handlers.  This 
+    can be thought of as including try-catch blocks in 
+    the method implementations of those implementations.  But in order to build more reusable building 
+    blocks for both the delegation classes and the exception handling logic, exception handlers are 
+    added to the core process model. 
+    </para>
+    <para>An exception handler can be associated to any process element.  When an exception 
+    occurs in a delegation class, a matching exception handler will be searched for.  If 
+    such an exception handler is found, it will get a chance to handle the exception.
+    </para>
+    <para>If an exception handler completes without problems, then the exception is considered 
+    handled and the execution resumes right after the delegation code that was called.  For example,
+    a transition has three actions and the second action throws an exception that is handled 
+    by an exception handler, then   
+    </para>
+    <para>Writing automatic activities that are exception handler aware is easy.  The 
+    default is to proceed anyway.  No method needs to be called on the execution.  So 
+    if an automatic activity throws an exception that is handled by an exception handler,
+    the execution will just proceed after that activity.  It becomes a big more difficult 
+    for control flow activities.  They might have to include try-finally blocks to 
+    invoke the proper methods on the execution before an exception handler gets a 
+    chance to handle the exception.  For example, if an activity is a wait state and 
+    an exception occurs, then there is a risk that the thread jumps over the 
+    invocation of <literal>execution.waitForSignal()</literal>, causing the execution 
+    to proceed after the activity. 
+    </para>
+    <para>TODO: exceptionhandler.isRethrowMasked</para>
+    <para>TODO: transactional exception handlers</para>
+    <para>TODO: we never catch errors</para>
+  </section>
+
+  <!-- ### PROCESS MODIFICATIONS ########################################## -->
+  <section>
+    <title>Process modifications</title>
+    <para>TODO: process modifications</para>
+  </section>
+
+  <!-- ### LOCKING AND EXECUTION STATE #################################### -->
+  <section>
+    <title>Locking and execution state</title>
+    <para>The state of an execution is either active or locked. An active 
+    execution is either executing or waiting for an external trigger. If an 
+    execution is not in <literal>STATE_ACTIVE</literal>, then it is locked. 
+    A locked execution is read only and cannot receive any external triggers.
+    </para> 
+    <para>When a new execution is created, it is in STATE_ACTIVE. To change 
+    the state to a locked state, use lock(String). Some STATE_* constants 
+    are provided that represent the most commonly used locked states. But 
+    the state '...' in the picture indicates that any string can be provided 
+    as the state in the lock method.
+    </para>
+    <figure id="execution.states">
+      <title>States of an execution</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/ch04.execution.states.png"/></imageobject></mediaobject>
+    </figure>
+    <para>If an execution is locked, methods that change the execution will 
+    throw a PvmException and the message will reference the actual locking state. 
+    Firing events, updating variables, updating priority and adding comments 
+    are not considered to change an execution. Also creation and removal of child 
+    executions are unchecked, which means that those methods can be invoked by 
+    external API clients and activity behaviour methods, even while the execution 
+    is in a locked state.
+    </para> 
+    <para>Make sure that comparisons between getState() and the STATE_* constants 
+    are done with .equals and not with '==' because if executions are loaded 
+    from persistent storage, a new string is created instead of the constants.
+    </para> 
+    <para>An execution implementation will be locked:
+    </para>
+    <itemizedlist>
+      <listitem>When it is ended</listitem>
+      <listitem>When it is suspended</listitem>
+      <listitem>During asynchronous continuations</listitem>
+    </itemizedlist>
+    <para>Furthermore, locking can be used by Activity implementations to make 
+    executions read only during wait states hen responsibility for the execution is 
+    transferred to an external entity such as:
+    </para>
+    <itemizedlist>
+      <listitem>A human task</listitem>
+      <listitem>A service invocation</listitem>
+      <listitem>A wait state that ends when a scanner detects that a file appears</listitem>
+    </itemizedlist>
+    <para>In these situations the strategy is that the external entity should get 
+    full control over the execution because it wants to control what is allowed 
+    and what not.  To get that control, they lock the execution so that all interactions 
+    have to go through the external entity. 
+    </para>
+    <para>One of the main reasons to create external entities is that they can live
+    on after the execution has already proceeded.  For example, in case 
+    of a service invocation, a timer could cause the execution to take the timeout transition.
+    When the response arrives after the timeout, the service invocation entity should 
+    make sure it doesn't signal the execution.  So the service invocation can be 
+    seen as a activity instance (aka activity instance) and is unique for every execution 
+    of the activity.
+    </para>
+    <para>External entities themselves are responsible for managing the execution 
+    lock.  If the timers and client applications are consequent in addressing the 
+    external entities instead of the execution directly, then locking is in theory 
+    unnecessary.  It's up to the activity behaviour implementations whether they want 
+    to take the overhead of locking and unlocking.
+    </para>
+  </section>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch07-Variables.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch07-Variables.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch07-Variables.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<chapter id="variables">
+  <title>Variables</title>
+  <para>TODO</para>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch08-Timers.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch08-Timers.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch08-Timers.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<chapter id="timers">
+  <title>Timers</title>
+  <para>TODO</para>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch09-AsynchronousContinuations.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch09-AsynchronousContinuations.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch09-AsynchronousContinuations.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<chapter id="asynchronouscontinuations">
+  <title>Asynchronous continuations</title>
+  <para>TODO</para>
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch10-SoftwareLogging.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch10-SoftwareLogging.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch10-SoftwareLogging.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+<chapter id="softwarelogging">
+  <title>Software logging</title>
+
+  <section>
+    <title>Configuration</title>
+    <para>PVM can use JDK logging (java.util.logging) or log4j. When the first message is 
+    logged, PVM logging will make the selection with following procedure:
+    <orderedlist>
+      <listitem>If a <literal>logging.properties</literal> resource is found 
+      on the classpath (using the context classloader), then JDK logging will 
+      be used and that file will be used to initialize the JDK logging.
+      </listitem>
+      <listitem>If log4j is found on the classpath, then log4j will be used.
+      The check for log4j will be done by checking availability of class 
+      <literal>org.apache.log4j.LogManager</literal> with the context classloader.
+      </listitem>
+      <listitem>If none of the above, JDK logging will be used.</listitem>
+    </orderedlist>
+    </para>
+  </section>
+
+  <section>
+    <title>Categories</title>
+    <para>The PVM classes use their class name as the category for the logger.
+    </para>
+    <para>To have a basic understanding of what the PVM classes are doing, 
+    turning on the <literal>debug</literal> level is great.  Level 
+    <literal>trace</literal> might be spitting out too much for that 
+    purpose. 
+    </para>
+  </section>
+  
+  <section>
+    <title>JDK logging</title>
+    <para>In JDK logging, <literal>debug</literal>maps to <literal>fine</literal> 
+    and <literal>trace</literal> maps to <literal>finest</literal>. 
+    Level <literal>finer</literal> is not used.
+    </para>
+    <para><literal>org.jbpm.pvm.internal.log.LogFormatter</literal> is part of 
+    the pvm library and it can create a nice one-line output for log messages.
+    It also has a neat feature that creates a unique indentation per thread.
+    To configure it, this is a typical <literal>logging.properties</literal>
+    </para>
+    <programlisting>handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.pvm.internal.log.LogFormatter
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+.level = SEVERE
+org.jbpm.level=FINE
+org.jbpm.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE</programlisting>
+
+<!-- 
+    <para>For production usage, jBPM also includes an error triggered log handler.  This is 
+    a log handler that will only keep the most recent log messages in 
+    memory and these will only be flushed to a file in case an error occurs.
+    </para>
+    <para>to configure it, add <literal>org.jbpm.util.ErrorTriggeredFileHandler</literal>
+    to the handlers in the logging properties like this:
+    </para>
+    <programlisting>handlers = java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler</programlisting>
+    <para>Next snippet shows how in the same logging.properties, the error 
+    triggered file handler can be configured.  The given values are the default 
+    values.
+    </para>
+    <programlisting>org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+org.jbpm.util.ErrorTriggeredFileHandler.push = SEVERE
+org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log</programlisting>
+    <para>Alternatively to using the org.jbpm.util.ErrorTriggeredFileHandler, the 
+    JDK handlers FileHandler and MemoryHandler can used in combination to get 
+    similar results with a bit more configuration.
+    </para>
+
+-->    
+  </section>
+
+  <section>
+    <title>Debugging persistence</title>
+    <para>When testing the persistence, following logging configurations can be 
+    valuable.  Category <literal>org.hibernate.SQL</literal> shows the SQL statement that is executed 
+    and category <literal>org.hibernate.type</literal> shows the values of the parameters that are 
+    set in the queries. 
+    </para>
+    <programlisting>org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST</programlisting>
+    <para>And in case you get a failed batch as a cause in a hibernate exception,
+    you might want to set the batch size to 0 like this in the hibernate properties:
+    </para>
+    <programlisting>hibernate.jdbc.batch_size = 0</programlisting>
+    <para>Also in the hibernate properties, the following properties allow for 
+    detailed logs of the SQL that hibernate spits out:</para>
+    <programlisting>hibernate.show_sql = true
+hibernate.format_sql = true
+hibernate.use_sql_comments = true</programlisting>
+  </section>
+</chapter>  
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch11-History.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch11-History.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/ch11-History.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+<chapter id="history">
+  <title>History</title>
+
+  <section id="overview">
+    <title>Overview</title>
+    
+    <para>HistoryEvents are fired during process execution.
+    </para>
+
+    <para>We maintain history information on 2 levels: process instance and activity instance.
+    </para>
+
+    <para>Process instance start and process instance end generate history events are fired directly 
+    from within the implementation.
+    </para>
+
+    <para>ActivityBehaviour implementations are responsible for calling the historyXxx methods that 
+    are exposed on the ActivityExecution
+    </para>
+
+    <para>All the HistoryEvents are delegated to a HistorySession.  The default HistorySessionImpl 
+    will invoke the process() method on the history events themselves.
+    </para>
+
+    <para>The HistoryEvents are temporary events.  In the process method, they build up the information 
+    in the history model.  There is a HistoryProcessInstance and there is a whole class hierarchy starting with HistoryActivityInstance.   
+    </para>
+
+    <para>In the HistoryEvent.process methods, the history events create model entities or merge 
+    information into the model entities.  For instance, a ProcessInstanceStart history event will 
+    create a HistoryProcessInstance entity/record.  And the ProcessInstanceEnd will set the endTime 
+    property in the existing HistoryProcessInstance entity/record.  
+    </para>
+
+    <para>Similar pattern for the activities.  But for automatic activities, there is an optimisation 
+    so that only 1 event is created and all the information is stored in one single insert (as all 
+    this happens inside 1 transaction).
+    </para>
+
+  </section>
+
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-DelegationClasses.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-DelegationClasses.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-DelegationClasses.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+<chapter id="delegationclasses">
+  <title>Delegation classes</title>
+  
+   <section>
+     <title>What are delegation classes</title>
+     <para>Delegation classes are the classes that implement 
+     <literal>Activity</literal> or <literal>Condition</literal>.  From the Process 
+     Virtual Machine's perspective, these are external classes that provide 
+     programming logic that is inserted into the PVM's graph execution.
+     Delegation classes can be provided by the process languages as well 
+     as by the end users.
+     </para>
+   </section>
+
+   <section>
+     <title>Configuration of delegation classes</title>
+     <para>Delegation classes can be made configurable.  Member fields can 
+     contain configuration parameters so that a delegation class can be 
+     configured differently each time it is used.  For example, in the 
+     <literal><link linkend="activity">Display</link></literal> activity,
+     the message that is to be printed to the console is a configuration 
+     parameter.
+     </para>
+     <para>Delegation classes should be stateless.  This means that executing the interface 
+     methods should not change values of the member fields.  Changing member field values 
+     of delegation classes during execution methods is actually changing the process 
+     while it's executing.  That is not threadsafe and usually leads to unexpected 
+     results.  As an exception, getters and setters might be made available to inject 
+     the configuration cause they are used before the delegation object is actually 
+     used in the process execution.
+     </para>
+  </section>
+
+  <section>
+    <title>Object references</title>
+    <para>TODO</para>
+  </section>
+  
+   <section>
+     <title>Design time versus runtime</title>
+     <para>TODO: the activity behaviour allows for design time as well as runtime behaviour.</para>
+   </section>
+    
+   <section>
+     <title>UserCodeInterceptor</title>
+     <para>TODO: UserCodeInterceptor</para>
+   </section>
+    
+   <section>
+     <title>Member field configurations versus properties</title>
+     <para>TODO: document field configurations versus properties</para>
+   </section>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Environment.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Environment.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Environment.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,139 @@
+<chapter id="environment">
+  <title>Environment</title>
+  
+  <section>
+    <title>Introduction</title>
+    <para>The environment component together with the wire context is a kind of 
+    Inversion of Control (IoC) container.  It reads configuration information that 
+    describes how objects should be instantiated, configured and wired together.
+    </para>
+    <para>The environment is used to retrieve resources and services needed by 
+    <literal>Activity</literal> implementations and the Process Virtual Machine 
+    itself.  The main purpose is to make various aspects of the Process Virtual Machine 
+    configurable so that the PVM and the languages that run on top can work 
+    in a standard Java environment as well as an enterprise Java environment.
+    </para>
+    <para>The environment is partitioned into a set of contexts.  Each context 
+    can have its own lifecycle.  For instance, the process-engine context will 
+    strech over the full lifetime of the application.  The block context only 
+    for the duration of a try-finally block.  Typically a block context represents 
+    a database transaction.  Each context exposes a list of key-value 
+    pairs. 
+    </para>
+  </section>
+  
+  <section id="environmentfactory">
+    <title>EnvironmentFactory</title>
+    <para>To start working with an environment, you need an EnvironmentFactory.
+    One single environment factory object can be used throughout the complete 
+    lifetime of the application.  So typically this is kept in a static 
+    member field.  The EnvironmentFactory itself is the process-engine context.
+    </para>
+    <para>An <literal>EnvironmentFactory</literal> is typically obtained by 
+    parsing a configuration file like this:
+    </para>
+    <programlisting>static EnvironmentFactory environmentFactory = 
+        EnvironmentFactory.parse(new ResourceStreamSource("pvm.cfg.xml");</programlisting>
+    <para>See javadocs package org.jbpm.stream for more types of stream sources.
+    </para>
+    <para>There is a default parser in the environment factory that will 
+    create <literal>DefaultEnvironmentFactory</literal>s.  The idea is that we'll 
+    also support spring as an IoC container.  But that is still TODO.  Feel free 
+    to help us out :-).  The parser can be configured with the static setter 
+    method <literal>EnvironmentFactory.setParser(Parser)</literal>
+    </para>
+  </section>
+    
+  <section id="environmentblock">
+    <title>Environment block</title>
+    <para>An environment exists for the duration of a try-finally block.  This is how 
+    an environment block looks like:
+    </para>
+    <programlisting><emphasis role="bold">Environment environment = environmentFactory.openEnvironment();
+try {
+
+  ...
+
+} finally {
+  environment.close();
+}</emphasis></programlisting>
+    <para>The environment block defines another lifespan: the <literal>block</literal> context.  
+    A transaction would be a typical example of an object that is defined in the block 
+    context. 
+    </para>
+    <para>Inside such a block, objects can be looked up from the environment by name 
+    or by type.  If objects can looked up from the environment with method 
+    <literal>environment.get(String name)</literal> or 
+    <literal>&lt;T&gt; T environment.get(Class&lt;T&gt;)</literal>.  
+    </para>
+    <para>when an environment is created, it has a <literal>process-engine</literal> context 
+    and a <literal>block</literal>
+    context.  
+    </para>
+    <para>In the default implementation, the <literal>process-engine</literal> context and 
+    the <literal>block</literal> context are <literal>WireContext</literal>s.  A 
+    <literal>WireContext</literal> contains a description of how its objects are 
+    created and wired together to form object graphs.
+    </para>
+  </section>
+  
+  <section>
+    <title>Example</title>
+    <para>To start with a simple example, we'll need a <literal>Book</literal>:</para>
+    <programlisting>public class <emphasis role="bold">Book</emphasis> {
+  ...
+  public Book() {}
+  ...
+}</programlisting>
+    <para>Then let's create an environment factory that knows how to create book</para>
+    <programlisting>static EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString(
+    "&lt;jbpm-configuration&gt;" +
+    "  &lt;process-engine&gt;" +
+    "    &lt;object name='book' class='org.jbpm.examples.ch09.Book' /&gt;" +
+    "  &lt;/process-engine&gt;" +
+    "&lt;/jbpm-configuration&gt;"
+));</programlisting>
+    <para>Now we'll create an environment block with this environment factory and 
+    we'll look up the book in the environment.  First the lookup is done by 
+    type and secondly by name.
+    </para>
+    <programlisting>Environment environment = environmentFactory.openEnvironment();
+try {
+  
+  Book book = <emphasis role="bold">environment.get(Book.class);</emphasis>
+  assertNotNull(book);
+  
+  assertSame(book, <emphasis role="bold">environment.get("book")</emphasis>);
+  
+} finally {
+  environment.close();
+}</programlisting>
+    <para>To prevent that you have to pass the environment as a parameter in 
+    all methods, the current environment is maintained in a threadlocal stack:
+    </para>
+    <programlisting>Environment environment = Environment.getCurrent();</programlisting>
+  </section>
+  
+  <section id="context">
+    <title>Context</title>
+    <para>Contexts can be added and removed dynamically.  Anything can be exposed 
+    as a <literal>Context</literal>.
+    </para>
+    <programlisting>public interface <emphasis role="bold">Context</emphasis> {
+  
+  <emphasis role="bold">Object get(String key);
+  &lt;T&gt; T get(Class&lt;T&gt; type);
+  Set&lt;String&gt; keys();</emphasis>
+
+  ...
+}</programlisting>
+    <para>When doing a lookup on the environment, there is a default search order 
+    in which the contexts will be scanned for the requested object.  The default 
+    order is the inverse of the sequence in which the contexts were added.  E.g.
+    if an object is defined in both the process-engine context and in the block context,
+    the block context is considered more applicable and that will be scanned first.
+    Alternatively, an explicit search order can be passed in with the 
+    <literal>get</literal> lookups as an optional parameter.
+    </para>
+  </section>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Persistence.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Persistence.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-Persistence.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,267 @@
+<chapter id="persistence">
+  <title>Persistence</title>
+  
+  <section>
+    <title>Standard environment configuration</title>
+	  <para>This section describes how the environment can be configured to use 
+	  hibernate in a standard Java environment.
+	  </para>
+	  <programlisting>01 | &lt;jbpm-configuration&gt;
+02 | 
+03 |   &lt;process-engine&gt;
+04 |<emphasis role="bold">     &lt;hibernate-session-factory /&gt;</emphasis>
+05 |<emphasis role="bold">     &lt;hibernate-configuration&gt;</emphasis>
+06 |<emphasis role="bold">       &lt;properties resource=&quot;hibernate.properties&quot; /&gt;</emphasis>
+07 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.typedefs.hbm.xml&quot; /&gt;</emphasis>
+08 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.wire.hbm.xml&quot; /&gt;</emphasis>
+09 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.definition.hbm.xml&quot; /&gt;</emphasis>
+10 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.execution.hbm.xml&quot; /&gt;</emphasis>
+11 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.variable.hbm.xml&quot; /&gt;</emphasis>
+12 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.pvm.job.hbm.xml&quot; /&gt;</emphasis>
+13 |<emphasis role="bold">       &lt;mapping resource=&quot;jbpm.jpdl.hbm.xml&quot; /&gt;</emphasis>
+14 |<emphasis role="bold">       &lt;cache-configuration resource=&quot;jbpm.pvm.cache.xml&quot;</emphasis> 
+15 |<emphasis role="bold">                           usage=&quot;nonstrict-read-write&quot; /&gt;</emphasis>
+16 |<emphasis role="bold">     &lt;/hibernate-configuration&gt;</emphasis>
+17 |   &lt;/process-engine&gt;
+18 |
+19 |   &lt;transaction-context&gt;
+20 |<emphasis role="bold">     &lt;standard-transaction /&gt;</emphasis>
+21 |<emphasis role="bold">     &lt;hibernate-session /&gt;</emphasis>
+22 |<emphasis role="bold">     &lt;pvm-db-session /&gt;</emphasis>
+23 |   &lt;/transaction-context&gt;
+24 |
+25 | &lt;/jbpm-configuration&gt;</programlisting>
+    <para><literal>line 04</literal> specifies a hibernate session factory in the 
+    process-engine context.  This means that a hibernate session factory is lazy 
+    created when it is first needed and cached in the 
+    <literal>EnvironmentFactory</literal>.
+    </para>
+    <para>A hibernate session factory is build calling the 
+    method <literal>buildSessionFactory()</literal> on a hibernate configuration.
+    By default, the hibernate configuration will be looked up by type.
+    </para>
+    <para><literal>line 05</literal> specifies a hibernate configuration.  
+    </para>
+    <para><literal>line 06</literal> specifies the that the resource file 
+    <literal>hibernate.properties</literal> should be loaded into the configuration. 
+    </para>
+    <para><literal>line 07 - 13</literal> specifies the mapping resources files.
+    </para>
+    <para><literal>line 14 - 15</literal> provide a single place to specify the 
+    hibernate caching strategy for all the PVM classes and collections.  
+    </para>
+    <para><literal>line 20</literal> specifies a standard transaction.  This is 
+    a very simple global transaction strategy without recovery that can be used 
+    in standard environments to get all-or-nothing semantics over multiple 
+    transactional resources.  
+    </para>
+    <para><literal>line 21</literal> specifies the hibernate session that will 
+    automatically register itself with the standard transaction.  
+    </para>
+    <para><literal>line 22</literal> specifies a <literal>PvmDbSession</literal>.
+    That is a class that adds methods that bind to specific queries to be executed
+    on the hibernate session.
+    </para>
+  </section>
+
+  <section>
+    <title>Standard hibernate configuration</title>
+    <para>Here is a set of default properties to configure hibernate with 
+    hsqldb in a standard Java environment.
+    </para>
+    <programlisting>hibernate.dialect                      org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class      org.hsqldb.jdbcDriver
+hibernate.connection.url               jdbc:hsqldb:mem:.
+hibernate.connection.username          sa
+hibernate.connection.password
+hibernate.cache.use_second_level_cache true
+hibernate.cache.provider_class         org.hibernate.cache.HashtableCacheProvider</programlisting>
+    <para>Optionally in development the schema export can be used to 
+    create the schema when the session factory is created and drop the 
+    schema when the session factory is closed.
+    </para>
+    <programlisting>hibernate.hbm2ddl.auto                 create-drop</programlisting>
+    <para>For more information about hibernate configurations, see the hibernate 
+    reference manual.
+    </para>
+  </section>
+
+  <section>
+    <title>Standard transaction</title>
+    <para>By default, the <literal>&lt;hibernate-session /&gt;</literal> will
+    start a hibernate transaction with <literal>session.beginTransaction()</literal>.
+    Then the hibernate transaction is wrapped in a <literal>org.jbpm.pvm.internal.hibernate.HibernateTransactionResource</literal>
+    and that resource is enlisted with the <literal>&lt;standard-transaction /&gt;</literal> 
+    (<literal>org.jbpm.tx.StandardTransaction</literal>)
+    </para>
+    <para>Inside of the environment block, the transaction is available
+    through <literal>environment.getTransaction()</literal>.  So inside an 
+    environment block, the transaction can be rolled back with 
+    <literal>environment.getTransaction().setRollbackOnly()</literal> 
+    </para>
+    <para>When created, the standard transaction will register itself to be notified on the 
+    close of the environment.  So in side the close, the standard transaction will 
+    commit or rollback depending on whether <literal>setRollbackOnly()</literal> 
+    was called.
+    </para>
+    <para>So in the configuration shown above, each environment block will be 
+    a separate transaction.  At least, if the hibernate session is used.</para>
+  </section>
+
+  <section>
+    <title>Basics of process persistence</title>
+    <para>In the next example, we'll show how this hibernate persistence is 
+    used with a concrete example.  The 'persistent process' is a simple 
+    three-step process: 
+    </para>
+    <figure id="the.persistent.process">
+      <title>The persistent process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/ch09.persistent.process.png"/></imageobject></mediaobject>
+    </figure>
+    <para>The activities in the three activities will be wait states just like 
+    in <xref linkend="externalactivityexample" /> 
+    </para>
+    <para>To make sure we can persist this class, we create the hibernate mapping for 
+    it and add it to the configuration like this:
+    </para>
+    <programlisting>&lt;hibernate-configuration&gt;
+  &lt;properties resource=&quot;hibernate.properties&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.typedefs.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.wire.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.definition.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.execution.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.variable.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.pvm.job.hbm.xml&quot; /&gt;
+  &lt;mapping resource=&quot;jbpm.jpdl.hbm.xml&quot; /&gt;
+  <emphasis role="bold">&lt;mapping resource="org/jbpm/examples/ch09/state.hbm.xml" /&gt;</emphasis>
+  &lt;cache-configuration resource=&quot;jbpm.pvm.cache.xml&quot; 
+                       usage=&quot;nonstrict-read-write&quot; /&gt;
+&lt;/hibernate-configuration&gt;</programlisting>
+    <para>The next code pieces show the contents of one unit test method.  The method 
+    will first create the environment factory. Then, in a first transaction, a process 
+    definition will be created and saved into the database.  Then the next transaction will 
+    create a new execution of that process.  And the following two transactions will 
+    provide external triggers to the execution.
+    </para>
+    <programlisting>EnvironmentFactory environmentFactory = EnvironmentFactory.parse(new ResourceStreamSource(
+    "org/jbpm/examples/ch09/environment.cfg.xml"
+));</programlisting>
+    <para>Then in a first transaction, a process is created and saved in the database.
+    This is typically referred to as deploying a process and it only needs to be done 
+    once.
+    </para>
+    <programlisting>Environment environment = environmentFactory.openEnvironment();
+try {
+  PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+  
+  ProcessDefinition processDefinition = ProcessFactory.build("persisted process")
+    .activity("one").initial().behaviour(new State())
+      .transition().to("two")
+    .activity("two").behaviour(new State())
+      .transition().to("three")
+    .activity("three").behaviour(new State())
+  .done();
+  
+  pvmDbSession.save(processDefinition);
+} finally {
+  environment.close();
+}</programlisting>
+    <para>In the previous transaction, the process definition, the activities and transitions 
+    will be inserted into the database tables.
+    </para>
+    <para>Next we'll show how a new process execution can be started for this 
+    process definition.  Note that in this case, we provide <link linkend="businesskey">a 
+    business key</link> called 'first'.  This will make it easy for us to retrieve 
+    the same execution from the database in subsequent transactions.  After starting 
+    the new process execution, it will wait in activity 'one' cause the behaviour is a 
+    wait state.
+    </para>
+    <programlisting>environment = environmentFactory.openEnvironment();
+try {
+  PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+  
+  ProcessDefinition processDefinition = pvmDbSession.findProcessDefinition("persisted process");
+  assertNotNull(processDefinition);
+  
+  Execution execution = processDefinition.startExecution("first");
+  assertEquals("one", execution.getActivity().getName());
+  pvmDbSession.save(execution);
+
+} finally {
+  environment.close();
+}</programlisting>
+    <para>In the previous transaction, a new execution record will be inserted into 
+    the database.
+    </para>
+    <para>Next we feed in an external trigger into this existing process execution.
+    We load the execution, provide a signal and just save it back into the database.
+    </para>
+    <programlisting>environment = environmentFactory.openEnvironment();
+try {
+  PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+  
+  Execution execution = pvmDbSession.findExecution("persisted process", "first");
+  assertNotNull(execution);
+  assertEquals("one", execution.getActivity().getName());
+  
+  // external trigger that will cause the execution to execute until 
+  // it reaches the next wait state
+  execution.signal();
+
+  assertEquals("two", execution.getActivity().getName());
+
+  pvmDbSession.save(execution);
+
+} finally {
+  environment.close();
+}</programlisting>
+    <para>The previous transaction will result in an update of the existing 
+    execution, reassigning the foreign key to reference another record in 
+    the activity table.
+    </para>
+    <programlisting>UPDATE JBPM_EXECUTION 
+SET
+  NODE_=?,
+  DBVERSION_=?,
+  ...
+WHERE DBID_=? 
+  AND DBVERSION_=?</programlisting>
+    <para>The version in this SQL shows the automatic optimistic locking that 
+    is baked into the PVM persistence so that process persistence can easily 
+    scale to multiple JVM's or multiple machines.
+    </para>
+    <para>In the example code, there is one more transaction that is 
+    completely similar to the previous which takes the execution from 
+    activity 'two' to activity 'three'. 
+    </para>
+    <para>All of this shows that the PVM can move from one wait state to 
+    another wait state transactionally.  Each transaction correcponds to 
+    a state transition.
+    </para>
+    <para>Note that in case of automatic activities, multiple activities 
+    will be executed before the execution reaches a wait state.  Typically 
+    that is desired behaviour.  In case the automatic activities take too 
+    long or you don't want to block the original transaction to wait for 
+    the completion of those automatic activities, check out <xref linkend="asynchronouscontinuations"/>
+    to learn about how it's possible to demarcate transactions in the process 
+    definition, which can also be seen as safe-points during process execution.
+    </para>
+  </section>
+
+  <section id="businesskey">
+    <title>Business key</title>
+    <para>TODO</para>
+  </section>
+    	  
+	  
+  <para>TODO: General persistence architecture
+  </para>
+  <para>TODO: Object references
+  </para>
+  <para>TODO: Threads, concurrency with respect to forks and joins
+  </para>
+  <para>TODO: Caching
+  </para>
+  <para>TODO: Process instance migration
+  </para>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-ProcessLanguages.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-ProcessLanguages.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/devguide/src/main/docbook/en/modules/chxx-ProcessLanguages.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<chapter id="processlanguages">
+  <title>Process languages</title>
+  
+  <para>TODO: xml parser infrastructure
+  </para>
+  <para>TODO: inherit from ProcessDefinitionImpl, ExecutionImpl
+  </para>
+  <para>TODO: overriding the default proceed()
+  </para>
+  <para>TODO: activity type implementations
+  </para>
+  <para>TODO: persistence
+  </para>
+  <para>TODO: compensation: languages like bpel and bpnm define that 
+       as a normal contination that fits within the process 
+       structures available in the pvm (taking a transition and 
+       executing a nested activity). 
+  </para>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>distro</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.stp.bpmn.validation.BatchValidationBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+		<nature>org.eclipse.stp.bpmn.validation.BatchValidationBuildAbleNature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/distro/.settings/attachedFile.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/.settings/attachedFile.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/.settings/attachedFile.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+## index of importer -> set(imports)
+#Wed Mar 04 10:44:26 CET 2009

Added: jbpm4/branches/tbaeyens/modules/distro/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 4046 2009-02-26 13:05:50Z heiko.braun at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Distro</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-distro</artifactId>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-gpd</artifactId>
+      <type>zip</type>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-log</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+      <classifier>config</classifier>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-db</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-enterprise</artifactId>      
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-enterprise</artifactId>
+      <classifier>config</classifier>
+      <version>${version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-examples</artifactId>
+      <version>${version}</version>
+    </dependency>
+       
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-db</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-spi</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jboss5</artifactId>
+      <version>${version}</version>
+    </dependency>
+     <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jboss5</artifactId>
+      <classifier>config</classifier>
+      <version>${version}</version>
+    </dependency>
+
+    <!-- GWT Console -->
+    <dependency>
+      <groupId>org.jboss.bpm</groupId>
+      <artifactId>gwt-console</artifactId>
+      <type>war</type>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.bpm</groupId>
+      <artifactId>gwt-console-server</artifactId>
+      <type>war</type>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.bpm</groupId>
+      <artifactId>gwt-console-server-integration</artifactId>          
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.bpm</groupId>
+      <artifactId>gwt-console-rpc</artifactId>      
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- Please sort by groupid -->
+    <dependency>
+      <groupId>org.apache.ant</groupId>
+      <artifactId>ant</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>izpack</groupId>
+      <artifactId>standalone-compiler</artifactId>
+    </dependency>
+
+    <!-- Database Drivers -->
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.jtds</groupId>
+      <artifactId>jtds</artifactId>
+    </dependency>
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-2</version>
+        <executions>
+
+          <!-- Installer -->
+
+          <execution>
+            <id>create-installer</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>directory-single</goal>
+            </goals>
+            <configuration>
+              <finalName>deploy-artifacts</finalName>
+              <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+              <appendAssemblyId>false</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-deploy-artifacts.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>izpack</id>
+            <phase>package</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+                <property name="database" value="${database}" />
+                <property name="jboss.home" value="${jboss.home}" />
+                <property name="jboss422.home" value="${jboss422.home}" />
+                <property name="jboss423.home" value="${jboss423.home}" />
+                <property name="jboss500.home" value="${jboss500.home}" />
+                <property name="jbpm.target.container" value="${jbpm.target.container}" />
+                <property name="product.name" value="${project.name}" />
+                <property name="product.short.name" value="${artifactId}" />
+                <property name="product.version" value="${project.version}" />
+                <property name="user.home" value="${user.home}" />
+                <ant antfile="scripts/antrun-installer.xml" target="build-installer" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/distro/scripts/antrun-installer.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/scripts/antrun-installer.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/scripts/antrun-installer.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: antrun-installer.xml 3319 2008-12-10 14:29:01Z thomas.diesler at jboss.com $ -->
+<project>
+
+  <macrodef name="macro-disable">
+    <attribute name="file" />
+    <attribute name="section" />
+    <sequential>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) -->]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) ===]]></replacevalue>
+      </replace>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (end) -->]]></replacetoken>
+        <replacevalue><![CDATA[==== ]]>@{section}<![CDATA[ (end) -->]]></replacevalue>
+      </replace>
+    </sequential>
+  </macrodef>
+
+  <macrodef name="macro-enable">
+    <attribute name="file" />
+    <attribute name="section" />
+    <sequential>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) ===]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) -->]]></replacevalue>
+      </replace>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[==== ]]>@{section}<![CDATA[ (end) -->]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (end) -->]]></replacevalue>
+      </replace>
+    </sequential>
+  </macrodef>
+
+  <!-- ================================================================== -->
+  <!-- Setup                                                              -->
+  <!-- ================================================================== -->
+  <property name="output.dir" value="${basedir}/target" />
+  <property name="resources.dir" value="${basedir}/src/main/resources" />
+  <property name="filtered.resources.dir" value="${output.dir}/resources" />
+  <property name="deploy.artifacts.dir" value="${output.dir}/deploy-artifacts" />
+  <property name="deploy.artifacts.lib" value="${deploy.artifacts.dir}/lib" />
+  <property name="deploy.artifacts.resources" value="${deploy.artifacts.dir}/resources" />
+
+  <!-- ================================================================== -->
+  <!-- Initialization                                                     -->
+  <!-- ================================================================== -->
+  <target name="init">
+
+  </target>
+
+  <!-- ================================================================== -->
+  <!-- Configuration                                                     -->
+  <!-- ================================================================== -->
+  <target name="configure" depends="init">
+
+    <property name="hsqldb.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.hsqldb.xml"/>
+    <macro-disable file="${hsqldb.cfg.xml}" section="JDBC connection properties"/>
+    <macro-disable file="${hsqldb.cfg.xml}" section="Automatic schema creation"/>
+    <macro-enable file="${hsqldb.cfg.xml}" section="DataSource properties"/>
+    <macro-enable file="${hsqldb.cfg.xml}" section="JTA transaction properties"/>
+
+    <property name="mysql.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.mysql.xml"/>
+    <macro-disable file="${mysql.cfg.xml}" section="JDBC connection properties"/>
+    <macro-disable file="${mysql.cfg.xml}" section="Automatic schema creation"/>
+    <macro-enable file="${mysql.cfg.xml}" section="DataSource properties"/>
+    <macro-enable file="${mysql.cfg.xml}" section="JTA transaction properties"/>
+
+    <property name="postgresql.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.postgresql.xml"/>
+    <macro-disable file="${postgresql.cfg.xml}" section="JDBC connection properties"/>
+    <macro-disable file="${postgresql.cfg.xml}" section="Automatic schema creation"/>
+    <macro-enable file="${postgresql.cfg.xml}" section="DataSource properties"/>
+    <macro-enable file="${postgresql.cfg.xml}" section="JTA transaction properties"/>
+
+    <property name="oracle.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.oracle.xml"/>
+    <macro-disable file="${oracle.cfg.xml}" section="JDBC connection properties"/>
+    <macro-disable file="${oracle.cfg.xml}" section="Automatic schema creation"/>
+    <macro-enable file="${oracle.cfg.xml}" section="DataSource properties"/>
+    <macro-enable file="${oracle.cfg.xml}" section="JTA transaction properties"/>
+
+    <property name="sybase.cfg.xml" value="${deploy.artifacts.resources}/jbpm-jpdl-config/hibernate.cfg.sybase.xml"/>
+    <macro-disable file="${sybase.cfg.xml}" section="JDBC connection properties"/>
+    <macro-disable file="${sybase.cfg.xml}" section="Automatic schema creation"/>
+    <macro-enable file="${sybase.cfg.xml}" section="DataSource properties"/>
+    <macro-enable file="${sybase.cfg.xml}" section="JTA transaction properties"/>
+
+    <condition property="database.is.hsqldb" value="true" else="false">
+      <equals arg1="${database}" arg2="hsqldb"/>
+    </condition>
+    <condition property="database.is.mysql" value="true" else="false">
+      <equals arg1="${database}" arg2="mysql"/>
+    </condition>
+    <condition property="database.is.postgresql" value="true" else="false">
+      <equals arg1="${database}" arg2="postgresql"/>
+    </condition>
+    <condition property="database.is.oracle" value="true" else="false">
+      <equals arg1="${database}" arg2="oracle"/>
+    </condition>
+    <condition property="database.is.sybase" value="true" else="false">
+      <equals arg1="${database}" arg2="sybase"/>
+    </condition>
+
+  </target>
+
+  <!-- ================================================================== -->
+  <!-- Distribution                                                       -->
+  <!-- ================================================================== -->
+  <target name="build-installer" depends="configure">
+
+    <copy todir="${filtered.resources.dir}" filtering="true" overwrite="true">
+      <fileset dir="${resources.dir}/installer" />
+      <filterset>
+        <filter token="database" value="${database}" />
+        <filter token="database.is.hsqldb" value="${database.is.hsqldb}" />
+        <filter token="database.is.mysql" value="${database.is.mysql}" />
+        <filter token="database.is.postgresql" value="${database.is.postgresql}" />
+        <filter token="database.is.oracle" value="${database.is.oracle}" />
+        <filter token="database.is.sybase" value="${database.is.sybase}" />
+        <filter token="jbpm.target.container" value="${jbpm.target.container}" />
+        <filter token="jboss.home" value="${jboss.home}" />
+        <filter token="product.version" value="${product.version}" />
+        <filter token="user.home" value="${user.home}" />
+      </filterset>
+    </copy>
+
+    <!-- Allows us to use the IzPack Ant task, standalone-compiler.jar added to Ant lib -->
+    <taskdef name="izpack" classname="com.izforge.izpack.ant.IzPackTask">
+      <classpath>
+        <pathelement path="${maven.runtime.classpath}" />
+      </classpath>
+    </taskdef>
+    <property name="izpack.temp.dir" value="${output.dir}/izpack-temp" />
+    <mkdir dir="${izpack.temp.dir}" />
+
+    <!-- Run installer build -->
+    <echo message="Running IzPack to build the installer..." />
+    <izpack input="${resources.dir}/installer/install-definition.xml" output="${output.dir}/jbpm-installer-${product.version}.jar"
+      installerType="standard" inheritAll="true" basedir="${izpack.temp.dir}" />
+
+    <!-- Clean working directory -->
+    <delete dir="${izpack.temp.dir}" quiet="true" includeemptydirs="true" />
+  </target>
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/scripts/assembly-deploy-artifacts.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/scripts/assembly-deploy-artifacts.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/scripts/assembly-deploy-artifacts.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,184 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+
+  <id>deploy-artifacts</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+
+  <!-- Dependency Sets -->
+  <dependencySets>
+
+    <!-- lib -->
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+      <useStrictFiltering>true</useStrictFiltering>
+      <scope>compile</scope>
+      <unpack>false</unpack>
+    </dependencySet>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+      <useStrictFiltering>true</useStrictFiltering>
+      <scope>provided</scope>
+      <unpack>false</unpack>
+    </dependencySet>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+      <useStrictFiltering>true</useStrictFiltering>
+      <scope>test</scope>
+      <unpack>false</unpack>
+    </dependencySet>
+    <dependencySet>
+      <includes>
+        <include>org.jbpm.jbpm4:jbpm-gpd:zip</include>
+      </includes>
+      <outputFileNameMapping>jbpm-gpd-site.zip</outputFileNameMapping>
+      <outputDirectory>gpd</outputDirectory>
+    </dependencySet>
+    <!-- resources -->
+    <dependencySet>
+      <outputDirectory>resources/jbpm-jpdl-config</outputDirectory>
+      <useStrictFiltering>true</useStrictFiltering>
+      <includes>
+        <include>*:jbpm-jpdl:jar:config</include>
+      </includes>
+      <unpack>true</unpack>
+    </dependencySet>
+    <dependencySet>
+      <outputDirectory>resources/jbpm-enterprise-config</outputDirectory>
+      <useStrictFiltering>true</useStrictFiltering>
+      <includes>
+        <include>*:jbpm-enterprise:jar:config</include>
+      </includes>
+      <unpack>true</unpack>
+    </dependencySet>
+    <dependencySet>
+      <outputDirectory>resources/jbpm-jboss5-config</outputDirectory>
+      <useStrictFiltering>true</useStrictFiltering>
+      <includes>
+        <include>*:jbpm-jboss5:jar:config</include>
+      </includes>
+      <unpack>true</unpack>
+    </dependencySet>
+     <dependencySet>
+      <outputDirectory>resources/jbpm-db</outputDirectory>
+      <useStrictFiltering>true</useStrictFiltering>
+      <includes>
+        <include>*:jbpm-db:jar:*</include>
+      </includes>
+      <unpack>true</unpack>
+    </dependencySet>
+  </dependencySets>
+
+  <fileSets>
+    <fileSet>
+      <directory>src/main/resources</directory>
+      <includes>
+        <include>jboss.eula.txt</include>
+        <include>license.txt</include>
+        <include>readme.html</include>
+      </includes>
+      <outputDirectory></outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../api/target/site/apidocs</directory>
+      <outputDirectory>doc/javadocs</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../api/target/schemadoc</directory>
+      <outputDirectory>doc/schemadoc</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../db/target/create</directory>
+      <outputDirectory>db/create</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../db/target/drop</directory>
+      <outputDirectory>db/drop</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../devguide/target/docbook/publish/en</directory>
+      <outputDirectory>doc/devguide</outputDirectory>
+      <excludes>
+        <exclude>**/*.fo</exclude>
+      </excludes>
+    </fileSet>
+    <fileSet>
+      <directory>../userguide/target/docbook/publish/en</directory>
+      <outputDirectory>doc/userguide</outputDirectory>
+      <excludes>
+        <exclude>**/*.fo</exclude>
+      </excludes>
+    </fileSet>
+    <fileSet>
+      <directory>../api/target/schemadocs</directory>
+      <outputDirectory>doc/schemadocs</outputDirectory>
+      <excludes>
+        <exclude>**/*.fo</exclude>
+      </excludes>
+    </fileSet>
+    <fileSet>
+      <directory>../api/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../api/src/main/resources</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../log/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../pvm/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../pvm/src/main/resources</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../jpdl/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../jpdl/src/main/resources</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../task/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../task/src/main/resources</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../test-base/src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../examples/src/test/java</directory>
+      <outputDirectory>examples/src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>../examples/src/test/resources</directory>
+      <outputDirectory>examples/src</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>src/main/resources</directory>
+      <includes>
+        <include>examples-hibernate.cfg.xml</include>
+      </includes>
+      <outputDirectory>examples/src</outputDirectory>
+    </fileSet>    
+    <fileSet>
+      <directory>../examples/src/eclipse</directory>
+      <outputDirectory>examples</outputDirectory>
+    </fileSet>
+  </fileSets>
+</assembly>

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/examples-hibernate.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/examples-hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/examples-hibernate.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+  <session-factory>
+
+    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>    
+    <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+    <property name="hibernate.connection.username">sa</property>
+    <property name="hibernate.connection.password"></property>
+
+    <property name="hibernate.hbm2ddl.auto">create</property>
+
+    <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
+    <property name="hibernate.format_sql">true</property>
+
+    <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+    <mapping resource="jbpm.pvm.wire.hbm.xml" />
+    <mapping resource="jbpm.pvm.definition.hbm.xml" />
+    <mapping resource="jbpm.pvm.execution.hbm.xml" />
+    <mapping resource="jbpm.pvm.variable.hbm.xml" />
+    <mapping resource="jbpm.pvm.job.hbm.xml" />
+    <mapping resource="jbpm.pvm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.jpdl.hbm.xml" />
+
+  </session-factory>
+  
+</hibernate-configuration>
+    
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/ant-actions-spec.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/ant-actions-spec.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/ant-actions-spec.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,14 @@
+<antactions>
+  <pack name="Download JBoss-5.0.0">
+    <antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
+      <property name="install.path" value="$INSTALL_PATH"/>
+      <target name="download-jboss"/>
+    </antcall>
+  </pack>
+  <pack name="Download Eclipse-3.4.0">
+    <antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
+      <property name="install.path" value="$INSTALL_PATH"/>
+      <target name="download-eclipse"/>
+    </antcall>
+  </pack>
+</antactions>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/auto-install-template.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/auto-install-template.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/auto-install-template.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+<AutomatedInstallation langpack="eng">
+  <com.izforge.izpack.panels.HelloPanel />
+  <com.izforge.izpack.panels.TargetPanel>
+    <installpath>@user.home@/jbpm- at product.version@</installpath>
+  </com.izforge.izpack.panels.TargetPanel>
+  <com.izforge.izpack.panels.TreePacksPanel>
+    <pack name="jBPM Installation Files" index="0" selected="true"/>
+    <pack name="Install jBPM in JBoss" index="1" selected="true"/>
+  </com.izforge.izpack.panels.TreePacksPanel>
+  <com.izforge.izpack.panels.UserInputPanel>
+    <userInput>
+      <entry key="jbossTargetServer" value="default" />
+      <entry key="jbossSelection" value="@jbpm.target.container@" />
+    </userInput>
+  </com.izforge.izpack.panels.UserInputPanel>
+  <com.izforge.izpack.panels.UserInputPanel>
+    <userInput>
+      <entry key="dbSelection" value="@database@"/>
+    </userInput>
+  </com.izforge.izpack.panels.UserInputPanel>
+  <com.izforge.izpack.panels.UserInputPanel>
+    <userInput>
+      <entry key="jbossInstallPath" value="@jboss.home@" />
+    </userInput>
+  </com.izforge.izpack.panels.UserInputPanel>
+  <com.izforge.izpack.panels.SummaryPanel />
+  <com.izforge.izpack.panels.InstallPanel />
+  <com.izforge.izpack.panels.FinishPanel />
+</AutomatedInstallation>

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/download-helper.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/download-helper.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/download-helper.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: download-helper.xml 3319 2008-12-10 14:29:01Z thomas.diesler at jboss.com $ -->
+<project>
+
+  <target name="download-jboss">
+    <get src="http://downloads.sourceforge.net/jboss/jboss-5.0.0.GA.zip?modtime=1228452561&amp;big_mirror=1" dest="${install.path}/Uninstaller/jboss-5.0.0.GA.zip" usetimestamp="true"/>
+    <unzip src="${install.path}/Uninstaller/jboss-5.0.0.GA.zip" dest="${install.path}"/>
+  </target>
+  <target name="download-eclipse">
+    <get src="http://download.eclipse.org/technology/epp/downloads/release/ganymede/R/eclipse-java-ganymede-linux-gtk.tar.gz" 
+      dest="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" usetimestamp="true"/>
+    <untar src="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" dest="${install.path}" compression="gzip"/>
+  </target>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/install-definition.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/install-definition.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/install-definition.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,344 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<installation version="1.0">
+  <!-- 
+    Ant properties in this file can be referenced with @{},
+    otherwise use variables below in installer files with ${} 
+  -->
+  <info>
+    <appname>@{product.name}</appname>
+    <appversion>@{product.version}</appversion>
+    <uninstaller write="no" />
+    <writeinstallationinformation>no</writeinstallationinformation>
+  </info>
+  <guiprefs width="600" height="440" resizable="yes">
+    <!--
+    <laf name="kunststoff">
+      <os family="unix" />
+    </laf>
+    -->
+  </guiprefs>
+  <locale>
+    <langpack iso3="eng" />
+  </locale>
+
+  <!-- It is necessary to include everything needed, in this case ant self -->
+  <jar src="@{deploy.artifacts.dir}/lib/ant.jar" stage="both" />
+  <jar src="@{deploy.artifacts.dir}/lib/ant-launcher.jar" stage="both" />
+
+  <!-- Setup the Ant Action Listener -->
+  <listeners>
+    <listener installer="AntActionInstallerListener" />
+  </listeners>
+
+  <!-- Resources -->
+  <resources>
+    <res id="AntActionsSpec.xml" src="@{filtered.resources.dir}/ant-actions-spec.xml" />
+    <res id="userInputSpec.xml" src="@{filtered.resources.dir}/user-input-spec.xml" />
+    <res id="TargetPanel.dir" src="@{filtered.resources.dir}/target-panel-dir.txt" />
+  </resources>
+
+  <!-- Variables -->
+  <variables>
+    <variable name="jboss422.home" value="@{jboss422.home}" />
+    <variable name="jboss423.home" value="@{jboss423.home}" />
+    <variable name="jboss500.home" value="@{jboss500.home}" />
+  </variables>
+
+  <!-- Dynamic Variables -->
+  <dynamicvariables>
+    <variable name="jboss.home" value="${jboss422.home}" condition="isJBoss422" />
+    <variable name="jboss.home" value="${jboss423.home}" condition="isJBoss423" />
+    <variable name="jboss.home" value="${jboss500.home}" condition="isJBoss500" />
+  </dynamicvariables>
+
+  <!-- Conditions -->
+  <conditions>
+    <!-- Target Server Conditions -->
+    <condition type="variable" id="isJBoss422">
+      <name>jbossSelection</name>
+      <value>jboss422</value>
+    </condition>
+    <condition type="variable" id="isJBoss423">
+      <name>jbossSelection</name>
+      <value>jboss423</value>
+    </condition>
+    <condition type="variable" id="isJBoss500">
+      <name>jbossSelection</name>
+      <value>jboss500</value>
+    </condition>
+
+    <!-- Target Database Conditions -->
+    <condition type="variable" id="isHypersonic">
+      <name>dbSelection</name>
+      <value>hsqldb</value>
+    </condition>
+    <condition type="variable" id="isMySQL">
+      <name>dbSelection</name>
+      <value>mysql</value>
+    </condition>
+    <condition type="variable" id="isPostgreSQL">
+      <name>dbSelection</name>
+      <value>postgresql</value>
+    </condition>
+    <condition type="variable" id="isOracle">
+      <name>dbSelection</name>
+      <value>oracle</value>
+    </condition>
+    <condition type="variable" id="isSybase">
+      <name>dbSelection</name>
+      <value>sybase</value>
+    </condition>
+  </conditions>
+
+  <!-- Panels -->
+  <panels>
+    <panel classname="HelloPanel" />
+    <panel classname="TargetPanel" />
+    <panel classname="TreePacksPanel" />
+    <panel classname="UserInputPanel" />
+    <panel classname="UserInputPanel" />
+    <panel classname="UserInputPanel" />
+    <panel classname="SummaryPanel" />
+    <panel classname="InstallPanel" />
+    <panel classname="FinishPanel" />
+  </panels>
+
+  <!-- Packs -->
+  <packs>
+
+    <!--
+        ==============================
+        Standalone setup
+        ==============================
+        -->
+
+    <pack name="jBPM Installation Files" required="yes" preselected="yes">
+      <description>Installation directory containing docs, libs, examples and sources</description>
+
+      <!-- jbpm4/ -->
+      <file src="@{deploy.artifacts.dir}/jboss.eula.txt" targetdir="$INSTALL_PATH" override="true" />
+      <file src="@{deploy.artifacts.dir}/license.txt" targetdir="$INSTALL_PATH" override="true" />
+      <file src="@{deploy.artifacts.dir}/readme.html" targetdir="$INSTALL_PATH" override="true" />
+
+      <!-- jbpm4/config -->
+      <file src="@{deploy.artifacts.dir}/lib/jbpm-jpdl-config.jar" targetdir="$INSTALL_PATH/config"
+            unpack="true" override="true" />
+
+      <!-- jbpm4/doc -->
+      <fileset dir="@{deploy.artifacts.dir}/doc" targetdir="$INSTALL_PATH/doc" />
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-db"
+               targetdir="$INSTALL_PATH/doc/database-scripts"
+               includes="create/,drop/"/>
+                      
+      <!-- jbpm4/examples -->
+      <fileset dir="@{deploy.artifacts.dir}/examples" targetdir="$INSTALL_PATH/examples" />
+
+      <!-- jbpm4/gpd -->
+      <fileset dir="@{deploy.artifacts.dir}/gpd" targetdir="$INSTALL_PATH/gpd" />
+
+      <!-- jbpm4/lib -->
+      <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/lib" override="true">
+        <include name="*.jar" />
+      </fileset>
+
+      <!-- jbpm4/src -->
+      <fileset dir="@{deploy.artifacts.dir}/src" targetdir="$INSTALL_PATH/src" />
+    </pack>
+
+    <!--
+    ==============================
+    JBoss integration
+    ==============================
+    -->
+
+    <pack name="Install jBPM in JBoss" required="no" preselected="yes">
+
+      <description>The Install jBPM in JBoss</description>
+
+      <!-- jbpm/jbpm-service.sar
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true">
+        <include name="logging.properties"/>
+      </fileset>
+       -->
+
+      <!-- jbpm/jbpm-service.sar , enterprise config-->
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-enterprise-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true">
+        <include name="jbpm.cfg.xml"/>
+        <include name="jbpm-users.properties"/>
+        <include name="jbpm-roles.properties"/>
+      </fileset>
+      <!-- jbpm/jbpm-service.sar/META-INF , enterprise config-->
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-enterprise-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/META-INF" override="true">
+        <include name="jboss-service.xml"/>
+      </fileset>
+
+      <!--fileset dir="@{deploy.artifacts.dir}/resources/jbpm-integration-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true">
+        <include name="bpm-process-deployer.xml" />
+      </fileset-->
+      <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true">
+        <include name="jbpm-log.jar" />
+        <include name="jbpm-pvm.jar" />
+        <include name="jbpm-jpdl.jar" />
+        <include name="jbpm-task.jar" />
+      </fileset>
+
+      <!-- jbpm/jbpm-enterprise.jar -->
+      <file src="@{deploy.artifacts.dir}/lib/jbpm-enterprise.jar" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-enterprise.jar"
+            unpack="true" override="true" />
+
+
+      <!-- jbpm/jbpm-userguide.war -->
+      <!--file src="@{deploy.artifacts.dir}/lib/jbpm-userguide.jdocbook" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-userguide.war"
+        unpack="true" override="true" /-->
+
+      <!-- jbpm-destinations-service.xml -->
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-enterprise-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/" override="true">
+        <include name="jbpm-destinations-service.xml"/>
+      </fileset>
+
+      <!-- Database configs to docs/examples/jbpm -->
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config" targetdir="${jbossInstallPath}/docs/examples/jbpm" override="true">
+        <include name="hibernate.cfg.hsqldb.xml"/>
+        <include name="hibernate.cfg.mysql.xml"/>
+        <include name="hibernate.cfg.postgresql.xml"/>
+        <include name="hibernate.cfg.oracle.xml"/>
+        <include name="hibernate.cfg.sybase.xml"/>
+        <include name="jbpm-hsqldb-ds.xml"/>
+        <include name="jbpm-mysql-ds.xml"/>
+        <include name="jbpm-postgresql-ds.xml"/>
+        <include name="jbpm-oracle-ds.xml"/>
+        <include name="jbpm-sybase-ds.xml"/>
+      </fileset>
+
+      <!-- Database Scripts / DDL -->
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-db"
+               targetdir="${jbossInstallPath}/docs/examples/jbpm/database-scripts"
+               override="true"
+               includes="create/,drop/"/>
+        
+      <!--
+         ==============================
+         JBoss 422
+         ==============================
+       -->
+      <fileset dir="@{deploy.artifacts.dir}/lib/"
+               targetdir="${jbossInstallPath}/server/${jbossTargetServer}/lib/"
+               override="true"
+               condition="isJBoss422">
+        <include name="jbpm-api.jar"/>
+        <include name="jbpm-spi.jar"/>
+      </fileset>
+
+
+      <!--
+        ==============================
+        JBoss 423
+        ==============================
+      -->
+
+      <fileset dir="@{deploy.artifacts.dir}/lib/"
+               targetdir="${jbossInstallPath}/server/${jbossTargetServer}/lib/"
+               override="true"
+               condition="isJBoss423">
+        <include name="jbpm-api.jar"/>
+        <include name="jbpm-spi.jar"/>
+      </fileset>
+
+      <!--
+        ==============================
+        JBoss 5
+        ==============================
+      -->
+
+      <fileset dir="@{deploy.artifacts.dir}/lib/"
+               targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deployers/jbpm.deployer"
+               override="true"
+               condition="isJBoss500">
+        <include name="jbpm-api.jar"/>
+        <include name="jbpm-spi.jar"/>
+        <include name="jbpm-jboss5.jar"/>
+      </fileset>
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jboss5-config/META-INF"
+               targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deployers/jbpm.deployer"
+               override="true"
+               condition="isJBoss500">
+        <include name="jbpm-deployers-jboss-beans.xml"/>
+      </fileset>
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jboss5-config/META-INF"
+               targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar"
+               override="true"
+               condition="isJBoss500">
+        <include name="jbpm-service-jboss-beans.xml"/>
+      </fileset>
+
+
+      <!--
+        ==============================
+        Database configurations
+        ==============================
+        -->
+
+      <!-- Database Hypsersonic -->
+      <file src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/jbpm-hsqldb-ds.xml" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" condition="isHypersonic"/>
+      <singlefile src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/hibernate.cfg.hsqldb.xml" condition="isHypersonic"
+                  target="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml" />
+      <fileset dir="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/data" condition="isHypersonic">
+        <include name="hypersonic/jbpm4DB.*" />
+      </fileset>
+
+      <!-- Database MySQL -->
+      <file src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/jbpm-mysql-ds.xml" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" condition="isMySQL"/>
+      <singlefile src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/hibernate.cfg.mysql.xml" condition="isMySQL"
+                  target="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml" />
+      <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar" override="true" condition="isMySQL">
+        <include name="mysql-connector-java.jar" />
+      </fileset>
+
+       <!-- Database Oracle -->
+      <file src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/jbpm-oracle-ds.xml" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" condition="isOracle"/>
+      <singlefile src="@{deploy.artifacts.dir}/resources/jbpm-jpdl-config/hibernate.cfg.oracle.xml" condition="isOracle"
+                  target="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm/jbpm-service.sar/hibernate.cfg.xml" />
+      <!-- NOTE: oracle driver needs to be provided manually -->
+
+      <!--
+         ==============================
+         GWT Console
+         ==============================
+      -->
+
+      <file src="@{deploy.artifacts.dir}/lib/gwt-console.war" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" unpack="false" override="true" />
+      <file src="@{deploy.artifacts.dir}/lib/gwt-console-server.war" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" unpack="false" override="true" />
+      <file src="@{deploy.artifacts.dir}/lib/gwt-console-server-integration.jar" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/lib/" unpack="false" override="true" />
+      <file src="@{deploy.artifacts.dir}/lib/gwt-console-rpc.jar" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/lib/" unpack="false" override="true" />
+      <!--file src="@{deploy.artifacts.dir}/lib/report-server.war" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/jbpm" unpack="false" override="true" />
+      <file src="@{deploy.artifacts.dir}/lib/gwt-console-server-report.zip" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/data/birt/" unpack="true" override="true" />
+      <file src="@{deploy.artifacts.dir}/lib/report-engine.zip" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/data/birt/" unpack="true" override="true" /-->
+
+    </pack>
+
+    <!--
+    ==============================
+    Optional Components
+    ==============================
+    <pack name="Optional Components" required="no" preselected="no">
+      <description>Optional jBPM4 Components</description>
+    </pack>
+    -->
+
+    <!-- JBoss-5.0.0 
+    <pack name="Download JBoss-5.0.0" required="no" parent="Optional Components" preselected="no">
+      <description>Download and Install JBoss-5.0.0</description>
+      http://jira.codehaus.org/browse/IZPACK-158 
+      <file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/Uninstaller"/>
+    </pack>
+    -->
+
+    <!-- Eclipse-3.4.0 -->
+    <!--pack name="Download Eclipse-3.4.0" required="no" parent="Optional Components" preselected="no">
+      <description>Download and Install Eclipse-3.4.0</description>
+      http://jira.codehaus.org/browse/IZPACK-158
+      <file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/Uninstaller"/>
+    </pack-->
+
+  </packs>
+</installation>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/target-panel-dir.txt
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/target-panel-dir.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/target-panel-dir.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+$USER_HOME/jbpm- at product.version@

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/user-input-spec.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/user-input-spec.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/installer/user-input-spec.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+<userInput>
+  <panel order="0">
+    <createForPack name="Install jBPM in JBoss" />
+    <field type="radio" variable="jbossSelection">
+      <description align="left" txt="Select your JBoss Version:" />
+      <spec>
+        <choice txt="JBoss-5.0.0" value="jboss500" set="true"/>
+        <choice txt="JBoss-4.2.3" value="jboss423"/>
+        <choice txt="JBoss-4.2.2" value="jboss422"/>
+      </spec>
+    </field>
+    <field type="text" variable="jbossTargetServer">
+      <spec txt="Server configuration:" size="15" set="default" />
+    </field>
+  </panel>
+  <panel order="1">
+    <createForPack name="Install jBPM in JBoss" />
+    <field type="dir" align="left" variable="jbossInstallPath">
+      <description align="left" txt="Select your JBoss home directory" />
+      <spec txt="JBoss Home:" size="25" set="${jboss.home}" />
+    </field>
+  </panel>
+  <panel order="2">
+    <createForPack name="Install jBPM in JBoss" />
+    <field type="radio" variable="dbSelection">
+      <description align="left" txt="Select your target database" />
+      <spec>
+        <choice txt="Hypersonic" value="hsqldb" set="true"/>
+        <choice txt="MySQL" value="mysql"/>
+        <choice txt="Oracle" value="oracle"/>
+        <!-- choice txt="PostgreSQL" value="postgresql"/-->
+        <!--choice txt="Sybase" value="sybase"/-->
+      </spec>
+    </field>
+  </panel>
+</userInput>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/jboss.eula.txt
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/jboss.eula.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/jboss.eula.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software 
+Packages, regardless of the delivery mechanism.  Each Software Package is a collective work 
+under U.S. Copyright Law.  Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to 
+the user ("Client") a license to the applicable collective work(s) pursuant to the 
+GNU Lesser General Public License v. 2.1 except for the following Software Packages: 
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the 
+GNU General Public License v.2; 
+
+(b) JBoss Rules, which is licensed pursuant to the Apache  License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the 
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database, 
+it may purchase a license from Sleepycat Software); 
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1, 
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various 
+royalty-free patent licenses.  
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1.  The Software.  "Software Packages" refer to the various software modules that are created and made available 
+for distribution by the JBoss.org open source community at http://www.jboss.org.   Each of the Software Packages 
+may be comprised of hundreds of software components.  The end user license agreement for each component is located in 
+the component's source code.  With the exception of certain image files identified in Section 2 below, 
+the license terms for the components permit Client to copy, modify, and redistribute the component, 
+in both source code and binary code forms.  This agreement does not limit Client's rights under, 
+or grant Client rights that supersede, the license terms of any particular component.
+
+2.  Intellectual Property Rights.  The Software Packages are owned by Red Hat and others and are protected under copyright 
+and other laws.  Title to the Software Packages and any component, or to any copy, modification, or merged portion shall 
+remain with the aforementioned, subject to the applicable license.  The "JBoss" trademark, "Red Hat" trademark, the 
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates 
+in the U.S. and other countries.  This agreement permits Client to distribute unmodified copies of the Software Packages 
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's 
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/.  Client must abide by 
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified. 
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at 
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.  
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.  
+
+3.  Limited Warranty.  Except as specifically stated in this Paragraph 3 or a license for a particular 
+component, to the maximum extent permitted under applicable law, the Software Packages and the 
+components are provided and licensed "as is" without warranty of any kind, expressed or implied, 
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.  
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in 
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.  
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements 
+or that the operation of the Software Packages will be entirely error free or appear precisely as described 
+in the accompanying documentation. This warranty extends only to the party that purchases the Services 
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor. 
+
+4.  Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies 
+described below are accepted by Client as its only remedies.  Red Hat's entire liability, and Client's 
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of 
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or 
+refund the money paid by Client for the Software.  To the maximum extent permitted by applicable law, 
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential 
+damages, including lost profits or lost savings arising out of the use or inability to use the Software, 
+even if Red Hat or such dealer has been advised of the possibility of such damages.  In no event shall 
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this 
+Agreement during the twelve months preceding the action.
+
+5.  Export Control.  As required by U.S. law, Client represents and warrants that it: 
+(a) understands that the Software Packages are subject to export controls under the 
+U.S. Commerce Department's Export Administration Regulations ("EAR"); 
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations 
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria); 
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity, 
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government; 
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or 
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by 
+regulation or specific license; 
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software 
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual 
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and 
+address (including country) of each transferee; 
+
+and (f) understands that countries other than the United States may restrict the import, use, or 
+export of encryption products and that it shall be solely responsible for compliance with any such 
+import, use, or export restrictions.
+
+6.  Third Party Programs. Red Hat may distribute third party software programs with the Software Packages 
+that are not part of the Software Packages and which Client must install separately.  These third party 
+programs are subject to their own license terms.  The license terms either accompany the programs or 
+can be viewed at http://www.redhat.com/licenses/.  If Client does not agree to abide by the applicable 
+license terms for such programs, then Client may not install them.  If Client wishes to install the programs 
+on more than one system or transfer the programs to another party, then Client must contact the licensor 
+of the programs.
+
+7.  General.  If any provision of this agreement is held to be unenforceable, that shall not affect the 
+enforceability of the remaining provisions.  This License Agreement shall be governed by the laws of the 
+State of North Carolina and of the United States, without regard to any conflict of laws provisions, 
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc.  All rights reserved.  
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.  
+All other trademarks are the property of their respective owners. 
+
+	Page 1 of 1	18 October 2006
+

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/license.txt
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/license.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/license.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,504 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

Added: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/readme.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/readme.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/readme.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+<html>
+  <head>
+    <title>jBPM 4 Readme and Release Notes</title>
+  </head>
+  <body>
+    <h1>Readme</h1>
+    
+    <p>Currently the userguide and devguide only show well in <a href="http://www.mozilla.com/firefox">firefox</a>.
+    We'll fix this in one of the next versions.  
+    See <a href="https://jira.jboss.org/jira/browse/JBPM-1895">JBPM-1895</a>.
+    </p>
+    
+    <table>
+      <tr>
+        <th>Link</th>
+        <th>Description</th>
+      </tr>
+      <tr>
+        <td valign="top" style="white-space:nowrap;"><a href="doc/userguide/html_single/index.html">User guide</a></td>
+        <td>Userguide docs describing the stable and supported ways of how to work with jBPM.</td>
+      </tr>
+      <tr>
+        <td valign="top" style="white-space:nowrap;"><a href="doc/javadocs/index.html">Javadocs</a></td>
+        <td>Javadocs describing the stable and supported API</td>
+      </tr>
+      <tr>
+        <td valign="top" style="white-space:nowrap;"><a href="doc/schemadocs/index.html">Schemadocs</a></td>
+        <td>Javadoc-like documentation of the jPDL XML schema and the jBPM configuration file XML schema</td>
+      </tr>
+      <tr>
+        <td valign="top" style="white-space:nowrap;"><a href="doc/devguide/html_single/index.html">Developers guide</a></td>
+        <td>Describes more configuration, usage and tweaking options.  
+        Unleash all the flexibility in jBPM.  But beware, the parts documented in this dev 
+        guide are not guaranteed to be forward compatible.</td>
+      </tr>
+    </table>
+
+    <h1>Release notes for jBPM 4.0.0.Alpha2</h1>
+
+<h2>        Bug
+</h2>
+<ul>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1980'>JBPM-1980</a>] -         Failed to initialze ScriptEngineManager on JDK 1.5
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1981'>JBPM-1981</a>] -         Example tests fail
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2049'>JBPM-2049</a>] -         hbm2ddl.auto doesn't work within AS
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2072'>JBPM-2072</a>] -         ConnectionManager deadlock running XA transaction on AS 4
+</li>
+</ul>
+        
+<h2>        Feature Request
+</h2>
+<ul>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1946'>JBPM-1946</a>] -         IzPack installer for jBPM4 that supports JBoss
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1993'>JBPM-1993</a>] -         Interface with the JBoss identity component
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1998'>JBPM-1998</a>] -         Dinstinction between candiadate-groups and candidate-users in Task API and model 
+</li>
+</ul>
+                    
+<h2>        Task
+</h2>
+<ul>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1246'>JBPM-1246</a>] -         document build
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1280'>JBPM-1280</a>] -         build out job executor basic test coverage
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1411'>JBPM-1411</a>] -         migrate enterprise into separate module
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1753'>JBPM-1753</a>] -         review event names
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1759'>JBPM-1759</a>] -         cleanup excluded tests
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1861'>JBPM-1861</a>] -         complete taskservice api
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1967'>JBPM-1967</a>] -         rename flow to transition
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1971'>JBPM-1971</a>] -         fix test-load hudson job in qa lab
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1972'>JBPM-1972</a>] -         introduce process definition attachments
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1973'>JBPM-1973</a>] -         finish programmatic process definition creation
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1974'>JBPM-1974</a>] -         rename node to activity
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1977'>JBPM-1977</a>] -         Provide process management through the GWT console on jbpm4
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1978'>JBPM-1978</a>] -         configure pvm2 user for hudson job jbpm4-load
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1983'>JBPM-1983</a>] -         rename context environment to transaction
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1986'>JBPM-1986</a>] -         rename ExecutionService.startExecutionXxx methods to startProcessInstanceXxx
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-1997'>JBPM-1997</a>] -         API package refactoring
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2003'>JBPM-2003</a>] -         document release procedure in a wiki page
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2020'>JBPM-2020</a>] -         fix timer mapping
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2032'>JBPM-2032</a>] -         verify blob caching
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2039'>JBPM-2039</a>] -         initial history infrastructure
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2041'>JBPM-2041</a>] -         move task mgmt into pvm module
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2044'>JBPM-2044</a>] -         Distribute GPD through the installer
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2063'>JBPM-2063</a>] -         examples hibernate configuration file
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2064'>JBPM-2064</a>] -         re-introduce schema sql scripts in distro
+</li>
+</ul>
+            
+<h2>        Sub-task
+</h2>
+<ul>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2011'>JBPM-2011</a>] -         Move non public classes to **/internal
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2012'>JBPM-2012</a>] -         Split jars into *-api.jar and *-impl.jar
+</li>
+</ul>
+
+<h2>        Task
+</h2>
+<ul>
+<li>[<a href='https://jira.jboss.org/jira/browse/GPD-281'>GPD-281</a>] -         Release jBPM Designer 4.0.0 Alpha2
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/GPD-283'>GPD-283</a>] -         Implement a tree structured details view for graphical entities
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/GPD-287'>GPD-287</a>] -         XML preservation
+</li>
+<li>[<a href='https://jira.jboss.org/jira/browse/GPD-294'>GPD-294</a>] -         Update to new icons
+</li>
+</ul>
+            
+        
+    <h1>Release notes for jBPM 4.0.0.Alpha1</h1>
+    <p>Finally..  phew !</p>
+  </body>
+</html>

Added: jbpm4/branches/tbaeyens/modules/enterprise/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/enterprise/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>enterprise</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/enterprise/README.txt
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/README.txt	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/README.txt	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,16 @@
+Tests in the enterprise module are integration tests. The maven surefire plugin
+runs tests during the 'test' phase by default. This module is configured to
+skip test execution during the 'test' phase, allowing the build to reach the
+'package' phase and assemble the ejb jar.
+
+Enterprise tests are associated to the 'integration-test' phase that occurs
+after 'package' but before 'install'. In order to run properly, enterprise
+tests require a running JBoss application server. The address to which the
+server is bound must be specified in the Maven property 'jboss.bind.address',
+otherwise the tests will be skipped.
+
+mvn -Djboss.bind.address=127.0.0.1 test
+
+Because several databases do not allow DDL in JTA transactions, the database
+schema has to be created prior to executing the tests for the first time,
+unless you've chosen Hsql as the target database when running the installer.

Added: jbpm4/branches/tbaeyens/modules/enterprise/jbpm4-enterprise.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/jbpm4-enterprise.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/jbpm4-enterprise.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,501 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="gwt-parent" />
+    <orderEntry type="module" module-name="toplevel" />
+    <orderEntry type="module" module-name="gwt-server-integration" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cargo:cargo:jar:0.5:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cargo/cargo/0.5/cargo-0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cactus:cactus:jar:13-1.7.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cactus/cactus/13-1.7.1/cactus-13-1.7.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: nekohtml:nekohtml:jar:0.9.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/nekohtml/nekohtml/0.9.1/nekohtml-0.9.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/nekohtml/nekohtml/0.9.1/nekohtml-0.9.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:runtime">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: xerces:xercesImpl:jar:2.6.2:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: aspectj:aspectjrt:jar:1.2.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/aspectj/aspectjrt/1.2.1/aspectjrt-1.2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-httpclient:commons-httpclient:jar:2.0.2:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cactus:cactus-ant:jar:13-1.7.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cactus/cactus-ant/13-1.7.1/cactus-ant-13-1.7.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: rhino:js:jar:1.5R4.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/rhino/js/1.5R4.1/js-1.5R4.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/rhino/js/1.5R4.1/js-1.5R4.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: ant:ant:jar:1.5.4:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/ant/ant/1.5.4/ant-1.5.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jtidy:jtidy:jar:4aug2000r7-dev:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: httpunit:httpunit:jar:1.6:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/httpunit/httpunit/1.6/httpunit-1.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/httpunit/httpunit/1.6/httpunit-1.6-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: xerces:xmlParserAPIs:jar:2.2.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/xerces/xmlParserAPIs/2.2.1/xmlParserAPIs-2.2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.servlet:servlet-api:jar:2.5:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.4.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.google.code.gson:gson:jar:1.2.2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/com/google/code/gson/gson/1.2.2/gson-1.2.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/enterprise/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3868 2009-02-13 13:33:58Z heiko.braun at jboss.com $ -->
+
+<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>
+
+  <name>jBPM 4 - Enterprise</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-enterprise</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>    
+    <dependency>
+      <groupId>org.jboss.bpm</groupId>
+      <artifactId>gwt-console-server-integration</artifactId>
+      <scope>compile</scope>
+    </dependency>
+
+    <!-- Test Dependencies -->
+    <dependency>
+      <groupId>cactus</groupId>
+      <artifactId>cactus</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.client</groupId>
+      <artifactId>jbossall-client</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+        <filtering>true</filtering>
+      </testResource>
+    </testResources>
+
+    <plugins>
+
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>jbpm.cfg.xml</exclude>
+            <exclude>jbpm-destinations-service.xml</exclude>
+            <exclude>jbpm-users.properties</exclude>
+            <exclude>jbpm-roles.properties</exclude>
+            <exclude>jboss-service.xml</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+
+          <execution>
+            <id>assembly-test-dependencies</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>directory-single</goal>
+            </goals>
+            <configuration>
+              <finalName>test-dependencies</finalName>
+              <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+              <appendAssemblyId>false</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-test-dependencies.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+
+          <execution>
+            <id>enterprise-config</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>${project.build.finalName}</finalName>
+              <appendAssemblyId>true</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-config.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>build-test-jars</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="build.dir" value="${project.build.directory}" />
+                <property name="test.resources.dir" value="${build.dir}/test-classes" />
+                <property name="build.finalName" value="${project.build.finalName}" />
+                <ant antfile="scripts/antrun-test-jars.xml" target="build-jars" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>org/jbpm/enterprise/internal/ejb/TimerTest.java</exclude>
+            <exclude>org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>no-jboss-bind-address</id>
+      <activation>
+        <property>
+          <name>!jboss.bind.address</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+  </profiles>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/scripts/antrun-test-jars.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/scripts/antrun-test-jars.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/scripts/antrun-test-jars.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: antrun-test-jars.xml 3915 2009-02-18 10:00:17Z heiko.braun at jboss.com $ -->
+
+<project>
+
+	<description>PVM test archive</description>
+
+	<target name="build-jars" description="Build the test modules.">
+
+	  <mkdir dir="${build.dir}/test-libs"/>
+
+		<war destfile="${build.dir}/test-libs/jbpm-enterprise-test.war" webxml="${test.resources.dir}/WEB-INF/web.xml">
+			<webinf dir="${test.resources.dir}/WEB-INF">
+				<exclude name="web.xml" />
+			</webinf>
+      <lib dir="${build.dir}/test-dependencies">
+        <include name="aspectjrt*.jar"/>
+        <include name="cactus*.jar"/>
+        <include name="junit*.jar"/>
+      </lib>
+		  <classes dir="${build.dir}/test-classes">
+		    <include name="org/jbpm/test/enterprise/*" />
+		    <include name="org/jbpm/enterprise/internal/ejb/*" />
+		  </classes>
+		</war>
+
+	  <jar destfile="${build.dir}/test-libs/jbpm-enterprise-test.jar">
+	    <fileset dir="${build.dir}/test-classes">	    	
+	      <include name="org/jbpm/enterprise/internal/custom/*" />
+	    </fileset>
+	  </jar>
+
+	  <ear destfile="${build.dir}/test-libs/jbpm-enterprise-test.ear" appxml="${test.resources.dir}/META-INF/application.xml">
+	    <!-- build artifact -->
+			<fileset dir="${build.dir}" includes="${build.finalName}.jar" />
+	    <!-- test modules -->
+	    <fileset dir="${build.dir}/test-libs" includes="jbpm-enterprise-test.war" />
+	    <zipfileset dir="${build.dir}/test-libs" includes="jbpm-enterprise-test.jar" prefix="lib" />
+	   
+		</ear>
+
+		<!-- Please add alphabetically -->
+
+	</target>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-config.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,21 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+  <id>config</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.outputDirectory}</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>jbpm.cfg.xml</include>
+        <include>jbpm-destinations-service.xml</include>
+        <include>jbpm-users.properties</include>
+        <include>jbpm-roles.properties</include>
+        <include>jboss-service.xml</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-test-dependencies.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-test-dependencies.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/scripts/assembly-test-dependencies.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,25 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+
+  <id>test-dependencies</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+
+  <!-- Dependency Sets -->
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <useStrictFiltering>true</useStrictFiltering>
+      <includes>
+        <include>aspectj:aspectjrt:jar</include>
+        <include>cactus:cactus</include>
+        <include>junit:junit</include>
+      </includes>
+      <unpack>false</unpack>
+      <scope>test</scope>
+    </dependencySet>
+  </dependencySets>
+
+</assembly>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jbpm.Configuration;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+
+/**
+ * Stateless session command executor.
+ * 
+ * <h3>Configuration</h3>
+ * 
+ * <p>
+ * In order to provide commands an environment in which to run, the command
+ * executor builds an environment factory from a configuration file loaded as a
+ * classpath resource. The environment entry <code>ConfigurationResource</code>
+ * specifies the name of the resource to access; the default is
+ * <code>jbpm.cfg.xml</code>.
+ * </p>
+ * 
+ * <h3>JNDI-bound environment factory</h3>
+ * 
+ * <p>
+ * To avoid parsing the configuration file multiple times, the command executor
+ * attempts to bind the environment factory to the name specified in the
+ * <code>EnvironmentFactoryName</code> environment entry, defaulting to
+ * <code>java:jbpm/EnvironmentFactory</code>. If the binding fails, the
+ * command executor will still work; however, each instance will build its own
+ * environment factory from the configuration.
+ * </p>
+ * 
+ * @author Jim Rigsbee
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class CommandExecutorSLSB implements SessionBean {
+
+  private SessionContext sessionContext;
+  private EnvironmentFactory environmentFactory;
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(CommandExecutorSLSB.class.getName());
+
+  public <T> T execute(Command<T> command) {
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      log.debug("executing command " + command);
+      return command.execute(environment);
+    }
+    catch (RuntimeException e) {
+      throw e;
+    }
+    catch (Exception e) {
+      throw new EJBException("failed to execute command " + command, e);
+    }
+    finally {
+      environment.close();
+    }
+  }
+
+  public void setSessionContext(SessionContext sessionContext) {
+    this.sessionContext = sessionContext;
+  }
+
+  /**
+   * Creates a command executor that will be used to execute the commands that
+   * are passed in the execute method.
+   */
+  public void ejbCreate() throws CreateException {
+    String envFactoryName = "java:jbpm/EnvironmentFactory";
+    try {
+      Context initial = new InitialContext();
+
+      // determine environment factory name
+      try {
+        envFactoryName = (String) initial.lookup("java:comp/env/EnvironmentFactoryName");
+      }
+      catch (NameNotFoundException e) {
+        log.debug("environment factory name not set, using default: " + envFactoryName);
+      }
+
+      try {
+        // retrieve environment factory
+        Object namedObject = initial.lookup(envFactoryName);
+        if (namedObject instanceof EnvironmentFactory) {
+          log.debug("using environment factory at " + envFactoryName);
+          environmentFactory = (EnvironmentFactory) namedObject;
+        }
+        else {
+          /*
+           * the bound object could be an instance of an environment factory
+           * loaded in another (older?) deployment; because each deployment sets
+           * up its own class loader, the existing instance could be perceived
+           * as not being an environment factory
+           */
+          if (namedObject == null || isInstance(EnvironmentFactory.class.getName(), namedObject)) {
+            log.debug("object bound to "
+                + envFactoryName
+                + " is a stale object factory, or null; unbinding it");
+            initial.unbind(envFactoryName);
+
+            environmentFactory = parseConfig(getConfigResource(initial));
+            bind(initial, environmentFactory, envFactoryName);
+          }
+          else {
+            log.debug("object bound to "
+                + envFactoryName
+                + " is not an environment factory, building one");
+            environmentFactory = parseConfig(getConfigResource(initial));
+            // no bind attempt
+          }
+        }
+      }
+      catch (NameNotFoundException noEnv) {
+        log.debug("environment factory not found at " + envFactoryName + ", building it");
+        environmentFactory = parseConfig(getConfigResource(initial));
+        bind(initial, environmentFactory, envFactoryName);
+      }
+    }
+    catch (NamingException e) {
+      log.error("could not create command executor", e);
+      throw new CreateException("jndi access failed");
+    }
+  }
+
+  private static boolean isInstance(String className, Object object) {
+    for (Class<?> cl = object.getClass(); cl != Object.class; cl = cl.getSuperclass()) {
+      if (cl.getName().equals(className))
+        return true;
+    }
+    return false;
+  }
+
+  private static String getConfigResource(Context context) throws NamingException {
+    String resource = "jbpm.cfg.xml";
+    try {
+      resource = (String) context.lookup("java:comp/env/ConfigurationResource");
+    }
+    catch (NameNotFoundException e) {
+      log.debug("configuration resource not set, using default: " + resource);
+    }
+    return resource;
+  }
+
+  private static EnvironmentFactory parseConfig(String resource) {
+    log.debug("parsing configuration from " + resource);
+    return (EnvironmentFactory) new Configuration().setResource(resource).buildProcessEngine();
+  }
+
+  private static void bind(Context context, EnvironmentFactory environmentFactory, String name) {
+    try {
+      context.bind(name, environmentFactory);
+      log.info("bound " + environmentFactory + " to " + name);
+    }
+    catch (NamingException e) {
+      log.info("WARNING: environment factory binding failed", e);
+    }
+  }
+
+  public void ejbRemove() {
+    environmentFactory = null;
+    sessionContext = null;
+  }
+
+  public void ejbActivate() {
+  }
+
+  public void ejbPassivate() {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandReceiverMDB.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandReceiverMDB.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandReceiverMDB.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.io.Serializable;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+
+/**
+ * Message driven command receiver.
+ * 
+ * <h3>Configuration</h3>
+ * 
+ * <p>
+ * The command receiver listens for messages on the destination established
+ * during deployment. Upon delivery, this bean extracts a
+ * {@linkplain Command command} from the message according to the format
+ * described in the {@link #onMessage(Message) onMessage} method.
+ * 
+ * <p>
+ * If the message does not match the expected format, it is forwarded to the
+ * message destination referenced by <code>jms/DeadLetterQueue</code>. No
+ * further processing is done on the message.
+ * </p>
+ * 
+ * <p>
+ * After extraction, the receiver dispatches the command to the
+ * {@linkplain LocalCommandExecutor local command executor} specified by the EJB
+ * reference <code>ejb/LocalCommandExecutor</code>.
+ * </p>
+ * 
+ * <p>
+ * In case the incoming message includes a <code>replyTo</code> destination,
+ * the result of the command execution is wrapped into a message and sent there.
+ * The resource manager connection factory reference
+ * <code>jms/CommandConnectionFactory</code> specifies the factory used to
+ * obtain JMS connections.
+ * </p>
+ * 
+ * @author Jim Rigsbee
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class CommandReceiverMDB implements MessageDrivenBean, MessageListener {
+
+  private MessageDrivenContext messageDrivenContext;
+  private LocalCommandExecutor commandExecutor;
+  private Connection jmsConnection;
+  private Destination deadLetterQueue;
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(CommandReceiverMDB.class.getName());
+
+  /**
+   * Processes a command message.
+   * 
+   * <h3>Message format</h3>
+   * 
+   * <p>
+   * The incoming messages must conform to one of the following formats.
+   * </p>
+   * 
+   * <ul>
+   * <li><strong>Command object</strong>. The body of the message is a Java
+   * {@linkplain ObjectMessage object} that implements the {@link Command}
+   * interface. The header properties of the message, if any, are ignored.</li>
+   * <li><strong>Job reference</strong>. The message contains a header
+   * property called <code>jobId</code> of type <code>long</code> which
+   * references a saved {@linkplain Job job} that is outstanding for execution.
+   * The body of the message, if any, is ignored.</li>
+   * </ul>
+   */
+  public void onMessage(Message message) {
+    try {
+      // extract command from message
+      Command<?> command = extractCommand(message);
+      if (command == null) {
+        discard(message);
+        return;
+      }
+      // execute command via local command executor bean
+      Object result = commandExecutor.execute(command);
+      // send a response back if a "reply to" destination is set
+      Destination replyTo = message.getJMSReplyTo();
+      if (replyTo != null && (result instanceof Serializable || result == null)) {
+        sendResult((Serializable) result, replyTo, message.getJMSMessageID());
+      }
+    }
+    catch (JMSException e) {
+      throw new EJBException("could not process message " + message, e);
+    }
+  }
+
+  private static Command<?> extractCommand(Message message) throws JMSException {
+    Command<?> command = null;
+    // messages can contain serialized commands
+    if (message instanceof ObjectMessage) {
+      ObjectMessage objectMessage = (ObjectMessage) message;
+      Serializable body = objectMessage.getObject();
+      log.debug("received object message with body " + body);
+      if (body instanceof Command) {
+        command = (Command<?>) body;
+      }
+      else {
+        log.info("WARNING: ignoring object message, body is not a command: " + message);
+      }
+    }
+    // messages can also contain a jobId property
+    else if (message.getObjectProperty("jobId") != null) {
+      long jobId = message.getLongProperty("jobId");
+      log.debug("received message with jobImpl id " + jobId);
+      // create a command with the given jobId
+      command = new ExecuteJobCmd(jobId);
+    }
+    else {
+      log.info("WARNING: ignoring message, unknown format: " + message);
+    }
+    return command;
+  }
+
+  private void discard(Message message) throws JMSException {
+    // if a dead letter queue is configured, send the message there
+    if (deadLetterQueue != null) {
+      Session jmsSession = createSession();
+      try {
+        jmsSession.createProducer(deadLetterQueue).send(message);
+      }
+      finally {
+        jmsSession.close();
+      }
+    }
+    else {
+      // reject the message
+      messageDrivenContext.setRollbackOnly();
+    }
+  }
+
+  private Session createSession() throws JMSException {
+    /*
+     * if the connection supports xa, the session will be transacted, else the
+     * session will auto acknowledge; in either case no explicit transaction
+     * control must be performed - see ejb 2.1 section 17.3.5
+     */
+    return jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+  }
+
+  private void sendResult(Serializable result, Destination destination, String correlationId)
+      throws JMSException {
+    log.debug("sending result " + result + " to " + destination);
+    Session jmsSession = createSession();
+    try {
+      Message resultMessage = jmsSession.createObjectMessage(result);
+      resultMessage.setJMSCorrelationID(correlationId);
+      jmsSession.createProducer(destination).send(resultMessage);
+    }
+    finally {
+      jmsSession.close();
+    }
+  }
+
+  public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) {
+    this.messageDrivenContext = messageDrivenContext;
+  }
+
+  public void ejbCreate() {
+    try {
+      Context context = new InitialContext();
+      LocalCommandExecutorHome commandExecutorHome = (LocalCommandExecutorHome) context.lookup("java:comp/env/ejb/LocalCommandExecutor");
+      ConnectionFactory jmsConnectionFactory = (ConnectionFactory) context.lookup("java:comp/env/jms/JbpmConnectionFactory");
+      try {
+        deadLetterQueue = (Destination) context.lookup("java:comp/env/jms/DeadLetterQueue");
+      }
+      catch (NameNotFoundException e) {
+        log.info("dead letter queue not specified, messages with unknown formats will be rejected");
+      }
+      context.close();
+
+      commandExecutor = commandExecutorHome.create();
+      jmsConnection = jmsConnectionFactory.createConnection();
+    }
+    catch (NamingException e) {
+      throw new EJBException("error retrieving managed objects", e);
+    }
+    catch (CreateException e) {
+      throw new EJBException("error creating command executor", e);
+    }
+    catch (JMSException e) {
+      throw new EJBException("error creating jms connection", e);
+    }
+  }
+
+  public void ejbRemove() {
+    if (jmsConnection != null) {
+      try {
+        jmsConnection.close();
+      }
+      catch (JMSException e) {
+        log.debug("could not close jms connection", e);
+      }
+      jmsConnection = null;
+    }
+    commandExecutor = null;
+    messageDrivenContext = null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbLocalCommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbLocalCommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbLocalCommandService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.CreateException;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+
+/**
+ * Local, stateless session bean implementation of the command service.
+ * 
+ * @author Tom Baeyens
+ */
+public class EjbLocalCommandService implements CommandService {
+
+  // injected
+  private LocalCommandExecutorHome commandExecutorHome;
+
+  private LocalCommandExecutor commandExecutor;
+
+  public LocalCommandExecutor getCommandExecutor() {
+    if (commandExecutor == null) {
+      try {
+        commandExecutor = commandExecutorHome.create();
+      } catch (CreateException e) {
+        throw new JbpmException("error creating command executor", e);
+      }
+    }
+    return commandExecutor;
+  }
+
+  public <T> T execute(Command<T> command) {
+    return getCommandExecutor().execute(command);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Timer;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.TimerSession;
+
+/**
+ * Timer session based on the EJB 2.1 timer service.
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class EjbTimerSession implements TimerSession {
+
+  // injected
+  private LocalTimerHome timerHome;
+
+  private static final Log log = Log.getLog(EjbTimerSession.class.getName());
+
+  public void schedule(Timer timer) {
+    log.debug("scheduling "+timer);
+
+    // flush timer to database
+    DbSession dbSession = Environment.getCurrent().get(DbSession.class);
+    dbSession.save(timer);
+    dbSession.flush();
+
+    // retrieve timer as entity bean, contact timer service
+    try {
+      LocalTimer timerBean = timerHome.findByPrimaryKey(timer.getDbid());
+      timerBean.schedule();
+    }
+    catch (FinderException e) {
+      throw new JbpmException("could not find bean for timer: " + timer);
+    }
+  }
+
+  public void cancel(Timer timer) {
+    try {
+      LocalTimer timerBean = timerHome.findByPrimaryKey(timer.getDbid());
+      log.debug("canceling " + timer);
+      /*
+       * EJB 2.1 section 22.4.4 If an entity bean is removed, the container must remove
+       * the timers for that bean
+       */
+      timerBean.remove();
+    }
+    catch (FinderException e) {
+      log.error("could not find bean for timer " + timer, e);
+    }
+    catch (RemoveException e) {
+      log.error("could not remove bean for timer " + timer, e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/ExecuteTimerCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/ExecuteTimerCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/ExecuteTimerCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.util.Date;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class ExecuteTimerCmd implements Command<Date> {
+
+  private final long timerDbid;
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ExecuteTimerCmd.class.getName());
+
+  public ExecuteTimerCmd(long timerDbid) {
+    this.timerDbid = timerDbid;
+  }
+
+  public Date execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TimerImpl timerImpl = dbSession.get(TimerImpl.class, timerDbid);
+    if (timerImpl == null) {
+      log.debug("timer not found: " + timerDbid);
+      return null; // i.e. delete this timer
+    }
+    return timerImpl.execute(environment) ? null : timerImpl.getDueDate();
+  }
+
+  public String toString() {
+    return ExecuteTimerCmd.class.getSimpleName() + '(' + timerDbid + ')';
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import org.jbpm.cmd.Command;
+
+/**
+ * EJB2 local interface for the command executor.
+ * @author Tom Baeyens
+ */
+public interface LocalCommandExecutor extends javax.ejb.EJBLocalObject {
+
+  /**
+   * Executes the given command locally.
+   */
+  <T> T execute(Command<T> command);
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutorHome.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutorHome.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalCommandExecutorHome.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+/**
+ * EJB2 local home for the command executor.
+ * @author Tom Baeyens
+ */
+public interface LocalCommandExecutorHome extends javax.ejb.EJBLocalHome {
+
+  /**
+   * Creates a command executor for local use.
+   * @throws javax.ejb.CreateException if creation fails
+   */
+  public LocalCommandExecutor create() throws javax.ejb.CreateException;
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface LocalTimer extends EJBLocalObject {
+
+  void schedule();
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimerHome.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimerHome.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/LocalTimerHome.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.EJBLocalHome;
+import javax.ejb.FinderException;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface LocalTimerHome extends EJBLocalHome {
+
+  LocalTimer findByPrimaryKey(Long id) throws FinderException;
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.rmi.RemoteException;
+
+import org.jbpm.cmd.Command;
+
+/**
+ * EJB2 remote interface for the command executor.
+ * @author Tom Baeyens
+ */
+public interface RemoteCommandExecutor extends javax.ejb.EJBObject {
+
+  /**
+   * Executes the given command remotely.
+   * @throws RemoteException if a communication error occurs
+   */
+  <T> T execute(Command<T> command) throws RemoteException;
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutorHome.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutorHome.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/RemoteCommandExecutorHome.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+
+/**
+ * EJB2 remote home interface for the command executor.
+ * @author Tom Baeyens
+ */
+public interface RemoteCommandExecutorHome extends javax.ejb.EJBHome {
+
+  /**
+   * Creates a command executor for remote use.
+   * @throws CreateException if creation fails
+   * @throws RemoteException if a communication error occurs
+   */
+  public RemoteCommandExecutor create() throws CreateException, RemoteException;
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/TimerEB.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/TimerEB.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/TimerEB.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.rmi.RemoteException;
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.ejb.TimedObject;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.TimerImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class TimerEB implements EntityBean, TimedObject {
+
+  private EntityContext entityContext;
+  private LocalCommandExecutor commandExecutor;
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(TimerEB.class.getName());
+
+  public abstract Long getDbid();
+
+  public abstract void setDbid(Long id);
+
+  public abstract Integer getDbversion();
+
+  public abstract void setDbversion(Integer version);
+
+  public abstract Date getDueDate();
+
+  public abstract void setDueDate(Date dueDate);
+
+  public void schedule() {
+    schedule(getDueDate());
+  }
+
+  private void schedule(Date dueDate) {
+    log.debug("registering timer #" + getDbid() + " due " + TimerImpl.formatDueDate(dueDate));
+    TimerService timerService = entityContext.getTimerService();
+    timerService.createTimer(dueDate, null);
+  }
+
+  public void setEntityContext(EntityContext entityContext) {
+    this.entityContext = entityContext;
+  }
+
+  public void unsetEntityContext() {
+    entityContext = null;
+  }
+
+  public void ejbRemove() throws RemoveException, RemoteException {
+    commandExecutor = null;
+  }
+
+  public void ejbActivate() throws RemoteException {
+    try {
+      Context context = new InitialContext();
+      LocalCommandExecutorHome commandExecutorHome = (LocalCommandExecutorHome) context
+          .lookup("java:comp/env/ejb/LocalCommandExecutor");
+      context.close();
+
+      commandExecutor = commandExecutorHome.create();
+    }
+    catch (NamingException e) {
+      throw new EJBException("error retrieving command executor home", e);
+    }
+    catch (CreateException e) {
+      throw new EJBException("error creating command executor", e);
+    }
+  }
+
+  public void ejbPassivate() throws RemoteException {
+    commandExecutor = null;
+  }
+
+  public void ejbLoad() throws RemoteException {
+  }
+
+  public void ejbStore() throws RemoteException {
+  }
+
+  public void ejbTimeout(Timer timer) {
+    Date nextDueDate = commandExecutor.execute(new ExecuteTimerCmd(getDbid()));
+    if (nextDueDate != null) {
+      schedule(nextDueDate);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbLocalCommandServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbLocalCommandServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbLocalCommandServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.wire.binding;
+
+import org.jbpm.enterprise.internal.ejb.EjbLocalCommandService;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.binding.WireDescriptorBinding;
+import org.jbpm.pvm.internal.wire.descriptor.JndiDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class EjbLocalCommandServiceBinding extends WireDescriptorBinding {
+
+  public EjbLocalCommandServiceBinding() {
+    super("ejb-local-command-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(EjbLocalCommandService.class);
+    // retrieve home name
+    String homeJndiName = "java:comp/env/ejb/LocalCommandExecutor";
+    Element homeElement = XmlUtil.element(element, "home");
+    if (homeElement != null && homeElement.hasAttribute("jndi-name")) {
+      homeJndiName = homeElement.getAttribute("jndi-name");
+    }
+    // inject home name
+    descriptor.addInjection("commandExecutorHome", new JndiDescriptor(homeJndiName));
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbTimerSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbTimerSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/wire/binding/EjbTimerSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.wire.binding;
+
+import org.jbpm.enterprise.internal.ejb.EjbTimerSession;
+import org.jbpm.pvm.internal.wire.binding.WireDescriptorBinding;
+import org.jbpm.pvm.internal.wire.descriptor.JndiDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class EjbTimerSessionBinding extends WireDescriptorBinding {
+
+  public EjbTimerSessionBinding() {
+    super("ejb-timer-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(EjbTimerSession.class);
+    descriptor.addInjection("timerHome", new JndiDescriptor(
+        "java:comp/env/ejb/LocalTimer"));
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/CommandDelegate.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/CommandDelegate.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/CommandDelegate.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.mgmt;
+
+
+import org.jbpm.enterprise.internal.ejb.LocalCommandExecutor;
+import org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome;
+
+import javax.ejb.CreateException;
+
+/**
+ * Adopts a business interface to the command facade.<br>
+ * Depends on the CommandExecutor(<code>java:jbpm/CommandExecutor</code>).
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class CommandDelegate
+{
+  private LocalCommandExecutor facade;
+  private static final String DEFAULT_JNDI_NAME = "java:jbpm/CommandExecutor";
+
+  /*
+  * Lookup with particluar JNDI name.
+  * @param jndiName
+  */
+  public CommandDelegate(String jndiName)
+  {
+    initialize(jndiName);
+  }
+
+  /*
+  * Lookup using default JNDI name.
+  * @see #DEFAULT_JNDI_NAME
+  */
+
+  public CommandDelegate()
+  {
+    initialize(DEFAULT_JNDI_NAME);
+  }
+
+  private void initialize(String jndiName)
+  {
+    try
+    {
+      LocalCommandExecutorHome home = (LocalCommandExecutorHome)ServiceLocator.getEjbLocalHome(jndiName);
+      this.facade = home.create();
+    }
+    catch (CreateException e)
+    {
+      throw new RuntimeException("Failed to create LocalCommandService", e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ManagementFactoryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ManagementFactoryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ManagementFactoryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.mgmt;
+
+import org.jboss.bpm.console.server.integration.*;
+import org.jboss.bpm.console.server.util.InvocationProxy;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ManagementFactoryImpl extends ManagementFactory
+{
+
+  public ProcessManagement createProcessManagement()
+  {
+    return (ProcessManagement)
+        InvocationProxy.newInstance(new ProcessManagementImpl());
+  }
+
+  public TaskManagement createTaskManagement()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  public UserManagement createUserManagement()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.mgmt;
+
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
+
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.model.Transition;
+
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ModelAdaptor
+{
+  public static ProcessDefinitionRef adoptDefinition(OpenProcessDefinition p0)
+  {
+    ProcessDefinitionRef def = new ProcessDefinitionRef();
+    def.setId( p0.getId() );
+    def.setName(p0.getName());
+    def.setVersion(p0.getVersion());
+
+    def.setKey( p0.getKey() );
+    def.setDescription(p0.getDescription());
+    def.setPackageName(p0.getPackageName());
+    
+    return def;
+
+  }
+
+  public static ProcessInstanceRef adoptExecution(OpenExecution e0)
+  {
+    ProcessInstanceRef ref = new ProcessInstanceRef();
+    ref.setId( e0.getId() );
+    ref.setKey(e0.getKey());
+    ref.setDefinitionId(e0.getProcessDefinition().getId() );    
+    ref.setStartDate( new Date() );                   // TODO: FIXME
+
+    OpenExecution topLevelExecution = e0.getProcessInstance();
+    TokenReference tok = execution2TokenReference(topLevelExecution);
+
+    Collection<OpenExecution> childExecutions = topLevelExecution.getExecutions();
+    if(childExecutions!=null)
+    {
+      for(OpenExecution childExecution : childExecutions)
+      {
+        TokenReference childTok = execution2TokenReference(childExecution);
+        tok.getChildren().add(childTok);
+      }
+    }
+
+    ref.setRootToken(tok);
+    
+    return ref;
+  }
+
+  private static TokenReference execution2TokenReference(OpenExecution topLevelExecution)
+  {
+    TokenReference tok = new TokenReference();
+    tok.setName(topLevelExecution.getName());
+    tok.setId(topLevelExecution.getId());
+    tok.setCurrentNodeName( topLevelExecution.getActivityName() );    
+
+    List<String> availableSignals = new ArrayList<String>();
+    for(Transition t : topLevelExecution.getActivity().getOutgoingTransitions())
+    {
+      availableSignals.add(t.getName());
+    }
+
+    tok.setAvailableSignals(availableSignals);
+    return tok;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.mgmt;
+
+import org.jboss.bpm.console.server.integration.ProcessManagement;
+import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
+import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jbpm.*;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.model.OpenExecution;
+
+import java.util.*;
+import java.io.InputStream;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class ProcessManagementImpl implements ProcessManagement
+{
+  private ProcessEngine processEngine;
+
+  public ProcessManagementImpl()
+  {
+    this.processEngine = new Configuration().buildProcessEngine(); 
+  }
+
+  public List<ProcessDefinitionRef> getProcessDefinitions()
+  {
+    List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
+
+    ProcessService processService = this.processEngine.getProcessService();
+    List<String> keys = processService.findProcessDefinitionKeys();
+    Set<ProcessDefinition> definitions = new HashSet<ProcessDefinition>();
+    for(String key : keys)
+    {
+      definitions.addAll(
+          processService.findProcessDefinitionsByKey(key)
+      );            
+    }
+
+    // adopt ProcessDefinition to console model
+    for(ProcessDefinition p0 : definitions)
+    {
+      results.add( ModelAdaptor.adoptDefinition((OpenProcessDefinition)p0) );
+    }
+
+    return results;
+
+  }
+
+  public ProcessDefinitionRef getProcessDefinition(String procDefId)
+  {
+    ProcessService processService = this.processEngine.getProcessService();
+    ProcessDefinition p0 = processService.findProcessDefinitionById(procDefId);
+    return ModelAdaptor.adoptDefinition((OpenProcessDefinition)p0);
+  }
+
+  public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId)
+  {
+    ProcessService processService = this.processEngine.getProcessService();
+    processService.deleteProcessDefinitionCascade(procDefId);
+    return getProcessDefinitions();
+  }
+
+  public List<ProcessInstanceRef> getProcessInstances(String procDefId)
+  {
+    ExecutionService execService = this.processEngine.getExecutionService();
+    ExecutionQuery query = execService.createExecutionQuery();
+    query.processDefinitionId(String.valueOf(procDefId));
+    
+    List<Execution> executions = query.execute();
+
+    List<ProcessInstanceRef> results = adoptTopLevelExecutions(executions);
+
+    return results;
+  }
+
+  private List<ProcessInstanceRef> adoptTopLevelExecutions(List<Execution> executions)
+  {
+    List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
+    for(Execution exec : executions)
+    {
+      if(exec.isEnded())
+      {
+        System.out.println("*** JBPM-2055: Execution ("+exec.getId()+") is already ended. Should not show up in query");
+        continue;
+      }
+
+      if(exec.isProcessInstance()) // parent execution
+      {
+        results.add( ModelAdaptor.adoptExecution((OpenExecution)exec) );
+      }
+    }
+    return results;
+  }
+
+  public ProcessInstanceRef getProcessInstance(String instanceId)
+  {
+    ExecutionService execService = this.processEngine.getExecutionService();
+    ExecutionQuery query = execService.createProcessInstanceQuery();
+    query.processInstanceId(instanceId);
+    List<Execution> executions = query.execute();
+
+    if(executions.size()>1 || executions.isEmpty())
+      throw new IllegalStateException("No precise match for instanceId " + instanceId +". Num results "+executions);
+
+    return ModelAdaptor.adoptExecution( (OpenExecution)executions.get(0));
+  }
+
+  public ProcessInstanceRef newInstance(String definitionId)
+  {
+    ExecutionService execService = this.processEngine.getExecutionService();
+    Execution exec = execService.startProcessInstanceById(definitionId);
+    return ModelAdaptor.adoptExecution((OpenExecution)exec);
+  }
+
+  public void setProcessState(String executionId, ProcessInstanceRef.STATE nextState)
+  {
+    if(ProcessInstanceRef.STATE.ENDED==nextState)
+    {
+      // TODO: It's actually a delte call. Once we got the 'cancel' notion this should be changed
+      ExecutionService execService = this.processEngine.getExecutionService();
+      Execution exec = execService.findExecution(executionId);
+      if(null==exec)
+        throw new IllegalArgumentException("No such execution with id "+ executionId);
+      
+      execService.deleteProcessInstance(executionId);
+    }
+    else
+    {
+      throw new IllegalArgumentException("State " + nextState + " currently not supported");
+    }
+  }
+
+  public void signalExecution(String executionId, String signal)
+  {        
+    ExecutionService execService = this.processEngine.getExecutionService();
+
+    if(null==signal)
+      execService.signalExecutionById(executionId);
+    else
+      execService.signalExecutionById(executionId, signal);
+            
+  }
+
+  public void deploy(String fileName, String contentType, InputStream deployment)
+  {
+    List<ProcessDefinition> definitions =
+        this.processEngine.getProcessService()
+        .createDeployment()
+        .addInputStream(fileName, deployment)
+        .deploy()
+        .getProcessDefinitions();
+    
+  }
+}
+

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ServiceLocator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ServiceLocator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ServiceLocator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.mgmt;
+
+import javax.ejb.EJBLocalHome;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class ServiceLocator
+{
+  public static EJBLocalHome getEjbLocalHome(String localHomeJndiName)
+  {
+    EJBLocalHome localHome = null;
+    try
+    {
+      Context ctx = createContext();
+      localHome = (EJBLocalHome) ctx.lookup(localHomeJndiName);
+    }
+    catch (Exception cce)
+    {
+      throw new RuntimeException("Failed load access EJB: " +localHomeJndiName, cce);
+    }
+
+    return localHome;
+  }
+
+  public static UserTransaction getUserTransaction()
+  {
+    UserTransaction tx = null;
+
+    try
+    {
+      Context ctx = createContext();
+      tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
+    }
+    catch (Exception e)
+    {
+      throw new RuntimeException("Failed to create UserTransaction");
+    }
+
+    return tx;
+  }
+
+  private static Context createContext()
+      throws NamingException
+  {
+    InitialContext ctx = new InitialContext();
+    return ctx;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/ejb-jar.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/ejb-jar.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<ejb-jar version="2.1"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+  http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee">
+
+  <description>JBoss jBPM enterprise beans</description>
+  <display-name>JBoss jBPM enterprise beans</display-name>
+
+  <enterprise-beans>
+
+    <session>
+      <description>Executes commands in a separate context.</description>
+      <display-name>jBPM Command Executor</display-name>
+      <ejb-name>CommandExecutor</ejb-name>
+      <home>org.jbpm.enterprise.internal.ejb.RemoteCommandExecutorHome</home>
+      <remote>org.jbpm.enterprise.internal.ejb.RemoteCommandExecutor</remote>
+      <local-home>org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome</local-home>
+      <local>org.jbpm.enterprise.internal.ejb.LocalCommandExecutor</local>
+      <ejb-class>org.jbpm.enterprise.internal.ejb.CommandExecutorSLSB</ejb-class>
+      <session-type>Stateless</session-type>
+      <transaction-type>Container</transaction-type>
+
+      <ejb-local-ref>
+        <description>
+          Link to the local entity bean that implements the timer session.
+          Required for that contain timers.
+        </description>
+        <ejb-ref-name>ejb/LocalTimer</ejb-ref-name>
+        <ejb-ref-type>Entity</ejb-ref-type>
+        <local-home>org.jbpm.enterprise.internal.ejb.LocalTimerHome</local-home>
+        <local>org.jbpm.enterprise.internal.ejb.LocalTimer</local>
+        <ejb-link>Timer</ejb-link>
+      </ejb-local-ref>
+
+      <resource-ref>
+        <description>
+          Logical name of the data source that provides connections to the database session.
+          Must match the hibernate.connection.datasource property.
+        </description>
+        <res-ref-name>jdbc/JbpmDataSource</res-ref-name>
+        <res-type>javax.sql.DataSource</res-type>
+        <res-auth>Container</res-auth>
+      </resource-ref>
+
+      <resource-ref>
+        <description>
+          Logical name of the factory that provides JMS connections to the message session.
+          Required for processes that contain asynchronous continuations.
+        </description>
+        <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+        <res-type>javax.jms.ConnnectionFactory</res-type>
+        <res-auth>Container</res-auth>
+      </resource-ref>
+
+      <message-destination-ref>
+        <description>
+          The command listener bean receives messages from the queue referenced here. To ensure this
+          is the same queue to which command messages can be sent, the message-destination-link
+          element points to a common logical destination, CommandQueue.
+        </description>
+        <message-destination-ref-name>jms/CommandQueue</message-destination-ref-name>
+        <message-destination-type>javax.jms.Queue</message-destination-type>
+        <message-destination-usage>Produces</message-destination-usage>
+        <message-destination-link>CommandQueue</message-destination-link>
+      </message-destination-ref>
+    </session>
+
+    <message-driven>
+      <description>
+        Listens for serialized commands and routes them to the command executor.
+      </description>
+      <display-name>jBPM Command Receiver</display-name>
+      <ejb-name>CommandReceiver</ejb-name>
+      <ejb-class>org.jbpm.enterprise.internal.ejb.CommandReceiverMDB</ejb-class>
+      <transaction-type>Container</transaction-type>
+      <message-destination-type>javax.jms.Queue</message-destination-type>
+      <message-destination-link>CommandQueue</message-destination-link>
+
+      <ejb-local-ref>
+        <description>
+          Link to the local session bean that executes commands on a separate environment.
+        </description>
+        <ejb-ref-name>ejb/LocalCommandExecutor</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <local-home>org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome</local-home>
+        <local>org.jbpm.enterprise.internal.ejb.LocalCommandExecutor</local>
+        <ejb-link>CommandExecutor</ejb-link>
+      </ejb-local-ref>
+
+      <resource-ref>
+        <description>
+          Logical name of the factory that provides JMS connections for producing result messages.
+          Required for command messages that indicate a reply destination.
+        </description>
+        <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+        <res-type>javax.jms.ConnectionFactory</res-type>
+        <res-auth>Container</res-auth>
+        <res-sharing-scope>Shareable</res-sharing-scope>
+      </resource-ref>
+
+      <message-destination-ref>
+        <description>
+          Messages that do not contain a command are sent to the queue referenced here.
+          If absent, said messages are rejected, which may cause the container to redeliver.
+        </description>
+        <message-destination-ref-name>jms/DeadLetterQueue</message-destination-ref-name>
+        <message-destination-type>javax.jms.Queue</message-destination-type>
+        <message-destination-usage>Produces</message-destination-usage>
+      </message-destination-ref>
+    </message-driven>
+
+    <entity>
+      <description>Interacts with the EJB timer service to schedule jBPM timers.</description>
+      <display-name>jBPM Timer</display-name>
+      <ejb-name>Timer</ejb-name>
+      <local-home>org.jbpm.enterprise.internal.ejb.LocalTimerHome</local-home>
+      <local>org.jbpm.enterprise.internal.ejb.LocalTimer</local>
+      <ejb-class>org.jbpm.enterprise.internal.ejb.TimerEB</ejb-class>
+      <persistence-type>Container</persistence-type>
+      <prim-key-class>java.lang.Long</prim-key-class>
+      <reentrant>false</reentrant>
+      <cmp-version>2.x</cmp-version>
+      <abstract-schema-name>pvm</abstract-schema-name>
+      <cmp-field>
+        <field-name>dbid</field-name>
+      </cmp-field>
+      <cmp-field>
+        <field-name>dueDate</field-name>
+      </cmp-field>
+      <!--
+      <cmp-field>
+        <field-name>dbversion</field-name>
+      </cmp-field>
+      -->
+      <primkey-field>dbid</primkey-field>
+
+      <ejb-local-ref>
+        <description>Link to the session bean that executes timers on a separate environment.</description>
+        <ejb-ref-name>ejb/LocalCommandExecutor</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <local-home>org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome</local-home>
+        <local>org.jbpm.enterprise.internal.ejb.LocalCommandExecutor</local>
+        <ejb-link>CommandExecutor</ejb-link>
+      </ejb-local-ref>
+    </entity>
+
+  </enterprise-beans>
+
+  <assembly-descriptor>
+
+    <container-transaction>
+      <method>
+        <ejb-name>CommandExecutor</ejb-name>
+        <method-name>*</method-name>
+      </method>
+      <trans-attribute>Required</trans-attribute>
+    </container-transaction>
+
+    <container-transaction>
+      <method>
+        <ejb-name>CommandReceiver</ejb-name>
+        <method-name>*</method-name>
+      </method>
+      <trans-attribute>Required</trans-attribute>
+    </container-transaction>
+
+    <container-transaction>
+      <method>
+        <ejb-name>Timer</ejb-name>
+        <method-name>*</method-name>
+      </method>
+      <trans-attribute>Required</trans-attribute>
+    </container-transaction>
+
+    <message-destination>
+    	<message-destination-name>CommandQueue</message-destination-name>
+    </message-destination>
+
+  </assembly-descriptor>
+
+</ejb-jar>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jboss.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jboss.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jboss.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
+  "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+
+  <enterprise-beans>
+
+    <session>
+      <ejb-name>CommandExecutor</ejb-name>
+      <jndi-name>jbpm/CommandExecutor</jndi-name>
+      <local-jndi-name>java:jbpm/CommandExecutor</local-jndi-name>
+      <resource-ref>
+        <res-ref-name>jdbc/JbpmDataSource</res-ref-name>
+        <jndi-name>java:JbpmDS</jndi-name>
+      </resource-ref>
+      <resource-ref>
+        <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+        <jndi-name>java:JmsXA</jndi-name>
+      </resource-ref>
+    </session>
+
+    <message-driven>
+      <ejb-name>CommandReceiver</ejb-name>
+      <resource-ref>
+        <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+        <jndi-name>java:JmsXA</jndi-name>
+      </resource-ref>
+      <message-destination-ref>
+        <message-destination-ref-name>jms/DeadLetterQueue</message-destination-ref-name>
+        <jndi-name>queue/DLQ</jndi-name>
+      </message-destination-ref>
+    </message-driven>
+
+    <entity>
+      <ejb-name>Timer</ejb-name>
+      <local-jndi-name>java:jbpm/Timer</local-jndi-name>
+    </entity>
+
+  </enterprise-beans>
+
+  <assembly-descriptor>
+
+    <message-destination>
+      <message-destination-name>CommandQueue</message-destination-name>
+      <jndi-name>queue/JbpmCommandQueue</jndi-name>
+    </message-destination>
+
+  </assembly-descriptor>
+
+</jboss>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jbosscmp-jdbc.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jbosscmp-jdbc.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/jbosscmp-jdbc.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
+  "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
+
+<jbosscmp-jdbc>
+  <defaults>
+    <datasource>java:/JbpmDS</datasource>
+    <create-table>false</create-table>
+    <remove-table>false</remove-table>
+    <pk-constraint>false</pk-constraint>
+  </defaults>
+  <enterprise-beans>
+    <entity>
+      <ejb-name>Timer</ejb-name>
+      <table-name>JBPM_JOB</table-name>
+      <cmp-field>
+        <field-name>dbid</field-name>
+        <column-name>DBID_</column-name>
+        <auto-increment/>
+      </cmp-field>
+      <cmp-field>
+        <field-name>dueDate</field-name>
+        <column-name>DUEDATE_</column-name>
+      </cmp-field>
+      <!--
+      <optimistic-locking>
+        <version-column />
+        <field-name>dbversion</field-name>
+        <column-name>DBVERSION_</column-name>
+      </optimistic-locking>
+      -->
+    </entity>
+  </enterprise-beans>
+</jbosscmp-jdbc>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/services/org.jboss.bpm.console.server.integration.ManagementFactory
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/services/org.jboss.bpm.console.server.integration.ManagementFactory	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/META-INF/services/org.jboss.bpm.console.server.integration.ManagementFactory	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+org.jbpm.enterprise.mgmt.ManagementFactoryImpl
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jboss-service.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jboss-service.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jboss-service.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+  <!-- The custom JAAS login configuration that installs
+      a Configuration capable of dynamically updating the
+      config settings
+  -->
+  <mbean code="org.jboss.security.auth.login.DynamicLoginConfig" name="org.jboss.jbpm:service=LoginConfig">
+    <attribute name="PolicyConfig" serialDataType="jbxb">
+      <jaas:policy xsi:schemaLocation="urn:jboss:security-config:4.1 resource:security-config_4_1.xsd" xmlns:jaas="urn:jboss:security-config:4.1"
+                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <jaas:application-policy name="jbpm-console">
+          <jaas:authentication>
+
+            <!-- Simple authentication -->
+            <jaas:login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
+                               flag="required">
+              <jaas:module-option name="usersProperties">jbpm-users.properties</jaas:module-option>
+              <jaas:module-option name="rolesProperties">jbpm-roles.properties</jaas:module-option>
+            </jaas:login-module>
+
+
+            <!-- Authenticate against the IDM database -->
+            <!--jaas:login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
+              <jaas:module-option name="dsJndiName">java:/JbpmDS</jaas:module-option>
+              <jaas:module-option name="principalsQuery"> SELECT PASSWORD_ FROM JBPM_ID_USER WHERE NAME_=? </jaas:module-option>
+              <jaas:module-option name="rolesQuery">
+                SELECT g.NAME_ ,'Roles' FROM JBPM_ID_USER u, JBPM_ID_MEMBERSHIP m, JBPM_ID_GROUP g
+                WHERE g.TYPE_='security-role' AND m.GROUP_ = g.ID_ AND m.USER_ = u.ID_ AND u.NAME_=? </jaas:module-option>
+            </jaas:login-module-->
+          </jaas:authentication>
+        </jaas:application-policy>
+      </jaas:policy>
+    </attribute>
+    <depends optional-attribute-name="LoginConfigService"> jboss.security:service=XMLLoginConfig</depends>
+    <depends optional-attribute-name="SecurityManagerService"> jboss.security:service=JaasSecurityManager</depends>
+  </mbean>
+</server>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-destinations-service.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-destinations-service.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-destinations-service.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: jbossmq-destinations-service.xml 25907 2004-11-16 04:32:39Z ejort $ -->
+
+<!--
+  This file defines the default Queues and Topics that jBPM ships with.  
+  You can add other destinations to this file, or you can create other
+  *-service.xml files to contain your application's destinations.
+ -->
+
+<server>
+  <!--
+    Destinations without a configured SecurityManager or without a
+    SecurityConf will default to role guest with read=true, write=true,
+    create=false.
+  -->
+
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+	 name="jboss.mq.destination:service=Queue,name=JbpmCommandQueue">
+    <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+  </mbean>
+
+</server>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-roles.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-roles.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-roles.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+admin=admin
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-users.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-users.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm-users.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+admin=admin
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  jBPM4 enterprise configuration.
+  Uses different command service and environment config.
+  (i.e. skips the TX interceptor)
+-->
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+
+    <process-service />
+    <execution-service />
+    <management-service />
+
+    <ejb-local-command-service>
+      <home jndi-name="java:jbpm/CommandExecutor"/>
+    </ejb-local-command-service>
+
+    <hibernate-configuration resource="hibernate.cfg.xml"/>
+
+    <hibernate-session-factory />
+
+    <id-generator />
+    <types resource="jbpm.pvm.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session current="true" />
+    <pvm-db-session />
+    <job-db-session />
+    <ejb-timer-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.enterprise.wire.bindings.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.enterprise.wire.bindings.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/main/resources/jbpm.enterprise.wire.bindings.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,6 @@
+<wire-bindings>
+
+  <binding class="org.jbpm.enterprise.internal.wire.binding.EjbTimerSessionBinding" />
+  <binding class="org.jbpm.enterprise.internal.wire.binding.EjbLocalCommandServiceBinding" />
+
+</wire-bindings>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/HappyListener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/HappyListener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/HappyListener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.custom;
+
+import java.util.Date;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.pvm.internal.job.TimerImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class HappyListener implements EventListener {
+
+  private static Date executionDate;
+  private static Semaphore semaphore = new Semaphore(0);
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(HappyListener.class.getName());
+
+  public void notify(EventListenerExecution execution) throws Exception {
+    executionDate = new Date();
+    log.info("executing on " + TimerImpl.formatDueDate(executionDate));
+
+    semaphore.release();
+  }
+
+  public static Date waitFor() {
+    return waitFor(10000);
+  }
+
+  public static Date waitFor(long timeout) {
+    executionDate = null;
+    try {
+      semaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS);
+    }
+    catch (InterruptedException e) {
+      log.info("wait interrupted");
+    }    
+    return executionDate;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.custom;
+
+import java.sql.SQLException;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class InsertCommentCmd implements Command<Void> {
+
+  private final String message;
+  private final boolean fail;
+
+  private static final long serialVersionUID = 1L;
+
+  public InsertCommentCmd(String message) {
+    this(message, false);
+  }
+
+  public InsertCommentCmd(String message, boolean fail) {
+    this.message = message;
+    this.fail = fail;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    CommentImpl comment = new CommentImpl();
+    comment.setMessage(message);
+    environment.get(DbSession.class).save(comment);
+    if (fail)
+      throw new SQLException("simulated failure");
+    return null;
+  }
+
+  @Override
+  public String toString() {
+    return InsertCommentCmd.class.getSimpleName() + '(' + message + ')';
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/NoisyListener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/NoisyListener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/NoisyListener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.custom;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.pvm.internal.job.TimerImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class NoisyListener implements EventListener {
+
+  private static Date executionDate;
+  private static Semaphore semaphore = new Semaphore(0);
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(NoisyListener.class.getName());
+
+  public void notify(EventListenerExecution execution) throws Exception {
+    executionDate = new Date();
+    execution.setVariable("executionDate", executionDate);
+    log.info("executing on " + TimerImpl.formatDueDate(executionDate));
+
+    semaphore.release();
+
+    throw new SQLException("simulated failure");
+  }
+
+  public static Date waitFor() {
+    executionDate = null;
+    try {
+      semaphore.tryAcquire(10000, TimeUnit.MILLISECONDS);
+    }
+    catch (InterruptedException e) {
+      log.info("wait interrupted");
+    }    
+    return executionDate;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.custom;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class RemoveCommentCmd implements Command<Boolean> {
+
+  private final String message;
+
+  private static final long serialVersionUID = 1L;
+
+  public RemoveCommentCmd(String message) {
+    this.message = message;
+  }
+
+  public Boolean execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    List<?> comments = session.createCriteria(CommentImpl.class)
+        .add(Restrictions.eq("message", message))
+        .setMaxResults(1)
+        .list();
+    if (comments.isEmpty())
+      return false;
+    CommentImpl phrase = (CommentImpl) comments.get(0);
+    session.delete(phrase);
+    return true;
+  }
+
+  public String toString() {
+    return RemoveCommentCmd.class.getSimpleName() + '(' + message + ')';
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.custom;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class WaitState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters)
+      throws Exception {
+    if (parameters != null) {
+      execution.setVariables(parameters);
+    }
+
+    Activity activity = execution.getActivity();
+    execution.fire(signalName, activity);
+
+    Transition transition = activity.findOutgoingTransition(signalName);
+    if (transition != null) {
+      execution.take(transition);
+    }
+    else {
+      execution.waitForSignal();
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.apache.cactus.ServletTestCase;
+
+import org.jbpm.enterprise.internal.custom.InsertCommentCmd;
+import org.jbpm.enterprise.internal.custom.RemoveCommentCmd;
+import org.jbpm.enterprise.internal.ejb.CommandExecutorSLSB;
+import org.jbpm.enterprise.internal.ejb.LocalCommandExecutor;
+import org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome;
+import org.jbpm.internal.log.Log;
+import org.jbpm.test.enterprise.IntegrationTestSetup;
+
+/**
+ * Server-side test for the {@linkplain CommandExecutorSLSB command executor}.
+ * The local interface is used.
+ * 
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class CommandExecutorTest extends ServletTestCase {
+
+  private LocalCommandExecutor commandExecutor;
+
+  private static final Log log = Log
+      .getLog(CommandExecutorTest.class.getName());
+
+  private static LocalCommandExecutorHome commandExecutorHome;
+
+  public static Test suite() {
+    return new IntegrationTestSetup(CommandExecutorTest.class,
+        "jbpm-enterprise-test.ear");
+  }
+
+  @Override
+  protected void setUp() throws Exception {
+    if (commandExecutorHome == null) {
+      // retrieve managed objects
+      InitialContext initialContext = new InitialContext();
+      try {
+        commandExecutorHome = (LocalCommandExecutorHome) initialContext
+            .lookup("java:jbpm/CommandExecutor");
+      }
+      finally {
+        initialContext.close();
+      }
+    }
+    commandExecutor = commandExecutorHome.create();
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    commandExecutor = null;
+  }
+
+  /**
+   * <p>
+   * This scenario tests a command that completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command creates a row with the specified text.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * A new row with the specified text exists in the table. The
+   * {@link RemoveCommentCmd} command removes the row, and the return value
+   * confirms it was there.
+   * </p>
+   */
+  public void testHappyCommand() throws CreateException {
+    String text = "been there, done that";
+    commandExecutor.execute(new InsertCommentCmd(text));
+    // verify phrase was inserted
+    assertTrue(commandExecutor.execute(new RemoveCommentCmd(text)));
+  }
+
+  /**
+   * <p>
+   * This scenario tests a command that throws a checked exception inside the
+   * {@link InsertCommentCmd#execute(org.jbpm.env.Environment) execute} method.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command creates a row with the specified text.
+   * The command is configured to throw a checked exception before completing.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The command executor throws an {@link EJBException} and rolls back the
+   * managed transaction. No row with the specified text exists in the database.
+   * The {@link RemoveCommentCmd} command return value confirms the row was not
+   * there.
+   * </p>
+   */
+  public void testNoisyCommand() throws CreateException {
+    String text = "houston, we have a problem";
+    // insert phrase via command
+    try {
+      commandExecutor.execute(new InsertCommentCmd(text, /* fail? */true));
+      fail("expected: " + EJBException.class.getSimpleName());
+    }
+    catch (EJBException e) {
+      log.info("noisy command threw exception", e);
+      // verify phrase was NOT inserted
+      assertFalse(commandExecutor.execute(new RemoveCommentCmd(text)));
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.apache.cactus.ServletTestCase;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.enterprise.internal.custom.InsertCommentCmd;
+import org.jbpm.enterprise.internal.custom.RemoveCommentCmd;
+import org.jbpm.enterprise.internal.ejb.CommandReceiverMDB;
+import org.jbpm.internal.log.Log;
+import org.jbpm.test.enterprise.IntegrationTestSetup;
+
+/**
+ * Server-side test for the {@linkplain CommandReceiverMDB command receiver}.
+ * 
+ * @author Alejandro Guizar
+ */
+public class CommandReceiverTest extends ServletTestCase {
+
+  private Connection jmsConnection;
+
+  private static ConnectionFactory jmsConnectionFactory;
+  private static Destination commandQueue;
+
+  private static final long TIMEOUT = 2000;
+  private static final Log log = Log.getLog(CommandReceiverTest.class.getName());
+
+  public static Test suite() {
+    return new IntegrationTestSetup(CommandReceiverTest.class, "jbpm-enterprise-test.ear");
+  }
+
+  @Override
+  protected void setUp() throws Exception {
+    log.info("=== starting " + getName() + " =============================");
+    if (jmsConnectionFactory == null) {
+      // retrieve managed objects
+      Context initial = new InitialContext();
+      try {
+        jmsConnectionFactory = (ConnectionFactory) initial
+            .lookup("ConnectionFactory");
+        commandQueue = (Destination) initial.lookup("queue/JbpmCommandQueue");
+      }
+      finally {
+        initial.close();
+      }
+    }
+    jmsConnection = jmsConnectionFactory.createConnection();
+    jmsConnection.start();
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    if (jmsConnection != null) {
+      jmsConnection.stop();
+      jmsConnection.close();
+      jmsConnection = null;
+    }
+    log.info("=== ending " + getName() + " =============================");
+  }
+
+  private boolean isJDK6()
+  {
+    if(System.getProperty("java.version").indexOf("1.6") !=-1)
+      return true;
+    else
+      return false;
+  }
+
+  /**
+   * <p>
+   * This scenario tests a command message that completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command message creates a row with the
+   * specified text. Once the command completes, the command receiver sends the
+   * result to the reply queue.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * A new row with the specified text exists in the table. The
+   * {@link RemoveCommentCmd} command message removes the row. The result sent
+   * to the reply queue confirms the row was there.
+   * </p>
+   */
+  public void testHappyMessage() throws JMSException {
+
+    if(isJDK6())
+    {
+      // https://jira.jboss.org/jira/browse/JBPM-2070
+      System.out.println("FIXME JBPM-2070: CommandReceiverTest on JDK 1.6");
+      return;
+    }
+
+    final String text = "been there, done that";
+    Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+    try {
+      // send insert command
+      Command<Void> insertCommand = new InsertCommentCmd(text, /* fail? */false);
+      Message insertMessage = jmsSession.createObjectMessage(insertCommand);
+      Destination replyTo = jmsSession.createTemporaryQueue();
+      insertMessage.setJMSReplyTo(replyTo);
+      MessageProducer producer = jmsSession.createProducer(commandQueue);
+      producer.send(insertMessage);
+
+      // receive insertion response
+      MessageConsumer insertConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '"
+          + insertMessage.getJMSMessageID()
+          + "'");
+      ObjectMessage responseMessage = (ObjectMessage) insertConsumer.receive(TIMEOUT);
+      assertNull(responseMessage.getObject());
+
+      // send remove command
+      Command<Boolean> removeCommand = new RemoveCommentCmd(text);
+      Message removeMessage = jmsSession.createObjectMessage(removeCommand);
+      removeMessage.setJMSReplyTo(replyTo);
+      producer.send(removeMessage);
+
+      // receive removal response
+      MessageConsumer removeConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '"
+          + removeMessage.getJMSMessageID()
+          + "'");
+      responseMessage = (ObjectMessage) removeConsumer.receive(TIMEOUT);
+      // verify phrase was inserted
+      assertTrue((Boolean) responseMessage.getObject());
+    }
+    finally {
+      jmsSession.close();
+    }
+  }
+
+  /**
+   * <p>
+   * This scenario tests a command message that throws a checked exception
+   * inside the {@link InsertCommentCmd#execute(org.jbpm.env.Environment)
+   * execute} method.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command message creates a row with the
+   * specified text. The command is configured to throw a checked exception
+   * before completing. The exception prevents the command receiver from sending
+   * the result to the reply queue.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The command receiver rolls back the managed transaction and puts the
+   * insertion message back in the command queue. No row with the specified
+   * exists in the database. The {@link RemoveCommentCmd} command result sent to
+   * the reply queue confirms the row was not there.
+   * </p>
+   */
+  public void testNoisyMessage() throws JMSException {
+
+    if(isJDK6())
+    {
+      // https://jira.jboss.org/jira/browse/JBPM-2070
+      System.out.println("FIXME JBPM-2070: CommandReceiverTest on JDK 1.6");
+      return;
+    }
+    
+    final String text = "houston, we have a problem";
+    // insert phrase via command
+    Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+    try {
+      // send insert command
+      Command<Void> insertCommand = new InsertCommentCmd(text, /* fail? */true);
+      Message insertMessage = jmsSession.createObjectMessage(insertCommand);
+      Destination replyTo = jmsSession.createTemporaryQueue();
+      insertMessage.setJMSReplyTo(replyTo);
+      MessageProducer producer = jmsSession.createProducer(commandQueue);
+      producer.send(insertMessage);
+
+      // receive insertion response
+      MessageConsumer insertConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '"
+          + insertMessage.getJMSMessageID()
+          + "'");
+      ObjectMessage insertResponse = (ObjectMessage) insertConsumer.receive(TIMEOUT);
+      assertNull(insertResponse);
+
+      // send remove command
+      Command<Boolean> removeCommand = new RemoveCommentCmd(text);
+      Message removeMessage = jmsSession.createObjectMessage(removeCommand);
+      removeMessage.setJMSReplyTo(replyTo);
+      producer.send(removeMessage);
+
+      // receive removal response
+      MessageConsumer removeConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '"
+          + removeMessage.getJMSMessageID()
+          + "'");
+      ObjectMessage removeResponse = (ObjectMessage) removeConsumer.receive(TIMEOUT);
+      // verify phrase was NOT inserted
+      assertFalse((Boolean) removeResponse.getObject());
+    }
+    finally {
+      jmsSession.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.util.Date;
+
+import javax.ejb.CreateException;
+
+import junit.framework.Test;
+
+import org.jbpm.ExecutionService;
+import org.jbpm.ProcessService;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.enterprise.internal.custom.HappyListener;
+import org.jbpm.enterprise.internal.custom.WaitState;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.TimerSession;
+import org.jbpm.test.enterprise.EnvironmentServletTestCase;
+import org.jbpm.test.enterprise.IntegrationTestSetup;
+
+/**
+ * Server-side test for the enterprise {@linkplain EjbTimerSession timer
+ * session}.
+ * 
+ * @author Alejandro Guizar
+ */
+public class EjbTimerSessionTest extends EnvironmentServletTestCase {
+
+  private String processDefinitionId;
+  private Date dueDate;
+
+  private static final int TIMEOUT = 2000;
+
+  public static Test suite() {
+    return new IntegrationTestSetup(EjbTimerSessionTest.class, "jbpm-enterprise-test.ear");
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    // define process
+    dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess(getName())
+      .startActivity("start", new ObjectDescriptor(WaitState.class))
+        .initial()
+        .startFlow("end")
+          .name("timeout")
+          .listener(new ObjectDescriptor(HappyListener.class))
+        .endFlow()
+        .startTimer("timeout")
+          .dueDate(dueDate)
+        .endTimer()
+      .endActivity()
+      .startActivity("end", new ObjectDescriptor(WaitState.class))
+      .endActivity()
+    .endProcess();
+    // deploy process
+    environment.get(ProcessService.class).createDeployment().addObject(processDefinition.getName(),
+        processDefinition).deploy();
+    processDefinitionId = processDefinition.getId();
+  }
+
+  protected void tearDown() throws Exception {
+    // environment.get(ProcessService.class).deleteProcessDefinition(processDefinitionId);
+    super.tearDown();
+  }
+
+  /**
+   * <p>
+   * This scenario schedules a non-repeating timer whose referenced activity
+   * completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link ScheduleTimerCmd} command activates a timer. After that, the
+   * test waits for the activity to execute. Upon timeout, the
+   * {@linkplain HappyListener activity} notifies the test of its execution.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date.
+   * </p>
+   */
+  public void testSchedule() throws CreateException {
+    // start an execution
+    environment.get(CommandService.class).execute(
+        new StartExecutionCmd(processDefinitionId, null, null));
+
+    // wait for activity to execute
+    Date executionDate = HappyListener.waitFor();
+    assertTrue(dueDate.compareTo(executionDate) <= 0);
+  }
+
+  /**
+   * <p>
+   * This scenario schedules a non-repeating timer and immediately cancels it.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link ScheduleTimerCmd} command activates a timer, which is
+   * immediately disabled by the {@link CancelTimerCmd} command. After that, the
+   * test waits past the timer's due date.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity does not execute, ever.
+   * </p>
+   */
+  public void testCancel() throws CreateException {
+    // start an execution
+    environment.get(ExecutionService.class).startProcessInstanceById(processDefinitionId);
+
+    // wait past the due date, ensure activity did not execute
+    Date executionDate = HappyListener.waitFor(2 * TIMEOUT);    
+    assertNull(executionDate);
+  }
+
+  static class ScheduleTimerCmd implements Command<Void> {
+
+    private final TimerImpl timer;
+
+    private static final long serialVersionUID = 1L;
+
+    ScheduleTimerCmd(TimerImpl timer) {
+      this.timer = timer;
+    }
+
+    public Void execute(Environment environment) throws Exception {
+      environment.get(DbSession.class).save(timer.getExecution());
+      environment.get(TimerSession.class).schedule(timer);
+      return null;
+    }
+  }
+
+  static class CancelTimerCmd implements Command<Void> {
+
+    private final long timerDbid;
+
+    private static final long serialVersionUID = 1L;
+
+    CancelTimerCmd(long timerDbid) {
+      this.timerDbid = timerDbid;
+    }
+
+    public Void execute(Environment environment) throws Exception {
+      TimerImpl timer = environment.get(DbSession.class).get(TimerImpl.class, timerDbid);
+      environment.get(TimerSession.class).cancel(timer);
+      return null;
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.enterprise.internal.ejb;
+
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jbpm.Execution;
+import org.jbpm.ExecutionService;
+import org.jbpm.ProcessService;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.enterprise.internal.custom.HappyListener;
+import org.jbpm.enterprise.internal.custom.NoisyListener;
+import org.jbpm.enterprise.internal.custom.WaitState;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+import org.jbpm.test.enterprise.EnvironmentServletTestCase;
+import org.jbpm.test.enterprise.IntegrationTestSetup;
+
+/**
+ * Server-side test for the {@linkplain TimerEB timer bean}. The local interface
+ * is used.
+ * 
+ * @author Alejandro Guizar
+ */
+public class TimerTest extends EnvironmentServletTestCase {
+
+  private ClientProcessDefinition processDefinition;
+  private ObjectDescriptor listenerDescriptor = new ObjectDescriptor();
+  private Date dueDate;
+
+  private static final int TIMEOUT = 2000;
+  private static final int REPEAT = 1000;
+
+  private static final Log log = Log.getLog(TimerTest.class.getName());
+
+  private static LocalTimerHome timerHome;
+
+  public static Test suite() {
+    return new IntegrationTestSetup(TimerTest.class, "jbpm-enterprise-test.ear");
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    // lookup timer home in jndi
+    if (timerHome == null) {
+      InitialContext initialContext = new InitialContext();
+      try {
+        timerHome = (LocalTimerHome) initialContext.lookup("java:comp/env/ejb/LocalTimer");
+      }
+      finally {
+        initialContext.close();
+      }
+    }
+    // define process
+    dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+    processDefinition = ProcessDefinitionBuilder
+    .startProcess(getName())
+      .startActivity(new ObjectDescriptor(WaitState.class))
+        .initial()
+        .startTimer("timeout")
+          .dueDate(dueDate)
+        .endTimer()
+        .startFlow("end")
+          .name("timeout")
+          .listener(listenerDescriptor)
+        .endFlow()
+      .endActivity()
+      .startActivity("end", new ObjectDescriptor(WaitState.class))
+      .endActivity()
+    .endProcess();
+  }
+
+  protected void tearDown() throws Exception {
+    // environment.get(ProcessService.class).deleteProcessDefinition(processDefinition.getId());
+    super.tearDown();
+  }
+
+  /**
+   * <p>
+   * This scenario tests a non-repeating timer whose referenced activity
+   * completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB timer
+   * service. After that, the test waits for the activity to execute. Upon
+   * timeout, the {@linkplain HappyListener activity} notifies the test of its
+   * execution.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date.
+   * </p>
+   */
+  public void testHappyTimer() throws CreateException {
+    // deploy process
+    listenerDescriptor.setClassName(HappyListener.class.getName());
+    environment.get(ProcessService.class).createDeployment().addObject(processDefinition.getName(),
+        processDefinition).deploy();
+    // start execution
+    Execution execution = environment.get(ExecutionService.class).startProcessInstanceById(
+        processDefinition.getId());
+
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setExecution((ExecutionImpl) execution);
+    environment.get(CommandService.class).execute(new CreateTimerCmd(timer));
+
+    Date executionDate = HappyListener.waitFor();
+    assertNotNull(executionDate);
+    assertTrue(dueDate.compareTo(executionDate) <= 0);
+  }
+
+  /**
+   * <p>
+   * This scenario tests a non-repeating timer whose referenced activity throws
+   * a checked exception.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB timer
+   * service. After that, the test waits for the activity to execute. Upon
+   * timeout, the {@linkplain NoisyListener activity} notifies the test of its
+   * execution, sets a variable and throws a checked exception.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date. The EJB timer
+   * service rolls back the managed transaction. The variable is unset.
+   * </p>
+   */
+  public void testNoisyTimer() throws CreateException {
+    // deploy process
+    listenerDescriptor.setClassName(NoisyListener.class.getName());
+    environment.get(ProcessService.class).createDeployment().addObject(processDefinition.getName(),
+        processDefinition).deploy();
+    // start execution
+    ExecutionService executionService = environment.get(ExecutionService.class);
+    ExecutionImpl execution = (ExecutionImpl) executionService.startProcessInstanceById(processDefinition
+        .getId());
+
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setExecution(execution);
+    CommandService commandService = environment.get(CommandService.class);
+    commandService.execute(new CreateTimerCmd(timer));
+
+    Date executionDate = NoisyListener.waitFor();
+    assertNotNull(executionDate);
+    assertTrue(dueDate.compareTo(executionDate) <= 0);
+
+    Object variableValue = executionService.getVariable(execution.getId(), "executionDate");
+    assertNull(variableValue);
+  }
+
+  /**
+   * <p>
+   * This scenario tests a repeating timer whose referenced activity completes
+   * with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB timer
+   * service. After that, the test waits for the first execution of the
+   * activity, and then for the subsequent <em>n</em> executions of the
+   * activity. Upon each timeout, the {@linkplain HappyListener activity}
+   * notifies the test of its execution.
+   * </p>
+   * <h3>
+   * Postconditions</h3>
+   * <p>
+   * The first execution of the activity occurs on or after the timer's due
+   * date. The subsequent <em>n</em> executions of the activity occur on or
+   * after the timer's repeat interval.
+   * </p>
+   */
+  public void testCyclicTimer() throws CreateException {
+    // deploy process
+    listenerDescriptor.setClassName(HappyListener.class.getName());
+    environment.get(ProcessService.class).createDeployment().addObject(processDefinition.getName(),
+        processDefinition).deploy();
+    // start execution
+    ExecutionImpl execution = (ExecutionImpl) environment.get(ExecutionService.class)
+        .startProcessInstanceById(processDefinition.getId());
+
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setRepeat(REPEAT + " milliseconds");
+    timer.setExecution(execution);
+    CommandService commandService = environment.get(CommandService.class);
+    commandService.execute(new CreateTimerCmd(timer));
+
+    try {
+      Date executionTime = HappyListener.waitFor();
+      assertTrue(dueDate.compareTo(executionTime) <= 0);
+
+      for (int i = 0; i < 5; i++) {
+        dueDate.setTime(dueDate.getTime() + REPEAT);
+        log.info("next execution due " + TimerImpl.formatDueDate(dueDate));
+        executionTime = HappyListener.waitFor();
+        assertTrue(dueDate.compareTo(executionTime) <= 0);
+      }
+    }
+    finally {
+      commandService.execute(new CancelTimerCmd(timer.getDbid()));
+    }
+  }
+
+  static class CreateTimerCmd implements Command<Void> {
+
+    private final TimerImpl timer;
+
+    private static final long serialVersionUID = 1L;
+
+    CreateTimerCmd(TimerImpl timer) {
+      this.timer = timer;
+    }
+
+    public Void execute(Environment environment) throws Exception {
+      DbSession dbSession = environment.get(DbSession.class);
+      dbSession.save(timer);
+      dbSession.flush();
+
+      long timerDbid = timer.getDbid();
+      log.info("scheduling " + timer + " #" + timerDbid);
+      LocalTimer timerBean = timerHome.findByPrimaryKey(timerDbid);
+      timerBean.schedule();
+      return null;
+    }
+
+    public String toString() {
+      return CreateTimerCmd.class.getSimpleName() + '(' + timer + ')';
+    }
+  }
+
+  static class CancelTimerCmd implements Command<Void> {
+
+    private final long timerDbid;
+
+    private static final long serialVersionUID = 1L;
+
+    CancelTimerCmd(long timerDbid) {
+      this.timerDbid = timerDbid;
+    }
+
+    public Void execute(Environment environment) throws Exception {
+      LocalTimer timerBean = timerHome.findByPrimaryKey(timerDbid);
+      timerBean.remove();
+      return null;
+    }
+
+    public String toString() {
+      return CancelTimerCmd.class.getSimpleName() + '(' + timerDbid + ')';
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ArchiveDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ArchiveDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ArchiveDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.net.URL;
+
+/**
+ * An archive deployer
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 16-May-2006
+ */
+public interface ArchiveDeployer {
+  /**
+   * Deploy the given archive
+   */
+  void deploy(URL archive) throws Exception;
+
+  /**
+   * Undeploy the given archive
+   */
+  void undeploy(URL archive) throws Exception;
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/EnvironmentServletTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/EnvironmentServletTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/EnvironmentServletTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cactus.ServletTestCase;
+import org.jbpm.Configuration;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+
+/**
+ * @author Alejandro Guizar
+ */
+public abstract class EnvironmentServletTestCase extends ServletTestCase {
+
+  private final String configResource;
+  protected Environment environment;
+  protected Log log = Log.getLog(getClass().getName());
+
+  private static final Map<String, EnvironmentFactory> environmentFactories = new HashMap<String, EnvironmentFactory>();
+
+  public EnvironmentServletTestCase() {
+    this("jbpm.cfg.xml");
+  }
+
+  public EnvironmentServletTestCase(String configResource) {
+    this.configResource = configResource;
+  }
+
+  protected void setUp() throws Exception {
+    log.info("=== starting " + getName() + " =============================");
+    openEnvironment();
+  }
+
+  protected void tearDown() throws Exception {
+    closeEnvironment();
+    log.info("=== ending " + getName() + " =============================");
+  }
+
+  void closeEnvironment() {
+    environment.close();
+    environment = null;
+  }
+
+  void openEnvironment() {
+    environment = getEnvironmentFactory().openEnvironment();
+  }
+
+  public EnvironmentFactory getEnvironmentFactory() {
+    EnvironmentFactory environmentFactory = environmentFactories.get(configResource);
+    if (environmentFactory == null) {
+      environmentFactory = createEnvironmentFactory(configResource);
+    }
+    return environmentFactory;
+  }
+
+  EnvironmentFactory createEnvironmentFactory(String configResource) {
+    try {
+      log.debug("creating environment factory for " + configResource);
+      EnvironmentFactory environmentFactory = (EnvironmentFactory) new Configuration().setResource(
+          configResource).buildProcessEngine();
+      environmentFactories.put(configResource, environmentFactory);
+      return environmentFactory;
+    }
+    catch (Exception e) {
+      throw new JbpmException("could not create environment factory for " + configResource, e);
+    }
+  }
+
+  void closeEnvironmentFactory(String configResource) {
+    EnvironmentFactory environmentFactory = environmentFactories.remove(configResource);
+    if (environmentFactory != null) {
+      log.debug("closing environment factory for " + configResource);
+      environmentFactory.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestHelper.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestHelper.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestHelper.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * An integration test helper that deals with test deployment/undeployment, etc.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestHelper {
+  private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+  private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+
+  private static String testResourcesDir;
+  private static String testArchiveDir;
+
+  private static MBeanServerConnection server;
+  private String integrationTarget;
+
+  public void deploy(String archive) throws Exception {
+    URL url = getTestArchiveFile(archive).toURI().toURL();
+    deploy(url);
+  }
+
+  public void deploy(URL archive) throws Exception {
+    getDeployer().deploy(archive);
+  }
+
+  public void undeploy(String archive) throws Exception {
+    URL url = getTestArchiveFile(archive).toURI().toURL();
+    undeploy(url);
+  }
+
+  public void undeploy(URL archive) throws Exception {
+    getDeployer().undeploy(archive);
+  }
+
+  public boolean isTargetJBoss500() {
+    String target = getIntegrationTarget();
+    return target.startsWith("jboss500");
+  }
+
+  public boolean isTargetJBoss423() {
+    String target = getIntegrationTarget();
+    return target.startsWith("jboss423");
+  }
+
+  public boolean isTargetJBoss422() {
+    String target = getIntegrationTarget();
+    return target.startsWith("jboss422");
+  }
+
+  private String getIntegrationTarget() {
+    if (integrationTarget == null) {
+      String jbossVersion;
+      try {
+        ObjectName oname = ObjectNameFactory
+            .create("jboss.system:type=ServerConfig");
+        jbossVersion = (String) getServer().getAttribute(oname,
+            "SpecificationVersion");
+      } catch (Exception ex) {
+        throw new IllegalStateException("Cannot obtain jboss version", ex);
+      }
+
+      if (jbossVersion.startsWith("5.0.0"))
+        integrationTarget = "jboss500";
+      else if (jbossVersion.startsWith("4.2.3"))
+        integrationTarget = "jboss423";
+      else if (jbossVersion.startsWith("4.2.2"))
+        integrationTarget = "jboss422";
+      else
+        throw new IllegalStateException("Unsupported jboss version: "
+            + jbossVersion);
+    }
+    return integrationTarget;
+  }
+
+  public MBeanServerConnection getServer() {
+    if (server == null) {
+      Hashtable jndiEnv = null;
+      try {
+        InitialContext iniCtx = new InitialContext();
+        jndiEnv = iniCtx.getEnvironment();
+        server = (MBeanServerConnection) iniCtx
+            .lookup("jmx/invoker/RMIAdaptor");
+      } catch (NamingException ex) {
+        throw new RuntimeException(
+            "Cannot obtain MBeanServerConnection using jndi props: " + jndiEnv,
+            ex);
+      }
+    }
+    return server;
+  }
+
+  private ArchiveDeployer getDeployer() {
+    return new JBossArchiveDeployer(getServer());
+  }
+
+  /** Try to discover the URL for the test resource */
+  public URL getResourceURL(String resource) {
+    URL resURL = null;
+    try {
+      File resourceFile = getResourceFile(resource);
+      resURL = resourceFile.toURI().toURL();
+    } catch (MalformedURLException e) {
+      // ignore
+    }
+    return resURL;
+  }
+
+  /** Try to discover the File for the test resource */
+  public File getResourceFile(String resource) {
+    File file = new File(resource);
+    if (file.exists())
+      return file;
+
+    file = new File(getTestResourcesDir() + "/" + resource);
+    if (file.exists())
+      return file;
+
+    throw new IllegalArgumentException("Cannot obtain '"
+        + getTestResourcesDir() + "/" + resource + "'");
+  }
+
+  public String getTestResourcesDir() {
+    if (testResourcesDir == null) {
+      testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY,
+          "target/test-classes");
+    }
+    return testResourcesDir;
+  }
+
+  /** Try to discover the URL for the deployment archive */
+  public URL getTestArchiveURL(String archive) throws MalformedURLException {
+    return getTestArchiveFile(archive).toURI().toURL();
+  }
+
+  /** Try to discover the File for the deployment archive */
+  public File getTestArchiveFile(String archive) {
+    File file = new File(archive);
+    if (file.exists())
+      return file;
+
+    file = new File(getTestArchiveDir() + "/" + archive);
+    if (file.exists())
+      return file;
+
+    String notSet = getTestArchiveDir() == null ? " System property '"
+        + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "";
+    throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir()
+        + "/" + archive + "'." + notSet);
+  }
+
+  public String getTestArchiveDir() {
+    if (testArchiveDir == null) {
+      testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY,
+          "target/test-libs");
+    }
+    return testArchiveDir;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestSetup.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestSetup.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/IntegrationTestSetup.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+
+import junit.extensions.TestSetup;
+import junit.framework.TestSuite;
+
+import org.jbpm.internal.log.Log;
+
+/**
+ * A test setup that deploys/undeploys archives
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestSetup extends TestSetup {
+  private IntegrationTestHelper delegate = new IntegrationTestHelper();
+  private String[] archives;
+  private ClassLoader originalClassLoader;
+
+  private static final Log log = Log.getLog(IntegrationTestSetup.class
+      .getName());
+
+  public IntegrationTestSetup(Class<?> testClass, String... archiveList) {
+    super(new TestSuite(testClass));
+    archives = archiveList != null ? archiveList : new String[0];
+  }
+
+  public File getArchiveFile(String archive) {
+    return delegate.getTestArchiveFile(archive);
+  }
+
+  public URL getArchiveURL(String archive) throws MalformedURLException {
+    return delegate.getTestArchiveFile(archive).toURI().toURL();
+  }
+
+  public boolean isTargetJBoss500() {
+    return delegate.isTargetJBoss500();
+  }
+
+  public boolean isTargetJBoss423() {
+    return delegate.isTargetJBoss423();
+  }
+
+  public boolean isTargetJBoss422() {
+    return delegate.isTargetJBoss422();
+  }
+
+  public MBeanServerConnection getServer() {
+    return delegate.getServer();
+  }
+
+  @Override
+  protected void setUp() throws Exception {
+    log.debug("### START SETUP " + getTest());
+
+    List<URL> clientJars = new ArrayList<URL>();
+    for (int i = 0; i < archives.length; i++) {
+      String archive = archives[i];
+      try {
+        delegate.deploy(archive);
+      } catch (Exception ex) {
+        ex.printStackTrace();
+        delegate.undeploy(archive);
+      }
+
+      if (archive.endsWith("-client.jar")) {
+        URL archiveURL = getArchiveURL(archive);
+        clientJars.add(archiveURL);
+      }
+    }
+
+    ClassLoader parent = Thread.currentThread().getContextClassLoader();
+    originalClassLoader = parent;
+
+    // add client jars to the class loader
+    if (!clientJars.isEmpty()) {
+      URL[] urls = new URL[clientJars.size()];
+      for (int i = 0; i < clientJars.size(); i++) {
+        urls[i] = clientJars.get(i);
+      }
+      URLClassLoader cl = new URLClassLoader(urls, parent);
+      Thread.currentThread().setContextClassLoader(cl);
+    }
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    try {
+      for (int i = 0; i < archives.length; i++) {
+        String archive = archives[archives.length - i - 1];
+        delegate.undeploy(archive);
+      }
+    } finally {
+      Thread.currentThread().setContextClassLoader(originalClassLoader);
+    }
+    log.debug("### END SETUP " + getTest());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/JBossArchiveDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/JBossArchiveDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/JBossArchiveDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.net.URL;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+/**
+ * An archive deployer that deals with test deployment/undeployment, etc.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class JBossArchiveDeployer implements ArchiveDeployer {
+  private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
+
+  private MBeanServerConnection server;
+
+  public JBossArchiveDeployer(MBeanServerConnection server) {
+    this.server = server;
+  }
+
+  public void deploy(URL url) throws Exception {
+    invokeMainDeployer("deploy", url);
+  }
+
+  public void undeploy(URL url) throws Exception {
+    invokeMainDeployer("undeploy", url);
+  }
+
+  private void invokeMainDeployer(String methodName, URL url) throws Exception {
+    server.invoke(new ObjectName(MAIN_DEPLOYER), methodName,
+        new Object[] { url }, new String[] { "java.net.URL" });
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ObjectNameFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ObjectNameFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/test/enterprise/ObjectNameFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.enterprise;
+
+import java.util.Hashtable;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * A simple factory for creating safe object names.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 08-May-2006
+ */
+public class ObjectNameFactory {
+  public static ObjectName create(String name) {
+    try {
+      return new ObjectName(name);
+    } catch (MalformedObjectNameException e) {
+      throw new IllegalArgumentException("Invalid ObjectName: " + name, e);
+    }
+  }
+
+  public static ObjectName create(String domain, String key, String value) {
+    try {
+      return new ObjectName(domain, key, value);
+    } catch (MalformedObjectNameException e) {
+      throw new IllegalArgumentException("Invalid ObjectName: " + domain + ","
+          + key + "," + value, e);
+    }
+  }
+
+  public static ObjectName create(String domain, Hashtable<String, String> table) {
+    try {
+      return new ObjectName(domain, table);
+    } catch (MalformedObjectNameException e) {
+      throw new IllegalArgumentException("Invalid ObjectName: " + domain + ","
+          + table, e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/META-INF/application.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/META-INF/application.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/META-INF/application.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application version="5"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee">
+
+  <display-name>JBoss jBPM enterprise beans</display-name>
+
+  <module>
+    <web>
+      <web-uri>jbpm-enterprise-test.war</web-uri>
+      <context-root>/jbpm-enterprise-test</context-root>
+    </web>
+  </module>
+  <library-directory>lib</library-directory>
+
+</application>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/jboss-web.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/jboss-web.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/jboss-web.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" 
+  "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd" >
+<jboss-web>
+
+  <!--resource-ref>
+    <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+    <jndi-name>java:ConnectionFactory</jndi-name>
+  </resource-ref-->
+
+</jboss-web>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/web.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/web.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/WEB-INF/web.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+  <servlet>
+    <servlet-name>ServletRedirector</servlet-name>
+    <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>ServletRedirector</servlet-name>
+    <url-pattern>/ServletRedirector</url-pattern>
+  </servlet-mapping>
+
+  <!--ejb-local-ref>
+    <ejb-ref-name>ejb/LocalCommandExecutor</ejb-ref-name>
+    <ejb-ref-type>Session</ejb-ref-type>
+    <local-home>org.jbpm.enterprise.internal.ejb.LocalCommandExecutorHome</local-home>
+    <local>org.jbpm.enterprise.internal.ejb.LocalCommandExecutor</local>
+    <ejb-link>CommandExecutor</ejb-link>
+  </ejb-local-ref>
+
+  <ejb-local-ref>
+    <ejb-ref-name>ejb/LocalTimer</ejb-ref-name>
+    <ejb-ref-type>Entity</ejb-ref-type>
+    <local-home>org.jbpm.enterprise.internal.ejb.LocalTimerHome</local-home>
+    <local>org.jbpm.enterprise.internal.ejb.LocalTimer</local>
+    <ejb-link>Timer</ejb-link>
+  </ejb-local-ref>
+
+  <resource-ref>
+    <res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
+    <res-type>javax.jms.ConnectionFactory</res-type>
+    <res-auth>Container</res-auth>
+    <res-sharing-scope>Shareable</res-sharing-scope>
+  </resource-ref>
+
+  <message-destination-ref>
+    <message-destination-ref-name>jms/CommandQueue</message-destination-ref-name>
+    <message-destination-type>javax.jms.Queue</message-destination-type>
+    <message-destination-usage>Produces</message-destination-usage>
+    <message-destination-link>CommandQueue</message-destination-link>
+  </message-destination-ref-->
+</web-app>

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/cactus.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/cactus.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/cactus.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1 @@
+cactus.contextURL =http\://${jboss.bind.address}\:8080/jbpm-enterprise-test
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/jndi.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/jndi.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/jndi.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp\://${jboss.bind.address}\:1099

Added: jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/log4j.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/log4j.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/resources/log4j.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+  <!-- ================================= -->
+  <!-- Preserve messages in a local file -->
+  <!-- ================================= -->
+
+  <appender name="FILE" class="org.apache.log4j.FileAppender">
+    <param name="File" value="${project.build.directory}/test.log"/>
+    <param name="Append" value="false"/>
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+    </layout>
+  </appender>
+  
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out" />
+    <param name="Threshold" value="INFO" />
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
+    </layout>
+  </appender>
+
+  <!-- ================ -->
+  <!-- Limit categories -->
+  <!-- ================ -->
+
+  <category name="org.jbpm">
+    <priority value="DEBUG" />
+  </category>
+
+  <!-- Limit the org.hibernate category to INFO as its DEBUG is verbose -->
+  <category name="org.hibernate">
+    <priority value="INFO" />
+  </category>
+
+  <!-- hide optimistic locking failures
+  <category name="org.hibernate.event.def.AbstractFlushingEventListener">
+    <priority value="FATAL" />
+  </category>
+  -->
+
+  <!-- hide proxy narrowing warns -->
+  <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog">
+    <priority value="ERROR" />
+  </category>
+
+  <!-- show SQL DML statements as they are executed -->
+  <category name="org.hibernate.SQL">
+    <priority value="DEBUG" />
+  </category>
+
+  <!-- show JDBC parameters
+  <category name="org.hibernate.type">
+    <priority value="TRACE" />
+  </category>
+  -->
+
+  <!-- ======================= -->
+  <!-- Setup the Root category -->
+  <!-- ======================= -->
+
+  <root>
+    <!--appender-ref ref="CONSOLE"/-->
+    <appender-ref ref="FILE"/>
+  </root>
+
+</log4j:configuration>

Added: jbpm4/branches/tbaeyens/modules/examples/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/test-classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/examples/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>examples</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/examples/jbpm4-examples.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/jbpm4-examples.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/jbpm4-examples.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,406 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="toplevel" exported="" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.0.1B:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax-api:jar:1.0.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.4.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/examples/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 4068 2009-02-27 14:27:54Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Examples</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-examples</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-base</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>    
+      <version>${version}</version>
+      <scope>test</scope>
+      <!--exclusions> TODO: Re-enable when JBPM-1997 is done.
+        <exclusion>
+          <artifactId>org.jbpm.jbpm4</artifactId>
+          <groupId>jbpm-pvm</groupId>
+        </exclusion>        
+      </exclusions-->
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+      <artifactId>test-util</artifactId>
+      <scope>test</scope>
+    </dependency>
+     <dependency>
+      <groupId>org.codehaus.woodstox</groupId>
+      <artifactId>wstx-lgpl</artifactId>
+      <scope>test</scope>
+    </dependency>   
+    <dependency>
+      <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+      <artifactId>jbossesb-rosetta</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+      <artifactId>test-util</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>                                                   
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack.jbpm.db</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jbpm.jbpm4</groupId>
+                  <artifactId>jbpm-jpdl</artifactId>
+                  <classifier>config</classifier>
+                  <overWrite>true</overWrite>
+                </artifactItem>
+              </artifactItems>
+              <excludeTransitive>true</excludeTransitive>
+              <outputDirectory>target/jpdl-config</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>install.hibernate.database.properties</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <copy file="target/jpdl-config/hibernate.cfg.${database}.xml"
+                      tofile="target/test-classes/examples-hibernate.cfg.xml"
+                      overwrite="true" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jBPM Libraries"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/eclipse/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>examples</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/graphbased/ConcurrencyGraphBasedTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/graphbased/ConcurrencyGraphBasedTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/concurrency/graphbased/ConcurrencyGraphBasedTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.concurrency.graphbased;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConcurrencyGraphBasedTest extends JbpmTestCase {
+
+  public void testConcurrencyGraphBased() {
+    deployJpdlResource("org/jbpm/examples/concurrency/graphbased/process.jpdl.xml");
+    
+    Execution processInstance = executionService.startProcessInstanceByKey("ConcurrencyGraphBased");
+    String pid = processInstance.getId();
+    
+    Set<String> expectedActivityNames = new HashSet<String>();
+    expectedActivityNames.add("send invoice");
+    expectedActivityNames.add("load truck");
+    expectedActivityNames.add("print shipping documents");
+    
+    assertEquals(expectedActivityNames, getActivityNames(pid));
+    
+    assertTrue(findExecution(pid, "send invoice").isActive());
+    assertTrue(findExecution(pid, "load truck").isActive());
+    assertTrue(findExecution(pid, "print shipping documents").isActive());
+    
+    String sendInvoiceExecutionId = findExecution(pid, "send invoice").getId();
+    executionService.signalExecutionById(sendInvoiceExecutionId);
+
+    expectedActivityNames.remove("send invoice");
+    expectedActivityNames.add("final join");
+    assertEquals(expectedActivityNames, getActivityNames(pid));
+
+    assertTrue(findExecution(pid, "load truck").isActive());
+    assertTrue(findExecution(pid, "print shipping documents").isActive());
+    assertFalse(findExecution(pid, "final join").isActive());
+
+    String loadTruckExecutionId = findExecution(pid, "load truck").getId();
+    executionService.signalExecutionById(loadTruckExecutionId);
+
+    expectedActivityNames.remove("load truck");
+    expectedActivityNames.add("shipping join");
+    assertEquals(expectedActivityNames, getActivityNames(pid));
+
+    assertTrue(findExecution(pid, "print shipping documents").isActive());
+    assertFalse(findExecution(pid, "final join").isActive());
+    
+    String printShippingDocumentsId = findExecution(pid, "print shipping documents").getId();
+    executionService.signalExecutionById(printShippingDocumentsId);
+
+    expectedActivityNames.remove("print shipping documents");
+    expectedActivityNames.remove("shipping join");
+    expectedActivityNames.add("drive truck to destination");
+    assertEquals(expectedActivityNames, getActivityNames(pid));
+
+    assertTrue(findExecution(pid, "drive truck to destination").isActive());
+    assertFalse(findExecution(pid, "final join").isActive());
+
+    String driveTruckExecutionId = findExecution(pid, "drive truck to destination").getId();
+    executionService.signalExecutionById(driveTruckExecutionId);
+
+    assertNull(executionService.findExecution(pid));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.end.multiple;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndMultipleTest extends JbpmTestCase {
+
+  public void testEndMultipleOk() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "200");
+    assertTrue(execution.isEnded());
+    assertEquals("ok", execution.getActivityName());
+  }
+
+  public void testEndMultipleBadRequest() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "400");
+    assertTrue(execution.isEnded());
+    assertEquals("bad request", execution.getActivityName());
+  }
+
+  public void testEndMultipleInternalServerError() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "500");
+    assertTrue(execution.isEnded());
+    assertEquals("internal server error", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.end.processinstance;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndProcessInstanceTest extends JbpmTestCase {
+
+  public void testEndProcessInstance() {
+    deployJpdlResource("org/jbpm/examples/end/processinstance/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndProcessInstance");
+    assertTrue(execution.isEnded());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.end.state;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndStateTest extends JbpmTestCase {
+
+  public void testEndStateCompleted() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "200");
+    assertEquals("completed", execution.getState());
+    assertEquals("ok", execution.getActivityName());
+  }
+
+  public void testEndStateErrorBadRequest() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "400");
+    assertEquals("cancel", execution.getState());
+    assertEquals("bad request", execution.getActivityName());
+  }
+
+  public void testEndStateErrorInternalServerError() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "500");
+    assertEquals("error", execution.getState());
+    assertEquals("internal server error", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.esb;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EsbTest extends JbpmTestCase {
+  
+  public JbpmMockCourier courier;
+
+  public void setUp() throws Exception {
+    super.setUp();
+    
+    MockCourierFactory.install();
+    MockRegistry.install();
+    EPR epr = new EPR(new URI("epr"));
+    courier = new JbpmMockCourier();
+    MockRegistry.register("orderProcessing", "bookSold", epr, courier);
+  }
+
+  public void testEsb() {
+    deployJpdlResource("org/jbpm/examples/esb/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("title", "Internetworking with TCP/IP");
+    
+    executionService.startProcessInstanceByKey("Esb", variables);
+
+    Message message = courier.getMessage();
+    Body body = message.getBody();
+    assertEquals("Internetworking with TCP/IP", body.get("bookTitle"));
+    assertEquals("deliver asap", body.get("goal"));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/JbpmMockCourier.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/JbpmMockCourier.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/esb/JbpmMockCourier.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.esb;
+
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.soa.esb.message.Message;
+
+public class JbpmMockCourier extends MockCourier {
+
+  public JbpmMockCourier() {
+    super(true);
+  }
+
+  public Message getMessage() {
+    return message;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.exclusive.conditions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveConditionsTest extends JbpmTestCase {
+
+  public void testExclusiveConditionsGood() {
+    deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "good");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveConditions", variables);
+    assertEquals("submit document", execution.getActivityName());
+  }
+
+  public void testExclusiveConditionsBad() {
+    deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "bad");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveConditions", variables);
+    assertEquals("try again", execution.getActivityName());
+  }
+
+  public void testExclusiveConditionsUgly() {
+    deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "ugly");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveConditions", variables);
+    assertEquals("give up", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.exclusive.expression;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveExpressionTest extends JbpmTestCase {
+
+  public void testExclusiveExpressionGood() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "good");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveExpression", variables);
+    assertEquals("submit document", execution.getActivityName());
+  }
+
+  public void testExclusiveExpressionBad() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "bad");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveExpression", variables);
+    assertEquals("try again", execution.getActivityName());
+  }
+
+  public void testExclusiveExpressionUgly() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "ugly");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveExpression", variables);
+    assertEquals("give up", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.exclusive.handler;
+
+import org.jbpm.jpdl.ExclusiveHandler;
+import org.jbpm.model.OpenExecution;
+
+public class ContentEvaluation implements ExclusiveHandler {
+
+  public String select(OpenExecution execution) {
+    String content = (String) execution.getVariable("content");
+    if (content.equals("you're great")) {
+      return "good";
+    }
+    if (content.equals("you gotta improve")) {
+      return "bad";
+    }
+    return "ugly";
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.exclusive.handler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveHandlerTest extends JbpmTestCase {
+  
+  public void testExclusiveHandlerGreat() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you're great");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveHandler", variables);
+    assertEquals("submit document", execution.getActivityName());
+  }
+
+  public void testExclusiveHandlerImprove() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you gotta improve");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveHandler", variables);
+    assertEquals("try again", execution.getActivityName());
+  }
+
+  public void testExclusiveHandlerSuck() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you suck");
+    Execution execution = executionService.startProcessInstanceByKey("ExclusiveHandler", variables);
+    assertEquals("give up", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.hql;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlTest extends JbpmTestCase {
+
+  public void testHql() {
+    deployJpdlResource("org/jbpm/examples/hql/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("Hql");
+    String executionId = execution.getId();
+    
+    Set<String> variableNames = executionService.getVariableNames(executionId);
+    Map<String, Object> variables = executionService.getVariables(executionId, variableNames);
+
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    List<String> activityNames = new ArrayList<String>();
+    activityNames.add("get process names");
+    activityNames.add("count activities");
+    expectedVariables.put("activities with o", activityNames);
+
+    expectedVariables.put("activities", new Long(4));
+
+    assertEquals(expectedVariables, variables);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JavaInstantiateTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JavaInstantiateTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JavaInstantiateTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.java;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JavaInstantiateTest extends JbpmTestCase {
+
+  public void testJavaInstantiate() {
+    deployJpdlResource("org/jbpm/examples/java/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("Java");
+    String executionId = execution.getId();
+    
+    String answer = (String) executionService.getVariable(executionId, "answer");
+    
+    assertEquals("I'm fine, thank you.", answer);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JohnDoe.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JohnDoe.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/java/JohnDoe.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.java;
+
+import org.hibernate.Session;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JohnDoe {
+  
+  String state;
+  Session session;
+  
+  public String hello(String msg) {
+    if ( (msg.indexOf("how are you?")!=-1)
+         && (session.isOpen())
+       ) {
+      return "I'm "+state+", thank you.";
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/expression/ScriptExpressionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/expression/ScriptExpressionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/expression/ScriptExpressionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.script.expression;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.examples.script.text.Person;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptExpressionTest extends JbpmTestCase {
+
+  public void testScriptText() {
+    deployJpdlResource("org/jbpm/examples/script/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("person", new Person("Honolulu"));
+    
+    Execution execution = executionService.startProcessInstanceByKey("ScriptExpression", variables);
+    String executionId = execution.getId();
+    
+    String text = (String) executionService.getVariable(executionId, "text");
+    assertTextPresent("Send packet to Honolulu", text);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/Person.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/Person.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/Person.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.script.text;
+
+import java.io.Serializable;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Person implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  String address;
+  
+  public Person(String address) {
+    this.address = address;
+  }
+  
+  public String getAddress() {
+    return address;
+  }
+  
+  public void setAddress(String address) {
+    this.address = address;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/ScriptTextTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/ScriptTextTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/script/text/ScriptTextTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.script.text;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptTextTest extends JbpmTestCase {
+
+  public void testScriptText() {
+    deployJpdlResource("org/jbpm/examples/script/text/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("person", new Person("Honolulu"));
+    
+    Execution execution = executionService.startProcessInstanceByKey("ScriptText", variables);
+    String executionId = execution.getId();
+    
+    String text = (String) executionService.getVariable(executionId, "text");
+    assertTextPresent("Send packet to Honolulu", text);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlTest extends JbpmTestCase {
+
+  public void testSql() {
+    deployJpdlResource("org/jbpm/examples/sql/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("Sql");
+    String executionId = execution.getId();
+    
+    List<String> expectedActivityNames = new ArrayList<String>();
+    expectedActivityNames.add("get process names");
+    expectedActivityNames.add("count activities");
+    Object activityNames = executionService.getVariable(executionId, "activities with o");
+    assertEquals(expectedActivityNames, activityNames);
+    
+    Object activities = executionService.getVariable(executionId, "activities");
+    assertEquals("4", activities.toString());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.state.choice;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateChoiceTest extends JbpmTestCase {
+
+  public void testStateChoiceAccept() {
+    deployJpdlResource("org/jbpm/examples/state/choice/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("StateChoice");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "accept");
+    assertEquals("submit document", execution.getActivityName());
+  }
+
+  public void testStateChoiceReject() {
+    deployJpdlResource("org/jbpm/examples/state/choice/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("StateChoice");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "reject");
+    assertEquals("try again", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/sequence/StateSequenceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/sequence/StateSequenceTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/state/sequence/StateSequenceTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.state.sequence;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateSequenceTest extends JbpmTestCase {
+
+  public void testWaitStatesSequence() {
+    deployJpdlResource("org/jbpm/examples/state/sequence/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("StateSequence");
+    assertEquals("a", execution.getActivityName());
+
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("b", execution.getActivityName());
+
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("c", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.task;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskTest extends JbpmTestCase {
+
+  public void testTask() {
+    deployJpdlResource("org/jbpm/examples/task/process.jpdl.xml");
+    
+    Execution execution = executionService.startProcessInstanceByKey("Task");
+    String executionId = execution.getId();
+    
+    List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+    assertEquals(1, taskList.size());
+    Task task = taskList.get(0);
+    assertEquals("review", task.getName());
+    assertEquals("johndoe", task.getAssignee());
+
+    // submit the task
+    taskService.submitTask(task.getDbid());
+    
+    // verify that the task list is now empty
+    taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+    assertEquals(0, taskList.size());
+
+    // verify that process moved to the next state
+    execution = executionService.findExecution(executionId);
+    assertEquals("wait", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+    
+    <process-service />
+    <execution-service />
+    <history-service />
+    <management-service />
+    <task-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration resource="examples-hibernate.cfg.xml">      
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    
+    <script-manager default-expression-language="juel"
+                    default-script-language="juel"
+                    read-contexts="execution, environment, process-engine"
+                    write-context="">
+        <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+    </script-manager>
+    
+    <job-executor auto-start="false" />
+    <job-test-helper />
+
+    <id-generator />
+    <types resource="jbpm.pvm.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <task-db-session />
+    <message-session />
+    <timer-session />
+    <history-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE
+org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/graphbased/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/graphbased/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/concurrency/graphbased/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ConcurrencyGraphBased" xmlns="http://jbpm.org/4/jpdl">
+
+   <start g="16,102,48,48">
+      <transition to="fork"/>
+   </start>
+   
+   <fork name="fork" g="96,102,48,48">
+      <transition to="send invoice" g="120,41:"/>
+      <transition to="load truck"/>
+      <transition to="print shipping documents" g="120,213:"/>
+   </fork>
+   
+   <state name="send invoice" g="176,16,149,52">
+      <transition to="final join" g="606,41:"/>
+   </state>
+   
+   <state name="load truck" g="176,100,149,52">
+      <transition to="shipping join" g="377,126:"/>
+   </state>
+   
+   <state name="print shipping documents" g="176,184,149,58">
+      <transition to="shipping join" g="378,213:"/>
+   </state>
+   
+   <join name="shipping join" g="353,145,48,48">
+      <transition to="drive truck to destination"/>
+   </join>
+   
+   <state name="drive truck to destination" g="431,140,148,52">
+      <transition to="final join" g="607,165:"/>
+   </state>
+   
+   <join name="final join" g="583,73,48,48">
+      <transition to="end"/>
+   </join>
+   
+   <end name="end" g="666,74,48,48"/>
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndMultiple" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,96,48,48">
+    <transition to="get return code" name=""/>
+  </start>
+  
+  <state g="96,94,111,52" name="get return code">
+    <transition g="151,60:-36,11" name="200" to="ok"/>
+    <transition g=":-16,-27" name="400" to="bad request"/>
+    <transition g="151,183:-33,-32" name="500" to="internal server error"/>
+  </state>
+  
+  <end g="238,37,48,48" name="ok"/>
+  <end g="238,98,48,48" name="bad request"/>
+  <end g="240,160,48,48" name="internal server error"/>
+  
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndProcessInstance" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="85,73,80,40">
+    <transition to="end" />
+  </start>
+
+  <end name="end" g="191,73,80,40"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndState" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,96,48,48">
+     <transition to="get return code" name=""/>
+  </start>
+
+  <state g="96,94,110,52" name="get return code">
+    <transition g="150,63:-36,11" name="200" to="ok"/>
+    <transition g=":-16,-27" name="400" to="bad request"/>
+    <transition g="150,177:-33,-32" name="500" to="internal server error"/>
+  </state>
+
+  <end g="239,40,48,48" name="ok" state="completed"/>
+  <end-cancel g="239,97,48,48" name="bad request"/>
+  <end-error g="240,154,48,48" name="internal server error"/>
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/esb/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/esb/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/esb/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Esb" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="32,22,80,40">
+    <transition to="invoke esb service" />
+  </start>
+
+  <esb name="invoke esb service" 
+       category="orderProcessing"
+       service="bookSold"
+       g="128,17,120,54">
+        
+    <part name="bookTitle" expr="#{title}" />
+    <part name="goal">
+      <string value="deliver asap" />
+    </part>
+    
+    <transition to="wait" />
+  </esb>
+  
+  <state name="wait" g="280,16,94,56" />
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveConditions" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,102,48,48">
+    <transition to="evaluate document" />
+  </start>
+  
+  <exclusive name="evaluate document" g="96,102,48,48">
+    <transition to="submit document" g="120,60:">
+      <condition expr="#{content==&quot;good&quot;}" />
+    </transition>
+    <transition to="try again">
+      <condition expr="#{content==&quot;bad&quot;}" />
+    </transition>
+    <transition to="give up" g="120,189:" />
+  </exclusive>
+
+  <state name="submit document" g="175,35,122,52"/>
+  <state name="try again" g="176,100,122,52"/>
+  <state name="give up" g="177,164,122,52"/>
+   
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveExpression" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,102,48,48">
+    <transition to="evaluate document" name=""/>
+  </start>
+
+  <exclusive expr="#{content}" g="96,102,48,48" name="evaluate document">
+    <transition g="120,60:-36,23" name="good" to="submit document"/>
+    <transition g=":-15,-21" name="bad" to="try again"/>
+    <transition g="120,189:-35,-41" name="ugly" to="give up"/>
+  </exclusive>
+
+  <state g="175,35,122,52" name="submit document"/>
+  <state g="176,100,122,52" name="try again"/>
+  <state g="177,164,122,52" name="give up"/>
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveHandler" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,102,48,48">
+    <transition to="evaluate document" name=""/>
+  </start>
+
+  <exclusive g="96,102,48,48" name="evaluate document">
+    <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation"/>
+    <transition g="120,60:-37,22" name="good" to="submit document"/>
+    <transition g=":-19,-22" name="bad" to="try again"/>
+    <transition g="120,189:-33,-39" name="ugly" to="give up"/>
+  </exclusive>
+
+  <state g="175,35,122,52" name="submit document"/>
+  <state g="176,100,122,52" name="try again"/>
+  <state g="177,164,122,52" name="give up"/>
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Hql" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="17,20,48,48">
+    <transition to="get process names" />
+  </start>
+
+  <hql name="get process names"
+       var="activities with o"
+       g="96,16,115,52">
+    <query>
+      select activity.name
+      from org.jbpm.pvm.internal.model.ActivityImpl as activity
+      where activity.name like :activityName
+    </query>
+    <parameters>
+      <string name="activityName" value="%o%" />
+    </parameters>
+    <transition to="count activities" />
+  </hql>
+  
+  <hql name="count activities"
+       var="activities"
+       unique="true"
+       g="243,16,95,52">
+    <query>
+      select count(*)
+      from org.jbpm.pvm.internal.model.ActivityImpl
+    </query>
+    <transition to="wait" />
+  </hql>
+
+  <state name="wait" g="370,18,96,48"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/java/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/java/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/java/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Java" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="20,20,48,48">
+    <transition to="invoke java method" />
+  </start>
+
+  <java name="invoke java method" 
+        class="org.jbpm.examples.java.JohnDoe"
+        method="hello"
+        var="answer"
+        g="96,16,127,52">
+        
+    <field name="state"><string value="fine"/></field>
+    <field name="session"><env type="org.hibernate.Session"/></field>
+
+    <arg><string value="Hi, how are you?"/></arg>
+    
+    <transition to="wait" />
+  </java>
+  
+  <state name="wait" g="255,16,88,52"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/expression/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/expression/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/expression/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ScriptExpression" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="17,19,48,48">
+    <transition to="invoke script" />
+  </start>
+
+  <script name="invoke script" 
+          expr="Send packet to #{person.address}"
+          var="text"
+          g="96,16,104,52">
+
+    <transition to="wait" />
+  </script>
+  
+  <state name="wait" g="232,16,80,52"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/text/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/text/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/script/text/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ScriptText" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,22,80,40">
+    <transition to="invoke script" />
+  </start>
+
+  <script name="invoke script" 
+          var="text"
+          g="113,18,104,52">
+    <text>
+      Send packet to #{person.address}
+    </text>
+
+    <transition to="wait" />
+  </script>
+  
+  <state name="wait" g="266,18,80,52"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/sql/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Sql" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,20,48,48">
+    <transition to="get process names" />
+  </start>
+
+  <sql name="get process names"
+       var="activities with o"
+       g="96,16,126,52">
+    <query>
+      select NAME_
+      from JBPM_ACTIVITY 
+      where NAME_ like :activityName
+    </query>
+    <parameters>
+      <string name="activityName" value="%o%" />
+    </parameters>
+    <transition to="count activities" />
+  </sql>
+  
+  <sql name="count activities"
+       var="activities"
+       unique="true"
+       g="254,16,92,52">
+    <query>
+      select count(*)
+      from JBPM_ACTIVITY
+    </query>
+    <transition to="wait" />
+  </sql>
+
+  <state name="wait" g="378,18,94,48"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
+
+   <start g="16,60,48,48">
+    <transition to="wait for response" name=""/>
+  </start>
+
+  <state g="96,58,109,52" name="wait for response">
+    <transition g="151,41:-48,0" name="accept" to="submit document"/>
+    <transition g="151,125:-47,-17" name="reject" to="try again"/>
+  </state>
+
+  <state g="237,16,114,52" name="submit document"/>
+  <state g="237,100,114,52" name="try again"/>
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/sequence/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/sequence/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/state/sequence/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,18,48,48">
+    <transition to="a" />
+  </start>
+  
+  <state name="a" g="96,16,75,52">
+    <transition to="b" />
+  </state>
+  
+  <state name="b" g="203,16,73,52">
+    <transition to="c" />
+  </state>
+  
+  <state name="c" g="308,16,76,52" />
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/task/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/task/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/org/jbpm/examples/task/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Task" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="20,20,48,48">
+    <transition to="review" />
+  </start>
+
+  <task name="review" 
+        assignee="johndoe"
+        g="96,16,127,52">
+        
+    <transition to="wait" />
+  </task>
+  
+  <state name="wait" g="255,16,88,52"/>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/integration/integration.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/integration.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/integration.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/jboss5/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/jboss5/src/main/resources" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/spi/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/spi/src/main/resources" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="jbpm4-jpdl" />
+    <orderEntry type="module" module-name="jbpm4-pvm" />
+    <orderEntry type="module" module-name="jbpm4-test-base" />
+    <orderEntry type="module" module-name="jbpm4-task" />
+    <orderEntry type="module" module-name="jbpm4-toplevel" />
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: oswego-concurrent:concurrent:jar:1.3.4-jboss-update1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.security:jbosssx:jar:2.0.2.CR6:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/security/jbosssx/2.0.2.CR6/jbosssx-2.0.2.CR6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.security:jboss-security-spi:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/security/jboss-security-spi/2.0.2.CR9/jboss-security-spi-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-dependency:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-kernel:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.security:jbosssx-client:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/security/jbosssx-client/2.0.2.CR9/jbosssx-client-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:jmx-invoker-adaptor-client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-jmx-invoker-adaptor-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system-jmx/5.0.0.GA/jboss-as-system-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.man:jboss-managed:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss.profiler.jvmti:jboss-profiler-jvmti:jar:1.0.0.CR5:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: stax:stax-api:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/stax/stax-api/1.0/stax-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/jbossws/jboss-jaxws/3.0.1-native-2.0.4.GA/jboss-jaxws-3.0.1-native-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.man:jboss-metatype:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jboss-vfs:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javassist:javassist:jar:3.9.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.0.1B:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-servlet-api:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.ws.native:jbossws-native-saaj:jar:3.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/ws/native/jbossws-native-saaj/3.0.3.GA/jbossws-native-saaj-3.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading-vfs:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-bootstrap:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-bootstrap/5.0.0.GA/jboss-as-bootstrap-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jbossxb:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-log4j:jar:2.0.5.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-ejb-api:jar:3.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-ejb-api/3.0.0.CR2/jboss-ejb-api-3.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.remoting:jboss-remoting:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/remoting/jboss-remoting/2.5.0.GA/jboss-remoting-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-aop-mc-int:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-security:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-security/5.0.0.CR2/jboss-as-security-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jms-api:jar:1.1.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-jms-api/1.1.0.CR2/jboss-jms-api-1.1.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.security:jaas:jar:1.0.01:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/security/jaas/1.0.01/jaas-1.0.01.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-j2se:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-j2se/5.0.0.GA/jboss-as-j2se-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.aop:jboss-aop:jar:2.0.0.SP1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.apache.ant:ant-junit:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.test:jboss-test:jar:1.1.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: sun-jaxb:jaxb-api:jar:2.1.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: trove:trove:jar:2.1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/trove/trove/2.1.1/trove-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jpl-pattern:jpl-pattern:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jpl-pattern/jpl-pattern/1.0/jpl-pattern-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jboss-transaction-spi:jar:5.0.0.Beta4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-transaction-spi/5.0.0.Beta4/jboss-transaction-spi-5.0.0.Beta4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: apache-xerces:xml-apis:jar:2.9.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: gnu-getopt:getopt:jar:1.0.13:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-server-manager:jar:1.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: bcel:bcel:jar:5.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jpl-util:jpl-util:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jpl-util/jpl-util/1.0/jpl-util-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.integration:jboss-transaction-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/integration/jboss-transaction-spi/5.0.0.CR2/jboss-transaction-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-deployment:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-deployment/5.0.0.CR2/jboss-as-deployment-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system/5.0.0.GA/jboss-as-system-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-structure-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.apache.ant:ant-launcher:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jboss-reflect:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-reflect/2.0.0.GA/jboss-reflect-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-jmx/5.0.0.GA/jboss-as-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.apache.ant:ant:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/apache/ant/ant/1.7.0/ant-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss:jboss-common-logging-spi:jar:2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss:jboss-mdr:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.integration:jboss-deployment-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/integration/jboss-deployment-spi/5.0.0.CR2/jboss-deployment-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jacc-api:jar:1.1.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.naming:jnp-client:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/naming/jnp-client/5.0.0.CR2/jnp-client-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-mbeans:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-mbeans/5.0.0.GA/jboss-as-mbeans-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-impl:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: wutka-dtdparser:dtdparser121:jar:1.2.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.ejb3:jboss-ejb3-ext-api:jar:0.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/activation/activation/1.1.1/activation-1.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jca-api:jar:1.5.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-jca-api/1.5.0.CR2/jboss-jca-api-1.5.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jad-api:jar:1.2.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-jad-api/1.2.0.CR2/jboss-jad-api-1.2.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.javaee:jboss-transaction-api:jar:1.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloader:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.integration:jboss-classloading-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/integration/jboss-classloading-spi/5.0.0.CR2/jboss-classloading-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxrpc:jar:1.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.ws:jbossws-spi:jar:1.0.6.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.metadata:jboss-metadata:jar:1.0.0.CR11:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: qdox:qdox:jar:1.6.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.jpa:jboss-jpa-deployers:jar:0.1.2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/jpa/jboss-jpa-deployers/0.1.2/jboss-jpa-deployers-0.1.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.integration:jboss-profileservice-spi:jar:5.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javassist:javassist:jar:3.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: stax:stax-api:jar:1.0.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/integration-jboss5.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/integration-jboss5.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/integration-jboss5.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="toplevel" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: oswego-concurrent:concurrent:jar:1.3.4-jboss-update1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jbosssx:jar:2.0.2.CR6:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jbosssx/2.0.2.CR6/jbosssx-2.0.2.CR6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jboss-security-spi:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jboss-security-spi/2.0.2.CR9/jboss-security-spi-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-dependency:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-kernel:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jbosssx-client:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jbosssx-client/2.0.2.CR9/jbosssx-client-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:jmx-invoker-adaptor-client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-jmx-invoker-adaptor-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system-jmx/5.0.0.GA/jboss-as-system-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.man:jboss-managed:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.profiler.jvmti:jboss-profiler-jvmti:jar:1.0.0.CR5:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax-api:jar:1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/stax/stax-api/1.0/stax-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossws/jboss-jaxws/3.0.1-native-2.0.4.GA/jboss-jaxws-3.0.1-native-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.man:jboss-metatype:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-vfs:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-servlet-api:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ws.native:jbossws-native-saaj:jar:3.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/native/jbossws-native-saaj/3.0.3.GA/jbossws-native-saaj-3.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading-vfs:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-bootstrap:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-bootstrap/5.0.0.GA/jboss-as-bootstrap-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jbossxb:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-log4j:jar:2.0.5.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-ejb-api:jar:3.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-ejb-api/3.0.0.CR2/jboss-ejb-api-3.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.remoting:jboss-remoting:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/remoting/jboss-remoting/2.5.0.GA/jboss-remoting-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-aop-mc-int:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jms-api:jar:1.1.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jms-api/1.1.0.CR2/jboss-jms-api-1.1.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-security:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-security/5.0.0.CR2/jboss-as-security-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.security:jaas:jar:1.0.01:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/security/jaas/1.0.01/jaas-1.0.01.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.aop:jboss-aop:jar:2.0.0.SP1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-j2se:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-j2se/5.0.0.GA/jboss-as-j2se-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant-junit:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.test:jboss-test:jar:1.1.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: trove:trove:jar:2.1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/trove/trove/2.1.1/trove-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: sun-jaxb:jaxb-api:jar:2.1.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jpl-pattern:jpl-pattern:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jpl-pattern/jpl-pattern/1.0/jpl-pattern-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-transaction-spi:jar:5.0.0.Beta4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-transaction-spi/5.0.0.Beta4/jboss-transaction-spi-5.0.0.Beta4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: apache-xerces:xml-apis:jar:2.9.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: gnu-getopt:getopt:jar:1.0.13:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-server-manager:jar:1.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: bcel:bcel:jar:5.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jpl-util:jpl-util:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jpl-util/jpl-util/1.0/jpl-util-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-transaction-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-transaction-spi/5.0.0.CR2/jboss-transaction-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-deployment:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-deployment/5.0.0.CR2/jboss-as-deployment-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system/5.0.0.GA/jboss-as-system-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-structure-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant-launcher:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-reflect:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-reflect/2.0.0.GA/jboss-reflect-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-jmx/5.0.0.GA/jboss-as-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant/1.7.0/ant-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-common-logging-spi:jar:2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-mdr:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-deployment-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-deployment-spi/5.0.0.CR2/jboss-deployment-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jacc-api:jar:1.1.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.naming:jnp-client:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/naming/jnp-client/5.0.0.CR2/jnp-client-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-mbeans:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-mbeans/5.0.0.GA/jboss-as-mbeans-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ejb3:jboss-ejb3-ext-api:jar:0.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: wutka-dtdparser:dtdparser121:jar:1.2.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-impl:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jca-api:jar:1.5.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jca-api/1.5.0.CR2/jboss-jca-api-1.5.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jad-api:jar:1.2.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jad-api/1.2.0.CR2/jboss-jad-api-1.2.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-transaction-api:jar:1.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloader:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-classloading-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-classloading-spi/5.0.0.CR2/jboss-classloading-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ws:jbossws-spi:jar:1.0.6.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxrpc:jar:1.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.metadata:jboss-metadata:jar:1.0.0.CR11:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: qdox:qdox:jar:1.6.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jpa:jboss-jpa-deployers:jar:0.1.2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jpa/jboss-jpa-deployers/0.1.2/jboss-jpa-deployers-0.1.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-profileservice-spi:jar:5.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.9.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/activation/activation/1.1.1/activation-1.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+  <name>jBPM 4 - Integration JBoss 5</name>
+  <description>JBoss jBPM - JBoss JBoss 5</description>
+
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-jboss5</artifactId>
+  <packaging>jar</packaging>
+
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm-integration</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+  </parent>
+
+  <!-- Properties -->
+  <properties>
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-spi</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-system-jmx</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- Build -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>${project.build.finalName}</finalName>
+              <appendAssemblyId>true</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-config.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>META-INF/jbpm-service-jboss-beans.xml</exclude>
+            <exclude>META-INF/jbpm-deployers-jboss-beans.xml</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/scripts/assembly-config.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/scripts/assembly-config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/scripts/assembly-config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+  <id>config</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.outputDirectory}</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>**/*beans.xml</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.jboss5;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+import org.jbpm.integration.spi.JBPMService;
+import org.jbpm.integration.util.KernelAwareSPIFactory;
+
+/**
+ * Deploys JBPM processes and associates a classloader.
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPMDeployer extends AbstractSimpleVFSRealDeployer<JBPMDeploymentMetaData>
+{
+
+  public JBPMDeployer()
+  {
+    super(JBPMDeploymentMetaData.class);
+  }
+
+  public void deploy(VFSDeploymentUnit unit, JBPMDeploymentMetaData deployment)
+      throws DeploymentException
+  {
+    System.out.println("*** JBPM : Working on " + deployment);
+
+    JBPMService jbpmService = new KernelAwareSPIFactory().getKernelProvidedSPI(
+        "org.jbpm:service=ProcessEngine", JBPMService.class
+    );
+
+    System.out.println("*** JBPM Service: " + jbpmService);
+  }
+
+  public void undeploy(DeploymentUnit unit, JBPMDeploymentMetaData deployment)
+  {
+    System.out.println("*** JBPM : Undeploy "+deployment);
+    
+    super.undeploy(unit, deployment);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeploymentMetaData.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeploymentMetaData.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMDeploymentMetaData.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.jboss5;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPMDeploymentMetaData
+{
+}

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMMetaDataDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMMetaDataDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMMetaDataDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.jboss5;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Prepares {@link org.jbpm.integration.jboss5.JBPMDeploymentMetaData}
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPMMetaDataDeployer extends AbstractVFSParsingDeployer<JBPMDeploymentMetaData>
+{
+
+  public JBPMMetaDataDeployer()
+  {
+    super(JBPMDeploymentMetaData.class);
+  }
+
+  protected JBPMDeploymentMetaData parse(VFSDeploymentUnit unit, VirtualFile file, JBPMDeploymentMetaData root) throws Exception
+  {
+    System.out.println("*** JBPM: Creating structure from " + file);
+
+    // TODO: implement parsing logic
+    
+    return new JBPMDeploymentMetaData();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.jboss5;
+
+import org.jbpm.integration.spi.JBPMService;
+import org.jbpm.ProcessEngine;
+import org.jbpm.Configuration;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JBPMServiceImpl implements JBPMService
+{
+  private ProcessEngine processEngine;
+
+  public void start()
+  {
+    this.processEngine = new Configuration().buildProcessEngine();
+    System.out.println("** JBPMService started: " + this.processEngine);
+  }
+
+  public void stop()
+  {
+    this.processEngine = null;
+    System.out.println("** JBPMService stopped");
+  }
+
+  public ProcessEngine getProcessEngine()
+  {
+    return this.processEngine;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-deployers-jboss-beans.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-deployers-jboss-beans.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-deployers-jboss-beans.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!--
+    Locate the single instance of the kernel
+    -->
+  <bean name="org.jbpm:service=KernelLocator" class="org.jbpm.integration.util.KernelLocator">
+    <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
+  </bean>
+
+  <!--
+    The JBPM Meta Data Deployer
+    -->
+  <bean name="org.jbpm:service=MetaDataDeployer" class="org.jbpm.integration.jboss5.JBPMMetaDataDeployer">
+    <property name="suffix">jpdl.xml</property>
+    <property name="jarExtension">par</property>
+    <property name="allowMultipleFiles">true</property>
+
+    <!-- files the deployer can process -->
+    <!--property name="names">
+      <set elementClass="java.lang.String">
+        <value>processdefinition.xml</value>
+      </set>
+    </property-->
+  </bean>
+
+  <!--
+    The actual jBPM Deployer
+    -->
+  <bean name="org.jbpm:service=Deployer" class="org.jbpm.integration.jboss5.JBPMDeployer"/>
+  
+</deployment>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-service-jboss-beans.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-service-jboss-beans.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/jboss5/src/main/resources/META-INF/jbpm-service-jboss-beans.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+  
+  <!--
+     JBPM Service
+  -->
+  <bean name="org.jbpm:service=ProcessEngine" class="org.jbpm.integration.jboss5.JBPMServiceImpl"/>
+</deployment>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/integration/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+  <name>jBPM 4 - Integration</name>
+  <description>JBoss jBPM - Integration</description>
+
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-integration</artifactId>
+  <packaging>pom</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <properties>
+    <jboss.deployers.version>2.0.3.GA</jboss.deployers.version>
+    <jboss.metadata.version>1.0.0.CR11</jboss.metadata.version>
+    <jboss.microcontainer.version>2.0.2.GA</jboss.microcontainer.version>
+    <jboss.jacc.version>1.1.0.GA</jboss.jacc.version>
+    <jbossas.version>5.0.0.GA</jbossas.version>
+    <junit.version>3.8.1</junit.version>
+    <log4j.version>1.2.14</log4j.version>
+  </properties>
+
+  <!-- Dependecy Management -->
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-jpdl</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>${junit.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.javaee</groupId>
+        <artifactId>jboss-jacc-api</artifactId>
+        <version>${jboss.jacc.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.jbossas</groupId>
+        <artifactId>jboss-as-server</artifactId>
+        <version>${jbossas.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.jbossas</groupId>
+        <artifactId>jboss-as-system-jmx</artifactId>
+        <version>${jbossas.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.jbossas</groupId>
+        <artifactId>jboss-as-client</artifactId>
+        <version>${jbossas.version}</version>
+        <type>pom</type>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-client</artifactId>
+        <version>${jboss.deployers.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-client-spi</artifactId>
+        <version>${jboss.deployers.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-spi</artifactId>
+        <version>${jboss.deployers.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-structure-spi</artifactId>
+        <version>${jboss.deployers.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs-spi</artifactId>
+        <version>${jboss.deployers.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.metadata</groupId>
+        <artifactId>jboss-metadata</artifactId>
+        <version>${jboss.metadata.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-kernel</artifactId>
+        <version>${jboss.microcontainer.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
+  <modules>
+    <module>spi</module>
+    <module>jboss5</module>
+  </modules>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/integration/spi/integration-spi.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/spi/integration-spi.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/spi/integration-spi.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="toplevel" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax-api:jar:1.0.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/transaction/jta/1.1/jta-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: oswego-concurrent:concurrent:jar:1.3.4-jboss-update1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jbosssx:jar:2.0.2.CR6:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jbosssx/2.0.2.CR6/jbosssx-2.0.2.CR6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jboss-security-spi:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jboss-security-spi/2.0.2.CR9/jboss-security-spi-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-dependency:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.2.GA/jboss-dependency-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-kernel:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.2.GA/jboss-kernel-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.security:jbosssx-client:jar:2.0.2.CR9:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/security/jbosssx-client/2.0.2.CR9/jbosssx-client-2.0.2.CR9.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:jmx-invoker-adaptor-client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-jmx-invoker-adaptor-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system-jmx/5.0.0.GA/jboss-as-system-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.man:jboss-managed:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-managed/2.0.0.GA/jboss-managed-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-spi/2.0.3.GA/jboss-deployers-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client/2.0.3.GA/jboss-deployers-client-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.profiler.jvmti:jboss-profiler-jvmti:jar:1.0.0.CR5:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossws/jboss-jaxws/3.0.1-native-2.0.4.GA/jboss-jaxws-3.0.1-native-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-server:jar:client:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-server/5.0.0.CR2/jboss-as-server-5.0.0.CR2-client.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.man:jboss-metatype:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/man/jboss-metatype/2.0.0.GA/jboss-metatype-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-vfs:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-vfs/2.0.0.GA/jboss-vfs-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.9.0.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-servlet-api:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-servlet-api/2.5.0.GA/jboss-servlet-api-2.5.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ws.native:jbossws-native-saaj:jar:3.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/native/jbossws-native-saaj/3.0.3.GA/jbossws-native-saaj-3.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading-vfs:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading-vfs/2.0.1.GA/jboss-classloading-vfs-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-bootstrap:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-bootstrap/5.0.0.GA/jboss-as-bootstrap-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs/2.0.3.GA/jboss-deployers-vfs-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jbossxb:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-log4j:jar:2.0.5.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core/2.0.3.GA/jboss-deployers-core-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-ejb-api:jar:3.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-ejb-api/3.0.0.CR2/jboss-ejb-api-3.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.remoting:jboss-remoting:jar:2.5.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/remoting/jboss-remoting/2.5.0.GA/jboss-remoting-2.5.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.microcontainer:jboss-aop-mc-int:jar:2.0.2.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/microcontainer/jboss-aop-mc-int/2.0.2.GA/jboss-aop-mc-int-2.0.2.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jms-api:jar:1.1.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jms-api/1.1.0.CR2/jboss-jms-api-1.1.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-security:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-security/5.0.0.CR2/jboss-as-security-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.security:jaas:jar:1.0.01:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/security/jaas/1.0.01/jaas-1.0.01.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-j2se:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-j2se/5.0.0.GA/jboss-as-j2se-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.aop:jboss-aop:jar:2.0.0.SP1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/aop/jboss-aop/2.0.0.SP1/jboss-aop-2.0.0.SP1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant-junit:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.test:jboss-test:jar:1.1.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/test/jboss-test/1.1.3.GA/jboss-test-1.1.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: sun-jaxb:jaxb-api:jar:2.1.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: trove:trove:jar:2.1.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/trove/trove/2.1.1/trove-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jpl-pattern:jpl-pattern:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jpl-pattern/jpl-pattern/1.0/jpl-pattern-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-transaction-spi:jar:5.0.0.Beta4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-transaction-spi/5.0.0.Beta4/jboss-transaction-spi-5.0.0.Beta4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-client-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-client-spi/2.0.3.GA/jboss-deployers-client-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: apache-xerces:xml-apis:jar:2.9.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: gnu-getopt:getopt:jar:1.0.13:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-server-manager:jar:1.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-server-manager/1.0.0.GA/jboss-server-manager-1.0.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-vfs-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.3.GA/jboss-deployers-vfs-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-transaction-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-transaction-spi/5.0.0.CR2/jboss-transaction-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jpl-util:jpl-util:jar:1.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jpl-util/jpl-util/1.0/jpl-util-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: bcel:bcel:jar:5.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/bcel/bcel/5.1/bcel-5.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-deployment:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-deployment/5.0.0.CR2/jboss-as-deployment-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-system:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-system/5.0.0.GA/jboss-as-system-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-structure-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-structure-spi/2.0.3.GA/jboss-deployers-structure-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-reflect:jar:2.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-reflect/2.0.0.GA/jboss-reflect-2.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant-launcher:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-common-logging-spi:jar:2.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.apache.ant:ant:jar:1.7.0:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/apache/ant/ant/1.7.0/ant-1.7.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-jmx:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-jmx/5.0.0.GA/jboss-as-jmx-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-mdr:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-deployment-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-deployment-spi/5.0.0.CR2/jboss-deployment-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jacc-api:jar:1.1.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jacc-api/1.1.0.GA/jboss-jacc-api-1.1.0.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloading:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloading/2.0.1.GA/jboss-classloading-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.naming:jnp-client:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/naming/jnp-client/5.0.0.CR2/jnp-client-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jbossas:jboss-as-mbeans:jar:5.0.0.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jbossas/jboss-as-mbeans/5.0.0.GA/jboss-as-mbeans-5.0.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-impl:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-impl/2.0.3.GA/jboss-deployers-impl-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: wutka-dtdparser:dtdparser121:jar:1.2.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ejb3:jboss-ejb3-ext-api:jar:0.4:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/javax/activation/activation/1.1.1/activation-1.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jca-api:jar:1.5.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jca-api/1.5.0.CR2/jboss-jca-api-1.5.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.deployers:jboss-deployers-core-spi:jar:2.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/deployers/jboss-deployers-core-spi/2.0.3.GA/jboss-deployers-core-spi-2.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-jad-api:jar:1.2.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-jad-api/1.2.0.CR2/jboss-jad-api-1.2.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.javaee:jboss-transaction-api:jar:1.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cl:jboss-classloader:jar:2.0.1.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/cl/jboss-classloader/2.0.1.GA/jboss-classloader-2.0.1.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-classloading-spi:jar:5.0.0.CR2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-classloading-spi/5.0.0.CR2/jboss-classloading-spi-5.0.0.CR2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossws:jboss-jaxrpc:jar:1.0.4.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.ws:jbossws-spi:jar:1.0.6.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.metadata:jboss-metadata:jar:1.0.0.CR11:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/metadata/jboss-metadata/1.0.0.CR11/jboss-metadata-1.0.0.CR11-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.9.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.9.GA/jboss-common-core-2.2.9.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: qdox:qdox:jar:1.6.1:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.jpa:jboss-jpa-deployers:jar:0.1.2:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/jpa/jboss-jpa-deployers/0.1.2/jboss-jpa-deployers-0.1.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.integration:jboss-profileservice-spi:jar:5.0.3.GA:provided">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../../.m2/repository/org/jboss/integration/jboss-profileservice-spi/5.0.3.GA/jboss-profileservice-spi-5.0.3.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/integration/spi/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/spi/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/spi/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+  <name>jBPM 4 - Integration SPI</name>
+  <description>JBoss jBPM - Integration SPI</description>
+
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-spi</artifactId>
+  <packaging>jar</packaging>
+
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm-integration</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+  </parent>
+
+  <!-- Properties -->
+  <properties>
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>      
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-system-jmx</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- Build -->
+  <build>
+    <plugins>
+      <!--plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>${project.build.finalName}</finalName>
+              <appendAssemblyId>true</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-config.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin-->
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>*beans.xml</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/spi/JBPMService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/spi/JBPMService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/spi/JBPMService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.spi;
+
+import org.jbpm.ProcessEngine;
+
+/**
+ * A JBPM service implementation
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface JBPMService
+{
+  void start();
+  void stop();
+  
+  ProcessEngine getProcessEngine();
+}

Added: jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelAwareSPIFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelAwareSPIFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelAwareSPIFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.util;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+
+/**
+ * SPI factory delegating to kernel for bean lookups
+ * 
+ * @author richard.opalka at jboss.com
+ * @author Heiko.Braun at jboss.com
+ */
+public class KernelAwareSPIFactory
+{
+   @SuppressWarnings("unchecked")
+   public <T> T getKernelProvidedSPI(String beanName, Class<T> spiArtifact)
+   {
+      KernelController controller = KernelLocator.getKernel().getController();
+      ControllerContext ctx = controller.getInstalledContext(beanName);
+      return (T)ctx.getTarget();
+   }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelLocator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelLocator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/integration/spi/src/main/java/org/jbpm/integration/util/KernelLocator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.util;
+
+//$Id$
+
+import org.jboss.kernel.Kernel;
+
+/**
+ * Locate the single instance of the kernel
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-May-2006
+ */
+public class KernelLocator
+{
+  private static Kernel kernel;
+
+  public static Kernel getKernel()
+  {
+    return KernelLocator.kernel;
+  }
+
+  public void setKernel(Kernel kernel)
+  {
+    KernelLocator.kernel = kernel;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/jpdl/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jpdl</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/jpdl/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 1790 2008-07-31 12:13:06Z tom.baeyens at jboss.com $ -->
+
+<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>
+
+  <name>jBPM 4 - jPDL</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-jpdl</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Properties -->
+  <properties>
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+
+    <!-- JBPM4 -->
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+    <!-- 3rd Party -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+      <artifactId>jbossesb-rosetta</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>stax</groupId>
+          <artifactId>stax-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>stax</groupId>
+          <artifactId>stax</artifactId>
+        </exclusion>
+      </exclusions>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>hibernate.*</exclude>
+            <exclude>jbpm.cfg.xml</exclude>
+            <exclude>jbpm-*-ds.xml</exclude>
+            <exclude>db.properties/**</exclude>
+            <exclude>logging.properties</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <!--execution>
+            <id>ant-copy-resources</id>
+            <phase>process-classes</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="build.path.system" value="${project.build.directory}" />
+                <property name="from.dir" value="src/main/resources" />
+                <property name="to.dir" value="target/classes"/>
+                <ant antfile="scripts/antrun-patch-hsql-properties.xml" target="patch" />
+              </tasks>
+            </configuration>
+          </execution-->
+          <execution>
+            <phase>compile</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+
+                <!-- Patch the Hsql DB Url to make it portable -->
+                <property name="build.path.system" value="${project.build.directory}" />
+                <property name="from.dir" value="${basedir}/src/main/resources" />
+                <property name="to.dir" value="${project.build.directory}/classes"/>
+                <ant antfile="scripts/antrun-patch-hsql-properties.xml" target="patch" />
+
+                <echo>============================</echo>
+                <echo>Database config: ${database}</echo>
+                <echo>============================</echo>
+                <property name="database" value="${database}" />
+                <property name="build.path.system" value="${project.build.directory}" />
+                <ant antfile="scripts/antrun-jbpm-config.xml" target="concat" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <!-- https://jira.jboss.org/jira/browse/JBPM-1759 -->
+            <exclude>org/jbpm/jpdl/controlflow/DecisionExpressionTest.java</exclude>
+            <exclude>org/jbpm/jpdl/controlflow/DecisionHandlerTest.java</exclude>
+            <exclude>org/jbpm/jpdl/parsing/JpdlSchemaTest.java</exclude>
+            <exclude>org/jbpm/jpdl/parsing/ProcessParsingTest.java</exclude>
+            <exclude>org/jbpm/jpdl/parsing/TransitionParsingTest.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>${project.build.finalName}</finalName>
+              <appendAssemblyId>true</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-config.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <!-- Profiles -->
+  <profiles>
+    <profile>
+      <id>distro</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>false</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+  </profiles>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-jbpm-config.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-jbpm-config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-jbpm-config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: antrun-jbpm-config.xml 3602 2009-01-08 04:27:48Z alex.guizar at jboss.com $ -->
+
+<project default="concat">
+
+  <property name="project.build.directory" value="${basedir}/target"/>
+  <property name="build.resources.directory" value="${basedir}/target/classes"/>
+
+  <macrodef name="macro-disable">
+    <attribute name="file" />
+    <attribute name="section" />
+    <sequential>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) -->]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) ===]]></replacevalue>
+      </replace>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (end) -->]]></replacetoken>
+        <replacevalue><![CDATA[==== ]]>@{section}<![CDATA[ (end) -->]]></replacevalue>
+      </replace>
+    </sequential>
+  </macrodef>
+
+  <macrodef name="macro-enable">
+    <attribute name="file" />
+    <attribute name="section" />
+    <sequential>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) ===]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (begin) -->]]></replacevalue>
+      </replace>
+      <replace file="@{file}" summary="true">
+        <replacetoken><![CDATA[==== ]]>@{section}<![CDATA[ (end) -->]]></replacetoken>
+        <replacevalue><![CDATA[<!-- ]]>@{section}<![CDATA[ (end) -->]]></replacevalue>
+      </replace>
+    </sequential>
+  </macrodef>
+
+  <macrodef name="macro-database-cfg">
+    <attribute name="database" />
+    <sequential>
+
+      <available property="@{database}.properties.available" file="${build.resources.directory}/hibernate.properties.@{database}.xml"/>
+      <fail message="hibernate.properties.@{database}.xml not available" unless="@{database}.properties.available"/>
+
+      <echo message="Concat hibernate.cfg.@{database}.xml using hibernate.properties.@{database}.xml, hibernate.mapping.@{database}.xml" />
+
+      <!-- Concat hibernate.cfg.xml -->
+      <concat destfile="${project.build.directory}/classes/hibernate.cfg.@{database}.xml">
+        <header><![CDATA[<?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>
+]]></header>
+        <fileset file="${build.resources.directory}/hibernate.properties.@{database}.xml" />
+        <fileset file="${build.resources.directory}/hibernate.common.xml" />
+        <fileset file="${build.resources.directory}/hibernate.mapping.@{database}.xml" />
+      	<fileset file="${build.resources.directory}/hibernate.mapping.default.xml" />
+        <fileset file="${build.resources.directory}/hibernate.cache.xml" />
+        <footer><![CDATA[  </session-factory>
+</hibernate-configuration>]]></footer>
+      </concat>
+    </sequential>
+  </macrodef>
+
+  <target name="concat" >
+    <macro-database-cfg database="db2" />
+    <macro-database-cfg database="derby" />
+    <macro-database-cfg database="firebird" />
+    <macro-database-cfg database="hsqldb"/>
+    <macro-database-cfg database="ingres" />
+    <macro-database-cfg database="interbase" />
+    <macro-database-cfg database="mckoi" />
+    <macro-database-cfg database="mssql" />
+    <macro-database-cfg database="mysql"/>
+    <macro-database-cfg database="postgresql"/>
+    <macro-database-cfg database="sapdb" />
+    <macro-database-cfg database="sybase"/>
+    <macro-database-cfg database="oracle" />
+    <macro-database-cfg database="postgresql" />
+
+    <echo message="Default configuration: Copy hibernate.cfg.${database}.xml to hibernate.cfg.xml" />
+    <copy file="${project.build.directory}/classes/hibernate.cfg.${database}.xml" tofile="${project.build.directory}/classes/hibernate.cfg.xml"/>
+
+  	<loadfile property="hibernate.properties.xml" srcFile="${build.resources.directory}/hibernate.properties.${database}.xml"/>
+    <echo message="${hibernate.properties.xml}"/>
+    <echo/>
+
+  </target>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-patch-hsql-properties.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-patch-hsql-properties.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/scripts/antrun-patch-hsql-properties.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: antrun-jbpm-config.xml 3602 2009-01-08 04:27:48Z alex.guizar at jboss.com $ -->
+
+<project>
+
+  <path id="build.path">
+    <pathelement location="${build.path.system}"/>
+  </path>
+
+  <target name="patch">
+
+    <pathconvert targetos="unix" property="build.path.unix" refid="build.path"/>
+    <echo>DEBUG: Build path: ${build.path.unix} </echo>
+
+    <mkdir dir="${to.dir}"/>
+
+    <copy todir="${to.dir}" filtering="true" verbose="true" overwrite="true">
+      <filterset>
+        <filter token="project.build.directory" value="${build.path.unix}"/>
+      </filterset>
+      <fileset dir="${from.dir}">
+        <include name="**/hibernate.properties.hsqldb.xml"/>
+      </fileset>
+    </copy>
+
+  </target>
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/scripts/assembly-config.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/scripts/assembly-config.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/scripts/assembly-config.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+  <id>config</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.outputDirectory}</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>jbpm.cfg.xml</include>
+        <include>logging.properties</include>
+        <include>hibernate.cfg.xml</include>
+        <include>hibernate.cfg.*.xml</include>
+        <include>jbpm-*-ds.xml</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${project.build.directory}</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>hypersonic/jbpm4DB.log</include>
+        <include>hypersonic/jbpm4DB.properties</include>
+        <include>hypersonic/jbpm4DB.script</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/scripts/build-jars-jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/scripts/build-jars-jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/scripts/build-jars-jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: build-jars-jpdl.xml 1466 2008-07-02 14:29:43Z heiko.braun at jboss.com $ -->
+
+<project>
+
+   <description>jPDL test archive</description>
+
+   <target name="build-jars-jpdl" description="Build the deployments.">
+
+      <echo>
+         * Build jPDL test artifacts
+         * Location: ${tests.output.dir}/test-libs
+         * Resources: ${tests.resources.dir}
+      </echo>
+      
+      <mkdir dir="${tests.output.dir}/test-libs"/>
+
+      <!-- enterprise tests -->
+      <!--war warfile="${tests.output.dir}/test-libs/pvm-test-enterprise-war.war"
+           webxml="${tests.resources.dir}/enterprise/WEB-INF/web.xml">
+         <webinf dir="${tests.resources.dir}/enterprise/WEB-INF">
+            <include name="jboss-web.xml"/>
+         </webinf>
+      </war>
+
+      <jar jarfile="${tests.output.dir}/test-libs/pvm-test-enterprise-ejb.jar">
+         <metainf dir="${tests.resources.dir}/enterprise/META-INF">
+            <include name="ejb-jar.xml"/>
+            <include name="jboss.xml"/>
+            <include name="jboss-cmp-jdbc.xml"/>
+         </metainf>         
+      </jar>
+
+      <ear destfile="${tests.output.dir}/test-libs/pvm-test-enterprise.ear"
+           appxml="${tests.resources.dir}/enterprise/META-INF/application.xml">
+         <fileset dir="${tests.output.dir}/test-libs">
+            <include name="pvm-test-enterprise-ejb.jar"/>
+            <include name="pvm-test-enterprise-war.war"/>
+         </fileset>
+      </ear-->
+
+      <!-- Please add alphabetically -->
+
+   </target>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/scripts/build.schema.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/scripts/build.schema.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/scripts/build.schema.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: antrun-jbpmschema.xml 2999 2008-11-19 16:16:01Z thomas.diesler at jboss.com $ -->
+
+<project>
+
+  <!-- ================================================================== -->
+  <!-- jBPM Database schema                                               -->
+  <!-- ================================================================== -->
+
+  <target name="create-schema">
+    <echo message="${maven.runtime.classpath}"/>
+      
+    <taskdef name="schemaexport"
+        classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
+      <classpath path="${maven.runtime.classpath}"/>
+    </taskdef>
+    
+    <property name="cfg" value="target/classes/hibernate.cfg.xml" />
+
+    <mkdir dir="target/classes/create"/>
+    <mkdir dir="target/classes/drop"/>
+
+    <schemaexport properties="target/classes/db.properties/hsqldb.properties"
+                  output="target/classes/create/jbpm.hsqldb.create.sql" 
+                  create="yes" drop="no" config="${cfg}" text="yes" />
+    <schemaexport properties="target/classes/db.properties/hsqldb.properties"
+                  output="target/classes/drop/jbpm.hsqldb.drop.sql" 
+                  create="no" drop="yes" config="${cfg}" text="yes" />
+
+    <schemaexport properties="target/classes/db.properties/mysql.properties"
+                  output="target/classes/create/jbpm.mysql.create.sql"
+    	            delimiter=";"
+                  create="yes" drop="no" config="${cfg}" text="yes" />
+    <schemaexport properties="target/classes/db.properties/mysql.properties"
+                  output="target/classes/drop/jbpm.mysql.drop.sql" 
+                  delimiter=";"
+                  create="no" drop="yes" config="${cfg}" text="yes" />
+
+    <schemaexport properties="target/classes/db.properties/oracle.properties"
+                  output="target/classes/create/jbpm.oracle.create.sql" 
+                  create="yes" drop="no" config="${cfg}" text="yes" 
+                  delimiter=";" />
+    <schemaexport properties="target/classes/db.properties/oracle.properties"
+                  output="target/classes/drop/jbpm.oracle.drop.sql" 
+                  create="no" drop="yes" config="${cfg}" text="yes" 
+                  delimiter=";" />
+
+    <schemaexport properties="target/classes/db.properties/postgresql.properties"
+                  output="target/classes/create/jbpm.postgresql.create.sql" 
+                  create="yes" drop="no" config="${cfg}" text="yes" />
+    <schemaexport properties="target/classes/db.properties/postgresql.properties"
+                  output="target/classes/drop/jbpm.postgresql.drop.sql" 
+                  create="no" drop="yes" config="${cfg}" text="yes" />
+
+    <schemaexport properties="target/classes/db.properties/sybase.properties"
+                  output="target/classes/create/jbpm.sybase.create.sql" 
+                  create="yes" drop="no" config="${cfg}" text="yes" />
+    <schemaexport properties="target/classes/db.properties/sybase.properties"
+                  output="target/classes/drop/jbpm.sybase.drop.sql" 
+                  create="no" drop="yes" config="${cfg}" text="yes" />
+
+  </target>
+  
+</project>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.OpenExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected boolean endProcessInstance = true;
+  protected String state = null;
+
+  public void execute(ActivityExecution execution) {
+    OpenExecution executionToEnd = null;
+    if (endProcessInstance) {
+      executionToEnd = execution.getProcessInstance();
+    } else {
+      executionToEnd = execution;
+    }
+    
+    if (state==null) {
+      execution.end(executionToEnd);
+    } else {
+      execution.end(executionToEnd, state);
+    }
+  }
+  
+  public void setEndProcessInstance(boolean endProcessInstance) {
+    this.endProcessInstance = endProcessInstance;
+  }
+  public void setState(String state) {
+    this.state = state;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndBinding extends JpdlActivityBinding {
+
+  public EndBinding() {
+    super("end");
+  }
+
+  protected EndBinding(String tag) {
+    super(tag);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    
+    boolean endProcessInstance = true;
+    String ends = XmlUtil.attribute(element, "ends", false, parse);
+    if ("execution".equalsIgnoreCase(ends)) {
+      endProcessInstance = false;
+    }
+    
+    String state = XmlUtil.attribute(element, "state", false, parse);
+    
+    EndActivity endActivity = new EndActivity();
+    endActivity.setEndProcessInstance(endProcessInstance);
+    endActivity.setState(state);
+    
+    return endActivity;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndCancelBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndCancelBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndCancelBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndCancelBinding extends EndBinding {
+
+  public EndCancelBinding() {
+    super("end-cancel");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EndActivity endActivity = (EndActivity) super.parse(element, parse, parser);
+    endActivity.setState("cancel");
+    return endActivity;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndErrorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndErrorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EndErrorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndErrorBinding extends EndBinding {
+
+  public EndErrorBinding() {
+    super("end-error");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EndActivity endActivity = (EndActivity) super.parse(element, parse, parser);
+    endActivity.setState("error");
+    return endActivity;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExpressionEvaluator;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EsbActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static Log log = Log.getLog(EsbActivity.class.getName());
+
+  protected String category = null;
+  protected String service = null;
+  protected ListDescriptor partsListDescriptor = null;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    Message message = MessageFactory.getInstance().getMessage();
+    Body body = message.getBody();
+    
+    if (partsListDescriptor!=null) {
+      WireContext wireContext = new WireContext();
+      for (Descriptor descriptor: partsListDescriptor.getValueDescriptors()) {
+        String name = descriptor.getName();
+        
+        Object object = wireContext.create(descriptor, true);
+        if (object instanceof ExpressionEvaluator) {
+          ExpressionEvaluator expressionEvaluator = (ExpressionEvaluator) object;
+          object = expressionEvaluator.evaluateExpression(execution);
+        }
+        body.add(name, object);
+      }
+    }
+    
+    ServiceInvoker invoker = new ServiceInvoker(category, service);
+    log.debug("sending "+message.getBody()+" to service "+service+" in category "+category+" over the esb");
+    invoker.deliverAsync(message);
+  }
+
+  public void setCategory(String category) {
+    this.category = category;
+  }
+  public void setService(String service) {
+    this.service = service;
+  }
+  public void setPartsListDescriptor(ListDescriptor partsListDescriptor) {
+    this.partsListDescriptor = partsListDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EsbBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ExpressionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EsbBinding extends JpdlActivityBinding {
+
+  public static final String TAG = "esb";
+  private static final WireParser wireParser = WireParser.getInstance(); 
+
+  public EsbBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EsbActivity esbActivity = new EsbActivity();
+    
+    String category = XmlUtil.attribute(element, "category", true, parse);
+    esbActivity.setCategory(category);
+    
+    String service = XmlUtil.attribute(element, "service", true, parse);
+    esbActivity.setService(service);
+    
+    List<Descriptor> partDescriptors = new ArrayList<Descriptor>();
+    List<Element> partElements = XmlUtil.elements(element, "part");
+    for (Element partElement: partElements) {
+      String name = XmlUtil.attribute(partElement, "name", true, parse);
+      AbstractDescriptor partDescriptor = getPartDescriptor(partElement, parse);
+      partDescriptor.setName(name);
+      partDescriptors.add(partDescriptor);
+    }
+    ListDescriptor partsListDescriptor = new ListDescriptor();
+    if (!partDescriptors.isEmpty()) {
+      partsListDescriptor.setValueDescriptors(partDescriptors);
+    }
+    esbActivity.setPartsListDescriptor(partsListDescriptor);
+
+    return esbActivity;
+  }
+
+  public AbstractDescriptor getPartDescriptor(Element partElement, Parse parse) {
+    String expression = XmlUtil.attribute(partElement, "expr");
+    Element descriptorElement = XmlUtil.element(partElement);
+    
+    if ( ( (expression==null) && (descriptorElement==null) ) 
+         || 
+         ( (expression!=null) && (descriptorElement!=null) )
+       ) {
+      parse.addProblem("in <"+TAG+"...> an expr or exactly one child element is expected");
+    }
+
+    if (expression!=null) {
+      return new ExpressionDescriptor(expression, null);
+    }
+
+    AbstractDescriptor descriptor = (AbstractDescriptor) wireParser.parseElement(descriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ExpressionEvaluator;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.pvm.internal.wire.descriptor.ExpressionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveBinding extends JpdlActivityBinding {
+
+  static ObjectBinding objectBinding = new ObjectBinding();
+  static WireParser wireParser = WireParser.getInstance();
+
+  public ExclusiveBinding() {
+    super("exclusive");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    if (element.hasAttribute("expr")) {
+      ExclusiveExpressionActivity exclusiveExpressionActivity = new ExclusiveExpressionActivity();
+      String expr = element.getAttribute("expr");
+      exclusiveExpressionActivity.setExpr(expr);
+      return exclusiveExpressionActivity;
+    }
+
+    if (element.hasAttribute("handler-ref")) {
+      String exclusiveHandlerName = element.getAttribute("handler-ref");
+      ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
+      exclusiveHandlerActivity.setExclusiveHandlerName(exclusiveHandlerName);
+      return exclusiveHandlerActivity;
+    }
+
+    Element handlerElement = XmlUtil.element(element, "handler");
+    if (handlerElement!=null) {
+      ExclusiveHandlerActivity exclusiveHandlerActivity = new ExclusiveHandlerActivity();
+      ObjectDescriptor exclusiveHandlerDescriptor = (ObjectDescriptor) 
+          objectBinding.parse(handlerElement, parse, wireParser);
+      exclusiveHandlerActivity.setExclusiveHandlerDescriptor(exclusiveHandlerDescriptor);
+      return exclusiveHandlerActivity;
+    }
+    
+    boolean hasConditions = false;
+    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+    ActivityImpl activity = parse.findObject(ActivityImpl.class);
+    List<TransitionImpl> transitions = (List) activity.getOutgoingTransitions();
+    
+    for (int i=0; i<transitionElements.size(); i++) {
+      TransitionImpl transition = transitions.get(i);
+      Element transitionElement = transitionElements.get(i);
+
+      Element conditionElement = XmlUtil.element(transitionElement, "condition");
+      if (conditionElement!=null) {
+        hasConditions = true;
+        
+        if (conditionElement.hasAttribute("expr")) {
+          String expr = conditionElement.getAttribute("expr");
+          String lang = XmlUtil.attribute(conditionElement, "expr-lang");
+          ExpressionDescriptor expressionDescriptor = new ExpressionDescriptor(expr, lang);
+          transition.setConditionDescriptor(expressionDescriptor);
+          
+        } else if (conditionElement.hasAttribute("ref")) {
+          String expr = conditionElement.getAttribute("ref");
+          ReferenceDescriptor refDescriptor = new ReferenceDescriptor(expr);
+          transition.setConditionDescriptor(refDescriptor);
+          
+        } else if (ObjectBinding.isObjectDescriptor(conditionElement)) {
+          ObjectDescriptor conditionDescriptor = (ObjectDescriptor) objectBinding.parse(conditionElement, parse, parser);
+          transition.setConditionDescriptor(conditionDescriptor);
+        }
+      }
+    }
+    
+    if (hasConditions) {
+      return new ExclusiveConditionActivity();
+    } else {
+      parse.addProblem("exclusive '"+element.getAttribute("name")+"' must have one of: expr attribute, handler attribute, handler element or condition expressions");
+    }
+    
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.builder.ActivityBehaviourBuilder;
+import org.jbpm.pvm.internal.builder.ActivityBuilder;
+import org.jbpm.pvm.internal.builder.CompositeBuilder;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveBuilder extends ActivityBehaviourBuilder {
+
+  public ExclusiveBuilder(ActivityBuilder activityBuilder) {
+    super(activityBuilder);
+  }
+
+  public ExclusiveBuilder handler(Descriptor descriptor) {
+    // TODO finish this
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveConditionActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveConditionActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveConditionActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Condition;
+import org.jbpm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveConditionActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+    Transition transition = findTransition(execution);
+    if (transition==null) {
+      throw new JbpmException("no outgoing transition condition evaluated to true for exclusive "+execution.getActivity());
+    }
+    if (transition.getName()!=null) {
+      execution.historyExclusive(transition.getName());
+    }
+    execution.take(transition);
+  }
+
+  private Transition findTransition(ActivityExecution execution) {
+    Activity activity = execution.getActivity();
+    List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+    for (Transition transition : outgoingTransitions) {
+      Condition condition = transition.getCondition();
+      if  ( (condition==null)
+            || (condition.evaluate(execution))
+          ) {
+        return transition;
+      }
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveExpressionActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveExpressionActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveExpressionActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.env.EnvironmentDefaults;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveExpressionActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String expr;
+  protected String lang;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    Activity activity = execution.getActivity();
+    String transitionName = null;
+
+    ScriptManager scriptManager = EnvironmentDefaults.getScriptManager();
+    Object result = scriptManager.evaluateExpression(expr, execution, lang);
+    if ( (result!=null)
+         && (! (result instanceof String))
+       ) {
+      throw new JbpmException("expression '"+expr+"' in exclusive '"+activity.getName()+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
+    }
+    transitionName = (String) result;
+    
+    Transition transition = activity.getOutgoingTransition(transitionName);
+    if (transition==null) {
+      throw new JbpmException("expression '"+expr+"' in exclusive '"+activity.getName()+"' returned unexisting outgoing transition name: "+transitionName);
+    }
+    
+    execution.historyExclusive(transitionName);
+
+    execution.take(transition);
+  }
+
+  public void setExpr(String expr) {
+    this.expr = expr;
+  }
+  public void setLang(String lang) {
+    this.lang = lang;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveHandlerActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveHandlerActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExclusiveHandlerActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.jpdl.ExclusiveHandler;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveHandlerActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String exclusiveHandlerName;
+  protected Descriptor exclusiveHandlerDescriptor;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    Activity activity = execution.getActivity();
+    String transitionName = null;
+
+    Object object = null; 
+    if (exclusiveHandlerDescriptor!=null) {
+      object = WireContext.create(exclusiveHandlerDescriptor);
+    } else if (exclusiveHandlerName!=null) {
+      Environment environment = Environment.getCurrent();
+      object = environment.get(exclusiveHandlerName);
+    }
+    
+    if (object==null) {
+      throw new JbpmException("exclusive handler for "+activity+" is null");
+    }
+    if (! (object instanceof ExclusiveHandler)) {
+      throw new JbpmException("handler for exclusive is not a "+ExclusiveHandler.class.getName()+": "+object.getClass().getName());
+    }
+    ExclusiveHandler exclusiveHandler = (ExclusiveHandler) object;
+    transitionName = exclusiveHandler.select(execution);
+
+    Transition transition = activity.getOutgoingTransition(transitionName);
+    if (transition==null) {
+      throw new JbpmException("handler in exclusive '"+activity.getName()+"' returned unexisting outgoing transition name: "+transitionName);
+    }
+    
+    execution.historyExclusive(transitionName);
+
+    execution.take(transition);
+  }
+
+  public void setExclusiveHandlerName(String exclusiveHandlerName) {
+    this.exclusiveHandlerName = exclusiveHandlerName;
+  }
+  public void setExclusiveHandlerDescriptor(Descriptor exclusiveHandlerDescriptor) {
+    this.exclusiveHandlerDescriptor = exclusiveHandlerDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ForkActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void execute(ActivityExecution execution) throws Exception {
+    OpenExecution processInstance = execution.getProcessInstance();
+
+    Activity activity = execution.getActivity();
+    List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+
+    // for each outgoing transition
+    for (Transition outgoingTransition: outgoingTransitions) {
+      // launch a concurrent path of execution
+      String childExecutionName = outgoingTransition.getName();
+      // creating the execution will cause the execution to become inactive
+      Execution childExecution = execution.createExecution(childExecutionName, processInstance);
+      execution.take(outgoingTransition, childExecution);
+    }
+
+    // if this was the first fork
+    if (execution.isProcessInstance()) {
+      execution.setActivity(null);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ForkBinding extends JpdlActivityBinding {
+
+  public ForkBinding() {
+    super("fork");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ForkActivity();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlActivity extends JpdlActivity {
+  
+  private static final Log log = Log.getLog(HqlActivity.class.getName());
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String query;
+  protected ListDescriptor parametersDescriptor;
+  protected String resultVariableName;
+  protected boolean isResultUnique;
+
+  public void execute(ActivityExecution execution) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new JbpmException("no environment for jpdl activity "+HqlBinding.TAG);
+    }
+    Session session = environment.get(Session.class);
+    
+    Query q = createQuery(session);
+    
+    if (parametersDescriptor!=null) {
+      for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
+        String parameterName = valueDescriptor.getName();
+        Object value = WireContext.create(valueDescriptor);
+        applyParameter(q, parameterName, value);
+      }
+    }
+    
+    Object result = null;
+    if (isResultUnique) {
+      result = q.uniqueResult();
+    } else {
+      result = q.list();
+    }
+    
+    execution.setVariable(resultVariableName, result);
+    
+    execution.historyAutomatic();
+  }
+
+  protected Query createQuery(Session session) {
+    return session.createQuery(query);
+  }
+
+  public void applyParameter(Query q, String parameterName, Object value) {
+    if (value instanceof String) {
+      q.setString(parameterName, (String) value);
+    } else if (value instanceof Long) {
+      q.setLong(parameterName, (Long) value);
+    } else {
+      log.error("unknown hql parameter type: "+value.getClass().getName());
+    }
+  }
+
+  public void setQuery(String query) {
+    this.query = query;
+  }
+  public void setParametersDescriptor(ListDescriptor parametersDescriptor) {
+    this.parametersDescriptor = parametersDescriptor;
+  }
+  public void setResultUnique(boolean isResultUnique) {
+    this.isResultUnique = isResultUnique;
+  }
+  public void setResultVariableName(String resultVariableName) {
+    this.resultVariableName = resultVariableName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlBinding extends JpdlActivityBinding {
+
+  public static final String TAG = "hql";
+
+  public HqlBinding() {
+    super(TAG);
+  }
+  
+  protected HqlBinding(String tagName) {
+    super(tagName);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HqlActivity hqlActivity = createHqlActivity();
+    
+    Element queryElement = XmlUtil.element(element, "query", true, parse);
+    if (queryElement!=null) {
+      String query = XmlUtil.getContentText(queryElement);
+      hqlActivity.setQuery(query);
+    }
+    
+    if (XmlUtil.attributeBoolean(element, "unique", false, parse, Boolean.FALSE)) {
+      hqlActivity.setResultUnique(true);
+    }
+    
+    String variableName = XmlUtil.attribute(element, "var", true, parse);
+    hqlActivity.setResultVariableName(variableName);
+    
+    Element parametersElement = XmlUtil.element(element, "parameters");
+    List<Element> paramElements = XmlUtil.elements(parametersElement);
+    if (!paramElements.isEmpty()) {
+      List<Descriptor> parametersDescriptor = new ArrayList<Descriptor>();
+      for (Element paramElement: paramElements) {
+        WireParser wireParser = WireParser.getInstance();
+        Descriptor paramDescriptor = (Descriptor) wireParser.parseElement(paramElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+        parametersDescriptor.add(paramDescriptor);
+      }
+
+      ListDescriptor parametersListDescriptor = new ListDescriptor();
+      parametersListDescriptor.setValueDescriptors(parametersDescriptor);
+      hqlActivity.setParametersDescriptor(parametersListDescriptor);
+    }
+      
+    return hqlActivity;
+  }
+
+  protected HqlActivity createHqlActivity() {
+    return new HqlActivity();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JavaActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Descriptor descriptor;
+  protected String methodName;
+  protected String variableName;
+  protected InvokeOperation invokeOperation;
+  
+  public void execute(ActivityExecution execution) throws Exception {
+    WireContext wireContext = new WireContext();
+    Object target = wireContext.create(descriptor, false);
+
+    try {
+      List<ArgDescriptor> argDescriptors = null;
+      Object[] args = null;
+      if (invokeOperation!=null) {
+        argDescriptors = invokeOperation.getArgDescriptors();
+        args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+      }
+      
+      Class<?> clazz = target.getClass();
+      Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
+      if (method==null) {
+        throw new WireException("method "+ReflectUtil.getSignature(methodName, argDescriptors, args)+" unavailable");
+      }
+
+      Object returnValue = ReflectUtil.invoke(method, target, args);
+      
+      if (variableName!=null) {
+        execution.setVariable(variableName, returnValue);
+      }
+      
+      execution.historyAutomatic();
+
+    } catch (WireException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new WireException("couldn't invoke method "+methodName+": "+e.getMessage(), e);
+    }
+  }
+
+  public void setDescriptor(Descriptor descriptor) {
+    this.descriptor = descriptor;
+  }
+  public void setMethodName(String methodName) {
+    this.methodName = methodName;
+  }
+  public void setVariableName(String variableName) {
+    this.variableName = variableName;
+  }
+  public void setInvokeOperation(InvokeOperation invokeOperation) {
+    this.invokeOperation = invokeOperation;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+import org.jbpm.pvm.internal.wire.operation.Operation;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JavaBinding extends JpdlActivityBinding {
+
+  public static final String TAG = "java";
+  
+  private static final WireParser wireParser = WireParser.getInstance();
+
+  public JavaBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    JavaActivity javaActivity = new JavaActivity();
+
+    String methodName = XmlUtil.attribute(element, "method", true, parse, null);
+    javaActivity.setMethodName(methodName);
+
+    String variableName = XmlUtil.attribute(element, "var");
+    javaActivity.setVariableName(variableName);
+
+    List<Element> argElements = XmlUtil.elements(element, "arg");
+    if (!argElements.isEmpty()) {
+      List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+      InvokeOperation invokeOperation = new InvokeOperation();
+      invokeOperation.setArgDescriptors(argDescriptors);
+      javaActivity.setInvokeOperation(invokeOperation);
+    }
+
+    String className = XmlUtil.attribute(element, "class");
+    if (className!=null) {
+      ObjectDescriptor objectDescriptor = new ObjectDescriptor();
+
+      objectDescriptor.setClassName(className);
+
+      // read the operations elements
+      List<Operation> operations = null;
+      List<Element> elements = XmlUtil.elements(element);
+      
+      Set<String> operationTagNames = wireParser.getBindings().getTagNames(WireParser.CATEGORY_OPERATION);
+      for (Element childElement: elements) {
+        if (operationTagNames.contains(childElement.getTagName())) {
+          Operation operation = (Operation) wireParser.parseElement(childElement, parse, WireParser.CATEGORY_OPERATION);
+          if (operations==null) {
+            operations = new ArrayList<Operation>();
+          }
+          operations.add(operation);
+        }
+      }
+      objectDescriptor.setOperations(operations);
+
+      // autowiring
+      Boolean isAutoWireEnabled = XmlUtil.attributeBoolean(element, "auto-wire", false, parse);
+      if (isAutoWireEnabled!=null) {
+        objectDescriptor.setAutoWireEnabled(isAutoWireEnabled.booleanValue());
+      }
+
+      javaActivity.setDescriptor(objectDescriptor);
+    }
+     
+    return javaActivity;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JoinActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    // end the child execution execution
+    // this will also remove the execution from it's parent
+    execution.setState(Execution.STATE_INACTIVE);
+    execution.waitForSignal();
+    
+    Activity join = execution.getActivity();
+    List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
+    
+    if (isComplete(joinedExecutions, join)) {
+      endJoinedExecutions(joinedExecutions, execution);
+
+      OpenExecution processInstance = execution.getProcessInstance();
+      
+      Execution outgoingExecution = null;
+      if ( processInstance.getExecutions()==null
+           || processInstance.getExecutions().isEmpty() 
+         ) {
+        outgoingExecution = processInstance;
+      } else {
+        outgoingExecution = execution.createExecution(processInstance);
+      }
+      
+      execution.setActivity(join, outgoingExecution);
+      Transition transition = join.getDefaultTransition();
+      execution.take(transition, outgoingExecution);
+    }
+  }
+  
+  List<OpenExecution> findJoinedExecutions(OpenExecution execution, Activity join) {
+    List<OpenExecution> joinedExecutions = new ArrayList<OpenExecution>();
+    scanRecursive(execution.getProcessInstance(), join, joinedExecutions);
+    return joinedExecutions;
+  }
+
+  void scanRecursive(OpenExecution execution, Activity join, List<OpenExecution> joinedExecutions) {
+    // if the execution is positioned in the join
+    if (join.equals(execution.getActivity())) {
+      joinedExecutions.add(execution);
+    }
+    Collection<OpenExecution> childExecutions = execution.getExecutions();
+    if (childExecutions!=null) {
+      for (OpenExecution childExecution: childExecutions) {
+        scanRecursive(childExecution, join, joinedExecutions);
+      }
+    }
+  }
+
+  boolean isComplete(List<OpenExecution> joinedExecutions, Activity join) {
+    int executionsToJoin = join.getIncomingTransitions().size();
+    return (executionsToJoin==joinedExecutions.size());
+  }
+
+  void endJoinedExecutions(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
+    for (OpenExecution joinedExecution: joinedExecutions) {
+      execution.end(joinedExecution);
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JoinBinding extends JpdlActivityBinding {
+
+  public JoinBinding() {
+    super("join");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new JoinActivity();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.activity.ActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlActivity implements ActivityBehaviour {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivityBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivityBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlActivityBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.List;
+
+import org.jbpm.jpdl.internal.xml.UnresolvedTransitions;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.TagBinding;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlActivityBinding extends TagBinding {
+
+  public JpdlActivityBinding(String tagName) {
+    super(tagName, "http://jbpm.org/4/jpdl", "activity");
+  }
+  
+  public void parseName(Element element, ActivityImpl activity, Parse parse) {
+    String name = XmlUtil.attribute(element, "name", isNameRequired(), parse);
+    
+    if (name!=null) {
+      // basic name validation
+      if ("".equals(name)) {
+        parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "is empty"));
+      } else if (name.indexOf('/')!=-1) {
+        parse.addProblem(XmlUtil.errorMessageAttribute(element, "name", name, "contains slash (/)"));
+      }
+      activity.setName(name);
+    }
+  }
+
+  public boolean isNameRequired() {
+    return true;
+  }
+
+  public void parseFlows(Element element, ActivityImpl activity, Parse parse) {
+    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+    UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
+    for (Element transitionElement: transitionElements) {
+      String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+      TransitionImpl transition = activity.createOutgoingTransition(transitionName);
+      unresolvedTransitions.add(transition, transitionElement);
+    }
+  }
+
+}
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlExternalActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlExternalActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlExternalActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlExternalActivity extends JpdlActivity implements ExternalActivityBehaviour {
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String script;
+  protected String language;
+  protected String variableName;
+
+  public void execute(ActivityExecution execution) {
+    ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+    Object returnValue = scriptManager.evaluateScript(script, execution, language);
+    
+    if (variableName!=null) {
+      execution.setVariable(variableName, returnValue);
+    }
+    
+    execution.historyAutomatic();
+  }
+
+  public void setScript(String script) {
+    this.script = script;
+  }
+  public void setLanguage(String language) {
+    this.language = language;
+  }
+  public void setVariableName(String variableName) {
+    this.variableName = variableName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ScriptBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptBinding extends JpdlActivityBinding {
+
+  private static final String TAG = "script";
+
+  public ScriptBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    String language = null;
+
+    String script = XmlUtil.attribute(element, "expr");
+    Element textElement = XmlUtil.element(element, "text");
+    if(script!=null) {
+      ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+      language = scriptManager.getDefaultExpressionLanguage();
+      if (textElement!=null) {
+        parse.addProblem("in <script ...> attribute expr can't be combined with a nexted text element");
+      }
+    } else {
+      language = XmlUtil.attribute(element, "lang");
+      script = XmlUtil.getContentText(textElement);
+    }
+
+    String variableName = XmlUtil.attribute(element, "var");
+    
+    ScriptActivity scriptActivity = new ScriptActivity();
+    scriptActivity.setScript(script);
+    scriptActivity.setLanguage(language);
+    scriptActivity.setVariableName(variableName);
+
+    return scriptActivity;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlActivity extends HqlActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Query createQuery(Session session) {
+    return session.createSQLQuery(query);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SqlBinding extends HqlBinding {
+
+  public static final String TAG = "sql";
+
+  public SqlBinding() {
+    super(TAG);
+  }
+
+  protected HqlActivity createHqlActivity() {
+    return new SqlActivity();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartActivity extends JpdlActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StartBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.jpdl.internal.xml.StartActivities;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartBinding extends JpdlActivityBinding {
+
+  public StartBinding() {
+    super("start");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ActivityImpl startActivity = parse.findObject(ActivityImpl.class);
+    StartActivities startActivities = parse.findObject(StartActivities.class);
+    startActivities.add(startActivity);
+    return new StartActivity();
+  }
+
+  public boolean isNameRequired() {
+    return false;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateActivity extends JpdlExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void execute(ActivityExecution execution) {
+    execution.historyActivityStart();
+
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    Activity activity = execution.getActivity();
+    
+    if (parameters!=null) {
+      execution.setVariables(parameters);
+    }
+    
+    execution.fire(signalName, activity);
+    
+    Transition transition = activity.findOutgoingTransition(signalName);
+    if (transition!=null) {
+      execution.historyActivityEnd(signalName);
+      execution.take(transition);
+    } else {
+      execution.waitForSignal();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateBinding extends JpdlActivityBinding {
+
+  public StateBinding() {
+    super("state");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new StateActivity();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.TaskDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskActivity extends JpdlExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String assignee;
+  
+  public void execute(ActivityExecution execution) {
+    TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
+    TaskImpl task = TaskImpl.create();
+    task.setExecution(execution);
+    task.setName(execution.getActivityName());
+    task.setAssignee(assignee);
+    taskDbSession.saveTask(task);
+    
+    execution.historyTaskStart(assignee);
+    execution.waitForSignal();
+  }
+  
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    Activity activity = execution.getActivity();
+    
+    if (parameters!=null) {
+      execution.setVariables(parameters);
+    }
+    
+    execution.fire(signalName, activity);
+    
+    Transition transition = activity.findOutgoingTransition(signalName);
+    if (transition!=null) {
+      execution.historyTaskEnd(signalName);
+      execution.take(transition);
+    } else {
+      throw new JbpmException("task outcome '"+signalName+"' doesn't match with the an outgoing transition "+activity.getOutgoingTransitions());
+    }
+  }
+
+  public void setAssignee(String assignee) {
+    this.assignee = assignee;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskBinding extends JpdlActivityBinding {
+
+  private static final String TAG = "task";
+
+  public TaskBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    TaskActivity taskActivity = new TaskActivity();
+    
+    String assignee = XmlUtil.attribute(element, "assignee", true, parse);
+    taskActivity.setAssignee(assignee);
+    
+    return taskActivity;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/deploy/ParseJpdlDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/deploy/ParseJpdlDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/deploy/ParseJpdlDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.deploy;
+
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.deploy.Deployer;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ParseJpdlDeployer implements Deployer {
+
+  static JpdlParser jpdlParser = new JpdlParser();
+
+  public void deploy(DeploymentImpl deployment) {
+    for (String fileName: deployment.getFileNamesForType("jpdl")) {
+      // parse them 
+      Parse parse = jpdlParser.createParse();
+      parse.setProblems(deployment.getProblems());
+      parse.setInputStream(deployment.getFile(fileName));
+      parse.execute();
+      
+      // add the parsed xml dom to the deployment documents
+      // so that other subsequent deployers can just use the dom
+      // instead of reparsing the whole jpdl.xml file
+      deployment.addDocument(fileName, parse.getDocument());
+      // add the parsed process definition to the objects
+      // this is where the save process deployer will find it
+      deployment.addObject(fileName, parse.getDocumentObject());
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.model;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JpdlExecution extends ExecutionImpl {
+
+  private static final long serialVersionUID = 1L;
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlProcessDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlProcessDefinition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlProcessDefinition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.model;
+
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JpdlProcessDefinition extends ProcessDefinitionImpl {
+
+  private static final long serialVersionUID = 1L;
+
+  protected ExecutionImpl newProcessInstance() {
+    return new JpdlExecution();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/Activities.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/Activities.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/Activities.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.xml.Bindings;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Activities {
+
+  List<String> schemaResources = new ArrayList<String>();
+  Bindings bindings = new Bindings();
+  
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ActivitiesParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ActivitiesParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ActivitiesParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Binding;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivitiesParser extends Parser {
+
+  private static final Log log = Log.getLog(ActivitiesParser.class.getName());
+  
+  public Object parseDocumentElement(Element documentElement, Parse parse) {
+    Activities activities = parse.findObject(Activities.class);
+    if (activities==null) {
+      activities = new Activities();
+    }
+    parse.setDocumentObject(activities);
+    
+    for (Element bindingElement : XmlUtil.elements(documentElement, "activity")) {
+      Binding binding = instantiateBinding(bindingElement, parse);
+      activities.bindings.addBinding(binding);
+    }
+    
+    for (Element schemaElement : XmlUtil.elements(documentElement, "schema")) {
+      String schemaResource = XmlUtil.attribute(schemaElement, "resource", true, parse);
+      activities.schemaResources.add(schemaResource);
+    }
+
+    return activities;
+  }
+
+  protected Binding instantiateBinding(Element bindingElement, Parse parse) {
+    String bindingClassName = XmlUtil.attribute(bindingElement, "binding", true, parse);
+    
+    log.trace("adding activity binding "+bindingClassName);
+    
+    if (bindingClassName!=null) {
+      try {
+        Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
+        return (Binding) bindingClass.newInstance();
+      } catch (Exception e) {
+        parse.addProblem("couldn't instantiate activity binding "+bindingClassName, e);
+      }
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.SAXParser;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.internal.log.Log;
+import org.jbpm.jpdl.internal.activity.JpdlActivityBinding;
+import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.DomBuilder;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JpdlParser extends Parser {
+  
+  private static final Log log = Log.getLog(JpdlParser.class.getName());
+  
+  public static final String[] DEFAULT_ACTIVITIES_RESOURCES = new String[]{
+    "jbpm.jpdl.activities.xml",
+    "jbpm.user.activities.xml"
+  }; 
+
+  static ActivitiesParser activityParser = new ActivitiesParser();
+
+  public JpdlParser() {
+    initialize(); 
+    
+    Activities activitiesConfiguration = parseActivitiesConfiguration();
+    setBindings(activitiesConfiguration.bindings);
+    setSchemaResources(activitiesConfiguration.schemaResources);
+  }
+
+  protected Activities parseActivitiesConfiguration() {
+    Activities activities = new Activities();
+
+    for (String activityResource: DEFAULT_ACTIVITIES_RESOURCES) {
+      Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, activityResource);
+      if (resourceUrls.hasMoreElements()) {
+        while (resourceUrls.hasMoreElements()) {
+          URL resourceUrl = resourceUrls.nextElement();
+          log.trace("loading jpdl activities from resource: "+resourceUrl);
+          activityParser.createParse()
+            .setUrl(resourceUrl)
+            .pushObject(activities)
+            .execute()
+            .checkProblems("jpdl activities from "+resourceUrl.toString());
+        }
+      } else {
+        log.trace("skipping unavailable jpdl activities resource: "+activityResource);
+      }
+    }
+    
+    return activities;
+  }
+
+  public Object parseDocumentElement(Element documentElement, Parse parse) {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) parse.getDocumentObject();
+    if (processDefinition==null) {
+      processDefinition = new JpdlProcessDefinition();
+    }
+    
+    StartActivities startActivities = new StartActivities();
+    parse.pushObject(startActivities);
+    try {
+      String name = XmlUtil.attribute(documentElement, "name", true, parse);
+      processDefinition.setName(name);
+      
+      String packageName = XmlUtil.attribute(documentElement, "package");
+      processDefinition.setPackageName(packageName);
+
+      Integer version = XmlUtil.attributeInteger(documentElement, "version", false, parse);
+      if (version!=null) {
+        processDefinition.setVersion(version);
+      }
+
+      String key = XmlUtil.attribute(documentElement, "key", false, parse);
+      if (key!=null) {
+        processDefinition.setKey(key);
+      }
+
+      Element descriptionElement = XmlUtil.element(documentElement, "description");
+      if (descriptionElement!=null) {
+        String description = XmlUtil.getContentText(descriptionElement);
+        processDefinition.setDescription(description);
+      }
+      
+      UnresolvedTransitions unresolvedTransitions = new UnresolvedTransitions();
+      parse.pushObject(unresolvedTransitions);
+      
+      List<Element> elements = XmlUtil.elements(documentElement);
+      for (Element element: elements) {
+        JpdlActivityBinding activityBinding = (JpdlActivityBinding) getBinding(element, "activity");
+        if (activityBinding!=null) {
+          ActivityImpl activity = (ActivityImpl) processDefinition.createActivity();
+          parse.pushObject(activity);
+          try {
+            activityBinding.parseName(element, activity, parse);
+            activityBinding.parseFlows(element, activity, parse);
+            ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(element, parse, this);
+            activity.setBehaviour(activityBehaviour);
+          } finally {
+            parse.popObject();
+          }
+        } else {
+          log.debug("unrecognized activity: "+XmlUtil.getTagLocalName(element));
+        }
+      }
+      
+      for (UnresolvedTransition unresolvedTransition: unresolvedTransitions.list) {
+        unresolvedTransition.resolve(processDefinition, parse);
+      }
+
+      // TODO remove the initial attribute parsing
+      String initialActivityName = XmlUtil.attribute(documentElement, "initial", false, parse);
+      if (initialActivityName!=null) {
+        ActivityImpl initial = processDefinition.getActivity(initialActivityName);
+        if (initial==null) {
+          parse.addProblem("initial activity '"+initialActivityName+"' was not found");
+        } else {
+          processDefinition.setInitial(initial);
+        }
+      }
+
+    } finally {
+      parse.popObject();
+    }
+    
+
+    if (startActivities.size()==0) {
+      parse.addProblem("no start activity in process");
+    } else if (startActivities.size()>1) {
+      parse.addProblem("multiple start events not yet supported");
+      // TODO verify that all start events have conditions
+    } else {
+      ActivityImpl uniqueStartEvent = startActivities.get(0);
+      processDefinition.setInitial(uniqueStartEvent);
+    }
+    
+    return processDefinition;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ParseJpdlBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ParseJpdlBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/ParseJpdlBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import org.jbpm.jpdl.internal.deploy.ParseJpdlDeployer;
+import org.jbpm.pvm.internal.wire.binding.WireDescriptorBinding;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ParseJpdlBinding extends WireDescriptorBinding {
+
+  public ParseJpdlBinding() {
+    super("parse-jpdl");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ObjectDescriptor(ParseJpdlDeployer.class);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/StartActivities.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/StartActivities.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/StartActivities.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartActivities {
+  
+  List<ActivityImpl> startEvents = new ArrayList<ActivityImpl>();
+  
+  
+  public void add(ActivityImpl startEventActivity) {
+    startEvents.add(startEventActivity);
+  }
+
+  public int size() {
+    return startEvents.size();
+  }
+
+  public ActivityImpl get(int i) {
+    return startEvents.get(i);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+public class UnresolvedTransition {
+  TransitionImpl transition;
+  Element transitionElement;
+  public UnresolvedTransition(TransitionImpl transition, Element transitionElement) {
+    this.transition = transition;
+    this.transitionElement = transitionElement;
+  }
+  public void resolve(ProcessDefinitionImpl processDefinition, Parse parse) {
+    String to = XmlUtil.attribute(transitionElement, "to", true, parse);
+    if (to!=null) {
+      ActivityImpl destination = (ActivityImpl) processDefinition.findActivity(to);
+      if (destination!=null) {
+        destination.addIncomingTransition(transition);
+      } else {
+        parse.addProblem(XmlUtil.errorMessageAttribute(transitionElement, "to", to, "doesn't reference an existing activity name"));
+      }
+    }
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransitions.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransitions.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/UnresolvedTransitions.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.w3c.dom.Element;
+
+public class UnresolvedTransitions {
+  List<UnresolvedTransition> list = new ArrayList<UnresolvedTransition>();
+  public void add(TransitionImpl transition, Element transitionElement) {
+    list.add(new UnresolvedTransition(transition, transitionElement));
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.common.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.common.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+
+    <!-- DataSource properties (begin) ===
+    <property name="hibernate.connection.datasource">java:JbpmDS</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>
+    <property name="jta.UserTransaction">UserTransaction</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                 # -->
+    <!-- ################################### -->
+
+    <!-- Simple memory-only cache -->
+    <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
+    <!-- logging properties -->
+    <property name="hibernate.format_sql">true</property>
+    <property name="hibernate.use_sql_comments">true</property>
+
+    <!-- Common hibernate mapping used with jpdl -->
+
+    <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+    <mapping resource="jbpm.pvm.wire.hbm.xml" />
+    <mapping resource="jbpm.pvm.definition.hbm.xml" />
+    <mapping resource="jbpm.pvm.execution.hbm.xml" />
+    <mapping resource="jbpm.pvm.variable.hbm.xml" />
+    <mapping resource="jbpm.pvm.job.hbm.xml" />
+    <mapping resource="jbpm.pvm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.jpdl.hbm.xml" />

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.db2.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.db2.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.db2.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://www-128.ibm.com/developerworks/db2/downloads/jcc -->
+    <property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
+    <property name="hibernate.connection.url">jdbc:db2://localhost:50000/testing</property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.derby.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.derby.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.derby.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://db.apache.org/derby -->
+    <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
+    <property name="hibernate.connection.url">jdbc:derby:build/derby/jbpmtest;create=true</property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.firebird.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.firebird.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.firebird.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://firebird.sourceforge.net/ -->
+    <property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
+    <property name="hibernate.connection.url">jdbc:firebirdsql:localhost:jbpmtest</property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,15 @@
+
+    <!-- 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:file:@project.build.directory@/hypersonic/jbpm4DB</property>
+    <property name="hibernate.connection.username">sa</property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+
+    <!-- Automatic schema creation (begin) -->
+    <property name="hibernate.hbm2ddl.auto">create</property>
+    <!-- Automatic schema creation (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.ingres.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.ingres.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.ingres.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.IngresDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://google.com -->
+    <property name="hibernate.connection.driver_class"></property>
+    <property name="hibernate.connection.url"></property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.interbase.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.interbase.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.interbase.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.InterbaseDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://google.com -->
+    <property name="hibernate.connection.driver_class"></property>
+    <property name="hibernate.connection.url"></property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mckoi.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mckoi.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mckoi.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.MckoiDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://google.com -->
+    <property name="hibernate.connection.driver_class"></property>
+    <property name="hibernate.connection.url"></property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mssql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mssql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mssql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://msdn.microsoft.com/data/jdbc -->
+    <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
+    <property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:1433/jbpmtest</property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mysql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mysql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.mysql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
+    <property name="hibernate.connection.url">${jdbc.mysql.url}</property>
+    <property name="hibernate.connection.username">${jdbc.mysql.username}</property>
+    <property name="hibernate.connection.password">${jdbc.mysql.password}</property>
+    <property name="hibernate.query.substitutions">true 1, false 0</property>
+    <!-- JDBC connection properties (end) -->

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.oracle.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.oracle.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.oracle.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
+                                       
+    <!-- JDBC connection properties (begin) -->
+    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
+    <property name="hibernate.connection.url">${jdbc.oracle.url}</property>
+    <property name="hibernate.connection.username">${jdbc.oracle.username}</property>
+    <property name="hibernate.connection.password">${jdbc.oracle.password}</property>
+    <!-- JDBC connection properties (end) -->

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.postgresql.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.postgresql.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.postgresql.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
+    <property name="hibernate.connection.url">${jdbc.postgresql.url}</property>
+    <property name="hibernate.connection.username">${jdbc.postgresql.username}</property>
+    <property name="hibernate.connection.password">${jdbc.postgresql.password}</property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sapdb.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sapdb.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sapdb.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.SAPDBDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <!-- fetch driver from http://google.com -->
+    <property name="hibernate.connection.driver_class"></property>
+    <property name="hibernate.connection.url"></property>
+    <property name="hibernate.connection.username"></property>
+    <property name="hibernate.connection.password"></property>
+    <!-- JDBC connection properties (end) -->
+

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sybase.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sybase.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/hibernate.properties.sybase.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+    <!-- 
+       Out-of-the-box compatibility with Sybase
+       https://jira.jboss.org/jira/browse/JBPM-700
+       
+       System Service QA Database Sybase
+       https://wiki.corp.jboss.com/bin/composite/IT/SystemServiceQaDatabaseSybase
+       
+       Install Sybase ASE 15.0.2 on Fedora9
+       https://www.jboss.org/community/docs/DOC-12932
+    -->
+
+    <!-- hibernate dialect -->
+    <property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
+
+    <!-- JDBC connection properties (begin) -->
+    <property name="hibernate.connection.driver_class">${jdbc.sybase.driver}</property>
+    <property name="hibernate.connection.url">${jdbc.sybase.url}</property>
+    <property name="hibernate.connection.username">${jdbc.sybase.username}</property>
+    <property name="hibernate.connection.password">${jdbc.sybase.password}</property>
+    <!-- JDBC connection properties (end) -->
+
+    <!-- jConnect does not support retrieving natively generated keys after insert -->
+    <property name="hibernate.jdbc.use_get_generated_keys">false</property>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+<?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${/}jbpm4DB</connection-url>    
+    <driver-class>org.hsqldb.jdbcDriver</driver-class>
+    <user-name>sa</user-name>
+    <password></password>
+
+    <!-- connection pool parameters -->
+    <min-pool-size>1</min-pool-size>
+    <max-pool-size>5</max-pool-size>
+
+    <!-- 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 -->
+    <metadata>
+      <type-mapping>Hypersonic SQL</type-mapping>
+    </metadata>
+
+    <!-- ensure the datasource is not initialized before the database itself -->
+    <depends>jboss:service=Hypersonic,database=jbpm4DB</depends>
+  </local-tx-datasource>
+
+  <mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=Hypersonic,database=jbpm4DB">
+    <attribute name="Database">jbpm4DB</attribute>
+    <attribute name="InProcessMode">true</attribute>
+  </mbean>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-mysql-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-mysql-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-mysql-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+
+    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+    <xa-datasource-property name="ServerName">${jdbc.mysql.server}</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">${jdbc.mysql.port}</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">${jdbc.mysql.database}</xa-datasource-property>
+    <user-name>${jdbc.mysql.username}</user-name>
+    <password>${jdbc.mysql.password}</password>
+
+    <!-- reduce isolation from the default level (repeatable read) -->
+    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
+    <!-- separate connections used with and without JTA transaction -->
+    <no-tx-separate-pools />
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <!-- leverage mysql integration features -->
+    <exception-sorter-class-name>
+      com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter
+    </exception-sorter-class-name>
+    <valid-connection-checker-class-name>
+      com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker
+    </valid-connection-checker-class-name>
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>mySQL</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-oracle-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-oracle-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-oracle-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  JBoss Server Configuration                                           -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: oracle-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION:  DO NOT FORGET TO SET Pad=true IN transaction-service.xml  -->
+<!-- ===================================================================== -->
+
+<datasources>
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+    <!-- uncomment to enable interleaving <interleaving/> -->
+    <isSameRM-override-value>false</isSameRM-override-value>
+    <track-connection-by-tx/>
+    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+    <xa-datasource-property name="URL">${jdbc.oracle.url}</xa-datasource-property>
+    <xa-datasource-property name="User">${jdbc.oracle.username}</xa-datasource-property>
+    <xa-datasource-property name="Password">${jdbc.oracle.password}</xa-datasource-property>
+    <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+    <!-- Checks the Oracle error codes and messages for fatal errors -->
+    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+    <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+    <no-tx-separate-pools/>
+
+      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+      <metadata>
+         <type-mapping>Oracle9i</type-mapping>
+      </metadata>
+  </xa-datasource>
+
+  <mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" 
+         name="jboss.jca:service=OracleXAExceptionFormatter">
+    <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
+  </mbean>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-postgresql-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-postgresql-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-postgresql-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+
+    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+    <xa-datasource-property name="ServerName">${jdbc.postgresql.server}</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">${jdbc.postgresql.port}</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">${jdbc.postgresql.database}</xa-datasource-property>
+    <user-name>${jdbc.postgresql.username}</user-name>
+    <password>${jdbc.postgresql.password}</password>
+
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>PostgreSQL 8.0</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-sybase-ds.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-sybase-ds.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm-sybase-ds.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources>
+
+  <xa-datasource>
+    <jndi-name>JbpmDS</jndi-name>
+    
+    <xa-datasource-class>${jdbc.sybase.datasource}</xa-datasource-class>
+    <xa-datasource-property name="ServerName">${jdbc.sybase.server}</xa-datasource-property>
+    <xa-datasource-property name="PortNumber">${jdbc.sybase.port}</xa-datasource-property>
+    <xa-datasource-property name="DatabaseName">${jdbc.sybase.database}</xa-datasource-property>
+    <user-name>${jdbc.sybase.username}</user-name>
+    <password>${jdbc.sybase.password}</password>
+
+    <!-- disable transaction interleaving -->
+    <track-connection-by-tx />
+
+    <exception-sorter-class-name>
+      org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter
+    </exception-sorter-class-name>
+
+    <!-- corresponding type-mapping in conf/standardjbosscmp-jdbc.xml -->
+    <metadata>
+      <type-mapping>Sybase</type-mapping>
+    </metadata>
+  </xa-datasource>
+
+</datasources>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+    
+    <process-service />
+    <execution-service />
+    <management-service />
+    <task-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration resource="hibernate.cfg.xml"/>    
+    
+    <hibernate-session-factory />
+    
+    <job-executor auto-start="false" />
+    <job-test-helper />
+
+    <id-generator />
+    <types resource="jbpm.pvm.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <task-db-session />
+    <message-session />
+    <timer-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.activities.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<activities>
+  <schema resource="jpdl.xsd" />
+  <activity binding="org.jbpm.jpdl.internal.activity.StartBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.StateBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.ExclusiveBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.EndBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.EndCancelBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.EndErrorBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.ForkBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.JoinBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.HqlBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.SqlBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.JavaBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.EsbBinding" />
+  <activity binding="org.jbpm.jpdl.internal.activity.TaskBinding" />
+</activities>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlProcessDefinition" table="JBPM_JPDL_PROCDEF"  extends="org.jbpm.pvm.internal.model.ProcessDefinitionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlExecution" table="JBPM_JPDL_EXECUTION" extends="org.jbpm.pvm.internal.model.ExecutionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <class name="org.jbpm.jpdl.internal.activity.JpdlActivity" table="JBPM_JPDL_ACTIVITY"  abstract="true" discriminator-value="X">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <subclass name="org.jbpm.jpdl.internal.activity.StartActivity" discriminator-value="start" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveConditionActivity" discriminator-value="excl-cond" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveExpressionActivity" discriminator-value="excl-expr">
+      <property name="expr" column="TEXT_" />
+      <property name="lang" column="TEXT2_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler">
+      <property name="exclusiveHandlerName" column="TEXT_" />
+      <many-to-one name="exclusiveHandlerDescriptor"
+                   column="EXCLDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_EXCLDESCR"
+                   index="IDX_ACT_EXCLDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.StateActivity" discriminator-value="state" />
+    <subclass name="org.jbpm.jpdl.internal.activity.EndActivity" discriminator-value="end">
+      <property name="endProcessInstance" column="ENDPI_" />
+      <property name="state" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ForkActivity" discriminator-value="fork" />
+    <subclass name="org.jbpm.jpdl.internal.activity.JoinActivity" discriminator-value="join" />
+    <subclass name="org.jbpm.jpdl.internal.activity.HqlActivity" discriminator-value="hql">
+      <property name="query" column="TEXT_" />
+      <property name="resultVariableName" column="TEXT2_" />
+      <property name="isResultUnique" column="ISUNIQ_" />
+      <many-to-one name="parametersDescriptor"
+                   column="PARAMDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+                   foreign-key="FK_ACT_PARAMDESCR"
+                   index="IDX_ACT_PARAMDESCR" />
+      
+      <subclass name="org.jbpm.jpdl.internal.activity.SqlActivity" discriminator-value="sql" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.JavaActivity" discriminator-value="java">
+      <property name="methodName" column="TEXT_" />
+      <property name="variableName" column="TEXT2_" />
+      <many-to-one name="descriptor"
+                   column="JAVADESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_JAVADESCR"
+                   index="IDX_ACT_JAVADESCR" />
+      <many-to-one name="invokeOperation"
+                   column="INVOPER_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.operation.InvokeOperation"
+                   foreign-key="FK_ACT_INVKOPER"
+                   index="IDX_ACT_INVKOPER" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ScriptActivity" discriminator-value="script">
+      <property name="script" column="TEXT_" />
+      <property name="language" column="TEXT2_" />
+      <property name="variableName" column="TEXT3_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.EsbActivity" discriminator-value="esb">
+      <property name="service" column="TEXT_" />
+      <property name="category" column="TEXT2_" />
+      <many-to-one name="partsListDescriptor"
+               column="PARTSDESCR_" 
+               cascade="all"
+               class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+               foreign-key="FK_ACT_PARTSDESCR"
+               index="IDX_ACT_PARTSDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.TaskActivity" discriminator-value="task">
+      <property name="assignee" column="TEXT_" />
+    </subclass>
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.wire.bindings.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.wire.bindings.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/jbpm.jpdl.wire.bindings.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<wire-bindings>
+  <binding class="org.jbpm.jpdl.internal.xml.ParseJpdlBinding" />
+</wire-bindings>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=FINEST
+org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE
+org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=FINEST
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/JpdlTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/JpdlTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.internal.log.Log;
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlTestCase extends BaseJbpmTestCase
+{
+
+  static protected Log log = Log.getLog(JpdlTestCase.class.getName());
+
+  public ClientProcessDefinition parseJpdl(String xmlString)
+  {
+    JpdlParser jpdlParser = new JpdlParser();
+    Parse result = jpdlParser.createParse().setString(xmlString).execute();
+    return (ClientProcessDefinition)result.checkProblems("process definition xml string").getDocumentObject();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ActivityParsingTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityParsingTest extends JpdlParseTestCase {
+
+  public void testInvalidActivityeName() {
+    List<Problem> problems = parseProblems(
+      "<process name='p'>" +
+      "  <state name='invalid / activityname' />" +
+      "</process>"
+    );
+    assertTextPresent("attribute <state name=\"invalid / activityname\" contains slash (/)", problems.get(0).getMsg());
+  }
+
+  public void testEmptyActivityName() {
+    List<Problem> problems = parseProblems(
+      "<process name='p'>" +
+      "  <state name='' />" +
+      "</process>"
+    );
+    assertTextPresent("attribute <state name=\"\" is empty", problems.get(0).getMsg());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlParseTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JpdlParseTestCase extends BaseJbpmTestCase {
+
+  static JpdlParser jpdlParser = new JpdlParser();
+
+  public List<Problem> parseProblems(String xmlString) {
+    List<Problem> problems = jpdlParser.createParse()
+               .setString(xmlString)
+               .execute()
+               .getProblems();
+    if ( (problems==null)
+         || (problems.isEmpty())
+       ) {
+      fail("expected problems during parse");
+    }
+    return problems;
+  }
+  
+  public ClientProcessDefinition parse(String xmlString) {
+    JpdlParser jpdlParser = new JpdlParser();
+    return (ClientProcessDefinition) jpdlParser.createParse()
+               .setString(xmlString)
+               .execute()
+               .checkProblems("process definition xml string")
+               .getDocumentObject();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/JpdlSchemaTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+
+
+/**
+ * @author Tom Baeyents
+ */
+public class JpdlSchemaTest extends JpdlParseTestCase {
+
+  public void testSimplestValidProcess() {
+    List<Problem> problems = jpdlParser.createParse()
+      .setString(
+          "<jpdl:process xmlns:jpdl='http://jbpm.org/4/jpdl' " +
+          "              name='p' >" +
+          "  <jpdl:start name='n' />" +
+          "</jpdl:process>"
+      )
+      .execute()
+      .getProblems();
+
+    assertEquals(0, problems.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ProcessParsingTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.client.ClientProcessDefinition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessParsingTest extends JpdlParseTestCase {
+
+  public void testSimplestValidProcess() {
+    ClientProcessDefinition processDefinition = parse(
+      "<process name='p'>" +
+      "  <start name='s' />" +
+      "</process>"
+    );
+    assertEquals("p", processDefinition.getName());
+    assertNotNull(processDefinition.getActivity("s"));
+    assertSame(processDefinition.getActivity("s"), processDefinition.getInitial());
+    assertEquals(1, processDefinition.getActivities().size());
+  }
+
+  public void testProcessWithoutAttributes() {
+    List<Problem> problems = parseProblems(
+      "<process />"
+    );
+    assertTextPresent("attribute <process name=\"...\" is required", problems.get(0).getMsg());
+  }
+
+
+  public void testEmptyProcessName() {
+    List<Problem> problems = parseProblems(
+      "<process name='' />"
+    );
+    assertTextPresent("attribute <process name=\"\" is empty", problems.get(0).getMsg());
+    assertTextPresent("no start activity in process", problems.get(1).getMsg());
+  }
+
+  public void testProcessWithUnexistingInitial() {
+    List<Problem> problems = parseProblems(
+      "<process name='p' initial='ufo' />"
+    );
+    assertTextPresent("initial activity 'ufo' was not found", problems.get(0).getMsg());
+    assertTextPresent("no start activity in process", problems.get(1).getMsg());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TransitionParsingTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionParsingTest extends JpdlParseTestCase {
+
+  public void testTransition() {
+    ClientProcessDefinition processDefinition = parse(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b' />" +
+      "</process>"
+    );
+    Activity a = processDefinition.getActivity("a");
+    assertNotNull(a);
+    Transition transition = a.getOutgoingTransitions().get(0);
+    assertNotNull(transition);
+    Activity b = processDefinition.getActivity("b");
+    assertNotNull(b);
+    assertSame(b, transition.getDestination());
+  }
+
+  public void testSelfTransition() {
+    ClientProcessDefinition processDefinition = parse(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "</process>"
+    );
+    Activity a = processDefinition.getActivity("a");
+    assertNotNull(a);
+    Transition transition = a.getOutgoingTransitions().get(0);
+    assertNotNull(transition);
+    assertSame(a, transition.getDestination());
+  }
+
+  public void testMissingTransitionDestination() {
+    List<Problem> problems = parseProblems(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition />" +
+      "  </start>" +
+      "</process>"
+    );
+    assertTextPresent("attribute <transition to=\"...\" is required", problems.get(0).getMsg());
+  }
+
+  public void testEmptyTransitionDestination() {
+    List<Problem> problems = parseProblems(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='' />" +
+      "  </start>" +
+      "</process>"
+    );
+    assertTextPresent("attribute <transition to=\"\" is empty", problems.get(0).getMsg());
+  }
+
+  public void testInvalidTransitionDestination() {
+    List<Problem> problems = parseProblems(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='unexisting' />" +
+      "  </start>" +
+      "</process>"
+    );
+    assertTextPresent("attribute <transition to=\"unexisting\" doesn't reference an existing activity name", problems.get(0).getMsg());
+  }
+
+  public void testMultipleOutgoingTransitions() {
+    ClientProcessDefinition processDefinition = parse(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "    <transition to='b' />" +
+      "    <transition to='c' />" +
+      "  </start>" +
+      "  <state name='b' />" +
+      "  <state name='c' />" +
+      "</process>"
+    );
+    Activity a = processDefinition.getActivity("a");
+    Activity b = processDefinition.getActivity("b");
+    Activity c = processDefinition.getActivity("c");
+
+    assertSame(b, a.getOutgoingTransitions().get(0).getDestination());
+    assertSame(b, a.getOutgoingTransitions().get(1).getDestination());
+    assertSame(c, a.getOutgoingTransitions().get(2).getDestination());
+  }
+
+  public void testMultipleIncomingTransitions() {
+    ClientProcessDefinition processDefinition = parse(
+      "<process name='p'>" +
+      "  <start name='a'>" +
+      "    <transition to='c' />" +
+      "    <transition to='c' />" +
+      "  </start>" +
+      "  <state name='b'>" +
+      "    <transition to='c' />" +
+      "  </state>" +
+      "  <state name='c' />" +
+      "</process>"
+    );
+    Activity a = processDefinition.getActivity("a");
+    Activity b = processDefinition.getActivity("b");
+    Activity c = processDefinition.getActivity("c");
+
+    assertSame(c, a.getOutgoingTransitions().get(0).getDestination());
+    assertSame(c, a.getOutgoingTransitions().get(1).getDestination());
+    assertSame(c, b.getOutgoingTransitions().get(0).getDestination());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/DbGenTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/DbGenTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/DbGenTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.xml;
+
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.Execution;
+
+/**
+ * A simple test execution that force the generation of the
+ * hypersomic database structure.
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class DbGenTest extends JbpmTestCase
+{
+
+  public void testWaitStatesSequence() {
+    deployJpdlResource("org/jbpm/test/xml/process.jpdl.xml");
+
+    Execution execution = executionService.startProcessInstanceByKey("StateSequence");
+    assertEquals("a", execution.getActivityName());
+
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("b", execution.getActivityName());
+
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("c", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/test/xml/JpdlXmlTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.xml;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JpdlXmlTest extends BaseJbpmTestCase {
+  
+  public void testValidXml() {
+    List<Problem> problems = new JpdlParser()
+      .createParse()
+      .setResource("org/jbpm/test/xml/valid.jpdl.xml")
+      .execute()
+      .getProblems();
+
+    assertEquals(problems.toString(), 0, problems.size());
+  }
+  
+  public void testInvalidXml() {
+    List<Problem> problems = new JpdlParser()
+      .createParse()
+      .setResource("org/jbpm/test/xml/invalid.jpdl.xml")
+      .execute()
+      .getProblems();
+
+    assertEquals(problems.toString(), 1, problems.size());
+  }
+
+  public void testNoNamespace() {
+    List<Problem> problems = new JpdlParser()
+      .createParse()
+      .setResource("org/jbpm/test/xml/nonamespace.jpdl.xml")
+      .execute()
+      .getProblems();
+
+    assertEquals(problems.toString(), 0, problems.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/extended.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/extended.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/extended.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl"
+                               xmlns:ext="http://jbpm.org/customextensions">
+
+  <start>
+    <transition to="a"/>
+  </start>
+
+  <customactivity name="a" customattrib="xxx">
+    <customconfigelement a="yyy" />
+    <transition to="end"/>
+  </customactivity>
+  
+  <end name="end" />
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/invalid.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/invalid.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/invalid.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl">
+
+  <start />
+
+  <buzzz>
+  
+  </buzzz>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/nonamespace.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/nonamespace.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/nonamespace.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Purchase order">
+
+  <start />
+
+  <buzzz>
+  
+  </buzzz>
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
+
+  <start g="16,18,48,48">
+    <transition to="a" />
+  </start>
+
+  <state name="a" g="96,16,75,52">
+    <transition to="b" />
+  </state>
+
+  <state name="b" g="203,16,73,52">
+    <transition to="c" />
+  </state>
+
+  <state name="c" g="308,16,76,52" />
+
+</process>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/valid.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/valid.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/org/jbpm/test/xml/valid.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl">
+
+  <start>
+    <transition to="a" />
+  </start>
+
+  <state name="a">
+    <transition name="Supplier ok" to="b" />
+  </state>
+
+  <state name="b">
+    <transition name="nok" to="Error" />
+    <transition name="ok" to="Completed" />
+  </state >
+
+  <end name="Completed" />
+
+  <end name="Error" />
+
+</process>

Added: jbpm4/branches/tbaeyens/modules/log/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/log/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>log</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/log/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 2702 2008-10-31 10:49:02Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Log</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-log</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+      </dependency>
+  </dependencies>
+  
+  <!-- Plugins -->
+  <build>
+    <plugins>
+    </plugins>
+  </build>
+  
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ConsoleHandler.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ConsoleHandler.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ConsoleHandler.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConsoleHandler extends java.util.logging.ConsoleHandler {
+
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ErrorTriggeredFileHandler.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ErrorTriggeredFileHandler.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/ErrorTriggeredFileHandler.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.MemoryHandler;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ErrorTriggeredFileHandler extends Handler {
+
+  private static final int    DEFAULT_SIZE       = 500;
+  private static final Level  DEFAULT_PUSH_LEVEL = Level.SEVERE;
+  private static final String DEFAULT_PATTERN    = "%h/jbpm%u.log";
+  
+  DecoratedMemoryHandler memoryHandler = null;
+  FileHandler fileHandler = null;
+
+  public ErrorTriggeredFileHandler() throws SecurityException, IOException {
+    fileHandler = getConfiguredTarget();
+    memoryHandler = new DecoratedMemoryHandler(fileHandler, getConfiguredSize(), getConfiguredPushLevel());
+  }
+
+  private static Level getConfiguredPushLevel() {
+    LogManager manager = LogManager.getLogManager();
+    String pushLevelText = manager.getProperty(ErrorTriggeredFileHandler.class.getName() + ".push");
+    if (pushLevelText == null) {
+      return DEFAULT_PUSH_LEVEL;
+    }
+    try {
+      return Level.parse(pushLevelText.trim());
+    } catch (Exception ex) {
+      return DEFAULT_PUSH_LEVEL;
+    }
+  }
+
+  protected static int getConfiguredSize() {
+    LogManager manager = LogManager.getLogManager();
+    String sizeText = manager.getProperty(ErrorTriggeredFileHandler.class.getName() + ".size");
+    if (sizeText == null) {
+      return DEFAULT_SIZE;
+    }
+    try {
+      return Integer.parseInt(sizeText.trim());
+    } catch (Exception ex) {
+      return DEFAULT_SIZE;
+    }
+  }
+
+  protected static FileHandler getConfiguredTarget() throws SecurityException, IOException {
+    LogManager manager = LogManager.getLogManager();
+    String pattern = manager.getProperty(ErrorTriggeredFileHandler.class.getName() + ".pattern");
+    if (pattern == null) {
+      pattern = DEFAULT_PATTERN;
+    }
+    return new FileHandler(pattern);
+  }
+
+  
+  public class DecoratedMemoryHandler extends MemoryHandler {
+    public DecoratedMemoryHandler(FileHandler target, int size, Level pushLevel) {
+      super(target, size, pushLevel);
+    }
+    public void push() {
+      fileHandler.setFormatter(new LogFormatter());
+      super.push();
+      LogRecord emptyLine = new LogRecord(Level.INFO, "");
+      emptyLine.setLoggerName("");
+      fileHandler.publish(emptyLine);
+      LogRecord line = new LogRecord(Level.INFO, "---- END OF TRIGGERED PUSH ---------------------------------------------------");
+      line.setLoggerName("");
+      fileHandler.publish(line);
+      fileHandler.publish(emptyLine);
+      fileHandler.publish(emptyLine);
+    }
+  }
+
+  public void close() throws SecurityException {
+    memoryHandler.close();
+  }
+
+  public void flush() {
+    memoryHandler.flush();
+  }
+
+  public void publish(LogRecord record) {
+    memoryHandler.publish(record);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14Log.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14Log.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14Log.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Jdk14Log extends Log {
+  
+  Logger log;
+
+  public Jdk14Log(Logger logger) {
+    this.log = logger;
+  }
+
+  public void error(String msg) {
+    log.log(Level.SEVERE, msg);
+  }
+
+  public void error(String msg, Throwable exception) {
+    log.log(Level.SEVERE, msg, exception);
+  }
+
+  public boolean isInfoEnabled() {
+    return log.isLoggable(Level.INFO);
+  }
+
+  public void info(String msg) {
+    log.log(Level.INFO, msg);
+  }
+
+  public void info(String msg, Throwable exception) {
+    log.log(Level.INFO, msg, exception);
+  }
+
+  public boolean isDebugEnabled() {
+    return log.isLoggable(Level.FINE);
+  }
+
+  public void debug(String msg) {
+    log.log(Level.FINE, msg);
+  }
+
+  public void debug(String msg, Throwable exception) {
+    log.log(Level.FINE, msg, exception);
+  }
+
+  public boolean isTraceEnabled() {
+    return log.isLoggable(Level.FINEST);
+  }
+
+  public void trace(String msg) {
+    log.log(Level.FINEST, msg);
+  }
+
+  public void trace(String msg, Throwable exception) {
+    log.log(Level.FINEST, msg, exception);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14LogFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14LogFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Jdk14LogFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Jdk14LogFactory implements LogFactory {
+  
+  public Jdk14LogFactory() {
+    initializeJdk14Logging();
+  }
+
+  public Log getLog(String name) {
+    return new Jdk14Log(Logger.getLogger(name));
+  }
+
+  /** redirects commons logging to JDK 1.4 logging.  This can be handy when 
+   * you have log4j on the classpath, but still want to use the JDK logging. */
+  public static synchronized void redirectCommonsToJdk14() {
+    System.setProperty("org.apache.commons.logging.Log",
+                       "org.apache.commons.logging.impl.Jdk14Logger" );
+  }
+
+  /** configures JDK 1.4 logging from the resource file <code>logging.properties</code> */
+  public static synchronized void initializeJdk14Logging() {
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    InputStream inputStream = classLoader.getResourceAsStream("logging.properties");
+    try {
+      if (inputStream != null) {
+        LogManager.getLogManager().readConfiguration(inputStream);
+
+        String redirectCommons = LogManager.getLogManager().getProperty("redirect.commons.logging");
+        if ( (redirectCommons!=null)
+             && (! redirectCommons.equalsIgnoreCase("disabled"))
+             && (! redirectCommons.equalsIgnoreCase("off"))
+             && (! redirectCommons.equalsIgnoreCase("false"))
+           ) {
+          redirectCommonsToJdk14();
+        }
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new RuntimeException("couldn't initialize logging properly", e);
+    } finally {
+      if (inputStream != null) {
+        try {
+          inputStream.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class Log {
+  
+  static LogFactory logFactory;
+
+  public static synchronized Log getLog(String name) {
+    if (logFactory==null) {
+      
+      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+      // if logging.properties is available on the classpath
+      if (classLoader.getResource("logging.properties")!=null) {
+        logFactory = new Jdk14LogFactory();
+        
+      // if log4j is available on the classpath
+      } else if (isLog4jAvailable(classLoader)) {
+        logFactory = new Log4jLogFactory();
+        
+      } else {
+        logFactory = new Jdk14LogFactory();
+         
+      }
+    }
+    return logFactory.getLog(name);
+  }
+
+  static boolean isLog4jAvailable(ClassLoader classLoader) {
+    try {
+      Class.forName("org.apache.log4j.LogManager", false, classLoader);
+      return true;
+    } catch (ClassNotFoundException e) {
+      return false;
+    }
+  }
+
+
+  public abstract void error(String msg);
+  public abstract void error(String msg, Throwable exception);
+
+  public abstract boolean isInfoEnabled();
+  public abstract void info(String msg);
+  public abstract void info(String msg, Throwable exception);
+
+  public abstract boolean isDebugEnabled();
+  public abstract void debug(String msg);
+  public abstract void debug(String msg, Throwable exception);
+
+  public abstract boolean isTraceEnabled();
+  public abstract void trace(String msg);
+  public abstract void trace(String msg, Throwable exception);
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLog.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLog.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLog.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Log4jLog extends Log {
+
+  org.apache.log4j.Logger log;
+  
+  public Log4jLog(org.apache.log4j.Logger log) {
+    this.log = log;
+  }
+
+  public void error(String msg) {
+    log.error(msg);
+  }
+
+  public void error(String msg, Throwable exception) {
+    log.error(msg, exception);
+  }
+
+  public boolean isInfoEnabled() {
+    return log.isInfoEnabled();
+  }
+
+  public void info(String msg) {
+    log.info(msg);
+  }
+
+  public void info(String msg, Throwable exception) {
+    log.info(msg, exception);
+  }
+
+  public boolean isDebugEnabled() {
+    return log.isDebugEnabled();
+  }
+
+  public void debug(String msg) {
+    log.debug(msg);
+  }
+
+  public void debug(String msg, Throwable exception) {
+    log.debug(msg, exception);
+  }
+
+  public boolean isTraceEnabled() {
+    return log.isTraceEnabled();
+  }
+
+  public void trace(String msg) {
+    log.trace(msg);
+  }
+
+  public void trace(String msg, Throwable exception) {
+    log.trace(msg, exception);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLogFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLogFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/Log4jLogFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+import org.apache.log4j.LogManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Log4jLogFactory implements LogFactory {
+
+  public Log getLog(String name) {
+    return new Log4jLog(LogManager.getLogger(name));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFactory.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFactory.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFactory.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.internal.log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface LogFactory {
+
+  Log getLog(String name);
+
+}

Added: jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFormatter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFormatter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/log/src/main/java/org/jbpm/internal/log/LogFormatter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,83 @@
+package org.jbpm.internal.log;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class LogFormatter extends Formatter {
+  
+  static final String NEWLINE = System.getProperty("line.separator");
+  static final DateFormat dateTimeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
+  static final Map<Level, String> levels = new HashMap<Level, String>();
+  private static Map<Integer, Integer> indentations = new HashMap<Integer, Integer>();
+
+  
+  static {
+    levels.put(Level.ALL,     "ALL");
+    levels.put(Level.CONFIG,  "CFG");
+    levels.put(Level.FINE,    "FIN");
+    levels.put(Level.FINER,   "FNR");
+    levels.put(Level.FINEST,  "FST");
+    levels.put(Level.INFO,    "INF");
+    levels.put(Level.OFF,     "OFF");
+    levels.put(Level.SEVERE,  "SEV");
+    levels.put(Level.WARNING, "WRN");
+  }
+
+  public String format(LogRecord logRecord) {
+    StringWriter msg = new StringWriter();
+    if (logRecord.getThrown()!=null) {
+      msg.append("### EXCEPTION ###########################################");
+      msg.append(NEWLINE);
+    }
+    msg.append(dateTimeFormat.format(new Date()));
+    msg.append(" ");
+    msg.append(levels.get(logRecord.getLevel()));
+    msg.append(" ");
+
+    int threadId = logRecord.getThreadID();
+    for (int i=0; i<getIndentation(threadId); i++) {
+      msg.append("  ");
+    }
+    
+    msg.append("| [");
+    
+    String loggerName = logRecord.getLoggerName();
+    int dotIndex = loggerName.lastIndexOf('.');
+    if (dotIndex!=-1) {
+      loggerName = loggerName.substring(dotIndex+1);
+    }
+    msg.append(loggerName);
+    
+    msg.append("] ");
+    
+    msg.append(logRecord.getMessage());
+    if (logRecord.getThrown()!=null) {
+      msg.append(NEWLINE);
+      logRecord.getThrown().printStackTrace(new PrintWriter(msg));
+      msg.append("### EXCEPTION ###########################################");
+    }
+    msg.append(NEWLINE);
+    return msg.toString();
+  }
+
+  private int getIndentation(int threadId) {
+    Integer indentation = indentations.get(threadId);
+    if (indentation==null) {
+      indentation = indentations.size();
+      indentations.put(threadId, indentation);
+    }
+    return indentation;
+  }
+
+  public static void resetIndentation() {
+    indentations = new HashMap<Integer, Integer>();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/pvm/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>pvm</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/pvm/build.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/build.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/build.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="update.pvm.configuration" basedir=".">
+	
+  <target name="update.configuration" description="update the test resources by running the config tool">
+    <delete dir="target/config" />
+    <mkdir dir="target/config" />
+    <copy todir="target/config">
+      <fileset dir="../config-tool/src/main/tool" />
+    </copy>
+    <copy todir="target/config" overwrite="true">
+      <fileset dir="src/main/config" />
+    </copy>
+  	<ant antfile="target/config/build.xml" target="generate" inheritall="false" />
+    <copy todir="src/test/resources" overwrite="true">
+      <fileset dir="target/config/target/configfiles" />
+    </copy>
+  </target>
+
+</project>

Added: jbpm4/branches/tbaeyens/modules/pvm/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3952 2009-02-19 17:09:20Z tom.baeyens at jboss.com $ -->
+
+<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>
+
+  <name>jBPM 4 - PVM</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-pvm</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Properties -->
+  <properties>
+    <table.prefix>JBPM_</table.prefix>
+    <!--test.resources.directory>${project.build.directory}/test-resources</test.resources.directory-->
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-log</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-base</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>juel</groupId>
+      <artifactId>juel</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>juel</groupId>
+      <artifactId>juel-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>juel</groupId>
+      <artifactId>juel-engine</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.identity</groupId>
+      <artifactId>idm</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-j2ee</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.livetribe</groupId>
+      <artifactId>livetribe-jsr223</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <showDeprecation>false</showDeprecation>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/*TestCase.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <!-- Profiles -->
+  <profiles>
+  </profiles>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <quiet>true</quiet>
+          <source>1.5</source>
+          <verbose>false</verbose>
+          <noqualifier>all</noqualifier>
+          <excludePackageNames>*.internal:*.test</excludePackageNames>
+        </configuration>
+      </plugin>
+
+    </plugins>
+  </reporting>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/config/build.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/config/build.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/config/build.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+jbpm.config.dest.dir=target/configfiles
+jbpm.config.tmp.dir=target/filtered
+jbpm.config.hibernate.cache=hashtable
+jbpm.config.hibernate.connection.type=jdbc
+jbpm.config.hibernate.database=hsqldb.inmemory
+jbpm.config.hibernate.format.sql=include
+jbpm.config.hibernate.jpdl=exclude
+jbpm.config.identity=include

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/jobexecutor.ppt
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/jobexecutor.ppt
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.build.uml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.build.uml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.build.uml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,607 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<XPD:PROJECT xmlns:XPD="http://www.staruml.com" version="1">
+<XPD:HEADER>
+<XPD:SUBUNITS>
+</XPD:SUBUNITS>
+<XPD:PROFILES>
+<XPD:PROFILE>ERD</XPD:PROFILE>
+<XPD:PROFILE>UMLStandard</XPD:PROFILE>
+</XPD:PROFILES>
+</XPD:HEADER>
+<XPD:BODY>
+<XPD:OBJ name="DocumentElement" type="UMLProject" guid="H0/lv4BKwkuxuNjHqRrogAAA">
+<XPD:ATTR name="Title" type="string">Untitled</XPD:ATTR>
+<XPD:ATTR name="#OwnedElements" type="integer">5</XPD:ATTR>
+<XPD:OBJ name="OwnedElements[0]" type="UMLModel" guid="rMmqNwr2nE2Ow5sMjpo5tQAA">
+<XPD:ATTR name="Name" type="string">Use Case Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">useCaseModel</XPD:ATTR>
+<XPD:REF name="Namespace">H0/lv4BKwkuxuNjHqRrogAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLUseCaseDiagram" guid="Yk0IOk62rUiByUfA5TzEDgAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">rMmqNwr2nE2Ow5sMjpo5tQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLUseCaseDiagramView" guid="7sVWZdDp00usug/cIW1OHgAA">
+<XPD:REF name="Diagram">Yk0IOk62rUiByUfA5TzEDgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[1]" type="UMLModel" guid="hLKz3ENdN0GHMvBjnFm5SQAA">
+<XPD:ATTR name="Name" type="string">Analysis Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">analysisModel</XPD:ATTR>
+<XPD:REF name="Namespace">H0/lv4BKwkuxuNjHqRrogAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLClassDiagram" guid="dkmkFGt2wEelQ6vQ5UeGygAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:ATTR name="DefaultDiagram" type="boolean">True</XPD:ATTR>
+<XPD:ATTR name="DiagramType" type="string">RobustnessDiagram</XPD:ATTR>
+<XPD:REF name="DiagramOwner">hLKz3ENdN0GHMvBjnFm5SQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLClassDiagramView" guid="I8YlsoUWN0epblrmBkfMuwAA">
+<XPD:REF name="Diagram">dkmkFGt2wEelQ6vQ5UeGygAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[2]" type="UMLModel" guid="rZzJfqAsXk6oml4M7O8i9wAA">
+<XPD:ATTR name="Name" type="string">Design Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">designModel</XPD:ATTR>
+<XPD:REF name="Namespace">H0/lv4BKwkuxuNjHqRrogAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLClassDiagram" guid="zQePzn7dgEOHzlzNhGKiDgAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:ATTR name="DefaultDiagram" type="boolean">True</XPD:ATTR>
+<XPD:REF name="DiagramOwner">rZzJfqAsXk6oml4M7O8i9wAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLClassDiagramView" guid="zbmLaxPBQUOBDUHwAACz3AAA">
+<XPD:REF name="Diagram">zQePzn7dgEOHzlzNhGKiDgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:ATTR name="#OwnedElements" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedElements[0]" type="UMLSubsystem" guid="tAaWOZCKQEuZXgOBfvDAPwAA">
+<XPD:ATTR name="Name" type="string">Subsystem1</XPD:ATTR>
+<XPD:REF name="Namespace">rZzJfqAsXk6oml4M7O8i9wAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[3]" type="UMLModel" guid="28BPj0etK0iOJ7+mHB5urgAA">
+<XPD:ATTR name="Name" type="string">Implementation Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">implementationModel</XPD:ATTR>
+<XPD:REF name="Namespace">H0/lv4BKwkuxuNjHqRrogAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLComponentDiagram" guid="/7U86x5U602F3ZhQN+ruPQAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLComponentDiagramView" guid="nR1QlagMCkitlmArWBqqvAAA">
+<XPD:REF name="Diagram">/7U86x5U602F3ZhQN+ruPQAA</XPD:REF>
+<XPD:ATTR name="#OwnedViews" type="integer">15</XPD:ATTR>
+<XPD:OBJ name="OwnedViews[0]" type="UMLComponentView" guid="WnsQDacPbEulqcQKIxIbTQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">50</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">175</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">144</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">AC69xcbL90Sxkz2VtDzq1wAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="W4Drld3fwEaRTInJfvshegAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="mz8+kMuK7kiNkMWfayGy0QAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">api</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="kncUB6UKhESMtvFaIUeYywAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="9oYcXP0VTkCxzrmqYJHlOAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="/gpPs5I2B0O3EUB3P9JF6gAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">AC69xcbL90Sxkz2VtDzq1wAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[1]" type="UMLComponentView" guid="On0Tjai8hEa2/tcQfPoPPwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">360</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">70</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">150</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Xrf56jtLbkKRQHxvQJ/bRwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="ikGc1kZ/a0OHY2jPOd0/LwAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="FIKZbAahak6PppbvedeJ1AAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">config-tool</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="CHJYi/81qUigD8p0HDVl1QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="E81QXQjm/EOB3Vq4s+N/kgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="mf71/idaiUSjMlAZUSKg8AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Xrf56jtLbkKRQHxvQJ/bRwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[2]" type="UMLComponentView" guid="Ng0E9dNi10CyzQjmzx9/WAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">370</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">175</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">142</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">4VGVXLeTr0GlvdaMhFMgNgAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="2PrCvFVqKkOT7oRDNvWCpgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="+NeQrI7ZqEC7Ev5RQz45LAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">config</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="bbY1BaM+hkG4Qf4UBWx1WQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="2KWv4eHdUEy0xu2Fiq46BQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="+Q81WRexMkiGF5daae/DgwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">4VGVXLeTr0GlvdaMhFMgNgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[3]" type="UMLComponentView" guid="lol5NhFjXEmsYPvtFbQZbAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">250</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">275</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">128</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">gOJiHSuPlEGbKY0bsgHO9gAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="AO344DlF10SypCX6OD0T1AAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="3oO6+B1PdEaNENxWJWXGYAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">pvm</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="Ci0kZ1cMu0CSk8qI9esGpwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="gZIFYnwipUysyW8MV5lDGwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="aoCO/hyFMkKARt/9kQQUXwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">gOJiHSuPlEGbKY0bsgHO9gAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[4]" type="UMLComponentView" guid="jq6n9pgoMUiIhSoOZnpaSwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">105</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">535</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">122</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">ofAHP9PTQEObIGwpCnaC1gAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="mBMZyWEYeEuu/3Nx1FaxKAAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="9p4qjmWUp06cv4Kbu0KTLQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">examples</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="y+LEh5c4T0W+7me5vf2BRwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="V4bzUmH/XEOclyWqJHd4+QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="Niern+2LakWuCvfjAfZOjAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">ofAHP9PTQEObIGwpCnaC1gAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[5]" type="UMLComponentView" guid="1jPegHR43UqMlFNhjPItXwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">250</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">535</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">163</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">9rRH9lp/10WLotkyvJ8bcQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="oeiK79JTgEqDEH02dbD9dgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="bQO94cz4nEGcOW8ubfon/wAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">test-db</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="NYVmw/vfI0KpJomKfEj2dwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="i4gwbQ2IAEey+8dqmot7xAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="cCkEgjvrTkW0UC83HdvDuAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">9rRH9lp/10WLotkyvJ8bcQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[6]" type="UMLComponentView" guid="YRvxVpeSJ06PIlC2SqJ3zwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">240</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">340</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">146</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">ZqzESRJ9bk6QJLH4xCkzLAAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="qOpjGnSrvkWe9/ugDdlJaAAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="Iz5lGIL1yUOz8RApBDR37gAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jpdl</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="fUdzNm9P5k6rJE+x+uIEwAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="ZetGvJLANkaby13j/Bqw3AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="TYKCNi0PZEKnlpUKL9kgKQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">ZqzESRJ9bk6QJLH4xCkzLAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[7]" type="UMLComponentView" guid="pf2iVGSMSEiOfdH8UJZp4wAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">890</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">143</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">RSKD7L1zQU6EsCg29QM6DQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="7G2NzZsYD068fC9HnFe/9gAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="YrUonWmJD0S0bgD3LmH/YAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">db</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="hco9mXHlekKbKqipRyWuyAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="tx5EJIStX0a9V5gqdyUntgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="IlPptS6Hs0qGKOks8SgzkAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">RSKD7L1zQU6EsCg29QM6DQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[8]" type="UMLComponentView" guid="ctBncZWN50KNja9rSEXeXwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">785</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">360</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">128</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">64ggzH/0DUuSLiYJybsobQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="14zozBsdSUGi6anl/OVnvgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="8xNKBzZn1U+dvZ6ed2rLFAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">distro</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="nyq9/KOzOEeCgsh2qCb9IQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="ip75X4ZNcUm7swCSCCNTfwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="Qg9mef20skOHArm1GgfHAAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">64ggzH/0DUuSLiYJybsobQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[9]" type="UMLComponentView" guid="ZUARE3ZbnUWRrxOjcnOvagAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">210</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">175</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">144</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">GSfiUKrqpkeZzbJ35t+SoQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="jesHK2GW1EKAK9TD0YBT9gAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="jD4z6LGMCkuR7+T3uZRHiQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">log</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="j9bnJy6oRk6RapfjL47AuAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="EjXuO5nTOUaAnHrOHxRRHgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="6qyayXOQPkSbOTeDtJjzIQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">GSfiUKrqpkeZzbJ35t+SoQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[10]" type="UMLComponentView" guid="hEzkGinSiUOZgNyvFngFLgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">725</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">150</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">L1HbHr28zkCo72gPiw2ZUwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="GRRA54elFkarf6R53b0p4QAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="yZ5f7Brxu0yyuiFXBukf6AAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">userguide</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="qrTk4QW240aiXjvca4td0wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="Cv0Q0wjNCEGFcD11AC1O8QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="RErj7cwxSUSst2mV37avegAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">L1HbHr28zkCo72gPiw2ZUwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[11]" type="UMLComponentView" guid="0gLvnIhR9U6rv3ONDdanDQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">820</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">210</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">142</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">tz8Be9YUaUKYaE0LwdrR/wAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="2+BZ8o8B30SkOgOax1EKlgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="4k2d4BnOF0aP1PlIvvNZTgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">devguide</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="ljbRUsmPc0K0EBM7T211yQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="wbCB8oWR6kmbelQ/aLUwpgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="DyMsya8aMEyuzM8gE6DKhAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">tz8Be9YUaUKYaE0LwdrR/wAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[12]" type="UMLComponentView" guid="FEzltrpWJ06Ui0qKYX/ywQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">435</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">535</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">128</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">lVhN6s4HcUqpNV2WO9FNlgAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="8Zp0TymXQUWPRTtvwGwK1QAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="vBSZ5syurUS1S/iO8phMWgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">test-load</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="+C/UgwKHjUWEeo18qOGsowAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="km8Ua9c0uE6DyxQKem4aBwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="py/vEtuT+kyD2FzxNopAKgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">lVhN6s4HcUqpNV2WO9FNlgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[13]" type="UMLComponentView" guid="EDekFyNEB0Ko4SWI84aIsgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">465</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">400</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">122</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">eedStDfblUCexk9A8j5dUQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="ODTo/fhZxUmNLzurL2NVkgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="9HRTE51qfkadD9k/9VVV8gAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">enterprise</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="LJpge2hzdkCKMb/F9O9bgQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="z31BLqiiSUWBq67CPEfteAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="DlXA5TPINkmmaUOoZ74GPgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">eedStDfblUCexk9A8j5dUQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[14]" type="UMLComponentView" guid="JjU9LqP1gkqxaoq97rPGdQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">640</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">210</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">163</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">UZuNTH/KL0q8CfQZgbXarwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="rRFSoc3ncU+9/leUxeRg+QAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="JksLo8Pk70uPzclIrXymrgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">integration</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="9NFt/pPVl0ysosB496U2LQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="AsWnDTwm4kGUQSq1hWzF0wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="HA0OWWzVskC72+EFTIjTLQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">UZuNTH/KL0q8CfQZgbXarwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:ATTR name="#OwnedElements" type="integer">15</XPD:ATTR>
+<XPD:OBJ name="OwnedElements[0]" type="UMLComponent" guid="AC69xcbL90Sxkz2VtDzq1wAA">
+<XPD:ATTR name="Name" type="string">api</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">WnsQDacPbEulqcQKIxIbTQAA</XPD:REF>
+<XPD:REF name="Views[1]">/gpPs5I2B0O3EUB3P9JF6gAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[1]" type="UMLComponent" guid="Xrf56jtLbkKRQHxvQJ/bRwAA">
+<XPD:ATTR name="Name" type="string">config-tool</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">On0Tjai8hEa2/tcQfPoPPwAA</XPD:REF>
+<XPD:REF name="Views[1]">mf71/idaiUSjMlAZUSKg8AAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[2]" type="UMLComponent" guid="4VGVXLeTr0GlvdaMhFMgNgAA">
+<XPD:ATTR name="Name" type="string">config</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">Ng0E9dNi10CyzQjmzx9/WAAA</XPD:REF>
+<XPD:REF name="Views[1]">+Q81WRexMkiGF5daae/DgwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[3]" type="UMLComponent" guid="gOJiHSuPlEGbKY0bsgHO9gAA">
+<XPD:ATTR name="Name" type="string">pvm</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">lol5NhFjXEmsYPvtFbQZbAAA</XPD:REF>
+<XPD:REF name="Views[1]">aoCO/hyFMkKARt/9kQQUXwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[4]" type="UMLComponent" guid="ofAHP9PTQEObIGwpCnaC1gAA">
+<XPD:ATTR name="Name" type="string">examples</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">jq6n9pgoMUiIhSoOZnpaSwAA</XPD:REF>
+<XPD:REF name="Views[1]">Niern+2LakWuCvfjAfZOjAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[5]" type="UMLComponent" guid="9rRH9lp/10WLotkyvJ8bcQAA">
+<XPD:ATTR name="Name" type="string">test-db</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">1jPegHR43UqMlFNhjPItXwAA</XPD:REF>
+<XPD:REF name="Views[1]">cCkEgjvrTkW0UC83HdvDuAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[6]" type="UMLComponent" guid="ZqzESRJ9bk6QJLH4xCkzLAAA">
+<XPD:ATTR name="Name" type="string">jpdl</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">YRvxVpeSJ06PIlC2SqJ3zwAA</XPD:REF>
+<XPD:REF name="Views[1]">TYKCNi0PZEKnlpUKL9kgKQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[7]" type="UMLComponent" guid="RSKD7L1zQU6EsCg29QM6DQAA">
+<XPD:ATTR name="Name" type="string">db</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">pf2iVGSMSEiOfdH8UJZp4wAA</XPD:REF>
+<XPD:REF name="Views[1]">IlPptS6Hs0qGKOks8SgzkAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[8]" type="UMLComponent" guid="64ggzH/0DUuSLiYJybsobQAA">
+<XPD:ATTR name="Name" type="string">distro</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">ctBncZWN50KNja9rSEXeXwAA</XPD:REF>
+<XPD:REF name="Views[1]">Qg9mef20skOHArm1GgfHAAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[9]" type="UMLComponent" guid="GSfiUKrqpkeZzbJ35t+SoQAA">
+<XPD:ATTR name="Name" type="string">log</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">ZUARE3ZbnUWRrxOjcnOvagAA</XPD:REF>
+<XPD:REF name="Views[1]">6qyayXOQPkSbOTeDtJjzIQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[10]" type="UMLComponent" guid="L1HbHr28zkCo72gPiw2ZUwAA">
+<XPD:ATTR name="Name" type="string">userguide</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">hEzkGinSiUOZgNyvFngFLgAA</XPD:REF>
+<XPD:REF name="Views[1]">RErj7cwxSUSst2mV37avegAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[11]" type="UMLComponent" guid="tz8Be9YUaUKYaE0LwdrR/wAA">
+<XPD:ATTR name="Name" type="string">devguide</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">0gLvnIhR9U6rv3ONDdanDQAA</XPD:REF>
+<XPD:REF name="Views[1]">DyMsya8aMEyuzM8gE6DKhAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[12]" type="UMLComponent" guid="lVhN6s4HcUqpNV2WO9FNlgAA">
+<XPD:ATTR name="Name" type="string">test-load</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">FEzltrpWJ06Ui0qKYX/ywQAA</XPD:REF>
+<XPD:REF name="Views[1]">py/vEtuT+kyD2FzxNopAKgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[13]" type="UMLComponent" guid="eedStDfblUCexk9A8j5dUQAA">
+<XPD:ATTR name="Name" type="string">enterprise</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">EDekFyNEB0Ko4SWI84aIsgAA</XPD:REF>
+<XPD:REF name="Views[1]">DlXA5TPINkmmaUOoZ74GPgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[14]" type="UMLComponent" guid="UZuNTH/KL0q8CfQZgbXarwAA">
+<XPD:ATTR name="Name" type="string">integration</XPD:ATTR>
+<XPD:REF name="Namespace">28BPj0etK0iOJ7+mHB5urgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">JjU9LqP1gkqxaoq97rPGdQAA</XPD:REF>
+<XPD:REF name="Views[1]">HA0OWWzVskC72+EFTIjTLQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[4]" type="UMLModel" guid="1AZZwlw9K0++UP00zbPhHgAA">
+<XPD:ATTR name="Name" type="string">Deployment Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">deploymentModel</XPD:ATTR>
+<XPD:REF name="Namespace">H0/lv4BKwkuxuNjHqRrogAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLDeploymentDiagram" guid="aa0njB1hHUaFP0Wb0wFDMAAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">1AZZwlw9K0++UP00zbPhHgAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLDeploymentDiagramView" guid="+INV8pPcdkaC2O8aAHCUCwAA">
+<XPD:REF name="Diagram">aa0njB1hHUaFP0Wb0wFDMAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:BODY>
+</XPD:PROJECT>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.dependencies.uml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.dependencies.uml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/docs/module.dependencies.uml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2048 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<XPD:PROJECT xmlns:XPD="http://www.staruml.com" version="1">
+<XPD:HEADER>
+<XPD:SUBUNITS>
+</XPD:SUBUNITS>
+<XPD:PROFILES>
+<XPD:PROFILE>ERD</XPD:PROFILE>
+<XPD:PROFILE>UMLStandard</XPD:PROFILE>
+</XPD:PROFILES>
+</XPD:HEADER>
+<XPD:BODY>
+<XPD:OBJ name="DocumentElement" type="UMLProject" guid="M0HBaTtrG027mqtMSnY3lAAA">
+<XPD:ATTR name="Title" type="string">Untitled</XPD:ATTR>
+<XPD:ATTR name="#OwnedElements" type="integer">5</XPD:ATTR>
+<XPD:OBJ name="OwnedElements[0]" type="UMLModel" guid="ZcLjKs94GEmzN5930ssSPgAA">
+<XPD:ATTR name="Name" type="string">Use Case Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">useCaseModel</XPD:ATTR>
+<XPD:REF name="Namespace">M0HBaTtrG027mqtMSnY3lAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLUseCaseDiagram" guid="FX3DwqbM70u4vbJC4C48fgAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">ZcLjKs94GEmzN5930ssSPgAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLUseCaseDiagramView" guid="urJ6h6tuFk+ieNvxoxYXWAAA">
+<XPD:REF name="Diagram">FX3DwqbM70u4vbJC4C48fgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[1]" type="UMLModel" guid="o/32Aa+hF0CSHv32iabYggAA">
+<XPD:ATTR name="Name" type="string">Analysis Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">analysisModel</XPD:ATTR>
+<XPD:REF name="Namespace">M0HBaTtrG027mqtMSnY3lAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLClassDiagram" guid="JnJTQ5A6o0aasS0HD6JfvgAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:ATTR name="DefaultDiagram" type="boolean">True</XPD:ATTR>
+<XPD:ATTR name="DiagramType" type="string">RobustnessDiagram</XPD:ATTR>
+<XPD:REF name="DiagramOwner">o/32Aa+hF0CSHv32iabYggAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLClassDiagramView" guid="edmEuK9Wcku7KXiRyazQ3wAA">
+<XPD:REF name="Diagram">JnJTQ5A6o0aasS0HD6JfvgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[2]" type="UMLModel" guid="mNlhQxH3RkCjxaH3VQBTwQAA">
+<XPD:ATTR name="Name" type="string">Design Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">designModel</XPD:ATTR>
+<XPD:REF name="Namespace">M0HBaTtrG027mqtMSnY3lAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">3</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLClassDiagram" guid="rqiG/UwkJUCLz+nGyU5PjQAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:ATTR name="DefaultDiagram" type="boolean">True</XPD:ATTR>
+<XPD:REF name="DiagramOwner">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLClassDiagramView" guid="BMzOBvSBnEOZr5NIHlMcNQAA">
+<XPD:REF name="Diagram">rqiG/UwkJUCLz+nGyU5PjQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedDiagrams[1]" type="UMLComponentDiagram" guid="P3SoCbzoDE6hYcPIUEpSNAAA">
+<XPD:ATTR name="Name" type="string">jBPM modules</XPD:ATTR>
+<XPD:REF name="DiagramOwner">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLComponentDiagramView" guid="Ly6NXYaRhEOxVqp3jH5kgQAA">
+<XPD:REF name="Diagram">P3SoCbzoDE6hYcPIUEpSNAAA</XPD:REF>
+<XPD:ATTR name="#OwnedViews" type="integer">36</XPD:ATTR>
+<XPD:OBJ name="OwnedViews[0]" type="UMLPackageView" guid="7gpcdFJdLEyTK/UY/CuWfgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Courier New</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">70</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">505</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">160</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">121</XPD:ATTR>
+<XPD:REF name="Model">5TvqnjB1jkG25vsTu+A0XgAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="dp6Ei5LmwUK7Gm5YrkOB/AAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="9V6aoWmzYUa5eJ5J7tuQ6QAA">
+<XPD:ATTR name="Text" type="string">jbpm-enterprise.jar</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="O418Tkih30KuAO1OjTzBpwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="i2v7x6Lv70WJgaV+ye6mVgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[1]" type="UMLPackageView" guid="/jMRysCRzEmjLJZ6tATbkQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Courier New</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">65</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">100</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">356</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">366</XPD:ATTR>
+<XPD:REF name="Model">tfl5FprffUy9SE+AmL+zpQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="NlT0a5NumEyWnqIha2n/8QAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="tSximKu16E6V7ne50DVjiAAA">
+<XPD:ATTR name="Text" type="string">jbpm.jar</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="e72MsJQj6k2sG8WAtKlQDQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="H230sC287kyWKm2nVcSdOAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[2]" type="UMLComponentView" guid="92NqScYMQkimi4w+8NuFxQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">110</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">135</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">89</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="hNVtOPEDiUeVRTg/RcehGgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="AetjncTHz06flInOFSfKKgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-api</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="SZvQKFveJU2S5ziqmLcVWQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="3uadsdSK0UmT98vDb/ntDwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="AeLQpgARN0yLiqeqynOkNwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[3]" type="UMLComponentView" guid="kL0ifBLH8k2M0PxjEkWXUwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">103</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">97</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="Ok6AsWY7DEq0NFgv+JRDPgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="vPbxEqriI0e98TCIONAyyAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-pvm</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="HAB7fQEI50q4TzlzXzW7UQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="j85WAOLPAEqvYRRSrnUu4AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="MVCD6NUwQU+Cr85hgNA9mQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[4]" type="UMLComponentView" guid="Gv5w/Hcm0k61rZhkNLQGtQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">170</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">330</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">115</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">AXGT6sG/YkWAzbne6BYH9gAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="KH2NYmALaE2miHbPQIBjIwAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="Vz86bqynM0WOes3ya36TbAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-task</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="8RsmC9BcakGcQzGLqVxtawAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="nvEuo4AFxUqhV41L7pziRAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="4bzO0l5v00ubDSwDgFvI0AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">AXGT6sG/YkWAzbne6BYH9gAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[5]" type="UMLComponentView" guid="0Vw/eC4690OaqgqTJ+R97QAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">80</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">560</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">137</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">rN2k9cfQlk2UzNSPqqPOegAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="y6tXNO0XVEmE4S8cz/JZzwAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="lLL3Dxhy90WRu0xdJIqkRQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-enterprise</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="5EluPNcI202RBl/XSRW98wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="oHSYGF85QEqQHalhSVALeAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="4QPtyjldhUunEN0gz7mavgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">rN2k9cfQlk2UzNSPqqPOegAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[6]" type="UMLComponentView" guid="WMFeUrRaqkmSFaxxGYhliQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFB9</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">610</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">132</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">MsVxfbvaTkidMyurdVALEAAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="w5f7JGC/hUGxNQi+v+vWNwAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="mV5ih0PXoEGKpTUElnOFjQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-examples</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="Olt0tXUQtkW43vPgM8V5bQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="Mk/nzCXtFkWRqxW0lhpheQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="3eg6/QNO/0a4Nf/fsXj1ogAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">MsVxfbvaTkidMyurdVALEAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[7]" type="UMLComponentView" guid="os/ZpLf6E0C9OkWrF0aPPwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFB9</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">555</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">131</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">kwDBvXNU5ECCKv4hB67TCgAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="qQbpeM449UyU4IOJYERcSAAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="nuibYU02nECZurOfQ/kMkQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-test-db</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="MkHNaxTU3kGjuN1xwWLkTgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="4EUyMenm9EuDwnkS1oNuXwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="hu1Gdh1EOkCRSVJ0NRuvGAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">kwDBvXNU5ECCKv4hB67TCgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[8]" type="UMLComponentView" guid="m19PobYTBkqfijmLqUHsGgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFB9</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">75</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">650</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">129</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Ti77WPS+TES4vmhJCWTIqAAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="Pi3oXqbiR0u8yHfBhG0migAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="6nzvH5QoJUOfmN/jJRNqZgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-test-pojo</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="S3yb9QEmyUG/e3NjCHY6lgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="Wc2ruRE/ZUSwpSpa6zOqPAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="+qeK+VfnAE+tgn+8gEMVYQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Ti77WPS+TES4vmhJCWTIqAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[9]" type="UMLComponentView" guid="uaMGdUZ3rUGciJaxG5vJyAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">105</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">400</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">94</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="dJnh7tU3dU2NiM5LIrSRHQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="mdcfy/GGAEywA6t1vCcEfQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-jpdl</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="hADb2E/qi06/J/Ghg6tCSwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="J/haEcS0UUqdTLevF8v2dwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="iVAA7IWP+Uy7KPqFyfmNxAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[10]" type="UMLDependencyView" guid="s0Uo/LoLqEy96cpUicZxmgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">152,260;154,179</XPD:ATTR>
+<XPD:REF name="Model">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+<XPD:REF name="Head">92NqScYMQkimi4w+8NuFxQAA</XPD:REF>
+<XPD:REF name="Tail">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="RfGkm6kG5UqSt9kGBV5sqQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="30JI6+M0hU+PaPHQ6RlApQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="fx/mR46vbEWcerX36xx2fgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[11]" type="UMLDependencyView" guid="tL936vHTiUKi/EO3eo4OCAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">203,330;175,304</XPD:ATTR>
+<XPD:REF name="Model">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+<XPD:REF name="Head">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:REF name="Tail">Gv5w/Hcm0k61rZhkNLQGtQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="YAsDk/oCHUWj2ORqyoQ85QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="7ksnXM1WOEqYib1PUzyAEgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="2OX6rux8gUmn4AU/qguwTgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[12]" type="UMLDependencyView" guid="myBpvTwWOEC8kka4yXiDxgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">151,400;151,304</XPD:ATTR>
+<XPD:REF name="Model">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+<XPD:REF name="Head">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:REF name="Tail">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="O/1gx6vDG0Wsia2+QoEb5AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="L4IP3JCta0qUlai/mtI+sgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="n7Z3ZpAHB0mHKJYlsw3VhgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[13]" type="UMLDependencyView" guid="FSrDLZ9lC06DMhXgXGZUQwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">93,560;55,545;55,340;115,304</XPD:ATTR>
+<XPD:REF name="Model">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+<XPD:REF name="Head">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:REF name="Tail">0Vw/eC4690OaqgqTJ+R97QAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="B9vPDM3UQE2zvxro+ufIDQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="6VDyiYPftEWH+jPwMVy1XAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="yCBx070VyUSE7L6mIiqZ6gAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[14]" type="UMLDependencyView" guid="SSw1SKkmZ0CoRq1XSUXS/QAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">260,622;245,620;245,490;181,444</XPD:ATTR>
+<XPD:REF name="Model">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+<XPD:REF name="Head">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:REF name="Tail">WMFeUrRaqkmSFaxxGYhliQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="ddhra6UTAkGmNgl0BZNyDAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="qx+nvFgOpEmfpqN0d8S+ygAA">
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-3,3733085417589</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">21,9317121994613</XPD:ATTR>
+<XPD:REF name="Model">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="eH/awcIp+k6tEkVnEeqKmQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[15]" type="UMLDependencyView" guid="Bld8RQIiYUaX3NAHOTSySwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">260,571;245,570;245,490;181,444</XPD:ATTR>
+<XPD:REF name="Model">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+<XPD:REF name="Head">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:REF name="Tail">os/ZpLf6E0C9OkWrF0aPPwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="xXfl6/dCXEq7ACI9opVt1AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="HXVe8usV8kO191DDCVY/WgAA">
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-0,259331685062154</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">50,6951674225463</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">&lt;&lt;runtime&gt;&gt;</XPD:ATTR>
+<XPD:REF name="Model">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="/E6l3m6OrkOq2pG928iwfQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[16]" type="UMLDependencyView" guid="LM7aM3xEFkSvbz7d7R2kSwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">81,650;55,640;55,340;115,304</XPD:ATTR>
+<XPD:REF name="Model">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+<XPD:REF name="Head">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:REF name="Tail">m19PobYTBkqfijmLqUHsGgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="/vBKMrZ33kGqCUGezbK4iQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="Ns1su3Qoj0Sgg5SOZhlpXwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="zU4Xr4puz0KAOt5mXy8wLwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[17]" type="UMLComponentView" guid="NR+DCad5w0aNy08gEmohjgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFB9</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">265</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">500</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">128</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">ldE/OPmI/UqAVOba04r45QAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="YT8uROkxlU6fR+/+ywr8ZgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="xy0/+b4LikOWhOuXXUWRYAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-test-load</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="6pAl28dfVU2hJFVh4Lu9CwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="yXpIz+IykEe/utW91ht2+AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="XCuwduuWdEurAe/qjiwuugAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">ldE/OPmI/UqAVOba04r45QAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[18]" type="UMLDependencyView" guid="XLpkZbX67E2e103suf5FgQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">265,517;245,515;245,490;181,444</XPD:ATTR>
+<XPD:REF name="Model">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+<XPD:REF name="Head">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:REF name="Tail">NR+DCad5w0aNy08gEmohjgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="8v1Xp2NxzEe4NBOz8qr6XwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="JInfIiF+yUWGEwRuC/fBbQAA">
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">3,54584433817258</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">26,3058928759318</XPD:ATTR>
+<XPD:REF name="Model">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="bW5E7jctskGxAqy4fBJsUwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[19]" type="UMLComponentView" guid="3fKHNq8HbU6ne7o9d0+49QAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00E8E8E8</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">55</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">25</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">111</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="WXTKL20/cUmhs3vDeDG3yQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="EqTeKdoLrkqBqfaass3EGgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">hibernate</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="IEv78twSK02SPTRCpcIJIQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="dV/3lfOaC0GhaLrfH4JtZwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="rn0f5HPHZEO/XyvSLpN4JQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[20]" type="UMLComponentView" guid="1ltfrrUBG0q0sFN/n22amgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">230</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">260</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">131</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="QhSleJX7IUih8ZGA9w7ViAAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="7n54pxDLN0ScKFNBaHBXSgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-test-base</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="KYsH/DrTJU21Bh2z4w0HLAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="HhehzkGoK0GjmrE9tGwepQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="R35cRSfTk0qzkqf1Cx0oIgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[21]" type="UMLComponentView" guid="rbLmK4jPbkGOYpeFKoIgSgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00E8E8E8</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">200</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">25</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">96</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">fTUNxe8WmEWd/zpINe6SCQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="0tmQeYTER066wYrhKHd8WQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="9ulaPsEWGkG22Sm4nJSN3gAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">log4j</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="I3DoTJmWG0CRUhErt3BY7QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="vwGrxbtDUkeuhP/I/JZ2kAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="kuQZh6R0rkGGOBYMpnDGTgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">fTUNxe8WmEWd/zpINe6SCQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[22]" type="UMLDependencyView" guid="Qn9aZDlQhUqj/NwTUNxQVgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">129,260;80,210;80,80;90,69</XPD:ATTR>
+<XPD:REF name="Model">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+<XPD:REF name="Head">3fKHNq8HbU6ne7o9d0+49QAA</XPD:REF>
+<XPD:REF name="Tail">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="+YwOZrWnJ0iToIs8PcSFmgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="T/p+j3dspE+BuSZgCcwALQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="B0y+v7Uuq0qyySQsnWwi/QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[23]" type="UMLComponentView" guid="okCq8TeiSkSTXxYO7BUdpgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00E8E8E8</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">330</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">25</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">96</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">q2sDsF5njUmjPrBEjAya2AAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="ksBtCHhzAEWyZ6uFqMVC2AAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="/KdG7NUAQ0qd4rQpRgCjgwAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">junit</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="iVLt93/yIUyVINZj/dj3tAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="5gasLVY4G0mg2XCmHIsSxwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="K2kHsEL97kSakGq0Z4Oo1AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">q2sDsF5njUmjPrBEjAya2AAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[24]" type="UMLDependencyView" guid="0lxWtHQGbk6+7v1xJ2HoggAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">333,260;385,230;385,120;379,69</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+<XPD:REF name="Head">okCq8TeiSkSTXxYO7BUdpgAA</XPD:REF>
+<XPD:REF name="Tail">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="FEHEASbMvEecK7YLlj8FEgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="GL/w4QuYME6cNf6/xBvuFwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="n/utdDZGREe1l2HwVBsJEAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[25]" type="UMLDependencyView" guid="BsUPUXy7aEiLZWpBGtzAmAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">333,260;385,230;385,115;292,69</XPD:ATTR>
+<XPD:REF name="Model">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+<XPD:REF name="Head">rbLmK4jPbkGOYpeFKoIgSgAA</XPD:REF>
+<XPD:REF name="Tail">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="WG5xv9mWSUOaQ+41Ydod6AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="dKb6ieet20GTJwk4JpHUcgAA">
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-5,60702717702113</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">110,258786497948</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">&lt;&lt;provided&gt;&gt;</XPD:ATTR>
+<XPD:REF name="Model">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="L9NTVtMZDUWvWhnCi6zCSgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[26]" type="UMLDependencyView" guid="7kms5wuBdkWkue3i1hjJJQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">175,400;203,374</XPD:ATTR>
+<XPD:REF name="Model">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+<XPD:REF name="Head">Gv5w/Hcm0k61rZhkNLQGtQAA</XPD:REF>
+<XPD:REF name="Tail">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="Yf1Ki7LFlECsofgw9t+nvwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="Nm/Ui3SGaECRJvG1zXtstAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="rxiJCsXKH0y8DgMwT4PT0wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[27]" type="UMLDependencyView" guid="HNZBvjwK4kaQw7soGOvO4AAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">391,630;405,630;405,355;328,304</XPD:ATTR>
+<XPD:REF name="Model">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+<XPD:REF name="Head">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:REF name="Tail">WMFeUrRaqkmSFaxxGYhliQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="RxymIYGCi0S3gabovkdxRAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="dqp7/VGztUSzsDwhpZuM5AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="m6cMhO2uaky1wLf4+FFx6AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[28]" type="UMLDependencyView" guid="NE4bCZ7gxUCx/KY6oJHiPQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">392,520;405,520;405,355;328,304</XPD:ATTR>
+<XPD:REF name="Model">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+<XPD:REF name="Head">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:REF name="Tail">NR+DCad5w0aNy08gEmohjgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="c+ULx/nPvU6EuUCYyIMszQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="ITukSZeua0SjzzwJpa35AQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="LBlYkAzvKkOCB1Nbm5KLNQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[29]" type="UMLDependencyView" guid="syRWy5PzLEC+E3RAHAo5lAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">390,575;405,575;405,355;328,304</XPD:ATTR>
+<XPD:REF name="Model">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+<XPD:REF name="Head">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:REF name="Tail">os/ZpLf6E0C9OkWrF0aPPwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="M7dffO/Yi0GlN8g1/aVovAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="UZ6I3qySg0WUjGoLzuAwLQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="v86mF5cwLEWXIf3u3GESOwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[30]" type="UMLDependencyView" guid="17AtBO6XMUe0t5mnVGyL7wAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">325,260;365,230;365,150;220,150;198,152</XPD:ATTR>
+<XPD:REF name="Model">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+<XPD:REF name="Head">92NqScYMQkimi4w+8NuFxQAA</XPD:REF>
+<XPD:REF name="Tail">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="9ryGXy1bBke2ZPu/V6d60AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="TYGxamv2L06bUrGTzI/NSAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="n7zKKP1cx0eE2yXcDGOmcgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[31]" type="UMLComponentView" guid="9h9tg46+zEqxK6eZGIVN3wAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">250</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">185</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">89</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">cmkpYh9kWUe54vVNch7vwgAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="Fv0gvo7OiUW8zm+HtL8LzQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="kvWORg0xAUWfBHC6t/xsFAAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-log</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="NYj3JOL5F060KpJuxxpElQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="4fMmSD4+VEGFWcMijsn2RgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="rSdIyFahOEWLQoXeMSWyjAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">cmkpYh9kWUe54vVNch7vwgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[32]" type="UMLDependencyView" guid="gB4b9zqn70C8L8FAE4pDcQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">295,260;294,229</XPD:ATTR>
+<XPD:REF name="Model">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+<XPD:REF name="Head">9h9tg46+zEqxK6eZGIVN3wAA</XPD:REF>
+<XPD:REF name="Tail">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="y24khAfz7EC/71Rxpg12bQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="sW0ozTYflEeMg8SJLoeeyQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">2,77877131294639</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">4,12310562561766</XPD:ATTR>
+<XPD:REF name="Model">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="kTqyC2HCIESNae5f5EwDTwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[33]" type="UMLDependencyView" guid="q+vX8HioM0WwJjGSnWU38wAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">193,260;252,229</XPD:ATTR>
+<XPD:REF name="Model">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+<XPD:REF name="Head">9h9tg46+zEqxK6eZGIVN3wAA</XPD:REF>
+<XPD:REF name="Tail">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="mJGC4mEENUGraL5xWLn7+AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="AyPIxu591UG5ecl0zDwdcQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-3,49137231079909</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">16,4924225024706</XPD:ATTR>
+<XPD:REF name="Model">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="crCid3eacEuEx3qLQq63gwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[34]" type="UMLDependencyView" guid="Z+YcEOR4XEuHSRX5lIjunQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">199,282;230,282</XPD:ATTR>
+<XPD:REF name="Model">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+<XPD:REF name="Head">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:REF name="Tail">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="8QvwB8UXG0ODJa0n9HW83AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="CN6zyu45XUWna7JwqXyDSAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="iicoPDgFQ0qMQebeFzttaQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[35]" type="UMLDependencyView" guid="M29407aZXUuJm2P05+NgVgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">216,575;220,575;220,500;170,444</XPD:ATTR>
+<XPD:REF name="Model">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+<XPD:REF name="Head">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:REF name="Tail">0Vw/eC4690OaqgqTJ+R97QAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="rxUyd/KQiEKe50ZrgKXVsgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="iDzZrTOIVUeZoq5clonoOAAA">
+<XPD:ATTR name="FontSize" type="integer">9</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-5,8420051300339</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">39,8120584747888</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">&lt;&lt;test&gt;&gt;</XPD:ATTR>
+<XPD:REF name="Model">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="l6iyGMrOJUmJ0ciSj+X15AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedDiagrams[2]" type="UMLComponentDiagram" guid="taMwNEcyNEONZh4emW/4wwAA">
+<XPD:ATTR name="Name" type="string">User code dependencies</XPD:ATTR>
+<XPD:REF name="DiagramOwner">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLComponentDiagramView" guid="OQ2hnc3z9UuOqaRGwXm+pQAA">
+<XPD:REF name="Diagram">taMwNEcyNEONZh4emW/4wwAA</XPD:REF>
+<XPD:ATTR name="#OwnedViews" type="integer">15</XPD:ATTR>
+<XPD:OBJ name="OwnedViews[0]" type="UMLComponentView" guid="pIqdMybCfUuB4j3Wk72M2QAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">155</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">125</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">103</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="4ysCNRrdKEiUxBH8cUE0ugAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="mf0fvdKtbkiK+XqUsJCtiwAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-api</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="s4NrFW+lx0ie54gyMKk8BwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="cg4FDBJnVUyhUEteWFW5TAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="Q5dUZHwFrk+7XYs5gpsDiQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[1]" type="UMLComponentView" guid="mpyVwOw4aEKV1rTZE6eGmQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">45</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">205</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">109</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="Vm1aBXjMRk+s2t801B2NhAAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="QdJdKZe3tkqvoL8jhlnKNQAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-jpdl</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="UcX7w75kNkqSz7O1aTzMGgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="7VDOZsZ8XEiE4o+gBaweeQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="73rwWTh1HEiMGKg/kf7WdgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[2]" type="UMLComponentView" guid="S26IZQGgbEuW/e8i+JwfJgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00E8E8E8</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">50</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">30</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">108</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="uGlzxfIUuEWVFQ967SAiPwAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="5Q7eyIPoak+rMFjdhbnd+AAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">hibernate</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="wui/oBMdcECyN7rnDhIrLgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="1HTUwsZ8kE2gAiHOuPbmWgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="moDyp4GQHU6RdoYk/xQofwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[3]" type="UMLComponentView" guid="shKyc/zYFEm70ertpvs0lgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">305</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">125</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">158</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="5e/lAdlkPU+jtSy3vYI+xgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="gvtAXmGC7kG6TAAfLHKNggAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">jbpm-test-base</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="BSbmozjTL0mIAmlOWk8sugAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="zqH+YXhfuUqSociNdHGQXAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="QCVHQ0YN9EO40bP5th/AcAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[4]" type="UMLComponentView" guid="CIpyZE96i0iOlRAJJmbidQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$008080FF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">145</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">291</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">118</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">46</XPD:ATTR>
+<XPD:REF name="Model">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="mnDhlyC830yaCsN/qhHLJQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="2/bTOrkX+EmwMPa6wmy31wAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">client-code</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="uyuj/PlJuUWR9W9pFZho0QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="yO6VqW5ulky2nmOYtCWi9wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="+oMi1PNRnUet4UvGOe+KNgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[5]" type="UMLDependencyView" guid="/fto29UmJke9UEPPg1dvCAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">203,291;206,169</XPD:ATTR>
+<XPD:REF name="Model">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+<XPD:REF name="Head">pIqdMybCfUuB4j3Wk72M2QAA</XPD:REF>
+<XPD:REF name="Tail">CIpyZE96i0iOlRAJJmbidQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="/Fw+ESyxNkmr9of7R0LEtwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="XHnuu2G6ZUqiQOcGfcfQhwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">4,81817989625563</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">13,6014705087354</XPD:ATTR>
+<XPD:REF name="Model">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="eFRlV6eG50GCkf6iWu6nCAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[6]" type="UMLDependencyView" guid="yGOyjwerWU+LDgRMqdhcDwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">176,291;125,249</XPD:ATTR>
+<XPD:REF name="Model">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+<XPD:REF name="Head">mpyVwOw4aEKV1rTZE6eGmQAA</XPD:REF>
+<XPD:REF name="Tail">CIpyZE96i0iOlRAJJmbidQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="UGyE7mW7+kqvsR13p6SzmQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="0PAiZlI0nkKMiWnrSeDbIwAA">
+<XPD:ATTR name="Alpha" type="real">0,389133018767367</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">9,21954445729289</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">&lt;&lt;runtime&gt;&gt;</XPD:ATTR>
+<XPD:REF name="Model">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="YsX9ulBWGUa9b3+dGsglXwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[7]" type="UMLDependencyView" guid="mV0lDADP50CyXt3p4NSh5AAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">383,295;383,169</XPD:ATTR>
+<XPD:REF name="Model">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+<XPD:REF name="Head">shKyc/zYFEm70ertpvs0lgAA</XPD:REF>
+<XPD:REF name="Tail">eXPgSONhSkKl6NGeLvs0+AAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="nL8zteNrTEaNdP0ORywPEQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="t7uW4qlY3EuUM02osTes4wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">4,66235770243218</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">31,1448230047949</XPD:ATTR>
+<XPD:REF name="Model">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="NqgLo30vAE2AgyFLA33V3QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[8]" type="UMLComponentView" guid="c6dWuci7PE6zGpeQ6NspuQAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00E8E8E8</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">335</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">30</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">96</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">q2sDsF5njUmjPrBEjAya2AAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="O2o1Kox+GUaI+FRSb4vasgAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="hEzTw7Jt0kWOK7C8reMbqgAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">junit</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="UYX2XXoXHUakutYdycWVSgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="SyRUo9MVaUCUJnuXD38CJAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="bx3wCLtuhEe3V7LN9SyewQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">q2sDsF5njUmjPrBEjAya2AAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[9]" type="UMLDependencyView" guid="JUwNsbz6vkC8Nz9vQN4mPwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">383,125;382,74</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+<XPD:REF name="Head">c6dWuci7PE6zGpeQ6NspuQAA</XPD:REF>
+<XPD:REF name="Tail">shKyc/zYFEm70ertpvs0lgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="wk9MB/ykpECEH7NCCgq5NQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="frgG4fBBwUyPlximUBmYSgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="sxIpqKrdnUGNrfiRZ0jvrwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[10]" type="UMLComponentView" guid="eXPgSONhSkKl6NGeLvs0+AAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$008080FF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Left" type="integer">305</XPD:ATTR>
+<XPD:ATTR name="Top" type="integer">295</XPD:ATTR>
+<XPD:ATTR name="Width" type="integer">158</XPD:ATTR>
+<XPD:ATTR name="Height" type="integer">45</XPD:ATTR>
+<XPD:REF name="Model">HymcrpkgrUanUlc3fpQZOAAA</XPD:REF>
+<XPD:OBJ name="NameCompartment" type="UMLNameCompartmentView" guid="1UmFqKOgAkGZC9GFq1WczQAA">
+<XPD:OBJ name="NameLabel" type="LabelView" guid="GQepRmZ1Sk+D7XyWimb8XwAA">
+<XPD:ATTR name="FontStyle" type="integer">1</XPD:ATTR>
+<XPD:ATTR name="Text" type="string">client-test-code</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="LabelView" guid="WW/xhM1ax0KBsLfm3SAQpAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="LabelView" guid="u1YM+UoVikua9/DynlievwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="ResidentCompartment" type="UMLResidentCompartmentView" guid="c/kRNfpHu063wsbGOAYjkQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:REF name="Model">HymcrpkgrUanUlc3fpQZOAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[11]" type="UMLDependencyView" guid="Tx3kQXcM80ugRN1WdblMDgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">305,315;262,314</XPD:ATTR>
+<XPD:REF name="Model">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+<XPD:REF name="Head">CIpyZE96i0iOlRAJJmbidQAA</XPD:REF>
+<XPD:REF name="Tail">eXPgSONhSkKl6NGeLvs0+AAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="5Ozobg/mM061Q00JA6a5kwAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="nplRFaFEj0aUfdQFEvcKlQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="os19kdxV30SP584fS08A4gAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[12]" type="UMLDependencyView" guid="XxzLJInR7kGT0tkOGUB5AgAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">100,205;103,74</XPD:ATTR>
+<XPD:REF name="Model">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+<XPD:REF name="Head">S26IZQGgbEuW/e8i+JwfJgAA</XPD:REF>
+<XPD:REF name="Tail">mpyVwOw4aEKV1rTZE6eGmQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="cRIQKwraNUO9IC4Hbe9o/QAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="MA65ojWaaUCvLzu4bx0X0wAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="N57lzUNqpkGH24TUZvAZIAAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[13]" type="UMLDependencyView" guid="Eh5CYhrY4kagmfN6HSXCWwAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">128,205;176,169</XPD:ATTR>
+<XPD:REF name="Model">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+<XPD:REF name="Head">pIqdMybCfUuB4j3Wk72M2QAA</XPD:REF>
+<XPD:REF name="Tail">mpyVwOw4aEKV1rTZE6eGmQAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="SqGHS/qu6EulEOUcYir9owAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="Cn23MthxIkuYYlzT6scB0AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="Ea+a/gpl9kGu+tVGLvTxEQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedViews[14]" type="UMLDependencyView" guid="RtA1l20tjkyB5rPxnuwkxAAA">
+<XPD:ATTR name="LineColor" type="string">clMaroon</XPD:ATTR>
+<XPD:ATTR name="FillColor" type="string">$00B9FFFF</XPD:ATTR>
+<XPD:ATTR name="FontFace" type="string">Verdana</XPD:ATTR>
+<XPD:ATTR name="FontSize" type="integer">11</XPD:ATTR>
+<XPD:ATTR name="Points" type="Points">305,147;257,147</XPD:ATTR>
+<XPD:REF name="Model">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+<XPD:REF name="Head">pIqdMybCfUuB4j3Wk72M2QAA</XPD:REF>
+<XPD:REF name="Tail">shKyc/zYFEm70ertpvs0lgAA</XPD:REF>
+<XPD:OBJ name="NameLabel" type="EdgeLabelView" guid="5mhew13G5Ey0i955ytoSIQAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="StereotypeLabel" type="EdgeLabelView" guid="tAgbMv3DnkWuHJjtwHkE1AAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">30</XPD:ATTR>
+<XPD:REF name="Model">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="PropertyLabel" type="EdgeLabelView" guid="quC9k+icv0yIkMeuPX5WUgAA">
+<XPD:ATTR name="Visible" type="boolean">False</XPD:ATTR>
+<XPD:ATTR name="Alpha" type="real">-1,5707963267949</XPD:ATTR>
+<XPD:ATTR name="Distance" type="real">15</XPD:ATTR>
+<XPD:REF name="Model">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:ATTR name="#OwnedElements" type="integer">53</XPD:ATTR>
+<XPD:OBJ name="OwnedElements[0]" type="UMLComponent" guid="Ois8O253kUadM8pwQY3z1AAA">
+<XPD:ATTR name="Name" type="string">jbpm-api</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">92NqScYMQkimi4w+8NuFxQAA</XPD:REF>
+<XPD:REF name="Views[1]">AeLQpgARN0yLiqeqynOkNwAA</XPD:REF>
+<XPD:REF name="Views[2]">pIqdMybCfUuB4j3Wk72M2QAA</XPD:REF>
+<XPD:REF name="Views[3]">Q5dUZHwFrk+7XYs5gpsDiQAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">8</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[2]">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[3]">TC2p7E/uqEKL4MYpl3vDjgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[4]">x9biYt23s02bSZC7RXUpYAAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[5]">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[6]">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[7]">q5HlqhLx/0+joW6Ksg+TBAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[1]" type="UMLComponent" guid="F/VKixV7K02VlwQlQmAvKwAA">
+<XPD:ATTR name="Name" type="string">jbpm-pvm</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">kL0ifBLH8k2M0PxjEkWXUwAA</XPD:REF>
+<XPD:REF name="Views[1]">MVCD6NUwQU+Cr85hgNA9mQAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">5</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">UzW89zVUMkOD2XR49GKBSwAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">zQOr92v5vE6dL0kKBFyp9wAA</XPD:REF>
+<XPD:REF name="ClientDependencies[3]">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+<XPD:REF name="ClientDependencies[4]">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">4</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[2]">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[3]">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[2]" type="UMLComponent" guid="AXGT6sG/YkWAzbne6BYH9gAA">
+<XPD:ATTR name="Name" type="string">jbpm-task</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">Gv5w/Hcm0k61rZhkNLQGtQAA</XPD:REF>
+<XPD:REF name="Views[1]">4bzO0l5v00ubDSwDgFvI0AAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">USrXc+RVC06k6g8JDBkKtQAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[3]" type="UMLComponent" guid="rN2k9cfQlk2UzNSPqqPOegAA">
+<XPD:ATTR name="Name" type="string">jbpm-enterprise</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">0Vw/eC4690OaqgqTJ+R97QAA</XPD:REF>
+<XPD:REF name="Views[1]">4QPtyjldhUunEN0gz7mavgAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">2</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">3soARAGPkkK23DUBcA3VbAAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[4]" type="UMLComponent" guid="MsVxfbvaTkidMyurdVALEAAA">
+<XPD:ATTR name="Name" type="string">jbpm-examples</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">WMFeUrRaqkmSFaxxGYhliQAA</XPD:REF>
+<XPD:REF name="Views[1]">3eg6/QNO/0a4Nf/fsXj1ogAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">3</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">x9biYt23s02bSZC7RXUpYAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[5]" type="UMLComponent" guid="kwDBvXNU5ECCKv4hB67TCgAA">
+<XPD:ATTR name="Name" type="string">jbpm-test-db</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">os/ZpLf6E0C9OkWrF0aPPwAA</XPD:REF>
+<XPD:REF name="Views[1]">hu1Gdh1EOkCRSVJ0NRuvGAAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">3</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">xLWpS9xVCUqhVtqkNICGJwAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[6]" type="UMLComponent" guid="Ti77WPS+TES4vmhJCWTIqAAA">
+<XPD:ATTR name="Name" type="string">jbpm-test-pojo</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">m19PobYTBkqfijmLqUHsGgAA</XPD:REF>
+<XPD:REF name="Views[1]">+qeK+VfnAE+tgn+8gEMVYQAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">KGxkaAq6n0iaJ5qJnbuCiAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[7]" type="UMLComponent" guid="Bs15lMzAj0mz+NvzVS7E4QAA">
+<XPD:ATTR name="Name" type="string">jbpm-jpdl</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">uaMGdUZ3rUGciJaxG5vJyAAA</XPD:REF>
+<XPD:REF name="Views[1]">iVAA7IWP+Uy7KPqFyfmNxAAA</XPD:REF>
+<XPD:REF name="Views[2]">mpyVwOw4aEKV1rTZE6eGmQAA</XPD:REF>
+<XPD:REF name="Views[3]">73rwWTh1HEiMGKg/kf7WdgAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">4</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">Y4WLKpAHrUilfBgG5ABxQgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">ITZTIh3Yc06xCgHd+5qbvAAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+<XPD:REF name="ClientDependencies[3]">IVVD7BW6MkCqjmD6+TzTfAAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">5</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">1CXs2RCBIEmDFPmyngQ7wQAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">JmpD2e0w4UycQJFvCIIURQAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[2]">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[3]">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[4]">KVrn3WbJ9kukPyN/3xu9qQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[8]" type="UMLDependency" guid="UzW89zVUMkOD2XR49GKBSwAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">s0Uo/LoLqEy96cpUicZxmgAA</XPD:REF>
+<XPD:REF name="Views[1]">RfGkm6kG5UqSt9kGBV5sqQAA</XPD:REF>
+<XPD:REF name="Views[2]">30JI6+M0hU+PaPHQ6RlApQAA</XPD:REF>
+<XPD:REF name="Views[3]">fx/mR46vbEWcerX36xx2fgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[9]" type="UMLDependency" guid="USrXc+RVC06k6g8JDBkKtQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">AXGT6sG/YkWAzbne6BYH9gAA</XPD:REF>
+<XPD:REF name="Supplier">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">tL936vHTiUKi/EO3eo4OCAAA</XPD:REF>
+<XPD:REF name="Views[1]">YAsDk/oCHUWj2ORqyoQ85QAA</XPD:REF>
+<XPD:REF name="Views[2]">7ksnXM1WOEqYib1PUzyAEgAA</XPD:REF>
+<XPD:REF name="Views[3]">2OX6rux8gUmn4AU/qguwTgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[10]" type="UMLDependency" guid="Y4WLKpAHrUilfBgG5ABxQgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:REF name="Supplier">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">myBpvTwWOEC8kka4yXiDxgAA</XPD:REF>
+<XPD:REF name="Views[1]">O/1gx6vDG0Wsia2+QoEb5AAA</XPD:REF>
+<XPD:REF name="Views[2]">L4IP3JCta0qUlai/mtI+sgAA</XPD:REF>
+<XPD:REF name="Views[3]">n7Z3ZpAHB0mHKJYlsw3VhgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[11]" type="UMLDependency" guid="3soARAGPkkK23DUBcA3VbAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">rN2k9cfQlk2UzNSPqqPOegAA</XPD:REF>
+<XPD:REF name="Supplier">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">FSrDLZ9lC06DMhXgXGZUQwAA</XPD:REF>
+<XPD:REF name="Views[1]">B9vPDM3UQE2zvxro+ufIDQAA</XPD:REF>
+<XPD:REF name="Views[2]">6VDyiYPftEWH+jPwMVy1XAAA</XPD:REF>
+<XPD:REF name="Views[3]">yCBx070VyUSE7L6mIiqZ6gAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[12]" type="UMLDependency" guid="1CXs2RCBIEmDFPmyngQ7wQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">MsVxfbvaTkidMyurdVALEAAA</XPD:REF>
+<XPD:REF name="Supplier">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">SSw1SKkmZ0CoRq1XSUXS/QAA</XPD:REF>
+<XPD:REF name="Views[1]">ddhra6UTAkGmNgl0BZNyDAAA</XPD:REF>
+<XPD:REF name="Views[2]">qx+nvFgOpEmfpqN0d8S+ygAA</XPD:REF>
+<XPD:REF name="Views[3]">eH/awcIp+k6tEkVnEeqKmQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[13]" type="UMLDependency" guid="JmpD2e0w4UycQJFvCIIURQAA">
+<XPD:ATTR name="StereotypeName" type="string">runtime</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">kwDBvXNU5ECCKv4hB67TCgAA</XPD:REF>
+<XPD:REF name="Supplier">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">Bld8RQIiYUaX3NAHOTSySwAA</XPD:REF>
+<XPD:REF name="Views[1]">xXfl6/dCXEq7ACI9opVt1AAA</XPD:REF>
+<XPD:REF name="Views[2]">HXVe8usV8kO191DDCVY/WgAA</XPD:REF>
+<XPD:REF name="Views[3]">/E6l3m6OrkOq2pG928iwfQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[14]" type="UMLDependency" guid="KGxkaAq6n0iaJ5qJnbuCiAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">Ti77WPS+TES4vmhJCWTIqAAA</XPD:REF>
+<XPD:REF name="Supplier">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">LM7aM3xEFkSvbz7d7R2kSwAA</XPD:REF>
+<XPD:REF name="Views[1]">/vBKMrZ33kGqCUGezbK4iQAA</XPD:REF>
+<XPD:REF name="Views[2]">Ns1su3Qoj0Sgg5SOZhlpXwAA</XPD:REF>
+<XPD:REF name="Views[3]">zU4Xr4puz0KAOt5mXy8wLwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[15]" type="UMLComponent" guid="ldE/OPmI/UqAVOba04r45QAA">
+<XPD:ATTR name="Name" type="string">jbpm-test-load</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">NR+DCad5w0aNy08gEmohjgAA</XPD:REF>
+<XPD:REF name="Views[1]">XCuwduuWdEurAe/qjiwuugAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">3</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">gNdjs1FEbkyttFXd3t0sNQAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">TC2p7E/uqEKL4MYpl3vDjgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[16]" type="UMLDependency" guid="gNdjs1FEbkyttFXd3t0sNQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">ldE/OPmI/UqAVOba04r45QAA</XPD:REF>
+<XPD:REF name="Supplier">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">XLpkZbX67E2e103suf5FgQAA</XPD:REF>
+<XPD:REF name="Views[1]">8v1Xp2NxzEe4NBOz8qr6XwAA</XPD:REF>
+<XPD:REF name="Views[2]">JInfIiF+yUWGEwRuC/fBbQAA</XPD:REF>
+<XPD:REF name="Views[3]">bW5E7jctskGxAqy4fBJsUwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[17]" type="UMLComponent" guid="7b0gCEntNUmxlyQ1YVGDvwAA">
+<XPD:ATTR name="Name" type="string">hibernate</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">3fKHNq8HbU6ne7o9d0+49QAA</XPD:REF>
+<XPD:REF name="Views[1]">rn0f5HPHZEO/XyvSLpN4JQAA</XPD:REF>
+<XPD:REF name="Views[2]">S26IZQGgbEuW/e8i+JwfJgAA</XPD:REF>
+<XPD:REF name="Views[3]">moDyp4GQHU6RdoYk/xQofwAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">3</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">YaWv2bgmv0u8vpBv6SJgUwAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">b+gX8dz5uEe/vDyX6nczwgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[2]">G2xeWXCBOEGWVsaaT++RSAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[18]" type="UMLComponent" guid="RnhmSXHjpkqPifkoBI0xMQAA">
+<XPD:ATTR name="Name" type="string">jbpm-test-base</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">1ltfrrUBG0q0sFN/n22amgAA</XPD:REF>
+<XPD:REF name="Views[1]">R35cRSfTk0qzkqf1Cx0oIgAA</XPD:REF>
+<XPD:REF name="Views[2]">shKyc/zYFEm70ertpvs0lgAA</XPD:REF>
+<XPD:REF name="Views[3]">QCVHQ0YN9EO40bP5th/AcAAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">5</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[3]">c3aosxo56Eq4/dBLnd1HgAAA</XPD:REF>
+<XPD:REF name="ClientDependencies[4]">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">8</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">m0CfPAyQ3EiWaEREHjgftgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[2]">qYZxI+u2T0KrBKsT29viVAAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[3]">xLWpS9xVCUqhVtqkNICGJwAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[4]">QA6wifJqU0uoQEOC7wjPbgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[5]">Ybqb/Q8TQUqgiUYrvmAmKgAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[6]">zQOr92v5vE6dL0kKBFyp9wAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[7]">CvL1H2cfL0aBb2DIsO3Z/QAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[19]" type="UMLComponent" guid="fTUNxe8WmEWd/zpINe6SCQAA">
+<XPD:ATTR name="Name" type="string">log4j</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">rbLmK4jPbkGOYpeFKoIgSgAA</XPD:REF>
+<XPD:REF name="Views[1]">kuQZh6R0rkGGOBYMpnDGTgAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">ATdgO9ALgEG91h9rrbmQpgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[20]" type="UMLComponent" guid="/F3HsPfnqkO8g89mfJ8xVQAA">
+<XPD:ATTR name="Name" type="string">client-code</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">CIpyZE96i0iOlRAJJmbidQAA</XPD:REF>
+<XPD:REF name="Views[1]">+oMi1PNRnUet4UvGOe+KNgAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">4</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">d4Lxosfzm062JvBnEmkWHgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">m0CfPAyQ3EiWaEREHjgftgAA</XPD:REF>
+<XPD:REF name="ClientDependencies[2]">YaWv2bgmv0u8vpBv6SJgUwAA</XPD:REF>
+<XPD:REF name="ClientDependencies[3]">/M/x3rnebUe2dGXfP6ErHwAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[21]" type="UMLDependency" guid="d4Lxosfzm062JvBnEmkWHgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">/fto29UmJke9UEPPg1dvCAAA</XPD:REF>
+<XPD:REF name="Views[1]">/Fw+ESyxNkmr9of7R0LEtwAA</XPD:REF>
+<XPD:REF name="Views[2]">XHnuu2G6ZUqiQOcGfcfQhwAA</XPD:REF>
+<XPD:REF name="Views[3]">eFRlV6eG50GCkf6iWu6nCAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[22]" type="UMLDependency" guid="m0CfPAyQ3EiWaEREHjgftgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[23]" type="UMLDependency" guid="YaWv2bgmv0u8vpBv6SJgUwAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:REF name="Supplier">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[24]" type="UMLDependency" guid="/M/x3rnebUe2dGXfP6ErHwAA">
+<XPD:ATTR name="StereotypeName" type="string">runtime</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:REF name="Supplier">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">yGOyjwerWU+LDgRMqdhcDwAA</XPD:REF>
+<XPD:REF name="Views[1]">UGyE7mW7+kqvsR13p6SzmQAA</XPD:REF>
+<XPD:REF name="Views[2]">0PAiZlI0nkKMiWnrSeDbIwAA</XPD:REF>
+<XPD:REF name="Views[3]">YsX9ulBWGUa9b3+dGsglXwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[25]" type="UMLDependency" guid="b+gX8dz5uEe/vDyX6nczwgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:REF name="Supplier">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">Qn9aZDlQhUqj/NwTUNxQVgAA</XPD:REF>
+<XPD:REF name="Views[1]">+YwOZrWnJ0iToIs8PcSFmgAA</XPD:REF>
+<XPD:REF name="Views[2]">T/p+j3dspE+BuSZgCcwALQAA</XPD:REF>
+<XPD:REF name="Views[3]">B0y+v7Uuq0qyySQsnWwi/QAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[26]" type="UMLDependency" guid="WxpF6j3KhUm9GPQcpxmhpwAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">HymcrpkgrUanUlc3fpQZOAAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">mV0lDADP50CyXt3p4NSh5AAA</XPD:REF>
+<XPD:REF name="Views[1]">nL8zteNrTEaNdP0ORywPEQAA</XPD:REF>
+<XPD:REF name="Views[2]">t7uW4qlY3EuUM02osTes4wAA</XPD:REF>
+<XPD:REF name="Views[3]">NqgLo30vAE2AgyFLA33V3QAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[27]" type="UMLComponent" guid="q2sDsF5njUmjPrBEjAya2AAA">
+<XPD:ATTR name="Name" type="string">junit</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">okCq8TeiSkSTXxYO7BUdpgAA</XPD:REF>
+<XPD:REF name="Views[1]">K2kHsEL97kSakGq0Z4Oo1AAA</XPD:REF>
+<XPD:REF name="Views[2]">c6dWuci7PE6zGpeQ6NspuQAA</XPD:REF>
+<XPD:REF name="Views[3]">bx3wCLtuhEe3V7LN9SyewQAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">j1GCNWMKW0CgQEXmzVa7bQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[28]" type="UMLDependency" guid="j1GCNWMKW0CgQEXmzVa7bQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:REF name="Supplier">q2sDsF5njUmjPrBEjAya2AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">8</XPD:ATTR>
+<XPD:REF name="Views[0]">0lxWtHQGbk6+7v1xJ2HoggAA</XPD:REF>
+<XPD:REF name="Views[1]">FEHEASbMvEecK7YLlj8FEgAA</XPD:REF>
+<XPD:REF name="Views[2]">GL/w4QuYME6cNf6/xBvuFwAA</XPD:REF>
+<XPD:REF name="Views[3]">n/utdDZGREe1l2HwVBsJEAAA</XPD:REF>
+<XPD:REF name="Views[4]">JUwNsbz6vkC8Nz9vQN4mPwAA</XPD:REF>
+<XPD:REF name="Views[5]">wk9MB/ykpECEH7NCCgq5NQAA</XPD:REF>
+<XPD:REF name="Views[6]">frgG4fBBwUyPlximUBmYSgAA</XPD:REF>
+<XPD:REF name="Views[7]">sxIpqKrdnUGNrfiRZ0jvrwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[29]" type="UMLDependency" guid="ATdgO9ALgEG91h9rrbmQpgAA">
+<XPD:ATTR name="StereotypeName" type="string">provided</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:REF name="Supplier">fTUNxe8WmEWd/zpINe6SCQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">BsUPUXy7aEiLZWpBGtzAmAAA</XPD:REF>
+<XPD:REF name="Views[1]">WG5xv9mWSUOaQ+41Ydod6AAA</XPD:REF>
+<XPD:REF name="Views[2]">dKb6ieet20GTJwk4JpHUcgAA</XPD:REF>
+<XPD:REF name="Views[3]">L9NTVtMZDUWvWhnCi6zCSgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[30]" type="UMLComponent" guid="HymcrpkgrUanUlc3fpQZOAAA">
+<XPD:ATTR name="Name" type="string">client-test-code</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">eXPgSONhSkKl6NGeLvs0+AAA</XPD:REF>
+<XPD:REF name="Views[1]">c/kRNfpHu063wsbGOAYjkQAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">2</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">WxpF6j3KhUm9GPQcpxmhpwAA</XPD:REF>
+<XPD:REF name="ClientDependencies[1]">RrCuQjUInk6Q5HxzA+GowAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[31]" type="UMLDependency" guid="RrCuQjUInk6Q5HxzA+GowAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">HymcrpkgrUanUlc3fpQZOAAA</XPD:REF>
+<XPD:REF name="Supplier">/F3HsPfnqkO8g89mfJ8xVQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">Tx3kQXcM80ugRN1WdblMDgAA</XPD:REF>
+<XPD:REF name="Views[1]">5Ozobg/mM061Q00JA6a5kwAA</XPD:REF>
+<XPD:REF name="Views[2]">nplRFaFEj0aUfdQFEvcKlQAA</XPD:REF>
+<XPD:REF name="Views[3]">os19kdxV30SP584fS08A4gAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[32]" type="UMLDependency" guid="ITZTIh3Yc06xCgHd+5qbvAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:REF name="Supplier">AXGT6sG/YkWAzbne6BYH9gAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">7kms5wuBdkWkue3i1hjJJQAA</XPD:REF>
+<XPD:REF name="Views[1]">Yf1Ki7LFlECsofgw9t+nvwAA</XPD:REF>
+<XPD:REF name="Views[2]">Nm/Ui3SGaECRJvG1zXtstAAA</XPD:REF>
+<XPD:REF name="Views[3]">rxiJCsXKH0y8DgMwT4PT0wAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[33]" type="UMLPackage" guid="VbqlK+vTb0SoHdpEXFsRkgAA">
+<XPD:ATTR name="Name" type="string">Package1</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[34]" type="UMLPackage" guid="tfl5FprffUy9SE+AmL+zpQAA">
+<XPD:ATTR name="Name" type="string">jbpm.jar</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">1</XPD:ATTR>
+<XPD:REF name="Views[0]">/jMRysCRzEmjLJZ6tATbkQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[35]" type="UMLPackage" guid="5TvqnjB1jkG25vsTu+A0XgAA">
+<XPD:ATTR name="Name" type="string">jbpm-enterprise.jar</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">1</XPD:ATTR>
+<XPD:REF name="Views[0]">7gpcdFJdLEyTK/UY/CuWfgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[36]" type="UMLDependency" guid="G2xeWXCBOEGWVsaaT++RSAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:REF name="Supplier">7b0gCEntNUmxlyQ1YVGDvwAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">XxzLJInR7kGT0tkOGUB5AgAA</XPD:REF>
+<XPD:REF name="Views[1]">cRIQKwraNUO9IC4Hbe9o/QAA</XPD:REF>
+<XPD:REF name="Views[2]">MA65ojWaaUCvLzu4bx0X0wAA</XPD:REF>
+<XPD:REF name="Views[3]">N57lzUNqpkGH24TUZvAZIAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[37]" type="UMLDependency" guid="IVVD7BW6MkCqjmD6+TzTfAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">Eh5CYhrY4kagmfN6HSXCWwAA</XPD:REF>
+<XPD:REF name="Views[1]">SqGHS/qu6EulEOUcYir9owAA</XPD:REF>
+<XPD:REF name="Views[2]">Cn23MthxIkuYYlzT6scB0AAA</XPD:REF>
+<XPD:REF name="Views[3]">Ea+a/gpl9kGu+tVGLvTxEQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[38]" type="UMLDependency" guid="qYZxI+u2T0KrBKsT29viVAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">MsVxfbvaTkidMyurdVALEAAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">HNZBvjwK4kaQw7soGOvO4AAA</XPD:REF>
+<XPD:REF name="Views[1]">RxymIYGCi0S3gabovkdxRAAA</XPD:REF>
+<XPD:REF name="Views[2]">dqp7/VGztUSzsDwhpZuM5AAA</XPD:REF>
+<XPD:REF name="Views[3]">m6cMhO2uaky1wLf4+FFx6AAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[39]" type="UMLDependency" guid="xLWpS9xVCUqhVtqkNICGJwAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">kwDBvXNU5ECCKv4hB67TCgAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[40]" type="UMLDependency" guid="QA6wifJqU0uoQEOC7wjPbgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">ldE/OPmI/UqAVOba04r45QAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">NE4bCZ7gxUCx/KY6oJHiPQAA</XPD:REF>
+<XPD:REF name="Views[1]">c+ULx/nPvU6EuUCYyIMszQAA</XPD:REF>
+<XPD:REF name="Views[2]">ITukSZeua0SjzzwJpa35AQAA</XPD:REF>
+<XPD:REF name="Views[3]">LBlYkAzvKkOCB1Nbm5KLNQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[41]" type="UMLDependency" guid="TC2p7E/uqEKL4MYpl3vDjgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">ldE/OPmI/UqAVOba04r45QAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[42]" type="UMLDependency" guid="Ybqb/Q8TQUqgiUYrvmAmKgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">kwDBvXNU5ECCKv4hB67TCgAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">syRWy5PzLEC+E3RAHAo5lAAA</XPD:REF>
+<XPD:REF name="Views[1]">M7dffO/Yi0GlN8g1/aVovAAA</XPD:REF>
+<XPD:REF name="Views[2]">UZ6I3qySg0WUjGoLzuAwLQAA</XPD:REF>
+<XPD:REF name="Views[3]">v86mF5cwLEWXIf3u3GESOwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[43]" type="UMLDependency" guid="x9biYt23s02bSZC7RXUpYAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">MsVxfbvaTkidMyurdVALEAAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[44]" type="UMLDependency" guid="0G9IV2lOwEGquFmnHxVYQgAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">17AtBO6XMUe0t5mnVGyL7wAA</XPD:REF>
+<XPD:REF name="Views[1]">9ryGXy1bBke2ZPu/V6d60AAA</XPD:REF>
+<XPD:REF name="Views[2]">TYGxamv2L06bUrGTzI/NSAAA</XPD:REF>
+<XPD:REF name="Views[3]">n7zKKP1cx0eE2yXcDGOmcgAA</XPD:REF>
+<XPD:ATTR name="#ClientDependencies" type="integer">1</XPD:ATTR>
+<XPD:REF name="ClientDependencies[0]">q5HlqhLx/0+joW6Ksg+TBAAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[45]" type="UMLDependency" guid="zQOr92v5vE6dL0kKBFyp9wAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[46]" type="UMLDependency" guid="c3aosxo56Eq4/dBLnd1HgAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">RtA1l20tjkyB5rPxnuwkxAAA</XPD:REF>
+<XPD:REF name="Views[1]">5mhew13G5Ey0i955ytoSIQAA</XPD:REF>
+<XPD:REF name="Views[2]">tAgbMv3DnkWuHJjtwHkE1AAA</XPD:REF>
+<XPD:REF name="Views[3]">quC9k+icv0yIkMeuPX5WUgAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[47]" type="UMLComponent" guid="cmkpYh9kWUe54vVNch7vwgAA">
+<XPD:ATTR name="Name" type="string">jbpm-log</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">2</XPD:ATTR>
+<XPD:REF name="Views[0]">9h9tg46+zEqxK6eZGIVN3wAA</XPD:REF>
+<XPD:REF name="Views[1]">rSdIyFahOEWLQoXeMSWyjAAA</XPD:REF>
+<XPD:ATTR name="#SupplierDependencies" type="integer">2</XPD:ATTR>
+<XPD:REF name="SupplierDependencies[0]">/soSCHK5oECw23ApKZpFJQAA</XPD:REF>
+<XPD:REF name="SupplierDependencies[1]">+zYUHfvAdES31I2z2CHbmQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[48]" type="UMLDependency" guid="+zYUHfvAdES31I2z2CHbmQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:REF name="Supplier">cmkpYh9kWUe54vVNch7vwgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">gB4b9zqn70C8L8FAE4pDcQAA</XPD:REF>
+<XPD:REF name="Views[1]">y24khAfz7EC/71Rxpg12bQAA</XPD:REF>
+<XPD:REF name="Views[2]">sW0ozTYflEeMg8SJLoeeyQAA</XPD:REF>
+<XPD:REF name="Views[3]">kTqyC2HCIESNae5f5EwDTwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[49]" type="UMLDependency" guid="/soSCHK5oECw23ApKZpFJQAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:REF name="Supplier">cmkpYh9kWUe54vVNch7vwgAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">q+vX8HioM0WwJjGSnWU38wAA</XPD:REF>
+<XPD:REF name="Views[1]">mJGC4mEENUGraL5xWLn7+AAA</XPD:REF>
+<XPD:REF name="Views[2]">AyPIxu591UG5ecl0zDwdcQAA</XPD:REF>
+<XPD:REF name="Views[3]">crCid3eacEuEx3qLQq63gwAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[50]" type="UMLDependency" guid="q5HlqhLx/0+joW6Ksg+TBAAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">0G9IV2lOwEGquFmnHxVYQgAA</XPD:REF>
+<XPD:REF name="Supplier">Ois8O253kUadM8pwQY3z1AAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[51]" type="UMLDependency" guid="CvL1H2cfL0aBb2DIsO3Z/QAA">
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">F/VKixV7K02VlwQlQmAvKwAA</XPD:REF>
+<XPD:REF name="Supplier">RnhmSXHjpkqPifkoBI0xMQAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">Z+YcEOR4XEuHSRX5lIjunQAA</XPD:REF>
+<XPD:REF name="Views[1]">8QvwB8UXG0ODJa0n9HW83AAA</XPD:REF>
+<XPD:REF name="Views[2]">CN6zyu45XUWna7JwqXyDSAAA</XPD:REF>
+<XPD:REF name="Views[3]">iicoPDgFQ0qMQebeFzttaQAA</XPD:REF>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[52]" type="UMLDependency" guid="KVrn3WbJ9kukPyN/3xu9qQAA">
+<XPD:ATTR name="StereotypeName" type="string">test</XPD:ATTR>
+<XPD:REF name="Namespace">mNlhQxH3RkCjxaH3VQBTwQAA</XPD:REF>
+<XPD:REF name="Client">rN2k9cfQlk2UzNSPqqPOegAA</XPD:REF>
+<XPD:REF name="Supplier">Bs15lMzAj0mz+NvzVS7E4QAA</XPD:REF>
+<XPD:ATTR name="#Views" type="integer">4</XPD:ATTR>
+<XPD:REF name="Views[0]">M29407aZXUuJm2P05+NgVgAA</XPD:REF>
+<XPD:REF name="Views[1]">rxUyd/KQiEKe50ZrgKXVsgAA</XPD:REF>
+<XPD:REF name="Views[2]">iDzZrTOIVUeZoq5clonoOAAA</XPD:REF>
+<XPD:REF name="Views[3]">l6iyGMrOJUmJ0ciSj+X15AAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[3]" type="UMLModel" guid="D4U+Tw7Eg0mlnh0cjb2/cQAA">
+<XPD:ATTR name="Name" type="string">Implementation Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">implementationModel</XPD:ATTR>
+<XPD:REF name="Namespace">M0HBaTtrG027mqtMSnY3lAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLComponentDiagram" guid="GY4HIS8OKkyvKYZLFKuaxgAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">D4U+Tw7Eg0mlnh0cjb2/cQAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLComponentDiagramView" guid="YwMkR4EFukqgMcip09SnegAA">
+<XPD:REF name="Diagram">GY4HIS8OKkyvKYZLFKuaxgAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+<XPD:OBJ name="OwnedElements[4]" type="UMLModel" guid="tAQj1eUMl0yCflCWKw2LWwAA">
+<XPD:ATTR name="Name" type="string">Deployment Model</XPD:ATTR>
+<XPD:ATTR name="StereotypeProfile" type="string">UMLStandard</XPD:ATTR>
+<XPD:ATTR name="StereotypeName" type="string">deploymentModel</XPD:ATTR>
+<XPD:REF name="Namespace">M0HBaTtrG027mqtMSnY3lAAA</XPD:REF>
+<XPD:ATTR name="#OwnedDiagrams" type="integer">1</XPD:ATTR>
+<XPD:OBJ name="OwnedDiagrams[0]" type="UMLDeploymentDiagram" guid="+zkbIJ3GikGeaIfG5WJFDQAA">
+<XPD:ATTR name="Name" type="string">Main</XPD:ATTR>
+<XPD:REF name="DiagramOwner">tAQj1eUMl0yCflCWKw2LWwAA</XPD:REF>
+<XPD:OBJ name="DiagramView" type="UMLDeploymentDiagramView" guid="GwiEg1BX1EKVQEinoGkB6QAA">
+<XPD:REF name="Diagram">+zkbIJ3GikGeaIfG5WJFDQAA</XPD:REF>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:OBJ>
+</XPD:BODY>
+</XPD:PROJECT>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBehaviourBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBehaviourBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBehaviourBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityBehaviourBuilder {
+  
+  protected ActivityBuilder activityBuilder;
+  protected ActivityImpl activity;
+
+  public ActivityBehaviourBuilder(ActivityBuilder activityBuilder) {
+    this.activityBuilder = activityBuilder;
+    this.activity = activityBuilder.activity;
+  }
+  
+  public ActivityBuilder endBehaviour() {
+    return activityBuilder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import java.lang.reflect.Constructor;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityBuilder extends CompositeBuilder {
+  
+  private static final Class<?>[] ACTIVITYBEHAVIOURBUILDER_PARAMTYPES = new Class<?>[]{ActivityBuilder.class};
+
+  /** the enclosing composite */
+  protected CompositeBuilder compositeBuilder;
+  protected ActivityImpl activity;
+  
+  public ActivityBuilder(CompositeBuilder compositeBuilder, String activityName) {
+    this.compositeBuilder = compositeBuilder;
+    this.activity = compositeBuilder.createActivity();
+    this.compositeElement = activity;
+    this.activity.setName(activityName);
+  }
+  
+  public ActivityBuilder initial() {
+    setProcessDefinitionInitial(activity);
+    return this;
+  }
+  
+  protected void setProcessDefinitionInitial(ActivityImpl initial) {
+    compositeBuilder.setProcessDefinitionInitial(initial);
+  }
+
+  public <T extends ActivityBehaviourBuilder> T startBehaviour(Class<T> activityBehaviourBuilderType) {
+    return startBehaviour(null, activityBehaviourBuilderType);
+  }
+
+  public <T extends ActivityBehaviourBuilder> T startBehaviour(String activityName, Class<T> activityBehaviourBuilderType) {
+    if (activityBehaviourBuilderType==null) {
+      throw new RuntimeException("activityBuilderType is null");
+    }
+    try {
+      Constructor<T> constructor = activityBehaviourBuilderType.getConstructor(ACTIVITYBEHAVIOURBUILDER_PARAMTYPES);
+      T activityBuilder = constructor.newInstance(new Object[]{this});
+      return activityBuilder;
+    } catch (Exception e) {
+      throw new RuntimeException("couldn't instantiate activity behaviour builder type "+activityBehaviourBuilderType.getName(), e);
+    }
+  }
+  
+  public CompositeBuilder endActivity() {
+    return compositeBuilder;
+  }
+  
+  public FlowBuilder startFlow(String to) {
+    UnresolvedFlow unresolvedFlow = new UnresolvedFlow();
+    unresolvedFlow.transition = activity.createOutgoingTransition();
+    unresolvedFlow.destinationName = to;
+    addUnresolvedFlow(unresolvedFlow);
+    return new FlowBuilder(this, unresolvedFlow.transition);
+  }
+  
+  public ProcessDefinitionImpl endProcess() {
+    return compositeBuilder.endProcess();
+  }
+  
+  public ActivityBuilder transition(String to) {
+    startFlow(to);
+    return this;
+  }
+
+  public ActivityBuilder transition(String to, String name) {
+    startFlow(to).name(name);
+    return this;
+  }
+
+  public ActivityBuilder asyncExecute() {
+    activity.setExecutionAsync(true);
+    return this;
+  }
+
+  protected void addUnresolvedFlow(UnresolvedFlow unresolvedFlow) {
+    compositeBuilder.addUnresolvedFlow(unresolvedFlow);
+  }
+
+  public ActivityBuilder needsPrevious() {
+    activity.setPreviousNeeded(true);
+    return this;
+  }
+
+  public ActivityBuilder scope() {
+    activity.setLocalScope(true);
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.pvm.internal.model.CompositeElementImpl;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class CompositeBuilder {
+
+  protected CompositeElementImpl compositeElement;
+  
+  public abstract ProcessDefinitionImpl endProcess();
+  protected abstract void addUnresolvedFlow(UnresolvedFlow unresolvedFlow);
+  protected abstract void setProcessDefinitionInitial(ActivityImpl initial);
+
+  protected ActivityImpl createActivity() {
+    return compositeElement.createActivity();
+  }
+
+  public EventImpl createEvent(String eventName) {
+    return compositeElement.createEvent(eventName);
+  }
+  
+  public CompositeBuilder variable(String name) {
+    return startVariable(name)
+      .endVariable();
+  }
+  
+  public CompositeBuilder variable(String name, String type) {
+    return startVariable(name)
+      .type(type)
+      .endVariable();
+  }
+  
+  public TimerBuilder startTimer() {
+    return new TimerBuilder(this, null);
+  }
+
+  public TimerBuilder startTimer(String eventName) {
+    return new TimerBuilder(this, eventName);
+  }
+  
+  public VariableBuilder startVariable(String name) {
+    return new VariableBuilder(this)
+      .name(name);
+  }
+
+  public ActivityBuilder startActivity() {
+    return startActivity((String)null);
+  }
+
+  public ActivityBuilder startActivity(String activityName) {
+    return new ActivityBuilder(this, activityName);
+  }
+
+  public ActivityBuilder startActivity(Descriptor activityDescriptor) {
+    return startActivity(null, activityDescriptor);
+  }
+
+  public ActivityBuilder startActivity(String activityName, Descriptor activityDescriptor) {
+    if (activityDescriptor==null) {
+      throw new RuntimeException("activityDescriptor is null");
+    }
+    ActivityBuilder activityBuilder = new ActivityBuilder(this, activityName);
+    activityBuilder.activity.setBehaviour(activityDescriptor);
+    return activityBuilder;
+  }
+
+  public ActivityBuilder startActivity(ActivityBehaviour activityBehaviour) {
+    return startActivity(null, activityBehaviour);
+  }
+
+  public ActivityBuilder startActivity(String activityName, ActivityBehaviour activityBehaviour) {
+    if (activityBehaviour==null) {
+      throw new RuntimeException("activity is null");
+    }
+    ActivityBuilder activityBuilder = new ActivityBuilder(this, activityName);
+    activityBuilder.activity.setBehaviour(activityBehaviour);
+    return activityBuilder;
+  }
+
+  public ActivityBuilder startActivity(Class<? extends ActivityBehaviour> activityClass) {
+    return startActivity(null, new ObjectDescriptor(activityClass));
+  }
+
+  public ActivityBuilder startActivity(String activityName, Class<? extends ActivityBehaviour> activityClass) {
+    return startActivity(activityName, new ObjectDescriptor(activityClass));
+  }
+
+  public EventBuilder startEvent(String eventName) {
+    return new EventBuilder(this, eventName);
+  }
+  
+  public CompositeExceptionHandlerBuilder startExceptionHandler(Class<? extends Throwable> exceptionType) {
+    return new CompositeExceptionHandlerBuilder(this, exceptionType);
+  }
+  
+  public CompositeBuilder property(String name, String value) {
+    return property(new StringDescriptor(name, value));
+  }
+
+  public CompositeBuilder property(Descriptor descriptor) {
+    compositeElement.addProperty(descriptor);
+    return this;
+  }
+
+  public CompositeBuilder endActivity() {
+    throw new JbpmException("calling endActivity on a processBuilder is invalid");
+  }
+
+  public FlowBuilder startFlow(String to) {
+    throw new JbpmException("calling startFlow on a processBuilder is invalid");
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CompositeExceptionHandlerBuilder extends ExceptionHandlerBuilder {
+
+  protected CompositeBuilder compositeBuilder;
+
+  public CompositeExceptionHandlerBuilder(CompositeBuilder compositeBuilder, Class<? extends Throwable> exceptionType) {
+    this.compositeBuilder = compositeBuilder;
+    exceptionHandler = compositeBuilder.compositeElement.createExceptionHandler();
+    exceptionClass(exceptionType);
+  }
+  
+  public CompositeExceptionHandlerBuilder exceptionClass(Class<? extends Throwable> exceptionType) {
+    super.setExceptionClass(exceptionType);
+    return this;
+  }
+
+  public CompositeExceptionHandlerBuilder listener(EventListener eventListener) {
+    super.addListener(eventListener);
+    return this;
+  }
+
+  public CompositeExceptionHandlerBuilder listener(Descriptor descriptor) {
+    super.addListener(descriptor);
+    return this;
+  }
+
+  public CompositeExceptionHandlerBuilder listener(String expression) {
+    super.addListener(expression);
+    return this;
+  }
+
+  public CompositeBuilder endExceptionHandler() {
+    return compositeBuilder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventBuilder extends ObservableBuilder {
+
+  protected CompositeBuilder compositeBuilder;
+
+  public EventBuilder(CompositeBuilder compositeBuilder, String eventName) {
+    super(compositeBuilder.compositeElement, eventName);
+    this.compositeBuilder = compositeBuilder;
+  }
+  
+  public EventBuilder listener(EventListener eventListener) {
+    addListener(eventListener);
+    return this;
+  }
+
+  public EventBuilder listener(EventListener eventListener, boolean propagation) {
+    addListener(eventListener, propagation);
+    return this;
+  }
+
+  public EventBuilder listener(Descriptor descriptor) {
+    addListener(descriptor);
+    return this;
+  }
+
+  public EventBuilder listener(Descriptor descriptor, boolean propagation) {
+    addListener(descriptor, propagation);
+    return this;
+  }
+
+  public EventBuilder listener(String expression) {
+    addListener(expression);
+    return this;
+  }
+
+  public EventBuilder listener(String expression, boolean propagation) {
+    addListener(expression, propagation);
+    return this;
+  }
+
+  public EventBuilder property(String name, String value) {
+    StringDescriptor descriptor = new StringDescriptor(name, value);
+    getEvent().addProperty(descriptor);
+    return this;
+  }
+  
+  public EventExceptionHandlerBuilder startExceptionHandler(Class<? extends Throwable> exceptionType) {
+    return new EventExceptionHandlerBuilder(this, exceptionType);
+  }
+  
+  public CompositeBuilder endEvent() {
+    return compositeBuilder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventExceptionHandlerBuilder extends ExceptionHandlerBuilder {
+
+  protected EventBuilder eventBuilder;
+
+  public EventExceptionHandlerBuilder(EventBuilder eventBuilder, Class<? extends Throwable> exceptionType) {
+    this.eventBuilder = eventBuilder;
+    exceptionHandler = eventBuilder.getEvent().createExceptionHandler();
+    exceptionClass(exceptionType);
+  }
+
+  public EventExceptionHandlerBuilder exceptionClass(Class<? extends Throwable> exceptionType) {
+    super.setExceptionClass(exceptionType);
+    return this;
+  }
+
+  public EventExceptionHandlerBuilder listener(EventListener eventListener) {
+    super.addListener(eventListener);
+    return this;
+  }
+
+  public EventExceptionHandlerBuilder listener(Descriptor descriptor) {
+    super.addListener(descriptor);
+    return this;
+  }
+
+  public EventExceptionHandlerBuilder listener(String expression) {
+    super.addListener(expression);
+    return this;
+  }
+
+  public EventBuilder endExceptionHandler() {
+    return eventBuilder;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.model.ExceptionHandlerImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExceptionHandlerBuilder {
+  
+  protected ExceptionHandlerImpl exceptionHandler;
+
+  protected void setExceptionClass(Class<? extends Throwable> exceptionType) {
+    exceptionHandler.setExceptionClassName(exceptionType.getName());
+  }
+
+  protected void addListener(EventListener eventListener) {
+    exceptionHandler.createEventListenerReference(eventListener);
+  }
+
+  protected void addListener(Descriptor descriptor) {
+    exceptionHandler.createEventListenerReference(descriptor);
+  }
+
+  protected void addListener(String expression) {
+    exceptionHandler
+      .createEventListenerReference()
+      .setExpression(expression);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/FlowBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FlowBuilder extends ObservableBuilder {
+
+  protected ActivityBuilder activityBuilder;
+  protected TransitionImpl transition;
+  
+  public FlowBuilder(ActivityBuilder activityBuilder, TransitionImpl transition) {
+    super(transition, Event.TAKE);
+    this.activityBuilder = activityBuilder;
+    this.transition = transition;
+  }
+  
+  public FlowBuilder name(String name) {
+    transition.setName(name);
+    return this;
+  }
+  
+  public FlowBuilder expr(String expression) {
+    // transition.setExpression(expression);
+    return this;
+  }
+  
+  public FlowBuilder listener(EventListener eventListener) {
+    addListener(eventListener);
+    return this;
+  }
+
+  public FlowBuilder listener(EventListener eventListener, boolean propagation) {
+    addListener(eventListener, propagation);
+    return this;
+  }
+
+  public FlowBuilder listener(Descriptor descriptor) {
+    addListener(descriptor);
+    return this;
+  }
+
+  public FlowBuilder listener(Descriptor descriptor, boolean propagation) {
+    addListener(descriptor, propagation);
+    return this;
+  }
+
+  public FlowBuilder listener(String expression) {
+    addListener(expression);
+    return this;
+  }
+
+  public FlowBuilder listener(String expression, boolean propagation) {
+    addListener(expression, propagation);
+    return this;
+  }
+  
+  public FlowBuilder property(String name, String value) {
+    StringDescriptor descriptor = new StringDescriptor(name, value);
+    transition.addProperty(descriptor);
+    return this;
+  }
+
+  public ActivityBuilder endFlow() {
+    return (ActivityBuilder) activityBuilder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ObservableBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ObservableBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ObservableBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ObservableBuilder {
+
+  protected ObservableElementImpl observableElement;
+  protected String eventName;
+  protected EventImpl event = null;
+  
+  public ObservableBuilder(ObservableElementImpl observableElement, String eventName) {
+    this.observableElement = observableElement;
+    this.eventName = eventName;
+  }
+
+  protected void addListener(EventListener eventListener) {
+    getEvent().createEventListenerReference(eventListener);
+  }
+
+  protected void addListener(EventListener eventListener, boolean propagation) {
+    EventListenerReference eventListenerReference = getEvent().createEventListenerReference(eventListener);
+    eventListenerReference.setPropagationEnabled(propagation);
+  }
+
+  protected void addListener(Descriptor descriptor) {
+    getEvent().createEventListenerReference(descriptor);
+  }
+
+  protected void addListener(Descriptor descriptor, boolean propagation) {
+    EventListenerReference eventListenerReference = getEvent().createEventListenerReference(descriptor);
+    eventListenerReference.setPropagationEnabled(propagation);
+  }
+
+  protected void addListener(String expression) {
+    getEvent().createEventListenerReference(expression);
+  }
+
+  protected void addListener(String expression, boolean propagation) {
+    EventListenerReference eventListenerReference = getEvent().createEventListenerReference(expression);
+    eventListenerReference.setPropagationEnabled(propagation);
+  }
+
+  protected EventImpl getEvent() {
+    if (event==null) {
+      this.event = observableElement.createEvent(eventName);
+    }
+    return event;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ProcessDefinitionBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ProcessDefinitionBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ProcessDefinitionBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionBuilder extends CompositeBuilder {
+  
+  private static final Log log = Log.getLog(ProcessDefinitionBuilder.class.getName());
+  
+  protected ProcessDefinitionImpl processDefinition;
+  protected List<UnresolvedFlow> unresolvedFlows = new ArrayList<UnresolvedFlow>();
+
+  protected ProcessDefinitionBuilder(ProcessDefinitionImpl processDefinition) {
+    this.processDefinition = processDefinition;
+    this.compositeElement = processDefinition;
+  }
+
+  public static ProcessDefinitionBuilder startProcess() {
+    return startProcess(null);
+  }
+
+  public static ProcessDefinitionBuilder startProcess(String processDefinitionName) {
+    return startProcess(processDefinitionName, new ProcessDefinitionImpl());
+  }
+
+  public static ProcessDefinitionBuilder startProcess(String processDefinitionName, ProcessDefinitionImpl processDefinition) {
+    processDefinition.setName(processDefinitionName);
+    return new ProcessDefinitionBuilder(processDefinition);
+  }
+  
+  public ProcessDefinitionImpl endProcess() {
+    verifyInitial();
+    resolveFlows();
+    return processDefinition;
+  }
+
+  protected void verifyInitial() {
+    if (processDefinition.getInitial()==null) {
+      errorNoInitial();
+    }
+  }
+
+  protected void resolveFlows() {
+    for (UnresolvedFlow unresolvedFlow: unresolvedFlows) {
+      ActivityImpl destination = (ActivityImpl) processDefinition.findActivity(unresolvedFlow.destinationName);
+      if (destination==null) {
+        errorUnexistingFlowDestination(unresolvedFlow);
+      }
+      destination.addIncomingTransition(unresolvedFlow.transition);
+    }
+  }
+
+  public ProcessDefinitionBuilder key(String key) {
+    processDefinition.setKey(key);
+    return this;
+  }
+
+  public ProcessDefinitionBuilder version(int version) {
+    processDefinition.setVersion(version);
+    return this;
+  }
+
+  public ProcessDefinitionBuilder description(String description) {
+    processDefinition.setDescription(description);
+    return this;
+  }
+
+  public ProcessDefinitionBuilder attachment(String name, InputStream inputStream) {
+    processDefinition.addAttachment(name, inputStream);
+    return this;
+  }
+
+  public ProcessDefinitionBuilder attachment(String name, byte[] bytes) {
+    processDefinition.addAttachment(name, bytes);
+    return this;
+  }
+
+
+  protected void addUnresolvedFlow(UnresolvedFlow unresolvedFlow) {
+    unresolvedFlows.add(unresolvedFlow);
+  }
+
+  protected void setProcessDefinitionInitial(ActivityImpl initial) {
+    if (processDefinition.getInitial()!=null) {
+      errorMultipleInitials(initial);
+    }
+    processDefinition.setInitial(initial);
+  }
+
+  protected void errorMultipleInitials(ActivityImpl initial) {
+    log.error("multiple initial activities: "+processDefinition.getInitial()+" and "+initial);
+  }
+
+  protected void errorNoInitial() {
+    log.error("no initial activity");
+  }
+
+  protected void errorUnexistingFlowDestination(UnresolvedFlow unresolvedFlow) {
+    String sourceActivityName = unresolvedFlow.transition.getSource().getName();
+    log.error("unexisting transition destination: "+sourceActivityName+"-->"+unresolvedFlow.destinationName);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/TimerBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/TimerBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/TimerBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import java.util.Date;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TimerBuilder extends ObservableBuilder {
+  
+  protected CompositeBuilder compositeBuilder;
+  protected TimerDefinitionImpl timerDefinition;
+
+  public TimerBuilder(CompositeBuilder compositeBuilder, String eventName) {
+    super(compositeBuilder.compositeElement, eventName);
+    this.compositeBuilder = compositeBuilder;
+    
+    timerDefinition = compositeBuilder.compositeElement.createTimerDefinition();
+  }
+  
+  public TimerBuilder dueDate(String dueDateCalendarExpression) {
+    timerDefinition.setDueDateDescription(dueDateCalendarExpression);
+    return this;
+  }
+  
+  public TimerBuilder dueDate(Date dueDate) {
+    timerDefinition.setDueDate(dueDate);
+    return this;
+  }
+  
+  public TimerBuilder repeat(String repeatCalendarExpression) {
+    timerDefinition.setRepeat(repeatCalendarExpression);
+    return this;
+  }
+  
+  public TimerBuilder retries(int retries) {
+    timerDefinition.setRetries(retries);
+    return this;
+  }
+
+  public TimerBuilder signal(String signalName) {
+    timerDefinition.setSignalName(signalName);
+    return this;
+  }
+  
+  public TimerBuilder exclusive() {
+    timerDefinition.setExclusive(true);
+    return this;
+  }
+  
+  public TimerBuilder listener(EventListener eventListener) {
+    addListener(eventListener);
+    return this;
+  }
+
+  public TimerBuilder listener(EventListener eventListener, boolean propagation) {
+    addListener(eventListener, propagation);
+    return this;
+  }
+
+  public TimerBuilder listener(Descriptor descriptor) {
+    addListener(descriptor);
+    return this;
+  }
+
+  public TimerBuilder listener(Descriptor descriptor, boolean propagation) {
+    addListener(descriptor, propagation);
+    return this;
+  }
+
+  public TimerBuilder listener(String expression) {
+    addListener(expression);
+    return this;
+  }
+
+  public TimerBuilder listener(String expression, boolean propagation) {
+    addListener(expression, propagation);
+    return this;
+  }
+
+  public CompositeBuilder endTimer() {
+    return compositeBuilder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/UnresolvedFlow.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/UnresolvedFlow.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/UnresolvedFlow.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UnresolvedFlow {
+
+  TransitionImpl transition;
+  String destinationName;
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.builder;
+
+import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableBuilder {
+  
+  protected CompositeBuilder compositeBuilder;
+  protected VariableDefinitionImpl variableDefinition; 
+
+  public VariableBuilder(CompositeBuilder compositeBuilder) {
+    this.compositeBuilder = compositeBuilder;
+    variableDefinition = compositeBuilder.compositeElement.createVariableDefinition();
+  }
+  
+  public VariableBuilder name(String name) {
+    variableDefinition.setName(name);
+    return this;
+  }
+
+  public VariableBuilder type(String type) {
+    variableDefinition.setTypeName(type);
+    return this;
+  }
+  
+  public VariableBuilder initialValue(Descriptor initialValueDescriptor) {
+    variableDefinition.setInDescriptor(initialValueDescriptor);
+    return this;
+  }
+
+  public VariableBuilder initialExpression(String initialExpression) {
+    variableDefinition.setInExpression(initialExpression);
+    return this;
+  }
+
+  public VariableBuilder initialVariable(String initialVariable) {
+    variableDefinition.setInVariableName(initialVariable);
+    return this;
+  }
+  
+  public VariableBuilder outVariable(String outVariable) {
+    variableDefinition.setOutVariableName(outVariable);
+    return this;
+  }
+  
+  public CompositeBuilder endVariable() {
+    return compositeBuilder;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendar.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendar.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendar.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cal;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * a calendar that knows about business hours.
+ */
+public class BusinessCalendar implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+  private static BusinessCalendar instance = null;
+  
+  protected long oid = -1;
+  protected int version = 0;
+  protected TimeZone timeZone = TimeZone.getDefault();
+  /** array that contains the weekdays in the index as specified by {@link Calendar#SUNDAY} (=1),
+   * {@link Calendar#MONDAY} (=2),... {@link Calendar#SATURDAY} (=7).  
+   */ 
+  protected Day[] days = null;
+  protected Holiday[] holidays = null;
+  
+  protected long secondInMillis = 1000; 
+  protected long minuteInMillis = 60000; 
+  protected long hourInMillis = 3600000; 
+  protected long dayInMillis = 24*hourInMillis; 
+  protected long weekInMillis = 7*dayInMillis; 
+  protected long monthInMillis = 30*dayInMillis; 
+  protected long yearInMillis = 365*dayInMillis; 
+
+  protected long businessDayInMillis = 8*hourInMillis; 
+  protected long businessWeekInMillis = 40*hourInMillis; 
+  protected long businessMonthInMillis = 21*dayInMillis; 
+  protected long businessYearInMillis = 220*dayInMillis; 
+  
+  /** constructor for persistence and creating an empty business calendar */
+  public BusinessCalendar() {
+  }
+
+  public static synchronized BusinessCalendar getInstance() {
+    if (instance==null) {
+      instance = new BusinessCalendar();
+    }
+    return instance;
+  }
+
+  public Date add(Date date, Duration duration) {
+    Date end = null;
+    if (duration.isBusinessTime()) {
+      DayPart dayPart = findDayPart(date);
+      boolean isInbusinessHours = (dayPart!=null);
+      if (! isInbusinessHours) {
+        Object[] result = new Object[2];
+        findDay(date).findNextDayPartStart(0, date, result);
+        date = (Date) result[0];
+        dayPart = (DayPart) result[1];
+      }
+      long millis = convertToMillis(duration);
+      end = dayPart.add(date, millis, duration.isBusinessTime());
+    } else {
+      long millis = convertToMillis(duration);
+      end = new Date(date.getTime()+millis);
+    }
+    return end;
+  }
+
+  public long convertToMillis(Duration duration){
+    long millis = duration.getMillis();
+    millis += duration.getSeconds() * secondInMillis;
+    millis += duration.getMinutes() * minuteInMillis;
+    millis += duration.getHours() * hourInMillis;
+    if (duration.isBusinessTime()) {
+      millis += duration.getDays() * businessDayInMillis;
+      millis += duration.getWeeks() * businessWeekInMillis;
+      millis += duration.getMonths() * businessMonthInMillis;
+      millis += duration.getYears() * businessYearInMillis;
+    } else {
+      millis += duration.getDays() * dayInMillis;
+      millis += duration.getWeeks() * weekInMillis;
+      millis += duration.getMonths() * monthInMillis;
+      millis += duration.getYears() * yearInMillis;
+    }
+    return millis;
+  }
+
+  public boolean isInBusinessHours(Date date) { 
+    return (findDayPart(date)!=null); 
+  } 
+
+  public boolean isHoliday(Date date) {
+    if (holidays!=null) {
+      for(Holiday holiday: holidays) {
+        if (holiday.includes(date)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  protected Date findStartOfNextDay(Date date) {
+    Calendar calendar = createCalendar();
+    calendar.setTime(date);
+    calendar.add(Calendar.DATE, 1);
+    calendar.set(Calendar.HOUR_OF_DAY, 0);
+    calendar.set(Calendar.MINUTE, 0);
+    calendar.set(Calendar.SECOND, 0);
+    calendar.set(Calendar.MILLISECOND, 0);
+    date = calendar.getTime();
+    while(isHoliday(date)) {
+      calendar.setTime(date);
+      calendar.add(Calendar.DATE, 1);
+      date = calendar.getTime();
+    }
+    return date;
+  }
+
+  public Calendar createCalendar() {
+    return new GregorianCalendar();
+  }
+
+  protected Day findDay(Date date) {
+    Calendar calendar = createCalendar();
+    calendar.setTime(date);
+    int weekDayIndex = calendar.get(Calendar.DAY_OF_WEEK);
+    return days[weekDayIndex];
+  }
+
+  protected DayPart findDayPart(Date date) {
+    DayPart dayPart = null;
+    if (! isHoliday(date)) {
+      Day day = findDay(date);
+      DayPart[] dayParts = day.getDayParts();
+      if (dayParts!=null) {
+        for (int i=0; ((i < dayParts.length) && (dayPart==null)); i++) {
+          DayPart candidate = dayParts[i];
+          if (candidate.includes(date)) {
+            dayPart = candidate;
+          }
+        }
+      }
+    }
+    return dayPart;
+  }
+
+  protected DayPart findNextDayPart(Date date) { 
+    DayPart nextDayPart = null; 
+    while(nextDayPart==null) { 
+      nextDayPart = findDayPart(date); 
+      if (nextDayPart==null) { 
+        date = findStartOfNextDay(date); 
+        Object result[] = new Object[2]; 
+        Day day = findDay(date); 
+        day.findNextDayPartStart(0, date, result); 
+        nextDayPart = (DayPart) result[1]; 
+      } 
+    } 
+    return nextDayPart; 
+  }
+
+  
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public long getBusinessDayInMillis() {
+    return businessDayInMillis;
+  }
+  public void setBusinessDayInMillis(long businessDayInMillis) {
+    this.businessDayInMillis = businessDayInMillis;
+  }
+  public long getBusinessMonthInMillis() {
+    return businessMonthInMillis;
+  }
+  public void setBusinessMonthInMillis(long businessMonthInMillis) {
+    this.businessMonthInMillis = businessMonthInMillis;
+  }
+  public long getBusinessWeekInMillis() {
+    return businessWeekInMillis;
+  }
+  public void setBusinessWeekInMillis(long businessWeekInMillis) {
+    this.businessWeekInMillis = businessWeekInMillis;
+  }
+  public long getBusinessYearInMillis() {
+    return businessYearInMillis;
+  }
+  public void setBusinessYearInMillis(long businessYearInMillis) {
+    this.businessYearInMillis = businessYearInMillis;
+  }
+  public long getDayInMillis() {
+    return dayInMillis;
+  }
+  public void setDayInMillis(long dayInMillis) {
+    this.dayInMillis = dayInMillis;
+  }
+  public Day[] getDays() {
+    return days;
+  }
+  public void setDays(Day[] days) {
+    this.days = days;
+  }
+  public Holiday[] getHolidays() {
+    return holidays;
+  }
+  public void setHolidays(Holiday[] holidays) {
+    this.holidays = holidays;
+  }
+  public long getHourInMillis() {
+    return hourInMillis;
+  }
+  public void setHourInMillis(long hourInMillis) {
+    this.hourInMillis = hourInMillis;
+  }
+  public long getMinuteInMillis() {
+    return minuteInMillis;
+  }
+  public void setMinuteInMillis(long minuteInMillis) {
+    this.minuteInMillis = minuteInMillis;
+  }
+  public long getMonthInMillis() {
+    return monthInMillis;
+  }
+  public void setMonthInMillis(long monthInMillis) {
+    this.monthInMillis = monthInMillis;
+  }
+  public long getSecondInMillis() {
+    return secondInMillis;
+  }
+  public void setSecondInMillis(long secondInMillis) {
+    this.secondInMillis = secondInMillis;
+  }
+  public TimeZone getTimeZone() {
+    return timeZone;
+  }
+  public void setTimeZone(TimeZone timeZone) {
+    this.timeZone = timeZone;
+  }
+  public long getWeekInMillis() {
+    return weekInMillis;
+  }
+  public void setWeekInMillis(long weekInMillis) {
+    this.weekInMillis = weekInMillis;
+  }
+  public long getYearInMillis() {
+    return yearInMillis;
+  }
+  public void setYearInMillis(long yearInMillis) {
+    this.yearInMillis = yearInMillis;
+  } 
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Day.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Day.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Day.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cal;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * is a day on a business calendar.
+ */
+public class Day implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected long oid = -1;
+  protected int version = 0;
+  protected DayPart[] dayParts = null;
+  protected BusinessCalendar businessCalendar = null;
+
+  public void findNextDayPartStart(int dayPartIndex, Date date, Object[] result) {
+    // if there is a day part in this day that starts after the given date
+    if ( (dayParts!=null)
+         && (dayPartIndex < dayParts.length)
+       ) {
+      if (dayParts[dayPartIndex].isStartAfter(date)) {
+        result[0] = dayParts[dayPartIndex].getStartTime(date);
+        result[1] = dayParts[dayPartIndex];
+      } else {
+        findNextDayPartStart(dayPartIndex+1, date, result);
+      }
+    } else {
+      // descend recustively
+      date = businessCalendar.findStartOfNextDay(date);
+      Day nextDay = businessCalendar.findDay(date);
+      nextDay.findNextDayPartStart(0, date, result);
+    }
+  }
+
+  public BusinessCalendar getBusinessCalendar() {
+    return businessCalendar;
+  }
+  public DayPart[] getDayParts() {
+    return dayParts;
+  }
+  public void setBusinessCalendar(BusinessCalendar businessCalendar) {
+    this.businessCalendar = businessCalendar;
+  }
+  public void setDayParts(DayPart[] dayParts) {
+    this.dayParts = dayParts;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/DayPart.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/DayPart.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/DayPart.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cal;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * is part of a day that can for example be used to represent business hours. 
+ *
+ */
+public class DayPart implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long oid = -1;
+  protected int version = 0;
+  protected int fromHour = -1;
+  protected int fromMinute = -1;
+  protected int toHour = -1;
+  protected int toMinute = -1;
+  protected Day day = null;
+  protected int index = -1;
+
+  public Date add(Date date, long millis, boolean isBusinessTime) {
+    Date end = null;
+    
+    BusinessCalendar businessCalendar = day.getBusinessCalendar();
+    Calendar calendar = businessCalendar.createCalendar();
+    calendar.setTime(date);
+    int hour = calendar.get(Calendar.HOUR_OF_DAY);
+    int minute = calendar.get(Calendar.MINUTE);
+
+    long dateMilliseconds = ((hour*60)+minute)*60*1000;
+    long dayPartEndMilleseconds = ((toHour*60)+toMinute)*60*1000;
+    long millisecondsInThisDayPart = dayPartEndMilleseconds - dateMilliseconds;
+    
+    if (millis <= millisecondsInThisDayPart) {
+      end = new Date( date.getTime() + millis);
+    } else {
+      long remainderMillis = millis - millisecondsInThisDayPart;
+      Date dayPartEndDate = new Date(date.getTime() + millis - remainderMillis);
+      
+      Object[] result = new Object[2];
+      day.findNextDayPartStart(index+1, dayPartEndDate, result);
+      Date nextDayPartStart = (Date) result[0];
+      DayPart nextDayPart = (DayPart) result[1];
+      
+      end = nextDayPart.add(nextDayPartStart, remainderMillis, isBusinessTime);
+    }
+    
+    return end;
+  }
+  
+  public boolean isStartAfter(Date date) {
+    Calendar calendar = day.getBusinessCalendar().createCalendar();
+    calendar.setTime(date);
+    int hour = calendar.get(Calendar.HOUR_OF_DAY);
+    int minute = calendar.get(Calendar.MINUTE);
+    
+    return ( (hour<fromHour)
+             || ( (hour==fromHour)
+                  && (minute<=fromMinute) 
+                ) 
+           );
+  }
+
+
+  public boolean includes(Date date) {
+    Calendar calendar = day.getBusinessCalendar().createCalendar();
+    calendar.setTime(date);
+    int hour = calendar.get(Calendar.HOUR_OF_DAY);
+    int minute = calendar.get(Calendar.MINUTE);
+    
+    return ( ( (fromHour<hour)
+               || ( (fromHour==hour)
+                   && (fromMinute<=minute) 
+                 )
+             ) &&
+             ( (hour<toHour)
+               || ( (hour==toHour)
+                    && (minute<=toMinute) 
+                  )
+             )
+           );
+  }
+
+  public Date getStartTime(Date date) {
+    Calendar calendar = day.getBusinessCalendar().createCalendar();
+    calendar.setTime(date);
+    calendar.set(Calendar.HOUR_OF_DAY, fromHour);
+    calendar.set(Calendar.MINUTE, fromMinute);
+    return calendar.getTime();
+  }
+  
+  public Day getDay() {
+    return day;
+  }
+  public void setDay(Day day) {
+    this.day = day;
+  }
+  public int getFromHour() {
+    return fromHour;
+  }
+  public void setFromHour(int fromHour) {
+    this.fromHour = fromHour;
+  }
+  public int getFromMinute() {
+    return fromMinute;
+  }
+  public void setFromMinute(int fromMinute) {
+    this.fromMinute = fromMinute;
+  }
+  public int getIndex() {
+    return index;
+  }
+  public void setIndex(int index) {
+    this.index = index;
+  }
+  public int getToHour() {
+    return toHour;
+  }
+  public void setToHour(int toHour) {
+    this.toHour = toHour;
+  }
+  public int getToMinute() {
+    return toMinute;
+  }
+  public void setToMinute(int toMinute) {
+    this.toMinute = toMinute;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Duration.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,293 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cal;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+
+/**
+ * represents a time duration.
+ * 
+ * <p>With the constructor {link {@link #Duration(String)} you can create a 
+ * Duration from a text representation.  The syntax is as follows
+ * </p>
+ * 
+ * <pre>
+ * duration = part [',' part | 'and' part]*
+ * part = number ['business'] unit
+ * number = (0..9)+
+ * unit = (y|year|years|month|months|w|week|weeks|d|day|days|h|hour|hours|min|minute|minutes|s|sec|second|seconds|milli|millis|millisecond|milliseconds)
+ * </pre>
+ * 
+ * <p>Duration is immutable.
+ * </p>
+ */
+public class Duration implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  boolean isBusinessTime;
+  protected int millis;
+  protected int seconds;
+  protected int minutes;
+  protected int hours;
+  protected int days;
+  protected int weeks;
+  protected int months;
+  protected int years;
+
+  /** constructor for persistence.  note that this type is to be immutable. */
+  protected Duration() {
+  }
+
+  /** parses the duration from a text 
+   * 
+   * duration = part [',' part | 'and' part]*
+   * part = number ['business'] unit
+   * number = (0..9)+
+   * unit = (y|year|years|month|months|w|week|weeks|d|day|days|h|hour|hours|min|minute|minutes|s|sec|second|seconds|milli|millis|millisecond|milliseconds)
+   * 
+   * @throws JbpmException if the parsing is unsuccessful
+   */
+  public Duration(String text) {
+    if (text==null) throw new JbpmException("text is null");
+
+    for (String part: splitInParts(text)) {
+      parsePart(part);
+    }
+    
+    isBusinessTime = text.indexOf("business")!=-1;
+  }
+
+  public Duration(boolean isBusinessTime, int millis, int seconds, int minutes, int hours, int days, int weeks, int months, int years) {
+    this.isBusinessTime = isBusinessTime;
+    this.millis = millis;
+    this.seconds = seconds;
+    this.minutes = minutes;
+    this.hours = hours;
+    this.days = days;
+    this.weeks = weeks;
+    this.months = months;
+    this.years = years;
+  }
+  
+  private List<String> splitInParts(String text) {
+    List<String> parts = new ArrayList<String>(2);
+    while (text!=null) {
+      int commaIndex = text.indexOf(',');
+      int andIndex = text.indexOf(" and ");
+      if ( ( (commaIndex==-1) 
+             && (andIndex!=-1)
+           ) 
+           || 
+           ( ( (commaIndex!=-1) 
+               && (andIndex!=-1)
+             ) 
+             && (andIndex<commaIndex)
+           )
+         ) {
+        String part = text.substring(0, andIndex).trim();
+        parts.add(part);
+        text = text.substring(andIndex+5);
+        
+      } else if ( ( (commaIndex!=-1) 
+                    && (andIndex==-1)
+                  ) 
+                  || 
+                  ( ( (commaIndex!=-1) 
+                      && (andIndex!=-1)
+                    ) 
+                    && (andIndex>commaIndex)
+                  )
+                ) {
+        String part = text.substring(0, commaIndex).trim();
+        parts.add(part);
+        text = text.substring(commaIndex+1);
+        
+      } else {
+        parts.add(text.trim());
+        text = null;
+      }
+    }
+
+    return parts;
+  }
+
+  private void parsePart(String part) {
+    int spaceIndex = part.indexOf(' ');
+    if (spaceIndex==-1) {
+      throw new JbpmException("couldn't parse duration part "+part);
+    }
+    String quantityText = part.substring(0, spaceIndex).trim();
+    spaceIndex = part.lastIndexOf(' ');
+    String unitText = part.substring(spaceIndex+1).trim().toLowerCase();
+    
+    int quantity;
+    try {
+      quantity = Integer.parseInt(quantityText);
+    } catch (NumberFormatException e) {
+      throw new JbpmException("couldn't parse quantity "+quantityText+" in duration text", e);
+    }
+    FieldSetter fieldSetter = fieldSetters.get(unitText);
+    if (fieldSetter==null) {
+      throw new JbpmException("couldn't parse quantity "+quantityText);
+    }
+    fieldSetter.set(this, quantity);
+  }
+  
+  private interface FieldSetter {
+    void set(Duration duration, int quantity);
+  }
+  private static class MillisSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.millis = quantity;
+    }
+  }
+  private static class SecondSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.seconds = quantity;
+    }
+  }
+  private static class MinuteSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.minutes = quantity;
+    }
+  }
+  private static class HourSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.hours = quantity;
+    }
+  }
+  private static class DaySetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.days = quantity;
+    }
+  }
+  private static class WeekSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.weeks = quantity;
+    }
+  }
+  private static class MonthSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.months = quantity;
+    }
+  }
+  private static class YearSetter implements FieldSetter {
+    public void set(Duration duration, int quantity) {
+      duration.years = quantity;
+    }
+  }
+
+  private static final Map<String, FieldSetter> fieldSetters = new HashMap<String, FieldSetter>();
+  static {
+    FieldSetter fieldSetter = new MillisSetter();
+    fieldSetters.put("milli", fieldSetter);
+    fieldSetters.put("millis", fieldSetter);
+    fieldSetters.put("millisecond", fieldSetter);
+    fieldSetters.put("milliseconds", fieldSetter);
+
+    fieldSetter = new SecondSetter();
+    fieldSetters.put("s", fieldSetter);
+    fieldSetters.put("sec", fieldSetter);
+    fieldSetters.put("second", fieldSetter);
+    fieldSetters.put("seconds", fieldSetter);
+
+    fieldSetter = new MinuteSetter();
+    fieldSetters.put("min", fieldSetter);
+    fieldSetters.put("minute", fieldSetter);
+    fieldSetters.put("minutes", fieldSetter);
+
+    fieldSetter = new HourSetter();
+    fieldSetters.put("h", fieldSetter);
+    fieldSetters.put("hour", fieldSetter);
+    fieldSetters.put("hours", fieldSetter);
+
+    fieldSetter = new DaySetter();
+    fieldSetters.put("d", fieldSetter);
+    fieldSetters.put("day", fieldSetter);
+    fieldSetters.put("days", fieldSetter);
+
+    fieldSetter = new WeekSetter();
+    fieldSetters.put("w", fieldSetter);
+    fieldSetters.put("week", fieldSetter);
+    fieldSetters.put("weeks", fieldSetter);
+
+    fieldSetter = new MonthSetter();
+    fieldSetters.put("month", fieldSetter);
+    fieldSetters.put("months", fieldSetter);
+
+    fieldSetter = new YearSetter();
+    fieldSetters.put("y", fieldSetter);
+    fieldSetters.put("year", fieldSetter);
+    fieldSetters.put("years", fieldSetter);
+  }
+  
+  public int getDays() {
+    return days;
+  }
+
+  
+  public int getHours() {
+    return hours;
+  }
+
+  
+  public boolean isBusinessTime() {
+    return isBusinessTime;
+  }
+
+  
+  public int getMillis() {
+    return millis;
+  }
+
+  
+  public int getMinutes() {
+    return minutes;
+  }
+
+  
+  public int getMonths() {
+    return months;
+  }
+
+  
+  public int getSeconds() {
+    return seconds;
+  }
+
+  
+  public int getWeeks() {
+    return weeks;
+  }
+
+  
+  public int getYears() {
+    return years;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Holiday.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Holiday.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/Holiday.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cal;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * identifies a continuous set of days.
+ */
+public class Holiday implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected long oid = -1;
+  protected int version = 0;
+  protected Date fromDay = null;
+  protected Date toDay = null;
+  protected BusinessCalendar businessCalendar = null;
+
+  /*
+  public static List parseHolidays(Properties calendarProperties, BusinessCalendar businessCalendar) {
+    List holidays = new ArrayList();
+    
+    DateFormat dateFormat = new SimpleDateFormat(calendarProperties.getProperty("day.format"));
+    Iterator iter = calendarProperties.keySet().iterator();
+    while (iter.hasNext()) {
+      String key = (String) iter.next();
+      if (key.startsWith("holiday")) {
+        Holiday holiday = new Holiday(calendarProperties.getProperty(key), dateFormat, businessCalendar);
+        holidays.add(holiday);
+      }
+    }
+
+    return holidays;
+  }
+
+  public Holiday(String holidayText, DateFormat dateFormat, BusinessCalendar businessCalendar) {
+    this.businessCalendar = businessCalendar;
+    try {
+      int separatorIndex = holidayText.indexOf('-');
+      if (separatorIndex==-1) {
+        fromDay = dateFormat.parse(holidayText.trim());
+        toDay = fromDay;
+      } else {
+        String fromText = holidayText.substring(0, separatorIndex).trim();
+        String toText = holidayText.substring(separatorIndex+1).trim();
+        fromDay = dateFormat.parse(fromText);
+        toDay = dateFormat.parse(toText);
+      }
+      // now we are going to set the toDay to the end of the day, rather then the beginning.
+      // we take the start of the next day as the end of the toDay.
+      Calendar calendar = businessCalendar.createCalendar();
+      calendar.setTime(toDay);
+      calendar.add(Calendar.DATE, 1);
+      toDay = calendar.getTime();
+      
+    } catch (ParseException e) {
+      throw new PvmException("couldn't parse holiday '"+holidayText+"'", e);
+    }
+  }
+  */
+
+  public boolean includes(Date date) {
+    return ( (fromDay.getTime()<=date.getTime())
+             && (date.getTime()<toDay.getTime())
+           );
+  }
+  public BusinessCalendar getBusinessCalendar() {
+    return businessCalendar;
+  }
+  public void setBusinessCalendar(BusinessCalendar businessCalendar) {
+    this.businessCalendar = businessCalendar;
+  }
+  public Date getFromDay() {
+    return fromDay;
+  }
+  public void setFromDay(Date fromDay) {
+    this.fromDay = fromDay;
+  }
+  public Date getToDay() {
+    return toDay;
+  }
+  public void setToDay(Date toDay) {
+    this.toDay = toDay;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>
+a business calendar that knows about business hours.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cfg;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Configuration;
+import org.jbpm.ExecutionService;
+import org.jbpm.HistoryService;
+import org.jbpm.ManagementService;
+import org.jbpm.ProcessEngine;
+import org.jbpm.ProcessService;
+import org.jbpm.TaskService;
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.PvmEnvironment;
+import org.jbpm.pvm.internal.env.PvmEnvironmentFactoryParser;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * an environment factory that also is the process-engine context.
+ * 
+ * <p>
+ * This environment factory will produce environments with 2 contexts: the
+ * process-engine context and the block context.
+ * </p>
+ * 
+ * <p>
+ * An process-engine context is build from two wire definitions: the
+ * process-engine wire definition and the environment wire definition.
+ * </p>
+ * 
+ * <p>
+ * The process-engine context itself is build from the process-engine
+ * wire definition. So all objects that are created in this context remain
+ * cached for the lifetime of this process-engine context object.
+ * </p>
+ * 
+ * <p>
+ * This process-engine context is also a environment factory. The produced
+ * environments contain 2 contexts: the process-engine context itself and a
+ * new environment context, build from the environment wire definition. For each
+ * created environment, a new environment context will be created from the same
+ * environment wire definition. Objects in the environment context will live for
+ * as long as the environment.
+ * </p>
+ * 
+ * @author Tom Baeyens
+ */
+public class JbpmConfiguration extends Configuration implements Context, ProcessEngine, EnvironmentFactory {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(JbpmConfiguration.class.getName());
+  protected static PvmEnvironmentFactoryParser pvmEnvironmentFactoryParser = new PvmEnvironmentFactoryParser();
+
+  protected boolean isConfigured = false;
+  protected WireContext environmentFactoryCtxWireContext = null;
+  protected WireDefinition environmentCtxWireDefinition = null;
+
+  public JbpmConfiguration() {
+    super((Configuration)null);
+  }
+
+  public ProcessEngine buildProcessEngine() {
+    if (!isConfigured) {
+      setResource("jbpm.cfg.xml");
+    }
+    return this;
+  }
+
+  public Configuration setInputStream(InputStream inputStream) {
+    parse(new InputStreamInput(inputStream));
+    return this;
+  }
+
+  public Configuration setResource(String resource) {
+    parse(new ResourceStreamInput(resource, getClassLoader()));
+    return this;
+  }
+
+  public Configuration setUrl(URL url) {
+    parse(new UrlStreamInput(url));
+    return this;
+  }
+
+  public Configuration setFile(File file) {
+    parse(new FileStreamInput(file));
+    return this;
+  }
+
+  public Configuration setXmlString(String xmlString) {
+    parse(new StringStreamInput(xmlString));
+    return this;
+  }
+
+  protected void parse(StreamInput streamSource) {
+    isConfigured = true;
+    PvmEnvironmentFactoryParser.getInstance()
+      .createParse()
+      .setDocumentObject(this)
+      .setStreamSource(streamSource)
+      .execute()
+      .checkProblems("jbpm configuration " + streamSource);
+  }
+  
+  public ExecutionService getExecutionService() {
+    return environmentFactoryCtxWireContext.get(ExecutionService.class);
+  }
+  public HistoryService getHistoryService() {
+    return environmentFactoryCtxWireContext.get(HistoryService.class);
+  }
+  public ManagementService getManagementService() {
+    return environmentFactoryCtxWireContext.get(ManagementService.class);
+  }
+  public ProcessService getProcessService() {
+    return environmentFactoryCtxWireContext.get(ProcessService.class);
+  }
+  public TaskService getTaskService() {
+    return environmentFactoryCtxWireContext.get(TaskService.class);
+  }
+
+  public TaskService getTaskService(Map<String, Object> txResources) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+  public HistoryService getHistoryService(Map<String, Object> txResources) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+  public ExecutionService getExecutionService(Map<String, Object> txResources) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+  public ProcessService getProcessService(Map<String, Object> txResources) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+  public ManagementService getManagementService(Map<String, Object> txResources) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+
+  
+  public static EnvironmentFactory parseXmlString(String xmlString) {
+    JbpmConfiguration jbpmConfiguration = new JbpmConfiguration();
+    jbpmConfiguration.setXmlString(xmlString);
+    jbpmConfiguration.buildProcessEngine();
+    return jbpmConfiguration;
+  }
+
+  public Environment openEnvironment() {
+    PvmEnvironment environment = new PvmEnvironment(this);
+
+    log.debug("opening " + environment);
+
+    // set the classloader
+    ClassLoader classLoader = environmentFactoryCtxWireContext.getClassLoader();
+    if (classLoader != null) {
+      environment.setClassLoader(classLoader);
+    }
+
+    // add the process-engine context
+    environment.addContext(environmentFactoryCtxWireContext);
+
+    // add the environment block context
+    WireContext environmentContext = new WireContext(environmentCtxWireDefinition, Context.CONTEXTNAME_TRANSACTION, environment, true);
+    // add the environment block context to the environment
+    environment.addContext(environmentContext);
+
+    Environment.pushEnvironment(environment);
+    try {
+      // finish the creation of the environment wire context
+      environmentContext.create();
+
+    } catch (RuntimeException e) {
+      Environment.popEnvironment();
+      throw e;
+    }
+
+    // if all went well, return the created environment
+    return environment;
+  }
+
+  public void close() {
+    environmentFactoryCtxWireContext.fire(WireContext.EVENT_CLOSE, null);
+  }
+
+  // process-engine context delegation methods
+  // ///////////////////////////////////
+
+  public Object get(String key) {
+    return environmentFactoryCtxWireContext.get(key);
+  }
+
+  public <T> T get(Class<T> type) {
+    return environmentFactoryCtxWireContext.get(type);
+  }
+
+  public String getName() {
+    return environmentFactoryCtxWireContext.getName();
+  }
+
+  public boolean has(String key) {
+    return environmentFactoryCtxWireContext.has(key);
+  }
+
+  public Set<String> keys() {
+    return environmentFactoryCtxWireContext.keys();
+  }
+
+  public Object set(String key, Object value) {
+    return environmentFactoryCtxWireContext.set(key, value);
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public void setEnvironmentCtxWireDefinition(WireDefinition blockWireDefinition) {
+    this.environmentCtxWireDefinition = blockWireDefinition;
+  }
+  public WireContext getEnvironmentFactoryCtxWireContext() {
+    return environmentFactoryCtxWireContext;
+  }
+  public void setEnvironmentFactoryCtxWireContext(WireContext applicationWireContext) {
+    this.environmentFactoryCtxWireContext = applicationWireContext;
+  }
+  public WireDefinition getEnvironmentCtxWireDefinition() {
+    return environmentCtxWireDefinition;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cfg;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.spring.SpringEnvironment;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/** this environment factory will see only the singleton beans.
+ * 
+ * The created {@link SpringEnvironment}s will see the prototype 
+ * beans and it will cache them.
+ *  
+ * @author Tom Baeyens
+ */
+public class SpringConfiguration implements EnvironmentFactory, ApplicationContextAware {
+  
+  // TODO pull up the common behaviour between this class and the SpringEnvironmentContext
+  
+  private static final long serialVersionUID = 1L;
+  
+  ApplicationContext applicationContext;
+  
+  public SpringEnvironment openEnvironment() {
+    return new SpringEnvironment(this);
+  }
+
+  public boolean has(String key) {
+    return applicationContext.isSingleton(key);
+  }
+
+  public Object get(String key) {
+    if (has(key)) {
+      return applicationContext.getBean(key);
+    }
+    return null;
+  }
+
+  public <T> T get(Class<T> type) {
+    String name = ReflectUtil.getUnqualifiedClassName(type);
+    name = name.substring(0, 1).toLowerCase() + name.substring(1);
+    return (T) get(name);
+  }
+
+  public Set<String> keys() {
+    HashSet<String> keys = new HashSet<String>();
+    for (String key : applicationContext.getBeanDefinitionNames()) {
+      if (has(key)) {
+        keys.add(key);
+      }
+    }
+    return keys;
+  }
+  
+  public ApplicationContext getApplicationContext() {
+    return applicationContext;
+  }
+
+  public void setApplicationContext(ApplicationContext applicationContext) {
+    this.applicationContext = applicationContext;
+  }
+
+  
+  public void close() {
+  }
+
+  public String getName() {
+    return null;
+  }
+
+  public Object set(String key, Object value) {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AbstractCommand<T> implements Command<T> {
+
+  // TODO: REMOVE
+  protected ClientExecution getExecution(Environment environment, long executionDbid) {
+    DbSession dbSession = environment.get(DbSession.class);
+    ClientExecution execution = dbSession.get(ExecutionImpl.class, executionDbid);
+    if (execution==null) {
+      throw new CommandException("execution "+executionDbid+" doesn't exist");
+    }
+    return execution;
+  }
+
+  protected ClientExecution getExecution(Environment environment, String executionId) {
+    PvmDbSession dbSession = environment.get(PvmDbSession.class);
+    ClientExecution execution = dbSession.findExecutionById(executionId);
+    if (execution==null) {
+      throw new CommandException("execution "+executionId+" doesn't exist");
+    }
+    return execution;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddParticipantCmd implements Command<Object> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  protected IdentityRef identityRef;
+  protected String participation;
+  
+  public AddParticipantCmd(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+    this.taskDbid = taskDbid;
+    this.swimlaneDbid = swimlaneDbid;
+    this.identityRef = identityRef;
+    this.participation = participation;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = Environment.getFromCurrent(Session.class);
+    
+    if (taskDbid!=null) {
+      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+      if (task==null) {
+        throw new JbpmException("task "+taskDbid+" was not found");
+      }
+
+      task.addParticipant(identityRef, participation);
+    }
+
+    /*
+    if (swimlaneDbid!=null) {
+      SwimlaneImpl swimlane = (TaskImpl) session.get(SwimlaneImpl.class, swimlaneDbid);
+      if (swimlane==null) {
+        throw new JbpmException("swimlane "+swimlaneDbid+" was not found");
+      }
+
+      swimlane.addRole(identityType, identityId, roleName);
+    }
+    */
+
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddReplyCommentCmd implements Command<Comment> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long commentDbid;
+  protected String message;
+  
+  public AddReplyCommentCmd(long commentDbid, String message) {
+    this.commentDbid = commentDbid;
+    this.message = message;
+  }
+
+  public Comment execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    CommentImpl parentComment = dbSession.get(CommentImpl.class, commentDbid);
+    Comment replyComment = parentComment.createComment(message);
+    return replyComment;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddTaskCommentCmd implements Command<Comment> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  protected String message;
+  
+  public AddTaskCommentCmd(long taskDbid, String message) {
+    this.taskDbid = taskDbid;
+    this.message = message;
+  }
+
+  public Comment execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
+    Comment comment = task.createComment(message);
+    return comment;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandException.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandException.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandException.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CommandException extends JbpmException {
+
+  private static final long serialVersionUID = 1L;
+
+  public CommandException() {
+    super();
+  }
+
+  public CommandException(String msg, Throwable cause) {
+    super(msg, cause);
+  }
+
+  public CommandException(String msg) {
+    super(msg);
+  }
+
+  public CommandException(Throwable cause) {
+    super(cause);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+
+
+/** container for executing multiple commands in one transaction. 
+ * 
+ * @author Tom Baeyens
+ */
+public class CompositeCmd implements Command<Void> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected List<Command<?>> commands = new ArrayList<Command<?>>();
+
+  public Void execute(Environment environment) throws Exception {
+    for (Command command: commands) {
+      command.execute(environment);
+    }
+    return null;
+  }
+
+  public void addCommand(Command<?> command) {
+    commands.add(command);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteCommentCmd implements Command<Object> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected long commentDbid;
+  
+  public DeleteCommentCmd(long commentDbid) {
+    this.commentDbid = commentDbid;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    CommentImpl comment = (CommentImpl) dbSession.get(CommentImpl.class, commentDbid);
+    if (comment!=null) {
+      dbSession.delete(comment);
+      
+    } else {
+      throw new JbpmException("comment "+commentDbid+" doesn't exist");
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteProcessDefinitionCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+  
+  String processDefinitionId;
+  boolean deleteProcessInstances;
+  boolean deleteHistory;
+ 
+  public DeleteProcessDefinitionCmd(String processDefinitionId) {
+    this(processDefinitionId, false, false);
+  }
+
+  public DeleteProcessDefinitionCmd(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory) {
+    this.processDefinitionId = processDefinitionId;
+    this.deleteProcessInstances = deleteProcessInstances;
+    this.deleteHistory = deleteHistory;
+  }
+
+  public Void execute(Environment environment) {
+    PvmDbSession pvmDbSession = Environment.getFromCurrent(PvmDbSession.class);
+    if (pvmDbSession==null) {
+      throw new JbpmException("no "+PvmDbSessionBinding.TAG+" configured");
+    }
+    pvmDbSession.deleteProcessDefinition(processDefinitionId, deleteProcessInstances, deleteHistory);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteProcessInstance implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  String processInstanceId;
+  
+  public DeleteProcessInstance(String processInstanceId) {
+    this.processInstanceId = processInstanceId;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = Environment.getFromCurrent(PvmDbSession.class);
+    pvmDbSession.deleteProcessInstance(processInstanceId);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class DeleteTaskCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long taskDbid;
+
+  public DeleteTaskCmd(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
+    if (task!=null) {
+      dbSession.delete(task);
+    } else {
+      throw new JbpmException("task "+taskDbid+" doesn't exist");
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeployCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.deploy.DeployerManager;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeployCmd implements Command<List<ProcessDefinition>> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected DeploymentImpl deployment;
+  
+  public DeployCmd(DeploymentImpl deployment) {
+    this.deployment = deployment;
+  }
+
+  public List<ProcessDefinition> execute(Environment environment) throws Exception {
+    DeployerManager deployerManager = environment.get(DeployerManager.class);
+    if (deployerManager==null) {
+      throw new JbpmException("no "+DeployerManager.class.getName()+" configured");
+    }
+
+    // let the process parser managemer determine the process language
+    // and handle the deployment
+    deployerManager.deploy(deployment);
+    
+    List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
+    for (String objectName: deployment.getObjectNames()) {
+      Object object = deployment.getObject(objectName);
+      if (object instanceof ProcessDefinition) {
+        processDefinitions.add((ProcessDefinition) object);
+      }
+    }
+
+    return processDefinitions;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/EndProcessInstance.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/EndProcessInstance.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/EndProcessInstance.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndProcessInstance implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processInstanceId;
+  protected String state;
+  
+  public EndProcessInstance(String processInstanceId, String state) {
+    super();
+    this.processInstanceId = processInstanceId;
+    this.state = state;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = Environment.getFromCurrent(PvmDbSession.class);
+    ExecutionImpl processInstance = (ExecutionImpl) pvmDbSession.findProcessInstanceById(processInstanceId);
+    processInstance.end(state);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Date;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExceptionHandler;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecuteJobCmd implements Command<Job> {
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(ExecuteJobCmd.class.getName());
+  
+  protected long jobDbid;
+
+  public ExecuteJobCmd(long jobDbid) {
+    this.jobDbid = jobDbid;
+  }
+
+  public Job execute(Environment environment) throws Exception {
+  	JobDbSession session = environment.get(JobDbSession.class);
+  	if (session==null) {
+  	  throw new JbpmException("no job session configured to get job "+jobDbid+" for execution");
+  	}
+    JobImpl<?> job = (JobImpl<?>) session.get(JobImpl.class, jobDbid);
+
+  	// in case of exclusive jobs, the job might have been deleted
+  	// before we execute it (they are in a list)
+  	if (job != null) {
+	    try {
+	      log.debug("executing job "+job+"...");
+	      job.execute(environment);
+	      log.debug("executed job "+job);
+
+	      // if this job is locked too long, it could be unlocked by the lockmonitor and 
+	      // executed by another thread.
+	      Date lockExpirationDate = job.getLockExpirationTime();
+	      // can be null if it was rescheduled
+	      if (lockExpirationDate != null) {
+		      long lockExpiration = lockExpirationDate.getTime();
+		      long currentTime = System.currentTimeMillis();
+		      if (currentTime>lockExpiration) {
+		        throw new JbpmException("job took too long: lock expired "+(currentTime-lockExpiration)+"ms ago");
+		      }
+	      }
+	    } catch (Throwable exception) {
+	      log.error("exception while executing '"+job+"'", exception);
+	      handleJobExecutionException(environment, job, exception);
+	    }
+
+  	} else {
+  		log.debug("job " + jobDbid + " no longer exists");
+  	}
+    return job;
+  }
+
+  /** This transaction will be marked for rollback.  A command will be associated with the 
+   * Transaction.EVENT_AFTERCOMPLETION (after the job locks of the current transaction are 
+   * released).  Then the command will update the job with the exception details in a separate 
+   * transaction. */
+  protected void handleJobExecutionException(Environment environment, JobImpl<?> job, Throwable exception) {
+    Transaction transaction = environment.get(Transaction.class);
+    transaction.setRollbackOnly();
+
+    CommandService commandService = (CommandService) environment.get(CommandService.class);
+    JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);
+    transaction.registerSynchronization(jobExceptionHandler);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionCmd implements Command<Execution> {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected String executionId;
+  protected String processDefinitionName;
+  protected String executionKey;
+  
+  public FindExecutionCmd(String processDefinitionName, String executionKey) {
+    if (processDefinitionName==null) {
+      throw new JbpmException("processDefinitionName is null");
+    }
+    this.processDefinitionName = processDefinitionName;
+    if (executionKey==null) {
+      throw new JbpmException("executionKey is null");
+    }
+    this.executionKey = executionKey;
+  }
+
+  public FindExecutionCmd(String executionId) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null");
+    }
+    this.executionId = executionId;
+  }
+
+  public Execution execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    if (executionId!=null) {
+      return pvmDbSession.findExecutionById(executionId);
+    } 
+    Execution execution = pvmDbSession.findExecutionByKey(processDefinitionName, executionKey);
+    return execution;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionsCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionsCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindExecutionsCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionsCmd implements Command<List<Execution>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String executionId;
+
+  public FindExecutionsCmd(String executionId) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null");
+    }
+    this.executionId = executionId;
+  }
+
+
+  public List<Execution> execute(Environment environment) throws Exception {
+    List<Execution> executions = new ArrayList<Execution>();
+    
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    ClientExecution execution = pvmDbSession.findExecutionById(executionId);
+    scanExecutions(execution, executions);
+    
+    return executions;
+  }
+
+  public void scanExecutions(OpenExecution execution, List<Execution> executions) {
+
+    executions.add(execution);
+    
+    // initialize activity relation.  this is necessary for the method  
+    // Execution.getActivityName()
+    Activity activity = execution.getActivity();
+    if (activity!=null) {
+      activity.getName();
+    }
+    
+    Collection<OpenExecution> childExecutions = execution.getExecutions();
+    if (childExecutions!=null) {
+      for (OpenExecution childExecution: childExecutions) {
+        scanExecutions(childExecution, executions);
+      }
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByKeyCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByKeyCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByKeyCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindLatestProcessDefinitionByKeyCmd implements Command<ProcessDefinition> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String processDefinitionKey;
+  
+  public FindLatestProcessDefinitionByKeyCmd(String processDefinitionKey) {
+    this.processDefinitionKey = processDefinitionKey;
+  }
+
+  public OpenProcessDefinition execute(Environment environment) throws Exception {
+    return environment.get(PvmDbSession.class).findLatestProcessDefinitionByKey(processDefinitionKey);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionByIdCmd implements Command<OpenProcessDefinition> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  
+  public FindProcessDefinitionByIdCmd(String processDefinitionId) {
+    this.processDefinitionId = processDefinitionId;
+  }
+
+  public OpenProcessDefinition execute(Environment environment) throws Exception {
+    return environment.get(PvmDbSession.class).findProcessDefinitionById(processDefinitionId);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionKeysCmd implements Command<List<String>> {
+
+  private static final long serialVersionUID = 1L;
+
+  public List<String> execute(Environment environment) throws Exception {
+    return environment.get(PvmDbSession.class).findProcessDefinitionKeys();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionsByKeyCmd implements Command<List<ClientProcessDefinition>> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String processDefinitionKey;
+  
+  public FindProcessDefinitionsByKeyCmd(String processDefinitionKey) {
+    this.processDefinitionKey = processDefinitionKey;
+  }
+
+  public List<ClientProcessDefinition> execute(Environment environment) throws Exception {
+    return environment.get(PvmDbSession.class).findProcessDefinitionsByKey(processDefinitionKey);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetAttachment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetAttachment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetAttachment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetAttachment implements Command<byte[]> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  protected String name;
+  
+  public GetAttachment(String processDefinitionId, String name) {
+    this.processDefinitionId = processDefinitionId;
+    this.name = name;
+  }
+
+  public byte[] execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    ClientProcessDefinition processDefinition = pvmDbSession.findProcessDefinitionById(processDefinitionId);
+    return processDefinition.getAttachment(name);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.task.Participant;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetParticipantsCmd implements Command<List<Participant>> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  
+  public GetParticipantsCmd(Long taskDbid, Long swimlaneDbid) {
+    this.taskDbid = taskDbid;
+    this.swimlaneDbid = swimlaneDbid;
+  }
+
+  public List<Participant> execute(Environment environment) throws Exception {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select role from ");
+    hql.append(ParticipantImpl.class.getName());
+    hql.append(" as role where ");
+    
+    if (taskDbid!=null) {
+      hql.append(" role.task.dbid = :taskDbid ");
+
+    } else if (swimlaneDbid!=null) {
+      hql.append(" role.swimlane.dbid = :swimlaneDbid ");
+      
+    } else {
+      throw new JbpmException("no task nor swimlane specified");
+    }
+
+    Session session = Environment.getFromCurrent(Session.class);
+    Query query = session.createQuery(hql.toString());
+
+    if (taskDbid!=null) {
+      query.setLong("taskDbid", taskDbid);
+
+    } else if (swimlaneDbid!=null) {
+      query.setLong("swimlaneDbid", swimlaneDbid);
+    } 
+
+    List<Participant> participants = query.list();
+    return participants;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetSubTasksCmd implements Command<List<Task>> {
+  
+  private static final long serialVersionUID = 1L;
+
+  long parentTaskDbid;
+  
+  public GetSubTasksCmd(long parentTaskDbid) {
+    this.parentTaskDbid = parentTaskDbid;
+  }
+
+  public List<Task> execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    
+    Query query = session.createQuery(
+      "select task " +
+      "from "+TaskImpl.class.getName()+" as task " +
+      "where task.superTask.dbid = :parentTaskDbid"
+    );
+    
+    query.setLong("parentTaskDbid", parentTaskDbid);
+    
+    return query.list();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.TaskDbSession;
+import org.jbpm.task.Task;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class GetTaskCmd implements Command<Task> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  
+  public GetTaskCmd(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public Task execute(Environment environment) throws Exception {
+    TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+    return taskDbSession.findTaskByDbid(taskDbid);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetTaskCommentsCmd implements Command<List<Comment>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  
+  public GetTaskCommentsCmd(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public List<Comment> execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
+    List<Comment> comments = task.getComments();
+    forceInitializationAndClean(comments);
+    return comments;
+  }
+
+  protected void forceInitializationAndClean(List<Comment> comments) {
+    if (comments!=null) {
+      comments.size();
+      List<Comment> copy = new ArrayList<Comment>(comments);
+      for (int i=0; i<copy.size(); i++) {
+        Comment comment = copy.get(i);
+        
+        // when comments get deleted, it's possible that we 
+        // get null values in the list as the indexes of the 
+        // other comments are not upated.
+        // So if there is a null value, we can safely delete it
+        // from the persistent list and cause the indexes to 
+        // be updated
+        if (comment==null) {
+          comments.remove(i);
+        } else {
+          forceInitializationAndClean(comment.getComments());
+        }
+      }
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Set;
+
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetVariableNamesCmd implements Command<Set<String>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  String executionId;
+  
+  public GetVariableNamesCmd(String executionId) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null");
+    }
+    this.executionId = executionId;
+  }
+
+  public Set<String> execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    ClientExecution execution = pvmDbSession.findExecutionById(executionId);
+    return execution.getVariableKeys();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetVariablesCmd implements Command<Map<String, Object>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String executionId;
+  protected Set<String> variableNames;
+  
+  public GetVariablesCmd(String executionId, Set<String> variableNames) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null");
+    }
+    this.executionId = executionId;
+    if (variableNames==null) {
+      throw new JbpmException("variableNames is null");
+    }
+    this.variableNames = variableNames;
+  }
+
+  public Map<String, Object> execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    
+    ClientExecution execution = pvmDbSession.findExecutionById(executionId);
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    for (String variableName : variableNames) {
+      Object value = execution.getVariable(variableName);
+      variables.put(variableName, value);
+    }
+
+    return variables;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.Task;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NewTaskCmd implements Command<Task> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Long parentTaskDbid;
+  protected Long executionDbid;
+
+  public NewTaskCmd(Long parentTaskDbid, Long executionDbid) {
+    this.parentTaskDbid = parentTaskDbid;
+    this.executionDbid = executionDbid;
+  }
+
+  public Task execute(Environment environment) throws Exception {
+    ExecutionImpl execution = null;
+
+    TaskImpl task = TaskImpl.create();
+
+    if (executionDbid!=null) {
+      Session session = environment.get(Session.class);
+      execution = (ExecutionImpl) session.load(ExecutionImpl.class, executionDbid);
+      task.setExecution(execution);
+    }
+
+    if (parentTaskDbid!=null) {
+      Session session = environment.get(Session.class);
+      TaskImpl parentTask = (TaskImpl) session.load(TaskImpl.class, parentTaskDbid);
+      parentTask.addSubTask(task);
+    }
+    
+    return task;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/QueryCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/QueryCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/QueryCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+
+/** base class for commands that execute scalable queries.
+ * 
+ * @author Tom Baeyens 
+ */
+public abstract class QueryCommand<T> implements Command<T>{
+
+  private static final long serialVersionUID = 1L;
+  
+  protected int firstResult;
+  protected int maxResults;
+
+  public QueryCommand(int firstResult, int maxResults) {
+    this.firstResult = firstResult;
+    this.maxResults = maxResults;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RemoveParticipantCmd implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  protected IdentityRef identityRef;
+  protected String participation;
+  
+  public RemoveParticipantCmd(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+    this.swimlaneDbid = swimlaneDbid;
+    this.taskDbid = taskDbid;
+    this.identityRef = identityRef;
+    this.participation = participation;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = Environment.getFromCurrent(Session.class);
+    
+    
+    if (taskDbid!=null) {
+      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+      if (task==null) {
+        throw new JbpmException("task "+taskDbid+" was not found");
+      }
+
+      Set<ParticipantImpl> participants = new HashSet<ParticipantImpl>(task.getParticipants());
+      for (ParticipantImpl participant : participants) {
+        if ( participant.getIdentityRef().equals(identityRef)
+             && participant.getParticipation().equals(participation)
+           ) {
+          task.removeParticipant(participant);
+        }
+      }
+    }
+    
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.TaskDbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class SaveTaskCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected TaskImpl task;
+
+  public SaveTaskCmd(TaskImpl task) {
+    this.task = task;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+    
+    taskDbSession.saveTask(task);
+    
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Message;
+import org.jbpm.session.MessageSession;
+
+/** sends a given message to the configured message service.
+ * 
+ * @author Tom Baeyens
+ */
+public class SendMessageCmd implements Command<Object> {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected Message message;
+  
+  public SendMessageCmd(Message message) {
+    this.message = message;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    MessageSession messageSession = environment.get(MessageSession.class);
+    messageSession.send(message);
+    return null;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SetVariablesCmd extends VariablesCmd<Execution> {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected String executionId = null;
+  
+  public SetVariablesCmd(String executionId) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null"); 
+    }
+    this.executionId = executionId;
+  }
+
+  public SetVariablesCmd(String executionId, String key, Object variable) {
+    this(executionId);
+    addVariable(key, variable);
+  }
+
+  public Execution execute(Environment environment) throws Exception {
+    ClientExecution execution = getExecution(environment, executionId);
+    execution.setVariables(variables);
+    return execution;
+  }
+
+  public String getExecutionId() {
+    return executionId;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalCmd implements Command<Execution> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String executionId;
+  protected String signalName;
+  protected Map<String, Object> parameters;
+
+  public SignalCmd(String executionId, String signalName, Map<String, Object> parameters) {
+    if (executionId==null) {
+      throw new JbpmException("executionId is null");
+    }
+    this.executionId = executionId;
+    this.signalName = signalName;
+    this.parameters = parameters;
+  }
+
+  public Execution execute(Environment environment) throws Exception {
+    ClientExecution execution = null;
+    
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    execution = pvmDbSession.findExecutionById(executionId);
+    if (execution==null) {
+      throw new JbpmException("execution "+executionId+" does not exist");
+    }
+    
+    execution.signal(signalName, parameters);
+    
+    return execution;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionCmd extends VariablesCmd<Execution> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  protected String executionKey;
+
+  public StartExecutionCmd(String processDefinitionId, Map<String, Object> variables, String executionKey) {
+    this.processDefinitionId = processDefinitionId;
+    this.variables = variables;
+    this.executionKey = executionKey;
+  }
+
+  public Execution execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+
+    ClientProcessDefinition processDefinition = null;
+    
+    processDefinition = pvmDbSession.findProcessDefinitionById(processDefinitionId);
+    if (processDefinition==null) {
+      throw new JbpmException("no process definition with id '"+processDefinitionId+"'");
+    }
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
+    processInstance.setVariables(variables);
+    processInstance.start();
+    
+    pvmDbSession.save(processInstance);
+    return processInstance;
+  }
+
+  public String getProcessDefinitionKey() {
+    return processDefinitionId;
+  }
+  public void setProcessDefinitionKey(String processDefinitionKey) {
+    this.processDefinitionId = processDefinitionKey;
+  }
+  public String getExecutionKey() {
+    return executionKey;
+  }
+  public void setExecutionKey(String executionKey) {
+    this.executionKey = executionKey;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionInLatestCmd extends VariablesCmd<Execution> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String processDefinitionKey;
+  protected String executionKey;
+
+  public StartExecutionInLatestCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
+    if (processDefinitionKey==null) {
+      throw new JbpmException("processDefinitionKey is null");
+    }
+    this.processDefinitionKey = processDefinitionKey;
+    this.variables = variables;
+    this.executionKey = executionKey;
+  }
+  
+  public Execution execute(Environment environment) throws Exception {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+
+    ClientProcessDefinition processDefinition = null;
+    
+    processDefinition = pvmDbSession.findLatestProcessDefinitionByKey(processDefinitionKey);
+
+    if (processDefinition==null) {
+      throw new JbpmException("no process definition with key '"+processDefinitionKey+"'");
+    }
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
+    processInstance.setVariables(variables);
+    processInstance.start();
+    
+    pvmDbSession.save(processInstance);
+    return processInstance;
+  }
+
+  public String getExecutionKey() {
+    return executionKey;
+  }
+  public void setExecutionKey(String executionKey) {
+    this.executionKey = executionKey;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.TaskDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubmitTaskCmd implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  protected TaskImpl task;
+
+  public SubmitTaskCmd(TaskImpl task) {
+    this.task = task;
+  }
+
+  public SubmitTaskCmd(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    TaskDbSession taskDbession = environment.get(TaskDbSession.class);
+    if (task!=null) {
+      taskDbession.merge(task);
+    } else {
+      task = (TaskImpl) taskDbession.findTaskByDbid(taskDbid);
+    }
+    task.submit();
+    taskDbession.delete(task);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class VariablesCmd<T> extends AbstractCommand<T> {
+
+  private static final long serialVersionUID = 1L;
+
+  Map<String, Object> variables;
+
+  public void addVariable(String key, Object variable) {
+    if (variables==null) {
+      variables = new HashMap<String, Object>();
+    }
+    variables.put(key, variable);
+  }
+
+  public Map<String, Object> getVariables() {
+    return variables;
+  }
+
+  public void setVariables(Map<String, Object> variables) {
+    this.variables = variables;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/AssignFileTypeDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/AssignFileTypeDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/AssignFileTypeDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AssignFileTypeDeployer implements Deployer, Serializable {
+  
+  /* maps extensions to file types */
+  Map<String, String> fileTypes = new HashMap<String, String>();
+
+  private static final long serialVersionUID = 1L;
+
+  public void deploy(DeploymentImpl deployment) {
+    for (String fileName: deployment.getFileNames()) {
+      for (String extension: fileTypes.keySet()) {
+        if (fileName.endsWith(extension)) {
+          String fileType = fileTypes.get(extension);
+          deployment.setFileType(fileName, fileType);
+          break;
+        }
+      }
+    }
+  }
+
+  public void addFileType(String extension, String fileType) {
+    fileTypes.put(extension, fileType);  
+  }
+
+  public String toString() {
+    return "assign-file-type";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProblemsDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+import org.jbpm.Problem;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProblemsDeployer implements Deployer, Serializable {
+  
+  private static final Log log = Log.getLog(CheckProblemsDeployer.class.getName());
+  private static final long serialVersionUID = 1L;
+
+  public void deploy(DeploymentImpl deployment) {
+    if (deployment.hasProblems()) {
+      for (Problem problem: deployment.getProblems()) {
+        Throwable cause = problem.getCause();
+        if (cause!=null) {
+          log.debug("deployment exception", cause);
+        }
+      }
+      throw new JbpmException("problems during deployment: "+deployment.getProblemsText());
+    }
+  }
+
+  public String toString() {
+    return "check-problems";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import java.io.Serializable;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.pvm.internal.wire.binding.CheckProcessBinding;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProcessDeployer implements Deployer, Serializable {
+ 
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(CheckProcessDeployer.class.getName());
+  
+  protected boolean assignVersion = true;
+  protected boolean assignKey = true;
+
+  public void deploy(DeploymentImpl deployment) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      deployment.addProblem("environment is required by deployer "+CheckProcessBinding.TAG);
+      return;
+    }
+
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    if (pvmDbSession==null) {
+      deployment.addProblem(PvmDbSession.class.getName()+" is required in the environment by deployer "+CheckProcessBinding.TAG);
+      return;
+    }
+    
+    for (String processSourceName : deployment.getObjectNames()) {
+      Object object = deployment.getObject(processSourceName);
+      if (object instanceof ProcessDefinition) {
+        checkProcessDefinition(processSourceName, (ProcessDefinitionImpl)object, deployment, pvmDbSession);
+      }
+    }
+  }
+
+  public void checkProcessDefinition(String processSourceName, ProcessDefinitionImpl processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+    if ( (processDefinition.getName()==null)
+          || ("".equals(processDefinition.getName()))
+       ) {
+      // A problem was already added by the JpdlParser
+      return;
+    }
+       
+    checkKey(processSourceName, processDefinition, deployment, pvmDbSession);
+    checkVersion(processSourceName, processDefinition, deployment, pvmDbSession);
+    checkId(processSourceName, processDefinition, deployment, pvmDbSession);
+  }
+
+  protected void checkKey(String processSourceName, ProcessDefinitionImpl processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+    String name = processDefinition.getName();
+    String key = processDefinition.getKey();
+    if ( (key==null)
+         && assignKey
+       ) {
+      // replace any non-word character with an underscore
+      key = name.replaceAll("\\W", "_");
+
+      processDefinition.setKey(key);
+    }
+    
+    String existingKey = pvmDbSession.findProcessDefinitionKeyByName(name);
+    if ( (existingKey!=null)
+         && (!existingKey.equals(key))
+       ) {
+      deployment.addProblem("invalid key '"+key+"' in process "+processSourceName+".  Existing process has name '"+name+"' and key '"+existingKey+"'");
+    }
+
+    String existingName = pvmDbSession.findProcessDefinitionNameByKey(key);
+    if ( (existingName!=null)
+         && (!existingName.equals(name))
+       ) {
+      deployment.addProblem("invalid name '"+name+"' in process "+processSourceName+".  Existing process has name '"+existingName+"' and key '"+key+"'");
+    }
+  }
+
+  protected void checkVersion(String processSourceName, ProcessDefinitionImpl processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+    int version = processDefinition.getVersion();
+    String key = processDefinition.getKey();
+    if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
+         && ! assignVersion
+       ) {
+      deployment.addProblem("no version specified in process definition "+key);
+    }
+      
+    if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
+        && assignVersion
+       ) {
+      ClientProcessDefinition latestDeployedVersion = pvmDbSession.findLatestProcessDefinitionByKey(key);
+      if (latestDeployedVersion!=null) {
+        version = latestDeployedVersion.getVersion() + 1;
+      } else {
+        version = 1;
+      }
+      log.debug("assigning version "+version+" to process definition "+key);
+      processDefinition.setVersion(version);
+
+    }
+  }
+
+  protected void checkId(String processSourceName, ProcessDefinitionImpl processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+    String id = processDefinition.getId();
+    if (id==null) {
+      id = processDefinition.getKey()+":"+processDefinition.getVersion();
+      log.trace("created id '"+id+"' for "+processDefinition);
+      processDefinition.setId(id);
+    }
+    
+    if (pvmDbSession.findProcessDefinitionById(id) != null) {
+      deployment.addProblem("process '" + id + "' already exists");
+    }
+  }
+
+  public void setAssignVersion(boolean assignVersion) {
+    this.assignVersion = assignVersion;
+  }
+
+  public void setAssignKey(boolean assignKey) {
+    this.assignKey = assignKey;
+  }
+
+  public String toString() {
+    return "check-process";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/Deployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/Deployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/Deployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Deployer {
+
+  void deploy(DeploymentImpl deployment);
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/DeployerManager.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/DeployerManager.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/DeployerManager.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+
+/** manages sequences of deployers for multiple process languages.
+ * 
+ * <p>Each process language has a language-id.  In a deployment a language-id can 
+ * be given.  This deployer manager will be able to find a sequence of deployers
+ * based on the language-id.
+ * </p>
+ * 
+ * <p>Also, an extension can be associated to a process language.  In that case 
+ * the deployer manager can find the deployer sequence based on the 
+ * extension of the deployed file name.
+ * </p>
+ *  
+ * @author Tom Baeyens
+ */
+public class DeployerManager {
+  
+  private static final Log log = Log.getLog(DeployerManager.class.getName());
+  
+  /** configurable list of deployers */
+  protected List<Deployer> deployers = new ArrayList<Deployer>();
+
+  public void deploy(DeploymentImpl deployment) {
+    if (deployment==null) {
+      throw new JbpmException("deployment is null");
+    }
+    
+    for (Deployer deployer: deployers) {
+      log.debug("applying deployer "+deployer+" to "+deployment);
+      deployer.deploy(deployment);
+    }
+  }
+  
+  public void setDeployers(List<Deployer> deployers) {
+    this.deployers = deployers;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveDeployer.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/SaveDeployer.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.deploy;
+
+import java.io.InputStream;
+import java.io.Serializable;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SaveDeployer implements Deployer, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(SaveDeployer.class.getName());
+  
+  public void deploy(DeploymentImpl deployment) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      deployment.addProblem("environment is required by "+getClass().getName());
+      return;
+    }
+
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    if (pvmDbSession==null) {
+      deployment.addProblem(PvmDbSession.class.getName()+" is required in the environment by "+getClass().getName());
+      return;
+    }
+    
+    ProcessDefinitionImpl lastProcessDefinition = null;
+    
+    boolean deployedProcess = false;
+    for (String objectName : deployment.getObjectNames()) {
+      Object object = deployment.getObject(objectName);
+      if (object instanceof ProcessDefinition) {
+        deployedProcess = true;
+        lastProcessDefinition = (ProcessDefinitionImpl) object; 
+        
+        log.debug("saving process definition "+object);
+        pvmDbSession.save(object);
+      }
+    }
+
+    if (lastProcessDefinition!=null) {
+      for (String fileName : deployment.getFileNames()) {
+        InputStream inputStream = deployment.getFile(fileName);
+        lastProcessDefinition.addAttachment(fileName, inputStream);
+      }
+    }
+
+    if (!deployedProcess) {
+      log.info("no process definition in "+deployment);
+    }
+  }
+
+  public String toString() {
+    return "save";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Authentication.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Authentication.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/Authentication.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+/** knows how to get the userId (String) of the currently authenticated user.
+ * @author Tom Baeyens */
+public class Authentication {
+  
+  static final ThreadLocal<String> userIdThreadLocal = new ThreadLocal<String>();
+  
+  public String getUserId() {
+    return userIdThreadLocal.get();
+  }
+
+  public static void setUserId(String userId) {
+    userIdThreadLocal.set(userId);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/AuthenticationFilter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/AuthenticationFilter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/AuthenticationFilter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AuthenticationFilter implements Filter {
+
+  public void init(FilterConfig filterConfig) throws ServletException {
+  }
+
+  public void destroy() {
+  }
+
+  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+    HttpServletRequest httpRequest = (HttpServletRequest)request;
+    Principal userPrincipal = httpRequest.getUserPrincipal();
+    if (userPrincipal!=null) {
+      String userId = userPrincipal.getName();
+      Authentication.setUserId(userId);
+      try {
+        chain.doFilter(request, response);
+      } finally {
+        Authentication.setUserId(null);
+      }
+    } else {
+      chain.doFilter(request, response);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/BasicEnvironment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/BasicEnvironment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/BasicEnvironment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicEnvironment extends Environment {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final Log log = Log.getLog(BasicEnvironment.class.getName()); 
+
+  protected String userId;
+  protected Map<String, Context> contexts;
+  protected ArrayList<String> defaultSearchOrderList;
+  protected String[] defaultSearchOrder;
+  protected Throwable exception;
+
+  protected transient ClassLoader classLoader;
+
+  public BasicEnvironment() {
+    contexts = new HashMap<String, Context>();
+    defaultSearchOrderList = new ArrayList<String>();
+    defaultSearchOrder = null;
+  }
+
+  // context methods ////////////////////////////////////////////////////////////
+
+  public Context getContext(String contextName) {
+    return contexts.get(contextName);
+  }
+
+  public void addContext(Context context) {
+    String key = context.getName();
+    contexts.put(key, context);
+    defaultSearchOrderList.add(key);
+    defaultSearchOrder = null;
+  }
+
+  public void removeContext(Context context) {
+    String contextName = context.getName();
+    Context removedContext = contexts.remove(contextName);
+    if (removedContext!=null) {
+      defaultSearchOrderList.remove(contextName);
+      defaultSearchOrder = null;
+    }
+  }
+
+  public Context getEnvironmentFactoryContext() {
+    return getContext(Context.CONTEXTNAME_PROCESS_ENGINE);
+  }
+
+  public Context getEnvironmentContext() {
+    return getContext(Context.CONTEXTNAME_TRANSACTION);
+  }
+
+  // userId methods ///////////////////////////////////////////////////////////
+  
+  public String getUserId() {
+    // if the authenticated user was explicitely set
+    if (userId!=null) {
+      // return that one
+      return userId;
+    }
+    
+    // if an Authentication was specified
+    Authentication authentication = get(Authentication.class);
+    if (authentication!=null) {
+      // let the authentication do the work
+      return authentication.getUserId();
+    }
+
+    return null; 
+  }
+  
+  public void setUserId(String userId) {
+    this.userId = userId;
+  }
+
+  // classloader methods //////////////////////////////////////////////////////
+
+  public ClassLoader getClassLoader() {
+    return classLoader;
+  }
+  public void setClassLoader(ClassLoader classLoader) {
+    this.classLoader = classLoader;
+  }
+  
+  // search methods ///////////////////////////////////////////////////////////
+
+  public Object get(String name) {
+    return get(name, null);
+  }
+  
+  public Object get(String name, String[] searchOrder) {
+    if (searchOrder==null) {
+      searchOrder = getDefaultSearchOrder();
+    }
+    for (int i=0; i<searchOrder.length; i++){
+      Context context = contexts.get(searchOrder[i]);
+      if (context.has(name)) {
+        return context.get(name);
+      }
+    }
+    return null;
+  }
+
+  public <T> T get(Class<T> type) {
+    return get(type, null);
+  }
+
+  public <T> T get(Class<T> type, String[] searchOrder) {
+    if (searchOrder==null) {
+      searchOrder = getDefaultSearchOrder();
+    }
+    for (int i=0; i<searchOrder.length; i++){
+      Context context = contexts.get(searchOrder[i]);
+      T o = context.get(type);
+      if (o!=null) {
+        return o;
+      }
+    }
+    return null;
+  }
+  
+  // close ////////////////////////////////////////////////////////////////////
+
+  public void close() {
+    log.trace("closing "+this);
+
+    Environment popped = Environment.popEnvironment();
+    if (this!=popped) {
+      throw new JbpmException("environment nesting problem");
+    }
+  }
+  
+  // private methods //////////////////////////////////////////////////////////
+
+  protected String[] getDefaultSearchOrder() {
+    if (defaultSearchOrder==null) {
+      int size = defaultSearchOrderList.size();
+      defaultSearchOrder = (String[]) new String[size];
+      for (int i=0; i<size; i++) {
+        defaultSearchOrder[i] = defaultSearchOrderList.get(size-1-i);
+      }
+    }
+    return defaultSearchOrder;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentDefaults.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentDefaults.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/EnvironmentDefaults.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+
+/** central location for configuration objects that also 
+ * have a default so that they can be obtained without a 
+ * configuration and an environment block.
+ * 
+ * for every object, first, the current environment will 
+ * be searched if there is one,  if not, the default object 
+ * is returned.
+ *  
+ * @author Tom Baeyens
+ */
+public abstract class EnvironmentDefaults {
+
+  public static ScriptManager getScriptManager() {
+    ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class, false);
+    if (scriptManager!=null) {
+      return scriptManager;
+    }
+    return ScriptManager.getDefaultScriptManager();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionContext.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.env.Context;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+public class ExecutionContext implements Context {
+  
+  ExecutionImpl execution;
+
+  public String getName() {
+    return "execution";
+  }
+
+  public ExecutionContext(Execution execution) {
+    this.execution = (ExecutionImpl) execution;
+  }
+
+  public Object get(String key) {
+    return execution.getVariable(key);
+  }
+
+  public boolean has(String key) {
+    return execution.hasVariable(key);
+  }
+
+  public Set<String> keys() {
+    return execution.getVariableKeys();
+  }
+
+  public Object set(String key, Object value) {
+    execution.setVariable(key, value);
+    return null;
+  }
+
+  public <T> T get(Class<T> type) {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionEnvironment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionEnvironment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/ExecutionEnvironment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import org.jbpm.Execution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionEnvironment extends BasicEnvironment {
+
+  private static final long serialVersionUID = 1L;
+  
+  public ExecutionEnvironment(Execution execution) {
+    addContext(new ExecutionContext(execution));
+    pushEnvironment(this);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JobContext.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.env.Context;
+import org.jbpm.pvm.internal.job.JobImpl;
+
+public class JobContext implements Context {
+  
+  static final Set<String> keys = Collections.unmodifiableSet(getKeys());
+  static Set<String> getKeys() {
+    Set<String> keys = new HashSet<String>();
+    keys.add("jobImpl");
+    return keys;
+  }
+
+  JobImpl<?> jobImpl;
+
+  public JobContext(JobImpl<?> job) {
+    this.jobImpl = job;
+  }
+
+  public Object get(String key) {
+    if ("jobImpl".equals(key)) {
+      return jobImpl;
+    }
+    return null;
+  }
+
+  public boolean has(String key) {
+    return "jobImpl".equals(key);
+  }
+
+  public Set<String> keys() {
+    return keys;
+  }
+
+  public Object set(String key, Object value) {
+    throw new UnsupportedOperationException("set is not supported on "+JobContext.class.getName());
+  }
+  
+  public <T> T get(Class<T> type) {
+    return null;
+  }
+
+  public String getName() {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import org.jbpm.env.Context;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.util.Closable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmEnvironment extends BasicEnvironment {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final Log log = Log.getLog(PvmEnvironment.class.getName()); 
+
+  protected JbpmConfiguration jbpmConfiguration;
+
+  public PvmEnvironment(JbpmConfiguration jbpmConfiguration) {
+    this.jbpmConfiguration = jbpmConfiguration;
+  }
+
+  public String toString() {
+    return "PvmEnvironment["+System.identityHashCode(this)+"]";
+  }
+  public void close() {
+    Context context = getEnvironmentContext();
+    if (context instanceof Closable) {
+      ((Closable)context).close();
+    }
+    super.close();
+    log.debug("closed "+this);
+  }
+
+  
+  /*
+  // close ////////////////////////////////////////////////////////////////////
+
+  public void close() {
+    log.trace("closing "+this);
+
+    pvmEnvironmentFactory.getApplicationWireContext().fire(PvmEnvironment.EVENT_CLOSEENVIRONMENT, this);
+    
+    Environment popped = Environment.popEnvironment();
+    if (this!=popped) {
+      throw new PvmException("environment nesting problem");
+    }
+
+    Context context = getEnvironmentContext();
+    if (context instanceof Closable) {
+      ((Closable)context).close();
+    }
+    log.debug("closed "+this);
+  }
+
+  protected static void rethrow(Throwable exception) throws Error {
+    if (exception instanceof Error) {
+      throw (Error) exception;
+    }
+    if (exception instanceof RuntimeException) {
+      throw (RuntimeException) exception;
+    }
+    throw new PvmException(exception);
+  }
+  */
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironmentFactoryParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.env;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/** main parser. It parses the <code>jbpm-configuration</code>, which is assumed the document element
+ * and can contain the {@link EnvironmentFactoryXmlParser process-engine}
+ * context and the {@link EnvironmentXmlParser environment} context.
+ * 
+ * See {@link Parser} for usage instructions.
+ *   
+ * @author Tom Baeyens
+ */
+public class PvmEnvironmentFactoryParser extends Parser {
+
+  private static final long serialVersionUID = 1L;
+
+  Parser environmentFactoryXmlParser = new WireParser();
+  Parser environmentXmlParser = new WireParser();
+
+  protected static PvmEnvironmentFactoryParser INSTANCE = new PvmEnvironmentFactoryParser();
+  
+  public static PvmEnvironmentFactoryParser getInstance() {
+    return INSTANCE;
+  }
+
+  /** parses the given stream source with {@link #getInstance() the current parser}. */
+  static EnvironmentFactory parse(StreamInput streamSource) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) getInstance()
+           .createParse()
+           .setStreamSource(streamSource)
+           .execute()
+           .checkProblems("environment configuration "+streamSource)
+           .getDocumentObject();
+    return environmentFactory;
+  }
+  
+  public Object parseDocument(Document document, Parse parse) {
+    Element documentElement = document.getDocumentElement();
+    
+    // if the default environment factory was already set in the parse
+    JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) parse.getDocumentObject();
+    if (jbpmConfiguration==null) {
+      jbpmConfiguration = new JbpmConfiguration();
+      parse.setDocumentObject(jbpmConfiguration);
+    }
+
+    WireDefinition environmentFactoryWireDefinition = getApplicationWireDefinition(documentElement, parse);
+    WireDefinition environmentWireDefinition = getBlockWireDefinition(documentElement, parse);
+
+    // create the application wire context from the definition
+    WireContext environmentFactoryWireContext = new WireContext(environmentFactoryWireDefinition, Context.CONTEXTNAME_PROCESS_ENGINE);
+    // propagate the parser classloader to the application context
+    environmentFactoryWireContext.setClassLoader(classLoader);
+
+    // configure the default environment factory
+    jbpmConfiguration.setEnvironmentFactoryCtxWireContext(environmentFactoryWireContext);
+    jbpmConfiguration.setEnvironmentCtxWireDefinition(environmentWireDefinition);
+    
+    parse.setDocumentObject(jbpmConfiguration);
+
+    return jbpmConfiguration;
+  }
+
+  WireDefinition getApplicationWireDefinition(Element documentElement, Parse parse) {
+    Element applicationElement = XmlUtil.element(documentElement, "process-engine-context");
+    if (applicationElement != null) {
+      return (WireDefinition) environmentFactoryXmlParser.parseDocumentElement(applicationElement, parse);
+    }
+    return null;
+  }
+
+  WireDefinition getBlockWireDefinition(Element documentElement, Parse parse) {
+    Element blockElement = XmlUtil.element(documentElement, "transaction-context");
+    if (blockElement != null) {
+      return (WireDefinition) environmentXmlParser.parseDocumentElement(blockElement, parse);
+    }
+    return null;
+  }
+
+  public Parser getEnvironmentFactoryXmlParser() {
+    return environmentFactoryXmlParser;
+  }
+  public void setEnvironmentFactoryXmlParser(Parser applicationWireXmlParser) {
+    this.environmentFactoryXmlParser = applicationWireXmlParser;
+  }
+  public Parser getEnvironmentXmlParser() {
+    return environmentXmlParser;
+  }
+  public void setEnvironmentXmlParser(Parser blockWireXmlParser) {
+    this.environmentXmlParser = blockWireXmlParser;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+<body>environment implementation classes.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ConverterType.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.type.ImmutableType;
+import org.hibernate.usertype.ParameterizedType;
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConverterType extends ImmutableType implements ParameterizedType {
+  
+  private static final long serialVersionUID = 1L;
+  private static Map<Class<?>, String> converterNames = null;
+  private static Map<String, Converter> converters = null;
+  
+  public Object fromStringValue(String arg0) throws HibernateException {
+    return null;
+  }
+
+  public Object get(ResultSet resultSet, String name) throws HibernateException, SQLException {
+    String converterName = resultSet.getString(name);
+    return converters.get(converterName);
+  }
+
+  public void set(PreparedStatement stmt, Object value, int index) throws HibernateException, SQLException {
+    String converterName = (value!=null ? converterNames.get(value.getClass()) : null);
+    stmt.setString(index, converterName);
+  }
+
+  public int sqlType() {
+    return Types.VARCHAR;
+  }
+
+  public String toString(Object arg0) throws HibernateException {
+    return null;
+  }
+
+  public String getName() {
+    return "converter";
+  }
+
+  public Class getReturnedClass() {
+    return Converter.class;
+  }
+
+  public void setParameterValues(Properties properties) {
+    converterNames = new HashMap<Class<?>, String>();
+    converters = new HashMap<String, Converter>();
+    
+    for(Object key : properties.keySet()) {
+      String converterClassName = (String) key;
+      try {
+        Class<?> converterClass = ReflectUtil.loadClass(null, converterClassName);
+        
+        String converterName = properties.getProperty(converterClassName);
+        converterNames.put(converterClass, converterName);
+        Converter converter = (Converter) converterClass.newInstance();
+        converters.put(converterName, converter);
+      } catch (Exception e) {
+        throw new JbpmException("couldn't initialize converter type "+converterClassName, e);
+      }
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ExecutionType.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ExecutionType.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/ExecutionType.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,136 @@
+package org.jbpm.pvm.internal.hibernate;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.UserType;
+import org.jbpm.Execution;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+public class ExecutionType implements UserType, ParameterizedType {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ExecutionType.class.getName());
+  
+  int[] sqlTypes = new int[]{Types.VARCHAR};
+  
+  protected String processResource;
+  protected ProcessDefinitionImpl processDefinition;
+
+  public void setParameterValues(Properties properties) {
+  }
+
+  public int[] sqlTypes() {
+    return sqlTypes;
+  }
+
+  // JDBC - object translation 
+  
+  public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
+    ExecutionImpl execution = createExecution(owner);
+    String activityName = rs.getString(names[0]);
+    ActivityImpl activity = (ActivityImpl) execution.getProcessDefinition().getActivity(activityName);
+    execution.setActivity(activity);
+    execution.setState(Execution.STATE_ACTIVE);
+    return execution;
+  }
+
+  private ExecutionImpl createExecution(Object owner) {
+    ExecutionImpl execution = new ExecutionImpl();
+    execution.setProcessDefinition(getProcessDefinition(owner));
+    return execution;
+  }
+
+  private synchronized ProcessDefinitionImpl getProcessDefinition(Object owner) {
+    if (processDefinition!=null) {
+      return processDefinition;
+    }
+    Class<?> ownerClass = owner.getClass();
+    try {
+      Method method = ownerClass.getDeclaredMethod("getProcessDefinition");
+      processDefinition = (ProcessDefinitionImpl) ReflectUtil.invoke(method, null, null);
+    } catch (Exception e) {
+      throw new RuntimeException("couldn't get process definition for "+owner, e);
+    }
+    
+    return processDefinition;
+  }
+
+  public void nullSafeSet(PreparedStatement st, Object owner, int index) throws HibernateException, SQLException {
+    if (owner!=null) {
+      ExecutionImpl execution = (ExecutionImpl) owner;
+      String activityName = execution.getActivity().getName();
+      log.trace("binding 'execution-state{"+activityName+"}' to parameter: "+index);
+      st.setString(index, activityName);
+    }
+  }
+
+  // for dirty checking ?
+
+  public Object deepCopy(Object object) throws HibernateException {
+    if (object==null) {
+      return null;
+    }
+    
+    ExecutionImpl original = (ExecutionImpl) object;
+
+    ActivityImpl activity = new ActivityImpl();
+    activity.setName(original.getActivity().getName());
+    
+    ExecutionImpl copy = new ExecutionImpl();
+    copy.setActivity(activity);
+
+    return copy;
+  }
+
+  public boolean equals(Object arg0, Object arg1) throws HibernateException {
+    if ( (arg0==null) || (arg1==null)) return false;
+    
+    ExecutionImpl execution0 = (ExecutionImpl) arg0;
+    ExecutionImpl execution1 = (ExecutionImpl) arg1;
+    
+    String activityName0 = execution0.getActivity().getName();
+    String activityName1 = execution1.getActivity().getName();
+    
+    return activityName0.equals(activityName1);
+  }
+
+  public int hashCode(Object object) throws HibernateException {
+    return object.hashCode();
+  }
+
+  public boolean isMutable() {
+    return true;
+  }
+
+  public Class<?> returnedClass() {
+    return Execution.class;
+  }
+
+  // merge functionality //////////////////////////////////////////////////////
+  
+  public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException {
+    return null;
+  }
+
+  // serialization for cache //////////////////////////////////////////////////
+
+  public Object assemble(Serializable arg0, Object arg1) throws HibernateException {
+    return null;
+  }
+
+  public Serializable disassemble(Object arg0) throws HibernateException {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import java.io.Serializable;
+
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateDbSession implements DbSession {
+
+  protected Session session;
+
+  public void close() {
+    session.close();
+  }
+
+  public <T> T get(Class<T> entityClass, Object primaryKey) {
+    return entityClass.cast(session.get(entityClass, (Serializable) primaryKey));
+  }
+
+  public void flush() {
+    session.flush();
+  }
+
+  public void forceVersionUpdate(Object entity) {
+    session.lock(entity, LockMode.NONE);
+  }
+
+  public void lockPessimistically(Object entity) {
+    session.lock(entity, LockMode.UPGRADE);
+  }
+
+  public void save(Object entity) {
+    session.save(entity);
+  }
+
+  public void merge(Object entity) {
+    session.merge(entity);
+  }
+
+  public void delete(Object entity) {
+    session.delete(entity);
+  }
+
+  public Session getSession() {
+    return session;
+  }
+
+  public void setSession(Session session) {
+    this.session = session;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateJobDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateJobDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateJobDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.util.Clock;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateJobDbSession extends HibernateDbSession implements JobDbSession {
+  
+  public JobImpl<?> findFirstAcquirableJob() {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findFirstAcquirableJob");
+    query.setTimestamp("now", Clock.getCurrentTime());
+    query.setMaxResults(1);
+    return (JobImpl<?>) query.uniqueResult();
+  }
+
+  public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findExclusiveJobs");
+    query.setTimestamp("now", Clock.getCurrentTime());
+    query.setEntity("processInstance", processInstance);
+    return query.list();
+  }
+
+  public JobImpl<?> findFirstDueJob() {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findFirstDueJob");
+    query.setMaxResults(1);
+    return (JobImpl<?>) query.uniqueResult();
+  }
+
+  public JobImpl<?> getJob(long jobId) {
+    return JobImpl.class.cast(session.get(JobImpl.class, jobId));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,254 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Job;
+import org.jbpm.job.Message;
+import org.jbpm.job.Timer;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.svc.DefaultCommandService;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernatePvmDbSession extends HibernateDbSession implements PvmDbSession {
+  
+  private static final Log log = Log.getLog(HibernatePvmDbSession.class.getName());
+  
+  public HibernatePvmDbSession() {
+  }
+
+  // process definition queries ///////////////////////////////////////////////  
+
+  public List<String> findProcessDefinitionKeys() {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    return session.getNamedQuery("findProcessDefinitionKeys").list();
+  }
+
+  public ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionsByKey");
+    query.setString("key", processDefinitionKey);
+    query.setMaxResults(1);
+    ClientProcessDefinition processDefinition = (ClientProcessDefinition) query.uniqueResult();
+    return processDefinition;
+  }
+
+  public List<ClientProcessDefinition> findProcessDefinitionsByKey(String processDefinitionKey) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionsByKey");
+    query.setString("key", processDefinitionKey);
+    return query.list();
+  }
+
+  public ClientProcessDefinition findProcessDefinitionById(String processDefinitionId) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionById");
+    query.setString("id", processDefinitionId);
+    query.setMaxResults(1);
+    ClientProcessDefinition processDefinition = (ClientProcessDefinition) query.uniqueResult();
+    return processDefinition;
+  }
+  
+  public String findProcessDefinitionKeyByName(String processDefinitionName) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionKeysByName");
+    query.setString("name", processDefinitionName);
+    query.setMaxResults(1);
+    return (String) query.uniqueResult();
+  }
+
+  public String findProcessDefinitionNameByKey(String processDefinitionKey) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionNamesByKey");
+    query.setString("key", processDefinitionKey);
+    query.setMaxResults(1);
+    return (String) query.uniqueResult();
+  }
+
+  public void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory) {
+    List<String> processInstanceIds = findProcessInstanceIds(processDefinitionId);
+    
+    if ( deleteHistory
+         // and if hibernate knows about the history class
+         && (session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class)!=null)
+       ) {
+      List<HistoryProcessInstance> historyProcessInstances = new HistoryProcessInstanceQueryImpl(new DefaultCommandService())
+        .processDefinitionId(processDefinitionId)
+        .execute();
+      
+      for (HistoryProcessInstance historyProcessInstance : historyProcessInstances) {
+        session.delete(historyProcessInstance);
+      }
+    }
+    
+    if (deleteProcessInstances) {
+      for (String processInstanceId : processInstanceIds) {
+        deleteProcessInstance(processInstanceId);
+      }
+    } else {
+      if (processInstanceIds.size()>0) {
+        throw new JbpmException("still "+processInstanceIds.size()+" process instances for process definition "+processDefinitionId);
+      }
+    }
+    
+    ProcessDefinition processDefinition = findProcessDefinitionById(processDefinitionId);
+    session.delete(processDefinition);
+  }
+
+  // process execution queries ////////////////////////////////////////////////  
+  
+  public List<ClientProcessDefinition> findProcessDefinitionsByName(String processDefinitionName) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionsByName");
+    query.setString("name", processDefinitionName);
+    return query.list();
+  }
+
+  public ClientProcessDefinition findProcessDefinitionByName(String processDefinitionName, int version) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionByNameAndVersion");
+    query.setString("name", processDefinitionName);
+    query.setInteger("version", version);
+    ClientProcessDefinition processDefinition = (ClientProcessDefinition) query.uniqueResult();
+    return processDefinition;
+  }
+
+  public ClientProcessDefinition findLatestProcessDefinitionByName(String processDefinitionName) {
+    // query definition can be found at the bottom of resource jbpm.pvm.definition.hbm.xml
+    Query query = session.getNamedQuery("findProcessDefinitionsByName");
+    query.setString("name", processDefinitionName);
+    query.setMaxResults(1);
+    ClientProcessDefinition processDefinition = (ClientProcessDefinition) query.uniqueResult();
+    return processDefinition;
+  }
+  
+  public ClientExecution findExecutionById(String executionId) {
+    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
+    Query query = session.getNamedQuery("findExecutionById");
+    query.setString("id", executionId);
+    query.setMaxResults(1);
+    return (ClientExecution) query.uniqueResult();
+  }
+
+  public ClientExecution findExecutionByKey(String processDefinitionName, String executionKey) {
+    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
+    Query query = session.getNamedQuery("findExecutionByKey");
+    query.setString("processDefinitionName", processDefinitionName);
+    query.setString("executionKey", executionKey);
+    query.setMaxResults(1);
+    return (ClientExecution) query.uniqueResult();
+  }
+  
+  public ClientExecution findProcessInstanceById(String processInstanceId) {
+    // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
+    Query query = session.getNamedQuery("findProcessInstanceById");
+    query.setString("processInstanceId", processInstanceId);
+    query.setMaxResults(1);
+    return (ClientExecution) query.uniqueResult();
+  }
+
+  public List<Timer> findTimers(int firstResult, int maxResults) {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findTimers");
+    query.setFirstResult(firstResult);
+    query.setMaxResults(maxResults);
+    return query.list();
+  }
+  
+  public List<Message> findMessages(int firstResult, int maxResults) {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findMessages");
+    query.setFirstResult(firstResult);
+    query.setMaxResults(maxResults);
+    return query.list();
+  }
+  
+  public List<Job> findJobsWithException(int firstResult, int maxResults) {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findJobsWithException");
+    query.setFirstResult(firstResult);
+    query.setMaxResults(maxResults);
+    return query.list();
+  }
+
+  public List<String> findProcessInstanceIds(String processDefinitionId) {
+    // query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
+    Query query = session.getNamedQuery("findProcessInstanceIds");
+    query.setString("processDefinitionId", processDefinitionId);
+    return query.list();
+  }
+
+  public void deleteProcessInstance(String processInstanceId) {
+    deleteProcessInstance(processInstanceId, true);
+  }
+
+  public void deleteProcessInstance(String processInstanceId, boolean deleteHistory) {
+    if (processInstanceId==null) {
+      throw new JbpmException("processInstanceId is null");
+    }
+    
+    Execution processInstance = findExecutionById(processInstanceId);
+
+    // if history should be deleted 
+    if ( deleteHistory 
+         // and if hibernate knows about the history class
+         && (session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class)!=null)
+       ) {
+      HistoryProcessInstanceImpl historyProcessInstance = (HistoryProcessInstanceImpl) 
+          session.get(HistoryProcessInstanceImpl.class, processInstance.getId());
+  
+      // if there is a history process instance in the db
+      if (historyProcessInstance!=null) {
+        if (log.isDebugEnabled()) {
+          log.debug("deleting history process instance "+processInstanceId);
+        }
+        session.delete(historyProcessInstance);
+      }
+    }
+
+    if (processInstance!=null) {
+      if (log.isDebugEnabled()) {
+        log.debug("deleting process instance "+processInstanceId);
+      }
+      session.delete(processInstance);
+    }
+  }
+
+  public List<String> findHistoryProcessInstanceIds(String processDefinitionId) {
+    Query query = session.getNamedQuery("findHistoryProcessInstanceIds");
+    query.setString("processDefinitionId", processDefinitionId);
+    return query.list();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.TaskDbSession;
+import org.jbpm.task.Task;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class HibernateTaskDbSession extends HibernateDbSession implements TaskDbSession {
+
+  public TaskImpl findTaskByDbid(long taskDbid) {
+    // TODO maybe we should move these criteria queries to hql queries in the 
+    // hbm file so that users can easily customize.
+    return (TaskImpl) session.get(TaskImpl.class, taskDbid);
+  }
+
+  public void saveTask(Task task) {
+    TaskImpl taskImpl = (TaskImpl) task;
+    
+    if (! taskImpl.isPersisted()) {
+      Serializable dbid = session.save(taskImpl);
+      if (taskImpl.getId() == null) {
+        taskImpl.setId(dbid.toString());
+      }
+
+    } else {
+      session.update(taskImpl);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/PvmNamingStrategy.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/PvmNamingStrategy.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/PvmNamingStrategy.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.hibernate;
+
+import org.hibernate.cfg.ImprovedNamingStrategy;
+import org.hibernate.util.StringHelper;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmNamingStrategy extends ImprovedNamingStrategy {
+  
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(PvmNamingStrategy.class.getName());
+
+  String prefix;
+  
+  public PvmNamingStrategy(String prefix) {
+    if (! "".equals(prefix)) {
+      this.prefix = prefix;
+    }
+  }
+
+  // TABLE NAMES //////////////////////////////////////////////////////////////
+  
+  public String classToTableName(String className) {
+    String name = ReflectUtil.getUnqualifiedClassName(className);
+    if (name.endsWith("Impl")) {
+      name = name.substring(0, name.length()-4);
+    }
+    name = prefix+name.toUpperCase();
+    if (log.isTraceEnabled()) {
+      log.trace("classToTableName("+className+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String tableName(String tableName) {
+    if (prefix!=null) {
+      return prefix+tableName;
+    }
+    if (log.isTraceEnabled()) {
+      log.trace("tableName("+tableName+") ==> "+tableName);
+    }
+    return tableName;
+  }
+  
+  public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName) {
+    String name = StringHelper.unqualify(propertyName);
+    name = prefix+name.toUpperCase()+"_"; 
+    if (log.isTraceEnabled()) {
+      log.trace("collectionTableName("+ownerEntity+", "+ownerEntityTable+", "+associatedEntity+", "+associatedEntityTable+", "+propertyName+") ==> "+name);
+    }
+    return name;
+  }
+
+  // COLUMN NAMES /////////////////////////////////////////////////////////////
+
+  public String propertyToColumnName(String propertyName) {
+    String name = propertyName;
+    
+    name = StringHelper.unqualify(name);
+    name = name.toUpperCase()+"_";
+    
+    if (log.isTraceEnabled()) {
+      log.trace("propertyToColumnName("+propertyName+") ==> "+name);
+    }
+
+    return name;
+  }
+  
+  public String logicalColumnName(String columnName, String propertyName) {
+    String name = (columnName!=null ? columnName : propertyName);
+    name = name.replace('.', '_');
+    name = name.toUpperCase();
+    if (!name.endsWith("_")) {
+      name = name+"_";
+    }
+    if (log.isTraceEnabled()) {
+      log.trace("logicalColumnName("+columnName+", "+propertyName+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String columnName(String columnName) {
+    String name = columnName.toUpperCase();
+    if (log.isTraceEnabled()) {
+      log.trace("columnName("+columnName+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName) {
+    String name = super.foreignKeyColumnName(propertyName, propertyEntityName, propertyTableName, referencedColumnName);
+    if (log.isTraceEnabled()) {
+      log.trace("foreignKeyColumnName("+propertyName+", "+propertyEntityName+", "+propertyTableName+", "+referencedColumnName+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
+    String name = super.logicalCollectionColumnName(columnName, propertyName, referencedColumn);
+    if (log.isTraceEnabled()) {
+      log.trace("logicalCollectionColumnName("+columnName+", "+propertyName+", "+referencedColumn+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName) {
+    String name = super.logicalCollectionTableName(tableName, ownerEntityTable, associatedEntityTable, propertyName);
+    if (log.isTraceEnabled()) {
+      log.trace("logicalCollectionTableName("+tableName+", "+ownerEntityTable+", "+associatedEntityTable+", "+propertyName+") ==> "+name);
+    }
+    return name;
+  }
+
+  public String joinKeyColumnName(String joinedColumn, String joinedTable) {
+    String name = super.joinKeyColumnName(joinedColumn, joinedTable);
+    if (log.isTraceEnabled()) {
+      log.trace("joinKeyColumnName("+joinedColumn+", "+joinedTable+") ==> "+name);
+    }
+    return name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/** base class for process logs.  Process logs are dispatched to the 
+ * {@link HistorySession} that is configured in the environment.
+ * 
+ * <p>ProcessLogs that are send to a LogSession is the probe mechanism 
+ * provided to listen into the process execution progress and details.
+ * It is the mechanism to collect process history and process statistics.
+ * </p>
+ * 
+ * @author Tom Baeyens
+ */
+public abstract class HistoryEvent implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected ExecutionImpl execution;
+  
+  public void setExecution(ExecutionImpl execution) {
+    this.execution = execution;
+  }
+
+  public abstract void process();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history;
+
+
+public interface HistorySession {
+  
+  void process(HistoryEvent historyEvent);
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+/** log session that delegates to a delegate list of log sessions.
+ * 
+ * @author Tom Baeyens
+ */
+public class HistorySessionChain implements HistorySession {
+
+  protected List<HistorySession> delegates = new ArrayList<HistorySession>();
+
+  public void process(HistoryEvent historyEvent) {
+    for (HistorySession delegate: delegates) {
+      delegate.process(historyEvent);
+    }
+  }
+
+  public void addLogSession(HistorySession historySession) {
+    delegates.add(historySession);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionFilter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionFilter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionFilter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history;
+
+
+
+/** filtering log session.
+ * 
+ * @author Tom Baeyens
+ */
+public class HistorySessionFilter implements HistorySession {
+  
+  protected HistorySession delegate;
+  protected String type;
+
+  public void process(HistoryEvent historyEvent) {
+    if (passes(historyEvent)){
+      delegate.process(historyEvent);
+    }
+  }
+
+  /** can be overwritten in case filtering needs to be more 
+   * sophisticated then just type matching. */
+  protected boolean passes(HistoryEvent historyEvent) {
+    return true;
+  }
+
+  public void setDelegate(HistorySession delegate) {
+    this.delegate = delegate;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionImpl implements HistorySession {
+
+  public void process(HistoryEvent historyEvent) {
+    if (historyEvent.execution.getId()!=null) {
+      historyEvent.process();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.history.HistoryActivityInstance;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityEnd extends HistoryEvent {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String transitionName;
+  
+  public ActivityEnd() {
+  }
+
+  public ActivityEnd(String transitionName) {
+    this.transitionName = transitionName;
+  }
+
+  public void process() {
+    Session session = Environment.getFromCurrent(Session.class);
+    Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
+    HistoryActivityInstanceImpl historyActivityInstance = (HistoryActivityInstanceImpl) 
+        session.load(getHistoryActivityInstanceClass(), historyActivityInstanceDbId); 
+    historyActivityInstance.setEndTime(Clock.getCurrentTime());
+    historyActivityInstance.setTransitionName(transitionName);
+    updateActivitySpecificProperties(historyActivityInstance);
+    session.update(historyActivityInstance);
+  }
+
+  protected Class<? extends HistoryActivityInstanceImpl> getHistoryActivityInstanceClass() {
+    return HistoryActivityInstanceImpl.class;
+  }
+
+  protected void updateActivitySpecificProperties(HistoryActivityInstance historyActivityInstanceImpl) {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityStart extends HistoryEvent {
+
+  private static final long serialVersionUID = 1L;
+
+  public void process() {
+    Session session = Environment.getFromCurrent(Session.class);
+
+    String processInstanceId = execution.getProcessInstance().getId();
+
+    HistoryProcessInstance historyProcessInstanceImpl = (HistoryProcessInstance) 
+        session.load(HistoryProcessInstanceImpl.class, processInstanceId);
+    
+    HistoryActivityInstanceImpl historyActivityInstanceImpl = 
+        createHistoryActivityInstance(historyProcessInstanceImpl);
+    
+    session.save(historyActivityInstanceImpl);
+    
+    execution.setHistoryActivityInstanceDbid(historyActivityInstanceImpl.getDbid());
+  }
+
+  protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+    return new HistoryActivityInstanceImpl(historyProcessInstanceImpl, execution);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryAutomaticInstanceImpl;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticEnd extends ActivityStart {
+
+  private static final long serialVersionUID = 1L;
+
+  protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+    return new HistoryAutomaticInstanceImpl(historyProcessInstanceImpl, execution);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryExclusiveInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveEnd extends AutomaticEnd {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String transitionName;
+
+  public ExclusiveEnd(String transitionName) {
+    this.transitionName = transitionName;
+  }
+
+  protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+    return new HistoryExclusiveInstanceImpl(historyProcessInstanceImpl, execution, transitionName);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceEnd extends HistoryEvent {
+
+  private static final long serialVersionUID = 1L;
+
+  public void process() {
+    Session session = Environment.getFromCurrent(Session.class);
+    HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl) 
+        session.load(HistoryProcessInstanceImpl.class, execution.getId());
+    historyProcessInstanceImpl.setEndTime(Clock.getCurrentTime());
+    historyProcessInstanceImpl.setState(execution.getState());
+    historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import java.io.Serializable;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceStart extends HistoryEvent implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void process() {
+    HistoryProcessInstance historyProcessInstanceImpl = new HistoryProcessInstanceImpl(execution);
+    Session session = Environment.getFromCurrent(Session.class);
+    session.save(historyProcessInstanceImpl);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryActivityInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskEnd extends ActivityEnd {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String outcome;
+
+  public TaskEnd(String outcome) {
+    this.outcome = outcome;
+  }
+
+  protected Class<? extends HistoryActivityInstanceImpl> getHistoryActivityInstanceClass() {
+    return HistoryTaskInstanceImpl.class;
+  }
+
+  protected void updateActivitySpecificProperties(HistoryActivityInstance historyActivityInstanceImpl) {
+    HistoryTaskInstanceImpl historyTaskInstanceImpl = (HistoryTaskInstanceImpl) historyActivityInstanceImpl;
+    historyTaskInstanceImpl.setTransitionName(outcome);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskStart extends ActivityStart {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String assignee;
+  
+  public TaskStart(String assignee) {
+    this.assignee = assignee;
+  }
+ 
+  protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+    return new HistoryTaskInstanceImpl(historyProcessInstanceImpl, execution, assignee);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import java.util.Date;
+
+import org.jbpm.history.HistoryActivityInstance;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/** base activity instance class.
+ *  
+ * @author Tom Baeyens
+ */
+public class HistoryActivityInstanceImpl implements HistoryActivityInstance {
+
+  protected long dbid;
+  protected int dbversion;
+
+  protected HistoryProcessInstance historyProcessInstance;
+  protected String executionId;
+  protected ActivityImpl activity;
+  protected String activityName;
+
+  protected Date startTime;
+  protected Date endTime;
+  protected long duration;
+  
+  protected String transitionName;
+  
+  public HistoryActivityInstanceImpl() {
+  }
+
+  public HistoryActivityInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution) {
+    this.historyProcessInstance = historyProcessInstanceImpl;
+    this.activity = execution.getActivity();
+    this.executionId = execution.getId();
+    this.activityName = activity.getName();
+    this.startTime = execution.getHistoryActivityStart();
+  }
+
+  public void setEndTime(Date endTime) {
+    this.endTime = endTime;
+    this.duration = endTime.getTime() - startTime.getTime();
+  }
+  
+  public long getDbid() {
+    return dbid;
+  }
+  public ActivityImpl getActivity() {
+    return activity;
+  }
+  public String getActivityName() {
+    return activityName;
+  }
+  public Date getStartTime() {
+    return startTime;
+  }
+  public Date getEndTime() {
+    return endTime;
+  }
+  public long getDuration() {
+    return duration;
+  }
+  public HistoryProcessInstance getHistoryProcessInstance() {
+    return historyProcessInstance;
+  }
+  public String getExecutionId() {
+    return executionId;
+  }
+  public void setExecutionId(String executionId) {
+    this.executionId = executionId;
+  }
+  public String getTransitionName() {
+    return transitionName;
+  }
+  public void setTransitionName(String transitionName) {
+    this.transitionName = transitionName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryAutomaticInstanceImpl extends HistoryActivityInstanceImpl {
+  
+  public HistoryAutomaticInstanceImpl() {
+  }
+
+  public HistoryAutomaticInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution) {
+    super(historyProcessInstanceImpl, execution);
+    setEndTime(Clock.getCurrentTime());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryExclusiveInstanceImpl extends HistoryAutomaticInstanceImpl {
+
+  public HistoryExclusiveInstanceImpl() {
+  }
+
+  public HistoryExclusiveInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution, String transitionName) {
+    super(historyProcessInstanceImpl, execution);
+    this.transitionName = transitionName;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import java.util.Date;
+import java.util.Set;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryProcessInstanceImpl implements HistoryProcessInstance {
+  
+  protected long dbid;
+  protected int dbversion;
+  
+  protected ProcessDefinitionImpl processDefinition;
+  protected String processDefinitionId;
+  protected String processInstanceId;
+  protected String key;
+  protected String state;
+  protected String endActivityName;
+  protected Date startTime;
+  protected Date endTime;
+  protected long duration;
+  
+  /** only here to get hibernate cascade deletes */
+  protected Set<HistoryActivityInstanceImpl> historyActivityInstances;
+  
+  public HistoryProcessInstanceImpl() {
+  }
+
+  public HistoryProcessInstanceImpl(ExecutionImpl processInstance) {
+    this.processDefinition = processInstance.getProcessDefinition();
+    this.processDefinitionId = processDefinition.getId();
+    this.dbid = processInstance.getDbid();
+    this.processInstanceId = processInstance.getId();
+    this.key = processInstance.getKey();
+    this.state = "active";
+    this.startTime = Clock.getCurrentTime();
+  }
+
+  public void setEndTime(Date endTime) {
+    this.endTime = endTime;
+    this.duration = endTime.getTime() - startTime.getTime();
+    this.state = "ended";
+  }
+
+  public Date getEndTime() {
+    return endTime;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+  public ProcessDefinitionImpl getProcessDefinition() {
+    return processDefinition;
+  }
+  public Date getStartTime() {
+    return startTime;
+  }
+  public long getDuration() {
+    return duration;
+  }
+  public String getProcessInstanceId() {
+    return processInstanceId;
+  }
+  public String getKey() {
+    return key;
+  }
+  public String getState() {
+    return state;
+  }
+  public String getProcessDefinitionId() {
+    return processDefinitionId;
+  }
+  public void setState(String state) {
+    this.state = state;
+  }
+  public String getEndActivityName() {
+    return endActivityName;
+  }
+  public void setEndActivityName(String endActivityName) {
+    this.endActivityName = endActivityName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryTaskInstanceImpl extends HistoryActivityInstanceImpl {
+
+  protected String assignee;
+  public HistoryTaskInstanceImpl() {
+  }
+
+  public HistoryTaskInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution, String assignee) {
+    super(historyProcessInstanceImpl, execution);
+    this.assignee = assignee;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<body>infrastructure for listening to process event logs that 
+can be used to build up historic information about process 
+executions. 
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateGroup.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateGroup.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateGroup.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateGroup implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String groupName;
+  protected String groupType;
+  protected String parentGroupId;
+
+  
+  public CreateGroup(String groupName, String groupType, String parentGroupId) {
+    this.groupName = groupName;
+    this.groupType = groupType;
+    this.parentGroupId = parentGroupId;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    identitySession.createGroup(groupName, groupType, parentGroupId);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateMembership.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateMembership.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateMembership.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateMembership implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String userId;
+  protected String groupId;
+  protected String groupType;
+  protected String role;
+  
+  public CreateMembership(String userId, String groupId, String groupType, String role) {
+    this.userId = userId;
+    this.groupId = groupId;
+    this.groupType = groupType;
+    this.role = role;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    identitySession.createMembership(userId, groupId, groupType, role);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateUser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateUser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/CreateUser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateUser implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String userId;
+  protected String givenName;
+  protected String familyName;
+  
+  public CreateUser(String userId, String givenName, String familyName) {
+    this.userId = userId;
+    this.givenName = givenName;
+    this.familyName = familyName;
+  }
+
+
+  public Void execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    identitySession.createUser(userId, givenName, familyName);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteGroup.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteGroup.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteGroup.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteGroup implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String groupId;
+  protected String groupType;
+  
+  public DeleteGroup(String groupId, String groupType) {
+    this.groupId = groupId;
+    this.groupType = groupType;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    identitySession.deleteGroup(groupId, groupType);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteUser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteUser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/DeleteUser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteUser implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String userId;
+
+  public DeleteUser(String userId) {
+    this.userId = userId;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    identitySession.deleteUser(userId);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/FindGroupsByUserNameAndGroupType.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/FindGroupsByUserNameAndGroupType.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/FindGroupsByUserNameAndGroupType.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.Group;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindGroupsByUserNameAndGroupType implements Command<List<Group>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String userName;
+  protected String groupType;
+  
+  public FindGroupsByUserNameAndGroupType(String userName, String groupType) {
+    this.userName = userName;
+    this.groupType = groupType;
+  }
+
+  public List<Group> execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    return identitySession.findGroupsByUserAndGroupType(userName, groupType);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetGroups.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetGroups.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetGroups.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.Group;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetGroups implements Command<List<Group>> {
+
+  private static final long serialVersionUID = 1L;
+
+  public List<Group> execute(Environment environment) throws Exception {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    return identitySession.getGroups(Group.TYPE_ORGANISATION_UNIT);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetUsers.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetUsers.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/cmd/GetUsers.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.User;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetUsers implements Command<List<User>> {
+
+  private static final long serialVersionUID = 1L;
+
+  public List<User> execute(Environment environment) {
+    IdentitySession identitySession = environment.get(IdentitySession.class);
+    return identitySession.getUsers();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import java.io.Serializable;
+
+import org.jbpm.identity.Group;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroupImpl implements Group, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String name;
+
+  public GroupImpl(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import java.util.List;
+
+import org.jbpm.IdentityService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.pvm.internal.identity.cmd.CreateGroup;
+import org.jbpm.pvm.internal.identity.cmd.CreateMembership;
+import org.jbpm.pvm.internal.identity.cmd.CreateUser;
+import org.jbpm.pvm.internal.identity.cmd.DeleteGroup;
+import org.jbpm.pvm.internal.identity.cmd.DeleteUser;
+import org.jbpm.pvm.internal.identity.cmd.FindGroupsByUserNameAndGroupType;
+import org.jbpm.pvm.internal.identity.cmd.GetGroups;
+import org.jbpm.pvm.internal.identity.cmd.GetUsers;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentityServiceImpl implements IdentityService {
+  
+  protected CommandService commandService;
+  
+  public List<Group> getGroups() {
+    return commandService.execute(new GetGroups());
+  }
+
+  public List<User> getUsers() {
+    return commandService.execute(new GetUsers());
+  }
+
+  public void createUser(String userName, String givenName, String familyName) {
+    commandService.execute(new CreateUser(userName, givenName, familyName));
+  }
+
+  public void createGroup(String groupName, String groupType) {
+    commandService.execute(new CreateGroup(groupName, groupType, null));
+  }
+
+  public void createGroup(String groupName, String groupType, String parentGroupName) {
+    commandService.execute(new CreateGroup(groupName, groupType, parentGroupName));
+  }
+
+  public void deleteUser(String userName) {
+    commandService.execute(new DeleteUser(userName));
+  }
+
+  public void deleteGroup(String groupName, String groupType) {
+    commandService.execute(new DeleteGroup(groupName, groupType));
+  }
+
+  public void createMembership(String userName, String groupName, String groupType, String role) {
+    commandService.execute(new CreateMembership(userName, groupName, groupType, role));
+  }
+
+  public List<Group> findGroupsByUserAndGroupType(String userName, String groupType) {
+    return commandService.execute(new FindGroupsByUserNameAndGroupType(userName, groupType));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,291 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributesManager;
+import org.jboss.identity.idm.api.GroupType;
+import org.jboss.identity.idm.api.Identity;
+import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.api.model.SimpleGroupType;
+import org.jboss.identity.idm.p3p.P3PConstants;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionImpl implements org.jbpm.pvm.internal.identity.spi.IdentitySession {
+
+  protected IdentitySession identitySession;
+
+  public IdentitySessionImpl(IdentitySession identitySession) {
+    this.identitySession = identitySession;
+    
+    StandardTransaction transaction = Environment.getFromCurrent(StandardTransaction.class);
+    IdentitySessionResource identitySessionResource = new IdentitySessionResource(identitySession);
+    transaction.enlistResource(identitySessionResource);
+  }
+
+  public void createUser(String userName, String givenName, String lastName) {
+    try {
+      Identity identity = identitySession.getPersistenceManager().createIdentity(userName);
+      Attribute[] attributes = new Attribute[] { 
+        new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, new String[] { givenName }),
+        new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, new String[] { lastName }) 
+      };
+      identitySession.getAttributesManager().addAttributes(identity, attributes);
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't create user "+userName, e);
+    }
+  }
+
+  public List<User> getUsers() {
+    try {
+      Collection<Identity> identities = identitySession
+          .getPersistenceManager()
+          .findIdentity((IdentitySearchControl[])null);
+    
+      List<User> users = new ArrayList<User>();
+      for (Identity identity : identities) {
+        String name = identity.getName();
+        String givenName = getAttributeString(identity, null, P3PConstants.INFO_USER_NAME_GIVEN);
+        String familyName = getAttributeString(identity, P3PConstants.INFO_USER_NAME_FAMILY);
+        
+        UserImpl user = new UserImpl(name, givenName, familyName);
+        users.add(user);
+      }
+      
+      return users;
+      
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't get users from identity component", e);
+    }
+  }
+
+  public void deleteUser(String userName) {
+    try {
+      org.jboss.identity.idm.api.Identity identity = findIdentity(userName);
+      
+      if (identity==null) {
+        return;
+      }
+      
+      identitySession
+          .getPersistenceManager()
+          .removeIdentity(identity, true);
+    
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't delete group "+userName, e);
+    }
+  }
+
+  public void createGroup(String groupName, String groupType, String parentGroupName) {
+    try {
+      GroupType simpleGroupType = new SimpleGroupType(groupType);
+      org.jboss.identity.idm.api.Group group = identitySession.getPersistenceManager().createGroup(groupName, simpleGroupType);
+      
+      if (parentGroupName!=null) {
+        org.jboss.identity.idm.api.Group parentGroup = findGroup(parentGroupName, groupType);
+        if (parentGroup==null) {
+          throw new JbpmException("parent group "+parentGroupName+" doesn't exist");
+        }
+        identitySession.getRelationshipManager().associateGroups(parentGroup, group);
+      }
+      
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't create group "+groupName, e);
+    }
+  }
+  
+  public List<Group> getGroups(String groupType) {
+    try {
+      GroupType simpleGroupType = new SimpleGroupType(groupType);
+      Collection<org.jboss.identity.idm.api.Group> idGroups = identitySession
+          .getPersistenceManager()
+          .findGroup(simpleGroupType);
+    
+      List<Group> groups = new ArrayList<Group>();
+      for (org.jboss.identity.idm.api.Group idGroup: idGroups) {
+        String groupName = idGroup.getName();
+
+        GroupImpl group = new GroupImpl(groupName);
+        groups.add(group);
+      }
+      
+      return groups;
+      
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't get users from identity component", e);
+    }
+  }
+  
+  public void deleteGroup(String groupName, String groupType) {
+    try {
+      org.jboss.identity.idm.api.Group group = findGroup(groupName, groupType);
+
+      if (group==null) {
+        return;
+      }
+
+      identitySession
+          .getPersistenceManager()
+          .removeGroup(group, true);
+    
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't delete group "+groupName, e);
+    }
+  }
+
+  public void createMembership(String userName, String groupName, String groupType, String role) {
+    try {
+      org.jboss.identity.idm.api.Group group = findGroup(groupName, groupType);
+      if (group==null) {
+        throw new JbpmException("group "+groupName+" doesn't exist");
+      }
+  
+      org.jboss.identity.idm.api.Identity identity = findIdentity(userName);
+      if (identity==null) {
+        throw new JbpmException("user "+userName+" doesn't exist");
+      }
+      
+      
+      if (role!=null) {
+        RoleType roleType = identitySession.getRoleManager().getRoleType(role);
+        if (roleType==null) {
+          roleType = identitySession.getRoleManager().createRoleType(role);
+        }
+        
+        identitySession.getRoleManager().createRole(roleType, identity, group);
+        
+      } else {
+        identitySession.getRelationshipManager().associateIdentities(group, identity);
+      }
+      
+    } catch (Exception e) {
+      throw new JbpmException("couldn't create membership "+userName+", "+groupName+", "+role, e);
+    }
+  }
+  
+  public List<Group> findGroupsByUserAndGroupType(String userName, String groupType) {
+    try {
+      org.jboss.identity.idm.api.Identity identity = findIdentity(userName);
+      if (identity==null) {
+        return Collections.EMPTY_LIST;
+      }
+      
+      List<Group> groups = new ArrayList<Group>();
+
+      GroupType identityGroupType = new SimpleGroupType(groupType);
+      Collection<org.jboss.identity.idm.api.Group> identityGroups = identitySession
+        .getRoleManager()
+        .findGroupsWithRelatedRole(identity, identityGroupType, null);
+      
+      for (org.jboss.identity.idm.api.Group identityGroup: identityGroups) {
+        String groupName = identityGroup.getName();
+        GroupImpl group = new GroupImpl(groupName);
+        groups.add(group);
+      }
+
+      return groups;
+
+    } catch (Exception e) {
+      throw new JbpmException("couldn't get groups for user "+userName+" and groupType "+groupType, e);
+    }
+  }
+
+  protected org.jboss.identity.idm.api.Identity findIdentity(String userName) throws IdentityException {
+    Collection<org.jboss.identity.idm.api.Identity> identities = identitySession
+      .getPersistenceManager()
+      .findIdentity(new IdentitySearchControl[]{
+              new NameFilterSearchControl(userName)
+      } );
+    
+    if ( (identities==null) || (identities.size()==0) ) {
+      return null;
+    }
+    
+    return identities.iterator().next();
+  }
+
+  protected org.jboss.identity.idm.api.Group findGroup(String groupName, String groupType) throws IdentityException {
+    GroupType groupIdType = new SimpleGroupType(groupType);
+    
+    Collection<org.jboss.identity.idm.api.Group> groups = identitySession
+      .getPersistenceManager()
+      .findGroup(groupIdType, new IdentitySearchControl[]{
+              new NameFilterSearchControl(groupName)
+      } );
+    
+    if ( (groups==null) || (groups.size()==0) ) {
+      return null;
+    }
+    
+    return groups.iterator().next();
+  }
+
+  protected String getAttributeString(Identity identity, String attributeName) throws IdentityException {
+    return getAttributeString(identity, null, attributeName);
+  }
+
+  protected String getAttributeString(org.jboss.identity.idm.api.Group idGroup, String attributeName) throws IdentityException {
+    return getAttributeString(null, idGroup, attributeName);
+  }
+
+  protected String getAttributeString(Identity identity, org.jboss.identity.idm.api.Group idGroup, String attributeName) throws IdentityException {
+    AttributesManager attributesManager = identitySession.getAttributesManager();
+    Attribute attribute = null;
+    if (identity!=null) {
+      attribute = attributesManager.getAttribute(identity, attributeName);
+    } else {
+      attribute = attributesManager.getAttribute(idGroup, attributeName);
+    }
+    if (attribute!=null) {
+      return (String) attribute.getValue();
+    }
+    return null;
+  }
+
+
+  public IdentitySession getIdentitySession() {
+    return identitySession;
+  }
+  
+  public void setIdentitySession(IdentitySession identitySession) {
+    this.identitySession = identitySession;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionResource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionResource.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionResource.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Transaction;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.tx.StandardResource;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionResource implements StandardResource {
+  
+  protected IdentitySession identitySession;
+  protected Transaction transaction;
+  
+  public IdentitySessionResource(IdentitySession identitySession) {
+    this.identitySession = identitySession;
+    
+    begin();
+  }
+
+  protected void begin() {
+    try {
+      transaction = identitySession.beginTransaction();
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't begin identity transaction", e);
+    }
+  }
+
+  public void prepare() {
+    try {
+      identitySession.save();
+    } catch (IdentityException e) {
+      throw new JbpmException("couldn't save identity transaction", e);
+    }
+  }
+
+  public void commit() {
+    transaction.commit();
+  }
+
+  public void rollback() {
+    transaction.rollback();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JbpmIdentityStore.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JbpmIdentityStore.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JbpmIdentityStore.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import org.hibernate.ejb.HibernateEntityManager;
+import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl;
+import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JbpmIdentityStore extends HibernateIdentityStoreImpl {
+
+  public JbpmIdentityStore(String id) {
+    super(id);
+  }
+
+  protected HibernateEntityManager bootstrapHibernateEntityManager(String persistenceUnit) throws IdentityException {
+    return getEntityManagerFromEnvironment();
+  }
+
+  protected HibernateEntityManager getHibernateEntityManager(IdentityStoreInvocationContext ctx) throws IdentityException {
+    return getEntityManagerFromEnvironment();
+  }
+
+  protected HibernateEntityManager getEntityManagerFromEnvironment() {
+    return Environment.getFromCurrent(HibernateEntityManager.class);
+  }
+
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.impl;
+
+import java.io.Serializable;
+
+import org.jbpm.identity.User;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserImpl implements User, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String name;
+  protected String givenName;
+  protected String familyName;
+
+  public UserImpl(String name, String givenName, String familyName) {
+    this.name = name;
+    this.givenName = givenName;
+    this.familyName = familyName;
+  }
+
+  public String getName() {
+    return name;
+  }
+  public String getGivenName() {
+    return givenName;
+  }
+  public String getFamilyName() {
+    return familyName;
+  }
+  
+  public String toString() {
+    if ( (givenName!=null)
+         && (familyName!=null)
+       ) {
+      return givenName+" "+familyName;
+    }
+    return name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/spi/IdentitySession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity.spi;
+
+import java.util.List;
+
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface IdentitySession {
+
+  void createUser(String userName, String givenName, String familyName);
+  List<User> getUsers();
+  void deleteUser(String userName);
+
+  void createGroup(String groupName, String groupType, String parentGroupName);
+  List<Group> getGroups(String groupType);
+  void deleteGroup(String groupName, String groupType);
+  
+  void createMembership(String userName, String groupName, String groupType, String role);
+  
+  List<Group> findGroupsByUserAndGroupType(String userName, String groupType);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jms;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.jbpm.JbpmException;
+import org.jbpm.job.Message;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.MessageSession;
+
+/** message service implementation based on JMS.
+ * @author Tom Baeyens
+ */
+public class JmsMessageSession implements MessageSession {
+
+  private static final long serialVersionUID = 1L;
+  
+  /* injected */
+  DbSession dbSession;
+
+  /* injected */
+  Session jmsSession;
+
+  /* injected */
+  Destination jmsDestination;
+
+  // Connection connection;
+  
+  // If you use an XA connection factory in JBoss, the parameters will be ignored.  It will always take part in the global JTA transaction.
+  // If you use a non XQ connection factory, the first parameter specifies wether you want to have all message productions and 
+  // consumptions as part of one transaction (TRUE) or wether you want all productions and consumptions to be instantanious (FALSE)
+  // Of course, we never want messages to be received before the current jbpm transaction commits so we just set it to true.
+  // Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+  
+
+  public void send(Message message) {
+    try {
+      
+      dbSession.save(message);
+      
+      javax.jms.Message jmsMessage = jmsSession.createMessage();
+      MessageProducer messageProducer = jmsSession.createProducer(jmsDestination);
+      try {
+        messageProducer.send(jmsMessage);
+      } catch (Exception e) {
+        throw new JbpmException("couldn't send jms message: "+e.getMessage(), e);
+      } finally {
+        messageProducer.close();
+      }
+
+      jmsMessage.setLongProperty("jobId", message.getDbid());
+
+      /*
+      if (jobImpl.getToken()!=null) {
+        message.setLongProperty("tokenId", jobImpl.getToken().getId());
+      }
+      if (jobImpl.getProcessInstance()!=null) {
+        message.setLongProperty("processInstanceId", jobImpl.getProcessInstance().getId());
+      }
+      if (jobImpl.getTaskInstance()!=null) {
+        message.setLongProperty("taskInstanceId", jobImpl.getTaskInstance().getId());
+      }
+      */
+      
+    } catch (JMSException e) {
+      throw new JbpmException("couldn't send jms message", e);
+    }
+  }
+  
+  public void close() {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jms/JmsMessageUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */package org.jbpm.pvm.internal.jms;
+
+import java.util.Enumeration;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import org.jbpm.internal.log.Log;
+
+/** message printing and destination name extraction.
+ * @author Tom Baeyens, Jim Rigsbee
+ */
+public class JmsMessageUtil {
+
+  private static final Log log = Log.getLog(JmsMessageUtil.class.getName());
+
+  public static String dump(Message message) {
+
+    StringBuffer sb = new StringBuffer();
+
+    sb.append("JMS MessageImpl Dump\n").append("MessageImpl type is " + message.getClass().getName() + "\n");
+
+    try {
+      if (message instanceof ObjectMessage) {
+        sb.append("MessageImpl object type is " + ((ObjectMessage) message).getObject().getClass().getName() + "\n");
+      }
+      sb.append("Reply to " + getDestinationName(message.getJMSReplyTo()) + "\n");
+      Enumeration e = message.getPropertyNames();
+      while (e.hasMoreElements()) {
+        String propertyName = (String) e.nextElement();
+        Object property = message.getObjectProperty(propertyName);
+        sb.append("Property " + propertyName + " value " + property.toString() + "\n");
+      }
+    } catch (JMSException j) {
+      log.error("JMS exception while dumping message", j);
+    }
+
+    return sb.toString();
+  }
+
+  public static String getDestinationName(Destination d) {
+    try {
+      if (d instanceof Queue)
+        return ((Queue) d).getQueueName();
+      else if (d instanceof Topic)
+        return ((Topic) d).getTopicName();
+    } catch (JMSException j) {
+      log.error("JMS exception while getting destination name", j);
+    };
+
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/CommandMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.job;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CommandMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  public CommandMessage() {
+  }
+
+  public CommandMessage(Descriptor commandDescriptor) {
+    this.commandDescriptor = commandDescriptor;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Command<Object> command = (Command<Object>) WireContext.create(commandDescriptor);
+    command.execute(environment);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,125 @@
+package org.jbpm.pvm.internal.job;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+public abstract class JobImpl<T> implements Command<T>, Serializable, Job {
+
+  private static final long serialVersionUID = 1L;
+  // private static final DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS");
+
+  protected long dbid;
+  protected int dbversion;
+
+  /** date until which the command should not be executed
+   * for async messages, this dueDate should be set to null. */
+  protected Date dueDate = null;
+  
+  /** suspended jobs will not execute. */
+  protected boolean isSuspended;
+
+  /** the execution (if any) for this jobImpl */  
+  protected ExecutionImpl execution;
+
+  /** the process instance */  
+  protected ExecutionImpl processInstance;
+  
+  // execution members
+
+  /** specifies if this jobImpl can be executed concurrently with other jobs for the 
+   * same execution. */
+  protected boolean isExclusive;
+
+  /** name of the jobImpl executor name that has locked this jobImpl. */
+  protected String lockOwner;
+
+  /** the time the lock on this jobImpl expires. */
+  protected Date lockExpirationTime;
+
+  /** any information that subclasses might use in a specific way. */
+  protected String info;
+
+  /** stack trace of the exception that occurred during command execution. */
+  protected String exception;
+  
+  /** number of attempts left to try.  Should be decremented each time an exception 
+   * occurs during command execution. */
+  protected int retries = 3;
+  
+  /** a command that can be used as the behaviour of this job */ 
+  protected Descriptor commandDescriptor;
+
+  public JobImpl() {
+  }
+
+  public void setExecution(ExecutionImpl execution) {
+    this.execution = execution;
+    this.processInstance = execution.getProcessInstance();
+  }
+  
+  public long getDbid() {
+    return dbid;
+  }
+  public void setDbid(long id) {
+	  dbid = id;
+  }
+  public String getLockOwner() {
+    return lockOwner;
+  }
+  public boolean isSuspended() {
+    return isSuspended;
+  }
+  public Date getDueDate() {
+    return dueDate;
+  }
+  public void setDueDate(Date dueDate) {
+    this.dueDate = dueDate;
+  }
+  public String getException() {
+    return exception;
+  }
+  public int getRetries() {
+    return retries;
+  }
+  public boolean isExclusive() {
+    return isExclusive;
+  }
+  public ExecutionImpl getExecution() {
+    return execution;
+  }
+  public void setException(String exception) {
+    this.exception = exception;
+  }
+  public void setExclusive(boolean isExclusive) {
+    this.isExclusive = isExclusive;
+  }
+  public void setLockOwner(String jobExecutorName) {
+    this.lockOwner = jobExecutorName;
+  }
+  public void setRetries(int retries) {
+    this.retries = retries;
+  }
+  public void setSuspended(boolean isSuspended) {
+    this.isSuspended = isSuspended;
+  }
+  public ExecutionImpl getProcessInstance() {
+    return processInstance;
+  }
+  public Date getLockExpirationTime() {
+    return lockExpirationTime;
+  }
+  public void setLockExpirationTime(Date lockExpirationTime) {
+    this.lockExpirationTime = lockExpirationTime;
+  }
+  public Descriptor getCommandDescriptor() {
+    return commandDescriptor;
+  }
+  public void setCommandDescriptor(Descriptor commandDescriptor) {
+    this.commandDescriptor = commandDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.job;
+
+import org.jbpm.JbpmException;
+import org.jbpm.job.Message;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class MessageImpl<T> extends JobImpl<T> implements Message {
+
+  private static final long serialVersionUID = 1L;
+
+  public MessageImpl() {
+  }
+  
+  public String toString() {
+    return "message["+dbid+"]";
+  }
+  
+  public MessageImpl(ExecutionImpl execution) {
+    this.execution = execution;
+    this.processInstance = execution.getProcessInstance();
+  }
+
+  protected void unlockExecution() {
+    if (execution == null) {
+      throw new JbpmException("This message isn't bound to any execution");
+    }
+    execution.unlock();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.job;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Timer;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.cal.BusinessCalendar;
+import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.env.JobContext;
+import org.jbpm.pvm.internal.jobexecutor.JobAddedNotification;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.util.Clock;
+
+/** a runtime timer instance.
+ * 
+ * <p>Timers can be
+ * </p>
+ * 
+ * @author Tom Baeyens
+ * @author Pascal Verdage
+ * @author Alejandro Guizar
+ */
+public class TimerImpl extends JobImpl<Boolean> implements Timer {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(TimerImpl.class.getName());
+
+  private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
+
+  protected String signalName;
+  protected String eventName;
+  protected String repeat;
+  
+  public static final String EVENT_TIMER = "timer";
+
+  public TimerImpl() {
+  }
+
+  public void setDueDateDescription(String dueDateDescription) {
+    Duration duration = new Duration(dueDateDescription);
+    Date now = Clock.getCurrentTime();
+    
+    if ( duration.isBusinessTime()
+         || duration.getMonths()>0 
+         || duration.getYears()>0
+       ) {
+      Environment environment = Environment.getCurrent();
+      if (environment==null) {
+        throw new JbpmException("no environment to get business calendar for calculating dueDate "+dueDateDescription);
+      }
+      BusinessCalendar businessCalendar = environment.get(BusinessCalendar.class);
+      dueDate = businessCalendar.add(now, duration);
+
+    } else {
+      long millis = duration.getMillis() + 
+                    1000*( duration.getSeconds() + 
+                           60*( duration.getMinutes() + 
+                                60*( duration.getHours() + 
+                                     24*( duration.getDays() + 
+                                          7*duration.getWeeks()))));
+      dueDate = new Date(now.getTime() + millis);
+    }
+  }
+
+  public Boolean execute(Environment environment) throws Exception {
+    if (log.isDebugEnabled()) log.debug("executing " + this);
+
+    if (environment==null) {
+      throw new JbpmException("environment is null");
+    }
+    
+    JobContext jobContext = new JobContext(this);
+    environment.addContext(jobContext);
+    try {
+      if (signalName!=null) {
+        if (log.isDebugEnabled()) log.debug("feeding timer signal "+signalName+" into "+execution);
+        execution.signal(signalName);
+      }
+      
+      if (eventName!=null) {
+        ObservableElement eventSource = execution.getActivity();
+        if (log.isDebugEnabled()) log.debug("firing event "+signalName+" into "+eventSource);
+        execution.fire(eventName, eventSource);
+      }
+      
+    } finally {
+      environment.removeContext(jobContext);
+    }
+    
+    boolean deleteThisJob = true;
+    // if there is no repeat on this timer
+    if (repeat==null) {
+      // delete the jobImpl
+      if (log.isDebugEnabled()) log.debug("deleting " + this);
+      JobDbSession dbSession = environment.get(JobDbSession.class);
+      if (dbSession==null) {
+        throw new JbpmException("no "+JobDbSession.class.getName()+" in environment"); 
+      }
+      dbSession.delete(this);
+
+    } else { // there is a repeat on this timer
+      deleteThisJob = false;
+      // suppose that it took the timer runner thread a very long time to execute the timers
+      // then the repeat action dueDate could already have passed
+      do {
+        setDueDateDescription(repeat);
+      } while (dueDate.getTime() <= Clock.getCurrentTime().getTime());
+
+      if (log.isDebugEnabled()) log.debug("rescheduled "+this+" for "+formatDueDate(dueDate));
+      
+      // release the lock on the timer
+      setLockOwner(null);
+      setLockExpirationTime(null);
+      
+      // notify the jobExecutor at the end of the transaction
+      JobExecutor jobExecutor = environment.get(JobExecutor.class);
+      if (jobExecutor!=null) {
+        Transaction transaction = environment.get(Transaction.class);
+        if (transaction==null) {
+          throw new JbpmException("no transaction in environment");
+        }
+        JobAddedNotification jobNotificator = new JobAddedNotification(jobExecutor);
+        transaction.registerSynchronization(jobNotificator);
+      }
+    }
+
+    return deleteThisJob;
+  }
+  
+  public String toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("timer[");
+    buffer.append(dbid);
+    if (dueDate!=null) {
+      buffer.append("|");
+      buffer.append(formatDueDate(dueDate));
+    }
+    if (signalName!=null) {
+      buffer.append("|");
+      buffer.append(signalName);
+    }
+    if (eventName!=null) {
+      buffer.append("|");
+      buffer.append(eventName);
+    }
+    buffer.append("]");
+    return buffer.toString();
+  }
+
+  public static String formatDueDate(Date date) {
+	  return new SimpleDateFormat(dateFormat).format(date);
+  }
+
+  public String getSignalName() {
+    return signalName;
+  }
+  public void setSignalName(String signalName) {
+    this.signalName = signalName;
+  }
+  public String getEventName() {
+    return eventName;
+  }
+  public void setEventName(String eventName) {
+    this.eventName = eventName;
+  }
+  public String getRepeat() {
+    return repeat;
+  }
+  public void setRepeat(String repeat) {
+    this.repeat = repeat;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/AcquireJobsCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.JobImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AcquireJobsCmd implements Command<Collection<Long>> {
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(AcquireJobsCmd.class.getName());
+  private static final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss,SSS");
+  
+  JobExecutor jobExecutor;
+
+  public AcquireJobsCmd(JobExecutor jobExecutor) {
+    this.jobExecutor = jobExecutor;
+  }
+
+  public Collection<Long> execute(Environment environment) throws Exception {
+    Collection<Long> acquiredJobDbids = new ArrayList<Long>();
+
+    Collection<JobImpl<?>> acquiredJobs = new ArrayList<JobImpl<?>>();
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    log.debug("start querying first acquirable job...");
+
+    JobImpl<?> job = jobDbSession.findFirstAcquirableJob();
+
+    if (job!=null) {
+      if (job.isExclusive()) {
+        log.trace("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
+        List<JobImpl<?>> otherExclusiveJobs = jobDbSession.findExclusiveJobs(job.getProcessInstance());
+        acquiredJobs.addAll(otherExclusiveJobs);
+      } else {
+        acquiredJobs.add(job);
+      }
+
+      for (JobImpl<?> acquiredJob: acquiredJobs) {
+        long lockExpirationTime = System.currentTimeMillis()+jobExecutor.getLockMillis();
+        log.trace("trying to obtain a lock for '"+acquiredJob+"' with exp "+timeFormat.format(new Date(lockExpirationTime)));
+        acquiredJob.setLockExpirationTime(new Date(lockExpirationTime));
+        acquiredJob.setLockOwner(jobExecutor.getName());
+        acquiredJobDbids.add(acquiredJob.getDbid());
+      }
+
+    } else {
+      log.trace("no acquirable jobs in job table");
+    }
+    
+    log.debug("locking jobs "+acquiredJobDbids);
+    
+    return acquiredJobDbids;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.Collection;
+import java.util.Date;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.internal.log.Log;
+
+/** this thread is responsible for acquiring jobs in the job that need to be 
+ * executed and then let the JobExecutor dispatch the acquired ids to one of the
+ * JobExecutorThreads in the pool.  There is only one dispatcher thread per 
+ * JobExecutor.  
+ * 
+ * @author Tom Baeyens, Guillaume Porcher
+ */
+public class DispatcherThread extends Thread {
+
+  private static final Log log = Log.getLog(DispatcherThread.class.getName());
+  
+  protected JobExecutor jobExecutor;
+  protected   boolean isActive = true;
+  protected boolean checkForNewJobs;
+  protected int currentIdleInterval;
+  protected Object semaphore = new Object();
+
+  protected DispatcherThread(JobExecutor jobExecutor) {
+    this(jobExecutor, "DispatcherThread");
+  }
+
+  protected DispatcherThread(JobExecutor jobExecutor, String name) {
+    super(name);
+    this.jobExecutor = jobExecutor;
+  }
+
+  public void run() {
+    log.info("starting...");
+    currentIdleInterval = jobExecutor.getIdleMillis();
+    try {
+      while (isActive) {
+        try {
+          // checkForNewJobs is set to true in jobWasAdded() below
+          checkForNewJobs = false;
+
+          // try to acquire jobs
+          Collection<Long> acquiredJobDbids = acquireJobs();
+
+          // no exception so resetting the currentIdleInterval
+          currentIdleInterval = jobExecutor.getIdleMillis();
+          if ((acquiredJobDbids != null) && (!acquiredJobDbids.isEmpty())) {
+            putAcquiredJobDbidsOnQueue(acquiredJobDbids);
+            log.debug("added jobs "+acquiredJobDbids+" to the queue");
+
+          } else if (isActive) {
+            long waitPeriod = getWaitPeriod();
+            if (waitPeriod > 0) {
+              synchronized (semaphore) {
+                if (!checkForNewJobs) {
+                  log.debug(getName()+" will wait for max "+waitPeriod+"ms on "+jobExecutor);
+                  semaphore.wait(waitPeriod);
+                  log.debug(getName()+" woke up");
+                } else {
+                  log.debug("skipped wait because new message arrived");
+                }
+              }
+            }
+          }
+
+        } catch (InterruptedException e) {
+          log.info((isActive ? "active" : "inactivated") + " job dispatcher thread '" + getName() + "' got interrupted");
+        } catch (Exception e) {
+          log.error("exception in job executor thread. waiting " + currentIdleInterval + " milliseconds", e);
+          try {
+            synchronized (semaphore) {
+              semaphore.wait(currentIdleInterval);
+            }
+          } catch (InterruptedException e2) {
+            log.trace("delay after exception got interrupted", e2);
+          }
+          // after an exception, the current idle interval is doubled to prevent
+          // continuous exception generation when e.g. the db is unreachable
+          currentIdleInterval = currentIdleInterval * 2;
+        }
+      }
+    } catch (Throwable t) {
+      t.printStackTrace();
+    } finally {
+      log.info(getName() + " leaves cyberspace");
+    }
+  }
+
+  protected void putAcquiredJobDbidsOnQueue(Collection<Long> acquiredJobDbids) {
+    log.debug("pushing jobs on the queue "+acquiredJobDbids);
+    while (acquiredJobDbids!=null) {
+      try {
+        jobExecutor.getJobDbidsQueue().put(acquiredJobDbids);
+        log.trace("jobs "+acquiredJobDbids+" were put on the queue");
+        acquiredJobDbids = null;
+      } catch (InterruptedException e) {
+        log.trace("putting acquired job dbids got interrupted. retrying...");
+      }
+    }
+  }
+
+  protected Collection<Long> acquireJobs() {
+    CommandService commandService = jobExecutor.getCommandExecutor();
+    Command<Collection<Long>> acquireJobsCommand = jobExecutor.getAcquireJobsCommand();
+    return commandService.execute(acquireJobsCommand);
+  }
+
+  protected Date getNextDueDate() {
+    CommandService commandService = jobExecutor.getCommandExecutor();
+    Command<Date> getNextDueDate = jobExecutor.getNextDueDateCommand();
+    return commandService.execute(getNextDueDate);
+  }
+
+  protected long getWaitPeriod() {
+    long interval = jobExecutor.getIdleMillis();
+    Date nextDueDate = getNextDueDate();
+    if (nextDueDate != null) {
+      long currentTimeMillis = System.currentTimeMillis();
+      long nextDueDateTime = nextDueDate.getTime();
+      if (nextDueDateTime < currentTimeMillis + currentIdleInterval) {
+        interval = nextDueDateTime - currentTimeMillis;
+      }
+    }
+    if (interval < 0) {
+      interval = 0;
+    }
+    return interval;
+  }
+
+  public void deactivate() {
+    deactivate(false);
+  }
+  
+  public void deactivate(boolean join) {
+    if (isActive) {
+      log.debug("deactivating "+getName());
+      isActive = false;
+      interrupt();
+      if (join) {
+        while (isAlive()) {
+          try {
+            log.debug("joining "+getName());
+            join();
+          } catch (InterruptedException e) {
+            log.trace("joining "+getName()+" got interrupted");
+          }
+        }
+      }
+    } else {
+      log.trace("ignoring deactivate: "+getName()+" is not active");
+    }
+  }
+
+  public void jobWasAdded() {
+    log.trace("notifying job executor dispatcher thread of new job");
+    synchronized (semaphore) {
+      checkForNewJobs = true;
+      semaphore.notify();
+    }
+  }
+
+  public boolean isActive() {
+    return isActive;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/GetNextDueDateCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.Date;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.JobImpl;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetNextDueDateCmd implements Command<Date> {
+  
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(GetNextDueDateCmd.class.getName());
+  
+  JobExecutor jobExecutor;
+
+  public GetNextDueDateCmd(JobExecutor jobExecutor) {
+    this.jobExecutor = jobExecutor;
+  }
+
+  public Date execute(Environment environment) throws Exception {
+    Date nextDueDate = null;
+    log.debug("getting next due date...");
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    JobImpl<?> job = jobDbSession.findFirstDueJob();
+    if (job!=null) {
+      nextDueDate = job.getDueDate();
+    }
+    log.debug("next due date is "+nextDueDate);
+    return nextDueDate;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobAddedNotification.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobAddedNotification.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobAddedNotification.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import javax.transaction.Synchronization;
+
+import org.jbpm.internal.log.Log;
+
+/** listener that can be registered as a listener to the transaction
+ * to notify the job executor of added jobs so that the dispatcher
+ * thread can wake up.
+ *  
+ * @author Tom Baeyens
+ */
+public class JobAddedNotification implements Synchronization {
+  
+  private static final Log log = Log.getLog(JobAddedNotification.class.getName());
+  
+  JobExecutor jobExecutor;
+  
+  public JobAddedNotification(JobExecutor jobExecutor) {
+    this.jobExecutor = jobExecutor;
+  }
+
+  public void afterCompletion(int arg0) {
+    log.trace("notifying job executor of added message");
+    jobExecutor.jobWasAdded();
+  }
+
+  public void beforeCompletion() {
+  }
+  
+  public String toString() {
+    return "job-added-notification";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobDbSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobDbSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.MessageSession;
+
+/** internal interface used by the job executor and the 
+ * implementations of {@link MessageSession} and {@link TimerSession}.
+ * 
+ * So this session is only needed in case the {@link JobExecutor} is 
+ * used to execute messages or timers.
+ *  
+ * @author Tom Baeyens, Pascal Verdage
+ */
+public interface JobDbSession extends DbSession {
+
+  /** the job with the given id or null if none */
+  public JobImpl<?> getJob(long jobId);
+
+	/** the first job to finish among eligible and non-locked jobs or null if none */
+	public JobImpl<?> findFirstAcquirableJob();
+
+	/** the list of jobs of the process instance that mustn't be concurrent */
+	public List<JobImpl<?>> findExclusiveJobs(Execution processInstance);
+
+	/** the first job to finish among non-owned jobs or null if none */
+	public JobImpl<?> findFirstDueJob();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.transaction.Synchronization;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.JobImpl;
+
+/**  
+ * @author Tom Baeyens
+ */
+public class JobExceptionHandler implements Synchronization, Command<Object> {
+  
+  private static final Log log = Log.getLog(JobExceptionHandler.class.getName());
+  private static final long serialVersionUID = 1L;
+  
+  protected CommandService commandService;
+  protected long jobDbid;
+  protected Throwable exception;
+  
+  public JobExceptionHandler(long jobDbid, Throwable exception, CommandService commandService) {
+    this.commandService = commandService;
+    this.jobDbid = jobDbid;
+    this.exception = exception;
+  }
+
+  
+  public void beforeCompletion() {
+  }
+
+  public void afterCompletion(int status) {
+    // after the transaction rolled back, 
+    // execute this job exception handler object as a command with 
+    // the command service so that this gets done in a separate 
+    // transaction
+    log.debug("starting new transaction for handling job exception");
+    commandService.execute(this);
+    log.debug("completed transaction for handling job exception");
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    log.debug("handling job "+jobDbid+" exception: "+exception.getMessage());
+    
+    // load the job from the db
+    JobDbSession session = environment.get(JobDbSession.class);
+    if (session==null) {
+      throw new JbpmException("no job-session configured to handle job");
+    }
+    JobImpl<?> job = (JobImpl<?>) session.get(JobImpl.class, jobDbid);
+    // serialize the stack trace
+    StringWriter sw = new StringWriter();
+    exception.printStackTrace(new PrintWriter(sw));
+    if (job != null) {
+      // decrement the number of retries
+      int decrementedRetries = job.getRetries()-1;
+      log.debug("decrementing retries to "+decrementedRetries+" for "+job);
+      job.setRetries(decrementedRetries);
+	    job.setException(sw.toString());
+      log.debug("unlocking "+job);
+      job.setLockOwner(null);
+      job.setLockExpirationTime(null);
+      
+      // notify the job executor after the transaction is completed
+      Transaction transaction = environment.get(Transaction.class);
+      JobExecutor jobExecutor = environment.get(JobExecutor.class);
+      if ( (transaction!=null)
+           && (jobExecutor!=null)
+         ) {
+        log.trace("registering job executor notifier with "+transaction);
+        transaction.registerSynchronization(new JobAddedNotification(jobExecutor));
+      }
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.internal.log.Log;
+
+
+/** manager for job execution threads and their configuration.
+ * 
+ * @author Tom Baeyens, Guillaume Porcher
+ */
+public class JobExecutor implements Serializable {
+  private static final Log log = Log.getLog(JobExecutor.class.getName());
+
+  private static final long serialVersionUID = 1L;
+
+  // configuration parameters
+  
+  CommandService commandService;
+  String name = "JobExecutor-"+getHostName();
+  int nbrOfThreads = 3;
+  int idleMillis = 5000; // default normal poll interval is 5 seconds
+  int idleMillisMax = 1000*60*2; // default max poll interval in case of continuous exceptions is 2 minutes
+  int historySize = 200;
+  int lockMillis = 1000*60*30; // default max lock time is 30 minutes
+
+  // runtime state
+
+  Command<Collection<Long>> acquireJobsCommand;
+  Command<Date> nextDueDateCommand;
+  
+  boolean isActive = false;
+
+  JobExecutorThreadPool jobExecutorThreadPool;
+  
+  DispatcherThread dispatcherThread = null;
+  
+  /** queue to dispatch collections of jobDbids to the JobExecutorThreads, which are 
+   * competing readers. */
+  BlockingQueue<Collection<Long>> jobDbidsQueue = null;
+
+  List<JobHistoryEntry> history = new ArrayList<JobHistoryEntry>();
+  
+  /** starts the {@link DispatcherThread} and {@link JobExecutorThread}s for this job executor */
+  public synchronized void start() {
+    if (commandService==null) {
+      throw new JbpmException("no command executor available in job executor");
+    }
+    if (! isActive) {
+      acquireJobsCommand = new AcquireJobsCmd(this);
+      nextDueDateCommand = new GetNextDueDateCmd(this);
+      
+      // the max capacity of the jobDbidsQueue is set to nbrOfJobExecutorThreads.  
+      // That way, the distpatcher thread will be stalled if enough jobs are acquired.
+      jobDbidsQueue = new ArrayBlockingQueue<Collection<Long>>(nbrOfThreads, true);
+
+      isActive = true;
+      log.trace("starting job executor threads for job executor '"+name+"'...");
+      jobExecutorThreadPool = new JobExecutorThreadPool(this);
+      jobExecutorThreadPool.start();
+
+      log.trace("starting dispatcher thread for job executor '"+name+"'...");
+      dispatcherThread = new DispatcherThread(this);
+      dispatcherThread.start();
+      
+    } else {
+      log.trace("ignoring start: job executor '"+name+"' is already started'");
+    }
+  }
+  
+  /** stops with join set to false.
+   * @see #stop(boolean) */ 
+  public synchronized void stop() {
+    stop(false);
+  }
+  
+  /** signals to all threads managed by this job executor to stop.  Stopping the 
+   * dispatcher thread is blocking till the dispatcher is no more alive.  If join is set to true, 
+   * this method will block until all job executor threads 
+   * are joined and actually dead. If join is false, the job executor threads are only told to 
+   * stop, without waiting till they are actually stopped. It may be that job executor threads 
+   * are in the middle of executing a job and they may finish after this method returned.
+   */
+  public synchronized void stop(boolean join) {
+    log.debug("stopping job executor");
+    if (isActive) {
+      isActive = false;
+      dispatcherThread.deactivate(true);
+      waitTillQueueEmpty();
+      jobExecutorThreadPool.deactivate(join);
+    } else {
+      log.trace("ignoring stop: job executor '"+name+"' not started");
+    }
+  }
+
+  protected void waitTillQueueEmpty() {
+    while (! jobDbidsQueue.isEmpty()) {
+      log.trace("waiting for job-id-queue to become empty");
+      try {
+        Thread.sleep(200);
+      } catch (InterruptedException e) {
+        log.trace("waiting for job-id-queue to become empty got interrupted");
+      }
+    }
+  }
+
+  public void jobWasAdded() {
+    if ( (dispatcherThread!=null)
+         && (dispatcherThread.isActive())
+       ) {
+      dispatcherThread.jobWasAdded();
+    }
+  }
+
+  protected static String getHostName() {
+    try {
+      return InetAddress.getLocalHost().getHostAddress();
+    } catch (Exception e) {
+      return "unknown";
+    }
+  }
+
+  protected BlockingQueue<Collection<Long>> getJobDbidsQueue() {
+    return jobDbidsQueue;
+  }
+
+  // getters //////////////////////////////////////////////////////////////////
+  
+  public String getName() {
+    return name;
+  }
+  public int getHistorySize() {
+    return historySize;
+  }
+  public int getIdleMillis() {
+    return idleMillis;
+  }
+  public boolean isActive() {
+    return isActive;
+  }
+  public int getIdleMillisMax() {
+    return idleMillisMax;
+  }
+  public int getLockMillis() {
+    return lockMillis;
+  }
+  public int getNbrOfThreads() {
+    return nbrOfThreads;
+  }
+  public CommandService getCommandExecutor() {
+    return commandService;
+  }
+  public Command<Collection<Long>> getAcquireJobsCommand() {
+    return acquireJobsCommand;
+  }
+  public Command<Date> getNextDueDateCommand() {
+    return nextDueDateCommand;
+  }
+  public DispatcherThread getDispatcherThread() {
+    return dispatcherThread;
+  }
+  public List<JobHistoryEntry> getHistory() {
+    return history;
+  }
+
+  // configuration setters ////////////////////////////////////////////////////
+
+  public void setCommandExecutor(CommandService commandService) {
+    this.commandService = commandService;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public void setNbrOfJobExecutorThreads(int nbrOfJobExecutorThreads) {
+    this.nbrOfThreads = nbrOfJobExecutorThreads;
+  }
+  public void setIdleInterval(int idleInterval) {
+    this.idleMillis = idleInterval;
+  }
+  public void setMaxIdleInterval(int maxIdleInterval) {
+    this.idleMillisMax = maxIdleInterval;
+  }
+  public void setHistoryMaxSize(int historyMaxSize) {
+    this.historySize = historyMaxSize;
+  }
+  public void setMaxLockTime(int maxLockTime) {
+    this.lockMillis = maxLockTime;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorMessageSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorMessageSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorMessageSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Message;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.MessageSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorMessageSession implements MessageSession {
+  
+  private static final Log log = Log.getLog(JobExecutorMessageSession.class.getName());
+  
+  /* injected */
+  DbSession dbSession;
+
+  /* injected */
+  Transaction transaction;
+  
+  boolean isNotificationAdded;
+
+  public void send(Message message) {
+    log.debug("sending message "+ReflectUtil.getUnqualifiedClassName(message.getClass()));
+
+    dbSession.save(message);
+
+    if (!isNotificationAdded) {
+      isNotificationAdded = true;
+      
+      // notify the job executor after the transaction is completed
+      log.trace("registering job executor notifier with "+transaction);
+      JobExecutor jobExecutor = Environment.getCurrent().get(JobExecutor.class);
+      if (jobExecutor==null) {
+        throw new JbpmException("no job executor configured to execute "+message);
+      }
+      transaction.registerSynchronization(new JobAddedNotification(jobExecutor));
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jbpm.Configuration;
+import org.jbpm.JbpmException;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+
+/**
+ * starts the job executor on init and closes the 
+ * jbpm configuration upon destroy.  The closing of the
+ * jbpm configuration will also shut down the job executor 
+ * thread pool. 
+ * <h1>Config parameters</h1>
+ * <table>
+ *   <tr>
+ *     <th>Name</th> 
+ *     <th>Description</th> 
+ *     <th>Type</th>
+ *     <th>Default value</th>
+ *   </tr> 
+ *   <tr>
+ *     <td>jbpm.configuration.resource</td>
+ *     <td>resource location of the jbpm.cfg.xml</td>
+ *     <td>String</td>
+ *     <td>jbpm.cfg.xml</td>
+ *   </tr> 
+ * </table>
+ * 
+ * <p>Configuration example:
+ * <pre>
+ * &lt;web-app&gt;
+ *   ...
+ *   &lt;servlet &gt;
+ *     &lt;servlet-name>JobExecutorServlet&lt;/servlet-name>
+ *     &lt;servlet-class>org.jbpm.job.executor.JobExecutorServlet&lt;/servlet-class>
+ *     &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
+ *   &lt;/servlet&gt;
+ *   &lt;servlet-mapping &gt;
+ *     &lt;servlet-name&gt;JobExecutorServlet&lt;/servlet-name&gt;
+ *     &lt;url-pattern&gt;/jobexecutor&lt;/url-pattern&gt;
+ *   &lt;/servlet-mapping&gt;
+ *   ...
+ * &lt;/web-app&gt;
+ * </pre>
+ * </p>
+ * 
+ * @author Tom Baeyens
+ */
+public class JobExecutorServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  
+  JobExecutor jobExecutor;
+  
+  public void init() throws ServletException {
+    String configurationResource = getInitParameter("jbpm.configuration.resource", "jbpm.cfg.xml");
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) new Configuration().setResource(configurationResource).buildProcessEngine();
+    jobExecutor = environmentFactory.get(JobExecutor.class);
+    if (jobExecutor==null) {
+      throw new JbpmException("no job executor configured in resource "+configurationResource);
+    }
+    jobExecutor.start();
+  }
+  
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    PrintWriter out = response.getWriter();
+    out.println("<html>");
+    out.println("<body>");
+    out.println("<h2>JBoss jBPM job Executor Servlet</h2><hr />");
+    /* TODO
+    Iterator<Thread> iter = jobExecutor.getJobExecutorThreads().values().iterator();
+    while (iter.hasNext()) {
+      Thread thread = iter.next();
+      out.println("<h4>"+thread.getName()+"</h4>");
+      out.println("<b>isAlive</b>:"+thread.isAlive());
+    }
+    */
+    out.println("</body>");
+    out.println("</html>");
+  }
+
+  String getInitParameter(String name, String defaultValue) {
+    String value = getInitParameter(name);
+    if (value!=null) {
+      return value;
+    }
+    return defaultValue;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThread.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.Collection;
+import java.util.concurrent.BlockingQueue;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+
+
+/**
+ * @author Tom Baeyens, Guillaume Porcher
+ */
+public class JobExecutorThread extends Thread {
+  
+  private static final Log log = Log.getLog(JobExecutorThread.class.getName());
+  
+  JobExecutor jobExecutor; 
+  boolean isActive = true;
+
+  public JobExecutorThread(String name, JobExecutor jobExecutor) {
+    super(name);
+    this.jobExecutor = jobExecutor;
+  }
+
+  public void run() {
+    log.info("starting...");
+    try {
+      BlockingQueue<Collection<Long>> queue = jobExecutor.getJobDbidsQueue();
+      if (queue == null) {
+    	  log.debug("no queue to take jobs from");
+      } else {
+        while (isActive) {
+          try {
+            log.trace("taking jobs from queue");
+            Collection<Long> jobDbids = null;
+            jobDbids = queue.take();
+            log.debug("took job(s) "+jobDbids+" from queue");
+
+            for (Long jobDbid: jobDbids) {
+              CommandService commandService = jobExecutor.getCommandExecutor();
+              commandService.execute(new ExecuteJobCmd(jobDbid));
+            }
+          } catch (InterruptedException e) {
+            log.trace("waiting for acquired jobs got interrupted");
+          } catch (Exception e) {
+            log.error("exception in job executor thread", e);
+          }
+        }
+      }
+    } catch (Throwable t) {
+      t.printStackTrace();
+    } finally {
+      log.info(getName()+" leaves cyberspace");
+    }
+  }
+  
+  public void deactivate() {
+    deactivate(false);
+  }
+  
+  public void deactivate(boolean join) {
+    if (isActive) {
+      log.trace("deactivating "+getName());
+      isActive = false;
+      interrupt();
+      if (join) {
+        while (isAlive()) {
+          try {
+            join();
+          } catch (InterruptedException e) {
+            log.trace("joining "+getName()+" got interrupted");
+          }
+        }
+      }
+    } else {
+      log.trace("ignoring deactivate: "+getName()+" is not active");
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThreadPool.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThreadPool.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorThreadPool.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorThreadPool {
+  
+  private static final Log log = Log.getLog(JobExecutorThreadPool.class.getName());
+
+  List<JobExecutorThread> jobExecutorThreads = new ArrayList<JobExecutorThread>();
+  JobExecutor jobExecutor;
+
+  public JobExecutorThreadPool(JobExecutor jobExecutor) {
+    this.jobExecutor = jobExecutor;
+  }
+
+  public JobExecutorThread startThread() {
+    String threadName = getNextThreadName();
+    JobExecutorThread jobExecutorThread = new JobExecutorThread(threadName, jobExecutor);
+    jobExecutorThreads.add(jobExecutorThread);
+    log.trace("starting "+threadName);
+    jobExecutorThread.start();
+    return jobExecutorThread;
+  }
+
+  public JobExecutorThread stopThread() {
+    JobExecutorThread thread = null;
+    int lastIndex = jobExecutorThreads.size()-1;
+    if (lastIndex>=0) {
+      thread = (JobExecutorThread) jobExecutorThreads.remove(lastIndex);
+      thread.deactivate();
+    }
+    return thread;
+  }
+
+  public void start() {
+    for (int i=0; i<jobExecutor.getNbrOfThreads(); i++) {
+      startThread();
+    }
+  }
+
+  public void deactivate() {
+    deactivate(false);
+  }
+
+  public void deactivate(boolean join) {
+    for (JobExecutorThread jobExecutorThread : jobExecutorThreads) {
+      jobExecutorThread.deactivate(join);
+    }
+  }
+
+  protected String getNextThreadName() {
+    return "JobExecutorThread" + jobExecutorThreads.size();
+  }
+
+  public List<JobExecutorThread> getJobExecutorThreads() {
+    return jobExecutorThreads;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Timer;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.session.TimerSession;
+
+/**
+ * Timers created with this service are committed at the end of the transaction,
+ * so their execution will be late if the delay is shorter than the transaction.
+ * In that case, they will be executed at the end of the transaction.
+ * 
+ * @author Tom Baeyens, Pascal Verdage
+ */
+public class JobExecutorTimerSession implements TimerSession {
+  
+	private static final Log log = Log.getLog(TimerSession.class.getName());
+	
+  /* injected */
+  Transaction transaction;
+
+	/* injected */
+	JobExecutor jobExecutor; 
+	
+  /* injected */
+  JobDbSession jobDbSession;
+
+  boolean jobExecutorNotificationScheduled = false;
+
+	public void schedule(Timer timer) {
+    log.debug("scheduling "+timer);
+    validate(timer);
+    jobDbSession.save(timer);
+    if (!jobExecutorNotificationScheduled) {
+      jobExecutorNotificationScheduled = true;
+      transaction.registerSynchronization(new JobAddedNotification(jobExecutor));
+    }
+	}
+
+  protected void validate(Timer timer) {
+    if (timer == null)
+      throw new JbpmException("null timer scheduled");
+    if (timer.getExecution() == null) {
+      throw new JbpmException("timer has no execution specified");
+    }
+    if ( (timer.getSignalName() == null)
+         && (timer.getEventName() == null)
+       )
+      throw new JbpmException("timer has no signalName or eventName specified");
+    if (timer.getDueDate() == null)
+      throw new JbpmException("timer scheduled at null date");
+    if (timer.getDueDate().getTime() < 0)
+      throw new JbpmException("timer scheduled with a negative date");
+  }
+
+	public void cancel(Timer timer) {
+		log.debug("canceling "+timer);
+		if (timer != null) {
+		  jobDbSession.delete(timer);
+		} else {
+			throw new JbpmException("timer is null");
+		}
+	}
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobHistoryEntry.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobHistoryEntry.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobHistoryEntry.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/** one entry in the job execution history.
+ * @author Tom Baeyens
+ */
+public class JobHistoryEntry implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  Date executionTime;
+  String jobDescription;
+  String exception;
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategy.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategy.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategy.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+package org.jbpm.pvm.internal.lob;
+
+public interface BlobStrategy {
+  
+  void set(byte[] bytes, Lob lob);
+  byte[] get(Lob lob);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBinary.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBinary.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBinary.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,12 @@
+package org.jbpm.pvm.internal.lob;
+
+public class BlobStrategyBinary implements BlobStrategy {
+
+  public byte[] get(Lob lob) {
+    return lob.bytes;
+  }
+
+  public void set(byte[] bytes, Lob lob) {
+    lob.bytes = bytes;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,32 @@
+package org.jbpm.pvm.internal.lob;
+
+import java.sql.SQLException;
+
+import org.hibernate.Hibernate;
+import org.jbpm.JbpmException;
+
+public class BlobStrategyBlob implements BlobStrategy {
+  
+  public void set(byte[] bytes, Lob lob) {
+    if (bytes!=null) {
+      lob.cachedBytes = bytes;
+      lob.blob = Hibernate.createBlob(bytes);
+    }
+  }
+
+  public byte[] get(Lob lob) {
+    if (lob.cachedBytes!=null) {
+      return lob.cachedBytes;
+    }
+    
+    java.sql.Blob sqlBlob = lob.blob;
+    if (sqlBlob!=null) {
+      try {
+        return sqlBlob.getBytes(1, (int) sqlBlob.length());
+      } catch (SQLException e) {
+        throw new JbpmException("couldn't extract bytes out of blob", e);
+      }
+    } 
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyChopped.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyChopped.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyChopped.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+package org.jbpm.pvm.internal.lob;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BlobStrategyChopped implements BlobStrategy {
+
+  int chopSize = 1024;
+
+  public void set(byte[] bytes, Lob lob) {
+    lob.bytesChops = chop(bytes);
+  }
+
+  public byte[] get(Lob lob) {
+    return glue(lob.bytesChops);
+  }
+
+  public List<BytesChop> chop(byte[] bytes) {
+    List<BytesChop> chops = null;
+    if ( (bytes!=null)
+         && (bytes.length>0) ){
+      chops = new ArrayList<BytesChop>();
+      int index = 0;
+      while ( (bytes.length-index) > chopSize ) {
+        byte[] byteBlock = new byte[chopSize];
+        System.arraycopy(bytes, index, byteBlock, 0, chopSize);
+        chops.add(new BytesChop(byteBlock));
+        index+=chopSize;
+      }
+      byte[] byteBlock = new byte[bytes.length-index];
+      System.arraycopy(bytes, index, byteBlock, 0, bytes.length-index);
+      chops.add(new BytesChop(byteBlock));
+    }
+    return chops;
+  }
+
+  public byte[] glue(List<BytesChop> bytesChops) {
+    byte[] bytes = null;
+    if (bytesChops!=null) {
+      for (BytesChop bytesChop: bytesChops) {
+        if (bytes==null) {
+          bytes = bytesChop.getBytes();
+        } else {
+          byte[] oldValue = bytes;
+          bytes = new byte[bytes.length+bytesChop.getBytes().length];
+          System.arraycopy(oldValue, 0, bytes, 0, oldValue.length);
+          System.arraycopy(bytesChop.getBytes(), 0, bytes, oldValue.length, bytesChop.getBytes().length);
+        }
+      }
+    }
+    return bytes;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BytesChop.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BytesChop.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BytesChop.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.lob;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BytesChop extends Chop {
+
+  private static final long serialVersionUID = 1L;
+
+  protected byte[] bytes;
+
+  public BytesChop(byte[] bytes) {
+    this.bytes = bytes;
+  }
+
+  public byte[] getBytes() {
+    return bytes;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/CharChop.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/CharChop.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/CharChop.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.lob;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CharChop extends Chop {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String text;
+
+  public CharChop(String text) {
+    this.text = text;
+  }
+
+  public String getText() {
+    return text;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Chop.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Chop.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Chop.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.lob;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class Chop implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+
+  public long getDbid() {
+    return dbid;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategy.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategy.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategy.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+package org.jbpm.pvm.internal.lob;
+
+public interface ClobStrategy {
+
+  void set(char[] text, Lob lob);
+  char[] get(Lob lob);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyChopped.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyChopped.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyChopped.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+package org.jbpm.pvm.internal.lob;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClobStrategyChopped implements ClobStrategy {
+  
+  int chopSize = 1024;
+  
+  public char[] get(Lob lob) {
+    return glue(lob.charChops);
+  }
+
+  public void set(char[] chars, Lob lob) {
+    lob.charChops = chop(chars);
+  }
+
+  public List<CharChop> chop(char[] chars) {
+    List<CharChop> charChops = null;
+    if ( (chars!=null)
+         && (chars.length>0) ){
+      charChops = new ArrayList<CharChop>();
+      int index = 0;
+      while ( (chars.length-index) > chopSize ) {
+        String chop = new String(chars, index, chopSize);
+        charChops.add(new CharChop(chop));
+        index+=chopSize;
+      }
+      // add remainder chop
+      String chop = new String(chars, index, chars.length-index);
+      charChops.add(new CharChop(chop));
+    }
+    return charChops;
+  }
+
+  public char[] glue(List<CharChop> charChops) {
+    if (charChops!=null) {
+      StringWriter writer = new StringWriter();
+      
+      for (CharChop charChop: charChops) {
+        writer.write(charChop.getText());
+      }
+      
+      return writer.toString().toCharArray();
+    }
+
+    return null;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyClob.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyClob.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyClob.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+package org.jbpm.pvm.internal.lob;
+
+import java.sql.SQLException;
+
+import org.hibernate.Hibernate;
+import org.jbpm.JbpmException;
+
+public class ClobStrategyClob implements ClobStrategy {
+
+  public void set(char[] chars, Lob lob) {
+    if (chars!=null) {
+      lob.clob = Hibernate.createClob(new String(chars));
+    }
+  }
+
+  public char[] get(Lob lob) {
+    java.sql.Clob sqlClob = lob.clob;
+    if (sqlClob!=null) {
+      try {
+        int length = (int) sqlClob.length();
+        String text = sqlClob.getSubString(1, length);
+        return text.toCharArray();
+      } catch (SQLException e) {
+        throw new JbpmException("couldn't extract chars out of clob", e);
+      }
+    } 
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyText.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyText.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/ClobStrategyText.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,14 @@
+package org.jbpm.pvm.internal.lob;
+
+public class ClobStrategyText implements ClobStrategy {
+
+  public char[] get(Lob lob) {
+    return lob.extractChars();
+  }
+
+  public void set(char[] chars, Lob lob) {
+    String text = new String(chars);
+    lob.text = text;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.lob;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Lob implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  public static final BlobStrategy DEFAULT_BLOB_STRATEGY = new BlobStrategyBlob();
+  public static final ClobStrategy DEFAULT_CLOB_STRATEGY = new ClobStrategyChopped();
+
+  protected long dbid;
+  protected int dbversion;
+  
+  // cachedBytes is used by the BlobStrategyBlob as hibernate doesn't allow 
+  // blobs to be read in the same session as they are created in.
+  // So cachedBytes should not be persisted 
+  protected byte[] cachedBytes = null;
+  protected java.sql.Blob blob = null;
+  protected byte[] bytes = null;
+  protected List<BytesChop> bytesChops = null;
+  
+  protected java.sql.Clob clob = null;
+  protected String text = null;
+  protected List<CharChop> charChops = null;
+
+
+  public long getDbid() {
+    return dbid;
+  }
+  
+  public Lob() {
+  }
+  
+  public Lob(byte[] bytes) {
+    getBlobStrategy().set(bytes, this);
+  }
+
+  public Lob(char[] text) {
+    getClobStrategy().set(text, this);
+  }
+
+
+  public char[] extractChars() {
+    return getClobStrategy().get(this);
+  }
+
+
+  
+  public byte[] extractBytes() {
+    return getBlobStrategy().get(this);
+  }
+
+  protected ClobStrategy getClobStrategy() {
+    ClobStrategy clobStrategy = null;
+    
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      clobStrategy = environment.get(ClobStrategy.class);
+    }
+
+    if (clobStrategy==null) {
+      clobStrategy = DEFAULT_CLOB_STRATEGY;
+    }
+    
+    return clobStrategy;
+  }
+
+  protected BlobStrategy getBlobStrategy() {
+    BlobStrategy blobStrategy = Environment.getFromCurrent(BlobStrategy.class, false);
+
+    if (blobStrategy==null) {
+      blobStrategy = DEFAULT_BLOB_STRATEGY;
+    }
+    
+    return blobStrategy;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<body>
+offers blob and clob objects to be used in pvm persistent objects so that 
+persistence strategy is configurable.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,486 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityImpl extends CompositeElementImpl implements Activity {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected ObjectReference<ActivityBehaviour> behaviourReference;
+  protected List<TransitionImpl> outgoingTransitions;
+  protected List<TransitionImpl> incomingTransitions;
+  protected TransitionImpl defaultTransition;
+  protected ActivityImpl parentActivity;
+
+  protected boolean isLocalScope;
+  protected boolean isExecutionAsync;
+  protected boolean isSignalAsync;
+  protected boolean isLeaveAsync;
+  protected boolean isPreviousNeeded;
+  
+  transient protected Map<String, TransitionImpl> outgoingTransitionsMap;
+  
+  /**
+   * Use {@link ProcessDefinitionImpl#createActivity()} or {@link ActivityImpl#createActivity()} instead.
+   */
+  public ActivityImpl() {
+    super();
+  }
+  
+  // specialized activity containment methods /////////////////////////////////////
+  
+  public ActivityImpl addActivity(ActivityImpl activity) {
+    activity.setParentActivity(this);
+    super.addActivity(activity);
+    return activity;
+  }
+  
+  public Activity findActivity(String activityName) {
+    if (activityName==null) {
+      if (name==null) {
+        return this;
+      }
+    } else if (activityName.equals(name)) {
+      return this;
+    }
+    return super.findActivity(activityName);
+  }
+
+  // leaving transitions //////////////////////////////////////////////////////
+
+  /** creates an outgoing transition from this activity. */
+  public TransitionImpl createOutgoingTransition() {
+    // create a new transition
+    TransitionImpl transition = new TransitionImpl();
+    
+    // wire it between the source and destination
+    addOutgoingTransition(transition);
+
+    // if there is no default transition yet
+    if (defaultTransition==null) {
+      // make this the default outgoing transition
+      defaultTransition = transition;
+    }
+    
+    return transition;
+  }
+  
+
+  // TODO remove
+  public Transition createOutgoingTransition(ActivityImpl destination) {
+    return createOutgoingTransition(destination, null);
+  }
+
+  // TODO remove
+  public TransitionImpl createOutgoingTransition(ActivityImpl destination, String transitionName) {
+    TransitionImpl transition = createOutgoingTransition(transitionName);
+    if (destination!=null) {
+      destination.addIncomingTransition(transition);
+    }
+    return transition;
+  }
+  
+  // TODO remove
+  public TransitionImpl createOutgoingTransition(String transitionName) {
+    // create a new transition
+    TransitionImpl transition = new TransitionImpl();
+    transition.setName(transitionName);
+    
+    // wire it between the source and destination
+    addOutgoingTransition(transition);
+
+    // if there is no default transition yet
+    if (defaultTransition==null) {
+      // make this the default outgoing transition
+      defaultTransition = transition;
+    }
+    
+    return transition;
+  }
+
+  /**
+   * adds the given transition as a leaving transition to this activity.
+   * Also the source of the transition is set to this activity.
+   * Adding a transition that is already contained in the leaving 
+   * transitions has no effect. 
+   * @return the added transition. 
+   * @throws NullPointerException if transition is null.
+   */
+  public Transition addOutgoingTransition(TransitionImpl transition) {
+    transition.setSource(this);
+    
+    if (outgoingTransitions==null) {
+      outgoingTransitions = new ArrayList<TransitionImpl>();
+    }
+    if (! outgoingTransitions.contains(transition)) {
+      outgoingTransitions.add(transition);
+    }
+    outgoingTransitionsMap = null;
+    return transition;
+  }
+  
+  /**
+   * removes the given transition from the leaving transitions.
+   * Also the transition's source will be nulled.
+   * This method will do nothing if the transition is null or if 
+   * the given transition is not in the list of this activity's leaving 
+   * transitions.
+   * In case this is the transition that was in the 
+   * outgoingTransitionsMap and another transition exists with the same
+   * name, that transition (the first) will be put in the 
+   * outgoingTransitionsMap as a replacement for the removed transition.
+   * If the transition is actually removed from the list of 
+   * leaving transitions, the transition's source will be nulled. 
+   */
+  public boolean removeOutgoingTransition(TransitionImpl transition) {
+    if ( (transition!=null)
+         && (outgoingTransitions!=null)
+       ) {
+      boolean isRemoved = outgoingTransitions.remove(transition);
+      if (isRemoved) {
+        transition.setSource(null);
+        if (outgoingTransitions.isEmpty()) {
+          outgoingTransitions = null;
+        }
+        outgoingTransitionsMap = null;
+      }
+      return isRemoved;
+    }
+    return false;
+  }
+
+  /** the first leaving transition with the given name or null of no
+   * such leaving transition exists.
+   */
+  public TransitionImpl getOutgoingTransition(String transitionName) {
+    return (getOutgoingTransitionsMap()!=null ? outgoingTransitionsMap.get(transitionName) : null);
+  }
+  
+  /** searches for the given transitionName in this activity and then up the 
+   * parent chain. Returns null if no such transition is found. */
+  public TransitionImpl findOutgoingTransition(String transitionName) {
+    TransitionImpl transition = getOutgoingTransition(transitionName);
+    if (transition!=null) {
+      return transition;
+    }
+    if (parentActivity!=null) {
+      return parentActivity.findOutgoingTransition(transitionName);
+    }
+    return null;
+  }
+  
+  /** searches for the default transition in this activity and then up the 
+   * parent chain. Returns null if no such transition is found. */
+  public TransitionImpl findDefaultTransition() {
+    if (defaultTransition!=null) {
+      return defaultTransition;
+    }
+    if (parentActivity!=null) {
+      return parentActivity.findDefaultTransition();
+    }
+    return null;
+  }
+
+  
+  /** the list of leaving transitions.
+   * Beware: the actual member is returned.  No copy is made. 
+   */
+  public List<Transition> getOutgoingTransitions() {
+    return (List) outgoingTransitions;
+  }
+
+  /** indicates if a leaving transition with the given transitionName exists. */
+  public boolean hasOutgoingTransition(String transitionName) {
+    return (getOutgoingTransition(transitionName)!=null);
+  }
+
+  /** indicates if this activity has leaving transitions */
+  public boolean hasOutgoingTransitions() {
+    return ((outgoingTransitions!=null) && (!outgoingTransitions.isEmpty()));
+  }
+
+  /** sets the outgoingTransitions to the given list of outgoingTransitions.
+   * A copy of the collection is made.  Also the outgoingTransitionsMap will 
+   * be updated and the source of all the transitions in the given list will 
+   * be set to this activity.
+   * In case there was a leaving transitions list present, these transition's
+   * source will be nulled.
+   */
+  public void setOutgoingTransitions(List<TransitionImpl> outgoingTransitions) {
+    if (this.outgoingTransitions!=null) {
+      for (TransitionImpl removedTransition: this.outgoingTransitions) {
+        removedTransition.setSource(null);
+      }
+    }
+    if (outgoingTransitions!=null) {
+      this.outgoingTransitions = new ArrayList<TransitionImpl>(outgoingTransitions);
+      for (TransitionImpl addedTransition: outgoingTransitions) {
+        addedTransition.setSource(this);
+      }
+    } else {
+      this.outgoingTransitions = null;
+    }
+    this.outgoingTransitionsMap = null;
+  }
+
+  /** the leaving transitions, keyed by transition name.  If a transition with 
+   * the same name occurs mutltiple times, the first one is returned.
+   * Leaving transitions with a null value for their name are not included 
+   * in the map.
+   * Beware: the actual member is returned.  No copy is made. 
+   */
+  public Map<String, Transition> getOutgoingTransitionsMap() {
+    if(outgoingTransitionsMap == null){
+      this.outgoingTransitionsMap = getTransitionsMap(outgoingTransitions);
+    }
+    return (Map) outgoingTransitionsMap;
+  }
+
+  // arriving transitions /////////////////////////////////////////////////////
+  
+  /**
+   * adds the given transition as an arriving transition to this activity.
+   * Also the source of the transition is set to this activity. 
+   * @return the added transition. 
+   * @throws NullPointerException if transition is null.
+   */
+  public Transition addIncomingTransition(TransitionImpl transition) {
+    transition.setDestination(this);
+    if (incomingTransitions==null) {
+      incomingTransitions = new ArrayList<TransitionImpl>();
+    }
+    incomingTransitions.add(transition);
+    return transition;
+  }
+
+  /** removes the given transition if it is contained in the arriving
+   * transitions of this activity.  If this transition was actually removed,
+   * its destination pointer is nulled.
+   * @return true if a transition was removed.
+   */
+  public boolean removeIncomingTransition(TransitionImpl transition) {
+    if ( (transition!=null)
+         && (incomingTransitions!=null)
+         && (incomingTransitions.remove(transition))
+       ) {
+      transition.setDestination(null);
+      if (incomingTransitions.isEmpty()) {
+        incomingTransitions = null;
+      }
+      return true;
+    }
+    return false;
+  }
+
+  /** the list of arriving transitions.
+   * Beware: the actual member is returned.  No copy is made.
+   */ 
+  public List<Transition> getIncomingTransitions() {
+    return (List) incomingTransitions;
+  }
+
+  /** indicates if this activity has arriving transitions */
+  public boolean hasIncomingTransitions() {
+    return ((incomingTransitions!=null) && (!incomingTransitions.isEmpty()));
+  }
+
+
+  /** sets the incomingTransitions to the given list of incomingTransitions.
+   * A copy of the collection is made.  Also the destination of all the transitions 
+   * in the given list will be set to this activity.
+   * In case there was an arriving transitions list present, these transition's
+   * destination will be nulled.
+   */
+  public void setIncomingTransitions(List<TransitionImpl> incomingTransitions) {
+    if (this.incomingTransitions!=null) {
+      for (TransitionImpl removedTransition: this.incomingTransitions) {
+        removedTransition.setDestination(null);
+      }
+    }
+    if (incomingTransitions!=null) {
+      this.incomingTransitions = new ArrayList<TransitionImpl>(incomingTransitions);
+      for (TransitionImpl addedTransition: incomingTransitions) {
+        addedTransition.setDestination(this);
+      }
+    } else {
+      this.incomingTransitions = null;
+    }
+  }
+
+
+  // behaviour ////////////////////////////////////////////////////////////////
+
+  /** sets the given activity as the behaviour for this activity. 
+   * An object reference for the given activity is created. */ 
+  public void setBehaviour(ActivityBehaviour activityBehaviour) {
+    behaviourReference = new ObjectReference<ActivityBehaviour>(activityBehaviour);
+  }
+
+  /** sets the activity that can be created from the given descriptor as the 
+   * behaviour for this activity.   It is assumed that the descriptor will 
+   * create an {@link ActivityBehaviour}
+   * An object reference for the given descriptor is created. */ 
+  public void setBehaviour(Descriptor descriptor) {
+    behaviourReference = new ObjectReference<ActivityBehaviour>(descriptor);
+  }
+
+  /** sets the expression behaviour for this activity.  The evaluation of the 
+   * expression will replace the {@link ActivityBehaviour#execute(org.jbpm.pvm.Execution) Activity's execute method}.
+   * An object reference for the given descriptor is created. */ 
+  public void setBehaviour(String expression) {
+    behaviourReference = new ObjectReference<ActivityBehaviour>(expression);
+  }
+
+  public ObjectReference<ActivityBehaviour> getBehaviourReference() {
+    return behaviourReference;
+  }
+  
+  public void setBehaviourReference(ObjectReference<ActivityBehaviour> behaviourReference) {
+    this.behaviourReference = behaviourReference;
+  }
+
+  public ActivityBehaviour getBehaviour() {
+    ActivityBehaviour behaviour = ( behaviourReference!=null ? behaviourReference.get() : null);
+    if (behaviour==null) {
+      throw new JbpmException("no behaviour on "+this);
+    }
+    return behaviour;
+  }
+
+  // various helper methods ///////////////////////////////////////////////////
+  
+  private static Map<String, TransitionImpl> getTransitionsMap(List<TransitionImpl> transitions) {
+    Map<String, TransitionImpl> map = null;
+    if (transitions!=null) {
+      map = new HashMap<String, TransitionImpl>();
+      for (TransitionImpl transition: transitions) {
+        if (! map.containsKey(transition.getName())) {
+          map.put(transition.getName(), transition);
+        }
+      }
+    }
+    return map;
+  }
+  
+  static Map<String, ActivityImpl> getActivitiesMap(List<ActivityImpl> activities) {
+    Map<String, ActivityImpl> map = null;
+    if (activities!=null) {
+      map = new HashMap<String, ActivityImpl>();
+      for (ActivityImpl activity: activities) {
+        if (activity.getName()!=null) {
+          if (! map.containsKey(activity.getName())) {
+            map.put(activity.getName(), activity);
+          }
+        }
+      }
+    }
+    return map;
+  }
+
+  public String toString() { 
+    if (name!=null) return "activity("+name+")";
+    if (dbid!=0) return "activity("+dbid+")";
+    return "activity("+System.identityHashCode(this)+")"; 
+  }
+
+  /** collects the full stack of parent in a list.  This activity is the 
+   * first element in the chain.  The process definition will be the last element.
+   * the chain will never be null. */
+  public List<ObservableElementImpl> getParentChain() {
+    List<ObservableElementImpl> chain = new ArrayList<ObservableElementImpl>();
+    ObservableElementImpl processElement = this;
+    while (processElement!=null) {
+      chain.add(processElement);
+      processElement = processElement.getParent();
+    }
+    return chain;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public ObservableElementImpl getParent() {
+    return (parentActivity!=null ? parentActivity : processDefinition);
+  }
+  
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public TransitionImpl getDefaultTransition() {
+    return defaultTransition;
+  }
+  public void setDefaultTransition(TransitionImpl defaultTransition) {
+    this.defaultTransition = defaultTransition;
+  }
+  public ActivityImpl getParentActivity() {
+    return parentActivity;
+  }
+  public void setParentActivity(ActivityImpl parentActivity) {
+    this.parentActivity = parentActivity;
+  }
+  public boolean isExecutionAsync() {
+    return isExecutionAsync;
+  }
+  public boolean isSignalAsync() {
+    return isSignalAsync;
+  }
+  public void setSignalAsync(boolean isSignalAsync) {
+    this.isSignalAsync = isSignalAsync;
+  }
+  public void setExecutionAsync(boolean isExecutionAsync) {
+    this.isExecutionAsync = isExecutionAsync;
+  }
+  public boolean isLeaveAsync() {
+    return isLeaveAsync;
+  }
+  public void setLeaveAsync(boolean isLeaveAsync) {
+    this.isLeaveAsync = isLeaveAsync;
+  }
+  public boolean isPreviousNeeded() {
+    return isPreviousNeeded;
+  }
+  public void setPreviousNeeded(boolean isPreviousNeeded) {
+    this.isPreviousNeeded = isPreviousNeeded;
+  }
+  public boolean isLocalScope() {
+    return isLocalScope;
+  }
+  public void setLocalScope(boolean isLocalScope) {
+    this.isLocalScope = isLocalScope;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+
+public class CommentImpl implements Serializable, Comment {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String userId = null;
+  protected Date time = null;
+  protected String message = null;
+  protected List<CommentImpl> comments = null;
+
+  public CommentImpl() {
+  }
+
+  public CommentImpl(String message) {
+    this.message = message;
+    this.time = Clock.getCurrentTime();
+    
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      this.userId = environment.getUserId();
+    }
+  }
+  
+  // replies //////////////////////////////////////////////////////////////////
+  
+  public Comment createComment(String message) {
+    if (message==null) {
+      throw new JbpmException("message is null");
+    }
+    if (this.comments==null) {
+      comments = new ArrayList<CommentImpl>();
+    }
+    CommentImpl reply = new CommentImpl(message);
+    comments.add(reply);
+    return reply;
+  }
+
+  public void removeComment(Comment comment) {
+    if (comment==null) {
+      throw new JbpmException("reply is null");
+    }
+    if (comments!=null) {
+      comments.remove(comment);
+    }
+  }
+  
+  public List<Comment> getComments() {
+    if (comments==null) {
+      return Collections.EMPTY_LIST;
+    }
+    return (List)comments;
+  }
+  
+  
+  public void setComments(List<CommentImpl> replies) {
+    this.comments = replies;
+  }
+
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getUserId() {
+    return userId;
+  }
+  public String getMessage() {
+    return message;
+  }
+  public Date getTime() {
+    return time;
+  }
+  public void setUserId(String userId) {
+    this.userId = userId;
+  }
+  public void setTime(Date time) {
+    this.time = time;
+  }
+  public void setMessage(String message) {
+    this.message = message;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CompositeElementImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.model.CompositeElement;
+import org.jbpm.model.Activity;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class CompositeElementImpl extends ScopeElementImpl implements CompositeElement {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected List<ActivityImpl> activities;
+  transient protected Map<String, ActivityImpl> activitiesMap;
+
+  // nested activities /////////////////////////////////////////////////////////////
+  
+  /**
+   * creates a nested activity. Also the nested activity's parent pointer will be set 
+   * appropriatly. 
+   */
+  public ActivityImpl createActivity() {
+    return createActivity(null);
+  }
+
+  /**
+   * creates a nested activity with the given name. Also the nested activity's parent pointer will be set 
+   * appropriatly. 
+   * @param activityName may be null. 
+   */
+  public ActivityImpl createActivity(String activityName) {
+    ActivityImpl activity = new ActivityImpl();
+    activity.setName(activityName);
+    addActivity(activity);
+    return activity;
+  }
+
+  public Activity addActivity(ActivityImpl activity) {
+    activity.setProcessDefinition(processDefinition);
+    if (activities==null) {
+      activities = new ArrayList<ActivityImpl>();
+    }
+    if (! activities.contains(activity)) {
+      activities.add(activity);
+    }
+    activitiesMap = null;
+    return activity;
+  }
+  
+  /** removes the given activity from the nested activities.
+   * Also the activity's parent will be nulled.
+   * This method will do nothing if the activity is null or if 
+   * the activity is not in the list of nested activities.
+   * If the activity is actually removed from the list of 
+   * activities, the activity's source will be nulled. 
+   * In case this is the activity that was in the 
+   * activitiesMap and another activity exists with the same
+   * name, that activity (the first) will be put in the 
+   * activitiesMap as a replacement for the removed activity.
+   */
+  public boolean removeActivity(ActivityImpl activity) {
+    if ( (activity!=null)
+         && (activities!=null)
+       ) {
+      boolean isRemoved = activities.remove(activity);
+      if (isRemoved) {
+        activity.setParentActivity(null);
+        if (activities.isEmpty()) {
+          activities = null;
+        }
+        activitiesMap = null;
+      }
+      return isRemoved;
+    }
+    return false;
+  }
+
+  /** the first nested activity with the given name or null of no
+   * such activity exists.
+   */
+  public ActivityImpl getActivity(String activityName) {
+    return (getActivitiesMap()!=null ? activitiesMap.get(activityName) : null);
+  }
+
+  /** is this activity present ? */
+  public boolean hasActivity(String activityName) {
+    return ((getActivitiesMap()!=null) && (activitiesMap.containsKey(activityName)));
+  }
+
+  public Activity findActivity(String activityName) {
+    if (activities!=null) {
+      for(ActivityImpl n : activities) {
+        Activity activity = n.findActivity(activityName);
+        if (activity!=null) {
+          return activity;
+        }
+      }
+    }
+    return null;
+  }
+
+  /** the list of nested activities.
+   * Beware: the actual member is returned.  No copy is made. 
+   */
+  public List<Activity> getActivities() {
+    return (List) activities;
+  }
+
+  /** the nested activities, keyed by activity name.  If a activity with 
+   * the same name occurs mutltiple times, the first in the list
+   * is included in the map.
+   * Activities with a null value for their name are not included 
+   * in the map.
+   * Beware: the actual member is returned.  No copy is made. 
+   */
+  public Map<String, Activity> getActivitiesMap() {
+    if(activitiesMap == null){
+      this.activitiesMap = ActivityImpl.getActivitiesMap(activities);
+    }
+    return (Map) activitiesMap;
+  }
+  
+  /** indicates if this processDefinition has activities. */
+  public boolean hasActivities() {
+    return ((activities!=null) && (!activities.isEmpty()));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.IdGenerator;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DefaultIdGenerator implements IdGenerator {
+  
+  private static Log log = Log.getLog(DefaultIdGenerator.class.getName());
+
+  public String createId(ProcessDefinition processDefinition, Execution parent, Execution execution) {
+
+    String base = null;
+    if (parent!=null) {
+      base = parent.getId(); 
+    } else if (processDefinition.getKey()!=null){
+      base = processDefinition.getKey();
+    } else {
+      base = processDefinition.getId();
+    }
+
+    String executionPart = null;
+    if (execution.getKey()!=null) {
+      executionPart = execution.getKey();
+    
+    } else if (execution.getName()!=null) {
+      executionPart = execution.getName();
+
+    } else {
+      ExecutionImpl executionImpl = (ExecutionImpl) execution;
+      Session session = Environment.getFromCurrent(Session.class);
+      session.save(executionImpl);
+      executionPart = Long.toString(executionImpl.getDbid());
+    }
+
+    String executionId = base+"/"+executionPart;
+    
+    if (log.isDebugEnabled()) log.debug("generated execution id "+executionId);
+    
+    return executionId;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventImpl extends ProcessElementImpl implements Serializable, Event {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String name;
+  protected List<EventListenerReference> listenerReferences;
+
+  public String toString() {
+    return (name != null ? "event(" + name + ")" : "event");
+  }
+
+  // listener references //////////////////////////////////////////////////////
+  
+  public EventListenerReference createEventListenerReference() {
+    if (listenerReferences==null) {
+      listenerReferences = new ArrayList<EventListenerReference>();
+    }
+    EventListenerReference activityReference = new EventListenerReference();
+    listenerReferences.add(activityReference);
+    return activityReference;
+  }
+
+  public EventListenerReference createEventListenerReference(Descriptor descriptor) {
+    EventListenerReference eventListenerReference = createEventListenerReference();
+    eventListenerReference.setDescriptor(descriptor);
+    return eventListenerReference;
+  }
+  
+  public EventListenerReference createEventListenerReference(EventListener eventListener) {
+    EventListenerReference eventListenerReference = createEventListenerReference();
+    eventListenerReference.set(eventListener);
+    return eventListenerReference;
+  }
+  
+  public EventListenerReference createEventListenerReference(String expression) {
+    EventListenerReference eventListenerReference = createEventListenerReference();
+    eventListenerReference.setExpression(expression);
+    return eventListenerReference;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public List<EventListenerReference> getListenerReferences() {
+    return listenerReferences;
+  }
+  public void setListenerReferences(List<EventListenerReference> eventListenerReferences) {
+    this.listenerReferences = eventListenerReferences;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import org.jbpm.listener.EventListener;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventListenerReference extends ObjectReference<EventListener> {
+
+  private static final long serialVersionUID = 1L;
+
+  /** does this action accept propagated events ?  */
+  boolean isPropagationEnabled = false;
+
+  /** does this action accept propagated events ?  Default is false. */
+  public boolean isPropagationEnabled() {
+    return isPropagationEnabled;
+  }
+
+  /** does this action accept propagated events ?  Default is false. */
+  public void setPropagationEnabled(boolean isPropagationEnabled) {
+    this.isPropagationEnabled = isPropagationEnabled;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.listener.EventListener;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.model.op.MoveToChildActivity;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExceptionHandlerImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  static final Log log = Log.getLog(ExceptionHandlerImpl.class.getName());
+
+  protected long dbid;
+  protected int dbversion;
+  protected String exceptionClassName;
+  protected boolean isTransactional;
+  protected boolean isRethrowMasked;
+  protected List<ObjectReference<EventListener>> eventListenerReferences;
+  protected String transitionName; // mutually exclusive with activityName
+  protected String activityName;       // mutually exclusive with transitionName
+  
+  // construction methods /////////////////////////////////////////////////////
+  
+  public ObjectReference<EventListener> createEventListenerReference(EventListener eventListener) {
+    ObjectReference<EventListener> eventListenerReference = createEventListenerReference();
+    eventListenerReference.set(eventListener);
+    return eventListenerReference;
+  }
+
+  public ObjectReference<EventListener> createEventListenerReference(Descriptor descriptor) {
+    ObjectReference<EventListener> eventListenerReference = createEventListenerReference();
+    eventListenerReference.setDescriptor(descriptor);
+    return eventListenerReference;
+  }
+
+  public ObjectReference<EventListener> createActivityReference(String expression) {
+    ObjectReference<EventListener> eventListenerReference = createEventListenerReference();
+    eventListenerReference.setExpression(expression);
+    return eventListenerReference;
+  }
+
+  public ObjectReference<EventListener> createEventListenerReference() {
+    if (eventListenerReferences==null) {
+      eventListenerReferences = new ArrayList<ObjectReference<EventListener>>();
+    }
+    ObjectReference<EventListener> actionObjectReference = new ObjectReference<EventListener>();
+    eventListenerReferences.add(actionObjectReference);
+    return actionObjectReference;
+  }
+  
+  public List<EventListener> getEventListeners() {
+    if (eventListenerReferences==null) {
+      return null;
+    }
+    List<EventListener> eventListeners = new ArrayList<EventListener>(eventListenerReferences.size());
+    for (ObjectReference<EventListener> eventListenerReference : eventListenerReferences) {
+      EventListener eventListener = eventListenerReference.get();
+      eventListeners.add(eventListener);
+    }
+    return eventListeners;
+  }
+
+  // runtime behaviour methods ////////////////////////////////////////////////
+  
+  public boolean matches(Exception exception) {
+    return matches(exception.getClass());
+  }
+
+  public boolean matches(Class<?> exceptionClass) {
+    if (exceptionClass==null) {
+      return false;
+    }
+    if ( (exceptionClassName==null)
+         || (exceptionClass.getName().equals(exceptionClassName)) 
+       ) {
+      return true;
+    }
+    Class<?> superClass = exceptionClass.getSuperclass();
+    if (superClass!=null) {
+      return matches(superClass);
+    }
+    return false;
+  }
+  
+  public void handle(ExecutionImpl execution, Exception exception) {
+    if (isTransactional) {
+      Environment environment = Environment.getCurrent();
+      Transaction transaction = (environment!=null ? environment.get(Transaction.class) : null);
+      if (transaction!=null) {
+        log.trace("registering exception handler to "+transaction);
+        CommandService commandService = environment.get(CommandService.class);
+        if (commandService==null) {
+          throw new JbpmException("environment doesn't have a command service for registering transactional exception handler", exception);
+        }
+        ExceptionHandlerSynchronization exceptionHandlerSynchronization = new ExceptionHandlerSynchronization(
+                this, execution, 
+                exception,
+                commandService
+        );
+        // registration of the synchronization is delegated to the AfterTxCompletionListener
+        // to avoid a dependency on class Synchronization
+        exceptionHandlerSynchronization.register(transaction);
+        log.trace("registering exception handler to "+transaction);
+        throw new JbpmException("transaction exception handler registered handler after transaction completed.  make sure this transaction is rolled back", exception); 
+      } else {
+        throw new JbpmException("no transaction present in the environment for transactional exception handler", exception);
+      }
+    } else {
+      executeHandler(execution, exception);
+    }
+  }
+  
+  void executeHandler(ExecutionImpl execution, Exception exception) {
+    if (eventListenerReferences!=null) {
+      for (ObjectReference<EventListener> eventListenerReference: eventListenerReferences) {
+        
+        EventListener eventListener = eventListenerReference.get();
+        
+        log.trace("executing "+eventListener+" for "+this);
+        try {
+          eventListener.notify(execution);
+        } catch (RuntimeException e) {
+          throw e;
+        } catch (Exception e) {
+          throw new JbpmException("couldn't execute "+eventListener, e);
+        }
+      }
+    }
+    
+    if (transitionName!=null) {
+      ActivityImpl activity = execution.getActivity();
+      if (activity==null) {
+        // If the execution is not positioned in a activity, it must be 
+        // positioned in a transition.  In that case we check if the 
+        // transition is present on the enclosing activity.
+        
+        // The weird way of getting checking and fetching the parent activity
+        // is because hibernate doesn't support instanceof.  The transition-->parent
+        // relation is mapped as a ProcessElementImpl.  So we can't cast it to 
+        // a ActivityImpl.  Ouch.
+        // The workaround is to check if the parent is equal to the 
+        // process definition.  If that is not the case, we can be sure 
+        // that the parent is a activity.  In that case we look up the activity 
+        // from the process definition by name.  OuchOuchSquare :-)
+        
+        TransitionImpl transition = execution.getTransition();
+        log.trace("no current activity.  searching for transition from parent of "+transition);
+        if (transition!=null) {
+          OpenProcessDefinition processDefinition = transition.getProcessDefinition();
+          ObservableElementImpl transitionParent = transition.getParent();
+          
+          if ( (transitionParent!=null)
+               && (! transitionParent.equals(processDefinition))
+             ) {
+            activity = (ActivityImpl) processDefinition.findActivity(transitionParent.getName());
+          }
+        }
+      }
+      
+      if (activity!=null) {
+        TransitionImpl transition = activity.findOutgoingTransition(transitionName);
+        if (transition!=null) {
+          log.trace(toString()+" takes transition "+transitionName);
+          execution.setTransition(transition);
+          execution.performAtomicOperationSync(ExecutionImpl.TAKE_TRANSITION);
+        } else {
+          log.info("WARNING: "+toString()+" couldn't find transition "+transitionName+" on "+activity);
+        }
+      } else {
+        log.info("WARNING: "+toString()+" couldn't find current activity to take transition "+transitionName);
+      }
+
+    } else if (activityName!=null) {
+      // execute child activity
+      ActivityImpl activity = execution.getActivity();
+      ActivityImpl childActivity = ( activity!=null ? activity.getActivity(activityName) : null );
+      if (childActivity!=null) {
+        log.trace(toString()+" takes transition "+transitionName);
+        execution.performAtomicOperationSync(new MoveToChildActivity(childActivity));
+      } else {
+        log.info("WARNING: "+toString()+" couldn't find child activity "+activityName);
+      }
+    }
+  }
+
+  public static void rethrow(Exception exception, String prefixMessage) {
+    log.trace("rethrowing "+exception);
+    if (exception instanceof RuntimeException) {
+      throw (RuntimeException) exception;
+    } else {
+      throw new JbpmException(prefixMessage+": "+exception.getMessage(), exception);
+    }
+  }
+
+  public String toString() {
+    return (exceptionClassName!=null ? "exception-handler("+exceptionClassName+")" : "exception-handler");
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getExceptionClassName() {
+    return exceptionClassName;
+  }
+  public void setExceptionClassName(String exceptionClassName) {
+    this.exceptionClassName = exceptionClassName;
+  }
+  public boolean isTransactional() {
+    return isTransactional;
+  }
+  public void setTransactional(boolean isTransactional) {
+    this.isTransactional = isTransactional;
+  }
+  public String getTransitionName() {
+    return transitionName;
+  }
+  public void setTransitionName(String transitionName) {
+    this.transitionName = transitionName;
+  }
+  public String getActivityName() {
+    return activityName;
+  }
+  public void setActivityName(String activityName) {
+    this.activityName = activityName;
+  }
+  public boolean isRethrowMasked() {
+    return isRethrowMasked;
+  }
+  public void setRethrowMasked(boolean isRethrowMasked) {
+    this.isRethrowMasked = isRethrowMasked;
+  }
+  public List<ObjectReference<EventListener>> getEventListenerReferences() {
+    return eventListenerReferences;
+  }
+  public void setEventListenerReferences(List<ObjectReference<EventListener>> activityReferences) {
+    this.eventListenerReferences = activityReferences;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerSynchronization.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerSynchronization.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerSynchronization.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.env.Transaction;
+import org.jbpm.session.DbSession;
+
+public class ExceptionHandlerSynchronization implements Synchronization, Command<Object> {
+
+  private final ExceptionHandlerImpl exceptionHandler;
+
+  private static final long serialVersionUID = 1L;
+  
+  protected ExecutionImpl execution;
+  protected Exception exception;
+  protected CommandService commandService;
+
+  public ExceptionHandlerSynchronization(ExceptionHandlerImpl exceptionHandler, ExecutionImpl execution, Exception exception, CommandService commandService) {
+    this.exceptionHandler = exceptionHandler;
+    this.execution = execution;
+    this.exception = exception;
+    this.commandService = commandService;
+  }
+
+  public void afterCompletion(int status) {
+    if (status!=Status.STATUS_ROLLEDBACK) {
+      ExceptionHandlerImpl.log.info("WARNING: no rollback after transactional exception handler. did you forget to rollback the transaction ?");
+    }
+    commandService.execute(this);
+  }
+
+  public Object execute(Environment environment) {
+    // reload the execution
+    DbSession dbSession = environment.get(DbSession.class);
+    if (dbSession==null) {
+      throw new JbpmException("no "+DbSession.class.getName()+" available in the environment for reloading the execution");
+    }
+    execution = dbSession.get(ExecutionImpl.class, execution.getDbid());
+    exceptionHandler.executeHandler(execution, exception);
+    return null;
+  }
+
+  public void beforeCompletion() {
+  }
+
+  public void register(Transaction transaction) {
+    // registration of the synchronization is delegated to the AfterTxCompletionListener
+    // to avoid a dependency on class Synchronization in class ExceptionHandlerImpl
+    transaction.registerSynchronization(this);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Comment;
+import org.jbpm.model.Event;
+import org.jbpm.model.IdGenerator;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.events.ActivityEnd;
+import org.jbpm.pvm.internal.history.events.ActivityStart;
+import org.jbpm.pvm.internal.history.events.AutomaticEnd;
+import org.jbpm.pvm.internal.history.events.ExclusiveEnd;
+import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;
+import org.jbpm.pvm.internal.history.events.ProcessInstanceStart;
+import org.jbpm.pvm.internal.history.events.TaskEnd;
+import org.jbpm.pvm.internal.history.events.TaskStart;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.op.AtomicOperation;
+import org.jbpm.pvm.internal.model.op.ExecuteActivity;
+import org.jbpm.pvm.internal.model.op.MoveToChildActivity;
+import org.jbpm.pvm.internal.model.op.MoveToParentActivity;
+import org.jbpm.pvm.internal.model.op.ProceedToDestination;
+import org.jbpm.pvm.internal.model.op.Signal;
+import org.jbpm.pvm.internal.model.op.TakeTransition;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.session.MessageSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionImpl extends ScopeInstanceImpl 
+                           implements ClientProcessInstance,
+                                      ActivityExecution, 
+                                      EventListenerExecution, 
+                                      Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(Execution.class.getName());
+  
+  // atomic operations 
+  public static final AtomicOperation EXECUTE_ACTIVITY = new ExecuteActivity();
+  public static final AtomicOperation PROCEED_TO_DESTINATION = new ProceedToDestination();
+  public static final AtomicOperation TAKE_TRANSITION = new TakeTransition();
+  public static final AtomicOperation PROPAGATE_TO_PARENT = new MoveToParentActivity();
+  
+  /** an optional name for this execution.  can be used to 
+   * differentiate concurrent paths of execution like e.g. 
+   * the 'shipping' and 'billing' paths. */
+  protected String name;
+
+  /** a key for this execution. typically this is an externally provided reference 
+   * that is unique within the scope of the process definition.  */
+  protected String key;
+
+  /** a unique id for this execution. */
+  protected String id;
+
+  protected ProcessDefinitionImpl processDefinition;
+  
+  /** current activity */
+  protected ActivityImpl activity;
+  
+  /** transition is not to be made persistable by default */
+  protected TransitionImpl transition;
+  
+  /** the activity from which the transition was taken.  This can be different from 
+   * the transition source in case a transition of an eclosing activity was taken.
+   * transitionOrigin is not to be made persistable by default */
+  protected ActivityImpl transitionOrigin;
+
+  protected EventImpl event;
+  protected ObservableElementImpl eventSource;
+  
+  /** are concurrent executions that related to this execution. */
+  protected Collection<ExecutionImpl> executions;
+
+  /** the parent child relation of executions is convenient for some forms of
+   * concurrency. */
+  protected ExecutionImpl parent = null;
+  protected ExecutionImpl processInstance;
+  
+  protected ScopeInstanceImpl scopeInstanceImpl;
+  
+  /** the super process link in case this is a sub process execution */  
+  protected ExecutionImpl superProcessExecution;
+  
+  /** the sub process link in case of sub process execution */
+  protected ExecutionImpl subProcessInstance;
+ 
+  /** the free text comments users make on this execution */
+  protected Set<CommentImpl> comments;
+  
+  /** reference to the current activity instance history record */
+  protected Long historyActivityInstanceDbid;
+  
+  /** start time of the activity for history purposes (not persisted) */
+  protected Date historyActivityStart;
+
+  protected int priority = Priority.NORMAL;
+
+  /** caches the child executions by execution name.  This member might be
+   * null and is only created from the executions in case its needed.  Note
+   * that not all executions are forced to have a name and duplicates are allowed.
+   * In case the {@link #executions} change, the executionsMap can be nulled or
+   * also updated (but a check needs to be added whether it exists). */
+  protected transient Map<String, OpenExecution> executionsMap = null;
+
+  // transient members
+
+  /** the queue of atomic operations to be performed for this execution. */
+  protected Queue<AtomicOperation> atomicOperations;
+
+  public enum Propagation {
+    UNSPECIFIED, WAIT, EXPLICIT
+  }
+  protected Propagation propagation = null;
+
+  protected Activity previousActivity;
+  protected Transition previousTransition;
+
+  // construction /////////////////////////////////////////////////////////////
+  
+  public void initializeProcessInstance(ProcessDefinitionImpl processDefinition, String key) {
+    this.processDefinition = processDefinition;
+    this.activity = (ActivityImpl) processDefinition.getInitial();
+    this.processInstance = this;
+    this.state = STATE_CREATED;
+    this.key = key;
+
+    IdGenerator idGenerator = processDefinition.getIdGenerator();
+    if (idGenerator!=null) {
+      this.id = idGenerator.createId(processDefinition, null, this);
+    }
+  }
+
+  // execution method : start /////////////////////////////////////////////////
+
+  public void start() {
+    if (state!=STATE_CREATED) {
+      throw new JbpmException(toString()+" is already begun: "+state);
+    }
+    this.state = STATE_ACTIVE;
+    ExecutionImpl scopedExecution = initializeScopes();
+    
+    fireHistoryEvent(new ProcessInstanceStart());
+    fire(Event.START, processDefinition);
+    if (activity!=null) {
+      scopedExecution.performAtomicOperation(EXECUTE_ACTIVITY);
+    }
+  }
+
+  protected ExecutionImpl initializeScopes() {
+    LinkedList<ActivityImpl> enteredActivities = new LinkedList<ActivityImpl>();
+
+    ActivityImpl initial = processDefinition.getInitial();
+    ExecutionImpl scopedExecution = null;
+    
+    if (initial!=null) {
+      enteredActivities.add(initial);
+      ActivityImpl parentActivity = initial.getParentActivity();
+      while (parentActivity!=null) {
+        enteredActivities.addFirst(parentActivity);
+        parentActivity = parentActivity.getParentActivity();
+      }
+      
+      scopedExecution = this;
+
+      initializeVariables(processDefinition, this);
+      initializeTimers(processDefinition);
+      
+      for (ActivityImpl enteredActivity: enteredActivities) {
+        if (enteredActivity.isLocalScope()) {
+          scopedExecution.setActivity(enteredActivity);
+          scopedExecution = scopedExecution.createScope(enteredActivity);
+        }
+      }
+      
+      scopedExecution.setActivity(initial);
+    }
+    return scopedExecution;
+  }
+
+  public ExecutionImpl createScope(ScopeElementImpl scope) {
+    ExecutionImpl child = createExecution(scope.getName());
+    
+    // copy the current state from the child execution to the parent execution
+    child.setActivity(getActivity());
+    child.setTransition(getTransition());
+    child.setPropagation(getPropagation());
+    child.setTransitionOrigin(getTransitionOrigin());
+    child.setPreviousTransition(getPreviousTransition());
+    child.setPreviousActivity(getPreviousActivity());
+    
+    child.initializeVariables(scope, this);
+    child.initializeTimers(scope);
+    
+    return child;
+  }
+  
+  public ExecutionImpl destroyScope(CompositeElementImpl scope) {
+    destroyTimers(scope);
+    destroyVariables(scope, parent);
+    
+    // copy the current state from the child execution to the parent execution
+    getParent().setActivity(getActivity());
+    getParent().setTransition(getTransition());
+    getParent().setPropagation(getPropagation());
+    getParent().setTransitionOrigin(getTransitionOrigin());
+    getParent().setPreviousTransition(getPreviousTransition());
+    getParent().setPreviousActivity(getPreviousActivity());
+    
+    end();
+
+    return parent;
+  }
+  
+  // basic object methods /////////////////////////////////////////////////////
+
+  public String toString() {
+    if (name!=null) {
+      return "execution["+name+"]";
+    }
+    if (parent==null) {
+      return "process-instance";
+    }
+    return "execution";
+  }
+  
+  // execution method : end ///////////////////////////////////////////////////
+
+  public void end() {
+    end(Execution.STATE_ENDED);
+  }
+
+  public void end(String state) {
+    if (state==null) {
+      throw new JbpmException("state is null");
+    }
+    if (state.equals(STATE_ACTIVE)
+        || state.equals(STATE_CREATED)
+        || state.equals(STATE_INACTIVE)
+        || state.equals(STATE_SUSPENDED)
+        || state.equals(STATE_ASYNC)) {
+      throw new JbpmException("invalid end state: "+state);
+    }
+      
+    if (log.isDebugEnabled()) {
+      if (state==STATE_ENDED) {
+        log.debug(toString()+" ends");
+      } else {
+        log.debug(toString()+" ends with state "+state);
+      }
+    }
+    
+    // end all child executions
+    if (executions!=null) {
+      for (ExecutionImpl child: executions) {
+        child.end(state);
+      }
+    }
+    
+    setState(state);
+
+    this.propagation = Propagation.EXPLICIT;
+    
+    if (parent!=null) {
+      parent.removeExecution(this);
+      
+    } else { // this is a process instance
+      fireHistoryEvent(new ProcessInstanceEnd());
+      fire(Event.END, processDefinition);
+      if (superProcessExecution!=null) {
+        log.trace(toString()+" signals super process execution");
+        superProcessExecution.signal();
+      }
+      
+      Environment environment = Environment.getCurrent();
+      if (environment!=null) {
+        Transaction transaction = environment.get(Transaction.class);
+        CommandService commandService = environment.get(CommandService.class);
+        if ( (transaction!=null)
+             && (commandService!=null)
+           ) {
+          transaction.registerSynchronization(new ProcessInstanceEndedSynchronization(this.getId(), commandService));
+        }
+      }
+    }
+  }
+  
+  public void end(OpenExecution executionToEnd) {
+    ((ExecutionImpl)executionToEnd).end();
+  }
+
+  public void end(OpenExecution executionToEnd, String state) {
+    ((ExecutionImpl)executionToEnd).end(state);
+  }
+
+
+  // execution method : suspend and resume ////////////////////////////////////
+
+  /** @see Execution#suspend() */
+  public void suspend() {
+    if (isSuspended()) {
+      throw new JbpmException(toString()+" is suspended");
+    }
+    lock(STATE_SUSPENDED);
+  }
+
+  /** @see Execution#resume() */
+  public void resume() {
+    if (! isSuspended()) {
+      throw new JbpmException(toString()+" is not suspended");
+    }
+    unlock();
+  }
+
+  // execution method : signal ////////////////////////////////////////////////
+
+  public void signal() {
+    signal(null, (Map)null);
+  }
+
+  public void signal(String signal) {
+    signal(signal, (Map)null);
+  }
+  
+  public void signal(Map<String, Object> parameters) {
+    signal(null, parameters);
+  }
+
+  public void signal(String signal, Map<String, Object> parameters) {
+    checkLock();
+    if (activity!=null) {
+      performAtomicOperation(new Signal(signal, parameters, activity));
+    } else if (transition!=null) {
+      performAtomicOperation(ExecutionImpl.PROCEED_TO_DESTINATION);
+    } else {
+      throw new JbpmException("execution is not in a activity or in a transition");
+    }
+  }
+  
+  public void signal(Execution execution) {
+    ((ExecutionImpl)execution).signal(null, (Map)null);
+  }
+
+  public void signal(String signalName, Execution execution) {
+    ((ExecutionImpl)execution).signal(signalName, (Map)null);
+  }
+
+  public void signal(Map<String, Object> parameters, Execution execution) {
+    ((ExecutionImpl)execution).signal(null, parameters);
+  }
+
+  public void signal(String signalName, Map<String, Object> parameters, Execution execution) {
+    ((ExecutionImpl)execution).signal(signalName, parameters);
+  }
+
+  // execution method : take ////////////////////////////////////////////////
+  
+  /** @see Execution#takeDefaultTransition() */
+  public void takeDefaultTransition() {
+    TransitionImpl defaultTransition = activity.getDefaultTransition();
+    if (defaultTransition==null) {
+      throw new JbpmException("there is no default transition in "+activity);
+    }
+    take(defaultTransition);
+  }
+
+  /** @see Execution#take(String) */
+  public void take(String transitionName) {
+    if (activity==null) {
+      throw new JbpmException(toString()+" is not positioned in activity");
+    }
+    TransitionImpl transition = findTransition(transitionName);
+    if (transition==null) {
+      throw new JbpmException("there is no transition "+transitionName+" in "+activity);
+    }
+    take(transition);
+  }
+
+  /** @see Execution#takeDefaultTransition() */
+  public void take(Transition transition) {
+    checkLock();
+
+    setPropagation(Propagation.EXPLICIT);
+    setTransition((TransitionImpl) transition);
+    // copy the current activity as the transition origin.  the origin can be different from 
+    // the transition source in case a transition is taken from an enclosing activity
+    setTransitionOrigin(getActivity());
+    setPreviousTransition(null);
+
+    performAtomicOperation(TAKE_TRANSITION);
+  }
+  
+  public void take(Transition transition, Execution execution) {
+    ((ExecutionImpl)execution).take(transition);
+  }
+
+  // execution method : execute ///////////////////////////////////////////////
+
+  /** @see Execution#execute(String) */
+  public void execute(String activityName) {
+    if (activity==null) {
+      throw new JbpmException("activity is null");
+    }
+    Activity nestedActivity = activity.getActivity(activityName);
+    if (nestedActivity==null) {
+      throw new JbpmException("activity "+activityName+" doesn't exist in "+activity);
+    }
+    execute(nestedActivity);
+  }
+  
+  /** @see Execution#execute(Activity) */
+  public void execute(Activity activity) {
+    if (activity==null) {
+      throw new JbpmException("activity is null");
+    }
+    checkLock();
+    
+    this.propagation = Propagation.EXPLICIT;
+    performAtomicOperation(new MoveToChildActivity((ActivityImpl) activity));
+  }
+  
+  // execution method : waitForSignal /////////////////////////////////////////
+  
+  public void waitForSignal() {
+    propagation = Propagation.WAIT;
+  }
+  
+  // execution method : proceed ///////////////////////////////////////////////
+
+  public void proceed() {
+    checkLock();
+
+    // in graph based processDefinition languages we assume that a
+    // default transition is available
+    TransitionImpl defaultTransition = findDefaultTransition();
+    if (defaultTransition!=null) {
+      take(defaultTransition);
+      
+    // in block structured processDefinition languages we assume that 
+    // there is no default transition and that there is a 
+    // parent activity of the current activity
+    } else {
+      ActivityImpl parentActivity = activity.getParentActivity();
+
+      // if there is a parent activity
+      if (parentActivity!=null) {
+        // propagate to the parent
+        performAtomicOperation(PROPAGATE_TO_PARENT);
+        
+      }  else {
+        // When we don't know how to proceed, i don't know if it's best to 
+        // throw new PvmException("don't know how to proceed");
+        // or to end the execution.  Because of convenience for testing, 
+        // I opted to end the execution.
+        end();
+      }
+    }
+  }
+
+  public void setActivity(Activity destination, Execution execution) {
+    ((ExecutionImpl)execution).setActivity(destination);
+  }
+
+  public void setActivity(Activity destination) {
+    setActivity((ActivityImpl) destination);
+  }
+
+  // execution : internal methods /////////////////////////////////////////////
+
+  public void moveTo(ActivityImpl destination) {
+    // if the parent activity needs to know the previous activity
+    if (destination.isPreviousNeeded()) {
+      setPreviousActivity(getActivity());
+      setPreviousTransition(getTransition());
+    } else {
+      this.previousActivity = null;
+      this.previousTransition = null;
+    }
+
+    // move the execution to the destination
+    activity = destination;
+    transition = null;
+    transitionOrigin = null;
+  }
+
+  public ExecutionImpl startActivity(ActivityImpl activity) {
+    ExecutionImpl propagatingExecution = this;
+    if (activity.isLocalScope()) {
+      propagatingExecution = createScope(activity);
+    }
+    fire(Event.START, activity);
+    return propagatingExecution;
+  }
+
+  public ExecutionImpl endActivity(ActivityImpl activity) {
+    ExecutionImpl propagatingExecution = this;
+    fire(Event.END, activity);
+    if (activity.isLocalScope()) {
+      propagatingExecution = destroyScope(activity);
+    }
+    return propagatingExecution;
+  }
+
+  public synchronized void performAtomicOperation(AtomicOperation operation) {
+    if (operation.isAsync(this)) {
+      sendContinuationMessage(operation);
+    } else {
+      performAtomicOperationSync(operation);
+    }
+  }
+  
+  // asynchronous continuations ////////////////////////////////////////////////  
+
+  public void sendContinuationMessage(AtomicOperation operation) {
+    Environment environment = Environment.getCurrent();
+    MessageSession messageSession = environment.get(MessageSession.class);
+    if (messageSession==null) {
+      throw new JbpmException("no message-session configured to send asynchronous continuation message");
+    }
+    MessageImpl<?> asyncMessage = operation.createAsyncMessage(this);
+    lock(Execution.STATE_ASYNC);
+    messageSession.send(asyncMessage);
+  }
+
+  public void performAtomicOperationSync(AtomicOperation operation) {
+    if (atomicOperations==null) {
+      
+      // initialise the fifo queue of atomic operations
+      atomicOperations = new LinkedList<AtomicOperation>();
+      atomicOperations.offer(operation);
+      
+      try {
+        while (! atomicOperations.isEmpty()) {
+          AtomicOperation atomicOperation = atomicOperations.poll();
+          atomicOperation.perform(this);
+        }
+
+      } catch (RuntimeException e ) {
+        throw e;
+      } finally {
+        atomicOperations = null;
+      }
+    } else {
+      atomicOperations.offer(operation);
+    }
+  }
+
+  // events ///////////////////////////////////////////////////////////////////
+
+  /** @see Execution#fire(String, ObservableElement) */
+  public void fire(String eventName, ObservableElement eventSource) {
+    fire(eventName, eventSource, (ObservableElementImpl) eventSource);
+  }
+
+  /** fires the event on the given *processElement* and then propagates the event 
+   * up to the *processElement* parent chain. */
+  void fire(String eventName, ObservableElement eventSource, ObservableElementImpl observableElement) {
+    if (observableElement!=null) {
+      EventImpl event = (EventImpl) observableElement.getEvent(eventName);
+      if (event!=null) {
+        if (log.isTraceEnabled()) {
+          if (observableElement==eventSource) {
+            log.trace("firing "+event+" on "+eventSource);
+          } else {
+            log.trace("firing "+event+" on "+observableElement+", propagated from source "+eventSource);
+          }
+        }
+        fire(event, eventSource, observableElement);
+      }
+      propagateEvent(eventName, eventSource, observableElement);
+    }
+  }
+
+  /** this method enables specific process languages to overwrite the event propagation behaviour */
+  protected void propagateEvent(String eventName, ObservableElement eventSource, ObservableElementImpl observableElement) {
+    fire(eventName, eventSource, observableElement.getParent());
+  }
+
+  /** fires the given event without propagation */
+  void fire(EventImpl event, ObservableElement eventSource, ObservableElement observableElement) {
+    try {
+      this.event = event;
+      this.eventSource = (ObservableElementImpl) eventSource;
+      
+      List<EventListenerReference> eventListenerReferences = event.getListenerReferences();
+      
+      if (eventListenerReferences!=null) {
+        for (EventListenerReference eventListenerReference: eventListenerReferences) {
+          
+          if ( (observableElement.equals(eventSource)) // this event is not propagated
+               || (eventListenerReference.isPropagationEnabled()) // propagation is allowed
+             ) {
+            EventListener eventListener = eventListenerReference.get();
+            
+            log.trace("executing "+eventListener+" for "+event);
+            try {
+              // TODO can/should this invocation be unified with the exception handler invocation of the event notification method?
+              eventListener.notify(this);
+            } catch (Exception e) {
+              log.trace("exception during action: "+e);
+              handleException((ObservableElementImpl) observableElement, event, eventListenerReference, e, "couldn't run action "+eventListener);
+            }
+          }
+        }
+      }
+
+    } finally {
+      this.eventSource = null;
+      this.event = null;
+    }
+  }
+  
+  public void handleException(ObservableElementImpl observableElement,
+                              EventImpl event,
+                              EventListenerReference eventListenerReference,
+                              Exception exception,
+                              String rethrowMessage) {
+    
+    List<ProcessElementImpl> processElements = new ArrayList<ProcessElementImpl>();
+    if (eventListenerReference!=null) {
+      processElements.add(eventListenerReference);
+    }
+    if (event!=null) {
+      processElements.add(event);
+    }
+    while (observableElement!=null) {
+      processElements.add(observableElement);
+      observableElement = observableElement.getParent();
+    }
+    
+    for (ProcessElementImpl processElement: processElements) {
+      List<ExceptionHandlerImpl> exceptionHandlers = processElement.getExceptionHandlers();
+      if (exceptionHandlers!=null) {
+        for (ExceptionHandlerImpl exceptionHandler: exceptionHandlers) {
+          if (exceptionHandler.matches(exception)) {
+            try {
+              exceptionHandler.handle(this, exception);
+              return;
+            } catch (Exception rethrowException) {
+              if (!exceptionHandler.isRethrowMasked()) {
+                exception = rethrowException;
+              }
+            }
+            break;
+          }
+        }
+      }
+    }
+
+    log.trace("rethrowing exception cause no exception handler for "+exception);
+    ExceptionHandlerImpl.rethrow(exception, rethrowMessage+": "+exception.getMessage());
+  }
+  
+
+  /** searches for an event up the process element parent hierarchy starting 
+   * from the given process element and returns an event or null if no such 
+   * event exists. */ 
+  EventImpl findEvent(String eventName, ObservableElementImpl observableElement) {
+    EventImpl event = null;
+    while ( (event==null)
+            && (observableElement!=null)
+          ) {
+      event = (EventImpl) observableElement.getEvent(eventName);
+      if (event==null) {
+        observableElement = observableElement.getParent();
+      }
+    }
+    return event;
+  }
+
+  // comments /////////////////////////////////////////////////////////////////
+  
+  public Comment createComment(String message) {
+    if (message==null) {
+      throw new JbpmException("message is null");
+    }
+    CommentImpl comment = new CommentImpl(message);
+    addComment(comment);
+    return comment;
+  }
+  
+  public void removeComment(Comment comment) {
+    throw new UnsupportedOperationException("please implement me");
+  }
+
+  public void addComment(CommentImpl comment) {
+    if (comment==null) {
+      throw new JbpmException("comment is null");
+    }
+    if (comments==null) {
+      comments = new LinkedHashSet<CommentImpl>();
+    }
+    comments.add(comment);
+  }
+
+  // child executions /////////////////////////////////////////////////////////
+
+  /** @see Execution#createProcessInstance() */
+  public ExecutionImpl createExecution() {
+    return createExecution((String)null);
+  }
+
+  public Execution createExecution(Execution parent) {
+    return ((ExecutionImpl)parent).createExecution();
+  }
+
+  public Execution createExecution(String name, Execution parent) {
+    return ((ExecutionImpl)parent).createExecution(name);
+  }
+
+  /** @see Execution#createProcessInstance(String) */
+  public ExecutionImpl createExecution(String name) {
+    // creating a child execution implies that this execution 
+    // is not a leave any more and therefore, it is inactivated
+    if (isActive()) {
+      lock(STATE_INACTIVE);
+      propagation = Propagation.EXPLICIT;
+    }
+
+    // create child execution
+    ExecutionImpl childExecution = newChildExecution();
+    childExecution.processDefinition = this.processDefinition;
+    childExecution.processInstance = this.processInstance;
+    childExecution.activity = this.activity;
+    childExecution.state = STATE_ACTIVE;
+    childExecution.name = name;
+    log.debug("creating "+childExecution);
+    // add it to this execution
+    addExecution(childExecution);
+    // invalidate the cached executionsMap
+    executionsMap = null;
+    
+    IdGenerator keyGenerator = Environment.getFromCurrent(IdGenerator.class, false);
+    if (keyGenerator!=null) {
+      childExecution.id = keyGenerator.createId(processDefinition, this, childExecution);
+    }
+    
+    return childExecution;
+  }
+
+  protected ExecutionImpl newChildExecution() {
+    return new ExecutionImpl();
+  }
+
+  public void addExecution(Execution execution) {
+    ExecutionImpl executionImpl = (ExecutionImpl) execution;
+    executionImpl.parent = this;
+    if (executions==null) {
+      executions = new ArrayList<ExecutionImpl>();
+    }
+    executions.add(executionImpl);
+  }
+
+  /** @see Execution#getExecution(String) */
+  public ExecutionImpl getExecution(String name) {
+    Map<String, OpenExecution> executionsMap = getExecutionsMap();
+    return (ExecutionImpl) (executionsMap!=null ? executionsMap.get(name) : null);
+  }
+
+  public void removeExecution(Execution child) {
+    if (executions!=null) {
+      if (executions.remove(child)) {
+        if ( state.equals(STATE_INACTIVE) && 
+            (executions.isEmpty())
+          ) {
+         if (log.isTraceEnabled()) {
+           log.trace("last child execution was removed; unlocking");
+         }
+         state = STATE_ACTIVE;
+        } else if (log.isTraceEnabled()) {
+          log.trace("removed "+child+" from "+this);
+        }
+        // invalidate the executionsMap cache
+        executionsMap = null;
+      } else {
+        throw new JbpmException(child+" is not a child execution of "+this);
+      }
+    }
+  }
+
+  public void removeExecution(Execution child, Execution parent) {
+    ((ExecutionImpl)parent).removeExecution(child);
+  }
+
+  public Map<String, OpenExecution> getExecutionsMap() {
+    if ( (executionsMap==null)
+         && (executions!=null)
+        ) {
+      // initialize executionsMap cache
+      executionsMap = new HashMap<String, OpenExecution>();
+      for(ExecutionImpl execution: executions) {
+        String executionName = execution.getName();
+        // the next test makes sure that the first execution wins
+        // in case there are multiple executions with the same name
+        if (! executionsMap.containsKey(executionName)) {
+          executionsMap.put(executionName, execution);
+        }
+      }
+    }
+    return executionsMap;
+  }
+  
+  public boolean hasExecution(String name) {
+    return ( (getExecutionsMap()!=null)
+             && executionsMap.containsKey(name)
+           );
+  }
+
+  // sub process creation /////////////////////////////////////////////////////
+
+  public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition) {
+    return createSubProcessInstance(processDefinition, null);
+  }
+  
+  public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition, String key) {
+    if (subProcessInstance!=null) {
+      throw new JbpmException(toString()+" already has a sub process instance: "+subProcessInstance);
+    }
+    subProcessInstance = (ExecutionImpl) processDefinition.createProcessInstance(key);
+    subProcessInstance.setSuperProcessExecution(this);
+    return subProcessInstance;
+  }
+  
+  public ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition) {
+    return beginSubProcessInstance(processDefinition, null);
+  }
+  
+  public ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition, String key) {
+    createSubProcessInstance(processDefinition, key);
+    subProcessInstance.start();
+    return subProcessInstance;
+  }
+
+  // state : internal methods /////////////////////////////////////////////////
+
+  /** @see Execution#lock(String) */
+  public void lock(String state) {
+    if (state==null) {
+      throw new JbpmException("given state is null");
+    }
+    checkLock();
+    log.trace("locking "+this);
+    this.state = state;
+  }
+  
+  /** @see Execution#unlock() */
+  public void unlock() {
+    if (Execution.STATE_ACTIVE.equals(state)) {
+      throw new JbpmException("state is already active");
+    }
+    log.trace("unlocking "+this);
+    this.state = Execution.STATE_ACTIVE;
+  }
+
+  protected void checkLock() {
+    if (!Execution.STATE_ACTIVE.equals(state)) {
+      throw new JbpmException(toString()+" is not active: "+state);
+    }
+  }
+
+  // activity name ////////////////////////////////////////////////////////////////
+  
+  public String getActivityName() {
+    if (activity==null) {
+      return null;
+    }
+    return activity.getName();
+  }
+  
+  ////////////////////////////////////////////////////////////////////////////////
+
+  public void fireHistoryEvent(HistoryEvent historyEvent) {
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      HistorySession historySession = environment.get(HistorySession.class);
+      if (historySession!=null) {
+        historyEvent.setExecution(this);
+        historySession.process(historyEvent);
+      }
+    }
+  }
+
+  // overriding the ScopeInstanceImpl methods /////////////////////////////////
+  
+  public ScopeInstanceImpl getParentVariableScope() {
+    return parent;
+  }
+
+  public ExecutionImpl getTimerExecution() {
+    return this;
+  }
+
+  // overridable by process languages /////////////////////////////////////////
+  
+  /** by default this will use {@link ActivityImpl#findOutgoingTransition(String)} to 
+   * search for the outgoing transition, which includes a search over the parent chain 
+   * of the current activity.  This method allows process languages to overwrite this default 
+   * implementation of the transition lookup by transitionName.*/
+  protected TransitionImpl findTransition(String transitionName) {
+    return activity.findOutgoingTransition(transitionName);
+  }
+
+  protected TransitionImpl findDefaultTransition() {
+    return activity.findDefaultTransition();
+  }
+  
+  // history //////////////////////////////////////////////////////////////////
+
+  public void historyAutomatic() {
+    fireHistoryEvent(new AutomaticEnd());
+  }
+
+  public void historyExclusive(String transitionName) {
+    fireHistoryEvent(new ExclusiveEnd(transitionName));
+  }
+  
+  public void historyActivityStart() {
+    fireHistoryEvent(new ActivityStart());
+  }
+
+  public void historyActivityEnd() {
+    fireHistoryEvent(new ActivityEnd());
+  }
+
+  public void historyActivityEnd(String transitionName) {
+    fireHistoryEvent(new ActivityEnd(transitionName));
+  }
+
+  public void historyTaskStart(String assignee) {
+    fireHistoryEvent(new TaskStart(assignee));
+  }
+
+  public void historyTaskEnd(String outcome) {
+    fireHistoryEvent(new TaskEnd(outcome));
+  }
+  
+  // extensions ///////////////////////////////////////////////////////////////
+
+  public <T> T getExtension(Class<T> extensionClass) {
+    if (extensionClass==null) {
+      throw new JbpmException("extensionClass is null.  and this execution doesn't support extensions");
+    }
+    throw new JbpmException("unsuppported extension "+extensionClass.getName());
+  }
+
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  // getters and setters /////////////////////////////////////////////////////////
+  
+  public boolean isProcessInstance() {
+    return parent==null;
+  }
+
+  public List<Comment> getComments() {
+    if (comments==null) {
+      return Collections.emptyList();
+    }
+    return new ArrayList<Comment>(comments);
+  }
+
+  public Event getEvent() {
+    return event;
+  }
+  public ObservableElement getEventSource() {
+    return eventSource;
+  }
+  public Collection<OpenExecution> getExecutions() {
+    return (Collection) executions;
+  }
+  public String getName() {
+    return name;
+  }
+  public ExecutionImpl getParent() {
+    return parent;
+  }
+  public int getPriority() {
+    return priority;
+  }
+  public ProcessDefinitionImpl getProcessDefinition() {
+    return processDefinition;
+  }
+  public TransitionImpl getTransition() {
+    return transition;
+  }
+  public void setEvent(EventImpl event) {
+    this.event = event;
+  }
+  public void setEventSource(ObservableElementImpl eventSource) {
+    this.eventSource = eventSource;
+  }
+  public void setPriority(int priority) {
+    this.priority = priority;
+  }
+  public void setTransition(TransitionImpl transition) {
+    this.transition = transition;
+  }
+  public Activity getPreviousActivity() {
+    return previousActivity;
+  }
+  public Transition getPreviousTransition() {
+    return previousTransition;
+  }
+  public ExecutionImpl getProcessInstance() {
+    return processInstance;
+  }
+  public void setProcessInstance(ExecutionImpl processInstance) {
+    this.processInstance = processInstance;
+  }
+  public void setComments(Set<CommentImpl> comments) {
+    this.comments = comments;
+  }
+  public ActivityImpl getTransitionOrigin() {
+    return transitionOrigin;
+  }
+  public void setTransitionOrigin(ActivityImpl transitionOrigin) {
+    this.transitionOrigin = transitionOrigin;
+  }
+  public String getKey() {
+    return key;
+  }
+  public Propagation getPropagation() {
+    return propagation;
+  }
+  public void setPropagation(Propagation propagation) {
+    this.propagation = propagation;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public void setState(String state) {
+    this.state = state;
+  }
+  public void setExecutions(Collection<ExecutionImpl> executions) {
+    this.executions = executions;
+  }
+  public void setParent(ExecutionImpl parent) {
+    this.parent = parent;
+  }
+  public void setPreviousActivity(Activity previousActivity) {
+    this.previousActivity = previousActivity;
+  }
+  public void setPreviousTransition(Transition previousTransition) {
+    this.previousTransition = previousTransition;
+  }
+  public void setProcessDefinition(ProcessDefinitionImpl processDefinition) {
+    this.processDefinition = processDefinition;
+  }
+  public ExecutionImpl getSuperProcessExecution() {
+    return superProcessExecution;
+  }
+  public void setSuperProcessExecution(ExecutionImpl superProcessExecution) {
+    this.superProcessExecution = superProcessExecution;
+  }
+  public ExecutionImpl getSubProcessInstance() {
+    return subProcessInstance;
+  }
+  public void setSubProcessInstance(ExecutionImpl subProcessExecution) {
+    this.subProcessInstance = subProcessExecution;
+  }
+  public ActivityImpl getActivity() {
+    return activity;
+  }
+  public void setActivity(ActivityImpl activity) {
+    this.activity = activity;
+  }
+  public void setKey(String key) {
+    this.key = key;
+  }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
+  public Long getHistoryActivityInstanceDbid() {
+    return historyActivityInstanceDbid;
+  }
+  public void setHistoryActivityInstanceDbid(Long historyActivityInstanceDbid) {
+    this.historyActivityInstanceDbid = historyActivityInstanceDbid;
+  }
+  public Date getHistoryActivityStart() {
+    return historyActivityStart;
+  }
+  public void setHistoryActivityStart(Date historyActivityStart) {
+    this.historyActivityStart = historyActivityStart;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import org.jbpm.model.Condition;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.env.EnvironmentDefaults;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExpressionEvaluator implements Condition {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String name;
+  protected String expr;
+  protected String lang;
+  
+  public ExpressionEvaluator(String name, String expr, String lang) {
+    this.name = name;
+    this.expr = expr;
+    this.lang = lang;
+  }
+
+  public boolean evaluate(OpenExecution execution) {
+    return (Boolean) evaluateExpression(execution);
+  }
+
+  public Object evaluateExpression(OpenExecution execution) {
+    ScriptManager scriptManager = EnvironmentDefaults.getScriptManager();
+    return scriptManager.evaluateExpression(expr, execution, lang);
+  }
+
+  public String getName() {
+    return name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObjectReference.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObjectReference.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObjectReference.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+public class ObjectReference<T> extends ProcessElementImpl {
+  
+  private static final long serialVersionUID = 1L;
+  // private static final Log log = Log.getLog(ObjectReference.class.getName());
+
+  protected String expression;
+  protected String expressionLanguage;
+  protected Descriptor descriptor;
+  protected T object;
+
+  public ObjectReference() {
+  }
+
+  public ObjectReference(String expression) {
+    this.expression = expression;
+  }
+
+  public ObjectReference(Descriptor descriptor) {
+    this.descriptor = descriptor;
+  }
+
+  public ObjectReference(T object) {
+    this.object = object;
+  }
+  
+  public String toString() {
+    if (object!=null) {
+      return object.toString();
+    }
+    if (expression!=null) {
+      return expression;
+    }
+    if (descriptor!=null) {
+      return descriptor.toString();
+    }
+    return null;
+  }
+
+  public T get() {
+    if (object!=null) {
+      return object;
+    }
+    if (expression!=null) {
+      return resolveValueExpression();
+    }
+    if (descriptor!=null) {
+      return constructFromDescriptor();
+    }
+    return null;
+  }
+
+  public void set(T object) {
+    this.object = object;
+  }
+  
+  // object builders //////////////////////////////////////////////////////////
+
+  protected T constructFromDescriptor() {
+    return (T) WireContext.create(descriptor);
+  }
+
+  protected T resolveValueExpression() {
+    Environment environment = Environment.getCurrent();
+    return null;
+  }
+  
+  protected T resolveMethodExpression(Environment environment) {
+    return null;
+  }
+  
+  public void setDescriptor(Descriptor descriptor) {
+    this.descriptor = descriptor;
+  }
+  public Descriptor getDescriptor() {
+    return descriptor;
+  }
+  public void setExpression(String expression) {
+    this.expression = expression;
+  }
+  public T getObject() {
+    return object;
+  }
+  public void setObject(T object) {
+    this.object = object;
+  }
+  public String getExpression() {
+    return expression;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ObservableElementImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.model.Event;
+import org.jbpm.model.ObservableElement;
+
+
+/** observable and visible process elements.
+ * 
+ * @author Tom Baeyens
+ */
+public class ObservableElementImpl extends ProcessElementImpl implements ObservableElement {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String name;
+  protected String description;
+  protected Map<String, EventImpl> events;
+  
+  // default parent is null ///////////////////////////////////////////////////
+
+  public ObservableElementImpl getParent() {
+    return null;
+  }
+  
+  // events ///////////////////////////////////////////////////////////////////
+  
+  public EventImpl getEvent(String eventName) {
+    return (events != null ? events.get(eventName) : null);
+  }
+
+  public boolean hasEvent(String eventName) {
+    return (getEvent(eventName)!=null);
+  }
+
+  /** event factory method that also establishes the bidirectional relation. */
+  public EventImpl createEvent(String eventName) {
+    EventImpl event = new EventImpl();
+    event.setName(eventName);
+    return addEvent(event);
+  }
+
+  /**
+   * add an event to this processDefinition element.
+   * @throws NullPointerException if event is null.
+   */
+  public EventImpl addEvent(EventImpl event) {
+    if (events == null) {
+      events = new HashMap<String, EventImpl>();
+    }
+    events.put(event.getName(), event);
+    return event;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public Map<String, Event> getEvents() {
+    return (Map) events;
+  }
+  public void setEvents(Map<String, EventImpl> events) {
+    this.events = events;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.IdGenerator;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.util.IoUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionImpl extends CompositeElementImpl implements OpenProcessDefinition, ClientProcessDefinition {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ProcessDefinitionImpl.class.getName());
+  
+  public static final int UNASSIGNED_VERSION = -1;
+
+  /** user provided short reference for the process definition that 
+   * has the same scope as the name.  Multiple versions of the same 
+   * process can have the same key. The key is used to build the 
+   * globally unique execution ids. */
+  protected String key;
+  
+  /** the unique id (e.g. combination of name and versionnumber) for this 
+   * process definition. */
+  protected String id;
+
+  /** the version number of the process definitions with the same name.*/
+  protected int version = UNASSIGNED_VERSION;
+  
+  /** optional package name similar to the Java package name. */
+  protected String packageName;
+  
+  /** time this process was deployed */
+  protected Date deploymentTime;
+  
+  /** the activity which is executed when the process starts */
+  protected ActivityImpl initial;
+  
+  /** the attachments */
+  protected Map<String, Lob> attachments;
+
+  public ProcessDefinitionImpl() {
+    this.processDefinition = this;
+  }
+
+  // execution factory method /////////////////////////////////////////////////
+  
+  public ClientProcessInstance createProcessInstance() {
+    return createProcessInstance(null, null);
+  }
+  
+  public ClientProcessInstance createProcessInstance(String key) {
+    return createProcessInstance(key, null);
+  }
+
+  public ClientProcessInstance createProcessInstance(String key, Execution superProcessExecution) {
+    ExecutionImpl processInstance = newProcessInstance();
+    log.debug("creating new execution for process '"+name+"'");
+    if (superProcessExecution!=null) {
+      // establish the bidirectional relation between super process activity instance 
+      // and sub process instance 
+      ExecutionImpl superProcessExecutionImpl = (ExecutionImpl) superProcessExecution;
+      processInstance.setSuperProcessExecution(superProcessExecutionImpl);
+      superProcessExecutionImpl.setSubProcessInstance(processInstance);
+    }
+    processInstance.initializeProcessInstance(this, key);
+    return processInstance;
+  }
+  
+  public ClientProcessInstance startProcessInstance() {
+    ClientProcessInstance processInstance = createProcessInstance(null, null);
+    processInstance.start();
+    return processInstance;
+  }
+
+  public ClientProcessInstance startProcessInstance(String key) {
+    ClientProcessInstance processInstance = createProcessInstance(key, null);
+    processInstance.start();
+    return processInstance;
+  }
+
+  protected ExecutionImpl newProcessInstance() {
+    return new ExecutionImpl();
+  }
+
+  /** by default, during initialization, an id will be generated when 
+   * an IdGenerator is present in the environment.  By default,   
+   * this makes the execution persistent.  So in case the process definition 
+   * is not persistent and there is an environment present (like in the case 
+   * of task lifecycle for jpdl processes), this method needs to be overwritten. */
+  public IdGenerator getIdGenerator() {
+    return Environment.getFromCurrent(IdGenerator.class, false);
+  }
+
+  // attachments //////////////////////////////////////////////////////////////
+  
+  public void addAttachment(String name, InputStream inputStream) {
+    byte[] bytes = IoUtil.readBytes(inputStream);
+    addAttachment(name, bytes);
+  }
+  
+  public void addAttachment(String name, byte[] bytes) {
+    Lob lob = new Lob(bytes);
+    if (attachments==null) {
+      attachments = new HashMap<String, Lob>();
+    }
+    attachments.put(name, lob);
+  }
+
+  public byte[] getAttachment(String name) {
+    if (attachments==null) {
+      return null;
+    }
+    Lob lob = attachments.get(name);
+    if (lob==null) {
+      return null;
+    }
+    return lob.extractBytes();
+  }
+
+  public InputStream getAttachmentInputStream(String name) {
+    byte[] bytes = getAttachment(name);
+    if (bytes==null) {
+      return null;
+    }
+    return new ByteArrayInputStream(bytes);
+  }
+
+  // basic methods ////////////////////////////////////////////////////////////
+
+  public String toString() {
+    return (name!=null ? "process("+name+")" : "process");
+  }
+  
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public ActivityImpl getInitial() {
+    return initial;
+  }
+  public void setInitial(ActivityImpl initial) {
+    this.initial = initial;
+  }
+  public int getVersion() {
+    return version;
+  }
+  public void setVersion(int version) {
+    this.version = version;
+  }
+  public Date getDeploymentTime() {
+    return deploymentTime;
+  }
+  public void setDeploymentTime(Date deploymentTime) {
+    this.deploymentTime = deploymentTime;
+  }
+  public String getPackageName() {
+    return packageName;
+  }
+  public void setPackageName(String packageName) {
+    this.packageName = packageName;
+  }
+  public String getKey() {
+    return key;
+  }
+  public void setKey(String key) {
+    this.key = key;
+  }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessElementImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/** 
+ * superclass for {@link ActivityImpl}, {@link TransitionImpl} and {@link ProcessDefinitionImpl}.
+ * 
+ * @author Tom Baeyens
+ */
+ 
+public class ProcessElementImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ProcessElementImpl.class.getName());
+
+  protected long dbid;
+  protected int dbversion;
+  protected ProcessDefinitionImpl processDefinition;
+  protected List<ExceptionHandlerImpl> exceptionHandlers;
+  protected WireProperties properties;
+
+  // exception handlers ///////////////////////////////////////////////////////
+
+  public ExceptionHandlerImpl createExceptionHandler() {
+    ExceptionHandlerImpl exceptionHandler = new ExceptionHandlerImpl();
+    addExceptionHandler(exceptionHandler);
+    return exceptionHandler;
+  }
+
+  public void addExceptionHandler(ExceptionHandlerImpl exceptionHandler) {
+    if (exceptionHandlers==null) {
+      exceptionHandlers = new ArrayList<ExceptionHandlerImpl>();
+    }
+    exceptionHandlers.add(exceptionHandler);
+  }
+  
+  // properties ///////////////////////////////////////////////////////////////
+
+  public void addProperty(Descriptor descriptor) {
+    if (properties==null) {
+      properties = new WireProperties();
+    }
+    properties.add(descriptor);
+  }
+
+  public Object getProperty(String key) {
+    if (properties==null) {
+      return null;
+    }
+    return properties.get(key);
+  }
+
+  public Set<String> getPropertyKeys() {
+    if (properties==null) {
+      return Collections.EMPTY_SET;
+    }
+    return properties.keys();
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  /** the database id. */
+  public long getDbid() {
+    return dbid;
+  }
+  public ProcessDefinitionImpl getProcessDefinition() {
+    return processDefinition;
+  }
+  public void setProcessDefinition(ProcessDefinitionImpl processDefinition) {
+    this.processDefinition = processDefinition;
+  }
+  public WireProperties getProperties() {
+    return properties;
+  }
+  public void setProperties(WireProperties properties) {
+    this.properties = properties;
+  }
+  public List<ExceptionHandlerImpl> getExceptionHandlers() {
+    return exceptionHandlers;
+  }
+  public void setExceptionHandlers(List<ExceptionHandlerImpl> exceptionHandlers) {
+    this.exceptionHandlers = exceptionHandlers;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.hibernate.Session;
+import org.jbpm.ExecutionService;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceEndedSynchronization implements Synchronization, Command<Void> {
+  
+  private static final long serialVersionUID = 1L;
+
+  String processInstanceId;
+  CommandService commandService;
+
+  public ProcessInstanceEndedSynchronization(String processInstanceId, CommandService commandService) {
+    this.processInstanceId = processInstanceId;
+    this.commandService = commandService;
+  }
+
+  public void afterCompletion(int status) {
+    if (status==Status.STATUS_COMMITTED) {
+      commandService.execute(this);
+    }
+  }
+
+  public void beforeCompletion() {
+  }
+
+  public Void execute(Environment environment) {
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    pvmDbSession.deleteProcessInstance(processInstanceId, false);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessModificationsImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessModificationsImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessModificationsImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jbpm.model.Activity;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessModificationsImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long dbid;
+  protected int version;
+  
+  // TODO: as an optimisation, boolean flag properties could be added 
+  // as persistent memberfields to indicate if the collections are 
+  // empty or not.  That way, when a process modification object 
+  // is consulted, before accessing any of the collections it can 
+  // first check if the collections are empty, hence preventing a 
+  // database query for the empty collections.
+  
+  // Removed items just can be referenced in the process definition
+
+  // Adding is harder.  Full information of added items cannot be stored 
+  // in the process 
+  // definition database part as those tables will be cached and 
+  // marked with read-only.  So the added items must be stored in 
+  // the runtime (=execution) part of the database schema.
+  // That is why subclasses of the real process definition classes 
+  // are created.
+
+  protected List<AddedAction> addedActions;
+  protected List<EventListenerReference> removedActions;
+  protected List<AddedTransition> addedTransitions;
+  protected List<TransitionImpl> removedTransitions;
+  protected List<AddedActivity> addedActivities;
+  protected List<ActivityImpl> removedActivities;
+  
+  // TODO : convert to top level types
+  
+  public static class AddedAction extends EventListenerReference {
+    private static final long serialVersionUID = 1L;
+    EventImpl event;
+  }
+  
+  public static class AddedTransition extends TransitionImpl {
+    private static final long serialVersionUID = 1L;
+    
+  }
+  
+  public static class AddedActivity extends ActivityImpl {
+    private static final long serialVersionUID = 1L;
+  }
+  
+  // next this class would implement methods to merge the 
+  // modifications with the process definition information.
+  
+  // the ExecutionImpl would have to do lookups in 
+  // the process definition model conscientious through 
+  // these merging methods
+  
+  public TransitionImpl getOutgoingTransition(ActivityImpl activity, String transitionName) {
+    // first check if the requested transition is in the added transition list
+    if (addedTransitions!=null) {
+      for (AddedTransition addedTransition : addedTransitions) {
+        if ( activity.equals(addedTransition.getSource())
+             && addedTransition.getName()!=null
+             && addedTransition.getName().equals(transitionName)
+           ) {
+          return addedTransition;
+        }
+      }
+    }
+    
+    // now, check if it is in the normal transition list in the process definition
+    TransitionImpl transition = activity.getOutgoingTransition(transitionName);
+    
+    if ( (transition!=null) // if the transition exists
+         && (removedTransitions!=null) // and if there are removed transitions
+         && (removedTransitions.contains(transition)) // and if the transition found in the process definition is present in the removedTransitions collection
+       ) {
+      // then pretent it wasn't there :-)
+      return null;
+    }
+    
+    return transition;
+  }
+
+  // furhermore, action, activity and transition creation methods 
+  // will have to be exposed through the user interface classes.
+  // We have to make sure that the user is able to access and find 
+  // all the input parameters for these creation methods from the 
+  // org.jbpm.pvm classes, without ever needing org.jbpm.pvm.internal.model 
+  // classes.
+  // for example:
+  
+  public void addTransition(Activity source, String name, Activity destination) {
+    // TODO
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeElementImpl extends ObservableElementImpl {
+
+  private static final long serialVersionUID = 1L;
+
+  protected boolean hasVariableDefinitions; 
+  protected List<VariableDefinitionImpl> variableDefinitions;
+  protected boolean hasTimerDefinitions; 
+  protected Set<TimerDefinitionImpl> timerDefinitions;
+
+  // variable definitions /////////////////////////////////////////////////////
+  
+  public List<VariableDefinitionImpl> getVariableDefinitions() {
+    if (!hasVariableDefinitions) {
+      return Collections.EMPTY_LIST;
+    }
+    return (List) variableDefinitions;
+  }
+
+  public VariableDefinitionImpl createVariableDefinition() {
+    VariableDefinitionImpl variableDefinition = new VariableDefinitionImpl();
+    if (variableDefinitions==null) {
+      variableDefinitions = new ArrayList<VariableDefinitionImpl>();
+    }
+    variableDefinitions.add(variableDefinition);
+    hasVariableDefinitions = true;
+    return variableDefinition;
+  }
+
+  // timer definitions ////////////////////////////////////////////////////////
+  
+  public Set<TimerDefinitionImpl> getTimerDefinitions() {
+    if (!hasTimerDefinitions) {
+      return Collections.EMPTY_SET;
+    }
+    return timerDefinitions;
+  }
+  
+  public TimerDefinitionImpl createTimerDefinition() {
+    TimerDefinitionImpl timerDefinition = new TimerDefinitionImpl();
+    if (timerDefinitions==null) {
+      timerDefinitions = new HashSet<TimerDefinitionImpl>();
+    }
+    timerDefinitions.add(timerDefinition);
+    hasTimerDefinitions = true;
+    return timerDefinition;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,464 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.job.Timer;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Type;
+import org.jbpm.pvm.internal.type.TypeSet;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.pvm.internal.type.variable.NullVariable;
+import org.jbpm.pvm.internal.type.variable.UnpersistableVariable;
+import org.jbpm.session.TimerSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeInstanceImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(ScopeInstanceImpl.class.getName());
+  
+  protected long dbid;
+  protected int dbversion;
+
+  protected boolean hasVariables;
+  protected Map<String, Variable> variables;
+  protected boolean hasTimers;
+  protected Set<TimerImpl> timers;
+  
+  protected String state;
+  
+  // variables ////////////////////////////////////////////////////////////////
+
+  protected void initializeVariables(ScopeElementImpl scope, ExecutionImpl outerExecution) {
+    // loop over all variable definitions
+    List<VariableDefinitionImpl> variableDefinitions = scope.getVariableDefinitions();
+    if (!variableDefinitions.isEmpty()){
+      if (log.isTraceEnabled()) {
+        log.trace("initializing variables in scope "+scope);
+      }
+      variables = new HashMap<String, Variable>();
+      for (VariableDefinitionImpl variableDefinition: variableDefinitions) {
+        String key = variableDefinition.getName();
+        Object value = variableDefinition.getInValue(outerExecution);
+        String typeName = variableDefinition.getTypeName();
+        createVariable(key, value, typeName);
+      }
+    }
+  }
+
+  protected void destroyVariables(ScopeElementImpl scope, ExecutionImpl outerExecution) {
+    // loop over all variable definitions
+    List<VariableDefinitionImpl> variableDefinitions = scope.getVariableDefinitions();
+    if (variableDefinitions!=null) {
+      if (log.isTraceEnabled()) {
+        log.trace("destroying var scope "+scope);
+      }
+      
+      for (VariableDefinitionImpl variableDefinition: variableDefinitions) {
+        String destination = variableDefinition.getOutVariableName();
+        if (destination!=null) {
+          String key = variableDefinition.getName();
+          Object value = variableDefinition.getOutValue(this);
+          outerExecution.setVariable(key, value);
+        }
+      }
+    }
+  }
+  
+
+  public void createVariable(String key, Object value) {
+    createVariable(key, value, null);
+  }
+
+  public void createVariable(String key, Object value, String typeName) {
+    if (isEnded()) {
+      throw new JbpmException("can't create variable '"+key+"' on "+this+": "+state);
+    }
+
+    log.debug("create variable '"+key+"' in '"+this+"' with value '"+value+"'");
+    
+    Type type = null;
+    
+    if (type==null) {
+      TypeSet typeSet = Environment.getFromCurrent(TypeSet.class, false);
+      if (typeSet!=null) {
+        if (typeName!=null) {
+          type = typeSet.findTypeByName(typeName);
+        }
+        if (type==null) {
+          type = typeSet.findTypeByMatch(key, value);
+        }
+      }
+    }
+    
+    Variable variable = null;
+
+    if (type!=null) {
+      Class<?> variableClass = type.getVariableClass();
+      try {
+        log.trace("creating new "+type+" variable "+key);
+        variable = (Variable) variableClass.newInstance();
+      } catch (Exception e) {
+        throw new JbpmException("couldn't instantiate variable instance class '"+variableClass.getName()+"'");
+      }
+      Converter converter = type.getConverter();
+      variable.setConverter(converter);
+
+    } else {
+      if (value==null) {
+        log.trace("creating null variable for "+key);
+        variable = new NullVariable();
+      } else {
+        log.trace("creating new unpersistable variable for "+key);
+        variable = new UnpersistableVariable();
+      }
+    }
+
+    variable.setKey(key);
+    variable.setValue(value);
+    variable.setProcessInstance(getProcessInstance());
+    
+    if (variables==null) {
+      variables = new HashMap<String, Variable>();
+    }
+    variables.put(variable.getKey(), variable);
+    hasVariables = true;
+
+    // TODO add create-variable-log
+  }
+
+  public void setVariable(String key, Object value) {
+    if (isEnded()) {
+      throw new JbpmException("can't update variable '"+key+"' on "+this+": "+state);
+    }
+    Variable variable = getVariableObject(key);
+    // if there is already a variable instance and it doesn't support the current type...
+    if ( (variable!=null) 
+         && (!variable.supports(value))
+       ) {
+      // delete the old variable instance
+      log.debug("variable type change. deleting '"+key+"' from '"+this+"'");
+      removeVariable(key);
+      variable = null;
+    }
+
+    if (variable!=null) {
+      log.debug("updating variable '"+key+"' in '"+this+"' to value '"+value+"'");
+      variable.setValue(value);
+
+    } else if (getParentVariableScope()==null) {
+      createVariable(key, value, null);
+
+    } else {
+      getParentVariableScope().setVariable(key,value);
+    }
+  }
+  
+  public void setVariables(Map<String, Object> variables) {
+    if (variables!=null) {
+      for (String key: variables.keySet()) {
+        Object value = variables.get(key);
+        setVariable(key, value);
+       }
+    }
+  }
+  
+  public Object getVariable(String key) {
+    Object value = null;
+
+    Variable variable = getVariableObject(key);
+    if (variable!=null) {
+      return variable.getValue();
+    }
+    
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    if (parentScope!=null) {
+      return parentScope.getVariable(key);
+    }
+
+    return null;
+  }
+
+  public Variable getVariableObject(String key) {
+    return (hasVariables ? (Variable) variables.get(key) : null);
+  }
+
+  public boolean hasVariable(String key) {
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    return ( (hasVariables && variables.containsKey(key))
+             || (parentScope!=null && parentScope.hasVariable(key))
+           );
+  }
+
+  public Set<String> getVariableKeys() {
+    Set<String> variableKeys = null;
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    if (parentScope!=null) {
+      variableKeys = parentScope.getVariableKeys();
+    } else {
+      variableKeys = new TreeSet<String>();
+    }
+    if (hasVariables) {
+      variableKeys.addAll(variables.keySet());
+    }
+    return variableKeys;
+  }
+
+  public Map<String, Object> getVariables() {
+    Map<String, Object> values = null;
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    if (parentScope!=null) {
+      values = parentScope.getVariables();
+    } else {
+      values = new TreeMap<String, Object>();
+    }
+    if (hasVariables) {
+      for (Map.Entry<String, Variable> entry: variables.entrySet()) {
+        String name = (String) entry.getKey();
+        Variable variable = entry.getValue();
+        Object value = variable.getValue();
+        values.put(name, value);
+      }
+    }
+    return values;
+  }
+  
+  public boolean hasVariables() {
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    return ( hasVariables
+             || (parentScope!=null && parentScope.hasVariables())
+           );
+  }
+
+  public boolean removeVariable(String key) {
+    if (isEnded()) {
+      throw new JbpmException("can't remove variable '"+key+"' on "+this+": "+state);
+    }
+
+    Variable variable = null;
+    if (hasVariables) {
+      variable = variables.remove(key);
+      if (variables.isEmpty()) {
+        hasVariables = false;
+      }
+      if (variable!=null) {
+        return true;
+      }
+    }
+    ScopeInstanceImpl parentScope = getParentVariableScope();
+    if (parentScope!=null) {
+      return parentScope.removeVariable(key);
+    }
+    // the actual value is not returned to prevent that an object 
+    // has to be fetched from the db for it to be deleted
+    return false;
+  }
+
+  public void removeVariables() {
+    if (hasVariables) {
+      variables.clear();
+    }
+    hasVariables = false;
+  }
+
+  // timers ///////////////////////////////////////////////////////////////////
+
+  protected void initializeTimers(ScopeElementImpl scope) {
+    // initialize the timers
+    Set<TimerDefinitionImpl> timerDefinitions = scope.getTimerDefinitions();
+    if (!timerDefinitions.isEmpty()) {
+      timers = new HashSet<TimerImpl>();
+      for (TimerDefinitionImpl timerDefinition: timerDefinitions) {
+        createTimer(
+            timerDefinition.getEventName(),
+            timerDefinition.getSignalName(),
+            timerDefinition.getDueDateDescription(),
+            timerDefinition.getDueDate(),
+            timerDefinition.getRepeat(),
+            timerDefinition.isExclusive(),
+            timerDefinition.getRetries()
+        );
+      }
+    }
+  }
+
+  protected void destroyTimers(CompositeElementImpl scope) {
+    log.debug("destroying timers of "+toString());
+    if (hasTimers && timers!=null && !timers.isEmpty()) {
+      // get the TimerSession from the environment
+      Environment environment = Environment.getCurrent();
+      if (environment==null) {
+        throw new JbpmException("non environment for initializing timers");
+      }
+      TimerSession timerSession = environment.get(TimerSession.class);
+      if (timerSession==null) {
+        throw new JbpmException("no TimerSession in environment for initializing timers");
+      }
+      for (Timer timer : timers) {
+        timerSession.cancel(timer);
+      }
+      timers.clear();
+      hasTimers = false;
+    }
+  }
+
+  public void createTimer(String eventName, String signalName, String dueDateDescription) {
+    createTimer(eventName, signalName, dueDateDescription, null, null, null, null);
+  }
+
+  public void createTimer(String eventName, String signalName, String dueDateDescription, String repeat) {
+    createTimer(eventName, signalName, dueDateDescription, null, repeat, null, null);
+  }
+
+  public void createTimer(String eventName, String signalName, String dueDateDescription, Date dueDate, String repeat, Boolean isExclusive, Integer retries) {
+    if ( (eventName==null)
+         && (signalName==null)
+       ) {
+      throw new JbpmException("no event or signal specified");
+    }
+    if (log.isDebugEnabled()) {
+      log.debug("creating timer on "+this.toString());
+    }
+    
+    // instantiate the timer
+    TimerImpl timer = instantiateTimer();
+    // create the bidirectional reference
+    timer.setExecution(getTimerExecution());
+    timers.add(timer);
+    hasTimers = true;
+    // setInverseReference(timerImpl);
+    
+    // initialise all the timer properties
+    timer.setEventName(eventName);
+    timer.setSignalName(signalName);
+    if (dueDate!=null) {
+      timer.setDueDate(dueDate);
+    } else {
+      timer.setDueDateDescription(dueDateDescription);
+    }
+    
+    // the if is added to keep the original default
+    if (isExclusive!=null) {
+      timer.setExclusive(isExclusive);
+    }
+    
+    // the if is added to keep the original default
+    if (retries!=null) {
+      timer.setRetries(retries);
+    }
+
+    // the if is added to keep the original default
+    if (repeat!=null) {
+      timer.setRepeat(repeat);
+    }
+
+    // get the TimerSession from the environment
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new JbpmException("non environment for initializing timers");
+    }
+    TimerSession timerSession = environment.get(TimerSession.class);
+    if (timerSession==null) {
+      throw new JbpmException("no TimerSession in environment for initializing timers");
+    }
+    
+    // schedule the timer with the TimerSession
+    timerSession.schedule(timer);
+  }
+
+  public boolean hasTimers() {
+    return hasTimers;
+  }
+
+  public Set<Timer> getTimers() {
+    return (Set) timers;
+  }
+  
+  protected TimerImpl instantiateTimer() {
+    return new TimerImpl();
+  }
+  
+  // state ////////////////////////////////////////////////////////////////////
+
+  /** @see Execution#getState() */
+  public String getState() {
+    return state;
+  }
+
+  /** @see Execution#isActive() */
+  public boolean isActive() {
+    return Execution.STATE_ACTIVE.equals(state);
+  }
+
+  /** @see Execution#isLocked() */
+  public boolean isLocked() {
+    return ! isActive();
+  }
+  
+  /** @see Execution#isSuspended() */
+  public boolean isSuspended() {
+    return Execution.STATE_SUSPENDED.equals(state);
+  }
+
+  /** @see Execution#isEnded() */
+  public boolean isEnded() {
+    return Execution.STATE_ENDED.equals(state);
+  }
+
+  // customizable methods /////////////////////////////////////////////////////
+  
+  public ExecutionImpl getProcessInstance() {
+    return null;
+  }
+
+  public ExecutionImpl getTimerExecution() {
+    return null;
+  }
+
+  public ScopeInstanceImpl getParentVariableScope() {
+    return null;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Pascal Verdage
+ */
+public class TimerDefinitionImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String dueDateDescription;
+  protected String repeat;
+  protected Boolean isExclusive;
+  protected Integer retries;
+  protected String eventName;
+  protected String signalName;
+  protected Date dueDate;
+
+  public TimerDefinitionImpl() {
+  }
+
+  public String getRepeat() {
+    return repeat;
+  }
+  public void setRepeat(String repeat) {
+    this.repeat = repeat;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+  public String getDueDateDescription() {
+    return dueDateDescription;
+  }
+  public void setDueDateDescription(String dueDateDescription) {
+    this.dueDateDescription = dueDateDescription;
+  }
+  public Boolean isExclusive() {
+    return isExclusive;
+  }
+  public void setExclusive(Boolean isExclusive) {
+    this.isExclusive = isExclusive;
+  }
+  public Integer getRetries() {
+    return retries;
+  }
+  public void setRetries(Integer retries) {
+    this.retries = retries;
+  }
+  public String getSignalName() {
+    return signalName;
+  }
+  public void setSignalName(String signalName) {
+    this.signalName = signalName;
+  }
+  public String getEventName() {
+    return eventName;
+  }
+  public void setEventName(String eventName) {
+    this.eventName = eventName;
+  }
+  public Date getDueDate() {
+    return dueDate;
+  }
+  public void setDueDate(Date dueDate) {
+    this.dueDate = dueDate;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.util.List;
+
+import org.jbpm.model.Condition;
+import org.jbpm.model.Event;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/** 
+ * @author Tom Baeyens
+ */ 
+public class TransitionImpl extends ObservableElementImpl implements Transition {
+
+  private static final long serialVersionUID = 1L;
+
+  protected ActivityImpl source;
+  protected ActivityImpl destination;
+  protected Descriptor conditionDescriptor;
+  protected Descriptor waitConditionDescriptor;
+  protected boolean isTakeAsync;
+  
+  /* Use one of the ActivityImpl.createOutgoingTransition methods instead. */
+  TransitionImpl() {
+    super();
+  }
+  
+  public void makeDefault() {
+    source.setDefaultTransition(this);
+  }
+  
+  public String toString() {
+    String destinationName = (destination!=null ? destination.getName() : null);
+    String sourceName = (source!=null ? source.getName() : null);
+    return (sourceName!=null ? "("+sourceName+")--" : "--") +
+           (name!=null ? name+"-->" : ">") +
+           (destinationName!=null ? "("+destinationName+")" : "");
+  }
+  
+  public EventImpl createEvent() {
+    EventImpl event = new EventImpl();
+    event.setName(Event.TAKE);
+    addEvent(event);
+    return event;
+  }
+
+  public EventImpl getEvent() {
+    return getEvent(Event.TAKE);
+  }
+  
+  // get parent ///////////////////////////////////////////////////////////////
+  
+  /** the first common parent between the source and the destination activity. The 
+   * source and destination itself are included in the search except if 
+   * source and destination are equal.  In that case (self-transition), then 
+   * it's the parent of the activity. */
+  public ObservableElementImpl getParent() {
+    // if one of the two ends is null
+    if ( (source==null)
+         || (destination==null) 
+       ) {
+      // the process definition is returned
+      return processDefinition;
+    }
+    // if this is a self transition
+    if (source.equals(destination)) {
+      // the parent of the activity is returned
+      return source.getParent();
+    }
+    // if none of the above, we search for the first common element in the parent chains 
+    List<ObservableElementImpl> sourceChain = source.getParentChain();
+    List<ObservableElementImpl> destinationChain = destination.getParentChain();
+    for (ObservableElementImpl sourceElement : sourceChain) {
+      for (ObservableElementImpl destinationElement : destinationChain) {
+        if (sourceElement.equals(destinationElement)) {
+          return sourceElement;
+        }
+      }
+    }
+    return null;
+  }
+
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public void setName(String name) {
+    // if there is no source activity associated with this transition
+    if (source==null) {
+      // it s just a setter
+      this.name = name;
+
+    } else { // otherwise
+      // make sure the source activity's leavingTransitionsMap remains up to date
+      if (this.name!=null) {
+        source.removeOutgoingTransition(this);
+      }
+      this.name = name;
+      if (name!=null) {
+        source.addOutgoingTransition(this);
+      }
+    }
+  }
+  
+  public Condition getCondition() {
+    if (conditionDescriptor==null) {
+      return null;
+    }
+    return (Condition) WireContext.create(conditionDescriptor);
+  }
+
+  public Condition getWaitCondition() {
+    if (waitConditionDescriptor==null) {
+      return null;
+    }
+    return (Condition) WireContext.create(waitConditionDescriptor);
+  }
+
+  public ActivityImpl getSource() {
+    return source;
+  }
+  public void setSource(ActivityImpl source) {
+    this.source = source;
+  }
+  public ActivityImpl getDestination() {
+    return destination;
+  }
+  public void setDestination(ActivityImpl destination) {
+    this.destination = destination;
+  }
+  /** see <a href="#conditions">Conditions</a> */
+  public Descriptor getConditionDescriptor() {
+    return conditionDescriptor;
+  }
+  /** see <a href="#conditions">Conditions</a> */
+  public void setConditionDescriptor(Descriptor conditionDescriptor) {
+    this.conditionDescriptor = conditionDescriptor;
+  }
+  /** see <a href="#waitconditions">Wait conditions</a> */
+  public Descriptor getWaitConditionDescriptor() {
+    return waitConditionDescriptor;
+  }
+  /** see <a href="#waitconditions">Wait conditions</a> */
+  public void setWaitConditionDescriptor(Descriptor waitConditionDescriptor) {
+    this.waitConditionDescriptor = waitConditionDescriptor;
+  }
+  public boolean isTakeAsync() {
+    return isTakeAsync;
+  }
+  public void setTakeAsync(boolean isTakeAsync) {
+    this.isTakeAsync = isTakeAsync;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/** a declaration of a variable.
+ * 
+ * The source properties denote how the variable gets initialized upon creation.
+ * 
+ * The destination properties indicate how information from the current scope
+ * gets propagated back into the outer scope.
+ * 
+ * @author Tom Baeyens
+ */
+public class VariableDefinitionImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+
+  protected String name;
+  protected String typeName;
+
+  protected String inVariableName;
+  protected String inExpression;
+  protected Descriptor inDescriptor;
+
+  protected String outVariableName;
+  protected String outExpression;
+
+  public Object getInValue(ExecutionImpl execution) {
+    if (inDescriptor!=null) {
+      return WireContext.create(inDescriptor);
+    }
+    if (inVariableName!=null) {
+      return execution.getVariable(name);
+    }
+    if (inExpression!=null) {
+      throw new UnsupportedOperationException("TODO add variable in expression resolution");
+    }
+    return null;
+  }
+
+  public Object getOutValue(ScopeInstanceImpl scopeInstanceImpl) {
+    if (outExpression!=null) {
+      throw new UnsupportedOperationException("TODO add variable out expression resolution");
+    }
+    if (name!=null) {
+      return scopeInstanceImpl.getVariable(name);
+    }
+    return null;
+  }
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getInVariableName() {
+    return inVariableName;
+  }
+  public void setInVariableName(String inVariableName) {
+    this.inVariableName = inVariableName;
+  }
+  public String getInExpression() {
+    return inExpression;
+  }
+  public void setInExpression(String inExpression) {
+    this.inExpression = inExpression;
+  }
+  public Descriptor getInDescriptor() {
+    return inDescriptor;
+  }
+  public void setInDescriptor(Descriptor inDescriptor) {
+    this.inDescriptor = inDescriptor;
+  }
+  public String getOutVariableName() {
+    return outVariableName;
+  }
+  public void setOutVariableName(String outVariableName) {
+    this.outVariableName = outVariableName;
+  }
+  public String getOutExpression() {
+    return outExpression;
+  }
+  public void setOutExpression(String outExpression) {
+    this.outExpression = outExpression;
+  }
+  public String getTypeName() {
+    return typeName;
+  }
+  public void setTypeName(String typeName) {
+    this.typeName = typeName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/WireProperties.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WireProperties implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected WireContext wireContext;
+
+  public Object get(String key) {
+    if (wireContext==null) {
+      return null;
+    }
+    return wireContext.get(key);
+  }
+
+  public Set<String> keys() {
+    if (wireContext==null) {
+      return Collections.EMPTY_SET;
+    }
+    return wireContext.keys();
+  }
+  
+  public void add(Descriptor descriptor) {
+    if (wireContext==null) {
+      wireContext = new WireContext(new WireDefinition());
+    }
+    wireContext.getWireDefinition().addDescriptor(descriptor);
+  }
+
+  public WireContext getWireContext() {
+    return wireContext;
+  }
+  public void setWireContext(WireContext wireContext) {
+    this.wireContext = wireContext;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AtomicOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface AtomicOperation {
+  
+  boolean isAsync(ExecutionImpl execution);
+  MessageImpl<?> createAsyncMessage(ExecutionImpl execution);
+
+  void perform(ExecutionImpl execution);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl.Propagation;
+import org.jbpm.pvm.internal.util.Clock;
+
+public class ExecuteActivity implements AtomicOperation {
+  
+  private static Log log = Log.getLog(ExecuteActivity.class.getName());
+  
+  public boolean isAsync(ExecutionImpl execution) {
+    return execution.getActivity().isExecutionAsync();
+  }
+
+  public void perform(ExecutionImpl execution) {
+    ActivityImpl activity = execution.getActivity();
+    
+    if (log.isTraceEnabled()) {
+      if (execution.getName()!=null) {
+        log.trace(execution.toString()+" executes "+activity);
+      } else {
+        log.trace("executing "+activity);
+      }
+    }
+    
+    ActivityBehaviour activityBehaviour = activity.getBehaviour();
+    
+    try {
+      execution.setPropagation(Propagation.UNSPECIFIED);
+      execution.setHistoryActivityStart(Clock.getCurrentTime());
+
+      activityBehaviour.execute(execution);
+      
+    } catch (Exception e) {
+      execution.handleException(activity, null, null, e, execution.toString()+" couldn't execute "+activityBehaviour+" for activity "+activity);
+    }
+    
+    if (execution.getPropagation()==Propagation.UNSPECIFIED) {
+      execution.proceed();
+    }
+  }
+
+  public String toString() {
+    return "execute(activity)";
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return new ExecuteActivityMessage(execution);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecuteActivityMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public ExecuteActivityMessage() {
+  }
+
+  public ExecuteActivityMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    unlockExecution();
+    execution.performAtomicOperationSync(ExecutionImpl.EXECUTE_ACTIVITY);
+
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+
+  public String toString() {
+    return "execute-activity-message["+dbid+"]";
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToChildActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MoveToChildActivity implements AtomicOperation {
+  
+  ActivityImpl activity;
+
+  public MoveToChildActivity(ActivityImpl activity) {
+    this.activity = activity;
+  }
+
+  public void perform(ExecutionImpl execution) {
+    execution.moveTo(activity);
+    ExecutionImpl propagatingExecution = execution.startActivity(activity);
+    propagatingExecution.performAtomicOperation(ExecutionImpl.EXECUTE_ACTIVITY);
+  }
+
+  public boolean isAsync(ExecutionImpl execution) {
+    return false;
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/MoveToParentActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class MoveToParentActivity implements AtomicOperation {
+
+  public void perform(ExecutionImpl execution) {
+    ActivityImpl activity = execution.getActivity();
+    ActivityImpl parentActivity = activity.getParentActivity();
+    ExecutionImpl propagatingExecution = execution.endActivity(activity);
+    
+    // Restore original source activity 
+    // (so that the call to moveTo updates the previous activity) 
+    propagatingExecution.setActivity(activity);
+    propagatingExecution.moveTo(parentActivity);
+    propagatingExecution.performAtomicOperation(new Signal(null, null, parentActivity));
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return null;
+  }
+
+  public boolean isAsync(ExecutionImpl execution) {
+    return false;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProceedToDestination implements AtomicOperation {
+  
+  public boolean isAsync(ExecutionImpl execution) {
+    return false;
+  }
+
+  public void perform(ExecutionImpl execution) {
+    ActivityImpl destination = execution.getTransition().getDestination();
+    execution.setActivity(destination);
+    List<ActivityImpl> enteredActivities = getActivitiesEntered(execution.getTransitionOrigin(), destination);
+    
+    ExecutionImpl propagatingExecution = execution;
+    for (ActivityImpl enteredActivity : enteredActivities) {
+      propagatingExecution = propagatingExecution.startActivity(enteredActivity);
+    }
+    
+    // Restore original transition source activity 
+    // (so that the call to moveTo updates the previous activity) 
+    propagatingExecution.setActivity(execution.getTransitionOrigin());
+    propagatingExecution.moveTo(destination);
+    
+    propagatingExecution.performAtomicOperation(ExecutionImpl.EXECUTE_ACTIVITY);
+  }
+  
+  public List<ActivityImpl> getActivitiesEntered(ActivityImpl origin, ActivityImpl destination) {
+    LinkedList<ActivityImpl> activitiesEntered = new LinkedList<ActivityImpl>();
+    
+    if (origin.equals(destination)) {
+      activitiesEntered.add(destination);
+      
+    } else {
+      List<ObservableElementImpl> sourceChain = origin.getParentChain();
+      
+      if (!sourceChain.contains(destination)) {
+        ActivityImpl destinationActivity = destination;
+        while ( (destinationActivity!=null)
+                && (!sourceChain.contains(destinationActivity))
+              ) {
+          activitiesEntered.addFirst(destinationActivity);
+          destinationActivity = destinationActivity.getParentActivity(); 
+        }
+      }
+    }
+
+    return activitiesEntered;
+  }
+
+  
+  public String toString() {
+    return "proceed-to-destination";
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return new ProceedToDestinationMessage(execution);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProceedToDestinationMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public ProceedToDestinationMessage() {
+    super();
+  }
+
+  public ProceedToDestinationMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    unlockExecution();
+    execution.performAtomicOperationSync(ExecutionImpl.PROCEED_TO_DESTINATION);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+  
+  public String toString() {
+    return "proceed-to-destination-message["+dbid+"]";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl.Propagation;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Signal implements AtomicOperation {
+
+  private static final Log log = Log.getLog(Signal.class.getName());
+
+  String signalName;
+  Map<String, Object> parameters;
+  ActivityImpl activity;
+
+  public Signal(String signalName, Map<String, Object> parameters, ActivityImpl activity) {
+    this.signalName = signalName;
+    this.parameters = parameters;
+    this.activity = activity;
+  }
+
+  public boolean isAsync(ExecutionImpl execution) {
+    return execution.getActivity().isSignalAsync();
+  }
+
+  public void perform(ExecutionImpl execution) {
+    if (execution.getName()!=null) {
+      log.debug(execution.toString()+" signals "+activity);
+    } else {
+      log.debug("signalling "+activity+", signal="+signalName);
+    }
+
+    ExternalActivityBehaviour externalActivityBehaviour = (ExternalActivityBehaviour) activity.getBehaviour();
+    
+    try {
+      execution.setPropagation(Propagation.UNSPECIFIED);
+      externalActivityBehaviour.signal(execution, signalName, parameters);
+
+    } catch (RuntimeException e) {
+      throw e;
+      
+    } catch (Exception e) {
+      throw new JbpmException("couldn't signal "+activity+": "+e.getMessage(), e);
+    }
+
+    if (execution.getPropagation() == Propagation.UNSPECIFIED) {
+      execution.proceed();
+    }
+  }
+  
+  public String toString() {
+    return "signal(activity)";
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return new SignalMessage(execution, signalName, activity);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalMessage extends MessageImpl<Object> {
+  
+  private static final long serialVersionUID = 1L;
+  
+  String signalName;
+  ActivityImpl activity;
+
+  public SignalMessage() {
+  }
+
+  public SignalMessage(ExecutionImpl execution, String signalName, ActivityImpl activity) {
+    super(execution);
+    this.signalName = signalName;
+    this.activity = activity;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    unlockExecution();
+    
+    Signal signal = new Signal(signalName, null, activity);
+    execution.performAtomicOperationSync(signal);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+
+  public String toString() {
+    return "signal-transition-message["+dbid+"]";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.Condition;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+public class TakeTransition implements AtomicOperation {
+
+  private static Log log = Log.getLog(TakeTransition.class.getName());
+  
+  public boolean isAsync(ExecutionImpl execution) {
+    return execution.getActivity().isLeaveAsync()
+           || execution.getTransition().isTakeAsync();
+  }
+
+  public void perform(ExecutionImpl execution) {
+    TransitionImpl transition = execution.getTransition();
+
+    if (execution.getName()!=null) {
+      log.debug(execution.toString()+" takes "+transition);
+    } else {
+      log.debug("taking "+transition);
+    }
+    
+    List<ActivityImpl> leftActivities = getActivitiesLeft(execution.getActivity(), transition.getDestination());
+    ExecutionImpl propagatingExecution = execution;
+    for (ActivityImpl leftActivity : leftActivities) {
+      propagatingExecution = propagatingExecution.endActivity(leftActivity);
+    }
+    
+    propagatingExecution.setActivity(null);
+    propagatingExecution.fire(Event.TAKE, transition);
+    
+    boolean wait = false;
+    
+    Condition waitCondition = transition.getWaitCondition();
+    if (waitCondition!=null) {
+      wait = waitCondition.evaluate(propagatingExecution);
+    }
+    
+    if (!wait) {
+      propagatingExecution.performAtomicOperation(ExecutionImpl.PROCEED_TO_DESTINATION);
+    }
+  }
+
+  List<ActivityImpl> getActivitiesLeft(ActivityImpl source, ActivityImpl destination) {
+    List<ActivityImpl> activitiesLeft = new ArrayList<ActivityImpl>();
+    
+    if (source.equals(destination)) {
+      activitiesLeft.add(source);
+    } else {
+      List<ObservableElementImpl> destinationChain = destination.getParentChain();
+      
+      if (!destinationChain.contains(source)) {
+        ActivityImpl sourceActivity = source;
+        while ( (sourceActivity!=null)
+                && (!destinationChain.contains(sourceActivity))
+              ) {
+          activitiesLeft.add(sourceActivity);
+          sourceActivity = sourceActivity.getParentActivity(); 
+        }
+      }
+    }
+    
+    return activitiesLeft;
+  }
+
+  public String toString() {
+    return "take-transition";
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return new TakeTransitionMessage(execution);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.model.op;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TakeTransitionMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public TakeTransitionMessage() {
+  }
+
+  public TakeTransitionMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    unlockExecution();
+    execution.performAtomicOperationSync(ExecutionImpl.TAKE_TRANSITION);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+
+  public String toString() {
+    return "take-transition-message["+dbid+"]";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+<body>atomic operations and asynchronous continuation messages
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,20 @@
+<body>
+default implementation of process execution in {@link org.jbpm.pvm.internal.model.ExecutionImpl} 
+based on {@link org.jbpm.pvm.internal.model.AtomicOperation}s
+
+<h3>Bidirectional relations</h3>
+<p>In this process model thoughout the pvm codebase, there are several bidirectional 
+relations.  By convention, the bidirectional relations are maintained on the many side.
+This means that when you call for example {@link org.jbpm.pvm.internal.model.ProcessDefinitionImpl#addActivity(org.jbpm.pvm.internal.model.ActivityImpl)}, that 
+method will also update the inverse pointer by invoking the 
+{@link org.jbpm.pvm.internal.model.ActivityImpl#setProcessDefinition(org.jbpm.pvm.internal.model.ProcessDefinitionImpl)} setter.  Setter methods will be plain setter 
+methods and they will NOT update the inverse reference.  (that would cause 
+an infinite loop).
+</p>
+
+<p>In the same spirit, there is the convention that the many side of bidirection 
+relations provide factory methods for the related objects.  Those factory methods 
+will also establish the bidirectional relation.  E.g. {@link org.jbpm.pvm.internal.model.ProcessDefinitionImpl#createActivity(String)}.  
+</p>
+
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AbstractQuery implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected CommandService commandService;
+  protected String orderByClause = null;
+  protected Page page = null;
+  protected boolean isWhereAdded = false;
+  
+  public AbstractQuery(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  protected abstract void applyParameters(Query query);
+
+  public abstract String hql();
+
+  /* reuse by copy and paste:
+   * (return type can't be changed)
+  public ConcreteQuery page(int firstResult, int maxResults) {
+    this.page = new Page{firstResult, maxResults};
+    return this;
+  } 
+  */
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    String hql = hql();
+    Query query = session.createQuery(hql);
+    applyParameters(query);
+    applyPage(query);
+    return query.list();
+  }
+  
+  protected void appendWhereClause(String whereClause, StringBuffer hql) {
+    if (isWhereAdded) {
+      hql.append("  and ");
+    } else {
+      hql.append("where ");
+    }
+    hql.append(whereClause);
+  }
+
+  protected void appendOrderByClause(StringBuffer hql) {
+    if (orderByClause!=null) {
+      hql.append("order by ");
+      hql.append(orderByClause);
+    }
+  }
+
+  protected void applyPage(Query query) {
+    if (page!=null) {
+      query.setFirstResult(page.firstResult);
+      query.setMaxResults(page.maxResults);
+    }
+  }
+
+  protected void addOrderByClause(String clause) {
+    if (orderByClause==null) {
+      orderByClause = clause;
+    } else {
+      orderByClause += ", " + clause;
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AvgDurationPerActivityQueryCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AvgDurationPerActivityQueryCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AvgDurationPerActivityQueryCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AvgDurationPerActivityQueryCmd implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+
+  public AvgDurationPerActivityQueryCmd(String processDefinitionId) {
+    this.processDefinitionId = processDefinitionId;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    
+    Query query = session.createQuery(
+      "select distinct hai.activityName " +
+      "from "+HistoryActivityInstanceImpl.class.getName()+" as hai " +
+      "where hai.historyProcessInstance.processDefinitionId = :processDefinitionId"
+    );
+    query.setString("processDefinitionId", processDefinitionId);
+    
+    Map<String, Long> avgDuration = new HashMap<String, Long>();
+    
+    List<String> activityNames = query.list();
+    for (String activityName: activityNames) {
+      query = session.createQuery(
+        "select avg(hai.duration) " +
+        "from "+HistoryActivityInstanceImpl.class.getName()+" as hai " +
+        "where hai.historyProcessInstance.processDefinitionId = :processDefinitionId " +
+        "  and hai.activityName = :activityName"
+      );
+      query.setString("processDefinitionId", processDefinitionId);
+      query.setString("activityName", activityName);
+      
+      Number number = (Number) query.uniqueResult();
+      avgDuration.put(activityName, new Long(number.longValue()));
+    }
+    
+    return avgDuration;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ChoiceDistributionQueryCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ChoiceDistributionQueryCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ChoiceDistributionQueryCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ChoiceDistributionQueryCmd implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  protected String activityName;
+  
+  public ChoiceDistributionQueryCmd(String processDefinitionId, String activityName) {
+    this.processDefinitionId = processDefinitionId;
+    this.activityName = activityName;
+  }
+
+  public Object execute(Environment environment) {
+    Session session = environment.get(Session.class);
+    
+    Query query = session.createQuery(
+      "select hai.transitionName, count(hai) " +
+      "from "+HistoryActivityInstanceImpl.class.getName()+" as hai " +
+      "where hai.historyProcessInstance.processDefinitionId = :processDefinitionId " +
+      "  and hai.activityName = :activityName " +
+      "group by hai.transitionName "
+    );
+    query.setString("processDefinitionId", processDefinitionId);
+    query.setString("activityName", activityName);
+
+    List<Object[]> transitionCounts = query.list();
+
+    Map<String, Integer> choiceDistributionCounts = new HashMap<String, Integer>();
+    
+    for (Object[] pair: transitionCounts) {
+      String transitionName = (String) pair[0];
+      Number number = (Number) pair[1];
+      
+      choiceDistributionCounts.put(transitionName, new Integer(number.intValue()));
+    }
+    
+    return choiceDistributionCounts;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionQuery;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionQueryImpl extends AbstractQuery implements ExecutionQuery {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected boolean onlyProcessInstances; 
+  protected String processDefinitionNameLike;
+  protected String processDefinitionKeyLike;
+  protected String processDefinitionId;
+  protected String processInstanceId;
+
+  public ExecutionQueryImpl(CommandService commandService, boolean onlyProcessInstances) {
+    super(commandService);
+    this.onlyProcessInstances = onlyProcessInstances;
+  }
+
+  public Execution executeUniqueResult() {
+    List<Execution> executions = execute();
+    if (executions.isEmpty()) {
+      throw new JbpmException("no execution with these criteria");
+    }
+    if (executions.size()>1) {
+      throw new JbpmException("more then 1 execution with these criteria");
+    }
+    return executions.get(0);
+  }
+
+  public List<Execution> execute() {
+    return (List<Execution>) commandService.execute(this);
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select execution ");
+    hql.append("from ");
+    hql.append(ExecutionImpl.class.getName());
+    hql.append(" as execution ");
+    
+    if (onlyProcessInstances) {
+      appendWhereClause("execution.processInstance.dbid = execution.dbid ", hql);
+    }
+
+    if (processInstanceId!=null) {
+      appendWhereClause("execution.processInstance.id = '"+processInstanceId+"' ", hql);
+    }
+
+    if (processDefinitionId!=null) {
+      appendWhereClause("execution.processDefinition.id = '"+processDefinitionId+"' ", hql);
+    }
+
+    if (processDefinitionNameLike!=null) {
+      appendWhereClause("execution.processDefinition.name like '"+processDefinitionNameLike+"' ", hql);
+    }
+
+    if (processDefinitionKeyLike!=null) {
+      appendWhereClause("execution.processDefinition.key like '"+processDefinitionKeyLike+"' ", hql);
+    }
+    
+    appendOrderByClause(hql);
+
+    return hql.toString();
+  }
+  
+  protected void applyParameters(Query query) {
+  }
+
+  public ExecutionQuery orderAsc(String property) {
+    addOrderByClause("e."+property+" asc");
+    return this;
+  }
+
+  public ExecutionQuery orderDesc(String property) {
+    addOrderByClause("e."+property+" desc");
+    return this;
+  }
+
+  public ExecutionQuery processDefinitionId(String processDefinitionId) {
+    this.processDefinitionId = processDefinitionId;
+    return this;
+  }
+
+  public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
+    this.processDefinitionKeyLike = processDefinitionKey;
+    return this;
+  }
+
+  public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
+    this.processDefinitionNameLike = processDefinitionName;
+    return this;
+  }
+
+  public ExecutionQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public ExecutionQuery processInstanceId(String processInstanceId) {
+    this.processInstanceId = processInstanceId;
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.history.HistoryActivityInstance;
+import org.jbpm.history.HistoryActivityInstanceQuery;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryActivityInstanceQueryImpl extends AbstractQuery implements HistoryActivityInstanceQuery {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  protected Long tookLessThen;
+  protected Long tookLongerThen;
+  protected Date startedBefore;
+  protected Date startedAfter;
+  protected String executionId;
+  protected String activityName;
+
+  public HistoryActivityInstanceQueryImpl(CommandService commandService, String processInstanceId) {
+    super(commandService);
+    if (processInstanceId==null) {
+      throw new JbpmException("processInstanceId is null");
+    }
+    this.processDefinitionId = processInstanceId;
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select hai ");
+    hql.append("from ");
+    hql.append(HistoryActivityInstanceImpl.class.getName());
+    hql.append(" as hai ");
+    
+    if (processDefinitionId!=null) {
+      appendWhereClause(" hai.historyActivityInstance.processDefinitionId = '"+processDefinitionId+"' ", hql);
+    }
+
+    if (tookLessThen!=null) {
+      appendWhereClause(" hai.duration < :tookLessThen ", hql);
+    }
+    
+    if (tookLongerThen!=null) {
+      appendWhereClause(" hai.duration > :tookLongerThen ", hql);
+    }
+    
+    if (startedBefore!=null) {
+      appendWhereClause(" hai.startTime < :startedBefore ", hql);
+    }
+    
+    if (startedAfter!=null) {
+      appendWhereClause(" hai.startTime > :startedAfter ", hql);
+    }
+    
+    if (executionId!=null) {
+      appendWhereClause(" hai.executionId = '"+executionId+"'", hql);
+    }
+    
+    if (activityName!=null) {
+      appendWhereClause(" hai.activityName = '"+activityName+"'", hql);
+    }
+
+    return hql().toString();
+  }
+
+  protected void applyParameters(Query query) {
+    if (tookLessThen!=null) {
+      query.setLong("tookLessThen", tookLessThen);
+    }
+    
+    if (tookLongerThen!=null) {
+      query.setLong("tookLongerThen", tookLongerThen);
+    }
+    
+    if (startedBefore!=null) {
+      query.setTime("startedBefore", startedBefore);
+    }
+    
+    if (startedAfter!=null) {
+      query.setTime("startedAfter", startedAfter);
+    }
+  }
+
+  public List<HistoryActivityInstance> execute() {
+    return (List) commandService.execute(this);
+  }
+
+  public HistoryActivityInstanceQuery activityName(String activityName) {
+    this.activityName = activityName;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery executionId(String executionId) {
+    this.executionId = executionId;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery orderAsc(String property) {
+    addOrderByClause("hai."+property+" asc");
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery orderDesc(String property) {
+    addOrderByClause("hai."+property+" desc");
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery processDefinitionId(String processDefinitionId) {
+    this.processDefinitionId = processDefinitionId;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery startedAfter(Date time) {
+    this.startedAfter = time;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery startedBefore(Date time) {
+    this.startedBefore = time;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery tookLessThen(long durationInMillis) {
+    this.tookLessThen = durationInMillis;
+    return this;
+  }
+
+  public HistoryActivityInstanceQuery tookLongerThen(long durationInMillis) {
+    this.tookLongerThen = durationInMillis;
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryProcessInstanceQueryImpl extends AbstractQuery implements HistoryProcessInstanceQuery {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String processDefinitionId;
+  protected String state;
+  protected String processInstanceId;
+
+  public HistoryProcessInstanceQueryImpl(CommandService commandService) {
+    super(commandService);
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select hpi ");
+    hql.append("from ");
+    hql.append(HistoryProcessInstanceImpl.class.getName());
+    hql.append(" as hpi ");
+    
+    if (processInstanceId!=null) {
+      appendWhereClause(" hpi.id = '"+processInstanceId+"' ", hql);
+    }
+    
+    if (processDefinitionId!=null) {
+      appendWhereClause(" hpi.processDefinitionId = '"+processDefinitionId+"' ", hql);
+    }
+    
+    if (state!=null) {
+      appendWhereClause(" hpi.state = '"+state+"' ", hql);
+    }
+    
+    return hql.toString();
+  }
+
+  protected void applyParameters(Query query) {
+  }
+
+  public List<HistoryProcessInstance> execute() {
+    return (List) commandService.execute(this);
+  }
+
+  public HistoryProcessInstance executeUniqueResult() {
+    List<HistoryProcessInstance> historyProcessInstances = execute();
+    if (historyProcessInstances.isEmpty()) {
+      throw new JbpmException("no history process instance with these criteria");
+    }
+    if (historyProcessInstances.size()>1) {
+      throw new JbpmException("more then 1 history process instance with these criteria");
+    }
+    return historyProcessInstances.get(0);
+  }
+
+  public HistoryProcessInstanceQuery processInstanceId(String processInstanceId) {
+    this.processInstanceId = processInstanceId;
+    return this;
+  }
+
+  public HistoryProcessInstanceQuery orderAsc(String property) {
+    addOrderByClause("hpi."+property+" asc");
+    return this;
+  }
+
+  public HistoryProcessInstanceQuery orderDesc(String property) {
+    addOrderByClause("hpi."+property+" asc");
+    return this;
+  }
+
+  public HistoryProcessInstanceQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId) {
+    this.processDefinitionId = processDefinitionId;
+    return this;
+  }
+
+  public HistoryProcessInstanceQuery state(String state) {
+    this.state = state;
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.JobQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.job.TimerImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobQueryImpl extends AbstractQuery implements JobQuery {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected boolean messagesOnly = false; 
+  protected boolean timersOnly = false;
+  protected String processInstanceId = null;
+  protected boolean exception = false;
+
+  public JobQueryImpl(CommandService commandService) {
+    super(commandService);
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select j ");
+    hql.append("from ");
+    if (messagesOnly) {
+      hql.append(MessageImpl.class.getName());
+    } else if (timersOnly) {
+      hql.append(TimerImpl.class.getName());
+    } else {
+      hql.append(JobImpl.class.getName());
+    }
+    hql.append(" j ");
+
+    if (processInstanceId!=null) {
+      appendWhereClause("j.processInstance.id = '"+processInstanceId+"' ", hql);
+    }
+    
+    if (exception) {
+      appendWhereClause("j.exception is not null ", hql);
+    }
+
+    return hql.toString();
+  }
+
+  protected void applyParameters(Query query) {
+  }
+
+  public List<Job> execute() {
+    return (List<Job>) commandService.execute(this);
+  }
+
+  public JobQuery messages() {
+    this.messagesOnly = true;
+    return this;
+  }
+
+  public JobQuery timers() {
+    this.timersOnly = true;
+    return this;
+  }
+
+  public JobQuery exception() {
+    this.exception = true;
+    return this;
+  }
+
+  public JobQuery orderAsc(String property) {
+    addOrderByClause("j."+property+" asc");
+    return this;
+  }
+
+  public JobQuery orderDesc(String property) {
+    addOrderByClause("j."+property+" asc");
+    return this;
+  }
+
+  public JobQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public JobQuery processInstanceId(String processInstanceId) {
+    this.processInstanceId = processInstanceId;
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/Page.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Page implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  public int firstResult;
+  public int maxResults;
+  
+  public Page(int firstResult, int maxResults) {
+    this.firstResult = firstResult;
+    this.maxResults = maxResults;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryImpl extends AbstractQuery implements ProcessDefinitionQuery {
+  
+  private static final long serialVersionUID = 1L;
+
+  private static final String NEWLINE = System.getProperty("line.separator");
+  
+  protected String nameLike;
+  protected String keyLike;
+  
+  public ProcessDefinitionQueryImpl(CommandService commandService) {
+    super(commandService);
+  }
+
+  public List<ProcessDefinition> execute() {
+    return (List) commandService.execute(this);
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select pd ");
+    hql.append("from ");
+    hql.append(ProcessDefinitionImpl.class.getName());
+    hql.append(" as pd ");
+
+    if (nameLike!=null) {
+      appendWhereClause("pd.name like '"+nameLike+"'", hql);
+    }
+
+    if (keyLike!=null) {
+      appendWhereClause("pd.key like '"+keyLike+"'", hql);
+    }
+    
+    appendOrderByClause(hql);
+
+    return hql.toString();
+  }
+  
+  protected void applyParameters(Query query) {
+  }
+
+  public ProcessDefinitionQuery nameLike(String name) {
+    this.nameLike = name;
+    return this;
+  }
+
+  public ProcessDefinitionQuery keyLike(String key) {
+    this.keyLike = key;
+    return this;
+  }
+
+  public ProcessDefinitionQuery orderAsc(String property) {
+    addOrderByClause("pd."+property+" asc");
+    return this;
+  }
+
+  public ProcessDefinitionQuery orderDesc(String property) {
+    addOrderByClause("pd."+property+" desc");
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.script;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.script.Bindings;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentBindings implements Bindings {
+  
+  protected String[] readContextNames;
+  protected String writeContextName;
+  protected Map<String, WriteBinding> writeBindings;
+  protected Environment environment;
+
+  public EnvironmentBindings(String[] readContextNames, String writeContextName) {
+    this.readContextNames = readContextNames;
+    this.writeContextName = writeContextName;
+    
+    environment = Environment.getCurrent();
+  }
+
+  public Object get(Object key) {
+    Context context = getReadContext(key);
+    if (context!=null) {
+      return context.get((String) key);
+    }
+    return null;
+  }
+
+  protected Context getReadContext(Object key) {
+    for (String readContextName: readContextNames) {
+      Context readContext = environment.getContext(readContextName);
+      if ( (readContext!=null)
+           && (readContext.has((String) key))
+         ) {
+        return readContext;
+      }
+    }
+    return null;
+  }
+
+  public boolean containsKey(Object key) {
+    Context context = getReadContext(key);
+    return (context!=null);
+  }
+
+  public Object put(String key, Object value) {
+    if (writeContextName==null) {
+      return null;
+    }
+    Context writeContext = environment.getContext(writeContextName);
+    if (writeContext==null) {
+      return null;
+    }
+    return writeContext.set(key, value);
+  }
+
+  public void putAll(Map< ? extends String, ? extends Object> toMerge) {
+    throw new UnsupportedOperationException();
+  }
+
+  public Object remove(Object key) {
+    throw new UnsupportedOperationException();
+  }
+
+  public void clear() {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean containsValue(Object value) {
+    throw new UnsupportedOperationException();
+  }
+
+  public Set<java.util.Map.Entry<String, Object>> entrySet() {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean isEmpty() {
+    throw new UnsupportedOperationException();
+  }
+
+  public Set<String> keySet() {
+    throw new UnsupportedOperationException();
+  }
+
+  public int size() {
+    throw new UnsupportedOperationException();
+  }
+
+  public Collection<Object> values() {
+    throw new UnsupportedOperationException();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.script;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.ExecutionContext;
+import org.jbpm.pvm.internal.env.ExecutionEnvironment;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptManager {
+
+  private static Log log = Log.getLog(ScriptManager.class.getName());
+
+  private static ScriptManager defaultScriptManager = null;
+
+  protected String defaultExpressionLanguage;
+  protected String defaultScriptLanguage;
+  protected ScriptEngineManager scriptEngineManager;
+  protected String[] readContextNames = null;
+  protected String writeContextName;
+  
+  public static synchronized ScriptManager getDefaultScriptManager() {
+    if (defaultScriptManager==null) {
+      WireDefinition wireDefinition = (WireDefinition) new WireParser()
+        .createParse()
+        .setString(
+          "<objects>" +
+          "  <script-manager default-expression-language='juel'" +
+          "                  default-script-language='beanshell' " +
+          "                  read-contexts='execution, environment, process-engine' " +
+          "                  write-context=''>" +
+          "    <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />" +
+          "  </script-manager>" +
+          "</objects>"
+        )
+        .execute()
+        .getDocumentObject();
+  
+      WireContext wireContext = new WireContext(wireDefinition);
+      defaultScriptManager = wireContext.get(ScriptManager.class);
+    }
+    return defaultScriptManager;
+  }
+  
+  /** {@link #evaluate(String, Execution, String) evaluates} the expression 
+   * with the given language or with the defaultExpressionLanguage if the 
+   * given language is null. */
+  public Object evaluateExpression(String expression, Execution execution, String language) {
+    return evaluate(expression, execution, (language!=null ? language : defaultExpressionLanguage));
+  }
+
+  /** {@link #evaluate(String, Execution, String) evaluates} the script 
+   * with the given language or with the defaultScriptLanguage if the 
+   * given language is null. */
+  public Object evaluateScript(String script, Execution execution, String language) {
+    return evaluate(script, execution, (language!=null ? language : defaultScriptLanguage));
+  }
+
+  /** evaluates the script with the given language.
+   * If script is null, then this method will return null.
+   * @throws JbpmException if language is null.
+   */
+  public Object evaluate(String script, Execution execution, String language) {
+    if (script==null) {
+      return null;
+    }
+    if (language==null) {
+      throw new JbpmException("no language specified");
+    }
+    ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(language);
+    if (scriptEngine==null) {
+      throw new JbpmException("no scripting engine configured for language "+language);
+    }
+    
+    if (log.isDebugEnabled()) log.debug("evaluating "+language+" script :"+script);
+    
+    if (execution==null) {
+      return evaluate(scriptEngine, script);
+    }
+
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      environment = new ExecutionEnvironment(execution);
+      try {
+        return evaluate(scriptEngine, script);
+      } finally {
+        environment.close();
+      }
+    }
+
+    ExecutionContext executionContext = new ExecutionContext(execution);
+    environment.addContext(executionContext);
+    try {
+      return evaluate(scriptEngine, script);
+    } finally {
+      environment.removeContext(executionContext);
+    }
+  }
+  
+  protected Object evaluate(ScriptEngine scriptEngine, String script) {
+    Bindings bindings = new EnvironmentBindings(readContextNames, writeContextName);
+    scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
+    
+    try {
+      Object result = scriptEngine.eval(script);
+      log.debug("script evaluated to "+result);
+      return result;
+    } catch (ScriptException e) {
+      throw new JbpmException("script evaluation error: "+e.getMessage(), e);
+    }
+  }
+
+  public String getDefaultExpressionLanguage() {
+    return defaultExpressionLanguage;
+  }
+  public String getDefaultScriptLanguage() {
+    return defaultScriptLanguage;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/WriteBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/WriteBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/WriteBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.script;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class WriteBinding {
+
+  protected String scriptVariable;
+  protected String contextName;
+  protected String contextVariableName;
+  
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.spring;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallback;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CommandTransactionCallback<T> implements TransactionCallback {
+  
+  Command<T> command;
+  EnvironmentFactory environmentFactory;
+  
+  public CommandTransactionCallback(Command<T> command, EnvironmentFactory environmentFactory) {
+    this.command = command;
+    this.environmentFactory = environmentFactory;
+  }
+
+  public T doInTransaction(TransactionStatus status) {
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      return command.execute(environment);
+    } catch (Exception e) {
+      throw new RuntimeException("ooops", e);
+    } finally {
+      environment.close();
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.spring;
+
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionManager extends HibernateDaoSupport {
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.spring;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.springframework.orm.hibernate3.HibernateTransactionManager;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+import org.springframework.transaction.support.TransactionTemplate;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SpringCommandService implements CommandService {
+  
+  TransactionTemplate transactionTemplate;
+  EnvironmentFactory environmentFactory;
+  
+  public void setEnvironmentFactory(EnvironmentFactory environmentFactory) {
+    this.environmentFactory = environmentFactory;
+  }
+
+  public void setTransactionManager(HibernateTransactionManager transactionManager) {
+    this.transactionTemplate = new TransactionTemplate(transactionManager);
+  }
+  
+  public <T> T execute(Command<T> command) {
+    return (T) transactionTemplate.execute(
+        new CommandTransactionCallback(command, environmentFactory)
+    );
+  }
+  
+  
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.spring;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.SpringConfiguration;
+import org.jbpm.pvm.internal.env.BasicEnvironment;
+import org.springframework.context.ApplicationContext;
+
+/** sees the prototype beans in the application context and 
+ * this environment will cache all the prototyped objects.
+ * 
+ * @author Tom Baeyens
+ */
+public class SpringEnvironment extends BasicEnvironment {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected ApplicationContext applicationContext;
+
+  public SpringEnvironment(SpringConfiguration springConfiguration) {
+    addContext(springConfiguration);
+    addContext(new SpringEnvironmentContext(springConfiguration.getApplicationContext()));
+    pushEnvironment(this);
+  }
+
+  public ClassLoader getClassLoader() {
+    return null;
+  }
+
+  public EnvironmentFactory getEnvironmentFactory() {
+    return null;
+  }
+
+  public Throwable getException() {
+    return null;
+  }
+
+  public String getUserId() {
+    return null;
+  }
+
+  public void setClassLoader(ClassLoader classLoader) {
+  }
+
+  public void setException(Throwable exception) {
+  }
+
+  public void setUserId(String userId) {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.spring;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.springframework.context.ApplicationContext;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SpringEnvironmentContext implements Context {
+  
+  // TODO pull up the common behaviour between this class and the SpringEnvironmentFactory
+  
+  ApplicationContext applicationContext;
+  Map<String, Object> cache = new HashMap<String, Object>();
+
+  public SpringEnvironmentContext(ApplicationContext applicationContext) {
+    this.applicationContext = applicationContext;
+  }
+
+  public boolean has(String key) {
+    return applicationContext.isPrototype(key);
+  }
+
+  public Object get(String key) {
+    if (cache.containsKey(key)) {
+      return cache.get(key);
+    }
+    if (has(key)) {
+      Object bean = applicationContext.getBean(key);
+      // cache.put(key, bean);
+      return bean;
+    }
+    return null;
+  }
+
+  public <T> T get(Class<T> type) {
+    String name = ReflectUtil.getUnqualifiedClassName(type);
+    name = name.substring(0, 1).toLowerCase() + name.substring(1);
+    return (T) get(name);
+  }
+
+  public Set<String> keys() {
+    HashSet<String> keys = new HashSet<String>();
+    for (String key : applicationContext.getBeanDefinitionNames()) {
+      if (has(key)) {
+        keys.add(key);
+      }
+    }
+    return keys;
+  }
+  
+  public ApplicationContext getApplicationContext() {
+    return applicationContext;
+  }
+
+  public void setApplicationContext(ApplicationContext applicationContext) {
+    this.applicationContext = applicationContext;
+  }
+
+  
+  public String getName() {
+    return null;
+  }
+
+  public Object set(String key, Object value) {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ByteArrayStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ByteArrayStreamInput extends StreamInput {
+  
+  protected byte[] bytes;
+  
+  /** @throws JbpmException if bytes is null */
+  public ByteArrayStreamInput(byte[] bytes) {
+    if (bytes==null) {
+      throw new JbpmException("bytes is null");
+    }
+    this.name = "byte-array";
+    this.bytes = bytes;
+  }
+
+  public InputStream openStream() {
+    return new ByteArrayInputStream(bytes);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/FileStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FileStreamInput extends StreamInput {
+  
+  protected File file;
+
+  /** @throws JbpmException if file is null */
+  public FileStreamInput(File file) {
+    if (file==null) {
+      throw new JbpmException("file is null");
+    }
+
+    try {
+      this.name = file.toURL().toString();
+    } catch (MalformedURLException e) {
+      this.name = file.toString();
+    }
+
+    this.file = file;
+  }
+
+  public InputStream openStream() {
+    InputStream stream = null;
+    
+    try {
+      if (!file.exists()) {
+        throw new JbpmException("file "+file+" doesn't exist");
+      }
+      if (file.isDirectory()) {
+        throw new JbpmException("file "+file+" is a directory");
+      }
+      stream = new FileInputStream(file);
+      
+    } catch (Exception e) {
+      throw new JbpmException("couldn't access file "+file+": "+e.getMessage(), e);
+    }
+    
+    return stream;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/InputStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class InputStreamInput extends StreamInput {
+  
+  protected InputStream inputStream;
+  
+  public InputStreamInput(InputStream inputStream) {
+    if (inputStream==null) {
+      throw new JbpmException("inputStream is null");
+    }
+    this.name = "input-stream";
+    this.inputStream = inputStream;
+  }
+
+  public InputStream openStream() {
+    return inputStream;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/ResourceStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.InputStream;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ResourceStreamInput extends StreamInput {
+  
+  protected ClassLoader classLoader;
+  protected String resource;
+  
+  /** @throws JbpmException if resource is null */
+  public ResourceStreamInput(String resource) {
+    this(resource, null);
+  }
+
+  /** @throws JbpmException if resource is null */
+  public ResourceStreamInput(String resource, ClassLoader classLoader) {
+    if (resource==null) {
+      throw new JbpmException("resource is null");
+    }
+    this.name = "resource://"+resource;
+    this.resource = resource;
+    this.classLoader = classLoader;
+  }
+
+  public InputStream openStream() {
+    InputStream stream = ReflectUtil.getResourceAsStream(classLoader, resource);
+    if (stream==null) {
+      throw new JbpmException("resource "+resource+" does not exist");
+    }
+    return stream;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.InputStream;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class StreamInput {
+  
+  protected String name;
+
+  public abstract InputStream openStream();
+  
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+  
+  public String toString() {
+    return name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/StringStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StringStreamInput extends StreamInput {
+  
+  String string;
+  
+  public StringStreamInput(String string) {
+    this.name = "string";
+    this.string = string;
+  }
+
+  public InputStream openStream() {
+    byte[] bytes = string.getBytes();
+    return new ByteArrayInputStream(bytes);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/stream/UrlStreamInput.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.stream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class UrlStreamInput extends StreamInput {
+  
+  protected URL url;
+
+  /** @throws JbpmException if url is null */
+  public UrlStreamInput(URL url) {
+    if (url==null) {
+      throw new JbpmException("url is null");
+    }
+    this.name = url.toString();
+    this.url = url;
+  }
+
+  public InputStream openStream() {
+    InputStream stream = null;
+    try {
+      stream = url.openStream();
+    } catch (IOException e) {
+      throw new JbpmException("couldn't open URL stream", e);
+    }
+    return stream;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncCommandMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  Command<?> command;
+  String userId;
+  
+  public AsyncCommandMessage(Command<?> command) {
+    this.command = command;
+  }
+
+  public AsyncCommandMessage(Command<?> command, String userId) {
+    this.command = command;
+    this.userId = userId;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    unlockExecution();
+    if (userId!=null) {
+      environment.setUserId(userId);
+    }
+    try {
+      CommandService commandService = environment.get(CommandService.class);
+      commandService.execute(command);
+    } finally {
+      if (userId!=null) {
+        environment.setUserId(null);
+      }
+    }
+    return null;
+  }
+  
+  public String toString() {
+    return "async-command-message["+dbid+"]";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.session.MessageSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncCommandService implements CommandService {
+  
+  boolean propagateUserId = true;
+
+  public <T> T execute(Command<T> command) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new JbpmException("no environment for verifying authorization");
+    }
+    MessageSession messageSession = environment.get(MessageSession.class);
+    if (messageSession==null) {
+      throw new JbpmException("no message session for executing command asynchronously");
+    }
+    String userId = (propagateUserId ? environment.getUserId() : null);
+    messageSession.send(new AsyncCommandMessage(command, userId));
+    return null;
+  }
+  
+  public void setPropagateUserId(boolean propagateUserId) {
+    this.propagateUserId = propagateUserId;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationInterceptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationInterceptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationInterceptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+
+/** performs an authorization check before the command is executed.
+ * @author Tom Baeyens
+ */
+public class AuthorizationInterceptor extends Interceptor {
+
+  public <T> T execute(Command<T> command) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new JbpmException("no environment for verifying authorization");
+    }
+    AuthorizationSession authorizationSession = environment.get(AuthorizationSession.class);
+    if (authorizationSession==null) {
+      throw new JbpmException("no AuthorizationSession in environment for verifying authorization");
+    }
+    authorizationSession.checkPermission(command, environment);
+    // if the authorization check succeeded, proceed
+    return next.execute(command);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationSession.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AuthorizationSession.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,9 @@
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+
+public interface AuthorizationSession {
+
+  void checkPermission(Command<?> command, Environment environment);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DefaultCommandService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DefaultCommandService.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DefaultCommandService.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DefaultCommandService implements CommandService {
+
+  private static final Log log = Log.getLog(DefaultCommandService.class.getName());
+
+  public <T> T execute(Command<T> command) {
+    Environment environment = Environment.getCurrent();
+    
+    try {
+      return command.execute(environment);
+      
+    } catch (RuntimeException e) {
+      log.info("exception while executing command "+command, e);
+      throw e;
+      
+    } catch (Exception e) {
+      log.info("exception while executing command "+command, e);
+      throw new JbpmException("exception while executing command "+command, e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/DeploymentImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,408 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.jbpm.Deployment;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.stream.ByteArrayStreamInput;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.util.IoUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.pvm.internal.xml.ProblemImpl;
+import org.jbpm.pvm.internal.xml.ProblemList;
+import org.w3c.dom.Document;
+
+
+/** a deployment unit, containing all information in source format from which 
+ * a process definition will be created and stored in the process repository.
+ * 
+ * For more info, see Deployment.
+ * 
+ * @author Tom Baeyens
+ */
+public class DeploymentImpl extends ProblemList implements Deployment, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final Log log = Log.getLog(DeploymentImpl.class.getName());
+
+  private static final Parser parser = new Parser();
+  
+  protected ProcessServiceImpl processServiceImpl;
+
+  protected String name;
+
+  /** maps file names to stream source */
+  protected Map<String, StreamInput> files = new HashMap<String,StreamInput>();
+  /** maps file names to dom so that duplicate xml parsing can be avoided. */
+  protected Map<String, Document> fileDocuments = new HashMap<String, Document>();
+  /** maps file names to file types */
+  protected Map<String, String> fileTypes = new HashMap<String,String>();
+
+  /** generic pool of objects.  
+   * 1) users can supply objects directly to a deployment like 
+   *    e.g. ProcessDefinition's created by a factory
+   * 2) deployers can create objects as a result from processing the files
+   *    in those cases the object names are typically identical to the file 
+   *    names
+   * 3) the save deployer will store all objects in the db.
+   */
+  protected Map<String, Object> objects;
+  
+  /* maps object names to object types */
+  protected Map<String, Object> objectTypes;
+
+  // TODO REMOVE
+  protected ProcessDefinition processDefinition;
+  
+  public DeploymentImpl(ProcessServiceImpl processServiceImpl) {
+    this.processServiceImpl = processServiceImpl;
+    this.problems = new ArrayList<ProblemImpl>();
+  }
+
+  // TODO REMOVE
+  public DeploymentImpl() {
+    this.problems = new ArrayList<ProblemImpl>();
+  }
+  
+  // TODO REMOVE replace with addObject
+  public DeploymentImpl(ProcessDefinition processDefinition) {
+    this.problems = new ArrayList<ProblemImpl>();
+    setProcessDefinition(processDefinition);
+  }
+  
+
+  public Deployment addResource(String resource) {
+    addStreamSource(resource, new ResourceStreamInput(resource));
+    return this;
+  }
+  
+  public Deployment addFile(File file) {
+    addStreamSource(file.getAbsolutePath(), new FileStreamInput(file));
+    return this;
+  }
+  
+  public Deployment addUrl(URL url) {
+    addStreamSource(url.toString(), new UrlStreamInput(url));
+    return this;
+  }
+  
+  public Deployment addInputStream(String name, InputStream inputStream) {
+    addStreamSource(name, new InputStreamInput(inputStream));
+    return this;
+  }
+  
+  public Deployment addString(String name, String string) {
+    addStreamSource(name, new StringStreamInput(string));
+    return this;
+  }
+  
+  public Deployment addArchiveResource(String resource) {
+    this.name = resource;
+    ResourceStreamInput streamSource = new ResourceStreamInput(resource);
+    addStreamSource(resource, streamSource);
+    return this;
+  }
+  
+  public Deployment addArchiveFile(File file) {
+    addStreamSource(file.getAbsolutePath(), new FileStreamInput(file));
+    return this;
+  }
+  
+  public Deployment addArchiveUrl(URL url) {
+    addStreamSource(url.toString(), new UrlStreamInput(url));
+    return this;
+  }
+  
+  public Deployment addArchive(ZipInputStream zipInputStream) {
+    try {
+      ZipEntry zipEntry = zipInputStream.getNextEntry();
+      while(zipEntry!=null) {
+        String entryName = zipEntry.getName();
+        byte[] bytes = IoUtil.readBytes(zipInputStream);
+        if (bytes!=null) {
+          addStreamSource(entryName, new ByteArrayStreamInput(bytes));
+        }
+        zipEntry = zipInputStream.getNextEntry();
+      }
+    } catch (Exception e) {
+      throw new JbpmException("couldn't read zip archive", e);
+    }
+    return this;
+  }
+  
+  /** recursively adds all files in a directory using the relative file names */
+  public Deployment addDirectory(String directory) {
+    if (directory==null) {
+      throw new JbpmException("directory is null");
+    }
+    addDirectory(new File(directory), "", false); 
+    return this;
+  }
+  
+  /** recursively adds all files in a directory using the canonical file names */
+  public Deployment addDirectoryCanonical(String directory) {
+    if (directory==null) {
+      throw new JbpmException("directory is null");
+    }
+    addDirectory(new File(directory), "", true); 
+    return this;
+  }
+  
+  /** recursively adds all files in a directory using the relative file names */
+  public Deployment addDirectory(File directory) {
+    addDirectory(directory, "", false); 
+    return this;
+  }
+  
+  /** recursively adds all files in a directory using the canonical file names */
+  public Deployment addDirectoryCanonical(File directory) {
+    addDirectory(directory, "", true); 
+    return this;
+  }
+  
+  protected Deployment addDirectory(File directory, String relativeDirectoryName, boolean canonicalPathNames) {
+    if (directory==null) {
+      throw new JbpmException("directory is null");
+    }
+    if (!directory.isDirectory()) {
+      throw new JbpmException(directory.getAbsolutePath()+" is not a directory");
+    }
+
+    File[] files = directory.listFiles();
+    if (files!=null) {
+      for (File file: files) {
+        String relativeFileName = (canonicalPathNames ? null : relativeDirectoryName+"/"+file.getName());
+        if (file.isFile()) {
+          if (canonicalPathNames) {
+            try {
+              addStreamSource(file.getCanonicalPath(), new FileStreamInput(file));
+            } catch (IOException e) {
+              throw new JbpmException("can't get canonical path name for "+file);
+            }
+          } else {
+            addStreamSource(relativeFileName, new FileStreamInput(file));
+          }
+        } else if (file.isDirectory()) {
+          addDirectory(file, relativeFileName, canonicalPathNames);
+        }
+      }
+    }
+    return this;
+  }
+
+  protected Deployment addStreamSource(String name, StreamInput streamSource) {
+    if (this.name==null) {
+      this.name = name;
+    }
+    if (files==null) {
+      files = new HashMap<String, StreamInput>();
+    }
+    files.put(name, streamSource);
+    return this;
+  }
+  
+  public InputStream getFile(String name) {
+    if (files==null) {
+      return null;
+    }
+    StreamInput streamSource = files.get(name);
+    return (streamSource!=null ? streamSource.openStream() : null);
+  }
+  
+  public Set<String> getFileNames() {
+    if (files==null) {
+      return Collections.EMPTY_SET;
+    }
+    return files.keySet();
+  }
+  
+  public Object getObject(String name) {
+    if (objects==null) {
+      return null;
+    }
+    return objects.get(name);
+  }
+
+  public Set<String> getObjectNames() {
+    if (objects==null) {
+      return Collections.EMPTY_SET;
+    }
+    return objects.keySet();
+  }
+
+  public Document getDocument(String name) {
+    if ( (fileDocuments!=null)
+         && (fileDocuments.containsKey(name))
+       ) {
+      return fileDocuments.get(name);
+    }
+    if ( (files!=null)
+         && (files.containsKey(name))
+       ) {
+      InputStream fileStream = getFile(name);
+      return parser.createParse()
+                   .setInputStream(fileStream)
+                   .execute()
+                   .checkProblems("deployment file "+name)
+                   .getDocument();
+    }
+    return null;
+  }
+  
+  public ProcessDefinition getProcessDefinition() {
+    return processDefinition;
+  }
+  
+  public void setProcessDefinition(ProcessDefinition processDefinition) {
+    this.processDefinition = processDefinition;
+  }
+  
+  public String getName() {
+    return name;
+  }
+  public Deployment setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  public Deployment addObject(String name, Object object) {
+    if (objects==null) {
+      objects = new HashMap<String, Object>();
+    }
+    objects.put(name, object);
+    return this;
+  }
+
+  public Deployment deploy() {
+    processServiceImpl.deploy(this);
+    return this;
+  }
+  
+  public List<ProcessDefinition> getProcessDefinitions() {
+    List<ProcessDefinition> processDefinitions = null;
+    if (objects!=null) {
+      processDefinitions = new ArrayList<ProcessDefinition>();
+      for (Object object: objects.values()) {
+        if (object instanceof ProcessDefinition) {
+          processDefinitions.add((ProcessDefinition) object);
+        }
+      }
+    } else {
+      processDefinitions = Collections.EMPTY_LIST;
+    }
+
+    return processDefinitions;
+  }
+
+  // error logging ////////////////////////////////////////////////////////////
+  
+  public class DeploymentParse {
+    String name;
+    Parse parse;
+    public DeploymentParse(String name, Parse parse) {
+      this.name = name;
+      this.parse = parse;
+    }
+  }
+  
+  public String toString() {
+    if (name!=null) {
+      return "deployment("+name+")";
+    }
+    return "deployment";
+  }
+
+  public void addDocument(String name, Document document) {
+    if (fileDocuments==null) {
+      fileDocuments = new HashMap<String, Document>();
+    }
+    fileDocuments.put(name, document);
+  }
+
+  /** throws an exception with appropriate message in case the parse contains 
+   * errors or fatal errors.  This method also logs the problems with severity
+   * 'warning'. */
+  public Deployment checkProblems() {
+    if (hasProblems()) {
+      String problemsText = getProblemsText();
+      if (problemsText!=null) {
+        String errorMsg = "problems during deployment of "+this+":"+problemsText;
+        log.info(errorMsg);
+        throw new JbpmException(errorMsg);
+      }
+    }
+    return this;
+  }
+
+  public Deployment addObject(String name, Object object, String objectType) {
+    addObject(name, objectType);
+    if (objectTypes==null) {
+      objectTypes = new HashMap<String, Object>(); 
+    }
+    objectTypes.put(name, objectType);
+    return this;
+  }
+
+  public Deployment setFileType(String fileName, String fileType) {
+    if (fileTypes==null) {
+      fileTypes = new HashMap<String, String>(); 
+    }
+    fileTypes.put(name, fileType);
+    return this;
+  }
+
+  public List<String> getFileNamesForType(String type) {
+    if (type==null) {
+      throw new JbpmException("type is null");
+    }
+    List<String> fileNames = new ArrayList<String>();
+    for (String fileName: fileTypes.keySet()) {
+      if (fileTypes.get(fileName).equals(type)) {
+        fileNames.add(fileName);
+      }
+    }
+    return fileNames;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+
+
+/** sets up an environment around the execution of the command.
+ * 
+ * @author Tom Baeyens
+ */
+public class EnvironmentInterceptor extends Interceptor {
+
+  protected EnvironmentFactory environmentFactory;
+
+  public <T> T execute(Command<T> command) {
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      return next.execute(command);
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+  public EnvironmentFactory getEnvironmentFactory() {
+    return environmentFactory;
+  }
+  public void setEnvironmentFactory(EnvironmentFactory environmentFactory) {
+    this.environmentFactory = environmentFactory;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.ExecutionQuery;
+import org.jbpm.ExecutionService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.history.HistoryActivityInstanceQuery;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
+import org.jbpm.pvm.internal.cmd.EndProcessInstance;
+import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
+import org.jbpm.pvm.internal.cmd.FindExecutionCmd;
+import org.jbpm.pvm.internal.cmd.GetVariableNamesCmd;
+import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
+import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
+import org.jbpm.pvm.internal.cmd.SignalCmd;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
+import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionServiceImpl implements ExecutionService {
+
+  protected CommandService commandService;
+
+  public Execution startProcessInstanceById(String processDefinitionId){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, null, null));
+  }
+
+  public Execution startProcessInstanceById(String processDefinitionId, String executionKey) {
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, null, executionKey));
+  }
+
+  public Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, null));
+  }
+
+  public Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables, String executionKey){
+    return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, executionKey));
+  }
+
+
+  
+  public Execution startProcessInstanceByKey(String processDefinitionKey) {
+    return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, null, null));
+  }
+  
+  public Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables){
+    return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, variables, null));
+  }
+  
+  public Execution startProcessInstanceByKey(String processDefinitionKey, String executionKey) {
+    return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, null, executionKey));
+  }
+
+  public Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String executionKey){
+    return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, variables, executionKey));
+  }
+
+  
+  
+  public Execution signalExecutionById(String executionId) {
+    return commandService.execute(new SignalCmd(executionId, null, null));
+  }
+
+  public Execution signalExecutionById(String executionId, String signalName) {
+    return commandService.execute(new SignalCmd(executionId, signalName, null));
+  }
+
+  public Execution signalExecutionById(String executionId, String signalName, Map<String, Object> parameters) {
+    return commandService.execute(new SignalCmd(executionId, signalName, parameters));
+  }
+
+  public Execution signalExecutionById(String executionId, Map<String, Object> parameters) {
+    return commandService.execute(new SignalCmd(executionId, null, parameters));
+  }
+
+
+  public Execution signalExecutionByKey(String processDefinitionKey, String executionKey) {
+    return signalExecutionById(processDefinitionKey+"/"+executionKey, null, null);
+  }
+
+  public Execution signalExecutionByKey(String processDefinitionKey, String executionKey, String signalName) {
+    return signalExecutionById(processDefinitionKey+"/"+executionKey, signalName, null);
+  }
+
+  public Execution signalExecutionByKey(String processDefinitionKey, String executionKey, String signalName, Map<String, Object> parameters) {
+    return signalExecutionById(processDefinitionKey+"/"+executionKey, signalName, parameters);
+  }
+
+  public Execution signalExecutionByKey(String processDefinitionKey, String executionKey, Map<String, Object> parameters) {
+    return signalExecutionById(processDefinitionKey+"/"+executionKey, null, parameters);
+  }
+
+
+ 
+  public Execution findExecution(String processDefinitionName, String key) {
+    return commandService.execute(new FindExecutionCmd(processDefinitionName, key));
+  }
+  
+  public Execution findExecution(String executionId) {
+    return commandService.execute(new FindExecutionCmd(executionId));
+  }
+  
+  public List<Execution> findExecutions(String executionId) {
+    return commandService.execute(new FindExecutionsCmd(executionId));
+  }
+
+  public ExecutionQuery createExecutionQuery() {
+    return new ExecutionQueryImpl(commandService, false);
+  }
+
+  public ExecutionQuery createProcessInstanceQuery() {
+    return new ExecutionQueryImpl(commandService, true);
+  }
+
+  public void endProcessInstance(String processInstanceId, String state) {
+    commandService.execute(new EndProcessInstance(processInstanceId, state));
+  }
+
+  public void deleteProcessInstance(String processInstanceId) {
+    commandService.execute(new DeleteProcessInstance(processInstanceId));
+  }
+
+  public Object getVariable(String executionId, String variableName) {
+    Set<String> variableNames = new HashSet<String>();
+    variableNames.add(variableName);
+    Map<String, Object> variables = commandService.execute(new GetVariablesCmd(executionId, variableNames));
+    return variables.get(variableName);
+  }
+
+  public Set<String> getVariableNames(String executionId) {
+    return commandService.execute(new GetVariableNamesCmd(executionId));
+  }
+
+  public Map<String, Object> getVariables(String executionId, Set<String> variableNames) {
+    return commandService.execute(new GetVariablesCmd(executionId, variableNames));
+  }
+
+  public Execution setVariable(String executionId, String name, Object value) {
+    SetVariablesCmd cmd = new SetVariablesCmd(executionId);
+    cmd.addVariable(name, value);
+    return commandService.execute(cmd);
+  }
+
+  public Execution setVariables(String executionId, Map<String, Object> variables) {
+    SetVariablesCmd cmd = new SetVariablesCmd(executionId);
+    cmd.setVariables(variables);
+    return commandService.execute(cmd);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import java.util.Map;
+
+import org.jbpm.HistoryService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.history.HistoryActivityInstanceQuery;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
+import org.jbpm.pvm.internal.query.ChoiceDistributionQueryCmd;
+import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryServiceImpl implements HistoryService {
+  
+  protected CommandService commandService;
+
+  public Map<String, Long> avgDurationPerActivity(String processDefinitionId) {
+    return (Map) commandService.execute(new AvgDurationPerActivityQueryCmd(processDefinitionId));
+  }
+
+  public Map<String, Integer> choiceDistribution(String processDefinitionId, String activityName) {
+    return (Map) commandService.execute(new ChoiceDistributionQueryCmd(processDefinitionId, activityName));
+  }
+
+  public HistoryProcessInstanceQuery createHistoryProcessInstanceQuery() {
+    return new HistoryProcessInstanceQueryImpl(commandService);
+  }
+
+  public HistoryActivityInstanceQuery createHistoryActivityInstanceQuery(String processDefinitionId) {
+    return new HistoryActivityInstanceQueryImpl(commandService, processDefinitionId);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Interceptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Interceptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Interceptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.internal.log.Log;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class Interceptor implements CommandService {
+
+  private static final Log log = Log.getLog(Interceptor.class.getName());
+  
+  protected CommandService next;
+
+  public CommandService getNext() {
+    return next;
+  }
+  public void setNext(CommandService next) {
+    this.next = next;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.JobQuery;
+import org.jbpm.ManagementService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceImpl implements ManagementService {
+
+  protected CommandService commandService;
+
+  public void executeJob(long jobDbid) {
+    commandService.execute(new ExecuteJobCmd(jobDbid));
+  }
+
+  public JobQuery createJobQuery() {
+    return new JobQueryImpl(commandService);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import java.util.List;
+
+import org.jbpm.Deployment;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.ProcessService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.cmd.DeleteProcessDefinitionCmd;
+import org.jbpm.pvm.internal.cmd.DeployCmd;
+import org.jbpm.pvm.internal.cmd.FindLatestProcessDefinitionByKeyCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionByIdCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionKeysCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsByKeyCmd;
+import org.jbpm.pvm.internal.cmd.GetAttachment;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
+
+/** {@link ProcessService} implementation that delegates execution of the 
+ * methods to a {@link CommandService}.
+ * 
+ * @author Tom Baeyens
+ */
+public class ProcessServiceImpl implements ProcessService {
+
+  protected CommandService commandService;
+
+  public Deployment createDeployment() {
+    return new DeploymentImpl(this);
+  }
+
+  public List<String> findProcessDefinitionKeys() {
+    return commandService.execute(new FindProcessDefinitionKeysCmd());
+  }
+
+  public ProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey) {
+    return commandService.execute(new FindLatestProcessDefinitionByKeyCmd(processDefinitionKey));
+  }
+
+  public List<ProcessDefinition> findProcessDefinitionsByKey(String processDefinitionName) {
+    return (List)commandService.execute(new FindProcessDefinitionsByKeyCmd(processDefinitionName));
+  }
+
+  public ProcessDefinition findProcessDefinitionById(String processDefinitionId) {
+    return commandService.execute(new FindProcessDefinitionByIdCmd(processDefinitionId));
+  }
+
+  public void deleteProcessDefinition(String processDefinitionId) {
+    commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId));
+  }
+
+  public void deleteProcessDefinitionCascade(String processDefinitionId) {
+    commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId, true, true));
+  }
+
+  public byte[] getAttachment(String processDefinitionId, String name) {
+    return commandService.execute(new GetAttachment(processDefinitionId, name));
+  }
+  
+
+  public ProcessDefinitionQuery createProcessDefinitionQuery() {
+    return new ProcessDefinitionQueryImpl(commandService);
+  }
+
+  public List<ProcessDefinition> deploy(Deployment deployment) {
+    return commandService.execute(new DeployCmd((DeploymentImpl)deployment));
+  }
+
+  public List<ProcessDefinition> deploy(OpenProcessDefinition processDefinition) {
+    DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+    return commandService.execute(new DeployCmd(deploymentImpl));
+  }
+  
+  public CommandService getCommandService() {
+    return commandService;
+  }
+  public void setCommandService(CommandService commandService) {
+    this.commandService = commandService;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/RetryInterceptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.svc;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.internal.log.Log;
+
+import org.hibernate.StaleStateException;
+
+/** retries the command execution in case hibernate throws optimistic locking 
+ * (StaleObjectException) exceptions.
+ * 
+ * @author Tom Baeyens
+ */
+public class RetryInterceptor extends Interceptor {
+
+  private static final Log log = Log.getLog(RetryInterceptor.class.getName());
+  
+  int retries = 3;
+  long delay = 50;
+  long delayFactor = 4;
+
+  public <T> T execute(Command<T> command) {
+    int attempt = 1;
+    long sleepTime = delay;
+    while (attempt<=retries) {
+      if (attempt>1) {
+        log.trace("retrying...");
+      }
+      try {
+        
+        return next.execute(command);
+        
+      } catch (StaleStateException e) {
+        attempt++;
+        log.trace("optimistic locking failed: "+e);
+        log.trace("waiting "+sleepTime+" millis");
+        try {
+          Thread.sleep(sleepTime);
+        } catch (InterruptedException e1) {
+          log.trace("retry sleeping got interrupted");
+        }
+        sleepTime *= delayFactor;
+      }
+    }
+    throw new JbpmException("gave up after "+attempt+" attempts");
+  }
+
+  public int getRetries() {
+    return retries;
+  }
+  public void setRetries(int retries) {
+    this.retries = retries;
+  }
+  public long getDelay() {
+    return delay;
+  }
+  public void setDelay(long delay) {
+    this.delay = delay;
+  }
+  public long getDelayFactor() {
+    return delayFactor;
+  }
+  public void setDelayFactor(long delayFactor) {
+    this.delayFactor = delayFactor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.model.Activity;
+import org.jbpm.model.IdGenerator;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycle extends ProcessDefinitionImpl {
+  
+  private static final long serialVersionUID = 1L;
+  private static LifeCycleParser lifeCycleParser = new LifeCycleParser();
+  private static Map<String, ProcessDefinitionImpl> lifeCycleProcesses = new HashMap<String, ProcessDefinitionImpl>();
+
+  public static String initialise(TaskImpl task) {
+    ProcessDefinitionImpl lifeCycle = getLifeCycle(task);
+    Map<String, Object> lifeCycleVariables = new HashMap<String, Object>();
+    lifeCycleVariables.put("task", task);
+    ClientProcessInstance lifeCycleExecution = lifeCycle.createProcessInstance();
+    lifeCycleExecution.setVariables(lifeCycleVariables);
+    lifeCycleExecution.start();
+    return lifeCycleExecution.getActivity().getName();
+  }
+
+  public static ProcessDefinitionImpl getLifeCycle(TaskImpl task) {
+    if (task==null) {
+      throw new JbpmException("task is null");
+    }
+    String resource = task.getLifeCycleResource();
+    if (resource==null) {
+      throw new JbpmException("task "+task.getClass().getName()+" did'nt return a lifecycle");
+    }
+    ProcessDefinitionImpl lifeCycleProcess;
+    synchronized (lifeCycleProcesses) { 
+      lifeCycleProcess = lifeCycleProcesses.get(resource);
+      if (lifeCycleProcess==null) {
+        lifeCycleProcess = (ProcessDefinitionImpl) lifeCycleParser
+            .createParse()
+            .setResource(resource)
+            .execute()
+            .checkProblems("task lifecycle")
+            .getDocumentObject();
+        lifeCycleProcesses.put(resource, lifeCycleProcess);
+      }
+    }
+    return lifeCycleProcess;
+  }
+
+  protected static void fireLifeCycleEvent(String eventName, TaskImpl task) {
+    ExecutionImpl lifeCycleExecution = new ExecutionImpl();
+    ProcessDefinitionImpl lifeCycleProcess = getLifeCycle(task);
+    lifeCycleExecution.setProcessDefinition(lifeCycleProcess);
+    String state = task.getState();
+    Activity activity = lifeCycleProcess.getActivity(state);
+    lifeCycleExecution.setActivity((ActivityImpl) activity);
+    lifeCycleExecution.signal(eventName);
+    task.state = lifeCycleExecution.getActivity().getName();
+  }
+
+  public IdGenerator getIdGenerator() {
+    // overrides the default ProcessDefinitionImpl behaviour that will end up 
+    // in the execution being persisted
+    return null;
+  }
+
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycleParser extends Parser {
+
+  public Object parseDocumentElement(Element element, Parse parse) {
+    ProcessDefinitionImpl lifeCycleProcess = new LifeCycle();
+    
+    List<Element> stateElements = XmlUtil.elements(element, "state");
+    for (Element stateElement: stateElements) {
+      parseState(stateElement, lifeCycleProcess, parse);
+    }
+    for (Element stateElement: stateElements) {
+      parseTransitions(stateElement, lifeCycleProcess, parse);
+    }
+    
+    String initialStateName = null;
+    if (element.hasAttribute("initial")) {
+      initialStateName = element.getAttribute("initial");
+      ActivityImpl initial = (ActivityImpl) lifeCycleProcess.getActivity(initialStateName);
+      if (initial!=null) {
+        lifeCycleProcess.setInitial(initial);
+      } else {
+        parse.addProblem("initial "+initialStateName+" doesn't exist");
+      }
+    }
+    
+    return lifeCycleProcess;
+  }
+
+  public void parseTransitions(Element element, ProcessDefinitionImpl lifeCycleProcess, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("state doesn't have a name: "+XmlUtil.toString(element));
+      return;
+    }
+    String stateName = element.getAttribute("name");
+    ActivityImpl state = (ActivityImpl) lifeCycleProcess.getActivity(stateName);
+    
+    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+    for (Element transitionElement: transitionElements) {
+      parseTransition(transitionElement, state, parse);
+    }
+  }
+
+  public void parseTransition(Element element, ActivityImpl state, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("transition doesn't have a name: "+XmlUtil.toString(element));
+      return;
+    }
+    String transitionName = element.getAttribute("name");
+    if (! element.hasAttribute("to")) {
+      parse.addProblem("transition "+transitionName+" doesn't have a to attribute indicating the destination state: "+XmlUtil.toString(element));
+      return;
+    }
+    String destinationName = element.getAttribute("to");
+    ActivityImpl destination = (ActivityImpl) state.getProcessDefinition().getActivity(destinationName);
+    if (destination!=null) {
+      state.createOutgoingTransition(destination, transitionName);
+    } else {
+      parse.addProblem("destination "+destinationName+" of "+transitionName+" is unknown");
+    }
+  }
+
+  public void parseState(Element element, ProcessDefinitionImpl lifeCycleProcess, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("state doesn't have an id: "+XmlUtil.toString(element));
+      return;
+    }
+    String stateName = element.getAttribute("name");
+    ActivityImpl state = lifeCycleProcess.createActivity(stateName);
+    state.setBehaviour(new LifeCycleState());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycleState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName,
+      Map<String, Object> parameters) throws Exception {
+    execution.take(signalName);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.UserRef;
+
+
+/** the relation between a task and a person.
+ * @author Tom Baeyens
+ */
+public class ParticipantImpl implements Serializable, Participant {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  
+  protected String identityType; 
+  protected String identityId;
+  protected String participation;
+  protected TaskImpl task;
+  protected SwimlaneImpl swimlane;
+  
+  public ParticipantImpl() {
+  }
+  
+  public ParticipantImpl(IdentityRef identityRef, String participation) {
+    setIdentityRef(identityRef);
+    this.participation = participation;
+  }
+  
+  public IdentityRef getIdentityRef() {
+    if ("U".equals(identityType)) {
+      return new UserRef(identityId);
+    }
+    return new GroupRef(identityId);
+  }
+
+  public void setIdentityRef(IdentityRef identityRef) {
+    if (identityRef==null) {
+      throw new JbpmException("identityRef is null");
+    }
+
+    if (identityRef instanceof UserRef) {
+      identityType = "U";
+    } else if (identityRef instanceof GroupRef) {
+      identityType = "G";
+    } else {
+      throw new JbpmException("invalid identity type: "+identityRef.getClass().getName());
+    }
+    
+    identityId = identityRef.getId();
+  }
+
+  public TaskImpl getTask() {
+    return task;
+  }
+  public void setTask(TaskImpl task) {
+    this.task = task;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+  public SwimlaneImpl getSwimlane() {
+    return swimlane;
+  }
+  public void setSwimlane(SwimlaneImpl swimlane) {
+    this.swimlane = swimlane;
+  }
+  public String getParticipation() {
+    return participation;
+  }
+  public void setParticipation(String participation) {
+    this.participation = participation;
+  }
+  public String getIdentityId() {
+    return identityId;
+  }
+  public void setIdentityId(String identityId) {
+    this.identityId = identityId;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneDefinitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.util.EqualsUtil;
+
+/**
+ * is a process role (aka participant).
+ */
+public class SwimlaneDefinitionImpl implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String name = null;
+
+  /**
+   * expression that resolves to 1 single actorId.
+   */
+  protected String actorIdExpression = null;
+
+  /**
+   * expression that resolves to a comma separated list of actorIds.
+   */
+  protected String candidatesExpression = null;
+
+  /**
+   * expression that resolves to an AssignmentHandler implementation.
+   */
+  protected String assignmentExpression = null;
+
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  public void setActorIdExpression(String actorIdExpression) {
+    // Note: combination of actorIdExpression and candidatesExpression is allowed 
+    this.actorIdExpression = actorIdExpression;
+    this.assignmentExpression = null;
+  }
+  public void setCandidatesExpression(String pooledActorsExpression) {
+    // Note: combination of actorIdExpression and pooledActorsExpression is allowed 
+    this.candidatesExpression = pooledActorsExpression;
+    this.assignmentExpression = null;
+  }
+  public void setAssignmentExpression(String assignmentExpression) {
+    // assignment expressions and assignmentDelegation are mutually exclusive
+    this.actorIdExpression = null;
+    this.candidatesExpression = null;
+    this.assignmentExpression = assignmentExpression;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getName() {
+    return name;
+  }
+  public String getActorIdExpression() {
+    return actorIdExpression;
+  }
+  public String getCandidatesExpression() {
+    return candidatesExpression;
+  }
+  public String getAssignmentExpression() {
+    return assignmentExpression;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Swimlane;
+
+/**
+ * runtime process role for a specific process instance.
+ */
+public class SwimlaneImpl implements Serializable, Swimlane {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String name = null;
+  protected String assignee = null;
+  protected Set<ParticipantImpl> participants = null;
+  protected SwimlaneDefinitionImpl swimlaneDefinition = null;
+  
+  // assignment methods ///////////////////////////////////////////////////////
+
+  public String getAssignee() {
+    return assignee;
+  }
+
+  public void setAssignee(String assignee) {
+    this.assignee = assignee;
+  }
+
+  // participants /////////////////////////////////////////////////////////////
+
+  // participants /////////////////////////////////////////////////////////////
+  
+  public Set<ParticipantImpl> getParticipants() {
+    if (participants==null) {
+      return Collections.emptySet();
+    }
+    return participants;
+  }
+
+  public Participant addParticipant(IdentityRef identityRef, String participation) {
+    if (identityRef==null) {
+      throw new JbpmException("identityRef is null");
+    }
+    if (participation==null) {
+      throw new JbpmException("participation is null");
+    }
+    ParticipantImpl participant = new ParticipantImpl(identityRef, participation);
+    participant.setSwimlane(this);
+    if (participants==null) {
+      participants = new HashSet<ParticipantImpl>();
+    }
+    participants.add(participant);
+    return participant;
+  }
+
+  public void removeParticipant(ParticipantImpl participant) {
+    if (participant==null) {
+      throw new JbpmException("participant is null");
+    }
+    if ( (participants!=null)
+         && (participants.remove(participant))
+       ) {
+      ((ParticipantImpl)participant).setSwimlane(null);
+    }
+  }
+  
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+  
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getName() {
+    return name;
+  }
+  public SwimlaneDefinitionImpl getSwimlaneDefinition() {
+    return swimlaneDefinition;
+  }
+  public void setSwimlaneDefinition(SwimlaneDefinitionImpl swimlaneDefinition) {
+    this.swimlaneDefinition = swimlaneDefinition;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.model.ProcessElementImpl;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ * defines a task and how the actor(s) must be calculated at runtime.
+ */
+public class TaskDefinitionImpl extends ProcessElementImpl implements Serializable {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String name;
+  protected String description;
+
+  /** @see #isBlocking() */
+  protected boolean isBlocking;
+  
+  /** @see #isSignalling() */
+  protected boolean isSignalling = true;
+
+  protected String dueDateDuration;
+  protected List<TaskDefinitionImpl> subTaskDefinitions;
+  protected int priority = Priority.NORMAL;
+  protected SwimlaneDefinitionImpl swimlaneDefinition;
+  protected String assigneeExpression;
+  protected String candidatesExpression;
+  protected Descriptor assignerDescriptor;
+  
+
+  public String getForm() {
+    return (String) (properties!=null ? properties.get("form") : null);
+  }
+  
+  public ObservableElement getParent() {
+    // TODO Auto-generated method stub
+    // huh ?
+    return null;
+  }
+
+  public boolean hasEvent(String eventName) {
+    // TODO Auto-generated method stub
+    // huh ?
+    return false;
+  }
+
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public String getAssigneeExpression() {
+    return assigneeExpression;
+  }
+  public void setAssigneeExpression(String assigneeExpression) {
+    this.assigneeExpression = assigneeExpression;
+  }
+  public Descriptor getAssignerDescriptor() {
+    return assignerDescriptor;
+  }
+  public void setAssignerDescriptor(Descriptor assignerDescriptor) {
+    this.assignerDescriptor = assignerDescriptor;
+  }
+  public String getCandidatesExpression() {
+    return candidatesExpression;
+  }
+  public void setCandidatesExpression(String candidatesExpression) {
+    this.candidatesExpression = candidatesExpression;
+  }
+  public boolean isBlocking() {
+    return isBlocking;
+  }
+  public void setBlocking(boolean isBlocking) {
+    this.isBlocking = isBlocking;
+  }
+  public boolean isSignalling() {
+    return isSignalling;
+  }
+  public void setSignalling(boolean isSignalling) {
+    this.isSignalling = isSignalling;
+  }
+  public int getPriority() {
+    return priority;
+  }
+  public void setPriority(int priority) {
+    this.priority = priority;
+  }
+  public List<TaskDefinitionImpl> getSubTaskDefinitions() {
+    return subTaskDefinitions;
+  }
+  public void setSubTaskDefinitions(List<TaskDefinitionImpl> subTaskDefinitions) {
+    this.subTaskDefinitions = subTaskDefinitions;
+  }
+  public SwimlaneDefinitionImpl getSwimlaneDefinition() {
+    return swimlaneDefinition;
+  }
+  public void setSwimlaneDefinition(SwimlaneDefinitionImpl swimlaneDefinition) {
+    this.swimlaneDefinition = swimlaneDefinition;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public String getDueDateDuration() {
+    return dueDateDuration;
+  }
+  public void setDueDateDuration(String dueDateDuration) {
+    this.dueDateDuration = dueDateDuration;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskExecution.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskExecution.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskExecution.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.Map;
+
+import org.jbpm.task.Swimlane;
+import org.jbpm.task.Task;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TaskExecution {
+
+  Map<String, ? extends Task> getTasks();
+  Map<String, ? extends Swimlane> getSwimlanes();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,382 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Swimlane;
+import org.jbpm.task.Task;
+
+/**
+ * is one task instance that can be assigned to an actor (read: put in 
+ * someones task list) and that can trigger the continuation of execution 
+ * of the token upon completion.
+ */
+public class TaskImpl extends ScopeInstanceImpl implements Serializable, Task {
+
+  private static final long serialVersionUID = 1L;
+  // private static final Logger log = Logger.getLogger(TaskImpl.class.getName());
+  
+  protected String id;
+  protected String name;
+  protected String description;
+
+  protected String assignee;
+  protected Set<ParticipantImpl> participants;
+
+  protected Date create;
+  protected Date dueDate;
+  protected Integer progress;
+
+  // protected VariableMap variableMap;
+  protected List<CommentImpl> comments;
+
+  protected int priority = Priority.NORMAL;
+
+  protected String state;
+
+  protected ExecutionImpl execution;
+  protected boolean isSignalling = true;
+  protected boolean isBlocking;
+
+  protected SwimlaneImpl swimlane;
+  
+  protected TaskImpl superTask;
+  protected Set<TaskImpl> subTasks;
+  
+  protected TaskImpl() {
+  }
+  
+  // creating a task
+
+  public static TaskImpl create() {
+    TaskImpl task = new TaskImpl();
+
+    /*
+    // if a task class name is configured
+    Environment environment = Environment.getCurrent();
+    String taskClassName = environment!=null ? (String) environment.get(TaskImpl.CONTEXTKEY_TASK_CLASS_NAME, TaskImpl.SEARCHORDER_TASK_CLASS_NAME) : null;
+    if (taskClassName!=null) {
+      // dynamically instantiate it
+      ClassLoader classLoader = environment.getClassLoader();
+      Class<?> taskClass = ReflectUtil.loadClass(classLoader, taskClassName);
+      task = (TaskImpl) ReflectUtil.newInstance(taskClass);
+    }
+    // otherwise just use the default task implementation type 
+    else {
+      task = new TaskImpl();
+    }
+    */
+
+    task.setCreate(Clock.getCurrentTime());
+
+    // initialise the task state
+    task.state = LifeCycle.initialise(task); 
+
+    return task;
+  }
+
+  public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
+    if (taskDefinition!=null) {
+      this.name = taskDefinition.getName();
+      this.description = taskDefinition.getDescription();
+      this.isBlocking = taskDefinition.isBlocking();
+      this.isSignalling = taskDefinition.isSignalling();
+      this.priority = taskDefinition.getPriority();
+      
+      String durationText = taskDefinition.getDueDateDuration();
+      if (durationText!=null) {
+        this.dueDate = calculateDueDate(new Duration(durationText));
+      }
+    }
+  }
+  
+  protected static Date calculateDueDate(Duration dueDate) {
+    // TODO
+    return null;
+  }
+
+  // participants /////////////////////////////////////////////////////////////
+  
+  public Set<ParticipantImpl> getParticipants() {
+    if (participants==null) {
+      return Collections.emptySet();
+    }
+    return participants;
+  }
+
+  public Set<ParticipantImpl> getAllParticipants() {
+    Set<ParticipantImpl> allRoles = null;
+    if (participants!=null) {
+      allRoles = new HashSet<ParticipantImpl>(participants);
+    } else {
+      allRoles = new HashSet<ParticipantImpl>();
+    }
+    if (swimlane!=null) {
+      allRoles.addAll((Set)swimlane.getParticipants());
+    }
+    return allRoles;
+  }
+
+  public Participant addParticipant(IdentityRef identityRef, String participation) {
+    if (identityRef==null) {
+      throw new JbpmException("identityRef is null");
+    }
+    if (participation==null) {
+      throw new JbpmException("participation is null");
+    }
+    ParticipantImpl participant = new ParticipantImpl(identityRef, participation);
+    participant.setTask(this);
+    if (participants==null) {
+      participants = new HashSet<ParticipantImpl>();
+    }
+    participants.add(participant);
+    return participant;
+  }
+
+  public void removeParticipant(ParticipantImpl participant) {
+    if (participant==null) {
+      throw new JbpmException("participant is null");
+    }
+    if ( (participants!=null)
+         && (participants.remove(participant))
+       ) {
+      ((ParticipantImpl)participant).setTask(null);
+    }
+  }
+  
+  // completion ///////////////////////////////////////////////////////////////
+
+  public void submit() {
+    if (execution!=null) {
+      // the outcome is dynamically calculated based on e.g. a 
+      // variable or a decision table on a variable.  an 
+      // interface OutcomeEvaluator for user defined outcome calculation 
+      // could be envisioned.
+      String outcome = evaluateOutcome();
+      // the outcome serves as the signal given to the execution.
+      execution.signal(outcome);
+    }
+  }
+
+  public String evaluateOutcome() {
+    // for now, only the default signal can be given.
+    return null;
+  }
+
+  // comments /////////////////////////////////////////////////////////////////
+
+  public List<Comment> getComments() {
+    if (comments==null) {
+      return Collections.emptyList();
+    }
+    return (List) comments;
+  }
+
+  public Comment createComment(String commentText) {
+    if (comments==null) {
+      comments = new ArrayList<CommentImpl>();
+    }
+    CommentImpl comment = new CommentImpl(commentText);
+    comments.add(comment);
+    return comment;
+  }
+
+  public void removeComment(Comment comment) {
+    if (comment==null) {
+      throw new JbpmException("comment is null");
+    }
+    if (comments!=null) {
+      comments.remove(comment);
+    }
+  }
+  
+  // subtasks /////////////////////////////////////////////////////////////////
+  
+  public Set<Task> getSubTasks() {
+    if (subTasks==null) {
+      return Collections.emptySet();
+    }
+    return (Set) subTasks;
+  }
+
+  public Task createSubTask(String name) {
+    if (subTasks==null) {
+      subTasks = new HashSet<TaskImpl>();
+    }
+    TaskImpl subtask = new TaskImpl();
+    subtask.setName(name);
+    addSubTask(subtask);
+    return subtask;
+  }
+  
+  public Task addSubTask(TaskImpl subtask) {
+    if (subTasks==null) {
+      subTasks = new HashSet<TaskImpl>();
+    }
+    subtask.setSuperTask(this);
+    subTasks.add(subtask);
+    return subtask;
+  }
+
+  public void removeSubTask(Task subtask) {
+    if (subtask==null) {
+      throw new JbpmException("subtask is null");
+    }
+    if ( (subTasks!=null)
+         && (subTasks.remove(subtask))
+       ) {
+      ((TaskImpl)subtask).setSuperTask(null);
+    }
+  }
+  
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  public String getLifeCycleResource() {
+    // the default lifecycle can be overridden in subclasses
+    return "jbpm.task.default.lifecycle.xml";
+  }
+  
+  // modified getters and setters /////////////////////////////////////////////
+  public void setProgress(Integer progress) {
+    if ( (progress<0)
+         || (progress>100)
+       ) {
+      throw new JbpmException("task progress is a percentage (integer) and must be expressed between 0 and 100");
+    }
+    this.progress = progress;
+  }
+
+  public boolean isPersisted() {
+    return dbid!=0;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public long getDbid() {
+    return dbid;
+  }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public boolean isBlocking() {
+    return isBlocking;
+  }
+  public void setBlocking(boolean isBlocking) {
+    this.isBlocking = isBlocking;
+  }
+  public boolean isSignalling() {
+    return isSignalling;
+  }
+  public void setSignalling(boolean isSignalling) {
+    this.isSignalling = isSignalling;
+  }
+  public int getPriority() {
+    return priority;
+  }
+  public void setPriority(int priority) {
+    this.priority = priority;
+  }
+  public void setComments(List<CommentImpl> comments) {
+    this.comments = comments;
+  }
+  public Date getCreate() {
+    return create;
+  }
+  public void setCreate(Date create) {
+    this.create = create;
+  }
+  public Date getDueDate() {
+    return dueDate;
+  }
+  public void setDueDate(Date dueDate) {
+    this.dueDate = dueDate;
+  }
+  public ExecutionImpl getExecution() {
+    return execution;
+  }
+  public void setExecution(Execution execution) {
+    this.execution = (ExecutionImpl) execution;
+  }
+  public String getState() {
+    return state;
+  }
+  public String getAssignee() {
+    return assignee;
+  }
+  public void setAssignee(String assignedUserId) {
+    this.assignee = assignedUserId;
+  }
+  public Swimlane getSwimlane() {
+    return swimlane;
+  }
+  public void setSwimlane(SwimlaneImpl swimlane) {
+    this.swimlane = swimlane;
+  }
+  public TaskImpl getSuperTask() {
+    return superTask;
+  }
+  public void setSuperTask(TaskImpl superTask) {
+    this.superTask = superTask;
+  }
+  public Integer getProgress() {
+    return progress;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.TaskQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.query.AbstractQuery;
+import org.jbpm.pvm.internal.query.Page;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryImpl extends AbstractQuery implements TaskQuery {
+  
+  private static final long serialVersionUID = 1L;
+
+  private static final String UNASSIGNED = "unassigned";
+
+  protected String assignee = null;
+
+  public TaskQueryImpl(CommandService commandService) {
+    super(commandService);
+  }
+  
+  public TaskQuery assignee(String assignee) {
+    this.assignee = assignee;
+    return this;
+  }
+
+  public TaskQuery unassigned() {
+    this.assignee = UNASSIGNED;
+    return this;
+  }
+
+  public TaskQuery orderAsc(String property) {
+    orderByClause = "task."+property+" asc ";
+    return this;
+  }
+
+  public TaskQuery orderDesc(String property) {
+    orderByClause = "task."+property+" desc ";
+    return this;
+  }
+
+  public TaskQuery page(int firstResult, int maxResults) {
+    page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public List<Task> execute() {
+    return (List<Task>) commandService.execute(this);
+  }
+
+  protected void applyParameters(Query query) {
+    if ( (assignee!=UNASSIGNED) && (assignee!=null) ) {
+      query.setString("assignee", assignee);
+    }
+  }
+
+  public String hql() {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select task ");
+    hql.append("from ");
+    hql.append(TaskImpl.class.getName());
+    hql.append(" as task ");
+    
+    if (assignee==UNASSIGNED) {
+      appendWhereClause("task.assignee is null ", hql);
+    } else if (assignee!=null) {
+      appendWhereClause("task.assignee = :assignee ", hql);
+    }
+    
+    appendOrderByClause(hql);
+
+    return hql.toString();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.task;
+
+import java.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.TaskService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.AddParticipantCmd;
+import org.jbpm.pvm.internal.cmd.AddReplyCommentCmd;
+import org.jbpm.pvm.internal.cmd.AddTaskCommentCmd;
+import org.jbpm.pvm.internal.cmd.DeleteCommentCmd;
+import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetParticipantsCmd;
+import org.jbpm.pvm.internal.cmd.GetSubTasksCmd;
+import org.jbpm.pvm.internal.cmd.GetTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetTaskCommentsCmd;
+import org.jbpm.pvm.internal.cmd.NewTaskCmd;
+import org.jbpm.pvm.internal.cmd.RemoveParticipantCmd;
+import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
+import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceImpl implements TaskService {
+
+  protected CommandService commandService;
+
+  public TaskServiceImpl() {
+  }
+
+  public TaskServiceImpl(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  public CommandService getCommandService() {
+    return commandService;
+  }
+
+  public void setCommandService(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  public Task newTask() {
+    return commandService.execute(new NewTaskCmd(null, null));
+  }
+
+  public Task getTask(long taskDbid) {
+    return commandService.execute(new GetTaskCmd(taskDbid));
+  }
+
+  public void saveTask(Task task) {
+    commandService.execute(new SaveTaskCmd((TaskImpl) task));
+  }
+
+  public void deleteTask(long taskDbid) {
+    commandService.execute(new DeleteTaskCmd(taskDbid));
+  }
+
+  public void submitTask(long taskDbid) {
+    commandService.execute(new SubmitTaskCmd(taskDbid));
+  }
+
+  public void submitTask(Task task) {
+    commandService.execute(new SubmitTaskCmd((TaskImpl)task));
+  }
+
+  public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+    commandService.execute(new AddParticipantCmd(taskDbid, null, identityRef, participation));
+  }
+
+  public List<Participant> getTaskParticipants(long taskDbid) {
+    return commandService.execute(new GetParticipantsCmd(taskDbid, null));
+  }
+
+  public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+    commandService.execute(new RemoveParticipantCmd(taskDbid, null, identityRef, participation));
+  }
+
+  public void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+    commandService.execute(new AddParticipantCmd(null, szimlaneDbid, identityRef, participation));
+  }
+
+  public List<Participant> getSwimlaneParticipants(long szimlaneDbid) {
+    return commandService.execute(new GetParticipantsCmd(null, szimlaneDbid));
+  }
+
+  public void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+    commandService.execute(new RemoveParticipantCmd(null, szimlaneDbid, identityRef, participation));
+  }
+
+  public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
+    return createTaskQuery()
+      .assignee(assignee)
+      .orderDesc(TaskQuery.PROPERTY_PRIORITY)
+      .page(firstResult, maxResults)
+      .execute();
+  }
+
+  public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
+    return null;
+  }
+
+  public TaskQuery createTaskQuery() {
+    return new TaskQueryImpl(commandService);
+  }
+
+  public List<Task> getSubTasks(long taskDbid) {
+    return commandService.execute(new GetSubTasksCmd(taskDbid));
+  }
+
+  public Task newTask(long parentTaskDbid) {
+    return commandService.execute(new NewTaskCmd(parentTaskDbid, null));
+  }
+
+  public Comment addTaskComment(long taskDbid, String message) {
+    return commandService.execute(new AddTaskCommentCmd(taskDbid, message));
+  }
+
+  public List<Comment> getTaskComments(long taskDbid) {
+    return commandService.execute(new GetTaskCommentsCmd(taskDbid));
+  }
+
+  public void deleteComment(long commentDbid) {
+    commandService.execute(new DeleteCommentCmd(commentDbid));
+  }
+
+  public Comment addReplyComment(long commentDbid, String message) {
+    return commandService.execute(new AddReplyCommentCmd(commentDbid, message));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.test;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.job.TimerImpl;
+
+
+/** helper class for testing that executes messages and timers
+ * in the test runner thread.  This way, the test can simulate 
+ * timers and messages being executed.  The dueDate is ignored.
+ * 
+ * @author Tom Baeyens
+ */
+public class JobTestHelper {
+  
+  CommandService commandService;
+  
+  public Execution executeMessage(final long executionDbid) {
+    return commandService.execute(new Command<Execution>() {
+      private static final long serialVersionUID = 1L;
+      public Execution execute(Environment environment) throws Exception {
+        Session session = environment.get(Session.class);
+        Query query = session.createQuery(
+            "select m.dbid " +
+            "from "+MessageImpl.class.getName()+" as m " +
+            "where m.execution.dbid = :executionDbid"
+        );
+        query.setLong("executionDbid", executionDbid);
+        query.setMaxResults(1);
+        Long messageDbid = (Long) query.uniqueResult();
+        ExecuteJobCmd executeJobCommand = new ExecuteJobCmd(messageDbid); 
+        Job job = executeJobCommand.execute(environment);
+        return job.getExecution();
+      }
+    });
+  }
+
+  public Execution executeTimer(final long timerDbid) {
+    return commandService.execute(new Command<Execution>() {
+      private static final long serialVersionUID = 1L;
+      public Execution execute(Environment environment) throws Exception {
+        Session session = environment.get(Session.class);
+        Query query = session.createQuery(
+            "select t.dbid " +
+            "from "+TimerImpl.class.getName()+" as t " +
+            "where t.dbid = :timerDbid"
+        );
+        query.setLong("timerDbid", timerDbid);
+        query.setMaxResults(1);
+        Long timerDbid = (Long) query.uniqueResult();
+        ExecuteJobCmd executeJobCommand = new ExecuteJobCmd(timerDbid); 
+        Job job = executeJobCommand.execute(environment);
+        return job.getExecution();
+      }
+    });
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.hibernate.Session;
+import org.jbpm.internal.log.Log;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionResource implements StandardResource {
+  
+  private static final Log log = Log.getLog(HibernateSessionResource.class.getName());
+
+  protected Session session;
+  protected org.hibernate.Transaction transaction;
+  
+  public HibernateSessionResource(Session session) {
+    this.session = session;
+    if (log.isTraceEnabled()) log.trace("beginning transaction on hibernate session "+System.identityHashCode(session));
+    
+    try {
+      this.transaction = session.beginTransaction();
+    } catch (RuntimeException e) {
+      log.error("hibernate transaction begin failed.  closing hibernate session", e);
+      session.close();
+      throw e;
+    }
+
+    log.debug("begun hibernate transaction "+System.identityHashCode(transaction)+" on hibernate session "+System.identityHashCode(session));
+  }
+
+  public void prepare() {
+    log.debug("flushing hibernate session "+System.identityHashCode(session));
+    session.flush();
+  }
+
+  public void commit() {
+    log.debug("committing hibernate transaction "+System.identityHashCode(transaction));
+    try {
+      transaction.commit();
+    } finally {
+      closeSession();
+    }
+  }
+
+  private void closeSession() {
+    log.debug("closing hibernate session "+System.identityHashCode(session));
+    session.close();
+  }
+
+  public void rollback() {
+    log.debug("rolling back hibernate transaction "+System.identityHashCode(transaction));
+    try {
+      transaction.rollback();
+    } finally {
+      closeSession();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface StandardResource {
+
+  void prepare();
+
+  void commit();
+
+  void rollback();
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StandardSynchronization {
+  
+  Synchronization synchronization;
+  
+  public StandardSynchronization(Synchronization synchronization) {
+    this.synchronization = synchronization;
+  }
+
+  public void afterCompletion(StandardTransaction.State transactionState) {
+    if (transactionState==StandardTransaction.State.COMMITTED) {
+      synchronization.afterCompletion(Status.STATUS_COMMITTED);
+      
+    } else if (transactionState==StandardTransaction.State.ROLLEDBACK) {
+      synchronization.afterCompletion(Status.STATUS_ROLLEDBACK);
+      
+    } else {
+      throw new TransactionException("invalid transaction state: "+transactionState);
+    }
+  }
+
+  public void beforeCompletion() {
+    synchronization.beforeCompletion();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.Synchronization;
+
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+
+
+/** simple 2 phase commit transaction.
+ * no logging or recovery.
+ * non thread safe (which is ok).
+ * @author Tom Baeyens
+ */
+public class StandardTransaction implements Transaction, Serializable {
+
+  private static final long serialVersionUID = 1L; 
+  private static Log log = Log.getLog(StandardTransaction.class.getName());
+
+  enum State {
+    CREATED,
+    ACTIVE,
+    ROLLBACKONLY,
+    COMMITTED,
+    ROLLEDBACK
+  }
+
+  protected List<StandardResource> resources;
+  protected List<StandardSynchronization> synchronizations;
+  protected State state = State.CREATED;
+
+  // methods for interceptor //////////////////////////////////////////////////
+
+  public void begin() {
+    log.debug("beginning "+this);
+    state = State.ACTIVE;
+  }
+
+  public void complete() {
+    if (state==State.ACTIVE) {
+      commit();
+    } else if (state==State.ROLLBACKONLY){
+      rollback();
+    } else {
+      throw new TransactionException("complete on transaction in state "+state);
+    }
+  }
+
+  // public tx methods ////////////////////////////////////////////////////////
+
+  public void setRollbackOnly() {
+    if (state!=State.ACTIVE) {
+      throw new TransactionException("transaction was not active: "+state);
+    }
+    state = State.ROLLBACKONLY;
+  }
+
+  public boolean isRollbackOnly() {
+    return ( (state==State.ROLLBACKONLY)
+             || (state==State.ROLLEDBACK)
+           );
+  }
+  
+  // commit ///////////////////////////////////////////////////////////////////
+
+  /** implements simplest two phase commit. */
+  public void commit() {
+    if (state!=State.ACTIVE) {
+      throw new TransactionException("commit on transaction in state "+state);
+    }
+    
+    log.trace("committing "+this);
+
+    try {
+      beforeCompletion();
+
+      if (resources!=null) {
+        // prepare //////////////////////////////////////////////////////////////
+        // the prepare loop will be skipped at the first exception
+        for (StandardResource standardResource: resources) {
+          log.trace("preparing resource "+standardResource);
+          standardResource.prepare();
+        }
+      }
+
+    // for any exception in the prepare phase, we'll rollback
+    } catch (Exception exception) {
+      try {
+        log.debug("resource threw exception in prepare.  rolling back.");
+        rollbackResources();
+      } catch (Exception rollbackException) {
+        log.error("rollback failed as well", rollbackException);
+      }
+
+      // rethrow
+      if (exception instanceof RuntimeException) {
+        throw (RuntimeException) exception;
+      }
+      throw new TransactionException("prepare failed", exception);
+    }
+    
+    // here is the point of no return :-)
+
+    // commit ///////////////////////////////////////////////////////////////
+    Throwable commitException = null;
+    if (resources!=null) {
+      // The commit loop will try to send the commit to every resource, 
+      // No matter what it takes.  If exceptions come out of resource.commit's 
+      // they will be suppressed and the first exception will be rethrown after
+      // all the resources are commited 
+      for (StandardResource standardResource: resources) {
+        try {
+          log.trace("committing resource "+standardResource);
+          standardResource.commit();
+          
+        // Exceptions in the commit phase will not lead to rollback, since some resources
+        // might have committed and can't go back.
+        } catch (Throwable t) {
+          // TODO this should go to a special log for sys admin recovery
+          log.error("commit failed for resource "+standardResource, t);
+          if (commitException==null) {
+            commitException = t;
+          }
+        }
+      }
+    }
+    
+    state = State.COMMITTED;
+    afterCompletion();
+    log.debug("committed "+this);
+    
+    if (commitException!=null) {
+      if (commitException instanceof RuntimeException) {
+        throw (RuntimeException) commitException;
+      } else if (commitException instanceof Error) {
+        throw (Error) commitException;
+      }
+      throw new TransactionException("resource failed to commit", commitException);
+    }
+  }
+
+  // rollback /////////////////////////////////////////////////////////////////
+
+  public void rollback() {
+    if ( (state!=State.ACTIVE)
+         && (state!=State.ROLLBACKONLY)
+       ) {
+      throw new TransactionException("rollback on transaction in state "+state);
+    }
+
+    log.trace("rolling back "+this);
+
+    beforeCompletion();
+    rollbackResources();
+  }
+  
+
+  void rollbackResources() {
+    if (resources!=null) {
+      for (StandardResource resource: resources) {
+        try {
+          log.trace("rolling back resource "+resource);
+          resource.rollback();
+        } catch (Exception e) {
+          log.error("rollback failed for resource "+resource);
+        }
+      }
+    }
+
+    state = State.ROLLEDBACK;
+    
+    afterCompletion();
+
+    log.debug("rolled back");
+  }
+  
+  // synchronizations /////////////////////////////////////////////////////////
+
+  public void registerSynchronization(Synchronization synchronization) {
+    if (synchronizations==null) {
+      synchronizations = new ArrayList<StandardSynchronization>(); 
+    }
+    synchronizations.add(new StandardSynchronization(synchronization));
+  }
+
+  public void afterCompletion() {
+    if (synchronizations!=null) {
+      for (StandardSynchronization synchronization: synchronizations) {
+        synchronization.afterCompletion(state);
+      }
+    }
+  }
+
+  public void beforeCompletion() {
+    if (synchronizations!=null) {
+      for (StandardSynchronization synchronization: synchronizations) {
+        synchronization.beforeCompletion();
+      }
+    }
+  }
+
+  // resource enlisting ///////////////////////////////////////////////////////
+
+  public void enlistResource(StandardResource standardResource) {
+    if (resources==null) {
+      resources = new ArrayList<StandardResource>();
+    }
+    log.trace("enlisting resource "+standardResource+" to standard transaction");
+    resources.add(standardResource);
+  }
+
+  List<StandardResource> getResources() {
+    return resources;
+  }
+
+  public String toString() {
+    return "StandardTransaction["+System.identityHashCode(this)+"]";
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.Interceptor;
+
+
+/** calls setRollbackOnly on the transaction in the environment 
+ * in case an exception occurs during execution of the command.
+ * 
+ * @author Tom Baeyens
+ */
+public class StandardTransactionInterceptor extends Interceptor {
+  
+  private static final Log log = Log.getLog(StandardTransactionInterceptor.class.getName());
+  
+  public <T> T execute(Command<T> command) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new JbpmException("no environment for managing hibernate transaction");
+    }
+
+    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+    if (standardTransaction==null) {
+      throw new JbpmException("no standard-transaction in environment");
+    }
+    
+    standardTransaction.begin();
+
+    try {
+      return next.execute(command);
+      
+    } catch (RuntimeException e) {
+      standardTransaction.setRollbackOnly();
+      throw e;
+      
+    } finally {
+      standardTransaction.complete();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/TransactionException.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/TransactionException.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/TransactionException.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.JbpmException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionException extends JbpmException {
+
+  private static final long serialVersionUID = 1L;
+
+  public TransactionException(String msg) {
+    super(msg);
+  }
+
+  public TransactionException(Throwable cause) {
+    super(cause);
+  }
+
+  TransactionException(String msg, Throwable cause) {
+    super(msg, cause);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Converter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Converter extends Serializable {
+
+  /**
+   * is true if this converter supports the given type, false otherwise.
+   */
+  boolean supports(Object value);
+  
+  /**
+   * converts a given object to its persistable format.
+   */
+  Object convert(Object o);
+
+  /**
+   * reverts a persisted object to its original form.
+   */
+  Object revert(Object o);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/DefaultTypeSet.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/DefaultTypeSet.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/DefaultTypeSet.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DefaultTypeSet implements TypeSet, Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected List<TypeMapping> typeMappings;
+
+  public Type findTypeByMatch(String key, Object value) {
+    if (typeMappings!=null) {
+      for (TypeMapping typeMapping: typeMappings) {
+        if (typeMapping.matches(key, value)) {
+          return typeMapping.getType();
+        }
+      }
+    }
+    
+    return null;
+  }
+
+  public Type findTypeByName(String typeName) {
+    if ( (typeMappings!=null)
+           && (typeName!=null)
+       ) {
+      for (TypeMapping typeMapping: typeMappings) {
+        Type type = typeMapping.getType();
+        if (typeName.equals(type.getName())) {
+          return type;
+        }
+      }
+    }
+    return null;
+  }
+
+  public void addTypeMapping(TypeMapping typeMapping) {
+    if (typeMappings==null) {
+      typeMappings = new ArrayList<TypeMapping>();
+    }
+    typeMappings.add(typeMapping);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Matcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Matcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Matcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,9 @@
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+
+
+public interface Matcher extends Serializable {
+
+  boolean matches(String name, Object value);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Type.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Type.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Type.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.util.ReflectUtil;
+
+
+/** a variable type.
+ * @author Tom Baeyens
+ */
+public class Type implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String name;
+  protected Converter converter;
+  protected Class<?> variableClass;
+
+  public String toString() {
+    if (name!=null) {
+      return name;
+    }
+    StringBuffer buffer = new StringBuffer();
+    if (converter!=null) {
+      buffer.append(converter.toString());
+      buffer.append("-->");
+    }
+    if (variableClass!=null) {
+      buffer.append(ReflectUtil.getUnqualifiedClassName(variableClass));
+    } else {
+      buffer.append("undefined");
+    }
+    return buffer.toString();
+  }
+  
+  public Converter getConverter() {
+    return converter;
+  }
+  public void setConverter(Converter converter) {
+    this.converter = converter;
+  }
+  public Class< ? > getVariableClass() {
+    return variableClass;
+  }
+  public void setVariableClass(Class< ? > variableClass) {
+    this.variableClass = variableClass;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeMapping.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeMapping.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeMapping.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+
+
+public class TypeMapping implements Serializable {
+
+  Matcher matcher;
+  Type type;
+
+  private static final long serialVersionUID = 1L;
+  
+  public boolean matches(String name, Object value) {
+    return matcher.matches(name, value);
+  }
+  
+  public String toString() {
+    return "("+matcher+"-->"+type+")";
+  }
+  
+  public void setMatcher(Matcher matcher) {
+    this.matcher = matcher;
+  }
+  public Type getType() {
+    return type;
+  }
+  public void setType(Type type) {
+    this.type = type;
+  }
+  public Matcher getMatcher() {
+    return matcher;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeSet.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeSet.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/TypeSet.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TypeSet {
+
+  Type findTypeByMatch(String key, Object value);
+  Type findTypeByName(String typeName);
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * is a jbpm-internal class that serves as a base class for classes 
+ * that store variable values in the database.
+ */
+public abstract class Variable implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long dbid = -1;
+  protected int dbversion = 0;
+  
+  protected String key = null;
+  protected Converter converter = null;
+  protected String queryText = null;
+  protected ExecutionImpl processInstance;
+  
+  // constructors /////////////////////////////////////////////////////////////
+  
+  // abstract methods /////////////////////////////////////////////////////////
+
+  /**
+   * is true if this variable-instance supports the given value, false otherwise.
+   */
+  public abstract boolean isStorable(Object value);
+  /**
+   * is the value, stored by this variable instance.
+   */
+  protected abstract Object getObject();
+  /**
+   * stores the value in this variable instance.
+   */
+  protected abstract void setObject(Object value);
+
+  // variable management //////////////////////////////////////////////////////
+
+  public boolean supports(Object value) {
+    if (converter!=null) {
+      return converter.supports(value);
+    }
+    return isStorable(value);
+  }
+
+  public void setValue(Object value) {
+    if (converter!=null) {
+      if (! converter.supports(value)) {
+        throw new JbpmException("the converter '"+converter.getClass().getName()+"' in variable instance '"+this.getClass().getName()+"' does not support values of type '"+value.getClass().getName()+"'.  to change the type of a variable, you have to delete it first");
+      }
+      value = converter.convert(value);
+    }
+    if ( (value!=null)
+         && (! this.isStorable(value)) ) {
+      throw new JbpmException("variable instance '"+this.getClass().getName()+"' does not support values of type '"+value.getClass().getName()+"'.  to change the type of a variable, you have to delete it first");
+    }
+    setObject(value);
+  }
+
+  public Object getValue() {
+    Object value = getObject();
+    if ( (value!=null)
+         && (converter!=null) ) {
+      value = converter.revert(value);
+    }
+    return value;
+  }
+  
+  // utility methods /////////////////////////////////////////////////////////
+
+  public String toString() {
+    return "${"+key+"}";
+  }
+  
+  public Type getType() {
+    Type type = new Type();
+    type.setConverter(converter);
+    type.setVariableClass(getClass());
+    return type;
+  }
+  
+  // getters and setters //////////////////////////////////////////////////////
+
+  public String getKey() {
+    return key;
+  }
+  public Converter getConverter() {
+    return converter;
+  }
+  public void setConverter(Converter converter) {
+    this.converter = converter;
+  }
+  public void setKey(String key) {
+    this.key = key;
+  }
+  public ExecutionImpl getProcessInstance() {
+    return processInstance;
+  }
+  public void setProcessInstance(ExecutionImpl processInstance) {
+    this.processInstance = processInstance;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/BooleanToStringConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class BooleanToStringConverter implements Converter {
+  
+  private static final long serialVersionUID = 1L;
+  
+  public static final String TRUE_TEXT = "T";
+  public static final String FALSE_TEXT = "F";
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Boolean.class);
+  }
+
+  public Object convert(Object o) {
+    String convertedValue = FALSE_TEXT;
+    if (((Boolean)o).booleanValue()) {
+      convertedValue = TRUE_TEXT;
+    }
+    return convertedValue;
+  }
+
+  public Object revert(Object o) {
+    Boolean revertedValue = Boolean.FALSE;
+    if (TRUE_TEXT.equals(o)) {
+      revertedValue = Boolean.TRUE;
+    }
+    return revertedValue;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ByteToLongConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class ByteToLongConverter implements Converter {
+  
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Byte.class);
+  }
+
+  public Object convert(Object o) {
+    return new Long( ((Number)o).longValue() );
+  }
+
+  public Object revert(Object o) {
+    return new Byte(((Long)o).byteValue());
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/CharacterToStringConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class CharacterToStringConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Character.class);
+  }
+
+  public Object convert(Object o) {
+    return o.toString();
+  }
+
+  public Object revert(Object o) {
+    return new Character(((String)o).charAt(0));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToLongConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import java.util.Date;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class DateToLongConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (Date.class.isAssignableFrom(value.getClass()));
+  }
+
+  public Object convert(Object o) {
+    return new Long(((Date)o).getTime());
+  }
+
+  public Object revert(Object o) {
+    return new Date(((Long)o).longValue());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DateToStringConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.type.Converter;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DateToStringConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+  
+  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+  
+  public Object convert(Object o) {
+    return dateFormat.format((Date)o);
+  }
+
+  public Object revert(Object o) {
+    try {
+      return dateFormat.parseObject((String)o);
+    } catch (ParseException e) {
+      throw new JbpmException("invalid date format in date variable: "+o, e);
+    }
+  }
+
+  public boolean supports(Object value) {
+    return ((value!=null) && (value instanceof Date));
+  }
+
+  public void setFormat(String format) {
+    dateFormat = new SimpleDateFormat(format);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/DoubleToStringConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class DoubleToStringConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Double.class);
+  }
+
+  public Object convert(Object o) {
+    return o.toString();
+  }
+
+  public Object revert(Object o) {
+    return new Double((String)o);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToDoubleConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class FloatToDoubleConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Float.class);
+  }
+
+  public Object convert(Object o) {
+    return new Double(((Float)o).doubleValue());
+  }
+
+  public Object revert(Object o) {
+    return new Float(((Double)o).floatValue());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/FloatToStringConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class FloatToStringConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Float.class);
+  }
+
+  public Object convert(Object o) {
+    return o.toString();
+  }
+
+  public Object revert(Object o) {
+    return new Float((String)o);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/IntegerToLongConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class IntegerToLongConverter implements Converter {
+  
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (Integer.class.equals(value.getClass()));
+  }
+
+  public Object convert(Object o) {
+    return new Long( ((Number)o).longValue() );
+  }
+
+  public Object revert(Object o) {
+    return new Integer(((Long)o).intValue());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.type.Converter;
+
+public class SerializableToBytesConverter implements Converter {
+
+  private static final long serialVersionUID = 1L;
+  
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return Serializable.class.isAssignableFrom(value.getClass());
+  }
+
+  public Object convert(Object o) {
+    byte[] bytes = null;
+    try {
+      ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+      oos.writeObject(o);
+      oos.flush();
+      bytes = baos.toByteArray();
+    } catch (IOException e) {
+      throw new JbpmException("couldn't serialize '"+o+"'", e);
+    }
+    
+    return bytes;
+  }
+
+  public Object revert(Object o) {
+    byte[] bytes = (byte[]) o;
+    try {
+      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+      ObjectInputStream ois = new ObjectInputStream(bais);
+      return ois.readObject();
+    } catch (Exception e) {
+      throw new JbpmException("couldn't deserialize object", e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/ShortToLongConverter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.converter;
+
+import org.jbpm.pvm.internal.type.Converter;
+
+public class ShortToLongConverter implements Converter {
+  
+  private static final long serialVersionUID = 1L;
+
+  public boolean supports(Object value) {
+    if (value==null) return true;
+    return (value.getClass()==Short.class);
+  }
+
+  public Object convert(Object o) {
+    return new Long( ((Number)o).longValue() );
+  }
+  
+  public Object revert(Object o) {
+    return new Short(((Long)o).shortValue());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>
+implementations of Converter.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/ClassNameMatcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/ClassNameMatcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/ClassNameMatcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.matcher;
+
+import org.jbpm.pvm.internal.type.Matcher;
+
+
+public class ClassNameMatcher implements Matcher {
+
+  private static final long serialVersionUID = 1L;
+  
+  String className = null;
+  
+  public ClassNameMatcher(String className) {
+    this.className = className;
+  }
+  
+  public String toString() {
+    return className;
+  }
+
+  public boolean matches(String name, Object value) {
+    if (value==null) {
+      return true;
+    }
+    
+    Class<?> valueClass = value.getClass();
+    
+    while (valueClass!=null) {
+      if (className.equals(value.getClass().getName())) {
+        return true;
+      } else {
+        Class<?>[] interfaces = valueClass.getInterfaces();
+        for (int i=0; i<interfaces.length; i++) {
+          if (className.equals(interfaces[i].getName())) {
+            return true;
+          }
+        }
+        valueClass = valueClass.getSuperclass();
+      }
+    }
+    return false;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateIdMatcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateIdMatcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateIdMatcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.matcher;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.type.Type;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.type.Matcher;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class HibernateIdMatcher implements Matcher {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(HibernateIdMatcher.class.getName());
+  
+  String hibernateSessionFactoryName;
+  
+  public HibernateIdMatcher(String hibernateSessionFactoryName) {
+    this.hibernateSessionFactoryName = hibernateSessionFactoryName;
+  }
+
+  protected abstract Class<? extends Type> getIdType();
+  
+  public boolean matches(String name, Object value) {
+    boolean matches = false;
+    
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      SessionFactory sessionFactory = null;
+      if (hibernateSessionFactoryName!=null) {
+        sessionFactory = (SessionFactory) environment.get(hibernateSessionFactoryName);
+      } else {
+        sessionFactory = environment.get(SessionFactory.class);
+      }
+      if (sessionFactory!=null) {
+        ClassMetadata classMetadata = sessionFactory.getClassMetadata(value.getClass());
+        matches =  ( (classMetadata!=null)
+                     && (classMetadata.getIdentifierType().getClass()==getIdType())
+                   );
+      }
+    } else {
+      log.trace("no current environment so valueClass cannot be stored as an id-ref to a hibernate object");
+      matches = false;
+    }
+    return matches;
+  }
+
+  public String getHibernateSessionFactoryName() {
+    return hibernateSessionFactoryName;
+  }
+  public void setHibernateSessionFactoryName(String hibernateSessionFactoryName) {
+    this.hibernateSessionFactoryName = hibernateSessionFactoryName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateLongIdMatcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateLongIdMatcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateLongIdMatcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.matcher;
+
+import org.hibernate.type.LongType;
+import org.hibernate.type.Type;
+
+public class HibernateLongIdMatcher extends HibernateIdMatcher {
+
+  private static final long serialVersionUID = 1L;
+  
+  public HibernateLongIdMatcher(String hibernateSessionFactoryName) {
+    super(hibernateSessionFactoryName);
+  }
+
+  public String toString() {
+    return "hibernatable-long-id";
+  }
+
+  protected Class<? extends Type> getIdType() {
+    return LongType.class;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateStringIdMatcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateStringIdMatcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/HibernateStringIdMatcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.matcher;
+
+import org.hibernate.type.StringType;
+import org.hibernate.type.Type;
+
+public class HibernateStringIdMatcher extends HibernateIdMatcher {
+
+  private static final long serialVersionUID = 1L;
+  
+  public HibernateStringIdMatcher(String hibernateSessionFactoryName) {
+    super(hibernateSessionFactoryName);
+  }
+
+  public String toString() {
+    return "hibernatable-string-id";
+  }
+
+  protected Class<? extends Type> getIdType() {
+    return StringType.class;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/SerializableMatcher.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/SerializableMatcher.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/matcher/SerializableMatcher.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.matcher;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.type.Matcher;
+
+
+public class SerializableMatcher implements Matcher {
+
+  private static final long serialVersionUID = 1L;
+
+  public String toString() {
+    return "serializable";
+  }
+
+  public boolean matches(String name, Object value) {
+    return (Serializable.class.isAssignableFrom(value.getClass()));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/BlobVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.session.DbSession;
+
+public class BlobVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Lob lob = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (byte[].class.isAssignableFrom(value.getClass()));
+  }
+
+  public Object getObject() {
+    if (lob==null) return null; 
+    return lob.extractBytes();
+  }
+
+  public void setObject(Object value) {
+    if (this.lob!=null) {
+      DbSession dbSession = Environment.getFromCurrent(DbSession.class, false);
+      if (dbSession!=null) {
+        dbSession.delete(this.lob);
+      }
+    }
+    this.lob = new Lob((byte[])value);
+  }
+  
+  public Lob getLob() {
+    return lob;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/ClobVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.type.Variable;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ClobVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Lob lob = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (char[].class.isAssignableFrom(value.getClass()));
+  }
+
+  public Object getObject() {
+    if (lob==null) return null; 
+    return lob.extractChars();
+  }
+
+  public void setObject(Object value) {
+    this.lob = new Lob((char[])value);
+  }
+
+  public Lob getLob() {
+    return lob;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DateVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DateVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DateVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class DateVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final String dateFormat = "dd/MM/yyyy HH:mm:ss";
+  
+  protected Date date = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (Date.class.isAssignableFrom(value.getClass()));
+  }
+
+  public Object getObject() {
+    return date;
+  }
+
+  public void setObject(Object value) {
+    this.date = (Date) value;
+    if (value!=null) {
+      this.queryText = new SimpleDateFormat(dateFormat).format(value);
+    } else {
+      this.queryText = null;
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DoubleVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DoubleVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/DoubleVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class DoubleVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Double d = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (Double.class==value.getClass());
+  }
+
+  public Object getObject() {
+    return d;
+  }
+
+  public void setObject(Object value) {
+    this.d = (Double) value;
+    if (value!=null) {
+      this.queryText = value.toString();
+    } else {
+      this.queryText = null;
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateLongVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateLongVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateLongVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class HibernateLongVariable  extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Object hibernatable = null;
+
+  public boolean isStorable(Object value) {
+    return true;
+  }
+
+  public Object getObject() {
+    return hibernatable;
+  }
+
+  public void setObject(Object value) {
+    this.hibernatable = value;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateStringVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateStringVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/HibernateStringVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class HibernateStringVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Object hibernatable = null;
+
+  public boolean isStorable(Object value) {
+    return true;
+  }
+
+  public Object getObject() {
+    return hibernatable;
+  }
+
+  public void setObject(Object value) {
+    this.hibernatable = value;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/LongVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/LongVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/LongVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class LongVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Long l = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (Long.class==value.getClass());
+  }
+
+  public Object getObject() {
+    return l;
+  }
+
+  public void setObject(Object value) {
+    this.l = (Long) value;
+    if (value!=null) {
+      this.queryText = value.toString();
+    } else {
+      this.queryText = null;
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/NullVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/NullVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/NullVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,20 @@
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class NullVariable extends Variable {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Object getObject() {
+    return null;
+  }
+  
+  public boolean isStorable(Object value) {
+    return (value==null);
+  }
+  
+  protected void setObject(Object value) {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/StringVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/StringVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/StringVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+public class StringVariable extends Variable {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected String string = null;
+
+  public boolean isStorable(Object value) {
+    if (value==null) return true;
+    return (String.class==value.getClass());
+  }
+
+  public Object getObject() {
+    return string;
+  }
+
+  public void setObject(Object value) {
+    this.string = (String) value;
+    if (value!=null) {
+      this.queryText = string;
+    } else {
+      this.queryText = null;
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/UnpersistableVariable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/UnpersistableVariable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/variable/UnpersistableVariable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,27 @@
+package org.jbpm.pvm.internal.type.variable;
+
+import org.jbpm.pvm.internal.type.Variable;
+
+
+/**
+ * uses the cache in variable instance to store any object
+ * without persisting it.
+ */
+public class UnpersistableVariable extends Variable {
+  
+  private static final long serialVersionUID = 1L;
+  
+  Object value;
+
+  protected Object getObject() {
+    return value;
+  }
+
+  public boolean isStorable(Object value) {
+    return true;
+  }
+
+  protected void setObject(Object value) {
+    this.value = value;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ArrayUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ArrayUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ArrayUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,26 @@
+package org.jbpm.pvm.internal.util;
+
+public class ArrayUtil {
+
+  public static String toString(Object[] array) {
+    if (array==null) {
+      return "null";
+    } else {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("[");
+      for (int i=0; i<array.length; i++) {
+        Object o = array[i];
+        if (o!=null) {
+          buffer.append(o);
+        } else {
+          buffer.append("null");
+        }
+        if (i!=array.length-1) {
+          buffer.append("|");
+        }
+      }
+      buffer.append("]");
+      return buffer.toString();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+package org.jbpm.pvm.internal.util;
+
+import java.util.Date;
+
+public abstract class Clock {
+  
+  protected static Date currentTime = null;
+  
+  public static Date getCurrentTime() {
+    if (currentTime==null) {
+      return new Date();
+    }
+    return currentTime;
+  }
+  
+  public static void setCurrentTime(Date currentTime) {
+    Clock.currentTime = currentTime;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Closable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Closable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Closable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Closable {
+
+  void close();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DOMWriter.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DOMWriter.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DOMWriter.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,634 @@
+package org.jbpm.pvm.internal.util;
+
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ *    any, must include the following acknowlegement:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ *    Foundation" must not be used to endorse or promote products derived
+ *    from this software without prior written permission. For written
+ *    permission, please contact apache at apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ *    nor may "Apache" appear in their names without prior written
+ *    permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Traverse a DOM tree in order to print a document that is parsed.
+ *
+ * @author Andy Clark, IBM
+ * @author Thomas.Diesler at jboss.org
+ */
+ at SuppressWarnings("unchecked")
+public class DOMWriter
+{
+  // Print writer
+  private PrintWriter out;
+  // True, if canonical output
+  private boolean canonical;
+  // True, if pretty printing should be used
+  private boolean prettyprint;
+  // True, if the XML declaration should be written
+  private boolean writeXMLDeclaration;
+  // True, if whitespace should be ignored
+  private boolean ignoreWhitespace;
+  // Explicit character set encoding
+  private String charsetName;
+  // indent for the pretty printer
+  private int prettyIndent;
+  // True, if the XML declaration has been written
+  private boolean wroteXMLDeclaration;
+  // The node that started the write
+  private Node rootNode;
+  // True if we want namespace completion
+  private boolean completeNamespaces = true;
+  // The current default namespace
+  private String currentDefaultNamespace;
+
+  public DOMWriter(Writer w)
+  {
+    this.out = new PrintWriter(w);
+  }
+
+  public DOMWriter(Writer w, String charsetName)
+  {
+    this.out = new PrintWriter(w);
+    this.charsetName = charsetName;
+    this.writeXMLDeclaration = true;
+  }
+
+  public DOMWriter(OutputStream stream)
+  {
+    try
+    {
+      this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      // ignore, UTF-8 should be available
+    }
+  }
+
+  public DOMWriter(OutputStream stream, String charsetName)
+  {
+    try
+    {
+      this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
+      this.charsetName = charsetName;
+      this.writeXMLDeclaration = true;
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      throw new IllegalArgumentException("Unsupported encoding: " + charsetName);
+    }
+  }
+
+  /**
+   * Print a node with explicit prettyprinting.
+   * The defaults for all other DOMWriter properties apply.
+   *
+   */
+  public static String printNode(Node node, boolean prettyprint)
+  {
+    StringWriter strw = new StringWriter();
+    new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
+    return strw.toString();
+  }
+
+  public boolean isCanonical()
+  {
+    return canonical;
+  }
+
+  /**
+   * Set wheter entities should appear in their canonical form.
+   * The default is false.
+   */
+  public DOMWriter setCanonical(boolean canonical)
+  {
+    this.canonical = canonical;
+    return this;
+  }
+
+  public boolean isIgnoreWhitespace()
+  {
+    return ignoreWhitespace;
+  }
+
+  /**
+   * Set whether whitespace should be ignored.
+   * The default is false.
+   */
+  public DOMWriter setIgnoreWhitespace(boolean ignoreWhitespace)
+  {
+    this.ignoreWhitespace = ignoreWhitespace;
+    return this;
+  }
+
+  /**
+   * Set wheter subelements should have their namespaces completed.
+   * Setting this to false may lead to invalid XML fragments.
+   * The default is true.
+   */
+  public DOMWriter setCompleteNamespaces(boolean complete)
+  {
+    this.completeNamespaces = complete;
+    return this;
+  }
+
+  public boolean isPrettyprint()
+  {
+    return prettyprint;
+  }
+
+  /**
+   * Set wheter element should be indented.
+   * The default is false.
+   */
+  public DOMWriter setPrettyprint(boolean prettyprint)
+  {
+    this.prettyprint = prettyprint;
+    return this;
+  }
+
+  public boolean isWriteXMLDeclaration()
+  {
+    return writeXMLDeclaration;
+  }
+
+  /**
+   * Set wheter the XML declaration should be written.
+   * The default is false.
+   */
+  public DOMWriter setWriteXMLDeclaration(boolean flag)
+  {
+    this.writeXMLDeclaration = flag;
+    return this;
+  }
+
+  public void print(Node node)
+  {
+    if (prettyprint && ignoreWhitespace)
+      throw new IllegalStateException("Cannot pretty print and ignore whitespace");
+
+    rootNode = node;
+    printInternal(node, false);
+  }
+
+  private void printInternal(Node node, boolean indentEndMarker)
+  {
+    // is there anything to do?
+    if (node == null)
+    {
+      return;
+    }
+
+    // JBAS-2117 - Don't skip the DOCUMENT_NODE
+    // if (node instanceof Document) node = ((Document)node).getDocumentElement();
+
+    if (wroteXMLDeclaration == false && writeXMLDeclaration == true && canonical == false)
+    {
+      out.print("<?xml version='1.0'");
+      if (charsetName != null)
+        out.print(" encoding='" + charsetName + "'");
+
+      out.print("?>");
+      if (prettyprint)
+        out.println();
+
+      wroteXMLDeclaration = true;
+    }
+
+    int type = node.getNodeType();
+    boolean hasChildNodes = node.getChildNodes().getLength() > 0;
+
+    String nodeName = node.getNodeName();
+    switch (type)
+    {
+      // print document
+      case Node.DOCUMENT_NODE:
+      {
+        NodeList children = node.getChildNodes();
+        for (int iChild = 0; iChild < children.getLength(); iChild++)
+        {
+          printInternal(children.item(iChild), false);
+        }
+        out.flush();
+        break;
+      }
+
+      // print element with attributes
+      case Node.ELEMENT_NODE:
+      {
+        Element element = (Element)node;
+        if (prettyprint)
+        {
+          for (int i = 0; i < prettyIndent; i++)
+          {
+            out.print(' ');
+          }
+          prettyIndent++;
+        }
+
+        out.print('<');
+        out.print(nodeName);
+
+        Map nsMap = new HashMap();
+        String elPrefix = node.getPrefix();
+        String elNamespaceURI = node.getNamespaceURI();
+        if (elPrefix != null)
+        {
+          String nsURI = getNamespaceURI(elPrefix, element, rootNode);
+          nsMap.put(elPrefix, nsURI);
+        }
+
+        Attr attrs[] = sortAttributes(node.getAttributes());
+        for (int i = 0; i < attrs.length; i++)
+        {
+          Attr attr = attrs[i];
+          String atPrefix = attr.getPrefix();
+          String atName = attr.getNodeName();
+          String atValue = normalize(attr.getNodeValue(), canonical);
+
+          if (atName.equals("xmlns"))
+            currentDefaultNamespace = atValue;
+
+          if (atPrefix != null && !atPrefix.equals("xmlns") && !atPrefix.equals("xml"))
+          {
+            String nsURI = getNamespaceURI(atPrefix, element, rootNode);
+            nsMap.put(atPrefix, nsURI);
+            // xsi:type='ns1:SubType', xsi:type='xsd:string'
+            if (atName.equals(atPrefix + ":type") && atValue.indexOf(":") > 0)
+            {
+              // xsi defined on the envelope
+              if (nsURI == null)
+                nsURI = getNamespaceURI(atPrefix, element, null);
+
+              if ("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
+              {
+                String typePrefix = atValue.substring(0, atValue.indexOf(":"));
+                String typeURI = getNamespaceURI(typePrefix, element, rootNode);
+                nsMap.put(typePrefix, typeURI);
+              }
+            }
+          }
+
+          out.print(" " + atName + "='" + atValue + "'");
+        }
+
+        // Add namespace declaration for prefixes
+        // that are defined further up the tree
+        if (completeNamespaces)
+        {
+          Iterator itPrefix = nsMap.keySet().iterator();
+          while (itPrefix.hasNext())
+          {
+            String prefix = (String)itPrefix.next();
+            String nsURI = (String)nsMap.get(prefix);
+            if (nsURI == null)
+            {
+              nsURI = getNamespaceURI(prefix, element, null);
+              out.print(" xmlns:" + prefix + "='" + nsURI + "'");
+            }
+          }
+        }
+
+        // The SAX ContentHandler will by default not add the namespace declaration
+        // <Hello xmlns='http://somens'>World</Hello>
+        if (elPrefix == null && elNamespaceURI != null)
+        {
+          String defaultNamespace = element.getAttribute("xmlns");
+          if (defaultNamespace.length() == 0 && !elNamespaceURI.equals(currentDefaultNamespace))
+          {
+            out.print(" xmlns='" + elNamespaceURI + "'");
+            currentDefaultNamespace = elNamespaceURI;
+          }
+        }
+
+        if (hasChildNodes)
+        {
+          out.print('>');
+        }
+
+        // Find out if the end marker is indented
+        indentEndMarker = isEndMarkerIndented(node);
+
+        if (indentEndMarker)
+        {
+          out.print('\n');
+        }
+
+        NodeList childNodes = node.getChildNodes();
+        int len = childNodes.getLength();
+        for (int i = 0; i < len; i++)
+        {
+          Node childNode = childNodes.item(i);
+          printInternal(childNode, false);
+        }
+        break;
+      }
+
+      // handle entity reference nodes
+      case Node.ENTITY_REFERENCE_NODE:
+      {
+        if (canonical)
+        {
+          NodeList children = node.getChildNodes();
+          if (children != null)
+          {
+            int len = children.getLength();
+            for (int i = 0; i < len; i++)
+            {
+              printInternal(children.item(i), false);
+            }
+          }
+        }
+        else
+        {
+          out.print('&');
+          out.print(nodeName);
+          out.print(';');
+        }
+        break;
+      }
+
+      // print cdata sections
+      case Node.CDATA_SECTION_NODE:
+      {
+        if (canonical)
+        {
+          out.print(normalize(node.getNodeValue(), canonical));
+        }
+        else
+        {
+          out.print("<![CDATA[");
+          out.print(node.getNodeValue());
+          out.print("]]>");
+        }
+        break;
+      }
+
+      // print text
+      case Node.TEXT_NODE:
+      {
+        String text = normalize(node.getNodeValue(), canonical);
+        if (text.trim().length() > 0)
+        {
+          out.print(text);
+        }
+        else if (prettyprint == false && ignoreWhitespace == false)
+        {
+          out.print(text);
+        }
+        break;
+      }
+
+      // print processing instruction
+      case Node.PROCESSING_INSTRUCTION_NODE:
+      {
+        out.print("<?");
+        out.print(nodeName);
+        String data = node.getNodeValue();
+        if (data != null && data.length() > 0)
+        {
+          out.print(' ');
+          out.print(data);
+        }
+        out.print("?>");
+        break;
+      }
+
+      // print comment
+      case Node.COMMENT_NODE:
+      {
+        for (int i = 0; i < prettyIndent; i++)
+        {
+          out.print(' ');
+        }
+
+        out.print("<!--");
+        String data = node.getNodeValue();
+        if (data != null)
+        {
+          out.print(data);
+        }
+        out.print("-->");
+
+        if (prettyprint)
+        {
+          out.print('\n');
+        }
+
+        break;
+      }
+    }
+
+    if (type == Node.ELEMENT_NODE)
+    {
+      if (prettyprint)
+        prettyIndent--;
+
+      if (hasChildNodes == false)
+      {
+        out.print("/>");
+      }
+      else
+      {
+        if (indentEndMarker)
+        {
+          for (int i = 0; i < prettyIndent; i++)
+          {
+            out.print(' ');
+          }
+        }
+
+        out.print("</");
+        out.print(nodeName);
+        out.print('>');
+      }
+
+      if (prettyIndent > 0)
+      {
+        out.print('\n');
+      }
+    }
+    out.flush();
+  }
+
+  private String getNamespaceURI(String prefix, Element element, Node stopNode)
+  {
+    Node parent = element.getParentNode();
+    String nsURI = element.getAttribute("xmlns:" + prefix);
+    if (nsURI.length() == 0 && element != stopNode && parent instanceof Element)
+      return getNamespaceURI(prefix, (Element)parent, stopNode);
+
+    return (nsURI.length() > 0 ? nsURI : null);
+  }
+
+  private boolean isEndMarkerIndented(Node node)
+  {
+    if (prettyprint)
+    {
+      NodeList childNodes = node.getChildNodes();
+      int len = childNodes.getLength();
+      for (int i = 0; i < len; i++)
+      {
+        Node children = childNodes.item(i);
+        if (children.getNodeType() == Node.ELEMENT_NODE)
+        {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  /** Returns a sorted list of attributes. */
+  private Attr[] sortAttributes(NamedNodeMap attrs)
+  {
+
+    int len = (attrs != null) ? attrs.getLength() : 0;
+    Attr array[] = new Attr[len];
+    for (int i = 0; i < len; i++)
+    {
+      array[i] = (Attr)attrs.item(i);
+    }
+    for (int i = 0; i < len - 1; i++)
+    {
+      String name = array[i].getNodeName();
+      int index = i;
+      for (int j = i + 1; j < len; j++)
+      {
+        String curName = array[j].getNodeName();
+        if (curName.compareTo(name) < 0)
+        {
+          name = curName;
+          index = j;
+        }
+      }
+      if (index != i)
+      {
+        Attr temp = array[i];
+        array[i] = array[index];
+        array[index] = temp;
+      }
+    }
+    return (array);
+  }
+
+  /** Normalizes the given string. */
+  public static String normalize(String s, boolean canonical)
+  {
+    StringBuffer str = new StringBuffer();
+
+    int len = (s != null) ? s.length() : 0;
+    for (int i = 0; i < len; i++)
+    {
+      char ch = s.charAt(i);
+      switch (ch)
+      {
+        case '<':
+        {
+          str.append("&lt;");
+          break;
+        }
+        case '>':
+        {
+          str.append("&gt;");
+          break;
+        }
+        case '&':
+        {
+          str.append("&amp;");
+          break;
+        }
+        case '"':
+        {
+          str.append("&quot;");
+          break;
+        }
+        case '\'':
+        {
+          str.append("&apos;");
+          break;
+        }
+        case '\r':
+        case '\n':
+        {
+          if (canonical)
+          {
+            str.append("&#");
+            str.append(Integer.toString(ch));
+            str.append(';');
+            break;
+          }
+          // else, default append char
+        }
+        default:
+        {
+          str.append(ch);
+        }
+      }
+    }
+    return (str.toString());
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DefaultObservable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DefaultObservable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/DefaultObservable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,74 @@
+package org.jbpm.pvm.internal.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+
+/** default implementation of the {@link Observable} interface.
+ * 
+ * @author Tom Baeyens
+ */
+public class DefaultObservable implements Observable {
+
+  protected List<Listener> listeners = null;
+  
+  public void addListener(Listener listener) {
+    if (listener==null) {
+      throw new JbpmException("listener is null");
+    }
+    if (listeners==null) {
+      listeners = new ArrayList<Listener>();
+    }
+    listeners.add(listener);
+  }
+
+  public void removeListener(Listener listener) {
+    if (listener==null) {
+      throw new JbpmException("listener is null");
+    }
+    if (listeners!=null) {
+      listeners.remove(listener);
+    }
+  }
+
+  public Listener addListener(Listener listener, String eventName) {
+    if (eventName==null) {
+      throw new JbpmException("eventName is null");
+    }
+
+    List<String> eventNames = new ArrayList<String>();
+    eventNames.add(eventName);
+
+    return addListener(listener, eventNames);
+  }
+
+
+  public Listener addListener(Listener listener, List<String> eventNames) {
+    if (listener==null) {
+      throw new JbpmException("listener is null");
+    }
+    if (eventNames==null) {
+      throw new JbpmException("eventNames is null");
+    }
+    FilterListener filterListener = new FilterListener(listener, eventNames);
+    addListener(filterListener);
+    return filterListener;
+  }
+
+  public void fire(String eventName) {
+    fire(eventName, null);
+  }
+
+  public void fire(String eventName, Object info) {
+    if (listeners!=null) {
+      for (Listener listener: listeners)  {
+        listener.event(this, eventName, info);
+      }
+    }
+  }
+  
+  public List<Listener> getListeners() {
+    return listeners;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/EqualsUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+public abstract class EqualsUtil {
+
+  public static boolean equals(Object thisObject, Object otherObject) {
+    if ( (thisObject==null) || (otherObject==null) ) return false;
+    
+    if (isProxy(otherObject)) {
+      return otherObject.equals(thisObject);
+    } else {
+      return otherObject==thisObject;
+    }
+  }
+
+  static boolean isInitialized = false;
+  static boolean isHibernateInClasspth = true;
+  static Class<?> hibernateProxyClass = null;
+  
+  static boolean isProxy(Object otherObject) {
+    boolean isProxy = false;
+    if (!isInitialized) initializeHibernateProxyClass();
+
+    if (isHibernateInClasspth) {
+      return hibernateProxyClass.isAssignableFrom(otherObject.getClass());
+    }
+    return isProxy;
+  }
+
+  static synchronized void initializeHibernateProxyClass() {
+    try {
+      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+      hibernateProxyClass = classLoader.loadClass("org.hibernate.proxy.HibernateProxy");
+    } catch (ClassNotFoundException e) {
+      isHibernateInClasspth = false;
+    }
+    isInitialized = true;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/FilterListener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/FilterListener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/FilterListener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+package org.jbpm.pvm.internal.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+
+/** listener that only delegates events to a given listener if 
+ * they pass the filter based on event names. */
+public class FilterListener implements Listener {
+
+  protected Listener listener;
+  protected List<String> eventNames;
+
+  public FilterListener(Listener listener, String eventName) {
+    if (listener==null) throw new JbpmException("listener is null");
+    this.listener = listener;
+    if (eventName==null) throw new JbpmException("eventName is null");
+    this.eventNames = new ArrayList<String>();
+    this.eventNames.add(eventName);
+  }
+
+  public FilterListener(Listener listener, List<String> eventNames) {
+    if (listener==null) throw new JbpmException("listener is null");
+    this.listener = listener;
+    if (eventNames==null) throw new JbpmException("eventNames is null");
+    this.eventNames = eventNames;
+  }
+  
+  public void event(Object source, String name, Object info) {
+    if (! isFiltered(name)) {
+      listener.event(source, name, info);
+    }
+  }
+
+  public boolean isFiltered(String eventName) {
+    if (eventNames.contains(eventName)) {
+      return false;
+    }
+    return true;
+  }
+
+  public boolean equals(Object object) {
+    if (object==null) return false;
+    if (object==this) return true;
+    if ( (object instanceof Listener)
+         && (listener.equals(object))
+       ) {
+      return true;
+    }
+    return false;
+  }
+  public int hashCode() {
+    return 17+listener.hashCode();
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/IoUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/IoUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/IoUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.jbpm.JbpmException;
+
+public abstract class IoUtil {
+
+  public static final int BUFFERSIZE = 4096;
+
+  public static byte[] readBytes(InputStream inputStream) {
+    byte[] bytes = null;
+    if (inputStream==null) {
+      throw new JbpmException("inputStream is null");
+    }
+    try {
+      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+      transfer(inputStream, outputStream);
+      bytes = outputStream.toByteArray();
+      outputStream.close();
+      return bytes;
+    } catch (IOException e) {
+      throw new JbpmException("couldn't read bytes from inputStream", e);
+    }
+  }
+  
+  public static int transfer(InputStream in, OutputStream out) {
+    int total = 0;
+    byte[] buffer = new byte[BUFFERSIZE];
+    try {
+      int bytesRead = in.read( buffer );
+      while ( bytesRead != -1 ) {
+        out.write( buffer, 0, bytesRead );
+        total += bytesRead;
+        bytesRead = in.read( buffer );
+      }
+      return total;
+    } catch (IOException e) {
+      throw new JbpmException("couldn't write bytes to output stream", e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Listener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Listener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Listener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,17 @@
+package org.jbpm.pvm.internal.util;
+
+/** listener to events that are produced by an {@link Observable}.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public interface Listener {
+
+  /** is called by the {@link Observable} when an event is fired.
+   * @param source {@link Observable} that fired the event.
+   * @param eventName name of the event.
+   * @param info more information about the fired event.  See the concrete
+   * observable docs for more information about what information is provided.
+   */
+  public void event(Object source, String eventName, Object info);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Observable.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Observable.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Observable.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+package org.jbpm.pvm.internal.util;
+
+import java.util.List;
+
+
+/** dispatches events to which {@link Listener listeners} can subscribe. 
+ * Aka publish-subscribe.
+ * 
+ * @see DefaultObservable a default implementation of this interface
+ * @author Tom Baeyens
+ */
+public interface Observable {
+  
+  /** subscribes a listener to every event 
+   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
+   */
+  void addListener(Listener listener);
+
+  /** removes a listener that was subscribed for every event 
+   */
+  void removeListener(Listener listener);
+  
+  /** subscribes the listener to receive event notifications only of the given eventName.  Events with 
+   * different eventNames will not be dispatched to the given listener.
+   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
+   * @param eventName is the type of events the listener is interested in and this is mandatory.
+   * @return the {@link FilterListener} that is created as a wrapper for the given listener.  That handle
+   *   might be necessary to remove the listener later on.
+   * @throws NullPointerException in case listener or eventName is null. */
+  Listener addListener(Listener listener, String eventName);
+
+  /** subscribes the listener to receive event notifications only if event matches one of the 
+   * given eventNames.  Events with different eventNames will not be dispatched to the given listener.
+   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
+   * @param eventNames is the type of events the listener is interested in and this is mandatory.
+   * @return the {@link FilterListener} that is created as a wrapper for the given listener.  That handle
+   *   might be necessary to remove the listener later on.
+   * @throws NullPointerException in case listener or eventName is null. */
+  Listener addListener(Listener listener, List<String> eventNames);
+
+  /** dispatches an event to the listeners.  
+   * @param eventName identifies the type of event and is allowed to be null.
+   */ 
+  void fire(String eventName);
+
+  /** dispatches an event to the listeners.
+  * @param eventName identifies the type of event and is allowed to be null.
+  * @param info is the optional information that the observable wants to pass to it's listeners.  
+  *   Each observable should indicate which type of info it's passing for each event.
+  */  
+  void fire(String eventName, Object info);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Priority.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Priority.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Priority.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import org.jbpm.JbpmException;
+
+public abstract class Priority {
+  
+  public static final int HIGHEST = 2;
+  public static final int HIGH    = 1;
+  public static final int NORMAL  = 0;
+  public static final int LOW     = -1;
+  public static final int LOWEST  = -2;
+  
+  public static final String TEXT_HIGHEST = "highest";
+  public static final String TEXT_HIGH = "high";
+  public static final String TEXT_NORMAL = "normal";
+  public static final String TEXT_LOW = "low";
+  public static final String TEXT_LOWEST = "lowest";
+  
+  public static String toString(int priority) {
+    if (priority==3) return TEXT_NORMAL;
+    if (priority==2) return TEXT_HIGH;
+    if (priority==1) return TEXT_HIGHEST;
+    if (priority==4) return TEXT_LOW;
+    if (priority==5) return TEXT_LOWEST;
+    return Integer.toString(priority);
+  }
+
+  public static int parsePriority(String priorityText) {
+    if (TEXT_NORMAL.equalsIgnoreCase(priorityText)) return NORMAL;
+    else if (TEXT_HIGH.equalsIgnoreCase(priorityText)) return HIGH;
+    else if (TEXT_HIGHEST.equalsIgnoreCase(priorityText)) return HIGHEST;
+    else if (TEXT_LOW.equalsIgnoreCase(priorityText)) return LOW;
+    else if (TEXT_LOWEST.equalsIgnoreCase(priorityText)) return LOWEST;
+    try {
+      return Integer.parseInt(priorityText);
+    } catch (NumberFormatException e) {
+      throw new JbpmException("priority '"+priorityText+"' could not be parsed as a priority", e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,385 @@
+package org.jbpm.pvm.internal.util;
+
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+
+public abstract class ReflectUtil {
+
+  private static Log log = Log.getLog(ReflectUtil.class.getName());
+
+  static ClassLoader resolveClassLoader(ClassLoader classLoader) {
+    // 1) if the user provided a classloader through the API, use that one
+    if (classLoader!=null) {
+      log.trace("using provided classloader");
+      return classLoader;
+    }
+    
+    // 2) if the user provided a classloader through the environment, use that one
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      classLoader = environment.getClassLoader();
+      if (classLoader!=null) {
+        log.trace("using environment classloader");
+        return classLoader;
+      }
+    }
+
+    // 3) otherwise, use the current thread's context classloader
+    log.trace("using context classloader");
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  public static Class<?> loadClass(ClassLoader classLoader, String className) {
+    if (classLoader!=null) {
+      try {
+        return classLoader.loadClass(className);
+      } catch (ClassNotFoundException e) {
+        log.trace("couldn't load class "+className+" with given classloader "+classLoader);
+      }
+    }
+    try {
+      return Thread.currentThread().getContextClassLoader().loadClass(className);
+    } catch (ClassNotFoundException e) {
+      log.trace("couldn't load class "+className+" with context classloader "+classLoader);
+    }
+    try {
+      return ReflectUtil.class.getClassLoader().loadClass(className);
+    } catch (ClassNotFoundException e) {
+      log.trace("couldn't load class "+className+" with pvm lib classloader "+classLoader);
+    }
+    throw new JbpmException("couldn't load class "+className);
+  }
+  
+  public static InputStream getResourceAsStream(ClassLoader classLoader, String resource) {
+    classLoader = resolveClassLoader(classLoader);
+    log.trace("getting resource as stream "+resource);
+    return classLoader.getResourceAsStream(resource);
+  }
+  
+  public static Enumeration<URL> getResources(ClassLoader classLoader, String resource) {
+    classLoader = resolveClassLoader(classLoader);
+    try {
+      log.trace("getting resources "+resource);
+      return classLoader.getResources(resource);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't get resources "+resource, e);
+    }
+  }
+  
+  public static URL getResource(ClassLoader classLoader, String resource) {
+    classLoader = resolveClassLoader(classLoader);
+    try {
+      log.trace("getting resource "+resource);
+      return classLoader.getResource(resource);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't get resources "+resource, e);
+    }
+  }
+  
+  public static Object instantiate(ClassLoader classLoader, String className) {
+    Object newObject;
+    try {
+      classLoader = resolveClassLoader(classLoader);
+      Class<?> clazz = loadClass(classLoader, className);
+      log.trace("instantiating "+className);
+      newObject = clazz.newInstance();
+    } catch (Exception e) {
+      throw new JbpmException("couldn't instantiate "+className, e);
+    }
+    return newObject;
+  }
+
+  public static Class<?>[] loadClasses(ClassLoader classLoader, List<String> constructorArgTypeNames) {
+    if (constructorArgTypeNames==null) return null;
+    Class<?>[] classes = new Class[constructorArgTypeNames.size()];
+    for (int i=0; i<constructorArgTypeNames.size(); i++) {
+      classLoader = resolveClassLoader(classLoader);
+      classes[i] = loadClass(classLoader, constructorArgTypeNames.get(i));
+    }
+    return classes;
+  }
+
+  public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>[] parameterTypes) {
+    Constructor<T> constructor = null;
+    try {
+      constructor = clazz.getDeclaredConstructor(parameterTypes);
+      
+      if (log.isTraceEnabled()) log.trace("found constructor "+clazz.getName()+"("+ArrayUtil.toString(parameterTypes)+")");
+      
+    } catch (SecurityException e) {
+      throw new JbpmException("wasn't allowed to get constructor '"+clazz.getName()+"("+getParameterTypesText(parameterTypes)+")'", e);
+    } catch (NoSuchMethodException e) {
+      throw new JbpmException("couldn't find constructor '"+clazz.getName()+"("+getParameterTypesText(parameterTypes)+")'", e);
+    }
+
+    return constructor;
+  }
+
+  public static Field getField(Class<?> clazz, String fieldName) {
+    return getField(clazz, fieldName, clazz);
+  }
+
+  private static Field getField(Class<?> clazz, String fieldName, Class<?> original) {
+    Field field = null;
+
+    try {
+      field = clazz.getDeclaredField(fieldName);
+      log.trace("found field "+fieldName+" in "+clazz.getName());
+    } catch (SecurityException e) {
+      throw new JbpmException("wasn't allowed to get field '"+clazz.getName()+"."+fieldName+"'", e);
+    } catch (NoSuchFieldException e) {
+      if (clazz.getSuperclass()!=null) {
+        return getField(clazz.getSuperclass(), fieldName, original);
+      } else {
+        throw new JbpmException("couldn't find field '"+original.getName()+"."+fieldName+"'", e);
+      }
+    }
+    
+    return field;
+  }
+
+  public static Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {
+    return getMethod(clazz, methodName, parameterTypes, clazz);
+  }
+
+  private static Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes, Class<?> original) {
+    Method method = null;
+    
+    try {
+      method = clazz.getDeclaredMethod(methodName, parameterTypes);
+      
+      if (log.isTraceEnabled()) 
+        log.trace("found method "+clazz.getName()+"."+methodName+"("+ArrayUtil.toString(parameterTypes)+")");
+
+    } catch (SecurityException e) {
+      throw new JbpmException("wasn't allowed to get method '"+clazz.getName()+"."+methodName+"("+getParameterTypesText(parameterTypes)+")'", e);
+    } catch (NoSuchMethodException e) {
+      if (clazz.getSuperclass()!=null) {
+        return getMethod(clazz.getSuperclass(), methodName, parameterTypes, original);
+      } else {
+        throw new JbpmException("couldn't find method '"+original.getName()+"."+methodName+"("+getParameterTypesText(parameterTypes)+")'", e);
+      }
+    }
+    
+    return method;
+  }
+
+  private static String getParameterTypesText(Class<?>[] parameterTypes) {
+    if (parameterTypes==null) return "";
+    StringBuffer parametersTypeText = new StringBuffer();
+    for (int i=0; i<parameterTypes.length; i++) {
+      Class<?> parameterType = parameterTypes[i];
+      parametersTypeText.append(parameterType.getName());
+      if (i!=parameterTypes.length-1) {
+        parametersTypeText.append(", ");
+      }
+    }
+    return parametersTypeText.toString();
+  }
+
+  public static <T> T newInstance(Class<T> clazz) {
+    return newInstance(clazz, null, null);
+  }
+  public static <T> T newInstance(Constructor<T> constructor) {
+    return newInstance(null, constructor, null);
+  }
+  public static <T> T newInstance(Constructor<T> constructor, Object[] args) {
+    return newInstance(null, constructor, args);
+  }
+  
+  private static <T> T newInstance(Class<T> clazz, Constructor<T> constructor, Object[] args) {
+    if ( (clazz==null)
+         && (constructor==null)
+       ) {
+      throw new IllegalArgumentException("can't create new instance without clazz or constructor");
+    }
+
+    String className = null;
+    try {
+      log.trace("creating new instance for class '"+className+"' with args "+ArrayUtil.toString(args));
+      if (constructor==null) {
+        log.trace("getting default constructor");
+        constructor = clazz.getConstructor((Class[])null);
+      }
+      className = constructor.getDeclaringClass().getName();
+      if (!constructor.isAccessible()) {
+        log.trace("making constructor accessible");
+        constructor.setAccessible(true);
+      }
+      return constructor.newInstance(args);
+
+    } catch (Throwable t) {
+      throw new JbpmException("couldn't construct new '"+className+"' with args "+ArrayUtil.toString(args), t);
+    }
+  }
+  
+  public static Object get(Field field, Object object) {
+    if (field==null) {
+      throw new NullPointerException("field is null");
+    }
+    try {
+      Object value = field.get(object);
+      log.trace("got value '"+value+"' from field '"+field.getName()+"'");
+      return value;
+    } catch (Exception e) {
+      throw new JbpmException("couldn't get '"+field.getName()+"'", e);
+    }
+  }
+
+  public static void set(Field field, Object object, Object value) {
+    if (field==null) {
+      throw new NullPointerException("field is null");
+    }
+    try {
+      log.trace("setting field '"+field.getName()+"' to value '"+value+"'");
+      if (!field.isAccessible()) {
+        log.trace("making field accessible");
+        field.setAccessible(true);
+      }
+      field.set(object, value);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't set '"+field.getName()+"' to '"+value+"'", e);
+    }
+  }
+  
+  public static Object invoke(Method method, Object target, Object[] args) {
+    if (method==null) {
+      throw new JbpmException("method is null");
+    }
+    try {
+      log.trace("invoking '"+method.getName()+"' on '"+target+"' with "+ArrayUtil.toString(args));
+      if (!method.isAccessible()) {
+        log.trace("making method accessible");
+        method.setAccessible(true);
+      }
+      return method.invoke(target, args);
+    } catch (InvocationTargetException e) {
+      Throwable targetException = e.getTargetException();
+      throw new JbpmException("couldn't invoke '"+method.getName()+"' with "+ArrayUtil.toString(args)+" on "+target+": "+targetException.getMessage(), targetException);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't invoke '"+method.getName()+"' with "+ArrayUtil.toString(args)+" on "+target+": "+e.getMessage(), e);
+    }
+  }
+
+  public static Method findMethod(Class<?> clazz, String methodName, List<ArgDescriptor> argDescriptors, Object[] args) {
+    log.trace("searching for method "+methodName+" in "+clazz.getName());
+    Method[] candidates = clazz.getDeclaredMethods();
+    for (int i=0; i<candidates.length; i++) {
+      Method candidate = candidates[i];
+      if ( (candidate.getName().equals(methodName))
+           && (isArgumentMatch(candidate.getParameterTypes(), argDescriptors, args))
+         ) {
+
+        if (log.isTraceEnabled()) {
+          log.trace("found matching method "+clazz.getName()+"."+methodName);
+        }
+        
+        return candidate;
+      }
+    }
+    if (clazz.getSuperclass()!=null) {
+      return findMethod(clazz.getSuperclass(), methodName, argDescriptors, args);
+    }
+    return null;
+  }
+
+  public static Constructor<?> findConstructor(Class<?> clazz, List<ArgDescriptor> argDescriptors, Object[] args) {
+    Constructor<?>[] constructors = clazz.getDeclaredConstructors();
+    for (int i=0; i<constructors.length; i++) {
+      if (isArgumentMatch(constructors[i].getParameterTypes(), argDescriptors, args)) {
+        return constructors[i];
+      }
+    }
+    return null;
+  }
+
+  public static boolean isArgumentMatch(Class<?>[] parameterTypes, List<ArgDescriptor> argDescriptors, Object[] args) {
+    int nbrOfArgs = 0;
+    if (args!=null) nbrOfArgs = args.length;
+    
+    int nbrOfParameterTypes = 0;
+    if (parameterTypes!=null) nbrOfParameterTypes = parameterTypes.length;
+    
+    if ( (nbrOfArgs==0)
+         && (nbrOfParameterTypes==0)
+       ) {
+      return true;
+    }
+    
+    if (nbrOfArgs!=nbrOfParameterTypes) {
+      return false;
+    }
+
+    for (int i=0; (i<parameterTypes.length); i++) {
+      Class<?> parameterType = parameterTypes[i];
+      String argTypeName = (argDescriptors!=null ? argDescriptors.get(i).getTypeName() : null);
+      if (argTypeName!=null) {
+         if (! argTypeName.equals(parameterType.getName())) {
+           return false;
+         }
+      } else if ( (args[i]!=null)
+                  && (! parameterType.isAssignableFrom(args[i].getClass()))
+                ) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  public static String getSignature(String methodName, List<ArgDescriptor> argDescriptors, Object[] args) {
+    String signature = methodName+"(";
+    if (args!=null) {
+      for (int i=0; i<args.length; i++) {
+        String argType = null;
+        if (argDescriptors!=null) {
+          ArgDescriptor argDescriptor = argDescriptors.get(i);
+          if ( (argDescriptor!=null)
+               && (argDescriptor.getTypeName()!=null)
+             ) {
+            argType = argDescriptor.getTypeName(); 
+          }
+        }
+        if ( (argType==null)
+             && (args[i]!=null)
+           ) {
+          argType = args[i].getClass().getName();
+        }
+        signature += argType;
+        if (i<(args.length-1)) {
+          signature += ", ";
+        }
+      }
+    }
+    signature+=")";
+    return signature;
+  }
+  
+  public static String getUnqualifiedClassName(Class<?> clazz) {
+    if (clazz==null) {
+      return null;
+    }
+    return getUnqualifiedClassName(clazz.getSimpleName());
+  }
+
+  public static String getUnqualifiedClassName(String className) {
+    if (className==null) {
+      return null;
+    }
+    int dotIndex = className.lastIndexOf('.');
+    if (dotIndex!=-1) {
+      className = className.substring(dotIndex+1);
+    }
+    return className;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/StringUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class StringUtil {
+  
+  public static List<String> tokenize(String text, String delimiter) {
+    if (delimiter==null) {
+      throw new JbpmException("delimiter is null");
+    }
+    if (text==null) {
+      return Collections.EMPTY_LIST;
+    }
+    
+    List<String> pieces = new ArrayList<String>();
+    
+    int start = 0;
+    int end = text.indexOf(delimiter);
+    while (end!=-1) {
+      pieces.add(text.substring(start, end));
+      start = end+delimiter.length();
+      end = text.indexOf(delimiter, start);
+    }
+    
+    if (start<text.length()) {
+      pieces.add(text.substring(start));
+    }
+    
+    return pieces;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/TagBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/TagBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/TagBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.xml.Binding;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class TagBinding implements Binding {
+  
+  protected String category;
+  protected String tagName;
+  protected String namespaceUri;
+  
+  /** @param tagName is required and represents the local part of the tag name.
+   * @param namespaceUri is optional (null is allowed) and represents the full 
+   *   namespace URI of the element
+   * @param category is optional (null is allowed) and represents the category of 
+   *   the binding. 
+   * @see Bindings */
+  public TagBinding(String tagName, String namespaceUri, String category) {
+    if (tagName==null) {
+      throw new JbpmException("tagName is null");
+    }
+    this.tagName = tagName;
+    this.namespaceUri = namespaceUri;
+    this.category = category;
+  }
+
+  public boolean matches(Element element) {
+    String elementNamespaceUri = element.getNamespaceURI();
+    if ( (elementNamespaceUri!=null)
+         && (namespaceUri!=null)
+         && (!namespaceUri.equals(elementNamespaceUri))
+       ) {
+      return false;
+    }
+    String elementTagLocalName = XmlUtil.getTagLocalName(element);
+    if (!tagName.equals(elementTagLocalName)) {
+      return false;
+    }
+    return true;
+  }
+
+  public String getCategory() {
+    return category;
+  }
+
+  public String toString() {
+    // xml parsing error messages depend on this implementation of the toString to be meaningfull 
+    return tagName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/UrlEntity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/UrlEntity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/UrlEntity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.xml.Entity;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+/**
+ * an implementation of {@link Entity} based on a {@link URL} used in the 
+ * {@link Parser}s implementation of {@link EntityResolver}.
+ * 
+ * @author Tom Baeyens
+ */
+public class UrlEntity implements Entity {
+
+  protected String systemId = null;
+  protected URL url = null;
+
+  public UrlEntity(URL url, String systemId) {
+    this.url = url;
+    this.systemId = systemId;
+  }
+  
+  public UrlEntity(String resource, ClassLoader classLoader) {
+    this.url = classLoader.getResource(resource);
+    if (url!=null) {
+      this.systemId = url.toString();
+    } else {
+      throw new JbpmException("couldn't create Entity from resource "+resource);
+    }
+  }
+
+  public InputSource getInputSource() {
+    try {
+      InputStream stream = url.openStream();
+      InputSource inputSource = new InputSource(stream);
+      inputSource.setSystemId(systemId);
+      return inputSource;
+    } catch (IOException e) {
+      throw new JbpmException("couldn't open stream from url "+url, e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,519 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.jbpm.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.xml.Parse;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * convenience methods to make reading org.w3c.dom models easier.
+ *
+ * @author Tom Baeyens
+ */
+public class XmlUtil {
+
+  private static Log log = Log.getLog(XmlUtil.class.getName());
+
+  private XmlUtil() {
+    // hide default constructor to prevent instantiation
+  }
+
+  public static List<Element> elements(Element element, String tagName) {
+    if (element==null) {
+      return Collections.emptyList();
+    }
+    NodeList activityList = element.getChildNodes();
+    if ( (activityList == null)
+         || (activityList.getLength()==0)
+       ) {
+      return Collections.emptyList();
+    }
+    List<Element> elements = new ArrayList<Element>();
+    for (int i = 0; i < activityList.getLength(); i++) {
+      Node child = activityList.item(i);
+      if (Element.class.isAssignableFrom(child.getClass())) {
+        Element childElement = (Element) child;
+        String childTagName = getTagLocalName(childElement);
+        if (childTagName.equals(tagName)) {
+          if (elements == null) {
+            elements = new ArrayList<Element>();
+          }
+          elements.add(childElement);
+        }
+      }
+    }
+    return elements;
+  }
+
+  public static List<Element> elements(Element element, Set<String> allowedTagNames) {
+    if (element==null) {
+      return Collections.emptyList();
+    }
+    NodeList activityList = element.getChildNodes();
+    if ( (activityList == null)
+         || (activityList.getLength()==0)
+       ) {
+      return Collections.emptyList();
+    }
+    List<Element> elements = new ArrayList<Element>();
+    for (int i = 0; i < activityList.getLength(); i++) {
+      Node child = activityList.item(i);
+      if (Element.class.isAssignableFrom(child.getClass())) {
+        Element childElement = (Element) child;
+        String childTagName = getTagLocalName(childElement);
+        if (allowedTagNames.contains(childTagName)) {
+          if (elements == null) {
+            elements = new ArrayList<Element>();
+          }
+          elements.add(childElement);
+        }
+      }
+    }
+    return elements;
+  }
+
+  public static Element element(Element element, String tagName) {
+    return element(element, tagName, false, null);
+  }
+
+  public static Element element(Element element, String tagName, boolean required, Parse parse) {
+    if (element==null) {
+      return null;
+    }
+    NodeList activityList = element.getChildNodes();
+    for (int i = 0; (i < activityList.getLength()); i++) {
+      Node child = activityList.item(i);
+      if ((Element.class.isAssignableFrom(child.getClass())) && (getTagLocalName((Element) child)).equals(tagName)) {
+        return (Element) child;
+      }
+    }
+    
+    if (required && (parse!=null)) {
+      parse.addProblem("nested element <"+XmlUtil.getTagLocalName(element)+"><"+tagName+" ... />... is required");
+    }
+    return null;
+  }
+
+
+  public static List<Element> elements(Element element) {
+    if (element==null) {
+      return Collections.emptyList();
+    }
+    NodeList activityList = element.getChildNodes();
+    if ( (activityList == null)
+         || (activityList.getLength()==0)
+       ) {
+      return Collections.emptyList();
+    }
+    List<Element> elements = new ArrayList<Element>();
+    if ((activityList != null) && (activityList.getLength() > 0)) {
+      elements = new ArrayList<Element>();
+      for (int i = 0; i < activityList.getLength(); i++) {
+        Node activity = activityList.item(i);
+        if (activity instanceof Element) {
+          elements.add((Element) activity);
+        }
+      }
+    }
+    return elements;
+  }
+
+  public static List<Element> elements(Element element, String ns, String localName) {
+    if (element==null) {
+      return Collections.emptyList();
+    }
+    NodeList activityList = element.getChildNodes();
+    if ( (activityList == null)
+         || (activityList.getLength()==0)
+       ) {
+      return Collections.emptyList();
+    }
+    List<Element> matchingElements = new ArrayList<Element>();
+    NodeList nl = element.getChildNodes();
+    for (int i=0;i<nl.getLength();i++) {
+      Node n = nl.item(i);
+      if (n instanceof Element && n.getLocalName() != null && n.getLocalName().equals(localName) && n.getNamespaceURI() != null && n.getNamespaceURI().equals(ns)) {
+        matchingElements.add((Element)n);
+      }
+    }
+    return matchingElements;
+  }
+
+  public static List<Element> elementsQName(Element element, Set<QName> allowedTagNames) {
+    if (element==null) {
+      return Collections.emptyList();
+    }
+    NodeList activityList = element.getChildNodes();
+    if ( (activityList == null)
+         || (activityList.getLength()==0)
+       ) {
+      return Collections.emptyList();
+    }
+    List<Element> elements = new ArrayList<Element>();
+    if (activityList != null) {
+      for (int i = 0; i < activityList.getLength(); i++) {
+        Node child = activityList.item(i);
+        if (Element.class.isAssignableFrom(child.getClass())) {
+          Element childElement = (Element) child;
+          QName childElementQName = new QName(childElement.getNamespaceURI(), childElement.getLocalName());
+          if (allowedTagNames.contains(childElementQName)) {
+            if (elements == null) {
+              elements = new ArrayList<Element>();
+            }
+            elements.add(childElement);
+          }
+        }
+      }
+    }
+    return elements;
+  }
+
+  public static Element element(Element element) {
+    Element onlyChild = null;
+    List<Element> elements = elements(element);
+    if (!elements.isEmpty()) {
+      onlyChild = elements.get(0);
+    }
+    return onlyChild;
+  }
+
+  public static String toString(Element element) {
+    if (element == null) {
+      return "null";
+    }
+
+    Source source = new DOMSource(element);
+
+    StringWriter stringWriter = new StringWriter();
+    PrintWriter printWriter = new PrintWriter(stringWriter);
+    Result result = new StreamResult(printWriter);
+
+    try {
+      TransformerFactory transformerFactory = TransformerFactory.newInstance();
+      Transformer transformer = transformerFactory.newTransformer();
+      transformer.transform(source, result);
+    } catch (Exception e) {
+      log.error("couldn't transform dom element into string representation");
+      return "<" + element.getTagName() + " ... >...</" + element.getTagName() + ">";
+    }
+
+    printWriter.close();
+
+    return stringWriter.toString();
+  }
+
+  public static String getContentText(Element element) {
+    StringBuffer buffer = new StringBuffer();
+    NodeList activityList = element.getChildNodes();
+    for (int i = 0; i < activityList.getLength(); i++) {
+      Node activity = activityList.item(i);
+      if (activity instanceof CharacterData) {
+        CharacterData characterData = (CharacterData) activity;
+        buffer.append(characterData.getData());
+      }
+    }
+    return buffer.toString();
+  }
+
+  public static boolean isTextOnly(Element element) {
+    boolean isTextOnly = true;
+    NodeList activityList = element.getChildNodes();
+    for (int i = 0; ((i < activityList.getLength()) && (isTextOnly)); i++) {
+      if (Element.class.isAssignableFrom(activityList.item(i).getClass())) {
+        isTextOnly = false;
+      }
+    }
+    return isTextOnly;
+  }
+
+  public static List<Attr> attributes(Element element) {
+    NamedNodeMap attributeMap = element.getAttributes();
+    if ((attributeMap == null) || (attributeMap.getLength() == 0)) {
+      return Collections.emptyList();
+    }
+
+    List<Attr> attributes = new ArrayList<Attr>();
+    for (int i = 0; i < attributeMap.getLength(); i++) {
+      attributes.add((Attr) attributeMap.item(i));
+    }
+
+    return attributes;
+  }
+
+  public static List<Node> contents(Element element) {
+    NodeList activityList = element.getChildNodes();
+    if ((activityList == null) || (activityList.getLength() == 0)) {
+      return Collections.emptyList();
+    }
+
+    List<Node> contents = new ArrayList<Node>();
+    for (int i = 0; i < activityList.getLength(); i++) {
+      contents.add((Node) activityList.item(i));
+    }
+
+    return contents;
+  }
+
+  public static String getTagLocalName(Element element) {
+    if (element == null) {
+      return null;
+    }
+    String localName = element.getLocalName();
+    if (localName != null) {
+      return localName;
+    }
+    return element.getTagName();
+  }
+
+  /** the attribute value or null if the attribute is not present */
+  public static String attribute(Element element, String attributeName) {
+    if (element.hasAttribute(attributeName)) {
+      return element.getAttribute(attributeName);
+    } else {
+      return null;
+    }
+  }
+
+  /** convenience method to combine extraction of a string attribute value.
+   * 
+   * If the attribute exists, it is returned.  If the attribute is not present, null 
+   * is returned.  The attribute is not present and it is required, 
+   * a problem will be added to the parse.  */
+  public static String attribute(Element element, String attributeName, boolean required, Parse parse) {
+    return attribute(element, attributeName, required, parse, null);
+  }
+
+  /** convenience method to combine extraction of a string attribute value.
+   * 
+   * If the attribute exists, it is returned.  If the attribute is not present, the 
+   * defaultValue is returned.  The attribute is not present and it is required, 
+   * a problem will be added to the parse.  */
+  public static String attribute(Element element, String attributeName, boolean required, Parse parse, String defaultValue) {
+    if (element.hasAttribute(attributeName)) {
+      String value = element.getAttribute(attributeName);
+      if (required && "".equals(value)) {
+        parse.addProblem("attribute <"+XmlUtil.getTagLocalName(element)+" "+attributeName+"=\"\" is empty");
+      }
+      return value;
+    } 
+
+    if (required) {
+      parse.addProblem("attribute <"+XmlUtil.getTagLocalName(element)+" "+attributeName+"=\"...\" is required");
+    }
+    
+    return null;
+  }
+  
+  
+  /** parse an attribute as an integer. */
+  public static Integer attributeInteger(Element element, String attributeName, boolean required, Parse parse) {
+    String valueText = attribute(element, attributeName, required, parse);
+
+    if (valueText!=null) {
+      try {
+        return Integer.parseInt(valueText);
+      } catch (NumberFormatException e) {
+        parse.addProblem(errorMessageAttribute(element, attributeName, valueText, "value not parsable as integer"));
+      }
+    }
+
+    return null;
+  }
+
+  /** parse an attribute as an boolean. */
+  public static Boolean attributeBoolean(Element element, String attributeName, boolean required, Parse parse) {
+    return attributeBoolean(element, attributeName, required, parse, null);
+  }
+  
+  /** parse an attribute as an boolean. */
+  public static Boolean attributeBoolean(Element element, String attributeName, boolean required, Parse parse, Boolean defaultValue) {
+    String valueText = attribute(element, attributeName, required, parse);
+    if (valueText!=null) {
+      Boolean value = parseBooleanValue(valueText);
+      if (value==null) {
+        parse.addProblem(errorMessageAttribute(element, attributeName, valueText, "value not in {true, enabled, on, false, disabled, off}"));
+      }
+      return value; 
+    }
+    return defaultValue;
+  }
+
+  public static Boolean parseBooleanValue(String valueText) {
+    if (valueText!=null) {
+      // if we have to check for value true
+      if ( ("true".equals(valueText))
+          || ("enabled".equals(valueText))
+          || ("on".equals(valueText))
+        ) {
+       return Boolean.TRUE;
+
+      } else if ( ("false".equals(valueText))
+           || ("disabled".equals(valueText))
+           || ("off".equals(valueText))
+        ) {
+        return Boolean.FALSE;
+      }
+    }
+    
+    return null;
+  }
+  
+  public static String errorMessageAttribute(Element element, String attributeName, String attributeValue, String message) {
+    return "attribute <"+XmlUtil.getTagLocalName(element)+" "+attributeName+"=\""+attributeValue+"\" "+message;
+  }
+
+  public static List<String> parseList(Element element, String singularTagName) {
+    // a null value for text represents a wildcard
+    String text = XmlUtil.attribute(element, singularTagName + "s");
+    // so next we'll convert a '*' into the text null value, which indicates a
+    // wildcard
+    if ("*".equals(text)) {
+      text = null;
+    }
+    if (element.hasAttribute(singularTagName)) {
+      String eventText = element.getAttribute(singularTagName);
+      text = (text == null ? eventText : text + "," + eventText);
+    }
+    List<String> eventNames = parseCommaSeparatedList(text);
+    return eventNames;
+  }
+
+  /**
+   * parses comma or space separated list. A null return value means a wildcard.
+   *
+   * @return List of tokens or null if the commaSeparatedListText is null, '*',
+   *         or empty
+   */
+  public static List<String> parseCommaSeparatedList(String commaSeparatedListText) {
+    List<String> entries = null;
+    if (commaSeparatedListText != null) {
+      if (!"*".equals(commaSeparatedListText)) {
+        StringTokenizer tokenizer = new StringTokenizer(commaSeparatedListText, ", ");
+        while (tokenizer.hasMoreTokens()) {
+          if (entries == null) {
+            entries = new ArrayList<String>();
+          }
+          entries.add(tokenizer.nextToken());
+        }
+      }
+    }
+    return entries;
+  }
+
+  public static class NamespaceValue {
+
+    public String prefix;
+    public String localPart;
+
+    public NamespaceValue(String prefix, String localPart) {
+      this.prefix = prefix;
+      this.localPart = localPart;
+    }
+  }
+
+  public static NamespaceValue attributeNamespaceValue(Element element, String attributeName) {
+    NamespaceValue namespaceValue = null;
+    String text = attribute(element, attributeName);
+    if (text != null) {
+      int colonIndex = text.indexOf(':');
+      if (colonIndex == -1) {
+        namespaceValue = new NamespaceValue(null, text);
+      } else {
+        String prefix = text.substring(0, colonIndex);
+        String localPart = null;
+        if (text.length() > colonIndex + 1) {
+          localPart = text.substring(colonIndex + 1);
+        }
+        namespaceValue = new NamespaceValue(prefix, localPart);
+      }
+    }
+    return namespaceValue;
+  }
+
+  public static QName attributeQName(Element element, String attributeName) {
+    QName qname = null;
+
+    NamespaceValue namespaceValue = attributeNamespaceValue(element, attributeName);
+    String text = attribute(element, attributeName);
+    if (namespaceValue!=null) {
+      if (namespaceValue.prefix==null) {
+        qname = new QName(text);
+      } else {
+        String uri = element.lookupNamespaceURI(namespaceValue.prefix);
+        if (uri==null) {
+          throw new JbpmException("unknown prefix in qname "+text);
+        } else if (namespaceValue.localPart==null) {
+          throw new JbpmException("no local part in qname "+text);
+        } else {
+          qname = new QName(uri, namespaceValue.localPart, namespaceValue.prefix);
+        }
+      }
+    }
+    return qname;
+  }
+
+  public static QName getQNameFromString(Element element, String qnameAsString) {
+    if (qnameAsString == null || element == null) {
+      return null;
+    }
+    int colonIndex = qnameAsString.indexOf(":");
+    String prefix = qnameAsString.substring(0, colonIndex);
+    String localName = qnameAsString.substring(colonIndex + 1);
+    String ns = getNamespaceURI(element, prefix);
+    return new QName(ns, localName, prefix);
+  }
+
+  public static String getNamespaceURI(final org.w3c.dom.Node n, final String prefix) {
+    Node prefixDeclaration = n.getAttributes().getNamedItem("xmlns:" + prefix);
+    if (prefixDeclaration != null) {
+      // we have found the good NameSpace
+      return prefixDeclaration.getNodeValue();
+    }
+    // we have found the good NameSpace
+    // we look for the NameSpace in the parent Node
+    return getNamespaceURI(n.getParentNode(), prefix);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/Descriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/Descriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/Descriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.util.Observable;
+
+/**
+ * knows how an object can be created.
+ *
+ * <p>A {@link WireDefinition} contains a map of {@link Descriptor}s.
+ * They are used by the {@link WireContext} that will build and cache the 
+ * objects.
+ * </p>
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ */
+public interface Descriptor extends Observable, Serializable {
+
+  /**
+   * is fired when construction of a wired object starts.  The provided event is a {@link WireObjectEventInfo}.
+   * @see WireContext
+   */
+  String EVENT_CONSTRUCTING = "constructing";
+  /**
+   * is fired when initialization of a wired object starts (after construction).  The provided event is a {@link WireObjectEventInfo}.
+   * @see WireContext
+   */
+  String EVENT_INITIALIZING = "initializing";
+  /**
+   * is fired when object construction is completed.  The provided event is a {@link WireObjectEventInfo}.
+   * @see WireContext
+   */
+  String EVENT_CONSTRUCTED = "constructed";
+  /**
+   * is fired when an object is being set into the cache of this wire context with {@link WireContext#set(String, Object)}.  The provided event is a {@link WireObjectEventInfo}.
+   * @see WireContext
+   */
+  String EVENT_SET = "set";
+  /**
+   * is fired when an object is being removed from the cache of the wire context with {@link WireContext#remove(String)}.  The provided event is a {@link WireObjectEventInfo}.
+   * @see WireContext
+   */
+  String EVENT_REMOVE = "remove";
+
+  /** the name of this descriptor */
+  String getName();
+
+  /** the type of the produced object or null if that is not available */
+  Class<?> getType(WireDefinition wireDefinition);
+
+  /**
+   * if eager initialization is set, it means that an object must be created  
+   * immediately during construction of the {@link WireContext}. 
+   */
+  boolean isEagerInit();
+
+  /**
+   * constructs the object.
+   * @param wireContext {@link WireContext} in which the object is created. This is also the {@link WireContext} 
+   * where the object will search for other object that may be needed during the initialization phase.
+   * @return the constructed object.
+   */
+  Object construct(WireContext wireContext);
+  
+  /**
+   * Checks if the initialization should be done during the construction phase or if it can be done later.
+   * @return <code>false</code> if the initialization should be done during the creation phase, <code>true</code> if it can be done later.
+   */
+  boolean isDelayable();
+
+  /**
+   * called by the WireContext to initialize the specified object.
+   * For more information about initialization, see {@link WireContext} section lifecycle.
+   * @param object object to initialize.
+   * @param wireContext the context in which the object will be initialized.
+   */
+  void initialize(Object object, WireContext wireContext);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,739 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.model.ProcessElementImpl;
+import org.jbpm.pvm.internal.util.Closable;
+import org.jbpm.pvm.internal.util.DefaultObservable;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.operation.FieldOperation;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+import org.jbpm.pvm.internal.wire.operation.Operation;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+import org.jbpm.pvm.internal.wire.operation.SubscribeOperation;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * object factory that creates, initializes, wires and caches objects
+ * based on {@link Descriptor descriptors} (aka IoC container).
+ *
+ * <h3>General principle</h3>
+ *
+ * <p>As input, a WireContext takes a {@link WireDefinition}.  The WireDefinition contains
+ * named {@link Descriptor}s that know how to create objects and wire them together.
+ * Each object has a name.  The WireContext will maintain a cache (map) of the created
+ * objects.  So that upon subsequent requests, the same object can be given from the cache.
+ * </p>
+ *
+ * <center><img src="wirescope.gif"/></center>
+ *
+ * <h3>Purpose</h3>
+ * 
+ * <p>A WireContext is used often in combination with {@link Environment} to 
+ * decouple the processDefinition virtual machine from its environment.  In the 
+ * {@link JbpmConfiguration}, both the process-engine context and 
+ * the environment contexts are WireContexts.  The PVM will use the persistence service, 
+ * asynchronous message service, timer service and other services through specified 
+ * abstractions in the environment.
+ * </p>
+ * 
+ * <p>Another usage of the WireContext is construction and configuration of user 
+ * code objects in a persistable way.  {@link ActivityBehaviour}s and {@link org.jbpm.activity.ExternalActivityBehaviour}
+ * and other user code can be instantiated with a WireContext.  That way, they can 
+ * be persisted in a fixed schema.    
+ * </p>
+ * 
+ * <p>Each {@link ProcessElementImpl} has configuration properties.
+ * Consider this extra metadata that can be associated to elements in a processDefinition definition.
+ * In that respect, it's somewhat similar to what annotations are in Java.  Because of the wire 
+ * persistence, all these configuration properties fit into the same process model and in its 
+ * database schema.  
+ * </p>
+ *
+ * <h3>Xml</h3>
+ * <p>Mostly often, {@link Descriptor}s and WireContext's are not used
+ * directly.  Instead, the wire XML is used in a configuration file.
+ * The {@link WireParser wire XML parser} contains the documentation on
+ * the XML grammer.  The {@link WireParser} will produce a {@link WireDefinition}
+ * with a bunch of {@link Descriptor}s in it.
+ *
+ * <h3 id="lifecycle">Object lifecycle</h3>
+ *
+ * <p>Objects are build in 2 phases: construction and initialization.
+ * The motivation for splitting these phases is to resolve many of the
+ * circular dependencies.  Imagine 2 objects that have a bidirectional
+ * reference.  By splitting the construction from the initialization
+ * phase, the objects can both be constructed first, and then during
+ * initialization, they will be injected into each other.
+ * </p>
+ *
+ * <h3>Construction</h3>
+ * <p>Construction of the object is all that needs to be done until a
+ * reference to the object is available.
+ * </p>
+ *
+ * <p>In the case of dynamically created
+ * objects ({@link ObjectDescriptor}), the simplest case this is
+ * accomplished with a constructor.  But also static or non-static factory
+ * methods can be used to obtain a reference to an object.
+ * </p>
+ *
+ * <p>In case of immutable objects, the descriptor can just provide a reference
+ * to a singleton object.
+ * </p>
+ *
+ * <h3>Initialization</h3>
+ * <p>Initialization is optional and it is comprised of everything that needs
+ * to be done with an object after a reference to the object is available.
+ * {@link AbstractDescriptor} contains an empty default initialization method.
+ * </p>
+ *
+ * <p>For objects {@link ObjectDescriptor}s, this means that a a
+ * sequence of {@link Operation}s can be applied to the object.  Following
+ * operations implementations are already available and can be applied to
+ * an object during initialization:
+ * </p>
+ *
+ * <ul>
+ *   <li><b>{@link FieldOperation}</b>: injects another object into a field</li>
+ *   <li><b>{@link PropertyOperation}</b>: injects another object with a setter method.</li>
+ *   <li><b>{@link InvokeOperation}</b>: invokes a method.</li>
+ *   <li><b>{@link SubscribeOperation}</b>: subscribes to an {@link Observable observable}.</li>
+ * </ul>
+ *
+ * <h3>Environment</h3>
+ *
+ * <p>When an environment is injected into a WireContext, lookup of all
+ * referenced object names will be done first in this WireContext, but
+ * if the object name is not defined there, the environment will be
+ * searched in the environment's default search order.
+ * </p>
+ *
+ * <h3>Events</h3>
+ * <p>Several objects will fire events to which can be subscribed:
+ * </p>
+ *
+ * <p>The WireContext itself fires the {@link #EVENT_OPEN} and {@link #EVENT_OPEN}
+ * events.
+ * </p>
+ *
+ * <p>The {@link Descriptor}s will fire the events {@link Descriptor#EVENT_CONSTRUCTING},
+ * {@link Descriptor#EVENT_INITIALIZING}, {@link Descriptor#EVENT_CONSTRUCTED},
+ * {@link Descriptor#EVENT_SET} and {@link Descriptor#EVENT_REMOVE}.
+ * </p>
+ *
+ * <p>And last but not least, the objects created by the WireContext can be
+ * {@link Observable} themselves.
+ * </p>
+ *
+ * <h3>Eager initialization</h3>
+ * 
+ * <p>By default, all objects in a WireContext are lazily constructued and initialized.
+ * Eager initialization is specified on a named object and it means that the 
+ * object is constructed and initialized during construction of the WireContext.
+ * You an only specify eager initialization when the object has a name.
+ * </p>
+ * 
+ * <h3>Specifying how an object should be initialized.</h3>
+ *
+ * <p>The initialization can be specified with the {@link AbstractDescriptor#setInit(char)} method.</p>
+ * The possible value for <code>init</code> parameter is one of :
+ * <ul>
+ *   <li>{@link AbstractDescriptor#INIT_LAZY}: for lazy creation and delayed initialization</li>
+ *   <li>{@link AbstractDescriptor#INIT_REQUIRED}: for lazy creation and immediate initialization</li>
+ *   <li>{@link AbstractDescriptor#INIT_EAGER}: for eager creation and delayed initialization</li>
+ *   <li>{@link AbstractDescriptor#INIT_IMMEDIATE}: for eager creation and immediate initialization</li>
+ * </ul>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class WireContext extends DefaultObservable implements Context, Closable, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(WireContext.class.getName());
+
+  // events ///////////////////////////////////////////////////////////////////
+
+  /**
+   * is fired when a new wiring environment is being opened. No event info provided.
+   */
+  public static final String EVENT_OPEN = "open";
+  /**
+   * is fired when the wiring environment is being closed.  No event info provided.
+   */
+  public static final String EVENT_CLOSE = "close";
+
+  // member fields ////////////////////////////////////////////////////////////
+
+  protected String name = "wire-context";
+  protected transient ClassLoader classLoader;
+  protected WireDefinition wireDefinition;
+
+  /** objects that are being instantiated or constructed */
+  Set<String> underConstruction = null;
+
+  /** objects that are constructed, but waiting for the initialization operations (like e.g. injections) to be performed */
+  Map<String, PendingInitialization> pendingInitializations = null;
+
+  /** objects on which the initialization operations (like e.g. injections) are being performed */
+  Map<String, Object> underInitialization = null;
+
+  /** fully created and initialized objects */
+  Map<String, Object> cache = null;
+  
+  /** exceptions throw by descriptor invocations */
+  Map<String, Exception> exceptions = null;
+
+
+  public WireContext() {
+  }
+
+  public WireContext(WireDefinition wireDefinition) {
+    this(wireDefinition, null, null, false);
+  }
+
+  /** when this {@link Context} is used in an {@link Environment}, it 
+   * needs a name.  */
+  public WireContext(WireDefinition wireDefinition, String name) {
+    this.wireDefinition = wireDefinition;
+    this.name = name;
+    this.classLoader = (wireDefinition!=null ? wireDefinition.getClassLoader() : null);
+    create();
+  }
+
+  /**
+   * allows for postponing the creation of this wire context.
+   * @param delayCreate specifies if creation should be postponed till {@link #create()} is called explicitly.
+   *   If delayCreate is set to false, creation is done as part of the constructor.  If delayCreate is
+   *   set to true, the {@link #create()} method needs to be called explicitly by the client after
+   *   construction is complete.  The use case is creation of environment where the transactionName needs to be
+   *   set and the scope needs to be added to the environment before the creation of this wire scope is done.
+   * @see JbpmConfiguration#openEnvironment()
+   */
+  public WireContext(WireDefinition wireDefinition, String name, Environment environment, boolean delayCreate) {
+    this.wireDefinition = wireDefinition;
+    this.name = name;
+    this.classLoader = (wireDefinition!=null ? wireDefinition.getClassLoader() : null);
+
+    if (! delayCreate) {
+      create();
+    }
+  }
+  
+  /** convenience method that wires the object for a given descriptor. */
+  public static Object create(Descriptor descriptor) {
+    WireContext wireContext = new WireContext();
+    return wireContext.create(descriptor, false);
+  }
+
+  /**
+   * initializes the eager objects and then fires the create event.  This method
+   * only needs to be called explicitly in case <code>delayCreate</code> is true
+   * in {@link #WireContext(WireDefinition, String, Environment, boolean)}.
+   */
+  public void create() {
+    log.trace("creating "+name);
+    initializeEagerObjects();
+    fire(EVENT_OPEN, null);
+  }
+
+  /**
+   * Initializes all the eager objects defined in the {@link #wireDefinition}.
+   */
+  void initializeEagerObjects() {
+    if(wireDefinition != null) {
+      List<String> eagerInitObjectNames = wireDefinition.getEagerInitNames();
+      if (eagerInitObjectNames!=null) {
+        for (String eagerInitObjectName: eagerInitObjectNames) {
+          Descriptor descriptor = wireDefinition.getDescriptor(eagerInitObjectName);
+          if (descriptor.isEagerInit()) {
+            log.debug("eagerly initializing "+eagerInitObjectName);
+            get(eagerInitObjectName, descriptor.isDelayable());
+          }
+        }
+        while ( (! hasObjectUnderConstruction()) 
+                && (! hasObjectUnderInitialization())
+                && (hasPendingInitializations())
+              ) {
+         processPendingInitializations();
+        }
+      }
+    }
+  }
+
+  public String toString() {
+    return (name!=null ? name : super.toString());
+  }
+
+
+  // environment methods //////////////////////////////////////////////////////////
+
+  /** the list of object names defined in this context.  This means the union of the
+   * object names that are defined in the {@link #wireDefinition} and the objects that 
+   * are just {@link #set(String, Object)}.  If there are no keys, an empty set will 
+   * be returned. */
+  public Set<String> keys() {
+    Set<String> keys = new HashSet<String>();
+    if (cache!=null) keys.addAll(cache.keySet());
+    if (wireDefinition!=null) {
+      Map<String, Descriptor> descriptors = wireDefinition.getDescriptors();
+      if (descriptors!=null) {
+        keys.addAll(descriptors.keySet());
+      }
+    }
+    return keys;
+  }
+
+  /** checks if the given objectName is defined, either by means of a descriptor or by an explicit {@link #set(String, Object)}. */
+  public boolean has(String objectName) {
+    return (hasCached(objectName) || (wireDefinition != null ? wireDefinition.hasDescriptor(objectName) : false));
+  }
+
+  /** retrieves the object for the given objectName, ensuring it is constructed and initialized.
+   * @return the object found, or null if the object was not found. */
+  public Object get(String objectName) {
+    return get(objectName, false);
+  }
+
+  /** adds an object to this context, which means storing it in the cache.  This doesn't have to be an object that is 
+   * defined by the {@link WireDefinition}.  If an object is set under a certain objectName that also is associated with 
+   * a descriptor, the object provided in this set invocation will be delivered upon subsequent {@link #get(String)} 
+   * requests. 
+   * @return previous value of the object with the name objectName in the {@link #cache}
+   * @throws WireException when the objectName is null
+   */
+  public synchronized Object set(String objectName, Object object) {
+    if (objectName==null) throw new WireException("objectName is null");
+    if (cache==null) {
+      cache = new HashMap<String, Object>();
+    }
+    fireObjectEvent(Descriptor.EVENT_SET, objectName, object);
+    return cache.put(objectName, object);
+  }
+
+  /** removes an object from the context and fires the remove event.
+   * @return previous object associated with the given name, or null if there was no mapping for this name. */
+  public Object remove(String objectName) {
+    Object removed = null;
+    if (cache!=null) {
+      removed = cache.remove(objectName);
+      fireObjectEvent(Descriptor.EVENT_REMOVE, objectName, removed);
+    }
+    return removed;
+  }
+
+  /** clears the {@link #cache}. */
+  public synchronized void clear() {
+    if (cache!=null) {
+      Set<String> objectsInCache = new HashSet<String>(cache.keySet()); 
+      for (String object: objectsInCache) {
+        remove(object);
+      }
+    }
+  }
+
+  /** fires the close event then removes the listeners, and cleans up the constructed objects 
+   * of the context (cleans up the object in the cache and the object in construction).
+   * @see #EVENT_CLOSE
+   */
+  public synchronized void close() {
+    log.trace("closing "+name+"...");
+
+    // fire the close event
+    fire(EVENT_CLOSE, null);
+  }
+
+  // object access helper methods /////////////////////////////////////////////
+
+  /** gets the object having the name <code>objectName</code> in this context.
+   * @param isDelayable indicates wether initialization is delayable.  When isDelayable is set to false 
+   * the returned object will be constructed and initialized.  When isDelayable is set to true, the returned 
+   * object will be constructed, but not necessarily initialized.
+   * @return the object found or created, or null if the object was not found and cannot be created.
+   * @throws WireException if a circular dependency was found during the object creation.
+   */
+  public synchronized Object get(String objectName, boolean isDelayable) {
+    if (hasException(objectName)) {
+      throw new WireException("getting "+objectName+" previously resulted in an exception", exceptions.get(objectName));
+    }
+    
+    // first check if the object is in the cache
+    if (hasCached(objectName)) {
+      Object object = cache.get(objectName);
+      log.trace("delivering "+objectName);
+      return object;
+    } 
+
+    // then check if it is constructed, but not yet in the cache (pending or under initialization)
+    Object constructed = getConstructed(objectName);
+    if ( isDelayable
+         && (null != constructed)
+       ) {
+      Object object = constructed;
+      log.trace("providing already constructed "+objectName);
+      return object;
+    }
+
+    // then check if we can create the object from a descriptor
+    boolean hasDescriptor = (wireDefinition!=null ? wireDefinition.hasDescriptor(objectName) : false);
+    if (hasDescriptor) {
+
+      if (isUnderConstruction(objectName) || isUnderInitialization(objectName)) {
+        throw new WireException("circular dependency for "+objectName);
+      }
+
+      return create(objectName, isDelayable);
+    }
+    
+    // then check if we can find it in the environment (if one is available)
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      log.trace("delivering "+objectName+" from environment");
+      return environment.get(objectName);
+    }
+    
+    log.trace("delivering null for undefined object "+objectName);
+    return null;
+  }
+
+  /** creates a new object for the given objectName as defined in the {@link #wireDefinition}. 
+   * @param isDelayable indicates wether initialization is delayable.  When isDelayable is set to false 
+   * the returned object will be constructed and initialized.  When isDelayable is set to true, the returned 
+   * object will be constructed, but not necessarily initialized. */
+  protected Object create(String objectName, boolean isDelayable) {
+    Descriptor descriptor = wireDefinition.getDescriptor(objectName);
+    return create(descriptor, isDelayable);
+  }
+
+
+  /** creates a new object for the given descriptor.
+   * @param isDelayable indicates wether initialization is delayable.  When isDelayable is set to false 
+   * the returned object will be constructed and initialized.  When isDelayable is set to true, the returned 
+   * object will be constructed, but not necessarily initialized. */
+  public Object create(Descriptor descriptor, boolean isDelayable) {
+    Object object = null;
+
+    object = construct(descriptor);
+    initialize(object, descriptor, isDelayable);
+    processPendingInitializations();
+
+    return object;
+  }
+
+  Object construct(Descriptor descriptor) {
+    Object object;
+
+    String objectName = descriptor.getName();
+    if (objectName!=null) {
+      fireObjectEvent(Descriptor.EVENT_CONSTRUCTING, objectName, null);
+      if (underConstruction==null) {
+        underConstruction = new HashSet<String>();
+      }
+      underConstruction.add(objectName);
+      log.trace("constructing "+objectName);
+    }
+      
+    try {
+      object = descriptor.construct(this);
+    } catch (RuntimeException e) {
+      addException(descriptor, e);
+      throw e;
+    }
+
+    if (objectName!=null) {
+      underConstruction.remove(objectName);
+    }
+      
+    return object;
+  }
+  
+  // initialization ///////////////////////////////////////////////////////////
+  
+  private enum InitializationType {
+    NONE,
+    IMMEDIATE,
+    DELAYEBLE
+  }
+
+  void initialize(Object object, Descriptor descriptor, boolean isDelayable) {
+
+    InitializationType initializationType = getInitializationType(object, descriptor, isDelayable);
+    
+    if (initializationType==InitializationType.IMMEDIATE) {
+      performInitialization(object, descriptor);
+      
+    } else if (initializationType==InitializationType.DELAYEBLE) {
+      addPendingInitialization(object, descriptor);
+    
+    } else {
+      String objectName = descriptor.getName();
+      if (objectName!=null) {
+        set(objectName, object);
+      }
+    }
+  }
+  
+  InitializationType getInitializationType(Object object, Descriptor descriptor, boolean isDelayable) {
+    if  (object==null) {
+      return InitializationType.NONE;
+    }
+    
+    if (isDelayable && descriptor.isDelayable()) {
+      return InitializationType.DELAYEBLE;
+    } 
+    
+    return InitializationType.IMMEDIATE;
+  }
+
+  void performInitialization(Object object, Descriptor descriptor) {
+    String objectName = descriptor.getName();
+
+    if (objectName!=null) {
+      fireObjectEvent(Descriptor.EVENT_INITIALIZING, objectName, object);
+      if (underInitialization==null) {
+        underInitialization = new HashMap<String, Object>();
+      }
+      underInitialization.put(objectName, object);
+      log.trace("initializing "+objectName );
+    }
+    
+    try {
+      descriptor.initialize(object, this);
+    } catch (RuntimeException e) {
+      addException(descriptor, e);
+      throw e;
+    }
+
+    if (objectName!=null) {
+      underInitialization.remove(objectName);
+      // event constructed is fired before the object is put in the cache 
+      // because that generates a set event
+      fireObjectEvent(Descriptor.EVENT_CONSTRUCTED, objectName, object);
+      set(objectName, object);
+    }
+  }
+
+  void addPendingInitialization(Object object, Descriptor descriptor) {
+    if (pendingInitializations==null) {
+      pendingInitializations = new HashMap<String, PendingInitialization>();
+    }
+    pendingInitializations.put(descriptor.getName(), new PendingInitialization(object, descriptor));
+  }
+
+   void processPendingInitializations() {
+     if (pendingInitializations!=null) {
+       Collection<PendingInitialization> pendingInitializationValues = new HashSet<PendingInitialization>(pendingInitializations.values());
+       for (PendingInitialization pi: pendingInitializationValues) {
+         // move pi from pending initializations to under initialization
+         String objectName = pi.initializable.getName();
+         pi = pendingInitializations.remove(objectName);
+         if(pi != null) {
+           // initialize
+           performInitialization(pi.object, pi.initializable);
+         }
+       }
+     }
+  }
+
+  boolean hasPendingInitializations() {
+    return ( (pendingInitializations!=null)
+             && (!pendingInitializations.isEmpty())
+           );
+  }
+
+  /** container for an storing waiting objects and their initializable in the list 
+   * {@link #pendingInitializations}, while waiting for initialization. */
+  class PendingInitialization implements Serializable {
+    private static final long serialVersionUID = 1L;
+    Object object;
+    Descriptor initializable;
+    public PendingInitialization(Object object, Descriptor descriptor) {
+      this.object = object;
+      this.initializable = descriptor;
+    }
+    public String toString() {
+      String objectName = initializable.getName();
+      return "PendingInitialization["+(objectName!=null ? objectName+"|" : "")+object+"]";
+    }
+  }
+
+  /** checks if the given objectName is available in the cache, which means it already has 
+   * been constructed from a wire definition or it has been {@link #set(String, Object)}
+   * explicitely. */
+  public boolean hasCached(String objectName) {
+    return (cache!=null)
+           && (cache.containsKey(objectName));
+  }
+
+  /** finds the object in all stages after construction. */
+  Object getConstructed(String objectName) {
+    Object constructed = null;
+    if ( (pendingInitializations!=null)
+         && (pendingInitializations.containsKey(objectName))
+       ) {
+      constructed = pendingInitializations.get(objectName).object;
+    } else if ( (underInitialization!=null)
+                && (underInitialization.containsKey(objectName))
+              ) {
+      constructed = underInitialization.get(objectName);
+    }
+    return constructed;
+  }
+
+  /** fires a {@link WireObjectEventInfo}. */
+  protected void fireObjectEvent(String eventName, String objectName, Object object) {
+    WireObjectEventInfo wireEvent = null;
+
+    // first fire the event on the descriptor for object specific listeners
+    if (wireDefinition!=null) {
+      Map<String, Descriptor> descriptors = wireDefinition.getDescriptors();
+      if (descriptors!=null) {
+        Descriptor descriptor = descriptors.get(objectName);
+        if (descriptor!=null) {
+          if (wireEvent==null) {
+            wireEvent = new WireObjectEventInfo(eventName, objectName, object);
+          }
+          descriptor.fire(eventName, wireEvent);
+        }
+      }
+    }
+
+    // then fire the event on this wiring environment for global listeners
+    if ( (listeners!=null)
+         && (wireEvent==null)
+       ) {
+      wireEvent = new WireObjectEventInfo(eventName, objectName, object);
+    }
+
+    fire(eventName, wireEvent);
+  }
+
+
+  boolean hasObjectUnderConstruction() {
+    return ( (underConstruction!=null)
+             && (! underConstruction.isEmpty())
+           );
+  }
+
+  boolean hasObjectUnderInitialization() {
+    return ( (underInitialization!=null)
+             && (! underInitialization.isEmpty())
+           );
+  }
+
+  boolean isUnderConstruction(String objectName) {
+    return ( (underConstruction!=null)
+             && (underConstruction.contains(objectName))
+           ) ;
+  }
+
+  boolean isUnderInitialization(String objectName) {
+    return ( (underInitialization!=null)
+             && (underInitialization.containsKey(objectName))
+           ) ;
+  }
+
+  /** the class loader to use to create objects or if none was explicitely set in this wire context, 
+   * the default context class loader for the current thread. */
+  public ClassLoader getClassLoader() {
+    // if there is a specific classloader specified
+    if (classLoader!=null) {
+      return classLoader;
+    }
+    // otherwise, use the current environment classloader
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  public boolean hasClassLoader() {
+    return classLoader!=null;
+  }
+
+  // search by class //////////////////////////////////////////////////////////
+
+  /** searches for the first descriptor that defines an object of the given type.
+   * In case of multiple objects of the same type, the first object that 
+   * is declared of the given type will be found.  Also super classes and interfaces 
+   * are taken into account.   Not all descriptor types will be type sensitive, only:
+   * <pre>
+   * | ObjectDescriptor                       | object            |
+   * | HibernatePersistenceServiceDescriptor  | business-calendar |
+   * | TransactionDescriptor                  | transaction       |
+   * | PropertiesDescriptor                   | properties        |
+   * | BusinessCalendarDescriptor             | business-calendar |
+   * </ul>
+   * </pre>
+   */
+  public <T> T get(Class<T> type) {
+    if (wireDefinition!=null) {
+      String name = wireDefinition.getDescriptorName(type);
+      if (name!=null) {
+        return (T) get(name);
+      } 
+    }
+    return null;
+  }
+  
+  protected boolean hasException(String objectName) {
+    return ( (exceptions!=null)
+             && (exceptions.containsKey(objectName))
+           );
+  }
+  
+  protected void addException(Descriptor descriptor, Exception exception) {
+    if (exceptions==null) {
+      exceptions = new HashMap<String, Exception>();
+    }
+    exceptions.put(descriptor.getName(), exception);
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public String getName() {
+    return name;
+  }
+  public void setClassLoader(ClassLoader classLoader) {
+    this.classLoader = classLoader;
+  }
+  public WireDefinition getWireDefinition() {
+    return wireDefinition;
+  }
+  public void setWireDefinition(WireDefinition wireDefinition) {
+    this.wireDefinition = wireDefinition;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireDefinition.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+
+
+/**
+ * map of {@link Descriptor}s that serve as input for a {@link WireContext}.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class WireDefinition implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(WireDefinition.class.getName());
+
+  transient ClassLoader classLoader;
+  /** maps object names to {@link Descriptor}s */
+  Map<String, Descriptor> descriptors;
+  Map<Class<?>, String> descriptorNames;
+  boolean useTypes = true;
+
+  /** references all objects that must eagerly initialized.
+   * @see WireContext */
+  List<String> eagerInitNames;
+  
+
+  public WireDefinition() {
+  }
+
+  public void addDescriptor(Descriptor descriptor) {
+    if (descriptor!=null) {
+
+      String name = descriptor.getName();
+
+      if (useTypes) {
+        Class<?> type = descriptor.getType(this);
+
+        if (type!=null) {
+          if ( (name==null)
+               && (descriptor instanceof AbstractDescriptor)
+             ) {
+            name = type.getName();
+            ((AbstractDescriptor)descriptor).setName(type.getName());
+          }
+          
+          if ( (name!=null)
+               && ( (descriptors==null)
+                    || (!descriptors.containsKey(name))
+                  )
+             ) {
+            // add all superclasses and interfaces to map to this descriptor
+            addDescriptorType(type, descriptor, name);
+          }
+        }
+      }
+      
+      if ( (name!=null)
+           && (! hasDescriptor(name))
+         ) {
+        putDescriptor(name, descriptor);
+
+        if (descriptor.isEagerInit()) {
+          addEagerInitObjectName(name);
+        }
+      }
+      
+    }
+  }
+
+  void putDescriptor(String name, Descriptor descriptor) {
+    if (descriptors==null) {
+      descriptors = new HashMap<String, Descriptor>();
+    }
+    descriptors.put(name, descriptor);
+  }
+
+  void addDescriptorType(Class<?> type, Descriptor descriptor, String descriptorName) {
+    if (type!=null) {
+      if (descriptorNames==null) {
+        descriptorNames = new HashMap<Class<?>, String>();
+      }
+      if (!descriptorNames.containsKey(type)) {
+        descriptorNames.put(type, descriptorName);
+      }
+      addDescriptorType(type.getSuperclass(), descriptor, descriptorName);
+      Class<?>[] interfaceTypes = type.getInterfaces();
+      if (interfaceTypes!=null) {
+        for (Class<?> interfaceType: interfaceTypes) {
+          addDescriptorType(interfaceType, descriptor, descriptorName);
+        }
+      }
+    }
+  }
+  
+  public String getDescriptorName(Class<?> type) {
+    return (descriptorNames!=null ? descriptorNames.get(type) : null ); 
+  }
+
+  /** the descriptor with the given name from the WireDefinition or <code>null</code>
+   * if the object doesn't have a descriptor.
+   */
+  public Descriptor getDescriptor(String objectName) {
+    if (descriptors==null) {
+      return null;
+    }
+    return descriptors.get(objectName);
+  }
+
+  /** @return previous Descriptor associated with the given name, or null if there was no Descriptor for this name. */
+  public synchronized Descriptor addDescriptor(String objectName, Descriptor descriptor) {
+    if (descriptors==null) {
+      descriptors = new HashMap<String, Descriptor>();
+    }
+    return descriptors.put(objectName, descriptor);
+  }
+
+  /** @return previous Descriptor associated with the given name, or null if there was no Descriptor for this name. */
+  public synchronized Descriptor removeDescriptor(String objectName) {
+    if (descriptors!=null) {
+      return descriptors.remove(objectName);
+    }
+    return null;
+  }
+
+  public boolean hasDescriptor(String objectName) {
+    return (descriptors!=null)
+           && (descriptors.containsKey(objectName));
+  }
+
+  public void addEagerInitObjectName(String eagerInitObjectName) {
+    if (eagerInitObjectName!=null) {
+      if (eagerInitNames==null) {
+        eagerInitNames = new ArrayList<String>();
+      }
+      eagerInitNames.add(eagerInitObjectName);
+    }
+  }
+
+  public ClassLoader getClassLoader() {
+    // if there is a specific classloader specified
+    if (classLoader!=null) {
+      return classLoader;
+    }
+    // otherwise, use the current environment classloader
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  
+  public Map<String, Descriptor> getDescriptors() {
+    return descriptors;
+  }
+  public List<String> getEagerInitNames() {
+    return eagerInitNames;
+  }
+  public void setEagerInitNames(List<String> eagerInitNames) {
+    this.eagerInitNames = eagerInitNames;
+  }
+  public void setDescriptors(Map<String, Descriptor> descriptors) {
+    this.descriptors = descriptors;
+  }
+  public void setClassLoader(ClassLoader classLoader) {
+    this.classLoader = classLoader;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireException.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireException.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireException.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+
+/**
+ * thrown during the creation or initialization of objects from the Wiring Context.
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class WireException extends RuntimeException {
+
+  private static final long serialVersionUID = 1L;
+
+  public WireException() {
+    super();
+  }
+
+  public WireException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public WireException(String message) {
+    super(message);
+  }
+
+  public WireException(Throwable cause) {
+    super(cause);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireObjectEventInfo.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireObjectEventInfo.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireObjectEventInfo.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,27 @@
+package org.jbpm.pvm.internal.wire;
+
+public class WireObjectEventInfo {
+
+  String eventName;
+  String objectName;
+  Object object;
+
+  public WireObjectEventInfo(String eventName, String objectName, Object object) {
+    this.eventName = eventName;
+    this.objectName = objectName;
+    this.object = object;
+  }
+
+  public String getEventName() {
+    return eventName;
+  }
+  public Object getObject() {
+    return object;
+  }
+  public String getObjectName() {
+    return objectName;
+  }
+  public String toString() {
+    return eventName+"("+objectName+")";
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,71 @@
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+public abstract class AbstractCollectionBinding extends WireDescriptorBinding {
+
+  public AbstractCollectionBinding(String tagName) {
+    super(tagName);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    CollectionDescriptor descriptor = createDescriptor();
+    
+    String className = XmlUtil.attribute(element,"class");
+    
+    // verify if the given classname is specified and implements the collection interface
+    if (verify(className, getCollectionInterface(), parse, parser)) {
+      descriptor.setClassName(className);
+    }
+    
+    Boolean isSynchronized = XmlUtil.attributeBoolean(element, "synchronized", false, parse);
+    if (isSynchronized!=null) {
+      descriptor.setSynchronized(isSynchronized.booleanValue());
+    }
+    
+    List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
+    List<Element> elements = XmlUtil.elements(element);
+    for (Element valueElement: elements) {
+      Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+      if (valueDescriptor!=null) {
+        valueDescriptors.add(valueDescriptor);
+      }
+    }
+    descriptor.setValueDescriptors(valueDescriptors);
+    return descriptor;
+  }
+
+  /** verifies if the given classname is specified and implements the collection interface */
+  public static boolean verify(String className, Class< ? > collectionInterface, Parse parse, Parser parser) {
+    if (className==null) {
+      return false;
+    }
+
+    try {
+      Class<?> collectionClass = ReflectUtil.loadClass(parse.getClassLoader(), className);
+      
+      if (collectionInterface.isAssignableFrom(collectionClass)) {
+        return true;
+      } else {
+        parse.addProblem("class "+ className+" is not a "+collectionInterface.getName());
+      }
+    } catch (JbpmException e) {
+      parse.addProblem("class "+className+" could not be found");
+    }
+    return false;
+  }
+
+  protected abstract Class<?> getCollectionInterface();
+  protected abstract CollectionDescriptor createDescriptor();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AssignFileTypesBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.deploy.AssignFileTypeDeployer;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AssignFileTypesBinding extends WireDescriptorBinding {
+
+  private static final String ASSIGN_FILE_TYPE = "assign-file-type";
+
+  public AssignFileTypesBinding() {
+    super(ASSIGN_FILE_TYPE);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    AssignFileTypeDeployer assignFileTypeDeployer = new AssignFileTypeDeployer();
+    
+    List<Element> fileElements = XmlUtil.elements(element, "file");
+    if (fileElements.isEmpty()) {
+      parse.addProblem("no files in "+ASSIGN_FILE_TYPE);
+    } else {
+      for(Element fileTypeElement : fileElements) {
+        String extension = XmlUtil.attribute(fileTypeElement, "extension", true, parse);
+        String type = XmlUtil.attribute(fileTypeElement, "type", true, parse);
+        if ( (extension!=null)
+             && (type!=null)
+           ) {
+          assignFileTypeDeployer.addFileType(extension, type);
+        }
+      }
+    }
+    
+    ProvidedObjectDescriptor providedObjectDescriptor = new ProvidedObjectDescriptor(assignFileTypeDeployer);
+
+    return providedObjectDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AsyncCommandServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AsyncCommandServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AsyncCommandServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.AsyncCommandService;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncCommandServiceBinding extends StandardCommandServiceBinding {
+  
+  public AsyncCommandServiceBinding() {
+    super("async-command-service");
+  }
+
+  protected CommandService getCommandService(Element element, Parse parse, Parser parser) {
+    AsyncCommandService asyncCommandService = new AsyncCommandService();
+    
+    if (XmlUtil.attributeBoolean(element, "propagate-auth", false, parse)) {
+      asyncCommandService.setPropagateUserId(true);
+    }
+    
+    return asyncCommandService;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AuthorizationInterceptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AuthorizationInterceptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AuthorizationInterceptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.svc.AuthorizationInterceptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AuthorizationInterceptorBinding extends WireDescriptorBinding {
+
+  public AuthorizationInterceptorBinding() {
+    super("authorization-interceptor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    AuthorizationInterceptor authorizationInterceptor = new AuthorizationInterceptor();
+    return new ProvidedObjectDescriptor(authorizationInterceptor);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BasicTypeBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BasicTypeBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BasicTypeBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+public abstract class BasicTypeBinding extends WireDescriptorBinding {
+  
+  public BasicTypeBinding(String tagName) {
+    super(tagName);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    AbstractDescriptor descriptor = null;
+    
+
+    if (element.hasAttribute("value")) {
+      String value = element.getAttribute("value");
+      descriptor = createDescriptor(value, element, parse);
+    } else {
+      parse.addProblem("attribute 'value' is required in element '"+XmlUtil.getTagLocalName(element)+"': "+XmlUtil.toString(element));
+    }
+    
+    return descriptor;
+  }
+  
+  public String createValueExceptionMessage(String message, Element element) {
+    return XmlUtil.getTagLocalName(element)+" has invalid formatted value attribute: "+(message!=null ? message+": " : "")+XmlUtil.toString(element);
+  }
+
+  /** subclasses can be sure that the value is not null.
+   * subclasses should use {@link #createValueExceptionMessage(String, Element) for 
+   * reporting format problems in the parse.  */
+  protected abstract AbstractDescriptor createDescriptor(String value, Element element, Parse parse);
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.TimeZone;
+
+import org.jbpm.pvm.internal.cal.BusinessCalendar;
+import org.jbpm.pvm.internal.cal.Day;
+import org.jbpm.pvm.internal.cal.DayPart;
+import org.jbpm.pvm.internal.cal.Holiday;
+import org.jbpm.pvm.internal.util.StringUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BusinessCalendarBinding extends WireDescriptorBinding {
+  
+  public BusinessCalendarBinding() {
+    super("business-calendar");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    BusinessCalendar businessCalendar = new BusinessCalendar();
+    
+    TimeZone timeZone = null;
+    if (element.hasAttribute("timezone")) {
+      timeZone = TimeZone.getTimeZone(element.getAttribute("timezone"));
+    } else {
+      timeZone = TimeZone.getDefault();
+    }
+    businessCalendar.setTimeZone(timeZone);
+    
+    String hourFormatText = "HH:mm";
+    if (element.hasAttribute("hour-format")) {
+      hourFormatText = element.getAttribute("hour-format");
+    }
+    DateFormat hourFormat = new SimpleDateFormat(hourFormatText);
+
+    Day[] days = new Day[8];
+    days[Calendar.SUNDAY] = parseDay(element, "sunday", hourFormat, businessCalendar, parse);
+    days[Calendar.MONDAY] = parseDay(element, "monday", hourFormat, businessCalendar, parse);
+    days[Calendar.TUESDAY] = parseDay(element, "tuesday", hourFormat, businessCalendar, parse);
+    days[Calendar.WEDNESDAY] = parseDay(element, "wednesday", hourFormat, businessCalendar, parse);
+    days[Calendar.THURSDAY] = parseDay(element, "thursday", hourFormat, businessCalendar, parse);
+    days[Calendar.FRIDAY] = parseDay(element, "friday", hourFormat, businessCalendar, parse);
+    days[Calendar.SATURDAY] = parseDay(element, "saturday", hourFormat, businessCalendar, parse);
+    businessCalendar.setDays(days);
+
+    String dayFormatText = "dd/MM/yyyy";
+    if (element.hasAttribute("day-format")) {
+      dayFormatText = element.getAttribute("day-format");
+    }
+    DateFormat dayFormat = new SimpleDateFormat(dayFormatText);
+
+    Holiday[] holidays = null;
+    List<Element> holidayElements = XmlUtil.elements(element, "holiday");
+    if (!holidayElements.isEmpty()) {
+      holidays = new Holiday[holidayElements.size()];
+      for (int i=0; i<holidayElements.size(); i++) {
+        holidays[i] = parseHoliday(holidayElements.get(i), dayFormat, businessCalendar, parse);
+      }
+    }
+    businessCalendar.setHolidays(holidays);
+    
+    ProvidedObjectDescriptor descriptor = new ProvidedObjectDescriptor(businessCalendar, true);
+    return descriptor;
+  }
+
+  private Day parseDay(Element daysElement, String dayText, DateFormat hourFormat, BusinessCalendar businessCalendar, Parse parse) {
+    Day day = new Day();
+    day.setBusinessCalendar(businessCalendar);
+
+    Element dayElement = XmlUtil.element(daysElement, dayText);
+    if (dayElement!=null) {
+      List<DayPart> dayParts = new ArrayList<DayPart>();
+      
+      if (dayElement.hasAttribute("hours")) {
+        int dayPartIndex = 0;
+        String hours = dayElement.getAttribute("hours");
+        for (String part: StringUtil.tokenize(hours, "and")) {
+          try {
+            int separatorIndex = part.indexOf('-');
+            if (separatorIndex==-1) throw new IllegalArgumentException("no dash (-)");
+            String fromText = part.substring(0, separatorIndex).trim().toLowerCase(); 
+            String toText = part.substring(separatorIndex+1).trim().toLowerCase();
+            
+            Date from = hourFormat.parse(fromText);
+            Date to = hourFormat.parse(toText);
+            
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(from);
+            int fromHour = calendar.get(Calendar.HOUR_OF_DAY);
+            int fromMinute = calendar.get(Calendar.MINUTE);
+
+            calendar.setTime(to);
+            int toHour = calendar.get(Calendar.HOUR_OF_DAY);
+            if (toHour==0) {
+              toHour=24;
+            }
+            int toMinute = calendar.get(Calendar.MINUTE);
+
+            DayPart dayPart = new DayPart();
+            dayPart.setDay(day);
+            dayPart.setIndex(dayPartIndex);
+            dayPart.setFromHour(fromHour);
+            dayPart.setFromMinute(fromMinute);
+            dayPart.setToHour(toHour);
+            dayPart.setToMinute(toMinute);
+            dayParts.add(dayPart);
+            
+          } catch(Exception e) {
+            parse.addProblem(dayText+" has invalid hours part '"+part+"': "+e.getMessage());  
+          }
+          
+          dayPartIndex++;
+        }
+        
+      } else {
+        parse.addProblem(dayText+" must have attribute 'hours'");
+      }
+      
+      DayPart[] dayPartArray = new DayPart[dayParts.size()];
+      dayPartArray = dayParts.toArray(dayPartArray);
+      day.setDayParts(dayPartArray);
+    }
+    return day;
+  }
+  
+  private Holiday parseHoliday(Element holidayElement, DateFormat dayFormat, BusinessCalendar businessCalendar, Parse parse) {
+    Holiday holiday = new Holiday();
+    try {
+      if (holidayElement.hasAttribute("period")) {
+        String holidayPeriodText = holidayElement.getAttribute("period");
+        
+        int dashIndex = holidayPeriodText.indexOf('-');
+        
+        String fromDateText = null;
+        String toDateText = null;
+        if (dashIndex!=-1) {
+          fromDateText = holidayPeriodText.substring(0, dashIndex).trim().toLowerCase(); 
+          toDateText = holidayPeriodText.substring(dashIndex+1).trim().toLowerCase();
+          
+        } else {
+          fromDateText = holidayPeriodText.trim().toLowerCase(); 
+          toDateText = fromDateText;
+        }
+
+        
+        Date fromDate = dayFormat.parse(fromDateText);
+        holiday.setFromDay(fromDate);
+
+        Date toDate = dayFormat.parse(toDateText);
+        holiday.setToDay(toDate);
+        
+      } else {
+        parse.addProblem("attribute 'period' in element business-calendar is required");
+      }
+
+      // now we are going to set the toDay to the end of the day, rather then the beginning.
+      // we take the start of the next day as the end of the toDay.
+      Calendar calendar = businessCalendar.createCalendar();
+      calendar.setTime(holiday.getToDay());
+      calendar.add(Calendar.DATE, 1);
+      Date toDay = calendar.getTime();
+      holiday.setToDay(toDay);
+      
+    } catch (Exception e) {
+      parse.addProblem("couldn't parse holiday: "+XmlUtil.toString(holidayElement));
+    }
+
+    return holiday;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ByteBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ByteBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ByteBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ByteDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating {@link Byte}s.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ByteBinding extends BasicTypeBinding {
+
+  public ByteBinding() {
+    super("byte");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    ByteDescriptor byteDescriptor = new ByteDescriptor();
+    Byte byteValue;
+    try {
+      byteValue = Byte.parseByte(value);
+      byteDescriptor.setValue(byteValue);
+      return byteDescriptor;
+
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to a byte", element));
+    }
+    return null;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CharBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CharBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CharBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.CharacterDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating {@link Character}s.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class CharBinding extends BasicTypeBinding {
+
+  public CharBinding() {
+    super("char");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    CharacterDescriptor characterDescriptor = new CharacterDescriptor();
+    if (value.length()!=1) {
+      parse.addProblem(createValueExceptionMessage("length of value must be 1", element));
+      return null;
+    }
+    char c = value.charAt(0);
+    characterDescriptor.setValue(new Character(c));
+    return characterDescriptor;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProblemsBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.CheckProblemsDeployer;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProblemsBinding extends WireDescriptorBinding {
+
+  public CheckProblemsBinding() {
+    super("check-problems");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    CheckProblemsDeployer checkProblemsDeployer = new CheckProblemsDeployer();
+    return new ProvidedObjectDescriptor(checkProblemsDeployer);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.CheckProcessDeployer;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/** parses a descriptor creating a {@link CheckProcessDeployer version verification deployer}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class CheckProcessBinding extends WireDescriptorBinding {
+
+  public static final String TAG = "check-process";
+
+  public CheckProcessBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    CheckProcessDeployer checkProcessDeployer = new CheckProcessDeployer();
+    
+    Boolean assignVersion = XmlUtil.attributeBoolean(element, "assign-version", false, parse, null);
+    if (assignVersion!=null) {
+      checkProcessDeployer.setAssignVersion(assignVersion);
+    }
+
+    Boolean assignKey = XmlUtil.attributeBoolean(element, "assign-key", false, parse, null);
+    if (assignKey!=null) {
+      checkProcessDeployer.setAssignKey(assignKey);
+    }
+
+    return new ProvidedObjectDescriptor(checkProcessDeployer);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ClassBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ClassBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ClassBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link Class}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ClassBinding extends WireDescriptorBinding {
+
+  public ClassBinding() {
+    super("class");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ClassDescriptor classDescriptor = null;
+    String className = XmlUtil.attribute(element, "class-name");
+    if (className!=null) {
+      classDescriptor = new ClassDescriptor();
+      classDescriptor.setClassName(className);
+    } else {
+      parse.addProblem("class must have classname attribute: "+XmlUtil.toString(element));
+    }
+    return classDescriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ContextRefBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ContextRefBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ContextRefBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.Context;
+import org.jbpm.pvm.internal.wire.descriptor.ContextRefDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for obtaining a reference to the current {@link Context}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ContextRefBinding extends WireDescriptorBinding {
+
+  public ContextRefBinding() {
+    super("context-ref");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ContextRefDescriptor descriptor = new ContextRefDescriptor();
+    if (element.hasAttribute("context-name")) {
+      descriptor.setContextName(element.getAttribute("context-name"));
+    }
+    return descriptor;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DeployerManagerBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.deploy.DeployerManager;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.DeployerManagerDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/** parses a descriptor for creating a {@link DeployerManager}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class DeployerManagerBinding extends WireDescriptorBinding {
+  
+  private static final String DEPLOYER_MANAGER_TAG = "deployer-manager";
+  
+  public DeployerManagerBinding() {
+    super(DEPLOYER_MANAGER_TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    DeployerManagerDescriptor descriptor = new DeployerManagerDescriptor();
+    
+    List<Descriptor> deployerDescriptors = new ArrayList<Descriptor>();
+    descriptor.setDeployerDescriptors(deployerDescriptors);
+
+    List<Element> deployerElements = XmlUtil.elements(element);
+    for (Element deployerElement: deployerElements) {
+      Descriptor deployerDescriptor = (Descriptor) parser
+          .parseElement(deployerElement, 
+                        parse, 
+                        WireParser.CATEGORY_DESCRIPTOR);
+      deployerDescriptors.add(deployerDescriptor);
+    }
+    
+    if (deployerDescriptors.isEmpty()) {
+      parse.addProblem("no deployers defined for "+DEPLOYER_MANAGER_TAG);
+    }
+    
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DoubleBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DoubleBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/DoubleBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.DoubleDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link java.lang.Double}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class DoubleBinding extends BasicTypeBinding {
+
+  public DoubleBinding() {
+    super("double");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    DoubleDescriptor doubleDescriptor = new DoubleDescriptor();
+    Double doubleValue;
+    try {
+      doubleValue = new Double(value);
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to a double", element));
+      return null;
+    }
+    doubleDescriptor.setValue(doubleValue);
+    return doubleDescriptor;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.operation.EnlistOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating an {@link EnlistOperation enlist operation}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnlistBinding extends WireOperationBinding {
+
+  public EnlistBinding() {
+    super("enlist");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EnlistOperation enlistOperation = new EnlistOperation();
+    if (element.hasAttribute("transaction")) {
+      enlistOperation.setTransactionName(element.getAttribute("transaction"));
+    }
+    return enlistOperation;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.EnvDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvBinding extends WireDescriptorBinding {
+
+  public EnvBinding() {
+    super("env");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EnvDescriptor envDescriptor = new EnvDescriptor();
+
+    String typeName = XmlUtil.attribute(element, "type");
+    envDescriptor.setTypeName(typeName);
+    
+    String objectName = XmlUtil.attribute(element, "object");
+    envDescriptor.setObjectName(objectName);
+    
+    return envDescriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvRefBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvRefBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvRefBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.wire.descriptor.EnvironmentDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for obtaining a reference to the {@link Environment}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnvRefBinding extends WireDescriptorBinding {
+
+  public EnvRefBinding() {
+    super("env-ref");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new EnvironmentDescriptor();
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentFactoryRefBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentFactoryRefBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentFactoryRefBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.wire.descriptor.EnvironmentFactoryDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**parses a descriptor for obtaining a reference to the {@link EnvironmentFactory}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnvironmentFactoryRefBinding extends WireDescriptorBinding {
+
+  public EnvironmentFactoryRefBinding() {
+    super("process-engine-ref");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) parse.getDocumentObject();
+    return new EnvironmentFactoryDescriptor(environmentFactory);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.wire.descriptor.EnvironmentInterceptorDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentInterceptorBinding extends WireInterceptorBinding {
+    
+  public EnvironmentInterceptorBinding() {
+    super("environment-interceptor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) parse.getDocumentObject();
+    return new EnvironmentInterceptorDescriptor(environmentFactory);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.ExecutionServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionServiceBinding extends WireDescriptorBinding {
+
+  public ExecutionServiceBinding() {
+    super("execution-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(ExecutionServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FalseBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FalseBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FalseBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating {@link Boolean.FALSE}
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (Documentation)
+ */
+public class FalseBinding extends WireDescriptorBinding {
+
+  public FalseBinding() {
+    super("false");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new FalseDescriptor();
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FieldBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FieldBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FieldBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.operation.FieldOperation;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a field injection operation.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class FieldBinding extends WireOperationBinding {
+
+  public FieldBinding() {
+    super("field");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    FieldOperation fieldOperation = new FieldOperation();
+    if (element.hasAttribute("name")) {
+      fieldOperation.setFieldName(element.getAttribute("name"));
+    } else {
+      parse.addProblem("field must have name : "+XmlUtil.toString(element));
+    }
+    Element descriptorElement = XmlUtil.element(element);
+    if (descriptorElement!=null) {
+      Descriptor descriptor = (Descriptor) parser.parseElement(descriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+      if (descriptor!=null) {
+        fieldOperation.setDescriptor(descriptor);
+      } else {
+        parse.addProblem("unknown descriptor element "+descriptorElement.getTagName()+" inside field operation: "+XmlUtil.toString(element));
+      }
+    } else {
+      parse.addProblem("field must have 1 descriptor element out of "+parser.getBindings().getTagNames(WireParser.CATEGORY_DESCRIPTOR)+" as content: "+XmlUtil.toString(element));
+    }
+    return fieldOperation;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FloatBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FloatBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/FloatBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.FloatDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link Float}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class FloatBinding extends BasicTypeBinding {
+
+  public FloatBinding() {
+    super("float");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    FloatDescriptor floatDescriptor =  new FloatDescriptor();
+    Float floatValue;
+    try {
+      floatValue = new Float(value);
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to a float", element));
+      return null;
+    }
+    floatDescriptor.setValue(floatValue);
+    return floatDescriptor;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateConfigurationBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.hibernate.cfg.Configuration;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.HibernateConfigurationDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.PropertiesDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a hibernate Configuration.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class HibernateConfigurationBinding extends WireDescriptorBinding {
+
+  private static final Log log = Log.getLog(HibernateConfigurationBinding.class.getName());
+  
+  private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
+
+  public HibernateConfigurationBinding() {
+    super("hibernate-configuration");
+  }
+
+  protected HibernateConfigurationBinding(String tagName) {
+    super(tagName);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateConfigurationDescriptor descriptor = new HibernateConfigurationDescriptor();
+    
+    String configurationClassName = null;
+    if ( element.hasAttribute("annotations")
+         && element.getAttribute("annotations").equalsIgnoreCase("enabled")   
+       ) {
+      // don't replace the string with the reflective classname as that will 
+      // introduce a hard dependency on the hibernate annotations library
+      configurationClassName = "org.hibernate.cfg.AnnotationConfiguration";
+
+    } else {
+      configurationClassName = Configuration.class.getName();
+    }
+
+    descriptor.setClassName(configurationClassName);
+
+    parseConfiguration(element, parse, descriptor, parser);
+    
+    return descriptor;
+  }
+
+  private void parseConfiguration(Element element, Parse parse, HibernateConfigurationDescriptor descriptor, Parser parser)
+  {
+    List<Element> configElements = XmlUtil.elements(element);
+    for (Element configElement: configElements) {
+
+      if ("cfg".equals(XmlUtil.getTagLocalName(configElement))) {
+        if (element.hasAttribute("resource")) {
+          String resource = element.getAttribute("resource");
+          log.trace("adding hibernate configuration resource "+resource);
+          descriptor.addCfgResource(resource);
+
+        } else if (element.hasAttribute("file")) {
+          String fileName = element.getAttribute("file");
+          log.trace("adding hibernate configuration file "+fileName);
+          descriptor.addCfgFile(fileName);
+
+        } else if (element.hasAttribute("url")) {
+          String urlText = element.getAttribute("url");
+          log.trace("adding hibernate configuration url "+urlText);
+          descriptor.addCfgUrl(urlText);
+          
+        } else {
+          parse.addProblem("exactly 1 attribute in {resource, file, url} was expected in cfg: "+XmlUtil.toString(element));
+        }
+
+      } else if ("mapping".equals(XmlUtil.getTagLocalName(configElement))) {
+        if (element.hasAttribute("resource")) {
+          String resource = element.getAttribute("resource");
+          log.trace("adding hibernate mapping resource "+resource);
+          descriptor.addMappingResource(resource);
+
+        } else if (element.hasAttribute("file")) {
+          String fileName = element.getAttribute("file");
+          log.trace("adding hibernate mapping file "+fileName);
+          descriptor.addMappingFile(fileName);
+
+        } else if (element.hasAttribute("class")) {
+          String className = element.getAttribute("class");
+          log.trace("adding hibernate mapping class "+className);
+          descriptor.addMappingClass(className);
+          
+        } else if (element.hasAttribute("url")) {
+          String urlText = element.getAttribute("url");
+          log.trace("adding hibernate mapping url "+urlText);
+          descriptor.addMappingUrl(urlText);
+          
+        } else {
+          parse.addProblem("exactly 1 attribute in {resource, file, class, url} was expected in mapping: "+XmlUtil.toString(element));
+        }
+
+      } else if ("properties".equals(XmlUtil.getTagLocalName(configElement))) {
+        PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
+        descriptor.setPropertiesDescriptor(propertiesDescriptor);
+
+      } else if ("cache-configuration".equals(XmlUtil.getTagLocalName(configElement))) {
+        StreamInput streamSource = null;
+
+        String cacheUsage = configElement.getAttribute("usage");
+        if (! ( ("read-only".equals(cacheUsage))
+                || ("nonstrict-read-write".equals(cacheUsage))
+                || ("read-write".equals(cacheUsage))
+                || ("transactional".equals(cacheUsage))
+              )
+           ){
+          parse.addProblem("problem in cache-configuration: no usage attribute or illegal value: "+cacheUsage+" Possible values are {read-only, nonstrict-read-write, read-write, transactional}");
+        } else {
+
+          if (configElement.hasAttribute("file")) {
+            String fileName = configElement.getAttribute("file");
+            File file = new File(fileName);
+            if (file.exists() && file.isFile()) {
+              streamSource = new FileStreamInput(file);
+            } else {
+              parse.addProblem("file "+fileName+" isn't a file");
+            }
+          }
+
+          if (configElement.hasAttribute("resource")) {
+            String resource = configElement.getAttribute("resource");
+            streamSource = new ResourceStreamInput(resource, parse.getClassLoader());
+          }
+
+          if (configElement.hasAttribute("url")) {
+            String urlText = configElement.getAttribute("url");
+            try {
+              URL url = new URL(urlText);
+              streamSource = new UrlStreamInput(url);
+            } catch (Exception e) {
+              parse.addProblem("couldn't open url "+urlText, e);
+            }
+          }
+
+          if (streamSource != null) {
+            parser.importStream(streamSource, configElement, parse);
+          }
+
+          // parse the cache configurations in the same way as the hibernate cfg schema
+          // translate the contents of the file into invoke operations for methods
+          // Configuration.setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
+          // Configuration.setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
+          //         <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
+          //         <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
+          //         <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
+          List<Element> cacheElements = XmlUtil.elements(configElement);
+          if (cacheElements!=null) {
+            for (Element cacheElement : cacheElements) {
+
+              if ("class-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
+                String className = cacheElement.getAttribute("class");
+                descriptor.addClassToCache(className, cacheUsage);
+
+              } else if ("collection-cache".equals(XmlUtil.getTagLocalName(cacheElement))) {
+                String collection = cacheElement.getAttribute("collection");
+                descriptor.addCollectionToCache(collection, cacheUsage);
+
+              } else {
+                parse.addProblem("unknown hibernate cache configuration element "+XmlUtil.toString(configElement));
+              }
+            }
+          }
+        }
+
+      } else {
+        parse.addProblem("unknown hibernate configuration element "+XmlUtil.toString(configElement));
+      }
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a hibernate Session.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class HibernateSessionBinding extends WireDescriptorBinding {
+
+  public HibernateSessionBinding() {
+    super("hibernate-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateSessionDescriptor descriptor = new HibernateSessionDescriptor();
+
+    if (element.hasAttribute("factory")) {
+      descriptor.setFactoryName(element.getAttribute("factory"));
+    }
+    
+    Boolean tx = XmlUtil.attributeBoolean(element, "tx", false, parse);
+    if (tx!=null) {
+      descriptor.setTx(tx);
+    }
+
+    Boolean useCurrent = XmlUtil.attributeBoolean(element, "current", false, parse);
+    // if usage of current session is specified
+    if (useCurrent!=null) {
+      // set it accordingly
+      descriptor.setUseCurrent(useCurrent);
+      // and set the default of close appropriately
+      descriptor.setClose( !useCurrent );
+    }
+    
+    Boolean close = XmlUtil.attributeBoolean(element, "close", false, parse);
+    if (close!=null) {
+      descriptor.setClose(close);
+    }
+
+    if (element.hasAttribute("standard-transaction")) {
+      descriptor.setStandardTransactionName(element.getAttribute("standard-transaction"));
+    }
+    
+    if (element.hasAttribute("connection")) {
+      descriptor.setConnectionName(element.getAttribute("connection"));
+    }
+
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionFactoryBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.HibernateSessionFactoryDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a hibernate SessionFactory.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class HibernateSessionFactoryBinding extends HibernateConfigurationBinding {
+
+  public HibernateSessionFactoryBinding() {
+    super("hibernate-session-factory");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateSessionFactoryDescriptor descriptor = new HibernateSessionFactoryDescriptor();
+    
+    if (element.hasAttribute("configuration")) {
+      descriptor.setConfigurationName(element.getAttribute("configuration"));
+
+    // if hibernate session factory binding has sub elements, we assume that 
+    // it is an inline configuration declaration
+    } else if (!XmlUtil.elements(element).isEmpty()) {
+      Descriptor configurationDescriptor = (Descriptor) super.parse(element, parse, parser);
+      descriptor.setConfigurationDescriptor(configurationDescriptor);
+    }
+
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.HistoryServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryServiceBinding extends WireDescriptorBinding {
+
+  public HistoryServiceBinding() {
+    super("history-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(HistoryServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.history.HistorySessionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionBinding extends WireDescriptorBinding {
+
+  public HistorySessionBinding() {
+    super("history-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ObjectDescriptor(HistorySessionImpl.class);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.model.DefaultIdGenerator;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdGeneratorBinding extends WireDescriptorBinding {
+
+  public IdGeneratorBinding() {
+    super("id-generator");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ObjectDescriptor(DefaultIdGenerator.class);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.identity.impl.IdentityServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentityServiceBinding extends WireDescriptorBinding {
+
+  public IdentityServiceBinding() {
+    super("identity-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(IdentityServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.IdentitySessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionBinding extends WireDescriptorBinding {
+
+  public IdentitySessionBinding() {
+    super("identity-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    IdentitySessionDescriptor descriptor = new IdentitySessionDescriptor();
+    
+    if (element.hasAttribute("realm")) {
+      descriptor.setRealmName(element.getAttribute("realm"));
+    }
+
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionFactoryBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionFactoryBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentitySessionFactoryBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.IdentitySessionFactoryDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionFactoryBinding extends WireDescriptorBinding {
+
+  public IdentitySessionFactoryBinding() {
+    super("identity-session-factory");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    IdentitySessionFactoryDescriptor descriptor = new IdentitySessionFactoryDescriptor();
+    
+    if (element.hasAttribute("resource")) {
+      descriptor.setResource(element.getAttribute("resource"));
+    }
+
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IntBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IntBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IntBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating an Integer.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class IntBinding extends BasicTypeBinding {
+
+  public IntBinding() {
+    super("int");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    IntegerDescriptor integerDescriptor =  new IntegerDescriptor();
+    Integer integerValue;
+    try {
+      integerValue = new Integer(value);
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to an int", element));
+      return null;
+    }
+    integerDescriptor.setValue(integerValue);
+    return integerDescriptor;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/InvokeBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating an {@link InvokeOperation invoke operation}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class InvokeBinding extends WireOperationBinding {
+  
+  public InvokeBinding() {
+    super("invoke");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    InvokeOperation invokeOperation = new InvokeOperation();
+    if (element.hasAttribute("method")) {
+      invokeOperation.setMethodName(element.getAttribute("method"));
+    } else {
+      parse.addProblem("invoke must have method : "+XmlUtil.toString(element));
+    }
+    List<Element> argElements = XmlUtil.elements(element, "arg");
+    Parser wireParser = (Parser) parser;
+    List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+    invokeOperation.setArgDescriptors(argDescriptors);
+    return invokeOperation;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JndiBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JndiBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JndiBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.JndiDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for looking up an object from 
+ * JNDI through the InitialContext.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class JndiBinding extends WireDescriptorBinding {
+  
+  public JndiBinding() {
+    super("jndi");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    if (element.hasAttribute("jndi-name")) {
+      String jndiName = element.getAttribute("jndi-name");
+      return new JndiDescriptor(jndiName);
+
+    } else {
+      parse.addProblem("jndi requires attribute 'jndi-name'");
+    }
+
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobDbSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobDbSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobDbSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.hibernate.HibernateJobDbSession;
+import org.jbpm.pvm.internal.wire.descriptor.HibernateJobDbSessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link HibernateJobDbSession}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class JobDbSessionBinding extends WireDescriptorBinding {
+
+  public JobDbSessionBinding() {
+    super("job-db-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateJobDbSessionDescriptor descriptor = new HibernateJobDbSessionDescriptor();
+    
+    if (element.hasAttribute("session")) {
+      descriptor.setSessionName(element.getAttribute("session"));
+    }
+
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobExecutorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobExecutorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobExecutorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.JobExecutorDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link JobExecutor}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Pascal Verdage
+ */
+public class JobExecutorBinding extends WireDescriptorBinding {
+
+  public JobExecutorBinding() {
+    super("job-executor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    // create a jobImpl executor object
+    JobExecutorDescriptor descriptor = new JobExecutorDescriptor();
+
+    // inject the command executor
+
+    if (element.hasAttribute("command-service")) {
+      descriptor.addInjection("commandService", 
+          new ReferenceDescriptor(element.getAttribute("command-service"))
+      );
+    } else {
+      descriptor.addInjection("commandService", 
+          new ContextTypeRefDescriptor(CommandService.class)
+      );
+    }
+
+    if (element.hasAttribute("name")) {
+      descriptor.addInjection("name", new StringDescriptor(element.getAttribute("name")));
+    }
+
+    parseIntAttribute(element, "threads", descriptor, "nbrOfThreads", parse);
+    parseIntAttribute(element, "idle", descriptor, "idleMillis", parse);
+    parseIntAttribute(element, "idle-max", descriptor, "idleMillisMax", parse);
+    parseIntAttribute(element, "history", descriptor, "historySize", parse);
+    parseIntAttribute(element, "lock", descriptor, "lockMillis", parse);
+
+    // by default invoke the start method, unless auto-start is disabled
+    if (XmlUtil.attributeBoolean(element, "auto-start", false, parse, true)) {
+      InvokeOperation invokeStartOperation = new InvokeOperation();
+      invokeStartOperation.setMethodName("start");
+      descriptor.addOperation(invokeStartOperation);
+      descriptor.setAutoStart(true);
+    }
+
+    return descriptor;
+  }
+
+  private void parseIntAttribute(Element element, String attributeName, ObjectDescriptor descriptor, String fieldName, Parse parse) {
+    Integer intValue = XmlUtil.attributeInteger(element, attributeName, false, parse);
+    if (intValue!=null) {
+      descriptor.addInjection(fieldName, new IntegerDescriptor(intValue));
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobTestHelperBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobTestHelperBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JobTestHelperBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.test.JobTestHelper;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobTestHelperBinding extends WireDescriptorBinding {
+
+  public JobTestHelperBinding() {
+    super("job-test-helper");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(JobTestHelper.class);
+    descriptor.addTypedInjection("commandService", CommandService.class);
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ListBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+
+/** parses a descriptor for creating a {@link JobExecutor}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ListBinding extends AbstractCollectionBinding {
+
+  public ListBinding() {
+    super("list");
+  }
+
+  protected CollectionDescriptor createDescriptor() {
+    return new ListDescriptor();
+  }
+
+  protected Class<?> getCollectionInterface() {
+    return List.class;
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/LongBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/LongBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/LongBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link java.lang.Long}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class LongBinding extends BasicTypeBinding {
+
+  public LongBinding() {
+    super("long");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    LongDescriptor longDescriptor =  new LongDescriptor();
+    Long longValue;
+    try {
+      longValue = new Long(value);
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to a long", element));
+      return null;
+    }
+    longDescriptor.setValue(longValue);
+    return longDescriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.ManagementServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceBinding extends WireDescriptorBinding {
+
+  public ManagementServiceBinding() {
+    super("management-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(ManagementServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MapBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link java.util.Map}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class MapBinding extends WireDescriptorBinding {
+
+  public MapBinding() {
+    super("map");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    MapDescriptor descriptor = new MapDescriptor();
+    String className = XmlUtil.attribute(element,"class");
+    if (AbstractCollectionBinding.verify(className, Map.class, parse, parser)) {
+      descriptor.setClassName(className);
+    }
+    
+    Boolean isSynchronized = XmlUtil.attributeBoolean(element, "synchronized", false, parse);
+    if (isSynchronized!=null) {
+      descriptor.setSynchronized(isSynchronized.booleanValue());
+    }
+
+    List<Descriptor> keyDescriptors = new ArrayList<Descriptor>();
+    List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
+    List<Element> elements = XmlUtil.elements(element);
+    for (Element entryElement: elements) {
+      if ("entry".equals(XmlUtil.getTagLocalName(entryElement))) {
+        // key
+        Element keyElement = XmlUtil.element(entryElement, "key");
+        Element keyDescriptorElement = (keyElement!=null ? XmlUtil.element(keyElement) : null);
+        Descriptor keyDescriptor = (Descriptor) parser.parseElement(keyDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+        // value
+        Element valueElement = XmlUtil.element(entryElement, "value");
+        Element valueDescriptorElement = (valueElement!=null ? XmlUtil.element(valueElement) : null);
+        Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+
+        if ( (keyDescriptor!=null)
+             && (valueDescriptor!=null)
+           ) {
+          keyDescriptors.add(keyDescriptor);
+          valueDescriptors.add(valueDescriptor);
+        } else {
+          parse.addProblem("entry must have key and value element with a single descriptor as contents: "+XmlUtil.toString(entryElement));
+        }
+      } else {
+        parse.addProblem("map can only contain entry elements: "+XmlUtil.toString(entryElement));
+      }
+    }
+
+    descriptor.setKeyDescriptors(keyDescriptors);
+    descriptor.setValueDescriptors(valueDescriptors);
+    return descriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.jms.JmsMessageSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutorMessageSession;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.JndiDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.TransactionRefDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.MessageSession;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link MessageSession}.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class MessageSessionBinding extends WireDescriptorBinding {
+
+  public MessageSessionBinding() {
+    super("message-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor objectDescriptor = new ObjectDescriptor();
+    
+    String target = XmlUtil.attribute(element, "target");
+    if ("jms".equals(target)) {
+      objectDescriptor.setClassName(JmsMessageSession.class.getName());
+      objectDescriptor.addInjection("dbSession", new ContextTypeRefDescriptor(DbSession.class));
+      
+      if (element.hasAttribute("session-jndi")) {
+        String jmsSessionJndiName = element.getAttribute("session-jndi");
+        JndiDescriptor jndiDescriptor = new JndiDescriptor(jmsSessionJndiName);
+        objectDescriptor.addInjection("jmsSession", jndiDescriptor);
+      } else {
+        parse.addProblem("attribute <"+XmlUtil.getTagLocalName(element)+" session-jndi=\"...\" is required when target=\"jms\"");
+      }
+      
+      if (element.hasAttribute("destination-jndi")) {
+        String jmsDestinationJndiName = element.getAttribute("destination-jndi");
+        JndiDescriptor jndiDescriptor = new JndiDescriptor(jmsDestinationJndiName);
+        objectDescriptor.addInjection("jmsDestination", jndiDescriptor);
+      } else {
+        parse.addProblem("attribute <"+XmlUtil.getTagLocalName(element)+" destination-jndi=\"...\" is required when target=\"jms\"");
+      }
+
+    } else {
+      objectDescriptor.setClassName(JobExecutorMessageSession.class.getName());
+      objectDescriptor.addInjection("transaction", new TransactionRefDescriptor());
+      objectDescriptor.addInjection("dbSession", new ContextTypeRefDescriptor(DbSession.class));
+    }
+
+    return objectDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/NullBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/NullBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/NullBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.NullDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a <code>null</code> value.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class NullBinding extends WireDescriptorBinding {
+
+  public NullBinding() {
+    super("null");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new NullDescriptor();
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.operation.Operation;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a java object through reflection.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ObjectBinding extends WireDescriptorBinding {
+  
+  public static final String TAG = "object";
+
+  public ObjectBinding() {
+    super(TAG);
+  }
+
+  public static boolean isObjectDescriptor(Element element) {
+    if (XmlUtil.attribute(element, "class")!=null) {
+      return true;
+    }
+    if (XmlUtil.attribute(element, "factory")!=null) {
+      return true;
+    }
+    if (XmlUtil.element(element, "factory")!=null) {
+      return true;
+    }
+    return false;
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor();
+
+    Parser wireParser = (Parser) parser;
+    String className = XmlUtil.attribute(element, "class");
+    String factoryObjectName = XmlUtil.attribute(element, "factory");
+    Element factoryElement = XmlUtil.element(element, "factory");
+
+    if (className!=null) {
+      descriptor.setClassName(className);
+      if (factoryObjectName!=null) {
+        parse.addProblem("attribute 'factory' is specified together with attribute 'class' in element 'object': "+XmlUtil.toString(element));
+      }
+      if (factoryElement!=null) {
+        parse.addProblem("element 'factory' is specified together with attribute 'class' in element 'object': "+XmlUtil.toString(element));
+      }
+
+      Element constructorElement = XmlUtil.element(element, "constructor");
+      if (constructorElement!=null) {
+        List<Element> argElements = XmlUtil.elements(constructorElement, "arg");
+        List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+        descriptor.setArgDescriptors(argDescriptors);
+
+        if (element.hasAttribute("method")) {
+          parse.addProblem("attributes 'class' and 'method' indicate static method and also a 'constructor' element is specified for element 'object': "+XmlUtil.toString(element));
+        }
+      }
+
+    } else if (factoryObjectName!=null) {
+      descriptor.setFactoryObjectName(factoryObjectName);
+      if (factoryElement!=null) {
+        parse.addProblem("element 'factory' is specified together with attribute 'factory' in element 'object': "+XmlUtil.toString(element));
+      }
+
+    } else if (factoryElement!=null) {
+      Element factoryDescriptorElement = XmlUtil.element(factoryElement);
+      Descriptor factoryDescriptor = (Descriptor) parser.parseElement(factoryDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+      descriptor.setFactoryDescriptor(factoryDescriptor);
+
+    } else {
+      parse.addProblem("element 'object' must have one of {attribute 'class', attribute 'factory' or element 'factory'}: "+XmlUtil.toString(element));
+    }
+
+    // method
+    if (element.hasAttribute("method")) {
+      descriptor.setMethodName(element.getAttribute("method"));
+
+      List<Element> argElements = XmlUtil.elements(element, "arg");
+      List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+      descriptor.setArgDescriptors(argDescriptors);
+    } else if (className == null) {
+      parse.addProblem("element 'object' with a element 'factory' or a attribute 'factory' must have a attribute 'method': "+XmlUtil.toString(element));
+    }
+
+    if( (className == null) && (XmlUtil.element(element, "constructor") != null)){
+      parse.addProblem("element 'object' with a element 'factory' or a attribute 'factory' can't have a 'constructor' element: "+XmlUtil.toString(element));
+    }
+
+    // read the operations elements
+    List<Operation> operations = null;
+    List<Element> elements = XmlUtil.elements(element);
+    
+    Set<String> operationTagNames = null;
+    Bindings bindings = parser.getBindings();
+    if (bindings!=null) {
+      operationTagNames = bindings.getTagNames(WireParser.CATEGORY_OPERATION);
+    } else {
+      operationTagNames = Collections.EMPTY_SET;
+    }
+
+    for (Element childElement: elements) {
+      if (operationTagNames.contains(childElement.getTagName())) {
+        Operation operation = (Operation) parser.parseElement(childElement, parse, WireParser.CATEGORY_OPERATION);
+        if (operations==null) {
+          operations = new ArrayList<Operation>();
+        }
+        operations.add(operation);
+      }
+    }
+    descriptor.setOperations(operations);
+
+    // autowiring
+    Boolean isAutoWireEnabled = XmlUtil.attributeBoolean(element, "auto-wire", false, parse);
+    if (isAutoWireEnabled!=null) {
+      descriptor.setAutoWireEnabled(isAutoWireEnabled.booleanValue());
+    }
+    return descriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ProcessServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ProcessServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ProcessServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.ProcessServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceBinding extends WireDescriptorBinding {
+
+  public ProcessServiceBinding() {
+    super("process-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(ProcessServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.PropertiesDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a java.util.Properties.
+ * 
+ * See schema docs for more details.
+ * 
+ * @author Tom Baeyens
+ */
+public class PropertiesBinding extends WireDescriptorBinding {
+  
+  public PropertiesBinding() {
+    super("properties");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    PropertiesDescriptor descriptor = new PropertiesDescriptor();
+    
+    if (element.hasAttribute("file")) {
+      descriptor.setFile(element.getAttribute("file"));
+    }
+    
+    if (element.hasAttribute("resource")) {
+      descriptor.setResource(element.getAttribute("resource"));
+    }
+    
+    if (element.hasAttribute("url")) {
+      descriptor.setUrl(element.getAttribute("url"));
+    }
+    
+    Boolean isXml = XmlUtil.attributeBoolean(element, "is-xml", false, parse);
+    if (isXml!=null) {
+      descriptor.setXml(isXml.booleanValue());
+    }
+
+    List<Descriptor> keyDescriptors = new ArrayList<Descriptor>();
+    List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
+
+    List<Element> elements = XmlUtil.elements(element);
+    for (Element propertyElement: elements) {
+      if ("property".equals(XmlUtil.getTagLocalName(propertyElement))) {
+        // key
+        String name = XmlUtil.attribute(propertyElement, "name");
+        // value
+        String value = XmlUtil.attribute(propertyElement, "value");
+
+        if ( (name!=null)
+             && (value!=null)
+           ) {
+          keyDescriptors.add(new StringDescriptor(name));
+          valueDescriptors.add(new StringDescriptor(value));
+        } else {
+          parse.addProblem("property must have name and value attributes: "+XmlUtil.toString(propertyElement));
+        }
+      } else {
+        parse.addProblem("properties can only contain property elements: "+XmlUtil.toString(propertyElement));
+      }
+    }
+
+    descriptor.setKeyDescriptors(keyDescriptors);
+    descriptor.setValueDescriptors(valueDescriptors);
+
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertyBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertyBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertyBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Binding;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * <p>This {@link Binding} specifies {@link PropertyOperation} (for property injection).</p>
+ *
+ * <p>A property injection is defined by a <b><code>{@literal <property>}</code></b> xml element.</p>
+ *
+ * <p>This element must have a attribute "name" or a attribute "setter".
+ * <ul>
+ * <li>the "name" attribute specifies the name of the property to inject. For a property <code>foo</code>, a setter method named <code>setFoo</code> should exist.</li>
+ * <li>the "setter" attribute specifies the name of the setter method to use to inject the property.</li>
+ * </ul>
+ * If both attributes are present, the setter method is used.
+ * </p>
+ *
+ * <p>This element should contain a child element that defines a {@link Descriptor}.
+ * This descriptor will be used to create the object that will be assigned to the field</p>
+ *
+ * <h3>Example</h3>
+ *
+ * Consider the following class:
+ * <pre> public class Foo {
+ *   String bar;
+ *   public void setBar(String bar) {
+ *     this.bar = bar;
+ *   }
+ * }</pre>
+ *
+ * The following Xml declaration will create an object 'o' of class 'Foo' (see {@link org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor}), and
+ * the value <code>hello</code> will be assigned to <code>o.bar</code> by calling the <code>setBar</code> method.
+ *
+ * <pre> &lt;objects&gt;
+ *   &lt;object name='o' class='Foo'&gt;
+ *     &lt;property name='bar'&gt;
+ *       &lt;string value='hello' /&gt;
+ *     &lt;/property&gt;
+ *   &lt;/object&gt;
+ * &lt;/objects&gt;</pre>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see ObjectBinding
+ * @see WireParser
+ */
+public class PropertyBinding extends WireOperationBinding {
+
+  public PropertyBinding() {
+    super("property");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    PropertyOperation propertyOperation = new PropertyOperation();
+    if (element.hasAttribute("setter")) {
+      propertyOperation.setSetterName(element.getAttribute("setter"));
+    } else if (element.hasAttribute("name")) {
+      propertyOperation.setPropertyName(element.getAttribute("name"));
+    } else {
+      parse.addProblem("property must have name or setter attribute: "+XmlUtil.toString(element));
+    }
+    Element descriptorElement = XmlUtil.element(element);
+    if (descriptorElement!=null) {
+      Descriptor descriptor = (Descriptor) parser.parseElement(descriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
+      if (descriptor!=null) {
+        propertyOperation.setDescriptor(descriptor);
+      } else {
+        parse.addProblem("couldn't parse property content element as a value descriptor: "+XmlUtil.toString(element));
+      }
+    } else {
+      parse.addProblem("property must have 1 descriptor element out of "+parser.getBindings().getTagNames(WireParser.CATEGORY_DESCRIPTOR)+" as content: "+XmlUtil.toString(element));
+    }
+    return propertyOperation;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PvmDbSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PvmDbSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PvmDbSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.hibernate.HibernatePvmDbSession;
+import org.jbpm.pvm.internal.wire.descriptor.HibernatePvmDbSessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link HibernatePvmDbSession}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class PvmDbSessionBinding extends WireDescriptorBinding {
+  
+  public static final String TAG = "pvm-db-session";
+
+  public PvmDbSessionBinding() {
+    super(TAG);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernatePvmDbSessionDescriptor descriptor = new HibernatePvmDbSessionDescriptor();
+    
+    if (element.hasAttribute("session")) {
+      descriptor.setSessionName(element.getAttribute("session"));
+    }
+    
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for referring to another object by name.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class RefBinding extends WireDescriptorBinding {
+
+  public RefBinding() {
+    super("ref");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ReferenceDescriptor descriptor = new ReferenceDescriptor();
+    if (element.hasAttribute("object")) {
+      descriptor.setValue(element.getAttribute("object"));
+    } else {
+      parse.addProblem("ref must have object attribute: "+XmlUtil.toString(element));
+    }
+    return descriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.svc.RetryInterceptor;
+import org.jbpm.pvm.internal.wire.descriptor.RetryInterceptorDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link RetryInterceptor}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class RetryInterceptorBinding extends WireInterceptorBinding {
+
+  public RetryInterceptorBinding() {
+    super("retry-interceptor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    RetryInterceptorDescriptor retryInterceptorDescriptor = new RetryInterceptorDescriptor();
+    
+    if (element.hasAttribute("retries")) {
+      String retriesText = element.getAttribute("retries");
+      try {
+        int retries = Integer.parseInt(retriesText);
+        retryInterceptorDescriptor.setRetries(retries);
+      } catch (NumberFormatException e) {
+        parse.addProblem("couldn't parse retries "+retriesText);
+      }
+    }
+
+    if (element.hasAttribute("delay")) {
+      String delayText = element.getAttribute("delay");
+      try {
+        long delay = Long.parseLong(delayText);
+        retryInterceptorDescriptor.setDelay(delay);
+      } catch (NumberFormatException e) {
+        parse.addProblem("couldn't parse delay "+delayText);
+      }
+    }
+
+    if (element.hasAttribute("delay-factor")) {
+      String delayFactorText = element.getAttribute("delay-factor");
+      try {
+        long delayFactor = Long.parseLong(delayFactorText);
+        retryInterceptorDescriptor.setDelayFactor(delayFactor);
+      } catch (NumberFormatException e) {
+        parse.addProblem("couldn't parse delay-factor "+delayFactorText);
+      }
+    }
+
+    return retryInterceptorDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SaveBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.SaveDeployer;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/** parses a descriptor for creating a {@link SaveDeployer} deployer.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class SaveBinding extends WireDescriptorBinding {
+
+  public SaveBinding() {
+    super("save");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    SaveDeployer saveDeployer = new SaveDeployer();
+    return new ProvidedObjectDescriptor(saveDeployer);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ScriptManagerBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ScriptManagerBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ScriptManagerBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptManagerBinding extends WireDescriptorBinding {
+
+  public ScriptManagerBinding() {
+    super("script-manager");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(ScriptManager.class);
+    
+    if (element.hasAttribute("default-expression-language")) {
+      String defaultLanguage = element.getAttribute("default-expression-language");
+      descriptor.addInjection("defaultExpressionLanguage", new StringDescriptor(defaultLanguage));
+    }
+
+    if (element.hasAttribute("default-script-language")) {
+      String defaultLanguage = element.getAttribute("default-script-language");
+      descriptor.addInjection("defaultScriptLanguage", new StringDescriptor(defaultLanguage));
+    }
+
+    if (element.hasAttribute("read-contexts")) {
+      String readContextsText = element.getAttribute("read-contexts");
+      List<String> readContextList = XmlUtil.parseCommaSeparatedList(readContextsText);
+      String[] readContextNames = readContextList.toArray(new String[readContextList.size()]);
+      descriptor.addInjection("readContextNames", new ProvidedObjectDescriptor(readContextNames));
+      
+    } else {
+      parse.addProblem("'read-contexts' is a required attribute in element <script-manager />");
+    }
+
+    if (element.hasAttribute("write-context")) {
+      String writeContextName = element.getAttribute("write-context");
+      descriptor.addInjection("writeContextName", new StringDescriptor(writeContextName));
+      
+    } else {
+      parse.addProblem("'write-context' is a required attribute in element <script-manager />");
+    }
+    
+    ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
+    List<Element> scriptElements = XmlUtil.elements(element, "script-language");
+    for (Element scriptElement : scriptElements) {
+      String languageName = null;
+      if (scriptElement.hasAttribute("name")) {
+        languageName = scriptElement.getAttribute("name");
+      } else {
+        parse.addProblem("'name' is a required attribute in element <script-language />");
+      }
+      String factoryClassName = null;
+      if (scriptElement.hasAttribute("factory")) {
+        factoryClassName = scriptElement.getAttribute("factory");
+      } else {
+        parse.addProblem("'name' is a required attribute in element <script-language />");
+      }
+      
+      if ( (languageName!=null)
+           && (factoryClassName!=null)
+         ) {
+        try {
+          Class<?> factoryClass = ReflectUtil.loadClass(parse.getClassLoader(), factoryClassName);
+          ScriptEngineFactory scriptEngineFactory = (ScriptEngineFactory) factoryClass.newInstance();
+          scriptEngineManager.registerEngineName(languageName, scriptEngineFactory);
+        } catch (Exception e) {
+          parse.addProblem("couldn't instantiate ScriptEngineFactory "+factoryClassName, e);
+        }
+      }
+    }
+    
+    descriptor.addInjection("scriptEngineManager", new ProvidedObjectDescriptor(scriptEngineManager));
+    
+    return descriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SeamHibernateSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SeamHibernateSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SeamHibernateSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.SeamHibernateSessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SeamHibernateSessionBinding extends WireDescriptorBinding {
+  
+  public SeamHibernateSessionBinding() {
+    super("seam-hibernate-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    SeamHibernateSessionDescriptor seamHibernateSessionDescriptor = new SeamHibernateSessionDescriptor(); 
+    
+    if (element.hasAttribute("component-name")) {
+      String componentName = element.getAttribute("component-name");
+      seamHibernateSessionDescriptor.setComponentName(componentName);
+    }
+    
+    return seamHibernateSessionDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SetBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SetBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SetBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.Set;
+
+import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.SetDescriptor;
+
+/** parses a descriptor for creating a {@link java.util.Set}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class SetBinding extends AbstractCollectionBinding {
+
+  public SetBinding() {
+    super("set");
+  }
+
+  protected CollectionDescriptor createDescriptor() {
+    return new SetDescriptor();
+  }
+
+  protected Class<?> getCollectionInterface() {
+    return Set.class;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ShortBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ShortBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ShortBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ShortDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for a {@link java.lang.Short}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ShortBinding extends BasicTypeBinding {
+
+  public ShortBinding() {
+    super("short");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    ShortDescriptor shortDescriptor = new ShortDescriptor();
+    Short shortValue;
+    try {
+      shortValue = new Short(value);
+    } catch (NumberFormatException e) {
+      parse.addProblem(createValueExceptionMessage("'"+value+"' cannot be parsed to a short", element));
+      return null;
+    }
+    shortDescriptor.setValue(shortValue);
+    return shortDescriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardCommandServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.DefaultCommandService;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.CommandServiceDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for a creating {@link DefaultCommandService}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class StandardCommandServiceBinding extends WireDescriptorBinding {
+
+  public StandardCommandServiceBinding() {
+    super("command-service");
+  }
+  
+  protected StandardCommandServiceBinding(String tagName) {
+    super(tagName);
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    CommandServiceDescriptor commandServiceDescriptor = new CommandServiceDescriptor();
+
+    CommandService commandService = getCommandService(element, parse, parser);
+    commandServiceDescriptor.setCommandService(commandService);
+    
+    List<Element> interceptorElements = XmlUtil.elements(element);
+    for (Element interceptorElement : interceptorElements) {
+      Descriptor interceptorDescriptor = (Descriptor) parser.parseElement(interceptorElement, parse, WireParser.CATEGORY_INTERCEPTOR);
+      commandServiceDescriptor.addInterceptorDescriptor(interceptorDescriptor);
+    }
+
+    return commandServiceDescriptor;
+  }
+
+  protected CommandService getCommandService(Element element, Parse parse, Parser parser) {
+    return new DefaultCommandService();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.tx.StandardTransactionInterceptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link StandardTransactionInterceptor}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class StandardTransactionInterceptorBinding extends WireInterceptorBinding {
+
+  public StandardTransactionInterceptorBinding() {
+    super("standard-transaction-interceptor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    StandardTransactionInterceptor standardTransactionInterceptor = new StandardTransactionInterceptor();
+    return new ProvidedObjectDescriptor(standardTransactionInterceptor);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StringBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StringBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/StringBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for a {@link java.lang.String}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class StringBinding extends BasicTypeBinding {
+
+  public StringBinding() {
+    super("string");
+  }
+
+  protected AbstractDescriptor createDescriptor(String value, Element element, Parse parse) {
+    StringDescriptor stringDescriptor = new StringDescriptor();
+    stringDescriptor.setValue(value);
+    return stringDescriptor;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SubscribeBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.operation.SubscribeOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for a {@link SubscribeOperation subscribe operation}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class SubscribeBinding extends WireOperationBinding {
+
+  public SubscribeBinding() {
+    super("subscribe");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    SubscribeOperation subscribeOperation = new SubscribeOperation();
+
+    // these are the different ways of specifying observables:
+    // <subscribe [context='contextName'] [event(s)='...']... /> will use the context as the observable
+    // <subscribe [context='contextName'] object(s)='objectName' [event(s)='...'] ... /> will use the object(s) with the given name in the specified context
+    // <subscribe [context='contextName'] to='wire-events' event(s)='...' [object(s)='...'] ... /> will listen to wire events of a specific object in the specified context
+
+    // context
+    String contextName = XmlUtil.attribute(element, "context");
+    subscribeOperation.setContextName(contextName);
+
+    // to
+    String to = XmlUtil.attribute(element, "to");
+    if ("wire-events".equalsIgnoreCase(to)) {
+      subscribeOperation.setWireEvents(true);
+    }
+
+    // events
+    List<String> eventNames = XmlUtil.parseList(element, "event");
+    subscribeOperation.setEventNames(eventNames);
+
+    // objects
+    List<String> objectNames = XmlUtil.parseList(element, "object");
+    subscribeOperation.setObjectNames(objectNames);
+
+    // method & args
+    String methodName = XmlUtil.attribute(element, "method");
+    subscribeOperation.setMethodName(methodName);
+    List<Element> argElements = XmlUtil.elements(element, "arg");
+    Parser wireParser = (Parser) parser;
+    List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse);
+    subscribeOperation.setArgDescriptors(argDescriptors);
+
+   return subscribeOperation;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskDbSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskDbSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskDbSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.HibernateTaskDbSessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskDbSessionBinding extends WireDescriptorBinding {
+
+  public TaskDbSessionBinding() {
+    super("task-db-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateTaskDbSessionDescriptor descriptor = new HibernateTaskDbSessionDescriptor();
+
+    if (element.hasAttribute("session")) {
+      descriptor.setSessionName(element.getAttribute("session"));
+    }
+
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.task.TaskServiceImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskServiceBinding extends WireDescriptorBinding {
+
+  public TaskServiceBinding() {
+    super("task-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(TaskServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutorTimerSession;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.EnvDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.TransactionRefDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.session.TimerSession;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link TimerSession}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens, Pascal Verdage
+ */
+public class TimerSessionBinding extends WireDescriptorBinding {
+
+  public TimerSessionBinding() {
+    super("timer-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor objectDescriptor = new ObjectDescriptor();
+    
+    String target = XmlUtil.attribute(element, "target");
+
+    if ((target!=null) && ("ejb".equalsIgnoreCase(target))) {
+      objectDescriptor.setClassName("org.jbpm.enterprise.internal.ejb.EnterpriseTimerSession");
+
+    } else {
+      // wire the JobExecutorTimerSession
+      objectDescriptor.setClassName(JobExecutorTimerSession.class.getName());
+
+      // inject fields
+      objectDescriptor.addInjection("transaction", new TransactionRefDescriptor());
+      objectDescriptor.addInjection("jobExecutor", new EnvDescriptor(JobExecutor.class));
+      objectDescriptor.addInjection("jobDbSession", new ContextTypeRefDescriptor(JobDbSession.class));
+    }
+
+    return objectDescriptor;
+  }
+}
+

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link Transaction}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class TransactionBinding extends WireDescriptorBinding {
+
+  public TransactionBinding() {
+    super("transaction");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor transactionDescriptor = null;
+
+    String type = "standard";
+    if (element.hasAttribute("type")) {
+      type = element.getAttribute("type");
+    }
+    
+    if ("standard".equals(type)) {
+      transactionDescriptor = new ObjectDescriptor(StandardTransaction.class);
+    } else {
+      parse.addProblem("unsupported transaction type: "+type);
+    }
+    
+    return transactionDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionRefBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionRefBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionRefBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.wire.descriptor.TransactionRefDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/** parses a descriptor for referring to the {@link Transaction}.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class TransactionRefBinding extends WireDescriptorBinding {
+
+  public TransactionRefBinding() {
+    super("transaction-ref");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new TransactionRefDescriptor();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TrueBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TrueBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TrueBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for Boolean.TRUE.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (Documentation)
+ */
+public class TrueBinding extends WireDescriptorBinding {
+
+  public TrueBinding() {
+    super("true");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new TrueDescriptor();
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.type.Converter;
+import org.jbpm.pvm.internal.type.Matcher;
+import org.jbpm.pvm.internal.type.Type;
+import org.jbpm.pvm.internal.type.TypeMapping;
+import org.jbpm.pvm.internal.type.matcher.ClassNameMatcher;
+import org.jbpm.pvm.internal.type.matcher.HibernateLongIdMatcher;
+import org.jbpm.pvm.internal.type.matcher.HibernateStringIdMatcher;
+import org.jbpm.pvm.internal.type.matcher.SerializableMatcher;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.TypesDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for Boolean.TRUE.
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class TypesBinding extends WireDescriptorBinding {
+  
+  public TypesBinding() {
+    super("types");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    StreamInput streamSource = null;
+    if (element.hasAttribute("file")) {
+      String fileName = element.getAttribute("file");
+      File file = new File(fileName);
+      if (file.exists() && file.isFile()) {
+        streamSource = new FileStreamInput(file);
+        parser.importStream(streamSource, element, parse);
+      } else {
+        parse.addProblem("file "+fileName+" isn't a file");
+      }
+    }
+    
+    if (element.hasAttribute("resource")) {
+      String resource = element.getAttribute("resource");
+      streamSource = new ResourceStreamInput(resource, parse.getClassLoader());
+      parser.importStream(streamSource, element, parse);
+    }
+    
+    if (element.hasAttribute("url")) {
+      String urlText = element.getAttribute("url");
+      try {
+        URL url = new URL(urlText);
+        streamSource = new UrlStreamInput(url);
+        parser.importStream(streamSource, element, parse);
+      } catch (Exception e) {
+        parse.addProblem("couldn't open url "+urlText, e);
+      }
+    }
+    
+    TypesDescriptor typesDescriptor = new TypesDescriptor();
+    
+    List<Element> typeElements = XmlUtil.elements(element, "type");
+    for (Element typeElement: typeElements) {
+      TypeMapping typeMapping = parseTypeMapping(typeElement, parse, parser);
+      typesDescriptor.addTypeMapping(typeMapping);
+    }
+    return typesDescriptor;
+  }
+
+  protected TypeMapping parseTypeMapping(Element element, Parse parse, Parser parser) {
+    TypeMapping typeMapping = new TypeMapping();
+    Type type = new Type();
+    typeMapping.setType(type);
+    
+    // type name
+    if (element.hasAttribute("name")) {
+      type.setName(element.getAttribute("name"));
+    }
+    
+    String hibernateSessionFactoryName = XmlUtil.attribute(element, "hibernate-session-factory");
+    
+    // first we get the matcher
+    Matcher matcher = null;
+    if (element.hasAttribute("class")) {
+      String className = element.getAttribute("class");
+      
+      // if type="serializable"
+      if ("serializable".equals(className)) {
+        matcher = new SerializableMatcher();
+        
+      // if type="persistable"
+      } else if ("persistable".equals(className)) {
+        if (element.hasAttribute("id-type")) {
+          String idType = element.getAttribute("id-type");
+          if ("long".equalsIgnoreCase(idType)) {
+            matcher = new HibernateLongIdMatcher(hibernateSessionFactoryName); 
+          } else if ("string".equalsIgnoreCase(idType)) {
+            matcher = new HibernateStringIdMatcher(hibernateSessionFactoryName); 
+          } else {
+            parse.addProblem("id-type was not 'long' or 'string': "+idType);
+          }
+        } else {
+          parse.addProblem("id-type is required in a persistable type");
+        }
+
+      // otherwise, we expect type="some.java.ClassName"
+      } else {
+        matcher = new ClassNameMatcher(className);
+      }
+
+    } else {
+      // look for the matcher element
+      Element matcherElement = XmlUtil.element(element, "matcher");
+      Element matcherObjectElement = XmlUtil.element(matcherElement);
+      if (matcherObjectElement!=null) {
+        try {
+          matcher = (Matcher) parser.parseElement(matcherObjectElement, parse);
+        } catch (ClassCastException e) {
+          parse.addProblem("matcher is not a "+Matcher.class.getName()+": "+(matcher!=null ? matcher.getClass().getName() : "null"));
+        }
+      } else {
+        parse.addProblem("no matcher specified in "+XmlUtil.toString(element));
+      }
+    }
+
+    typeMapping.setMatcher(matcher);
+
+    // parsing the converter 
+    Converter converter = null;
+    if (element.hasAttribute("converter")) {
+      String converterClassName = element.getAttribute("converter");
+      ClassLoader classLoader = parse.getClassLoader();
+      try {
+        Class<?> converterClass = ReflectUtil.loadClass(classLoader, converterClassName);
+        converter = (Converter) converterClass.newInstance();
+      } catch (Exception e) {
+        parse.addProblem("couldn't instantiate converter "+converterClassName);
+      }
+    } else {
+      // look for the matcher element
+      Element converterElement = XmlUtil.element(element, "converter");
+      Element converterObjectElement = XmlUtil.element(converterElement);
+      if (converterObjectElement!=null) {
+        try {
+          converter = (Converter) parser.parseElement(converterObjectElement, parse);
+        } catch (ClassCastException e) {
+          parse.addProblem("converter is not a "+Converter.class.getName()+": "+(converter!=null ? converter.getClass().getName() : "null"));
+        }
+      } 
+    }
+
+    type.setConverter(converter);
+    
+    // parsing the variable class
+    
+    Class<?> variableClass = null;
+    if (element.hasAttribute("variable-class")) {
+      String variableClassName = element.getAttribute("variable-class"); 
+      ClassLoader classLoader = parse.getClassLoader();
+      try {
+        variableClass = ReflectUtil.loadClass(classLoader, variableClassName);
+      } catch (Exception e) {
+        parse.addProblem("couldn't instantiate variable-class "+variableClassName, e);
+      }
+    } else {
+      parse.addProblem("variable-class is required on a type: "+XmlUtil.toString(element));
+    }
+
+    type.setVariableClass(variableClass);
+    
+    return typeMapping;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.util.TagBinding;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class WireBinding extends TagBinding {
+  
+  static final String WIRE_NAMESPACE = "http://jbpm.org/4/cfg";
+  
+  public WireBinding(String tagName, String category) {
+    // the wire bindings currently don't use the namespace as 
+    super(tagName, null, category);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireDescriptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireDescriptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireDescriptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class WireDescriptorBinding extends WireBinding {
+
+  public WireDescriptorBinding(String tagName) {
+    super(tagName, WireParser.CATEGORY_DESCRIPTOR);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireInterceptorBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireInterceptorBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireInterceptorBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class WireInterceptorBinding extends WireBinding {
+
+  public WireInterceptorBinding(String tagName) {
+    super(tagName, WireParser.CATEGORY_INTERCEPTOR);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireOperationBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireOperationBinding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/WireOperationBinding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class WireOperationBinding extends WireBinding {
+
+  public WireOperationBinding(String tagName) {
+    super(tagName, WireParser.CATEGORY_OPERATION);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,4 @@
+<body>
+each {@link org.jbpm.pvm.internal.xml.Binding} class creates a 
+wire descriptor from a dom element.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/AbstractDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/AbstractDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/AbstractDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.util.DefaultObservable;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * base class for {@link Descriptor}s.
+ * @author Tom Baeyens
+ */
+public abstract class AbstractDescriptor extends DefaultObservable implements Serializable, Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected int version;
+  protected String name = null;
+
+  /** lazy creation and delayed initialization */
+  public static final char INIT_LAZY='L';
+  
+  /** eager creation and delayed initialization */
+  public static final char INIT_EAGER='E';
+  
+  /** lazy creation and immediate initialization */
+  public static final char INIT_REQUIRED='R';
+  
+  /** eager creation and immediate initialization */
+  public static final char INIT_IMMEDIATE='I';
+
+  protected char init = INIT_LAZY;
+
+  public AbstractDescriptor() {
+  }
+
+  public AbstractDescriptor(String name) {
+    this.name = name;
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return null;
+  }
+  
+  public boolean isEagerInit() {
+    return (init == INIT_EAGER || init == INIT_IMMEDIATE);
+  }
+
+  public boolean isDelayable() {
+    return (init == INIT_EAGER || init == INIT_LAZY);
+  }
+  
+  public void initialize(Object object, WireContext wireContext) {
+  }
+
+  /** the db primary key. */
+  public Long getDbid() {
+    return dbid;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  /** see section 'Initialization' of {@link WireContext} */
+  public void setInit(char init) {
+    this.init = init;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ArgDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ArgDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ArgDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,61 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
+import org.jbpm.pvm.internal.wire.operation.SubscribeOperation;
+
+/**
+ * <p>This class specifies an argument to be supplied to a method.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see ObjectDescriptor
+ * @see InvokeOperation
+ * @see SubscribeOperation
+ */
+public class ArgDescriptor implements Serializable{
+
+  private static final long serialVersionUID = 1L;
+  
+  long dbid;
+  int dbversion;
+  String typeName;
+  Descriptor descriptor;
+
+  public ArgDescriptor() {
+  }
+
+  /**
+   * Gets the Descriptor used to construct the value given to the argument.
+   */
+  public Descriptor getDescriptor() {
+    return descriptor;
+  }
+
+  /**
+   * Sets the Descriptor used to construct the value given to the argument.
+   * @param descriptor
+   */
+  public void setDescriptor(Descriptor descriptor) {
+    this.descriptor = descriptor;
+  }
+
+  /**
+   * Gets the name of the type of this argument if it is defined.
+   * If the type name is not defined, the type of the Descriptor is used.
+   */
+  public String getTypeName() {
+    return typeName;
+  }
+
+  /**
+   * Sets the name of the type of this argument.
+   * @param typeName
+   */
+  public void setTypeName(String typeName) {
+    this.typeName = typeName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BooleanHelper.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BooleanHelper.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BooleanHelper.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+/** helper for converting boolean values into the appropriate descriptor.
+ * 
+ * @author Tom Baeyens
+ */
+public abstract class BooleanHelper {
+  
+  /** translates a tristate (true, false, null) Boolean value into 
+   * the appropriate descriptor ({@link TrueDescriptor}, {@link FalseDescriptor} 
+   * or {@link NullDescriptor}). */ 
+  public static AbstractDescriptor createDescriptor(Boolean tristate) {
+    if (tristate==null) {
+      return new NullDescriptor();
+    } else if (Boolean.TRUE.equals(tristate)) {
+      return new TrueDescriptor();
+    }
+    return new FalseDescriptor();
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BusinessCalendarDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BusinessCalendarDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/BusinessCalendarDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.cal.BusinessCalendar;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+public class BusinessCalendarDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  BusinessCalendar businessCalendar;
+  
+  public BusinessCalendarDescriptor() {
+  }
+
+  public BusinessCalendarDescriptor(BusinessCalendar businessCalendar) {
+    this.businessCalendar = businessCalendar;
+  }
+
+  public Object construct(WireContext wireContext) {
+    return businessCalendar;
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return BusinessCalendar.class;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ByteDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ByteDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ByteDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ByteDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Long longVal;
+
+  public ByteDescriptor() {
+  }
+
+  public ByteDescriptor(Byte value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    if (longVal==null) {
+      return null;
+    }
+    return new Byte(longVal.byteValue());
+  }
+
+  public void setValue(Byte value) {
+    if (value==null) {
+      longVal = null;
+    } else {
+      longVal = new Long(value);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class CharacterDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  String text;
+
+  public CharacterDescriptor() {
+  }
+
+  public CharacterDescriptor(Character value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    if (text==null) {
+      return null;
+    }
+    return new Character( text.charAt(0) );
+  }
+
+  public void setValue(Character value) {
+    if (value==null) {
+      text = null;
+    } else {
+      text = value.toString();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/** loads the class with the specified class name using the WireContext class loader.
+ * 
+ * @see WireContext#getClassLoader()
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ClassDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  String text;
+
+  /** loads the class from the class loader of the specified WireContext.
+   * @throws WireException if the class could not be loaded.
+   */
+  public Object construct(WireContext wireContext) {
+    ClassLoader classLoader = wireContext.getClassLoader();
+    try {
+      return ReflectUtil.loadClass(classLoader, text);
+    } catch (JbpmException e) {
+      Throwable cause = (e.getCause()!=null ? e.getCause() : e);
+      throw new WireException("couldn't load class '"+text+"': "+cause.getMessage(), cause);
+    }
+  }
+
+  public void setClassName(String className) {
+    this.text = className;
+  }
+
+  public void setClass(Class<?> clazz) {
+    if (clazz==null) {
+      text = null;
+    } else {
+      this.text = clazz.getName();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassLoaderDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassLoaderDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ClassLoaderDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/** returns the class loader of the wire context.
+ * 
+ * @author Tom Baeyens
+ */
+public class ClassLoaderDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext wireContext) {
+    return wireContext.getClassLoader();
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return ClassLoader.class;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,102 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CollectionDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  private static Log log = Log.getLog(CollectionDescriptor.class.getName());
+  
+  protected String className;
+  protected List<Descriptor> valueDescriptors;
+  protected boolean isSynchronized;
+
+  protected CollectionDescriptor() { }
+  
+  public CollectionDescriptor(String defaultImplClassName) {
+    this.className = defaultImplClassName;
+  }
+
+  public Object construct(WireContext wireContext) {
+    Object object = null;
+    try {
+      // instantiate
+      ClassLoader classLoader = wireContext.getClassLoader();
+      Class<?> clazz = ReflectUtil.loadClass(classLoader, className);
+      object = clazz.newInstance();
+      
+      if (isSynchronized) {
+        if (object instanceof SortedSet) {
+          object = Collections.synchronizedSortedSet((SortedSet) object);
+        } else if (object instanceof SortedMap) {
+          object = Collections.synchronizedSortedMap((SortedMap) object);
+        } else if (object instanceof Set) {
+          object = Collections.synchronizedSet((Set) object);
+        } else if (object instanceof Map) {
+          object = Collections.synchronizedMap((Map) object);
+        } else if (object instanceof List) {
+          object = Collections.synchronizedList((List) object);
+        } else if (object instanceof Collection) {
+          object = Collections.synchronizedCollection((Collection) object);
+        }
+      }
+
+    } catch (Exception e) {
+      throw new WireException("couldn't create '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
+    }
+    return object;
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    Collection<Object> collection = (Collection<Object>) object;
+    try {
+      if (valueDescriptors!=null) {
+        for(Descriptor descriptor: valueDescriptors) {
+          Object element = wireContext.create(descriptor, true);
+          log.trace("adding element "+element+" to collection");
+          collection.add(element);
+        }
+      }
+    } catch (WireException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
+    }
+  }
+
+  public String getClassName() {
+    return className;
+  }
+  public void setClassName(String className) {
+    this.className = className;
+  }
+  public List<Descriptor> getValueDescriptors() {
+    return valueDescriptors;
+  }
+  public void setValueDescriptors(List<Descriptor> valueDescriptors) {
+    this.valueDescriptors = valueDescriptors;
+  }
+  public boolean isSynchronized() {
+    return isSynchronized;
+  }
+  public void setSynchronized(boolean isSynchronized) {
+    this.isSynchronized = isSynchronized;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CommandServiceDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.svc.Interceptor;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CommandServiceDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  CommandService commandService;
+  List<Descriptor> interceptorDescriptors;
+
+  public Object construct(WireContext wireContext) {
+    CommandService interceptedCommandService = commandService;
+    if (interceptorDescriptors!=null) {
+      for (int i=interceptorDescriptors.size()-1 ; i>=0; i--) {
+        Descriptor descriptor = interceptorDescriptors.get(i);
+        Interceptor interceptor = (Interceptor) descriptor.construct(wireContext);
+        interceptor.setNext(interceptedCommandService);
+        interceptedCommandService = interceptor;
+      }
+    }
+    return interceptedCommandService;
+  }
+  
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return CommandService.class;
+  }
+  
+  public void addInterceptorDescriptor(Descriptor descriptor) {
+    if (interceptorDescriptors==null) {
+      interceptorDescriptors = new ArrayList<Descriptor>();
+    }
+    interceptorDescriptors.add(descriptor);
+  }
+  
+  public void setCommandService(CommandService commandService) {
+    this.commandService = commandService;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+public class ContextRefDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  String contextName;
+
+  public Object construct(WireContext wireContext) {
+    if (contextName==null) {
+      return wireContext;
+    }
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new WireException("can't get context '"+contextName+"': no current environment");
+    }
+    return environment.getContext(contextName);
+  }
+
+  public String getContextName() {
+    return contextName;
+  }
+  public void setContextName(String contextName) {
+    this.contextName = contextName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextTypeRefDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextTypeRefDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextTypeRefDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ContextTypeRefDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ContextTypeRefDescriptor.class.getName());
+  
+  Class<?> type;
+  
+  public ContextTypeRefDescriptor(Class<?> type) {
+    this.type = type;
+  }
+
+  public Object construct(WireContext wireContext) {
+    log.trace("looking up "+type+" by type in "+wireContext);
+    if (type!=null) {
+      return wireContext.get(type);
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DeployerManagerDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DeployerManagerDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DeployerManagerDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.deploy.Deployer;
+import org.jbpm.pvm.internal.deploy.DeployerManager;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeployerManagerDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  /** the list of descriptors for building the list of deployers */
+  protected List<Descriptor> deployerDescriptors = new ArrayList<Descriptor>();
+
+  public Object construct(WireContext wireContext) {
+    return new DeployerManager();
+  }
+  
+  public void initialize(Object object, WireContext wireContext) {
+    DeployerManager deployerManager = (DeployerManager) object;
+    
+    List<Deployer> deployers = new ArrayList<Deployer>();
+    for (Descriptor deployerDescriptor: deployerDescriptors) {
+      Deployer deployer = (Deployer) wireContext.create(deployerDescriptor, true);
+      deployers.add(deployer);
+    }
+    
+    deployerManager.setDeployers(deployers);
+  }
+
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return DeployerManager.class;
+  }
+
+  public void setDeployerDescriptors(List<Descriptor> deployerDescriptors) {
+    this.deployerDescriptors = deployerDescriptors;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DescriptorException.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DescriptorException.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DescriptorException.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,19 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+public class DescriptorException extends RuntimeException {
+
+  private static final long serialVersionUID = 1L;
+
+  public DescriptorException() {
+    super();
+  }
+  public DescriptorException(String message, Throwable cause) {
+    super(message, cause);
+  }
+  public DescriptorException(String message) {
+    super(message);
+  }
+  public DescriptorException(Throwable cause) {
+    super(cause);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class DoubleDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  Double doubleVal;
+
+  public DoubleDescriptor() {
+  }
+
+  public DoubleDescriptor(Double value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    return doubleVal;
+  }
+
+  public Double getDoubleVal() {
+    return doubleVal;
+  }
+
+  public void setValue(Double value) {
+    this.doubleVal = value;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(EnvDescriptor.class.getName());
+  
+  protected String objectName;
+  protected String typeName;
+  protected Class<?> type;
+
+  public EnvDescriptor() {
+  }
+
+  public EnvDescriptor(Class<?> type) {
+    this.type = type;
+  }
+
+  public Object construct(WireContext wireContext) {
+    Environment environment = Environment.getCurrent();
+    
+    if (environment==null) {
+      throw new WireException("no environment to get object "+(objectName!=null ? objectName : typeName));
+    }
+    
+    if (objectName!=null) {
+      log.trace("looking up "+objectName+" by name in environment");
+      return environment.get(objectName);
+    }
+
+    log.trace("looking up an object of type "+typeName+" in environment");
+    if (type==null) {
+      try {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        type = classLoader.loadClass(typeName); 
+      } catch (Exception e) {
+        throw new WireException("couldn't load class "+typeName, e);
+      }
+    }
+    return environment.get(type);
+  }
+
+  public void setObjectName(String objectName) {
+    this.objectName = objectName;
+  }
+  public void setTypeName(String typeName) {
+    this.typeName = typeName;
+  }
+  public void setType(Class< ? > type) {
+    this.type = type;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/** parses a descriptor for obtaining a reference to the environment
+ * 
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class EnvironmentDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext wireContext) {
+    return Environment.getCurrent();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentFactoryDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentFactoryDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentFactoryDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,24 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/** the {@link EnvironmentFactory} of the current {@link WireContext}.
+ * 
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnvironmentFactoryDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  EnvironmentFactory environmentFactory;
+
+  public EnvironmentFactoryDescriptor(EnvironmentFactory environmentFactory) {
+    this.environmentFactory = environmentFactory;
+  }
+
+  public Object construct(WireContext wireContext) {
+    return environmentFactory;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.svc.EnvironmentInterceptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentInterceptorDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  EnvironmentFactory environmentFactory;
+  
+  public EnvironmentInterceptorDescriptor(EnvironmentFactory environmentFactory) {
+    this.environmentFactory = environmentFactory;
+  }
+
+  public Object construct(WireContext wireContext) {
+    EnvironmentInterceptor environmentInterceptor = new EnvironmentInterceptor();
+    environmentInterceptor.setEnvironmentFactory(environmentFactory);
+    return environmentInterceptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.model.ExpressionEvaluator;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExpressionDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String expr;
+  protected String lang;
+  
+  public ExpressionDescriptor() {
+  }
+
+  public ExpressionDescriptor(String expr, String lang) {
+    this.expr = expr;
+    this.lang = lang;
+  }
+
+  public Object construct(WireContext wireContext) {
+    return new ExpressionEvaluator(getName(), expr, lang);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FalseDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FalseDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FalseDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FalseDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext wireContext) {
+    return Boolean.FALSE;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class FloatDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  Double doubleVal;
+
+  public FloatDescriptor() {
+  }
+
+  public FloatDescriptor(Float value) {
+    setValue(value); 
+  }
+
+  public Object construct(WireContext factory) {
+    if (doubleVal==null) {
+      return null;
+    }
+    return new Float(doubleVal.floatValue());
+  }
+
+  public void setValue(Float value) {
+    if (value==null) {
+      doubleVal = null;
+    } else {
+      doubleVal = new Double(value);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateConfigurationDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateConfigurationDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateConfigurationDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,309 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.hibernate.cfg.Configuration;
+import org.jbpm.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.operation.Operation;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateConfigurationDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  private static final Log log = Log.getLog(HibernateConfigurationDescriptor.class.getName());
+
+  String className;
+  String namingStrategyClassName;
+  List<Operation> cfgOperations = new ArrayList<Operation>();
+  List<Operation> cfgCacheOperations = new ArrayList<Operation>();
+  PropertiesDescriptor propertiesDescriptor = null;
+
+  public Object construct(WireContext wireContext) {
+    // instantiation of the configuration
+    Configuration configuration = null;
+    if (className!=null) {
+      ClassLoader classLoader = wireContext.getClassLoader();
+      log.trace("instantiating hibernate configuration class "+className);
+      Class<?> configurationClass = ReflectUtil.loadClass(classLoader, className);
+      configuration = (Configuration) ReflectUtil.newInstance(configurationClass);
+    } else {
+      log.trace("instantiating default hibernate configuration");
+      configuration = new Configuration();
+    }
+    return configuration;
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    Configuration configuration = (Configuration) object;
+
+    apply(cfgOperations, configuration, wireContext);
+    apply(cfgCacheOperations, configuration, wireContext);
+
+    if (propertiesDescriptor!=null) {
+      Properties properties = (Properties) wireContext.create(propertiesDescriptor, false);
+      if (log.isDebugEnabled()) log.debug("adding properties to hibernate configuration: "+properties);
+      configuration.addProperties(properties);
+    }
+  }
+
+  private void apply(List<Operation> operations, Configuration configuration, WireContext wireContext) {
+    if (operations!=null) {
+      for (Operation operation: operations) {
+        log.trace(operation.toString());
+        operation.apply(configuration, wireContext);
+      }
+    }
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    if (className!=null) {
+      try {
+        return ReflectUtil.loadClass(wireDefinition.getClassLoader(), className);
+      } catch (JbpmException e) {
+        throw new WireException("couldn't create hibernate configuration '"+className+"': "+e.getMessage(), e.getCause());
+      }
+    }
+    return Configuration.class;
+  }
+  
+  public void addCfgResource(String cfgResource) {
+    cfgOperations.add(new AddCfgResource(cfgResource));
+  }
+
+  public void addCfgFile(String cfgFile) {
+    cfgOperations.add(new AddCfgFile(cfgFile));
+  }
+
+  public void addCfgUrl(String cfgUrl) {
+    cfgOperations.add(new AddCfgUrl(cfgUrl));
+  }
+
+  public void addMappingResource(String mappingResource) {
+    cfgOperations.add(new AddMappingResource(mappingResource));
+  }
+
+  public void addMappingFile(String mappingFileName) {
+    cfgOperations.add(new AddMappingFile(mappingFileName));
+  }
+
+  public void addMappingClass(String mappingClassName) {
+    cfgOperations.add(new AddMappingClass(mappingClassName));
+  }
+
+  public void addMappingUrl(String mappingUrl) {
+    cfgOperations.add(new AddMappingUrl(mappingUrl));
+  }
+
+  public void addClassToCache(String className, String concurrencyStrategy) {
+    cfgCacheOperations.add(new SetCacheConcurrencyStrategy(className, concurrencyStrategy));
+  }
+
+  public void addCollectionToCache(String collectionName, String concurrencyStrategy) {
+    cfgCacheOperations.add(new SetCollectionCacheConcurrencyStrategy(collectionName, concurrencyStrategy));
+  }
+
+  public static class AddCfgResource implements Operation {
+    private static final long serialVersionUID = 1L;
+    String cfgResource;
+    public AddCfgResource(String cfgResource) {
+      this.cfgResource = cfgResource;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      configuration.configure(cfgResource);
+    }
+    public String toString() {
+      return "adding hibernate cfg resource "+cfgResource;
+    }
+  }
+
+  public static class AddCfgFile implements Operation {
+    private static final long serialVersionUID = 1L;
+    String cfgFileName;
+    public AddCfgFile(String cfgFileName) {
+      this.cfgFileName = cfgFileName;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      File file = new File(cfgFileName);
+      configuration.configure(file);
+    }
+    public String toString() {
+      return "adding hibernate cfg file "+cfgFileName;
+    }
+  }
+
+  public static class AddCfgUrl implements Operation {
+    private static final long serialVersionUID = 1L;
+    String cfgUrl;
+    public AddCfgUrl(String cfgUrl) {
+      this.cfgUrl = cfgUrl;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      try {
+        URL url = new URL(cfgUrl);
+        configuration.configure(url);
+      } catch (Exception e) {
+        throw new JbpmException("couldn't configure hibernate with url "+cfgUrl, e);
+      }
+    }
+    public String toString() {
+      return "adding hibernate cfg url "+cfgUrl;
+    }
+  }
+
+  public static class AddMappingResource implements Operation {
+    private static final long serialVersionUID = 1L;
+    String resource;
+    public AddMappingResource(String resource) {
+      this.resource = resource;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      configuration.addResource(resource, wireContext.getClassLoader());
+    }
+    public String toString() {
+      return "adding mapping resource "+resource+" to hibernate configuration";
+    }
+  }
+
+  public static class AddMappingFile implements Operation {
+    private static final long serialVersionUID = 1L;
+    String fileName;
+    public AddMappingFile(String fileName) {
+      this.fileName = fileName;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      configuration.addFile(fileName);
+    }
+    public String toString() {
+      return "adding hibernate mapping file "+fileName+" to configuration";
+    }
+  }
+
+  public static class AddMappingClass implements Operation {
+    private static final long serialVersionUID = 1L;
+    String className;
+    public AddMappingClass(String className) {
+      this.className = className;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      try {
+        Class<?> persistentClass = wireContext.getClassLoader().loadClass(className);
+        configuration.addClass(persistentClass);
+      } catch (Exception e) {
+        throw new JbpmException("couldn't add mapping for class "+className, e);
+      }
+    }
+    public String toString() {
+      return "adding persistent class "+className+" to hibernate configuration";
+    }
+  }
+
+  public static class AddMappingUrl implements Operation {
+    private static final long serialVersionUID = 1L;
+    String url;
+    public AddMappingUrl(String url) {
+      this.url = url;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      try {
+        configuration.addURL(new URL(url));
+      } catch (Exception e) {
+        throw new JbpmException("couldn't add hibernate mapping from URL "+url, e);
+      }
+    }
+  }
+
+  public static class SetCacheConcurrencyStrategy implements Operation {
+    private static final long serialVersionUID = 1L;
+    String className;
+    String concurrencyStrategy;
+    public SetCacheConcurrencyStrategy(String className, String concurrencyStrategy) {
+      this.className = className;
+      this.concurrencyStrategy = concurrencyStrategy;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      configuration.setCacheConcurrencyStrategy(className, concurrencyStrategy);
+    }
+    public String toString() {
+      return "setting cache concurrency strategy on class "+className+" to "+concurrencyStrategy+" on hibernate configuration";
+    }
+  }
+
+  public static class SetCollectionCacheConcurrencyStrategy implements Operation {
+    private static final long serialVersionUID = 1L;
+    String collection;
+    String concurrencyStrategy;
+    public SetCollectionCacheConcurrencyStrategy(String collection, String concurrencyStrategy) {
+      this.collection = collection;
+      this.concurrencyStrategy = concurrencyStrategy;
+    }
+    public void apply(Object target, WireContext wireContext) {
+      Configuration configuration = (Configuration) target;
+      configuration.setCollectionCacheConcurrencyStrategy(collection, concurrencyStrategy);
+    }
+    public String toString() {
+      return "setting cache concurrency strategy on collection "+collection+" to "+concurrencyStrategy+" on hibernate configuration";
+    }
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public String getClassName() {
+    return className;
+  }
+  public void setClassName(String className) {
+    this.className = className;
+  }
+  public PropertiesDescriptor getPropertiesDescriptor() {
+    return propertiesDescriptor;
+  }
+  public void setPropertiesDescriptor(PropertiesDescriptor propertiesDescriptor) {
+    this.propertiesDescriptor = propertiesDescriptor;
+  }
+  public String getNamingStrategyClassName() {
+    return namingStrategyClassName;
+  }
+  public void setNamingStrategyClassName(String namingStrategyClassName) {
+    this.namingStrategyClassName = namingStrategyClassName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateJobDbSessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateJobDbSessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateJobDbSessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.hibernate.HibernateJobDbSession;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateJobDbSessionDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  String sessionName;
+
+  public Object construct(WireContext wireContext) { 
+    return new HibernateJobDbSession();
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    // get the hibernate-session
+    Session session = null;
+    if (sessionName!=null) {
+      session = (Session) wireContext.get(sessionName);
+    } else {
+      session = wireContext.get(Session.class);
+    }
+    
+    if (session==null) {
+      throw new WireException("couldn't find hibernate-session "+(sessionName!=null ? "'"+sessionName+"'" : "by type ")+"to create pvm-db-session");
+    }
+    
+    // inject the session
+    ((HibernateJobDbSession)object).setSession(session);
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return HibernateJobDbSession.class;
+  }
+
+  public void setSessionName(String sessionName) {
+    this.sessionName = sessionName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernatePvmDbSessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernatePvmDbSessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernatePvmDbSessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.hibernate.HibernatePvmDbSession;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernatePvmDbSessionDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+  
+  String sessionName;
+
+  public Object construct(WireContext wireContext) { 
+    return new HibernatePvmDbSession();
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    // get the hibernate-session
+    Session session = null;
+    if (sessionName!=null) {
+      session = (Session) wireContext.get(sessionName);
+    } else {
+      session = wireContext.get(Session.class);
+    }
+    
+    if (session==null) {
+      throw new WireException("couldn't find hibernate-session "+(sessionName!=null ? "'"+sessionName+"'" : "by type ")+"to create pvm-db-session");
+    }
+    
+    // inject the session
+    ((HibernatePvmDbSession)object).setSession(session);
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return HibernatePvmDbSession.class;
+  }
+
+  public void setSessionName(String sessionName) {
+    this.sessionName = sessionName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.sql.Connection;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.impl.SessionImpl;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.tx.HibernateSessionResource;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(HibernateSessionDescriptor.class.getName());
+  
+  protected String factoryName;
+  protected boolean useCurrent = false;
+  protected boolean tx = true;
+  protected boolean close = true;
+  protected String standardTransactionName;
+  protected String connectionName;
+
+  public Object construct(WireContext wireContext) {
+    Environment environment = Environment.getCurrent();
+    if (environment==null) {
+      throw new WireException("no environment");
+    }
+
+    // get the hibernate-session-factory
+    SessionFactory sessionFactory = null;
+    if (factoryName!=null) {
+      sessionFactory = (SessionFactory) wireContext.get(factoryName);
+    } else {
+      sessionFactory = environment.get(SessionFactory.class);
+    }
+    if (sessionFactory==null) {
+      throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
+    }
+
+    // open the hibernate-session
+    Session session = null;
+    if (useCurrent) {
+      log.debug("getting current hibernate session");
+      session = sessionFactory.getCurrentSession();
+      
+    } else if (connectionName!=null) {
+      Connection connection = (Connection) wireContext.get(connectionName);
+      log.debug("creating hibernate session with connection "+connection);
+      session = sessionFactory.openSession(connection);
+
+    } else {
+      log.debug("creating hibernate session");
+      session = sessionFactory.openSession();
+    }
+    
+    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+    if (standardTransaction!=null) {
+      HibernateSessionResource hibernateSessionResource = new HibernateSessionResource(session);
+      standardTransaction.enlistResource(hibernateSessionResource);
+    }
+
+    return session;
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return SessionImpl.class;
+  }
+
+  public void setFactoryName(String factoryName) {
+    this.factoryName = factoryName;
+  }
+  public void setTx(boolean tx) {
+    this.tx = tx;
+  }
+  public void setStandardTransactionName(String standardTransactionName) {
+    this.standardTransactionName = standardTransactionName;
+  }
+  public void setConnectionName(String connectionName) {
+    this.connectionName = connectionName;
+  }
+  public void setUseCurrent(boolean useCurrent) {
+    this.useCurrent = useCurrent;
+  }
+  public void setClose(boolean close) {
+    this.close = close;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionFactoryDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
+import java.net.URL;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionFactoryDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(HibernateSessionFactoryDescriptor.class.getName());
+  
+  String configurationName;
+  Descriptor configurationDescriptor;
+  
+  public Object construct(WireContext wireContext) {
+    Configuration configuration = null;
+
+    if (configurationName!=null) {
+      configuration = (Configuration) wireContext.get(configurationName); 
+
+    } else if (configurationDescriptor!=null) {
+      configuration = (Configuration) wireContext.create(configurationDescriptor, false);
+      
+    } else {
+      configuration = wireContext.get(Configuration.class);
+    }
+    
+    if (configuration==null) {
+      throw new WireException("couldn't find configuration");
+    }
+
+    SessionFactory sessionFactory = configuration.buildSessionFactory();
+    
+    wireContext.addListener(new SessionFactoryCloser(sessionFactory));
+
+    return sessionFactory;
+  }
+  
+  public static class SessionFactoryCloser implements Listener {
+    SessionFactory sessionFactory;
+    public SessionFactoryCloser(SessionFactory sessionFactory) {
+      this.sessionFactory = sessionFactory;
+    }
+    public void event(Object source, String eventName, Object info) {
+      if (WireContext.EVENT_CLOSE.equals(eventName)) {
+        log.trace("closing hibernate session factory");
+        sessionFactory.close();
+      }
+    }
+  }
+
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return SessionFactory.class;
+  }
+
+  public void setConfigurationName(String configurationName) {
+    this.configurationName = configurationName;
+  }
+  public void setConfigurationDescriptor(Descriptor configurationDescriptor) {
+    this.configurationDescriptor = configurationDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.hibernate.HibernateTaskDbSession;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateTaskDbSessionDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  private String sessionName;
+
+  public Object construct(WireContext wireContext) {
+    return new HibernateTaskDbSession();
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    // get the hibernate-session
+    Session session = null;
+    if (sessionName != null) {
+      session = (Session) wireContext.get(sessionName);
+    } else {
+      session = wireContext.get(Session.class);
+    }
+
+    if (session == null) {
+      throw new WireException("couldn't find hibernate-session "
+          + (sessionName != null ? "'" + sessionName + "'" : "by type ")
+          + "to create pvm-db-session");
+    }
+
+    // inject the session
+    ((HibernateTaskDbSession) object).setSession(session);
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return HibernateTaskDbSession.class;
+  }
+
+  public void setSessionName(String sessionName) {
+    this.sessionName = sessionName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.identity.impl.IdentitySessionImpl;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String realmName;
+
+  public Object construct(WireContext wireContext) {
+    IdentitySessionFactory identitySessionFactory = Environment.getFromCurrent(IdentitySessionFactory.class);
+    return new IdentitySessionImpl(identitySessionFactory.createIdentitySession(realmName));
+  }
+
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return org.jbpm.pvm.internal.identity.spi.IdentitySession.class;
+  }
+  
+  public void setRealmName(String realmName) {
+    this.realmName = realmName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionFactoryDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionFactoryDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IdentitySessionFactoryDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jboss.identity.idm.impl.api.IdentitySessionFactoryImpl;
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentitySessionFactoryDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected String resource = "jbpm.identity.cfg.xml";
+
+  public Object construct(WireContext wireContext) {
+    try {
+      return new IdentitySessionFactoryImpl(resource);
+    } catch (Exception e) {
+      throw new JbpmException("couldn't instanatiate identity session factory: "+e.getMessage(), e);
+    }
+  }
+
+  public void setResource(String resource) {
+    this.resource = resource;
+  }
+
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return IdentitySessionFactoryImpl.class;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * <p>This {@link Descriptor} specifies an Integer.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class IntegerDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Long longVal;
+
+  public IntegerDescriptor() {
+  }
+
+  public IntegerDescriptor(Integer value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    if (longVal==null) {
+      return null;
+    }
+    return new Integer(longVal.intValue());
+  }
+
+  public void setValue(Integer value) {
+    if (value==null) {
+      longVal = null;
+    } else {
+      longVal = new Long(value);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JndiDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JndiDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  String jndiName;
+  
+  protected JndiDescriptor() {
+  }
+
+  public JndiDescriptor(String jndiName) {
+    this.jndiName = jndiName;
+  }
+
+  public Object construct(WireContext wireContext) {
+    try {
+      InitialContext initialContext = new InitialContext();
+      return initialContext.lookup(jndiName);
+    } catch (NamingException e) {
+      throw new WireException("couldn't lookup '"+jndiName+"' from the initial context");
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Pascal Verdage
+ * 
+ * Descriptor for the JobExecutor.
+ * If it is automatically started, a listener is created to stop it when
+ * the environementFactory is closed
+ * @see org.jbpm.env.EnvironmentFactory
+ * @see org.jbpm.pvm.internal.wire.binding.JobExecutorBinding
+ */
+public class JobExecutorDescriptor extends ObjectDescriptor {
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(JobExecutorDescriptor.class.getName());
+
+  
+  private boolean autoStart = false;
+
+  public JobExecutorDescriptor() {
+    super(JobExecutor.class.getName());
+  }
+
+  public Object construct(WireContext wireContext) {
+    JobExecutor jobExecutor = (JobExecutor) super.construct(wireContext);
+    if (autoStart) {
+      wireContext.addListener(new JobExecutorStopper(jobExecutor));
+    }
+    return jobExecutor;
+  }
+
+  public void setAutoStart(boolean autoStart) {
+    this.autoStart = autoStart;
+  }
+  
+  public static class JobExecutorStopper implements Listener {
+    JobExecutor jobExecutor;
+    public JobExecutorStopper(JobExecutor jobExecutor) {
+      this.jobExecutor = jobExecutor;
+    }
+    public void event(Object source, String eventName, Object info) {
+      if (WireContext.EVENT_CLOSE.equals(eventName)) {
+        log.trace("stopping jobExecutor");
+        // wait to prevent from calling stop before the run method (activation)
+        // has been called (after a system context switching)
+        //TODO: do not wait
+        try {
+          Thread.sleep(200);
+        } catch (InterruptedException e) {
+          e.printStackTrace();
+          throw new JbpmException("exception while stopping JobExecutor");
+        }
+        jobExecutor.stop(true);
+      }
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ListDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ListDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ListDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,29 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+ *
+ * <p>This {@link Descriptor} creates a {@link List}.</p>
+ *
+ * <p>If no specific implementation for the {@link List} is specified, an {@link ArrayList} will be used.
+ *
+ * <p>Entries can be added during the list initialization.
+ * The list of entries is specified with {@link #setValueDescriptors(List)}.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class ListDescriptor extends CollectionDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public ListDescriptor() {
+    super(ArrayList.class.getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class LongDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Long longVal;
+
+  public LongDescriptor() {
+  }
+
+  public LongDescriptor(Long value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    return longVal;
+  }
+
+  public void setValue(Long value) {
+    longVal = value;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ *
+ * <p>This {@link Descriptor} creates a {@link Map}.</p>
+ *
+ * <p>If no specific implementation for the {@link Map} is specified, a {@link HashMap} will be used.</p>
+ *
+ * <p>Entries can be added during the map initialization. The list of entries (key, value) to add must be specified with two operations:
+ * <ol>
+ * <li>{@link #setKeyDescriptors(List)} sets the list of the keys to generate.</li>
+ * <li>{@link #setValueDescriptors(List)} sets the list of value associated with these keys.</li>
+ * </ol>
+ * The two lists must be in the same order
+ * (the n-th element of the key list will be associated with the n-th element of the value list).</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class MapDescriptor extends CollectionDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  List<Descriptor> keyDescriptors;
+
+  public MapDescriptor() {
+    super(HashMap.class.getName());
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    Map<Object,Object> map = (Map<Object,Object>) object;
+    try {
+      if (keyDescriptors!=null) {
+        for (int i=0; i<keyDescriptors.size(); i++) {
+          Descriptor keyDescriptor = keyDescriptors.get(i);
+          Descriptor valueDescriptor = valueDescriptors.get(i);
+          Object key = wireContext.create(keyDescriptor, true);
+          Object value = wireContext.create(valueDescriptor, true);
+          map.put(key, value);
+        }
+      }
+    } catch (WireException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
+    }
+  }
+  
+  
+
+  public List<Descriptor> getKeyDescriptors() {
+    return keyDescriptors;
+  }
+
+  public void setKeyDescriptors(List<Descriptor> keyDescriptors) {
+    this.keyDescriptors = keyDescriptors;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * <p>This {@link Descriptor} creates a <code>null</code> object.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class NullDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext factory) {
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,503 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ArrayUtil;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.operation.FieldOperation;
+import org.jbpm.pvm.internal.wire.operation.Operation;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+
+/**
+ * <p>This {@link Descriptor} creates and initializes an object.
+ * Objects can be instantiated from a constructor or from a method invocation.</p>
+ *
+ * <p>The way to create an object is specified one of these methods (see <a href='#create'>creating objects</a>):
+ * <ul>
+ * <li>className ({@link #setClassName(String)})</li>
+ * <li>factoryObjectName ({@link #setFactoryObjectName(String)})</li>
+ * <li>factoryDescriptor ({@link #setFactoryDescriptor(Descriptor)})</li>
+ * </ul>
+ * Only one of these methods can be used.
+ * </p>
+ *
+ * <h3 id='create'>Creating objects</h3>
+ * <h4>Creating object from a constructor</h4>
+ *
+ * <p>This method is used when <code>{@link #getClassName()}!=null && {@link #getMethodName()}==null</code>.</p>
+ *
+ * <p>The {@link #construct(WireContext)} method creates a new object
+ * from a constructor matching the given arguments
+ * (specified with {@link #setArgDescriptors(List)}).</p>
+ *
+ *
+ * <h4>Creating an object from a method invocation</h4>
+ *
+ * <p>The name of the method to call is specified by the method attribute.</p>
+ * <ul>
+ * <li>If the method is <i>static</i>, the related class is {@link #getClassName()}.</li>
+ * <li>If the method is an object method, the object to which the method will be applied is defined by:
+ *  <ul>
+ *    <li>If <code>{@link #getFactoryObjectName()}!=null</code>: the object with the name factoryObjectName will be fetched from the context.</li>
+ *    <li>if <code>{@link #getFactoryDescriptor()}!=null</code>: the object will be created from the factory descriptor.</li>
+ *  </ul>
+ * </li>
+ * </ul>
+ * <p>The object returned by {@link #construct(WireContext)} is the object returned by the method invocation.</p>
+ *
+ *
+ * <h3>Initializing Objects</h3>
+ * <h4>Auto Wiring</h4>
+ * <p>If the auto wiring is enabled for the object (<code>{@link #isAutoWireEnabled()}==true</code>),
+ * the WireContext will try to look for objects with the same name as the fields in the class.
+ * If it finds an object with that name, and if it is assignable to the field's type, it is automatically injected,
+ * without the need for explicit {@link FieldOperation} that specifies the injection in the wiring xml.</p>
+ * <p>If the auto wiring is enabled and the WireContext finds an object with the name of a field, but not assignable to this field,
+ * a warning message is generated.</p>
+ *
+ * <p>Auto-wiring is disabled by default.</p>
+ *
+ * <h4>Operations</h4>
+ * <p>Field injection or property injection are done after the auto-wiring. For more information, see {@link Operation}.</p>
+ *
+ * <p>If a field was injected by auto-wiring, its value can be overridden by specifying
+ *  a {@link FieldOperation} or {@link PropertyOperation} operation.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ */
+public class ObjectDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(ObjectDescriptor.class.getName());
+
+  String className = null;
+
+  /** specifies the object reference on which the method will be invoked.
+   * Either className, objectName or a descriptor has to be specified.
+   *
+   * TODO check if this member can be replaced by a RefDescriptor in the factoryDescriptor member.
+   *
+   * */
+  String factoryObjectName = null;
+
+  /** specifies the object on which to invoke the method.
+   * Either className, objectName or a descriptor has to be specified. */
+  Descriptor factoryDescriptor = null;
+
+  String methodName = null;
+
+  /** map to db as a component */
+  List<ArgDescriptor> argDescriptors = null;
+  /** list of operations to perform during initialization. */
+  List<Operation> operations = null;
+
+  /** True if autowiring is enabled.  */
+  boolean isAutoWireEnabled = false;
+  
+  public ObjectDescriptor() {
+  }
+
+  public ObjectDescriptor(String className) {
+    this.className = className;
+  }
+
+  public ObjectDescriptor(Class<?> clazz) {
+    this.className = clazz.getName();
+  }
+
+  /**
+   * This method constructs a new Object from the ObjectDefinition.
+   * This object will be created from a class constructor or from a method invocation.
+   * @throws WireException one of the following exception occurred:
+   * <ul><li>if the object cannot be created (unable to load the specified class or no matching constructor found)</li>
+   * <li>if the invocation of the specified method failed</li>
+   * </ul>
+   * @see ObjectDescriptor
+   */
+  public Object construct(WireContext wireContext) {
+    Object object = null;
+    Class<?> clazz = null;
+
+    if (className!=null) {
+      try {
+        ClassLoader classLoader = wireContext.getClassLoader();
+        clazz = ReflectUtil.loadClass(classLoader, className);
+      } catch (Exception e) {
+        throw new WireException("couldn't create object"+(name!=null ? " '"+name+"'" : "")+": "+e.getMessage(), e);
+      }
+
+      if (methodName==null) {
+        // plain instantiation
+        try {
+          Object[] args = getArgs(wireContext, argDescriptors);
+          Constructor<?> constructor = ReflectUtil.findConstructor(clazz, argDescriptors, args);
+          if (constructor==null) {
+            throw new WireException("couldn't find constructor "+clazz.getName()+" with args "+ArrayUtil.toString(args));
+          }
+          object = constructor.newInstance(args);
+        } catch (WireException e) {
+          throw e;
+        } catch (Exception e) {
+          throw new WireException("couldn't create object '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
+        }
+      }
+
+    } else if (factoryObjectName!=null) {
+      // referenced factory object
+      object = wireContext.get(factoryObjectName, false);
+      if (object==null) {
+        throw new WireException("can't invoke method '"+methodName+"' on null, resulted from fetching object '"+factoryObjectName+"' from this wiring environment");
+      }
+
+    } else if (factoryDescriptor!=null) {
+      // factory object descriptor
+      object = wireContext.create(factoryDescriptor, false);
+      if (object==null) {
+        throw new WireException("created factory object is null, can't invoke method '"+methodName+"' on it");
+      }
+    }
+
+    if (methodName!=null) {
+      // method invocation on object or static method invocation in case object is null
+      if (object!=null) {
+        clazz = object.getClass();
+      }
+      try {
+        Object[] args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+        Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
+        if (method==null) {
+          // throw exception but first, generate decent message
+          throw new WireException("method "+ReflectUtil.getSignature(methodName, argDescriptors, args)+" is not available on "+
+              (object!=null ? "object "+object+" ("+clazz.getName()+")" : "class "+clazz.getName()));
+        }
+        if (object == null && (!Modifier.isStatic(method.getModifiers()))) {
+          // A non static method is invoked on a null object
+          throw new WireException("method "+ clazz.getName() + "." + ReflectUtil.getSignature(methodName, argDescriptors, args)+" is not static. It cannot be called on a null object.");
+        }
+        object = ReflectUtil.invoke(method, object, args);
+
+      } catch (WireException e) {
+        throw e;
+      } catch (Exception e) {
+        throw new WireException("couldn't invoke factory method "+methodName+": "+e.getMessage(), e);
+      }
+    }
+
+    return object;
+  }
+
+  /**
+   * Initializes the specified object.
+   * If auto-wiring was set to <code>true</code>, auto-wiring is performed (see {@link #autoWire(Object, WireContext)}). Fields and properties injections are then performed.
+   *
+   */
+  public void initialize(Object object, WireContext wireContext) {
+    try {
+      // specified operations takes precedence over auto-wiring.
+      // e.g. in case there is a collision between
+      // a field or property injection and an autowired value,
+      // the field or property injections should win.
+      // That is why autowiring is done first
+      if (isAutoWireEnabled) {
+        autoWire(object, wireContext);
+      }
+      if (operations!=null) {
+        for(Operation operation: operations) {
+          operation.apply(object, wireContext);
+        }
+      }
+    } catch (Exception e) {
+      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
+    }
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    if (className!=null) {
+      try {
+        return ReflectUtil.loadClass(wireDefinition.getClassLoader(), className);
+      } catch (JbpmException e) {
+        throw new WireException("couldn't get type of '"+(name!=null ? name : className)+"': "+e.getMessage(), e.getCause());
+      }
+    }
+    
+    Descriptor descriptor = null;
+    if (factoryDescriptor!=null) {
+      descriptor = factoryDescriptor;
+    } else if (factoryObjectName!=null) {
+      descriptor = wireDefinition.getDescriptor(factoryObjectName);
+    }
+
+    if (descriptor!=null) {
+      Class<?> factoryClass = descriptor.getType(wireDefinition);
+      if (factoryClass!=null) {
+        Method method = ReflectUtil.findMethod(factoryClass, methodName, argDescriptors, null);
+        if (method!=null) {
+          return method.getReturnType(); 
+        }
+      }
+    }
+
+    return null;
+  }
+  
+  /**
+   * Auto wire object present in the context and the specified object's fields.
+   * @param object object on which auto-wiring is performed.
+   * @param wireContext context in which the wiring objects are searched.
+   */
+  protected void autoWire(Object object, WireContext wireContext) {
+    Class<?> clazz = object.getClass();
+    while (clazz!=null) {
+      Field[] declaredFields = clazz.getDeclaredFields();
+      if (declaredFields!=null) {
+        for (Field field: declaredFields) {
+          if (! Modifier.isStatic(field.getModifiers())) {
+            String fieldName = field.getName();
+
+            Object autoWireValue = null;
+            if ("environment".equals(fieldName)) {
+              autoWireValue = Environment.getCurrent();
+
+            } else if ( ("context".equals(fieldName))
+                || ("wireContext".equals(fieldName))
+            ) {
+              autoWireValue = wireContext;
+
+            } else if (wireContext.has(fieldName)) {
+              autoWireValue = wireContext.get(fieldName);
+
+            } else {
+              autoWireValue = wireContext.get(field.getType());  
+            }
+            // if auto wire value has not been found in current context, 
+            // search in environment
+            if (autoWireValue == null) {
+              Environment currentEnvironment = Environment.getCurrent();
+              if (currentEnvironment != null) {
+                autoWireValue = currentEnvironment.get(fieldName); 
+                if (autoWireValue == null) {
+                  autoWireValue = currentEnvironment.get(field.getType());
+                }
+              }
+            }
+            
+            if (autoWireValue!=null) {
+              try {
+                log.debug("auto wiring field "+fieldName+" in "+name);
+                ReflectUtil.set(field, object, autoWireValue);
+              } catch (JbpmException e) {
+                if(e.getCause() instanceof IllegalArgumentException) {
+                  log.info("WARNING: couldn't auto wire "+fieldName+" (of type "+field.getType().getName()+") " +
+                      "with value "+autoWireValue + " (of type "+autoWireValue.getClass().getName()+")");
+                } else {
+                  log.info("WARNING: couldn't auto wire "+fieldName+" with value "+autoWireValue);
+                }
+              }
+            }
+          }
+        }
+      }
+      clazz = clazz.getSuperclass();
+    }
+  }
+
+  /**
+   * Creates a list of arguments (objects) from a list of argument descriptors.
+   * @param wireContext context used to create objects.
+   * @param argDescriptors list of argument descriptors.
+   * @return a list of object created from the descriptors.
+   * @throws Exception
+   */
+  public static Object[] getArgs(WireContext wireContext, List<ArgDescriptor> argDescriptors) throws Exception {
+    Object[] args = null;
+    if (argDescriptors!=null) {
+      args = new Object[argDescriptors.size()];
+      for(int i=0; i<argDescriptors.size(); i++) {
+        ArgDescriptor argDescriptor = argDescriptors.get(i);
+        Object arg;
+        try {
+          arg = wireContext.create(argDescriptor.getDescriptor(), true);
+          args[i] = arg;
+        } catch (RuntimeException e) {
+          // i have made sure that the runtime exception is caught everywhere the getArgs method
+          // is used so that a better descriptive exception can be rethrown
+          throw new Exception("couldn't create argument "+i+": "+e.getMessage(), e);
+        }
+      }
+    }
+    return args;
+  }
+
+  /**
+   * Adds a argument descriptor to the list of arguments descriptor to used when invoking the specified method.
+   * @param argDescriptor argument descriptor to add.
+   */
+  public void addArgDescriptor(ArgDescriptor argDescriptor) {
+    if (argDescriptors==null) {
+      argDescriptors = new ArrayList<ArgDescriptor>();
+    }
+    argDescriptors.add(argDescriptor);
+  }
+
+  /**
+   * Adds an operation to perform during initialization.
+   * @param operation operation to add.
+   */
+  public void addOperation(Operation operation) {
+    if (operations==null) {
+      operations = new ArrayList<Operation>();
+    }
+    operations.add(operation);
+  }
+  
+  /** convenience method to add a type based field injection */
+  public void addTypedInjection(String fieldName, Class<?> type) {
+    addInjection(fieldName, new EnvDescriptor(type));
+  }
+
+  /** add an injection based on a descriptor */
+  public void addInjection(String fieldName, Descriptor descriptor) {
+    FieldOperation injectionOperation = new FieldOperation();
+    injectionOperation.setFieldName(fieldName);
+    injectionOperation.setDescriptor(descriptor);
+    addOperation(injectionOperation);
+  }
+
+  /**
+   * Gets the class name of the object to create.
+   * This name is defined only when creating objects from a constructor or when invoking static methods.
+   * @return the name of the class of the object to create.
+   */
+  public String getClassName() {
+    return className;
+  }
+
+  /**
+   * Sets class name of the object to create.
+   * This name is defined only when creating objects from a constructor or when invoking static methods.
+   * If this name is set, the factoryObjectName and factoryDescriptor should not be set.
+   * @see #setFactoryDescriptor(Descriptor)
+   * @see #setFactoryObjectName(String)
+   * @param className name of the class to use.
+   */
+  public void setClassName(String className) {
+    this.className = className;
+  }
+
+  /**
+   * Gets the list of descriptors to use to create method arguments.
+   * @return list of descriptors to use to create method arguments.
+   */
+  public List<ArgDescriptor> getArgDescriptors() {
+    return argDescriptors;
+  }
+
+  /**
+   * Sets the list of descriptors to use to create method arguments.
+   * @param argDescriptors list of descriptors to use to create method arguments.
+   */
+  public void setArgDescriptors(List<ArgDescriptor> argDescriptors) {
+    this.argDescriptors = argDescriptors;
+  }
+
+  /**
+   * Gets the list of operations to perform during initialization.
+   * @return list of operations to perform during initialization.
+   */
+  public List<Operation> getOperations() {
+    return operations;
+  }
+
+  /**
+   * Sets the list of operations to perform during initialization.
+   * @param operations list of operations to perform during initialization.
+   */
+  public void setOperations(List<Operation> operations) {
+    this.operations = operations;
+  }
+
+  /**
+   * Gets the Descriptor from which the object should be created.
+   * @return the Descriptor from which the object should be created.
+   */
+  public Descriptor getFactoryDescriptor() {
+    return factoryDescriptor;
+  }
+
+  /**
+   * Sets the Descriptor from which the object should be created.
+   * If this Descriptor is set, the className and factoryObjectName should not be set.
+   * @see #setClassName(String)
+   * @see #setFactoryObjectName(String)
+   * @param factoryDescriptor the Descriptor from which the object should be created.
+   */
+  public void setFactoryDescriptor(Descriptor factoryDescriptor) {
+    this.factoryDescriptor = factoryDescriptor;
+  }
+
+
+  /**
+   * Gets the name of the object to get from the WireContext.
+   * @return name of the object to get from the WireContext.
+   */
+  public String getFactoryObjectName() {
+    return factoryObjectName;
+  }
+
+  /**
+   * Sets name of the object to get from the WireContext.
+   * If this name is set, the className and factoryDescriptor should not be set.
+   * @see #setClassName(String)
+   * @see #setFactoryDescriptor(Descriptor)
+   * @param factoryObjectName name of the object to get from the WireContext.
+   */
+  public void setFactoryObjectName(String factoryObjectName) {
+    this.factoryObjectName = factoryObjectName;
+  }
+
+  /**
+   * Gets the name of the method to invoke.
+   * @return name of the method to invoke.
+   */
+  public String getMethodName() {
+    return methodName;
+  }
+
+  /**
+   * Sets the name of the method to invoke.
+   * @param methodName name of the method to invoke.
+   */
+  public void setMethodName(String methodName) {
+    this.methodName = methodName;
+  }
+
+  /**
+   * Checks if auto-wiring is enabled
+   * @return <code>true</code> if auto-wiring is enabled.
+   */
+  public boolean isAutoWireEnabled() {
+    return isAutoWireEnabled;
+  }
+
+  /**
+   * Enables/Disables auto wiring mode.
+   * @param isAutoWireEnabled <code>true</code> to enable auto-wiring.
+   */
+  public void setAutoWireEnabled(boolean isAutoWireEnabled) {
+    this.isAutoWireEnabled = isAutoWireEnabled;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PropertiesDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PropertiesDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/PropertiesDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PropertiesDescriptor extends MapDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String url;
+  protected String file;
+  protected String resource;
+  protected boolean isXml;
+  
+  public PropertiesDescriptor() {
+    className = Properties.class.getName(); 
+  }
+
+  public Object construct(WireContext wireContext) {
+    return new Properties();
+  }
+   
+  public void initialize(Object object, WireContext wireContext) {
+    String description = null;
+    try {
+      if (url!=null) {
+        description = "url "+url;
+        InputStream inputStream = new URL(url).openStream();
+        load(object, inputStream);
+      }
+      
+      if (file!=null) {
+        description = "file "+file;
+        InputStream inputStream = new FileInputStream(file);
+        load(object, inputStream);
+      }
+      
+      if (resource!=null) {
+        description = "resource "+resource;
+        InputStream inputStream = wireContext.getClassLoader().getResourceAsStream(resource);
+        if (inputStream==null) {
+          throw new RuntimeException("resource "+resource+" doesn't exist");
+        }
+        load(object, inputStream);
+      }
+      
+    } catch (Exception e) {
+      throw new WireException("couldn't read properties from "+description, e);
+    }
+    
+    super.initialize(object, wireContext);
+  }
+  
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return Properties.class;
+  }
+
+  protected void load(Object object, InputStream inputStream) throws Exception {
+    Properties properties = (Properties) object;
+    if (isXml) {
+      properties.loadFromXML(inputStream);
+    } else {
+      properties.load(inputStream);
+    }
+  }
+
+  public String getFile() {
+    return file;
+  }
+  public void setFile(String file) {
+    this.file = file;
+  }
+  public String getResource() {
+    return resource;
+  }
+  public void setResource(String resource) {
+    this.resource = resource;
+  }
+  public String getUrl() {
+    return url;
+  }
+  public void setUrl(String url) {
+    this.url = url;
+  }
+  public boolean isXml() {
+    return isXml;
+  }
+  public void setXml(boolean isXml) {
+    this.isXml = isXml;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ProvidedObjectDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ProvidedObjectDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ProvidedObjectDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProvidedObjectDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+
+  Object providedObject;
+  boolean exposeType = false;
+  
+  public ProvidedObjectDescriptor() {
+  }
+
+  public ProvidedObjectDescriptor(Object providedObject) {
+    this.providedObject = providedObject;
+  }
+
+  public ProvidedObjectDescriptor(Object providedObject, boolean exposeType) {
+    this.providedObject = providedObject;
+    this.exposeType = exposeType;
+  }
+
+  public Object construct(WireContext wireContext) {
+    return providedObject;
+  }
+
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    if ( (!exposeType)
+         || (providedObject==null)
+       ) {
+      return null;
+    }
+    return providedObject.getClass();
+  }
+
+  public Object getProvidedObject() {
+    return providedObject;
+  }
+  public void setProvidedObject(Object providedObject) {
+    this.providedObject = providedObject;
+  }
+  public boolean isExposeType() {
+    return exposeType;
+  }
+  public void setExposeType(boolean exposeType) {
+    this.exposeType = exposeType;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * <p>This {@link Descriptor} specifies a reference to an object.
+ * The object referenced should be declared somewhere else in the wireContext.</p>
+ *
+ * <p>The constructed object is the referenced object.</p>
+ *
+ * <p>The {@link #init} field can be used to force initialization of the referenced object.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class ReferenceDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  String text = null;
+
+  // TODO add a refExpression that is evaluated with el
+  // the base referenced descriptor always should have delayedInitialization = false;
+
+  public ReferenceDescriptor() {
+  }
+
+  public ReferenceDescriptor(String objectName) {
+    setValue(objectName);
+  }
+
+  public Object construct(WireContext wireContext) {
+    return wireContext.get(text, isDelayedInitializationAllowed());
+  }
+
+  public boolean isDelayedInitializationAllowed() {
+    return (init == INIT_EAGER || init == INIT_LAZY);
+  }
+
+  public void setValue(String objectName) {
+    this.text = objectName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.svc.RetryInterceptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class RetryInterceptorDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+  
+  RetryInterceptor retryInterceptor = new RetryInterceptor();
+
+  public Object construct(WireContext wireContext) {
+    return retryInterceptor;
+  }
+
+  public void setRetries(int retries) {
+    retryInterceptor.setRetries(retries);
+  }
+  public void setDelay(long delay) {
+    retryInterceptor.setDelay(delay);
+  }
+  public void setDelayFactor(long delayFactor) {
+    retryInterceptor.setDelayFactor(delayFactor);
+  }
+  
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SeamHibernateSessionDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SeamHibernateSessionDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SeamHibernateSessionDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SeamHibernateSessionDescriptor extends AbstractDescriptor {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String componentName = "hibernateSession";
+
+  public Object construct(WireContext wireContext) {
+    /*
+    return (Session) Component.getInstance(componentName, true);
+    */
+    return null;
+  }
+
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return Session.class;
+  }
+
+  public void setComponentName(String componentName) {
+    this.componentName = componentName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SetDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SetDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/SetDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+/**
+*
+* <p>This {@link Descriptor} creates a {@link Set}.</p>
+*
+* <p>If no specific implementation for the {@link Set} is specified, a {@link HashSet} will be used.
+*
+* <p>Entries can be added during the set initialization.
+* The list of entries is specified with {@link #setValueDescriptors(List)}.</p>
+*
+* @author Tom Baeyens
+* @author Guillaume Porcher (documentation)
+*
+* @see Descriptor
+*/
+public class SetDescriptor extends CollectionDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public SetDescriptor() {
+    super(HashSet.class.getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ShortDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * <p>This {@link Descriptor} creates a Short.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class ShortDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  protected Long longVal;
+
+  public ShortDescriptor() {
+  }
+
+  public ShortDescriptor(Short value) {
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    if (longVal==null) {
+      return null;
+    }
+    return new Short(longVal.shortValue());
+  }
+
+  public void setValue(Short value) {
+    if (value==null) {
+      longVal = null;
+    } else {
+      longVal = new Long(value);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/StringDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,41 @@
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ *
+ * <p>This {@link Descriptor} creates a String.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ * @see Descriptor
+ */
+public class StringDescriptor extends AbstractDescriptor implements Descriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  String text;
+
+  public StringDescriptor() {
+  }
+
+  public StringDescriptor(String value) {
+    setValue(value);
+  }
+
+  public StringDescriptor(String name, String value) {
+    setName(name);
+    setValue(value);
+  }
+
+  public Object construct(WireContext factory) {
+    return text;
+  }
+
+  public void setValue(String value) {
+    this.text = value;
+  }
+}
+

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TransactionRefDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TransactionRefDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TransactionRefDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionRefDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext wireContext) {
+    return Environment.getCurrent().get(Transaction.class);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TrueDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TrueDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TrueDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TrueDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object construct(WireContext wireContext) {
+    return Boolean.TRUE;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TypesDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TypesDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/TypesDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.type.DefaultTypeSet;
+import org.jbpm.pvm.internal.type.TypeMapping;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TypesDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  DefaultTypeSet defaultTypeSet = new DefaultTypeSet();
+  
+  public Object construct(WireContext wireContext) {
+    return defaultTypeSet;
+  }
+  
+  public Class< ? > getType(WireDefinition wireDefinition) {
+    return DefaultTypeSet.class;
+  }
+
+  public void addTypeMapping(TypeMapping typeMapping) {
+    defaultTypeSet.addTypeMapping(typeMapping);
+  }
+  
+  public DefaultTypeSet getDefaultTypeSet() {
+    return defaultTypeSet;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/UrlDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/UrlDescriptor.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/UrlDescriptor.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import java.net.URL;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class UrlDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+  
+  String text = null;
+
+  public Object construct(WireContext wireContext) {
+    try {
+      return new URL(text);
+    } catch (Exception e) {
+      throw new WireException("couldn't create URL for text "+text, e);
+    }
+  }
+
+  public void setUrlText(String text) {
+    this.text = text;
+  }
+  
+  public void setUrl(URL url) {
+    this.text = url.toString();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.operation;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AbstractOperation implements Operation {
+
+  protected long dbid;
+  protected int dbversion;
+  
+  public long getDbid() {
+    return dbid;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,74 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import org.jbpm.env.Transaction;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.tx.StandardResource;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * enlists this {@link StandardResource} with the current {@link Transaction}.
+ *
+ * <p>This {@link Operation} specifies that the object on which this operation is applied
+ * should be added as a {@link StandardResource} to the specified {@link Transaction}.
+ * </p>
+ * 
+ * <p>property transactionName refers to the objectName of the {@link Transaction}
+ * and it may not be null.
+ * </p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnlistOperation implements Operation {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(EnlistOperation.class.getName());
+
+  String transactionName = null;
+
+  /**
+   * @throws WireException if this operation is applied on an object which is not a resource
+   * or if the specified transaction cannot be found.
+   */
+  public void apply(Object target, WireContext wireContext) {
+    if (! (target instanceof StandardResource)) {
+      throw new WireException("operation enlist can only be applied on objects that implement "+StandardResource.class.getName()+": "+target+(target!=null ? " ("+target.getClass().getName()+")" : ""));
+    }
+
+    Object object = null;
+    if (transactionName!=null) {
+      object = wireContext.get(transactionName);
+    } else {
+      object = wireContext.get(Transaction.class);
+    }
+
+    if ( (object==null)
+         || (! (object instanceof StandardTransaction))
+       ) {
+      throw new WireException("couldn't find "+StandardTransaction.class.getName()+" "+(transactionName!=null ? "'"+transactionName+"'" : "by type")+" to enlist resource "+target);
+    }
+
+    StandardTransaction standardTransaction = (StandardTransaction) object;
+
+    log.trace("enlisting resource "+target+" with transaction");
+    standardTransaction.enlistResource((StandardResource)target);
+  }
+
+  /**
+   * Gets the name of the transaction to which the object should be added.
+   */
+  public String getTransactionName() {
+    return transactionName;
+  }
+
+  /**
+   * Sets the name of the transaction to which the object should be added.
+   * @param transactionName
+   */
+  public void setTransactionName(String transactionName) {
+    this.transactionName = transactionName;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,83 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.lang.reflect.Field;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * injects another object into a field.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ */
+public class FieldOperation extends AbstractOperation {
+
+  private static final long serialVersionUID = 1L;
+
+  String fieldName = null;
+  Descriptor descriptor = null;
+
+  transient Field field = null;
+
+  public FieldOperation() {
+  }
+
+  public void apply(Object target, WireContext wireContext) {
+    if (target!=null) {
+
+      // Get field
+      synchronized(this) {
+        if (field==null) {
+          Class<?> clazz = target.getClass();
+          field = ReflectUtil.getField(clazz, fieldName);
+        }
+      }
+
+      // Create value
+      Object value = wireContext.create(descriptor, true);
+      // Set the field value
+      try {
+        ReflectUtil.set(field, target, value);
+      } catch (Exception e) {
+        throw new WireException("couldn't set "+fieldName+" to "+value, e);
+      }
+    }
+  }
+
+  /**
+   * Gets the name of the field that should be updated by this operation.
+   */
+  public String getFieldName() {
+    return fieldName;
+  }
+
+  /**
+   * Sets the name of the field that should be updated by this operation.
+   * @param fieldName
+   */
+  public synchronized void setFieldName(String fieldName) {
+    this.fieldName = fieldName;
+  }
+
+  /**
+   * Gets the descriptor used to create the field's value.
+   */
+  public Descriptor getDescriptor() {
+    return descriptor;
+  }
+  /**
+   * Sets the descriptor used to create the field's value
+   * @param valueDescriptor
+   */
+  public synchronized void setDescriptor(Descriptor valueDescriptor) {
+    this.descriptor = valueDescriptor;
+  }
+
+  private static Log log = Log.getLog(FieldOperation.class.getName());
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/InvokeOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/InvokeOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/InvokeOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,85 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+/**
+ * invokes a method.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ * @see ArgDescriptor
+ * @see ObjectDescriptor
+ */
+
+public class InvokeOperation extends AbstractOperation {
+
+  private static final long serialVersionUID = 1L;
+
+  /** name of the method to invoke. */
+  String methodName = null;
+  /** list of descriptors for creating arguments supplied to the method */
+  List<ArgDescriptor> argDescriptors = null;
+
+  public void apply(Object target, WireContext wireContext) {
+    try {
+      Object[] args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+      Class<?> clazz = target.getClass();
+      Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
+      if (method==null) {
+        throw new WireException("method "+ReflectUtil.getSignature(methodName, argDescriptors, args)+" unavailable");
+      }
+      ReflectUtil.invoke(method, target, args);
+    } catch (WireException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new WireException("couldn't invoke method "+methodName+": "+e.getMessage(), e);
+    }
+  }
+
+  /**
+   * Adds a descriptor to the list of arguments descriptors.
+   */
+  public void addArgDescriptor(ArgDescriptor argDescriptor) {
+    if (argDescriptors==null) {
+      argDescriptors = new ArrayList<ArgDescriptor>();
+    }
+    argDescriptors.add(argDescriptor);
+  }
+
+  /**
+   * Gets the name of the method to invoke.
+   */
+  public String getMethodName() {
+    return methodName;
+  }
+
+  /**
+   * Sets the name of the method to invoke.
+   * @param methodName the name of the method to invoke.
+   */
+  public synchronized void setMethodName(String methodName) {
+    this.methodName = methodName;
+  }
+
+  /**
+   * Gets the list of descriptor to create arguments supplied to the method .
+   */
+  public List<ArgDescriptor> getArgDescriptors() {
+    return argDescriptors;
+  }
+
+  /**
+   * Sets the list of descriptor to create arguments supplied to the method .
+   */
+  public void setArgDescriptors(List<ArgDescriptor> argDescriptors) {
+    this.argDescriptors = argDescriptors;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/MethodInvokerListener.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/MethodInvokerListener.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/MethodInvokerListener.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * Wrapper for the subscribe operation.
+ * This class will be used to call a specified method on reception of an event.
+ * This class is used so that a non {@link Listener} class can subscribe to an {@link Observable} object.
+ *
+ * @see SubscribeOperation
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (Documentation)
+ */
+public class MethodInvokerListener implements Listener, Serializable {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(MethodInvokerListener.class.getName());
+
+  String methodName;
+  List<ArgDescriptor> argDescriptors = null;
+  WireContext wireContext;
+  Object target;
+
+  transient Method method = null;
+
+  /**
+   * Creates a new Wrapper.
+   * When an event is received, the arguments <code>args</code> are created from the list <code>argDescriptors</code>, and <code>target.methodName(args)</code> is called.
+   * @param methodName name of the method to call when an event is received.
+   * @param argDescriptors list of descriptors of arguments given to the method.
+   * @param wireContext context to use to create the arguments
+   * @param target object on which the method will be called.
+   */
+  public MethodInvokerListener(String methodName, List<ArgDescriptor> argDescriptors, WireContext wireContext, Object target) {
+    this.methodName = methodName;
+    this.argDescriptors = argDescriptors;
+    this.wireContext = wireContext;
+    this.target = target;
+  }
+
+  public void event(Object source, String eventName, Object info) {
+    log.debug("invoking "+methodName+" on "+target+" for event "+eventName);
+    try {
+      Object[] args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+      Class<?> clazz = target.getClass();
+      Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
+      if(method == null) {
+        throw new WireException("method "+ReflectUtil.getSignature(methodName, argDescriptors, args)+" unavailable for "+target);
+      }
+      ReflectUtil.invoke(method, target, args);
+    } catch (WireException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new WireException("couldn't invoke listener method "+methodName+": "+e.getMessage(), e);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/Operation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/Operation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/Operation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,18 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * any field update or method invocation after the construction of an object.
+ */
+public interface Operation extends Serializable {
+
+  /**
+   * Apply this operation to the specified object, defined in the specified {@link WireContext}.
+   * @param target object on which the operation should be performed.
+   * @param wireContext context in which the operation is applied.
+   */
+  void apply(Object target, WireContext wireContext);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/PropertyOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/PropertyOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/PropertyOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.lang.reflect.Method;
+
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * injects another object with a setter method.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ */
+public class PropertyOperation extends AbstractOperation {
+
+  private static final long serialVersionUID = 1L;
+
+  String setterName = null;
+  /* the method will be searched by reflection on the runtime value */
+  Descriptor descriptor = null;
+
+  public void apply(Object target, WireContext wireContext) {
+    // create the value to assign to the property
+    Object value = wireContext.create(descriptor, true);
+    Method method = null;
+    Class<?> clazz = target.getClass();
+    Object[] args = new Object[]{value};
+    method = ReflectUtil.findMethod(clazz, setterName, null, args);
+    if (method==null) {
+      throw new WireException("couldn't find property setter "+setterName+" for value "+value);
+    }
+    ReflectUtil.invoke(method, target, args);
+  }
+
+  /**
+   * Sets the name of the property that should be updated by this operation.
+   * If propertyName is <code>foo</code>, the method used to set the value will be <code>setFoo</code>.
+   * @param propertyName
+   */
+  public void setPropertyName(String propertyName) {
+    this.setterName = "set"+propertyName.substring(0,1).toUpperCase()+propertyName.substring(1);
+  }
+
+  /**
+   * Gets the name of the setter method used to inject the property value.
+   * @return name of the setter method used to inject the property value.
+   */
+  public String getSetterName() {
+    return setterName;
+  }
+
+  /**
+   * Sets the name of the setter method to use to inject the property value.
+   * @param setterName
+   */
+  public void setSetterName(String setterName) {
+    this.setterName = setterName;
+  }
+
+  /**
+   * Gets the descriptor used to create the field's value.
+   */
+  public Descriptor getDescriptor() {
+    return descriptor;
+  }
+
+  /**
+   * Sets the descriptor used to create the field's value
+   * @param valueDescriptor
+   */
+  public void setDescriptor(Descriptor valueDescriptor) {
+    this.descriptor = valueDescriptor;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/SubscribeOperation.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/SubscribeOperation.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/SubscribeOperation.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,227 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.FilterListener;
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+
+
+/**
+ * subscribes to an {@link Observable observable}.
+ *
+ * <p>The target object can be a {@link Listener}
+ * or a specific method to call can be specified (by {@link #setMethodName(String)})</p>
+ *
+ * <p>The event can be filtered by specifying a {@link Context} (with {@link #setContextName(String)}),
+ * objects to observe (with {@link #setObjectNames(List)}) and events to observe
+ * (with {@link #setEventNames(List)}). If the objects or events are not specified,
+ * then all objects and events are observed.</p>
+ *
+ * <p>The {@link #setWireEvents(boolean)} specifies if the object or the {@link Descriptor} events
+ * should be observed.</p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ *
+ */
+public class SubscribeOperation implements Operation {
+
+  private static final long serialVersionUID = 1L;
+  private static Log log = Log.getLog(SubscribeOperation.class.getName());
+
+  String contextName = null;
+  List<String> eventNames = null;
+
+  boolean wireEvents = false;
+  List<String> objectNames = null;
+  String methodName = null;
+  List<ArgDescriptor> argDescriptors = null;
+
+  public void apply(Object target, WireContext targetWireContext) {
+    Listener listener = null;
+
+    // if a method has to be invoked, rather then using the observable interface
+    if (methodName!=null) {
+      listener = new MethodInvokerListener(
+        methodName,
+        argDescriptors,
+        targetWireContext,
+        target
+      );
+    } else {
+      try {
+        listener = (Listener) target;
+      } catch (ClassCastException e) {
+        throw new WireException("couldn't subscribe object "+target+ " because it is not a Listener");
+      }
+    }
+
+    // if there is a filter specified on the event names
+    if ( (eventNames!=null)
+         && (! eventNames.isEmpty())
+       ) {
+      listener = new FilterListener(listener, eventNames);
+    }
+
+    // identify the wireContext
+    WireContext wireContext = null;
+    if (contextName!=null) {
+      Environment environment = Environment.getCurrent();
+      if (environment!=null) {
+        try {
+          wireContext = (WireContext) environment.getContext(contextName);
+          if (wireContext==null) {
+            throw new WireException("couldn't subscribe because context "+contextName+" doesn't exist");
+          }
+        } catch (ClassCastException e) {
+          throw new WireException("couldn't subscribe because context "+contextName+" is not a WireContext", e);
+        }
+      } else {
+        throw new WireException("couldn't get context "+contextName+" for subscribe because no environment available in context "+targetWireContext);
+      }
+    } else {
+      wireContext = targetWireContext;
+    }
+
+    if (wireEvents) {
+      WireDefinition wireDefinition = wireContext.getWireDefinition();
+      
+      // if there are objectNames specified
+      if (objectNames!=null) {
+        // subscribe to the descriptors for the all objectNames
+        for (String objectName: objectNames) {
+          Descriptor descriptor = wireDefinition.getDescriptor(objectName);
+          subscribe(listener, descriptor);
+        }
+        
+      // if no objectNames are specified, subscribe to all the descriptors
+      } else { 
+        Set<Descriptor> descriptors = new HashSet<Descriptor>(wireDefinition.getDescriptors().values());
+        for(Descriptor descriptor: descriptors) {
+          subscribe(listener, descriptor);
+        }
+      }
+
+    } else if ( (objectNames!=null)
+                && (!objectNames.isEmpty())
+              ) {
+      // for every objectName
+      for (String objectName: objectNames) {
+        // subscribe to the objects themselves
+        Object object = wireContext.get(objectName);
+        if (object==null) {
+          throw new WireException("couldn't subscribe to object in context "+wireContext.getName()+": object "+objectName+" unavailable");
+        }
+        if (! (object instanceof Observable)) {
+          throw new WireException("couldn't subscribe to object in context "+wireContext.getName()+": object "+objectName+" ("+object.getClass().getName()+") isn't "+Observable.class.getName());
+        }
+        subscribe(listener, (Observable)object);
+      }
+
+    } else {
+      // subscribe to the context
+      subscribe(listener, wireContext);
+    }
+  }
+
+  void subscribe(Listener listener, Observable observable) {
+    log.trace("adding "+listener+" as listener to "+observable);
+    observable.addListener(listener);
+  }
+
+
+  /**
+   * Gets the list of argDescriptor used to create the arguments given to the method (only if a specific method has to be called).
+   */
+  public List<ArgDescriptor> getArgDescriptors() {
+    return argDescriptors;
+  }
+  /**
+   * Sets the list of argDescriptor used to create the arguments given to the method.
+   */
+  public void setArgDescriptors(List<ArgDescriptor> argDescriptors) {
+    this.argDescriptors = argDescriptors;
+  }
+
+  /**
+   * Gets the list of events to listen to.
+   */
+  public List<String> getEventNames() {
+    return eventNames;
+  }
+  /**
+   * Sets the list of events to listen to.
+   */
+  public void setEventNames(List<String> eventNames) {
+    this.eventNames = eventNames;
+  }
+
+  /**
+   * Gets the name of the method to invoke when an event is received.
+   */
+  public String getMethodName() {
+    return methodName;
+  }
+
+  /**
+  * Sets the name of the method to invoke when an event is received.
+  */
+  public void setMethodName(String methodName) {
+    this.methodName = methodName;
+  }
+
+  /**
+   * Gets the name of the WireContext where the Observable should be found.
+   */
+  public String getContextName() {
+    return contextName;
+  }
+
+  /**
+   * Sets the name of the WireContext where the Observable should be found.
+   */
+  public void setContextName(String contextName) {
+    this.contextName = contextName;
+  }
+
+  /**
+   * Gets the list of name of the Observable objects to observe.
+   */
+  public List<String> getObjectNames() {
+    return objectNames;
+  }
+
+  /**
+   * Sets the list of name of the Observable objects to observe.
+   */
+  public void setObjectNames(List<String> objectNames) {
+    this.objectNames = objectNames;
+  }
+
+  /**
+   * <p><code>true</code> if the target object will listen to Descriptor related events.</p>
+   * <p><code>false</code> if the target object will listen to the object instance events.</p>
+   */
+  public boolean isWireEvents() {
+    return wireEvents;
+  }
+  /**
+   * Sets if the object should listen to descriptor events or to events fired by the named object.
+   * <p><code>true</code> if the target object will listen to Descriptor related events.</p>
+   * <p><code>false</code> if the target object will listen to the object instance events.</p>
+   */
+  public void setWireEvents(boolean wireEvents) {
+    this.wireEvents = wireEvents;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/package.html
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/package.html	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/package.html	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+<body>
+wire context (aka IoC container), start reading {@link org.jbpm.pvm.internal.wire.WireContext}.
+</body>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/wirecontext.gif
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/wirecontext.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/BindingParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.xml;
+
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Binding;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+public class BindingParser extends Parser {
+  
+  private static final Log log = Log.getLog(BindingParser.class.getName());
+
+  public Object parseDocumentElement(Element documentElement, Parse parse) {
+    List<Element> elements = XmlUtil.elements(documentElement, "binding");
+    for (Element bindingElement : elements) {
+      String bindingClassName = XmlUtil.attribute(bindingElement, "class");
+      
+      log.trace("adding wire binding for "+bindingClassName);
+
+      Binding binding = null;
+      if (bindingClassName!=null) {
+        try {
+          Class<?> bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
+          binding = (Binding) bindingClass.newInstance();
+        } catch (Exception e) {
+          parse.addProblem("couldn't instantiate binding "+bindingClassName, e);
+        }
+      } else {
+        parse.addProblem("class is a required attribute in a binding "+XmlUtil.toString(bindingElement));
+      }
+      
+      if (binding!=null) {
+        Bindings bindings = parse.findObject(Bindings.class);
+        bindings.addBinding(binding);
+      } else {
+        log.info("WARNING: binding for "+bindingClassName+" could not be parsed. See parsing problems for more details.");
+      }
+    }
+    
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/xml/WireParser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,288 @@
+package org.jbpm.pvm.internal.wire.xml;
+
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.binding.ByteBinding;
+import org.jbpm.pvm.internal.wire.binding.CharBinding;
+import org.jbpm.pvm.internal.wire.binding.ClassBinding;
+import org.jbpm.pvm.internal.wire.binding.DoubleBinding;
+import org.jbpm.pvm.internal.wire.binding.FloatBinding;
+import org.jbpm.pvm.internal.wire.binding.IntBinding;
+import org.jbpm.pvm.internal.wire.binding.ListBinding;
+import org.jbpm.pvm.internal.wire.binding.MapBinding;
+import org.jbpm.pvm.internal.wire.binding.NullBinding;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.pvm.internal.wire.binding.RefBinding;
+import org.jbpm.pvm.internal.wire.binding.SetBinding;
+import org.jbpm.pvm.internal.wire.binding.StringBinding;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * parses object wiring xml and constructs a WireDefinition.
+ *
+ * <p>To learn the full XML syntax, check out the xsd docs
+ * </p>
+ * <ul><li>To describe an object:<br/>
+ * <ul>
+ *   <li><b><code>&lt;object .../&gt;</code></b>: see {@link ObjectBinding}</li>
+ * </ul></li>
+ * <li>To describe basic types:<br/>
+ * <ul>
+ *   <li><b><code>&lt;boolean .../&gt;</code>, <code>&lt;true /&gt;</code> and <code>&lt;false/&gt;</code></b>: see {@link BooleanBinding}</li>
+ *   <li><b><code>&lt;byte .../&gt;</code></b>: see {@link ByteBinding}</li>
+ *   <li><b><code>&lt;char .../&gt;</code></b>: see {@link CharBinding}</li>
+ *   <li><b><code>&lt;double .../&gt;</code></b>: see {@link DoubleBinding}</li>
+ *   <li><b><code>&lt;float .../&gt;</code></b>: see {@link FloatBinding}</li>
+ *   <li><b><code>&lt;int .../&gt;</code></b>: see {@link IntBinding}</li>
+ *   <li><b><code>&lt;string .../&gt;</code></b>: see {@link StringBinding}</li>
+ * </ul></li>
+ * <li>To describe collections:<br/>
+ * <ul>
+ *   <li><b><code>&lt;map .../&gt;</code></b>: see {@link MapBinding}</li>
+ *   <li><b><code>&lt;set .../&gt;</code></b>: see {@link SetBinding}</li>
+ *   <li><b><code>&lt;list .../&gt;</code></b>: see {@link ListBinding}</li>
+ * </ul></li>
+ * <li>Others:<br/>
+ * <ul>
+ *   <li><b><code>&lt;class .../&gt;</code></b>: see {@link ClassBinding}</li>
+ *   <li><b><code>&lt;ref .../&gt;</code></b>: see {@link RefBinding}</li>
+ *   <li><b><code>&lt;null .../&gt;</code></b>: see {@link NullBinding}</li>
+ * </ul></li>
+ * </ul>
+ *
+ * <h3>Bindings</h3>
+ *
+ * <p>The defaults bindings for the Wiring XML are divided in two categories:
+ * </p>
+ *
+ * <ul>
+ * 	<li>Descriptors, registered with the {@link #CATEGORY_DESCRIPTOR} category</li>
+ * 	<li>Operations, registered with the {@link #CATEGORY_OPERATION} category</li>
+ * </ul>
+ *
+ * <p>Once a parser is created, bindings can be added, overwritten and removed
+ * to customize that parser instance.
+ * </p>
+ *
+ * <h3 id='args'>Describing arguments</h3>
+ *
+ * <p>An ArgDescriptor is defined by a <b><code>&lt;arg&gt;</code></b> xml element.</p>
+ *
+ * <p>This element can have an attribute "type", which specifies name of the argument's type.</p>
+ * <p>This element contains <b>one</b> child element that defines a {@link Descriptor}. This descriptor specifies the value to give to the argument.</p>
+ *
+ * <h4>Example</h4>
+ *
+ * Consider the following class:
+ * <pre> public class Hello {
+ *   public static String sayHello(String name) {
+ *     return "Hello " + name + " !";
+ *   }
+ * }</pre>
+ *
+ * The following Xml declaration will create an object 's' of class 'String' (see {@link ObjectDescriptor}).
+ * This object is created by invoking <code>Hello.sayHello</code> with the value <code>world</code> as a parameter.
+ *
+ * <pre> &lt;objects&gt;
+ *   &lt;object name="s" class='Hello' method='sayHello'&gt;
+ *     &lt;arg&gt;
+ *      &lt;string value='world' /&gt;
+ *     &lt;/arg&gt;
+ *   &lt;/object&gt;
+ * &lt;/objects&gt;</pre>
+ *
+ * The created object 's' will be a String, containing "Hello world !".
+ * 
+ * <h3 id='init'>Initialization</h3>
+ * 
+ * <p>The initialization method can be defined with the <code>init</code> attribute. 
+ * For more details on how initialization works, see section 'Initialization' of {@link WireContext}.</p>
+ * 
+ * The <code>init</code> attribute can have these values:
+ * <ul>
+ *   <li><code>lazy</code>: for lazy creation and delayed initialization</li>
+ *   <li><code>required</code>: for lazy creation and immediate initialization</li>
+ *   <li><code>eager</code>: for eager creation and delayed initialization</li>
+ *   <li><code>immediate</code>: for eager creation and immediate initialization</li>
+ * </ul>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class WireParser extends Parser {
+
+  public static final String[] DEFAULT_WIRE_BINDING_RESOURCES = new String[]{
+    "jbpm.pvm.wire.bindings.xml",
+    "jbpm.jpdl.wire.bindings.xml",
+    "jbpm.task.wire.bindings.xml",
+    "jbpm.enterprise.wire.bindings.xml",
+    "jbpm.user.wire.bindings.xml"
+  }; 
+
+  private static final long serialVersionUID = 1L;
+  
+  private static final Log log = Log.getLog(WireParser.class.getName());
+
+  public static final String CATEGORY_DESCRIPTOR = "descriptor";
+  public static final String CATEGORY_OPERATION = "operation";
+  public static final String CATEGORY_INTERCEPTOR = "interceptor";
+
+  /** static instance of WireParser */
+  private static WireParser instance;
+  /** default bindings for handling wiring xml elements. */
+  private static Bindings defaultBindings; // initialized at the bottom of this file
+  
+  /**
+   * Constructs a new WireParser with the default bindings.
+   */
+  public WireParser() {
+    super(defaultBindings);
+  }
+
+  /**
+   * Default method to get an instance of the WireParser
+   * @return the static instance of WireParser
+   */
+  public static synchronized WireParser getInstance() {
+    if (instance==null) {
+      instance = new WireParser();
+    }
+    return instance;
+  }
+
+  /**
+   * Convenience method to parse a wiring xml.
+   * @param xmlString the xml string to parse
+   * @return the WireDefinition created by parsing the xml given in input.
+   * @see #parseXmlString(String)
+   */
+  public static WireDefinition parseXmlString(String xmlString) {
+    return (WireDefinition) getInstance()
+            .createParse()
+            .setString(xmlString)
+            .execute()
+            .checkProblems("wire definition xml string")
+            .getDocumentObject();
+  }
+
+  // document element parsing /////////////////////////////////////////////////
+
+  /**
+   * This method builds the WireDefinition from the DOM tree.
+   * This methods parses all child activities of the documentElement that correspond to a Descriptor definition.
+   * @param documentElement the root element of the document
+   * @param parse Parse object that contains all information for the current parse operation.
+   * @return an instance of WireDefinition containing the resulting WireDefinition.
+   * @see Parser#parseDocumentElement(Element, Parse)
+   */
+  public Object parseDocumentElement(Element documentElement, Parse parse) {
+    List<Element> elements = XmlUtil.elements(documentElement);
+
+    WireDefinition wireDefinition = new WireDefinition();
+    wireDefinition.setClassLoader(classLoader);
+    
+    parse.pushObject(wireDefinition);
+    try {
+      for (Element descriptorElement: elements) {
+        parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR);
+      }
+    } finally {
+      parse.popObject();
+    }
+
+    return wireDefinition;
+  }
+
+  /**
+   *  This method parses an arbitrary element in the document based on the bindings in the given category.
+   *  This method calls the {@link Parser#parseElement(Element, Parse, String)} method to build the resulting object.
+   *  If the resulting object is a subclass of {@link AbstractDescriptor}, the related fields are initialized.
+   *
+   *  @param element the element to parse
+   *  @param parse Parse object that contains all information for the current parse operation.
+   *  @param category is the category in which the tagName should be resolved to an ElementHandler.
+   *  If category is null, all the categories will be scanned for an appropriate binding in random order.
+   *  @return the java object created from the DOM element
+   */
+  public Object parseElement(Element element, Parse parse, String category) {
+    if (element==null) return null;
+    Object object = super.parseElement(element, parse, category);
+    if ( (object!=null)
+         && (object instanceof Descriptor)
+       ) {
+      
+      Descriptor descriptor = (Descriptor) object;
+      
+      if (descriptor instanceof AbstractDescriptor) {
+        AbstractDescriptor abstractDescriptor = (AbstractDescriptor) descriptor;
+        if(element.hasAttribute("name")){
+          String name = element.getAttribute("name");
+          // get the name
+          abstractDescriptor.setName(name);
+        }
+
+        if (element.hasAttribute("init")) {
+          // get the init
+          String initText = element.getAttribute("init");
+
+          if("eager".equalsIgnoreCase(initText)){
+            abstractDescriptor.setInit(AbstractDescriptor.INIT_EAGER);
+          }else if("immediate".equalsIgnoreCase(initText)){
+            abstractDescriptor.setInit(AbstractDescriptor.INIT_IMMEDIATE);
+          } else if("required".equalsIgnoreCase(initText)){
+            abstractDescriptor.setInit(AbstractDescriptor.INIT_REQUIRED);
+          } else {
+            // init='lazy' or default value
+            abstractDescriptor.setInit(AbstractDescriptor.INIT_LAZY);
+          }
+        }
+      }
+      
+      // add the descriptor
+      WireDefinition wireDefinition = parse.findObject(WireDefinition.class);
+      if (wireDefinition!=null) {
+        wireDefinition.addDescriptor(descriptor);
+      }
+    }
+    return object;
+  }
+
+  // other methods ////////////////////////////////////////////////////////////
+
+  static {
+    // default descriptor parsers ///////////////////////////////////////////////
+    defaultBindings = new Bindings();
+    
+    BindingParser bindingParser = new BindingParser();
+ 
+    for (String wireResource: DEFAULT_WIRE_BINDING_RESOURCES) {
+      Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, wireResource);
+      if (resourceUrls.hasMoreElements()) {
+        while (resourceUrls.hasMoreElements()) {
+          URL resourceUrl = resourceUrls.nextElement();
+          log.trace("loading wire bindings from resource: "+resourceUrl);
+          bindingParser.createParse()
+            .setUrl(resourceUrl)
+            .pushObject(defaultBindings)
+            .execute()
+            .checkProblems(resourceUrl.toString());
+        }
+      } else {
+        log.trace("skipping unavailable wire bindings resource "+wireResource);
+      }
+    }
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Binding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Binding.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Binding.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import org.w3c.dom.Element;
+
+/** a modular mapping between an xml element and a java object in the 
+ * domain model, see also {@link Parser}.
+ * 
+ * <a href="./Parser.html#bindings">See also 'Bindings'</a>.
+ * 
+ * @see Parser 
+ */
+public interface Binding {
+  
+  String getCategory();
+
+  /** does this binding apply to the given element? */
+  boolean matches(Element element);
+
+  /** translates the given element into a domain model java object.
+   * Use the parse to report problems. 
+   * @return the domain model java object.
+   * @see Parser
+   */
+  Object parse(Element element, Parse parse, Parser parser);
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Bindings.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Bindings.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Bindings.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.w3c.dom.Element;
+
+/** a set of {@link Binding}s divided into categories managed by a {@link Parser}.
+ * 
+ * <a href="./Parser.html#bindings">See also 'Bindinds'</a>
+ * @see Parser
+ * @author Tom Baeyens
+ */
+public class Bindings {
+
+  /** maps categories to a list of bindings */
+  protected Map<String, List<Binding>> bindings = null;
+  
+  public Bindings() {
+  }
+
+  /** to be used when you want to customize the binding behaviour of a {@link Parser}. */
+  public Bindings(Bindings other) {
+    if (other.bindings!=null) {
+      bindings = new HashMap<String, List<Binding>>();
+      Set<String> categorieNames = other.bindings.keySet();
+      if (categorieNames!=null) {
+        for (String categoryName: categorieNames) {
+          List<Binding> categoryBindings = other.bindings.get(categoryName);
+          List<Binding> categoryBindingsCopy = new ArrayList<Binding>(categoryBindings);
+          bindings.put(categoryName, categoryBindingsCopy);
+        }
+      }
+    }
+  }
+
+  /** get a binding for the given element and category. 
+   * If the category is null, then all the categories will be searched for a binding in random order.
+   */
+  public Binding getBinding(Element element) {
+    return getBinding(element, (String)null);
+  }
+
+  /** get a binding for the given element and category. 
+   * If the category is null, then all the categories will be searched for a binding in random order.
+   */
+  public Binding getBinding(Element element, String category) {
+    if (bindings==null) {
+      return null;
+    }
+    // if no category is specified
+    if (category==null) {
+      // search in all categories
+      for (List<Binding> categoryBindings : bindings.values()) {
+        Binding binding = getBinding(element, categoryBindings);
+        if (binding != null) {
+          return binding;
+        }
+      }
+    } else {
+      List<Binding> categoryBindings = bindings.get(category);
+      if (categoryBindings!=null) {
+        return getBinding(element, categoryBindings);
+      }
+    }
+    return null;
+  }
+
+  protected Binding getBinding(Element element, List<Binding> categoryBindings) {
+    for (Binding binding: categoryBindings) {
+      if (binding.matches(element)) {
+        return binding;
+      }
+    }
+    return null;
+  }
+
+  /** add an elementParser to this parser that will handle parsing of 
+   * elements of the given tagName for the default category. */ 
+  public void addBinding(Binding binding) {
+    if (bindings==null) {
+      bindings = new HashMap<String, List<Binding>>();
+    }
+    String category = binding.getCategory();
+    List<Binding> categoryBindings = bindings.get(category);
+    if (categoryBindings==null){
+      categoryBindings = new ArrayList<Binding>();
+      bindings.put(category, categoryBindings);
+    }
+    categoryBindings.add(binding);
+  }
+  
+  /** the set of all tagNames for which there is a binding specified in the given category */
+  public Set<String> getTagNames(String category) {
+    List<Binding> categoryBindings = (bindings!=null ? bindings.get(category) : null );
+    Set<String> tagNames = new HashSet<String>();
+    for (Binding binding: categoryBindings) {
+      tagNames.add(binding.toString());
+    }
+    return tagNames;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,851 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the  "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: DebugDomBuilder.java 1434 2008-07-01 10:32:10Z heiko.braun at jboss.com $
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.util.Stack;
+import java.util.Vector;
+
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/** builds the dom model from SAX events, optionally adding the line and 
+ * column number as attributes to every element. */
+public class DomBuilder extends DefaultHandler implements ContentHandler, LexicalHandler {  /** Root document */
+
+  public Document document;
+  
+  protected String debugNamespace = null;
+  protected String lineAttributeName = "line";
+  protected String columnAttributeName = null;
+
+  /** Current activity */
+  protected Node currentNode = null;
+
+  /** The root activity */
+  protected Node root = null;
+
+  /** The next sibling activity */
+  protected Node nextSibling = null;
+
+  /** First activity of document fragment or null if not a DocumentFragment */
+  public DocumentFragment docFrag = null;
+
+  /** Vector of element activities */
+  protected Stack elemStack = new Stack();
+
+  /** Namespace support */
+  protected Vector prefixMappings = new Vector();
+
+  /** to obtain the line number information */
+  protected Locator locator = null;
+
+  /**
+   * Get the root document or DocumentFragment of the DOM being created.
+   * 
+   * @return The root document or document fragment if not null
+   */
+  public Node getRootDocument() {
+    return (null != this.docFrag) ? (Node) this.docFrag : (Node) this.document;
+  }
+
+  /**
+   * Get the root activity of the DOM tree.
+   */
+  public Node getRootNode() {
+    return this.root;
+  }
+
+  /**
+   * Get the activity currently being processed.
+   * 
+   * @return the current activity being processed
+   */
+  public Node getCurrentNode() {
+    return this.currentNode;
+  }
+
+  /**
+   * Set the next sibling activity, which is where the result activities should be
+   * inserted before.
+   * 
+   * @param nextSibling
+   *          the next sibling activity.
+   */
+  public void setNextSibling(Node nextSibling) {
+    this.nextSibling = nextSibling;
+  }
+
+  /**
+   * Return the next sibling activity.
+   * 
+   * @return the next sibling activity.
+   */
+  public Node getNextSibling() {
+    return this.nextSibling;
+  }
+
+  /**
+   * Return null since there is no Writer for this class.
+   * 
+   * @return null
+   */
+  public java.io.Writer getWriter() {
+    return null;
+  }
+
+  /**
+   * Append a activity to the current container.
+   * 
+   * @param newNode
+   *          New activity to append
+   */
+  protected void append(Node newNode) throws org.xml.sax.SAXException {
+
+    Node currentNode = this.currentNode;
+
+    if (null != currentNode) {
+      if (currentNode == this.root && this.nextSibling != null)
+        currentNode.insertBefore(newNode, this.nextSibling);
+      else
+        currentNode.appendChild(newNode);
+
+      // System.out.println(newNode.getNodeName());
+    } else if (null != this.docFrag) {
+      if (this.nextSibling != null)
+        this.docFrag.insertBefore(newNode, this.nextSibling);
+      else
+        this.docFrag.appendChild(newNode);
+    } else {
+      boolean ok = true;
+      short type = newNode.getNodeType();
+
+      if (type == Node.TEXT_NODE) {
+        String data = newNode.getNodeValue();
+
+        if ((null != data) && (data.trim().length() > 0)) {
+          throw new org.xml.sax.SAXException("Warning: can't output text before document element!  Ignoring...");
+        }
+
+        ok = false;
+      } else if (type == Node.ELEMENT_NODE) {
+        if (this.document.getDocumentElement() != null) {
+          ok = false;
+
+          throw new org.xml.sax.SAXException("Can't have more than one root on a DOM!");
+        }
+      }
+
+      if (ok) {
+        if (this.nextSibling != null)
+          this.document.insertBefore(newNode, this.nextSibling);
+        else
+          this.document.appendChild(newNode);
+      }
+    }
+  }
+
+  /**
+   * Receive an object for locating the origin of SAX document events.
+   * 
+   * <p>
+   * SAX parsers are strongly encouraged (though not absolutely required) to
+   * supply a locator: if it does so, it must supply the locator to the
+   * application by invoking this method before invoking any of the other
+   * methods in the ContentHandler interface.
+   * </p>
+   * 
+   * <p>
+   * The locator allows the application to determine the end position of any
+   * document-related event, even if the parser is not reporting an error.
+   * Typically, the application will use this information for reporting its own
+   * errors (such as character content that does not match an application's
+   * business rules). The information returned by the locator is probably not
+   * sufficient for use with a search engine.
+   * </p>
+   * 
+   * <p>
+   * Note that the locator will return correct information only during the
+   * invocation of the events in this interface. The application should not
+   * attempt to use it at any other time.
+   * </p>
+   * 
+   * @param locator
+   *          An object that can return the location of any SAX document event.
+   * @see org.xml.sax.Locator
+   */
+  public void setDocumentLocator(Locator locator) {
+    this.locator = locator;
+    // No action for the moment.
+  }
+
+  /**
+   * Receive notification of the beginning of a document.
+   * 
+   * <p>
+   * The SAX parser will invoke this method only once, before any other methods
+   * in this interface or in DTDHandler (except for setDocumentLocator).
+   * </p>
+   */
+  public void startDocument() throws org.xml.sax.SAXException {
+
+    // No action for the moment.
+  }
+
+  /**
+   * Receive notification of the end of a document.
+   * 
+   * <p>
+   * The SAX parser will invoke this method only once, and it will be the last
+   * method invoked during the parse. The parser shall not invoke this method
+   * until it has either abandoned parsing (because of an unrecoverable error)
+   * or reached the end of input.
+   * </p>
+   */
+  public void endDocument() throws org.xml.sax.SAXException {
+
+    // No action for the moment.
+  }
+
+  /**
+   * Receive notification of the beginning of an element.
+   * 
+   * <p>
+   * The Parser will invoke this method at the beginning of every element in the
+   * XML document; there will be a corresponding endElement() event for every
+   * startElement() event (even when the element is empty). All of the element's
+   * content will be reported, in order, before the corresponding endElement()
+   * event.
+   * </p>
+   * 
+   * <p>
+   * If the element name has a namespace prefix, the prefix will still be
+   * attached. Note that the attribute list provided will contain only
+   * attributes with explicit values (specified or defaulted): #IMPLIED
+   * attributes will be omitted.
+   * </p>
+   * 
+   * 
+   * @param ns
+   *          The namespace of the activity
+   * @param localName
+   *          The local part of the qualified name
+   * @param name
+   *          The element name.
+   * @param atts
+   *          The attributes attached to the element, if any.
+   * @see #endElement
+   * @see org.xml.sax.Attributes
+   */
+  public void startElement(String ns, String localName, String name, Attributes atts) throws org.xml.sax.SAXException {
+
+    Element elem;
+
+    // Note that the namespace-aware call must be used to correctly
+    // construct a Level 2 DOM, even for non-namespaced activities.
+    if ((null == ns) || (ns.length() == 0))
+      elem = this.document.createElementNS(null, name);
+    else
+      elem = this.document.createElementNS(ns, name);
+
+    append(elem);
+
+    try {
+      int nAtts = atts.getLength();
+
+      if (0 != nAtts) {
+        for (int i = 0; i < nAtts; i++) {
+
+          // System.out.println("type " + atts.getType(i) + " name " +
+          // atts.getLocalName(i) );
+          // First handle a possible ID attribute
+          if (atts.getType(i).equalsIgnoreCase("ID"))
+            setIDAttribute(atts.getValue(i), elem);
+
+          String attrNS = atts.getURI(i);
+
+          if ("".equals(attrNS))
+            attrNS = null; // DOM represents no-namespace as null
+
+          // System.out.println("attrNS: "+attrNS+", localName:
+          // "+atts.getQName(i)
+          // +", qname: "+atts.getQName(i)+", value: "+atts.getValue(i));
+          // Crimson won't let us set an xmlns: attribute on the DOM.
+          String attrQName = atts.getQName(i);
+
+          // In SAX, xmlns[:] attributes have an empty namespace, while in DOM
+          // they
+          // should have the xmlns namespace
+          if (attrQName.startsWith("xmlns:") || attrQName.equals("xmlns")) {
+            attrNS = "http://www.w3.org/2000/xmlns/";
+          }
+
+          // ALWAYS use the DOM Level 2 call!
+          elem.setAttributeNS(attrNS, attrQName, atts.getValue(i));
+        }
+      }
+
+      if (locator!=null) {
+        int lineNumber = locator.getLineNumber();
+        int columnNumber = locator.getColumnNumber();
+
+        if (debugNamespace==null) {
+          if (lineAttributeName!=null) {
+            elem.setAttribute(lineAttributeName, Integer.toString(lineNumber));
+          }
+          if (columnAttributeName!=null) {
+            elem.setAttribute(columnAttributeName, Integer.toString(columnNumber));
+          }
+          
+        } else {
+          if (lineAttributeName!=null) {
+            elem.setAttributeNS(debugNamespace, lineAttributeName, Integer.toString(lineNumber));
+          }
+          if (columnAttributeName!=null) {
+            elem.setAttributeNS(debugNamespace, columnAttributeName, Integer.toString(columnNumber));
+          }
+          
+        }
+      }
+
+
+      /*
+       * Adding namespace activities to the DOM tree;
+       */
+      int nDecls = this.prefixMappings.size();
+
+      String prefix, declURL;
+
+      for (int i = 0; i < nDecls; i += 2) {
+        prefix = (String) this.prefixMappings.elementAt(i);
+
+        if (prefix == null)
+          continue;
+
+        declURL = (String) this.prefixMappings.elementAt(i + 1);
+
+        elem.setAttributeNS("http://www.w3.org/2000/xmlns/", prefix, declURL);
+      }
+
+      this.prefixMappings.clear();
+
+      // append(elem);
+
+      this.elemStack.push(elem);
+
+      this.currentNode = elem;
+
+      // append(elem);
+    } catch (java.lang.Exception de) {
+      // de.printStackTrace();
+      throw new org.xml.sax.SAXException(de);
+    }
+
+  }
+
+  /**
+   * 
+   * 
+   * 
+   * Receive notification of the end of an element.
+   * 
+   * <p>
+   * The SAX parser will invoke this method at the end of every element in the
+   * XML document; there will be a corresponding startElement() event for every
+   * endElement() event (even when the element is empty).
+   * </p>
+   * 
+   * <p>
+   * If the element name has a namespace prefix, the prefix will still be
+   * attached to the name.
+   * </p>
+   * 
+   * 
+   * @param ns
+   *          the namespace of the element
+   * @param localName
+   *          The local part of the qualified name of the element
+   * @param name
+   *          The element name
+   */
+  public void endElement(String ns, String localName, String name) throws org.xml.sax.SAXException {
+    this.elemStack.pop();
+    this.currentNode = this.elemStack.isEmpty() ? null : (Node) this.elemStack.peek();
+  }
+
+  /**
+   * Set an ID string to activity association in the ID table.
+   * 
+   * @param id
+   *          The ID string.
+   * @param elem
+   *          The associated ID.
+   */
+  public void setIDAttribute(String id, Element elem) {
+
+    // Do nothing. This method is meant to be overiden.
+  }
+
+  /**
+   * Receive notification of character data.
+   * 
+   * <p>
+   * The Parser will call this method to report each chunk of character data.
+   * SAX parsers may return all contiguous character data in a single chunk, or
+   * they may split it into several chunks; however, all of the characters in
+   * any single event must come from the same external entity, so that the
+   * Locator provides useful information.
+   * </p>
+   * 
+   * <p>
+   * The application must not attempt to read from the array outside of the
+   * specified range.
+   * </p>
+   * 
+   * <p>
+   * Note that some parsers will report whitespace using the
+   * ignorableWhitespace() method rather than this one (validating parsers must
+   * do so).
+   * </p>
+   * 
+   * @param ch
+   *          The characters from the XML document.
+   * @param start
+   *          The start position in the array.
+   * @param length
+   *          The number of characters to read from the array.
+   * @see #ignorableWhitespace
+   * @see org.xml.sax.Locator
+   */
+  public void characters(char ch[], int start, int length) throws org.xml.sax.SAXException {
+    if (isOutsideDocElem() && isWhiteSpace(ch, start, length))
+      return; // avoid DOM006 Hierarchy request error
+
+    if (this.inCData) {
+      cdata(ch, start, length);
+
+      return;
+    }
+
+    String s = new String(ch, start, length);
+    Node childNode;
+    childNode = this.currentNode != null ? this.currentNode.getLastChild() : null;
+    if (childNode != null && childNode.getNodeType() == Node.TEXT_NODE) {
+      ((Text) childNode).appendData(s);
+    } else {
+      Text text = this.document.createTextNode(s);
+      append(text);
+    }
+  }
+
+  /**
+   * If available, when the disable-output-escaping attribute is used, output
+   * raw text without escaping. A PI will be inserted in front of the activity with
+   * the name "lotusxsl-next-is-raw" and a value of "formatter-to-dom".
+   * 
+   * @param ch
+   *          Array containing the characters
+   * @param start
+   *          Index to start of characters in the array
+   * @param length
+   *          Number of characters in the array
+   */
+  public void charactersRaw(char ch[], int start, int length) throws org.xml.sax.SAXException {
+    if (isOutsideDocElem() && isWhiteSpace(ch, start, length))
+      return; // avoid DOM006 Hierarchy request error
+
+    String s = new String(ch, start, length);
+
+    append(this.document.createProcessingInstruction("xslt-next-is-raw", "formatter-to-dom"));
+    append(this.document.createTextNode(s));
+  }
+
+  /**
+   * Report the beginning of an entity.
+   * 
+   * The start and end of the document entity are not reported. The start and
+   * end of the external DTD subset are reported using the pseudo-name "[dtd]".
+   * All other events must be properly nested within start/end entity events.
+   * 
+   * @param name
+   *          The name of the entity. If it is a parameter entity, the name will
+   *          begin with '%'.
+   * @see #endEntity
+   * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
+   * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
+   */
+  public void startEntity(String name) throws org.xml.sax.SAXException {
+
+    // Almost certainly the wrong behavior...
+    // entityReference(name);
+  }
+
+  /**
+   * Report the end of an entity.
+   * 
+   * @param name
+   *          The name of the entity that is ending.
+   * @see #startEntity
+   */
+  public void endEntity(String name) throws org.xml.sax.SAXException {
+  }
+
+  /**
+   * Receive notivication of a entityReference.
+   * 
+   * @param name
+   *          name of the entity reference
+   */
+  public void entityReference(String name) throws org.xml.sax.SAXException {
+    append(this.document.createEntityReference(name));
+  }
+
+  /**
+   * Receive notification of ignorable whitespace in element content.
+   * 
+   * <p>
+   * Validating Parsers must use this method to report each chunk of ignorable
+   * whitespace (see the W3C XML 1.0 recommendation, section 2.10):
+   * non-validating parsers may also use this method if they are capable of
+   * parsing and using content models.
+   * </p>
+   * 
+   * <p>
+   * SAX parsers may return all contiguous whitespace in a single chunk, or they
+   * may split it into several chunks; however, all of the characters in any
+   * single event must come from the same external entity, so that the Locator
+   * provides useful information.
+   * </p>
+   * 
+   * <p>
+   * The application must not attempt to read from the array outside of the
+   * specified range.
+   * </p>
+   * 
+   * @param ch
+   *          The characters from the XML document.
+   * @param start
+   *          The start position in the array.
+   * @param length
+   *          The number of characters to read from the array.
+   * @see #characters
+   */
+  public void ignorableWhitespace(char ch[], int start, int length) throws org.xml.sax.SAXException {
+    if (isOutsideDocElem())
+      return; // avoid DOM006 Hierarchy request error
+
+    String s = new String(ch, start, length);
+
+    append(this.document.createTextNode(s));
+  }
+
+  /**
+   * Tell if the current activity is outside the document element.
+   * 
+   * @return true if the current activity is outside the document element.
+   */
+  private boolean isOutsideDocElem() {
+    return (null == this.docFrag) && this.elemStack.size() == 0 && (null == this.currentNode || this.currentNode.getNodeType() == Node.DOCUMENT_NODE);
+  }
+
+  /**
+   * Receive notification of a processing instruction.
+   * 
+   * <p>
+   * The Parser will invoke this method once for each processing instruction
+   * found: note that processing instructions may occur before or after the main
+   * document element.
+   * </p>
+   * 
+   * <p>
+   * A SAX parser should never report an XML declaration (XML 1.0, section 2.8)
+   * or a text declaration (XML 1.0, section 4.3.1) using this method.
+   * </p>
+   * 
+   * @param target
+   *          The processing instruction target.
+   * @param data
+   *          The processing instruction data, or null if none was supplied.
+   */
+  public void processingInstruction(String target, String data) throws org.xml.sax.SAXException {
+    append(this.document.createProcessingInstruction(target, data));
+  }
+
+  /**
+   * Report an XML comment anywhere in the document.
+   * 
+   * This callback will be used for comments inside or outside the document
+   * element, including comments in the external DTD subset (if read).
+   * 
+   * @param ch
+   *          An array holding the characters in the comment.
+   * @param start
+   *          The starting position in the array.
+   * @param length
+   *          The number of characters to use from the array.
+   */
+  public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException {
+    append(this.document.createComment(new String(ch, start, length)));
+  }
+
+  /** Flag indicating that we are processing a CData section */
+  protected boolean inCData = false;
+
+  /**
+   * Report the start of a CDATA section.
+   * 
+   * @see #endCDATA
+   */
+  public void startCDATA() throws org.xml.sax.SAXException {
+    this.inCData = true;
+    append(this.document.createCDATASection(""));
+  }
+
+  /**
+   * Report the end of a CDATA section.
+   * 
+   * @see #startCDATA
+   */
+  public void endCDATA() throws org.xml.sax.SAXException {
+    this.inCData = false;
+  }
+
+  /**
+   * Receive notification of cdata.
+   * 
+   * <p>
+   * The Parser will call this method to report each chunk of character data.
+   * SAX parsers may return all contiguous character data in a single chunk, or
+   * they may split it into several chunks; however, all of the characters in
+   * any single event must come from the same external entity, so that the
+   * Locator provides useful information.
+   * </p>
+   * 
+   * <p>
+   * The application must not attempt to read from the array outside of the
+   * specified range.
+   * </p>
+   * 
+   * <p>
+   * Note that some parsers will report whitespace using the
+   * ignorableWhitespace() method rather than this one (validating parsers must
+   * do so).
+   * </p>
+   * 
+   * @param ch
+   *          The characters from the XML document.
+   * @param start
+   *          The start position in the array.
+   * @param length
+   *          The number of characters to read from the array.
+   * @see #ignorableWhitespace
+   * @see org.xml.sax.Locator
+   */
+  public void cdata(char ch[], int start, int length) throws org.xml.sax.SAXException {
+    if (isOutsideDocElem() && isWhiteSpace(ch, start, length))
+      return; // avoid DOM006 Hierarchy request error
+
+    String s = new String(ch, start, length);
+
+    CDATASection section = (CDATASection) this.currentNode.getLastChild();
+    section.appendData(s);
+  }
+
+  /**
+   * Report the start of DTD declarations, if any.
+   * 
+   * Any declarations are assumed to be in the internal subset unless otherwise
+   * indicated.
+   * 
+   * @param name
+   *          The document type name.
+   * @param publicId
+   *          The declared public identifier for the external DTD subset, or
+   *          null if none was declared.
+   * @param systemId
+   *          The declared system identifier for the external DTD subset, or
+   *          null if none was declared.
+   * @see #endDTD
+   * @see #startEntity
+   */
+  public void startDTD(String name, String publicId, String systemId) throws org.xml.sax.SAXException {
+
+    // Do nothing for now.
+  }
+
+  /**
+   * Report the end of DTD declarations.
+   * 
+   * @see #startDTD
+   */
+  public void endDTD() throws org.xml.sax.SAXException {
+
+    // Do nothing for now.
+  }
+
+  /**
+   * Begin the scope of a prefix-URI Namespace mapping.
+   * 
+   * <p>
+   * The information from this event is not necessary for normal Namespace
+   * processing: the SAX XML reader will automatically replace prefixes for
+   * element and attribute names when the http://xml.org/sax/features/namespaces
+   * feature is true (the default).
+   * </p>
+   * 
+   * <p>
+   * There are cases, however, when applications need to use prefixes in
+   * character data or in attribute values, where they cannot safely be expanded
+   * automatically; the start/endPrefixMapping event supplies the information to
+   * the application to expand prefixes in those contexts itself, if necessary.
+   * </p>
+   * 
+   * <p>
+   * Note that start/endPrefixMapping events are not guaranteed to be properly
+   * nested relative to each-other: all startPrefixMapping events will occur
+   * before the corresponding startElement event, and all endPrefixMapping
+   * events will occur after the corresponding endElement event, but their order
+   * is not guaranteed.
+   * </p>
+   * 
+   * @param prefix
+   *          The Namespace prefix being declared.
+   * @param uri
+   *          The Namespace URI the prefix is mapped to.
+   * @see #endPrefixMapping
+   * @see #startElement
+   */
+  public void startPrefixMapping(String prefix, String uri) throws org.xml.sax.SAXException {
+    if (null == prefix || prefix.equals(""))
+      prefix = "xmlns";
+    else
+      prefix = "xmlns:" + prefix;
+    this.prefixMappings.addElement(prefix);
+    this.prefixMappings.addElement(uri);
+  }
+
+  /**
+   * End the scope of a prefix-URI mapping.
+   * 
+   * <p>
+   * See startPrefixMapping for details. This event will always occur after the
+   * corresponding endElement event, but the order of endPrefixMapping events is
+   * not otherwise guaranteed.
+   * </p>
+   * 
+   * @param prefix
+   *          The prefix that was being mapping.
+   * @see #startPrefixMapping
+   * @see #endElement
+   */
+  public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException {
+  }
+
+  /**
+   * Receive notification of a skipped entity.
+   * 
+   * <p>
+   * The Parser will invoke this method once for each entity skipped.
+   * Non-validating processors may skip entities if they have not seen the
+   * declarations (because, for example, the entity was declared in an external
+   * DTD subset). All processors may skip external entities, depending on the
+   * values of the http://xml.org/sax/features/external-general-entities and the
+   * http://xml.org/sax/features/external-parameter-entities properties.
+   * </p>
+   * 
+   * @param name
+   *          The name of the skipped entity. If it is a parameter entity, the
+   *          name will begin with '%'.
+   */
+  public void skippedEntity(String name) throws org.xml.sax.SAXException {
+  }
+
+  /**
+   * Returns whether the specified <var>ch</var> conforms to the XML 1.0
+   * definition of whitespace. Refer to <A
+   * href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-S"> the definition of
+   * <CODE>S</CODE></A> for details.
+   * 
+   * @param ch
+   *          Character to check as XML whitespace.
+   * @return =true if <var>ch</var> is XML whitespace; otherwise =false.
+   */
+  public static boolean isWhiteSpace(char ch) {
+    return (ch == 0x20) || (ch == 0x09) || (ch == 0xD) || (ch == 0xA);
+  }
+
+  /**
+   * Tell if the string is whitespace.
+   * 
+   * @param ch
+   *          Character array to check as XML whitespace.
+   * @param start
+   *          Start index of characters in the array
+   * @param length
+   *          Number of characters in the array
+   * @return True if the characters in the array are XML whitespace; otherwise,
+   *         false.
+   */
+  public static boolean isWhiteSpace(char ch[], int start, int length) {
+
+    int end = start + length;
+
+    for (int s = start; s < end; s++) {
+      if (!isWhiteSpace(ch[s]))
+        return false;
+    }
+
+    return true;
+  }
+
+  public void setDebugNamespace(String debugNamespace) {
+    this.debugNamespace = debugNamespace;
+  }
+  public void setLineAttributeName(String lineAttributeName) {
+    this.lineAttributeName = lineAttributeName;
+  }
+  public void setColumnAttributeName(String columnAttributeName) {
+    this.columnAttributeName = columnAttributeName;
+  }
+  public String getDebugNamespace() {
+    return debugNamespace;
+  }
+  public String getLineAttributeName() {
+    return lineAttributeName;
+  }
+  public String getColumnAttributeName() {
+    return columnAttributeName;
+  }
+  public Document getDocument() {
+    return document;
+  }
+  public void setDocument(Document document) {
+    this.document = document;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Entity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Entity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Entity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import org.xml.sax.InputSource;
+
+/** used by {@link Parser} to implement {@link org.xml.sax.EntityResolver} for
+ * entity resolving.
+ *
+ * <a href="./Parser.html#entityresolving">See also 'entity resolving'</a>.
+ *
+ * @author Tom Baeyens
+ */
+public interface Entity {
+
+  InputSource getInputSource();
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,262 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * 
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ListIterator;
+import java.util.Stack;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.jbpm.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.w3c.dom.Document;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXParseException;
+
+/** information related to one single parse operation, for instructions 
+ * see {@link Parser}.
+ * 
+ * @author Tom Baeyens
+ */
+public class Parse extends ProblemList implements Serializable, ErrorHandler {
+
+  private static Log log = Log.getLog(Parse.class.getName());
+  private static final long serialVersionUID = 1L;
+
+  protected Parser parser;
+  
+  protected ClassLoader classLoader;
+  protected StreamInput streamInput;
+  protected InputStream inputStream;
+  protected InputSource inputSource;
+  
+  protected DocumentBuilder documentBuilder = null;
+  protected Document document = null;
+
+  protected Stack<Object> objectStack;
+  protected Object documentObject;
+  
+  protected Parse(Parser parser) {
+    this.parser = parser;
+  }
+  
+  // specifying the input source //////////////////////////////////////////////
+
+  /** specify an input stream as the source for this parse */
+  public Parse setInputStream(InputStream inputStream) {
+    this.streamInput = new InputStreamInput(inputStream);
+    return this;
+  }
+
+  /** specify a URL as the source for this parse */
+  public Parse setUrl(URL url) {
+    this.streamInput = new UrlStreamInput(url);
+    return this;
+  }
+
+  /** specify a file as the source for this parse */
+  public Parse setFile(File file) {
+    this.streamInput = new FileStreamInput(file);
+    return this;
+  }
+
+  /** specify the classLoader to be used for resource input 
+   * (this is optional) */
+  public Parse setClassLoader(ClassLoader classLoader) {
+    this.classLoader = classLoader;
+    return this;
+  }
+
+  /** specify a resource as the source for this parse */
+  public Parse setResource(String resource) {
+    this.streamInput = new ResourceStreamInput(resource, classLoader);
+    return this;
+  }
+
+  /** specify an XML string as the source for this parse */
+  public Parse setString(String xmlString) {
+    this.streamInput = new StringStreamInput(xmlString);
+    return this;
+  }
+
+  /** specify a {@link StreamInput} as the source for this parse */
+  public Parse setStreamSource(StreamInput streamInput) {
+    this.streamInput = streamInput;
+    return this;
+  }
+
+  /** specify an InputStream as the source for this parse */
+  public Parse setInputSource(InputSource inputSource) {
+    this.inputSource = inputSource;
+    return this;
+  }
+
+  /** normally the Document Object Model is created during the 
+   * parse execution, but providing a document can be convenient when 
+   * the DOM is already available and only the walking of the 
+   * DOM needs to be done by the parser.  If the document 
+   * is provide, building the DOM from a source is skipped. */
+  public Parse setDocument(Document document) {
+    this.document = document;
+    return this;
+  }
+
+  /** provides the result of this parse operation. */
+  public Parse setDocumentObject(Object object) {
+    this.documentObject = object;
+    return this;
+  }
+
+  // retrieving input source //////////////////////////////////////////////////
+  
+  protected InputSource getInputSource() {
+    if (inputSource!=null) {
+      return inputSource;
+    }
+
+    if (streamInput!=null) {
+      inputStream = streamInput.openStream();
+      return new InputSource(inputStream);
+    }
+    
+    addProblem("no source specified to parse");
+    return null;
+  }
+
+  // parse execution //////////////////////////////////////////////////////////
+  
+  /** perform the actual parse operation with the specified input source. */
+  public Parse execute() {
+    parser.execute(this);
+    return this;
+  }
+
+  // problems /////////////////////////////////////////////////////////////////
+
+  /** part of {@link ErrorHandler} to capture XML parsing problems. */
+  public void error(SAXParseException e) {
+    addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_ERROR);
+  }
+
+  /** part of {@link ErrorHandler} to capture XML parsing problems. */
+  public void fatalError(SAXParseException e) {
+    addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_ERROR);
+  }
+  /** part of {@link ErrorHandler} to capture XML parsing problems. */
+  public void warning(SAXParseException e) {
+    addXmlValidationProblem(e, ProblemImpl.TYPE_XML_VALIDATION_WARNING);
+  }
+
+  protected void addXmlValidationProblem(SAXParseException e, String type) {
+    ProblemImpl problem = new ProblemImpl(e.getMessage(), e, type);
+    problem.setLine(e.getLineNumber());
+    problem.setColumn(e.getColumnNumber());
+    addProblem(problem);
+  }
+
+  /** throws an exception with appropriate message in case the parse contains 
+   * errors or fatal errors.  This method also logs the problems with severity
+   * 'warning'. */
+  public Parse checkProblems(String description) {
+    if (hasProblems()) {
+      String errorMsg = "problems during parse of "+description+":"+getProblemsText();
+      log.info(errorMsg);
+      if (errorMsg!=null) {
+        throw new JbpmException(errorMsg);
+      }
+    }
+    return this;
+  }
+
+  // contextual objects ///////////////////////////////////////////////////////
+
+  /** push a contextual object on the stack of this parse. */
+  public Parse pushObject(Object object) {
+    if (objectStack==null) {
+      objectStack = new Stack<Object>();
+    }
+    objectStack.push(object);
+    return this;
+  }
+
+  /** remove a contextual object from the stack. */
+  public Object popObject() {
+    if (objectStack!=null) {
+      return objectStack.pop();
+    }
+    return null;
+  }
+
+  /** look up the top contextual object from the stack. */
+  public Object peekObject() {
+    if (objectStack!=null) {
+      return objectStack.peek();
+    }
+    return null;
+  }
+  
+  /** search a contextual object in the stack by type. */
+  public <T> T findObject(Class<T> clazz) {
+    if ( (objectStack!=null)
+         && (! objectStack.isEmpty())
+       ) {
+      ListIterator<Object> listIter = objectStack.listIterator(objectStack.size());
+      while (listIter.hasPrevious()) {
+        Object object = listIter.previous();
+        if (object!=null) {
+          if (clazz.isAssignableFrom(object.getClass())) {
+            return (T) object;
+          }
+        }
+      }
+      return null;
+    }
+    return null;
+  }
+  
+  // getters //////////////////////////////////////////////////////////////////
+
+  /** the result of this parse operation. */
+  public Object getDocumentObject() {
+    return documentObject;
+  }
+  /** the Document Object Model (DOM). */
+  public Document getDocument() {
+    return document;
+  }
+  /** the ClassLoader used to resolve input resources. */
+  public ClassLoader getClassLoader() {
+    return classLoader;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,544 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.util.UrlEntity;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/** makes typical usage of JAXP more convenient, adds a binding framework, 
+ * entity resolution and error handling.
+ * 
+ * <h2>Purpose</h2>
+ * <p>This is a base parser for the common pattern where first JAXP is used
+ * to parse xml into a Document Object Model (DOM), and then, this DOM is
+ * examined to build a domain model object. The main purpose of this parser 
+ * is to serve as a base class for implementing such parsers and to provide 
+ * a more convenient API for working with JAXP.
+ * </p>
+ * 
+ * <p>A {@link Parser} is a thread safe object.  For each parse operation, a 
+ * new {@link Parse} object is created with method {@link #createParse()}.  
+ * Then the parse object is used to specify the input source, execute the 
+ * parse operation and extract the results. 
+ * </p>
+ * 
+ * <p>{@link Binding}s capture parsing of a certain element type. This way,
+ * the parser becomes more modular and customizable.
+ * </p>
+ * 
+ * <p>{@link Entity Entities} are schema's that specify the grammar of the 
+ * XML files that are parsed by the parser. 
+ * </p>
+ * 
+ * <h2>API Usage</h2>
+ * <p>Parsers can be customized by inheritance (that will be covered below), 
+ * but a parser can also be used as is:
+ * </p>
+ *
+ * <pre><i> 1 </i>|   static Parser parser = new Parser();
+ *<i> 2 </i>| 
+ *<i> 3 </i>|   void someMethod() {
+ *<i> 4 </i>|     MyDomainObject mdo = (MyDomainObject) parser
+ *<i> 5 </i>|             .createParse()
+ *<i> 6 </i>|             .setString(myXmlString)
+ *<i> 7 </i>|             .execute()
+ *<i> 8 </i>|             .checkProblems()
+ *<i> 9 </i>|             .getDocumentObject();
+ *<i>10 </i>|   }
+ * </pre>
+ * 
+ * <p><b>line 1</b> shows that a single parser can be used for all threads as 
+ * the parser is maintained in a static member field.
+ * </p>
+ *
+ * <p><b>line 5</b> shows that a new parse operation is always started with 
+ * the {@link #createParse()} operation.  The {@link Parse} object that is 
+ * returned will maintain all data that is related to that single parse 
+ * operation. 
+ * </p>
+ *
+ * <p><b>line 6</b> shows how a simple XML string can be provided as the input 
+ * source for the parse operation.  Alternative methods to specify the input 
+ * source are {@link Parse#setFile(java.io.File)}, 
+ * {@link Parse#setInputStream(java.io.InputStream)}, 
+ * {@link Parse#setInputSource(InputSource)},
+ * {@link Parse#setUrl(java.net.URL)} and
+ * {@link Parse#setStreamSource(StreamInput)}. 
+ * </p>
+ *
+ * <p><b>line 7</b> shows how the execution of the parse is performed.  The 
+ * input source will be read, the resulting Document Object Model (DOM) will 
+ * be walked and potentially problems are produced in the parse.
+ * </p>
+ *
+ * <p><b>line 8</b> shows how an exception can be thrown in case of an error.
+ * The parse execution itself tries to keep parsing as much as possible to 
+ * provide the developer with as much feedback as possible in one parse cycle.
+ * The {@link Parse#getProblems() problems} are silently captured in the parse
+ * object.  If an exception is thrown by 
+ * {@link #Parse#checkProblems(String, Parse)}, it will contain a report of 
+ * all the parsing problems.  Alternatively, the {@link Parse#hasProblems() problems
+ * in the parse object} could be examined directly without the need for an exception. 
+ * </p>
+ *
+ * <p><b>line 9</b> shows how the result of the parse operation is extracted 
+ * from the parse object.  
+ * </p>
+ * 
+ * <h2 id="binding">Binding</h2>
+ * <p>Bindings are the link between a certain type of element in your XML document
+ * and the corresponding java object in your domain model.</p>
+ *
+ * <p>A parser can be configured with a set of {@link Binding}s.  Each {@link Binding}
+ * knows how to transform a dom element of a given tagName to the corresponding Java
+ * object.  {@link Bindings} has a notion of binding categories.  For example, activities
+ * and actions can be seen as different categories in jPDL.
+ * </p>
+ *
+ * <p>The purpose of bindings is to make certain elements in the parsing configurable.
+ * E.g. in jPDL, the main structure of the document is fixed.  But activity types can be
+ * added dynamically.
+ * </p>
+ *
+ * <p>The current {@link Bindings} implementation only supports matching of an
+ * element with a {@link Binding} based on tagName.  If you want to take other things
+ * into account (e.g. when you want to differentiate between elements of the same
+ * tagName with a different attribute value), you can create a specialized
+ * {@link Bindings} class.</p>
+ *
+ * <p>Bindings are added by tagName, but they have to be looked up by element.  That is
+ * to support more specialized bindings implementations that match an element with a
+ * binding on more information then just the tagName.  In that case, a specialized subclass of
+ * {@link Binding} should be created and the method {@link #getBinding(Element, String)} and
+ * constructor {@link Bindings#Bindings(Bindings)} should be provided
+ * with the more specialized matching behaviour.
+ * </p>
+ *
+ * <h2 id="objectstack">Object stack</h2>
+ * <p>When implementing {@link Binding}s, you might want to make use of the
+ * contextual object stack that is provided on the {@link Parse}.  The
+ * {@link Binding} implementations can maintain Java objects on that stack
+ * that are being created.
+ * </p>
+ *
+ * <p>E.g. you could push the ProcessDefinition element onto the object stack while it
+ * is being parsed like this:
+ * </p>
+ *
+ * <pre>public class MyProcessBinding implements Binding {
+ *
+ *   public Object parse(Element element, Parse parse, Parser parser) {
+ *     <i>// instantiate the object for this binding</i>
+ *     MyProcess myProcess = new MyProcess();
+ *
+ *     <i>// collect all the child elements of element</i>
+ *     List<Element> elements = XmlUtil.elements(element);
+ *
+ *     <i>// push my processDefinition onto the object stack</i>
+ *     parse.pushObject(myProcess);
+ *     try {
+ *
+ *       for (Element activityElement: elements) {
+ *         // parse the child elements with the bindings in category "activity"
+ *         parseElement(activityElement, parse, "activity");
+ *       }
+ *     } finally {
+ *       // make sure my processDefinition is popped.
+ *       parse.popObject();
+ *     }
+ *     return myProcess;
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>Then, activity bindings might access the processDefinition like this:
+ * </p>
+ *
+ * <pre>public class MyNodeBinding implements Binding {
+ *
+ *   public Object parse(Element element, Parse parse, Parser parser) {
+ *     <i>// instantiate the object for this binding</i>
+ *     MyNode myNode = new MyNode();
+ *
+ *     <i>// add the activity to the processDefinition</i>
+ *     MyProcess myProcess = parse.findObject(MyProcess.class);
+ *     myProcess.addNode(myNode);
+ *     myNode.setMyProcess(myProcess);
+ *
+ *     return myNode;
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>A parser implementation will typically have a static Bindings object that
+ * is leveraged in all parser objects.   To customize bindings for a such a parser
+ * be sure to make a deep copy with {@link Bindings#Bindings(Bindings)} before
+ * you start adding more bindings to the specialized parser.  Otherwise the
+ * base parser's bindings will be updated as well.
+ * </p>
+ * 
+ * <h2 id="buildingcustomparsers">Building custom parsers</h2>
+ * 
+ * <p>This parser is build for inheritance.   
+ * Overriding method {@link #parseDocumentElement(Element, Parse)} can be an easy 
+ * way to start writing your own logic on walking the Document Object Model (DOM).
+ * Such customizations can still be combined with the usage of 
+ * <a href="#binding">bindings</a>.
+ * </p>
+ * 
+ * <h2 id="entityresolving">Entity resolving</h2>
+ * <p>A parser can be configured with a set of entities with the
+ * {@link #addEntity(String, Entity)} method.  The {@link UrlEntity} has
+ * a convenience method to build entities from resources
+ * {@link UrlEntity#UrlEntity(String, ClassLoader)}.
+ * </p>
+ *
+ * <p>When a document builder is created, the default implementation of the
+ * {@link #setEntityResolver(DocumentBuilder)} will set this parser as the entity resolver.
+ * The implementation method of {@link EntityResolver} ({@link #resolveEntity(String, String)}
+ * will use the added {@link Entity}s to try and find a match based on the
+ * publicId.  If one is found, the {@link Entity} inputSource is returned, otherwise
+ * the systemId is used.
+ * </p>
+ *
+ * <p>This class is intended to be used with aggregation as well as inheritence.
+ * </p>
+ *
+ * @author Tom Baeyens
+ */
+public class Parser {
+
+  private static Log log = Log.getLog(Parser.class.getName());
+
+  protected SAXParserFactory saxParserFactory;
+  protected String[] schemaResources;
+  
+  protected DocumentBuilderFactory documentBuilderFactory = null;
+  
+  protected Bindings bindings = null;
+  protected ClassLoader classLoader = null;
+
+  /** the default parser */
+  public Parser() {
+    initialize();
+  }
+
+  /** creates a new Parser with bindings that can be maintained statically in
+   * specialized subclasses of Parser. */
+  public Parser(Bindings bindings) {
+    initialize();
+    this.bindings = bindings;
+  }
+
+  /** creates a new Parser with bindings and entities that can be maintained statically
+   * in specialized subclasses of Parser.
+   * @deprecated entities should be replaced by {@link #setSchemaResources(List)} */
+  public Parser(Bindings bindings, Map<String, Entity> entities) {
+    initialize();
+    this.bindings = bindings;
+  }
+  
+  // initialization ///////////////////////////////////////////////////////////
+
+  public void initialize() {
+    initializeSaxParserFactory();
+    initializeDocumentBuilderFactory();
+  }
+
+  public void initializeDocumentBuilderFactory() {
+    documentBuilderFactory = DocumentBuilderFactory.newInstance();
+  }
+
+  public void initializeSaxParserFactory() {
+    saxParserFactory = SAXParserFactory.newInstance();
+  }
+
+  // document builder methods /////////////////////////////////////////////////
+
+  /** customizable creation of a new document builder.  Used by 
+   * {@link #buildDom(Parse)}. */
+  protected DocumentBuilder createDocumentBuilder(Parse parse) {
+    try {
+      parse.documentBuilder = documentBuilderFactory.newDocumentBuilder();
+    } catch (Exception e) {
+      parse.addProblem("couldn't get new document builder", e);
+      return null;
+    }
+    parse.documentBuilder.setErrorHandler(parse);
+    return parse.documentBuilder;
+  }
+
+  // schema validation ////////////////////////////////////////////////////////
+  
+  public void setSchemaResources(List<String> resources) {
+    saxParserFactory.setValidating(true);
+    saxParserFactory.setNamespaceAware(true);
+
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    List<String> schemaLocations = new ArrayList<String>(resources.size()); 
+    for (String schemaResource: resources) {
+      URL schemaUrl = classLoader.getResource(schemaResource);
+      if (schemaUrl!=null) {
+        String schemaLocation = schemaUrl.toString();
+        log.debug("schema resource found: " + schemaResource);
+        schemaLocations.add(schemaLocation);
+      } else {
+        log.debug("skipping unavailble schema resource: " + schemaResource);
+      }
+    }
+    schemaResources = schemaLocations.toArray(new String[schemaLocations.size()]);
+  }
+
+  // bindings /////////////////////////////////////////////////////////////////
+
+  /** the handlers for specific element types */
+  public Bindings getBindings() {
+    return bindings;
+  }
+
+  /** set the handlers for specific element types */
+  public void setBindings(Bindings bindings) {
+    this.bindings = bindings;
+  }
+
+  /** the handler for the given element */
+  public Binding getBinding(Element element) {
+    return getBinding(element, null);
+  }
+
+  /** the handler for the given element limited to a given category */
+  public Binding getBinding(Element element, String category) {
+    return (bindings!=null ? bindings.getBinding(element, category) : null);
+  }
+
+  // runtime parsing methods //////////////////////////////////////////////////
+  
+  /** main method to start a new parse, check {@link Parse} for specifying 
+   * input, executing the parse and extracting the results. */
+  public Parse createParse() {
+    return new Parse(this);
+  }
+
+  /** builds a dom from the importedStreamSource and appends the child elements 
+   * of the document element to the destination element.  Problems are reported 
+   * in the importingParse. */
+  public void importStream(StreamInput importedStreamInput, Element destination, Parse importingParse) {
+    try {
+      // build the dom of the imported document
+      Parse importedParse = createParse();
+      importedParse.setStreamSource(importedStreamInput);
+      Document importedDocument = buildDom(importedParse);
+      
+      // loop over all the imported document elements 
+      Element importedDocumentElement = importedDocument.getDocumentElement();
+      for(Element e : XmlUtil.elements(importedDocumentElement)) {
+        // import the element into the destination element
+        destination.appendChild(destination.getOwnerDocument().importNode(e, true));
+      }
+      
+    } catch (Exception e) {
+      importingParse.addProblem("couldn't import "+importedStreamInput, e);
+    }
+  }
+
+  /** customizable parse execution */
+  protected void execute(Parse parse) {
+    try {
+      if (parse.document==null) {
+        parse.document = buildDom(parse);
+      }
+
+      // walk the dom tree
+      if (parse.document!=null) {
+        try {
+          // walk the dom tree
+          parseDocument(parse.document, parse);
+
+        } catch (Exception e) {
+          parse.addProblem("couldn't interpret the dom model: "+e.getMessage(), e);
+        }
+      }
+      
+    } finally {
+      if (parse.inputStream!=null) {
+        try {
+          parse.inputStream.close();
+        } catch (Exception e) {
+          parse.addProblem("couldn't close input stream", e);
+        }
+      }
+    }
+  }
+
+  protected Document buildDom(Parse parse) {
+    Document document = null;
+
+    try {
+      SAXParser saxParser = saxParserFactory.newSAXParser();
+      XMLReader xmlReader = saxParser.getXMLReader();
+      
+      try {
+        saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+      } catch (Exception e){
+        log.info("couldn't set schema language property", e);
+      }
+
+      if (schemaResources!=null) {
+        try {
+          saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaResources);
+        } catch (Exception e){
+          log.info("couldn't set schema source property", e);
+        }
+      }
+
+      try {
+        xmlReader.setFeature("http://apache.org/xml/features/validation/dynamic", true);
+      } catch (Exception e){
+        log.info("couldn't set dynamic validation feature", e);
+      }
+
+      DocumentBuilder documentBuilder = createDocumentBuilder(parse);
+      document = documentBuilder.newDocument();
+      parse.setDocument(document);
+
+      DomBuilder domBuilder = new DomBuilder();
+      domBuilder.setDocument(document);
+
+      xmlReader.setContentHandler(domBuilder);
+      xmlReader.setErrorHandler(parse);
+      
+      InputSource inputSource = parse.getInputSource(); 
+      xmlReader.parse(inputSource);
+
+    } catch (Exception e) {
+      parse.addProblem("couldn't parse xml document", e);
+    }
+
+    return document;
+  }
+
+
+  // Document Object Model walking ////////////////////////////////////////////
+
+  /** start of the DOM walk.
+   * 
+   * This method is used as part of 
+   * {@link #execute(Parse) the parse execution}.
+   * 
+   * This default implementation behaviour extracts the document element and 
+   * delegates to {@link #parseDocumentElement(Element, Parse)}.
+   *
+   * This method can be overridden for customized behaviour.
+   * 
+   * @return the object that is the result from parsing this document. */
+  public Object parseDocument(Document document, Parse parse) {
+    Object object = parseDocumentElement(document.getDocumentElement(), parse);
+    parse.documentObject = object;
+    return object;
+  }
+
+  /** parses the top level element in the document and produces the object that 
+   * is the result from the parsing. 
+   *
+   * @return the object that is the result from parsing this document element. */
+  public Object parseDocumentElement(Element documentElement, Parse parse) {
+    return parseElement(documentElement, parse);
+  }
+
+  /** parses an arbitrary element in the document with the first matching 
+   * binding found using any of the categories.
+   * 
+   * @return the object that is the result from parsing this element. */
+  public Object parseElement(Element element, Parse parse) {
+    return parseElement(element, parse, null);
+  }
+
+  /** parses an arbitrary element in the document based on the bindings in the 
+   * given category.
+   * 
+   * @param category is the category in which the tagName should be resolved to 
+   *   a {@link Binding}.  If category is null, all the categories will be 
+   *   scanned for an appropriate binding in random order.
+   * 
+   * @return the object that is the result from parsing this element. */
+  public Object parseElement(Element element, Parse parse, String category) {
+
+    Object object = null;
+    String tagName = XmlUtil.getTagLocalName(element);
+
+    Binding binding = getBinding(element, category);
+
+    if (binding!=null) {
+      object = binding.parse(element, parse, this);
+    } else {
+      parse.addProblem("no element parser for tag "+tagName+(category!=null ? " in category "+category : " in the default category"));
+    }
+
+    return object;
+  }
+
+  public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse) {
+    return parseArgs(argElements, parse, WireParser.CATEGORY_DESCRIPTOR);
+  }
+
+  public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse, String category) {
+    List<ArgDescriptor> args = null;
+    if (argElements!=null) {
+      if (argElements.size()>0) {
+        args = new ArrayList<ArgDescriptor>(argElements.size());
+      }
+      for (Element argElement: argElements) {
+        ArgDescriptor argDescriptor = new ArgDescriptor();
+        argDescriptor.setTypeName(XmlUtil.attribute(argElement, "type"));
+        Element descriptorElement = XmlUtil.element(argElement);
+        if (descriptorElement==null) {
+          parse.addProblem("arg must contain exactly one descriptor element out of "+bindings.getTagNames(category)+" as contents:"+XmlUtil.toString((Element) argElement.getParentNode()));
+        } else {
+          Descriptor descriptor = (Descriptor) parseElement(descriptorElement, parse, category);
+          argDescriptor.setDescriptor(descriptor);
+        }
+        args.add(argDescriptor);
+      }
+    }
+    return args;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemImpl.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.io.Serializable;
+
+import org.jbpm.Problem;
+import org.xml.sax.SAXParseException;
+
+/**
+ * a unification for an XML parsing errors and DOM interpretation problems, see also {@link Parser}.
+ * 
+ * See also <a href="./Parser.html#problems">'Problems'</a>
+ * @author Tom Baeyens
+ */
+public class ProblemImpl implements Serializable, Problem {
+  
+  private static final long serialVersionUID = 1L;
+
+  public static final String TYPE_ERROR = "error";
+  public static final String TYPE_WARNING = "warning";
+  public static final String TYPE_XML_VALIDATION_ERROR = "xml validation error";
+  public static final String TYPE_XML_VALIDATION_WARNING = "xml validation warning";
+
+  String resource;
+  String type;
+  Integer line;
+  Integer column;
+  String msg;
+  Throwable cause;
+
+  public ProblemImpl(String msg, Exception e, String type) {
+    this.type = type;
+    this.msg = msg;
+    this.cause = e;
+    if (e instanceof SAXParseException) {
+      SAXParseException spe = (SAXParseException) e;
+      this.resource = spe.getPublicId();
+      this.line = spe.getLineNumber();
+      this.column = spe.getColumnNumber();
+    }
+  }
+
+  public Throwable getCause() {
+    return cause;
+  }
+  public void setCause(Throwable cause) {
+    this.cause = cause;
+  }
+  public int getColumn() {
+    return column;
+  }
+  public void setColumn(int columnNumber) {
+    this.column = columnNumber;
+  }
+  public int getLine() {
+    return line;
+  }
+  public void setLine(int lineNumber) {
+    this.line = lineNumber;
+  }
+  public String getMsg() {
+    return msg;
+  }
+  public void setMsg(String msg) {
+    this.msg = msg;
+  }
+  public String getResource() {
+    return resource;
+  }
+  public void setResource(String resource) {
+    this.resource = resource;
+  }
+  public String getSeverity() {
+    return type;
+  }
+  public void setSeverity(String severity) {
+    this.type = severity;
+  }
+  
+  public String toString() {
+    StringBuffer text = new StringBuffer();
+    text.append(type);
+    text.append(": ");
+    text.append(msg);
+    text.append(" ");
+    
+    if ((line!=null) || (column!=null) || (resource!=null)) {
+      text.append("[");
+      if (line!=-1) {
+        text.append("line="+line+" ");
+      }
+      
+      if (column!=-1) {
+        text.append("column="+column+" ");
+      }
+      
+      if (resource!=null) {
+        text.append("resource="+resource+" ");
+      }
+      text.append("]");
+    }
+
+    if (cause!=null) {
+      text.append(": " + cause.toString());
+    }
+    
+    return text.toString(); 
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.xml;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+
+
+/** list of problems.  Base class for {@link Parse} 
+ * and {@link DeploymentImpl}.
+ * 
+ * @author Tom Baeyens
+ */
+public class ProblemList implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  private static final String NEWLINE = System.getProperty("line.separator");
+
+  private static final Log log = Log.getLog(ProblemList.class.getName());
+
+  protected List<ProblemImpl> problems = null;
+
+  /** all problems encountered */
+  public List<Problem> getProblems() {
+    if (problems==null) {
+      return Collections.EMPTY_LIST;
+    }
+    return (List) problems;
+  }
+
+  /** to add parsing problems during XML parsing and DOM walking. */
+  public void addProblem(ProblemImpl problem) {
+    if (problems==null) {
+      problems = new ArrayList<ProblemImpl>();
+    }
+    problems.add(problem);
+  }
+
+  /** add a problem with {@link ProblemImpl#TYPE_ERROR the default severity}.*/
+  public void addProblem(String msg) {
+    addProblem(msg, null);
+  }
+
+  /** add a problem with an exception cause and 
+   * {@link ProblemImpl#TYPE_ERROR the default severity}.*/
+  public void addProblem(String msg, Exception e) {
+    addProblem(msg, e, ProblemImpl.TYPE_ERROR);
+  }
+
+  /** adds a problem with {@link ProblemImpl#TYPE_WARNING severity warning}.*/
+  public void addWarning(String msg) {
+    addWarning(msg, null);
+  }
+
+  /** adds a problem with {@link ProblemImpl#TYPE_WARNING severity warning}
+   * and an exception as the cause.*/
+  public void addWarning(String msg, Exception e) {
+    addProblem(msg, e, ProblemImpl.TYPE_WARNING);
+  }
+
+  /** adds a problem given message, exception cause and severity */
+  public void addProblem(String msg, Exception e, String severity) {
+    addProblem(new ProblemImpl(msg, e, severity));
+  }
+
+  /** indicates presence of problems */
+  public boolean hasProblems() {
+    return ((problems != null) && (problems.size() > 0));
+  }
+
+  /** allows to provide the list object that should be used to 
+   * capture the parsing problems. */
+  public void setProblems(List<Problem> problems) {
+    this.problems = (List)problems;
+  }
+  
+  
+  public String getProblemsText() {
+    if (problems!=null) {
+      StringBuffer errorBuffer = null;
+      StringBuffer warningBuffer = null;
+      for (Problem p : getProblems()) {
+        if (p.getSeverity().equals(ProblemImpl.TYPE_ERROR)) {
+          if (errorBuffer==null) {
+            errorBuffer = new StringBuffer();
+            errorBuffer.append("errors:");
+            errorBuffer.append(NEWLINE);
+          }
+          errorBuffer.append(NEWLINE);
+          errorBuffer.append("  ");
+          errorBuffer.append(p.toString());
+        } else {
+          if (warningBuffer==null) {
+            warningBuffer = new StringBuffer();
+            warningBuffer.append("warnings:");
+            warningBuffer.append(NEWLINE);
+          }
+          warningBuffer.append(NEWLINE);
+          warningBuffer.append("  ");
+          warningBuffer.append(p.toString());
+        }
+      }
+      if (errorBuffer!=null) {
+        if (warningBuffer!=null) {
+          errorBuffer.append(NEWLINE);
+          errorBuffer.append(warningBuffer.toString());
+        }
+        return errorBuffer.toString(); 
+      }
+      if (warningBuffer!=null) {
+        warningBuffer.append(NEWLINE);
+        return warningBuffer.toString();
+      }
+    }
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/AutomaticActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/AutomaticActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements ActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/DisplaySource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/DisplaySource.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/DisplaySource.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+
+public class DisplaySource implements EventListener {
+  
+  private static final long serialVersionUID = 1L;
+
+  public void notify(EventListenerExecution execution) {
+    System.out.println("leaving "+execution.getEventSource());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLn.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLn.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLn.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.OpenExecution;
+
+public class PrintLn implements ActivityBehaviour, EventListener {
+
+  private static final long serialVersionUID = 1L;
+
+  String message;
+  
+  public PrintLn() {
+  }
+
+  public PrintLn(String message) {
+    this.message = message;
+  }
+
+  public void execute(ActivityExecution execution) {
+    perform(execution);
+  }
+
+  public void notify(EventListenerExecution execution) throws Exception {
+    perform(execution);
+  }
+  
+  public void perform(OpenExecution execution) {
+    System.out.println(message);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLnBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLnBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/PrintLnBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import org.jbpm.pvm.internal.builder.ActivityBehaviourBuilder;
+import org.jbpm.pvm.internal.builder.ActivityBuilder;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class PrintLnBuilder extends ActivityBehaviourBuilder {
+
+  PrintLn printLn = new PrintLn();
+  
+  public PrintLnBuilder(ActivityBuilder activityBuilder) {
+    super(activityBuilder);
+    activity.setBehaviour(printLn);
+  }
+  
+  public PrintLnBuilder message(String message) {
+    printLn.message = message;
+    return this;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsole.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsole.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsole.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/** wraps the System.out and buffers the println(String) invocations
+ * so that those can be asserted */
+public class TestConsole extends PrintStream {
+  
+  public List<String> lines = new ArrayList<String>();
+
+  public TestConsole() {
+    super(System.out);
+  }
+
+  public static TestConsole install() {
+    TestConsole testConsole = new TestConsole();
+    System.setOut(testConsole);
+    return testConsole;
+  }
+
+  public static void uninstall() {
+    if (System.out instanceof TestConsole) {
+      TestConsole testConsole = (TestConsole) System.out;
+      System.setOut((PrintStream) testConsole.out);
+    }
+  }
+
+  public void println(String x) {
+    lines.add(x);
+    super.println(x);
+  }
+
+  public String getLine(int i) {
+    return lines.get(i);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsoleTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsoleTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/TestConsoleTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestConsoleTestCase extends BaseJbpmTestCase {
+
+  protected TestConsole testConsole;
+  
+  public void setUp() throws Exception {
+    super.setUp();
+    testConsole = TestConsole.install();
+  }
+
+  public void tearDown() throws Exception {
+    TestConsole.uninstall();
+    testConsole = null;
+    super.tearDown();
+  }
+
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, 
+                     String signalName, 
+                     Map<String, Object> parameters) {
+    execution.setVariables(parameters);
+    execution.take(signalName);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/BuilderTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/BuilderTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/BuilderTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.builder;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BuilderTest extends BaseJbpmTestCase {
+  
+  public void testBuilderProcessDefinitionProperties() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .key("k")
+      .version(5)
+      .description("the description")
+    .endProcess();
+    
+    assertEquals("p", processDefinition.getName());
+    assertEquals("k", processDefinition.getKey());
+    assertEquals(5, processDefinition.getVersion());
+    assertEquals("the description", processDefinition.getDescription());
+  }
+
+  public void testBuilderInitialActivity() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startActivity("start")
+        .initial()
+      .endActivity()
+    .endProcess();
+ 
+    ActivityImpl start = (ActivityImpl) processDefinition.getInitial();
+    assertNotNull(start);
+    assertEquals("start", start.getName());
+  }
+
+  public void testBuilderActivityProperties() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startActivity("start")
+        .startBehaviour(TestBehaviourBuilder.class)
+          .testActivityProperty("some cfg value")
+        .endBehaviour()
+      .endActivity()
+    .endProcess();
+    
+    ActivityImpl decisionActivity = (ActivityImpl) processDefinition.getActivity("start");
+    assertNotNull(decisionActivity);
+    assertEquals("start", decisionActivity.getName());
+
+    TestActivity testActivity = (TestActivity) decisionActivity.getBehaviour();
+    assertEquals("some cfg value", testActivity.getTestActivityProperty());
+  }
+
+  public void testBuilderMultipleOutgoingFlows() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startActivity("x")
+        .transition("a")
+        .transition("b", "to b")
+        .startFlow("c")
+          .name("to c")
+        .endFlow()
+        .transition("x")
+      .endActivity()
+      .startActivity("a")
+        .transition("b")
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    ActivityImpl decisionActivity = (ActivityImpl) processDefinition.getActivity("x");
+    assertNotNull(decisionActivity);
+    
+    List<Transition> outgoingTransitions = decisionActivity.getOutgoingTransitions();
+    assertNotNull(outgoingTransitions);
+    assertEquals("expected 4 transitions: "+outgoingTransitions, 4, outgoingTransitions.size());
+    Transition toA = outgoingTransitions.get(0);
+    assertNull(toA.getName());
+    assertEquals("a", toA.getDestination().getName());
+    
+    Transition toB = outgoingTransitions.get(1);
+    assertEquals("to b", toB.getName());
+    assertEquals("b", toB.getDestination().getName());
+
+    Transition toC = outgoingTransitions.get(2);
+    assertEquals("to c", toC.getName());
+    assertEquals("c", toC.getDestination().getName());
+    
+    Transition toX = outgoingTransitions.get(3);
+    assertNull(toX.getName());
+    assertEquals("x", toX.getDestination().getName());
+    
+    Map<String, Transition> outgoingTransitionsMap = decisionActivity.getOutgoingTransitionsMap();
+    assertSame(toA, outgoingTransitionsMap.get(null));
+    assertSame(toB, outgoingTransitionsMap.get("to b"));
+    assertSame(toC, outgoingTransitionsMap.get("to c"));
+    
+    ActivityImpl b = (ActivityImpl) processDefinition.getActivity("b");
+    List<Transition> incomingTransitions = b.getIncomingTransitions();
+    assertNotNull(incomingTransitions);
+    assertEquals("x", incomingTransitions.get(0).getSource().getName());
+    assertEquals("a", incomingTransitions.get(1).getSource().getName());
+    assertEquals(2, incomingTransitions.size());
+  }
+
+  public void testBuilderCompositeActivities() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("1")
+        .startActivity("1.1")
+          .transition("1.2.1", "to onedottwodotone")
+        .endActivity()
+        .startActivity("1.2")
+          .startActivity("1.2.1")
+          .endActivity()
+          .startActivity("1.2.2")
+            .initial()
+            .transition("1", "to one")
+          .endActivity()
+          .startActivity("1.2.3")
+          .endActivity()
+        .endActivity()
+        .startActivity("1.3")
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    ActivityImpl activity1 = (ActivityImpl) processDefinition.findActivity("1");
+    ActivityImpl activity11 = (ActivityImpl) processDefinition.findActivity("1.1");
+    ActivityImpl activity12 = (ActivityImpl) processDefinition.findActivity("1.2");
+    ActivityImpl activity121 = (ActivityImpl) processDefinition.findActivity("1.2.1");
+    ActivityImpl activity122 = (ActivityImpl) processDefinition.findActivity("1.2.2");
+    ActivityImpl activity123 = (ActivityImpl) processDefinition.findActivity("1.2.3");
+    ActivityImpl activity13 = (ActivityImpl) processDefinition.findActivity("1.3");
+    
+    assertNotNull(activity1);
+    assertNotNull(activity11);
+    assertNotNull(activity12);
+    assertNotNull(activity121);
+    assertNotNull(activity122);
+    assertNotNull(activity123);
+    assertNotNull(activity13);
+
+    assertSame(activity1, processDefinition.getActivities().get(0));
+    assertEquals(1, processDefinition.getActivities().size());
+
+    assertSame(activity11, activity1.getActivities().get(0));
+    assertSame(activity12, activity1.getActivities().get(1));
+    assertSame(activity13, activity1.getActivities().get(2));
+    assertEquals(3, activity1.getActivities().size());
+
+    assertSame(activity121, activity12.getActivities().get(0));
+    assertSame(activity122, activity12.getActivities().get(1));
+    assertSame(activity123, activity12.getActivities().get(2));
+    assertEquals(3, activity12.getActivities().size());
+    
+    assertSame(processDefinition, activity1.getParent());
+    assertSame(activity1, activity11.getParent());
+    assertSame(activity1, activity12.getParent());
+    assertSame(activity12, activity121.getParent());
+    assertSame(activity12, activity122.getParent());
+    assertSame(activity12, activity123.getParent());
+    assertSame(activity1, activity13.getParent());
+    
+    assertSame(activity1, activity122.getOutgoingTransition("to one").getDestination());
+    assertSame(activity121, activity11.getOutgoingTransition("to onedottwodotone").getDestination());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.builder;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestActivity implements ActivityBehaviour {
+  
+  private static final long serialVersionUID = 1L;
+
+  String testActivityProperty;
+
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+
+  public String getTestActivityProperty() {
+    return testActivityProperty;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestBehaviourBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestBehaviourBuilder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/builder/TestBehaviourBuilder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.builder;
+
+import org.jbpm.pvm.internal.builder.ActivityBehaviourBuilder;
+import org.jbpm.pvm.internal.builder.ActivityBuilder;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestBehaviourBuilder extends ActivityBehaviourBuilder {
+  
+  TestActivity testActivity = new TestActivity();
+
+  public TestBehaviourBuilder(ActivityBuilder activityBuilder) {
+    super(activityBuilder);
+    activity.setBehaviour(testActivity);
+  }
+
+  public TestBehaviourBuilder testActivityProperty(String testActivityProperty) {
+    testActivity.testActivityProperty = testActivityProperty;
+    return this;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class BasicEnvironmentTest extends BaseJbpmTestCase {
+  
+  public void testBasicEnvironmentOperation() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object name='a' class='"+Object.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object name='b' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Object firstA;
+    Object firstB;
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      firstA = environment.get("a");
+      assertNotNull(firstA);
+      firstB = environment.get("b");
+      assertNotNull(firstB);
+      
+      // in the same environment, the same a and b should be returned.
+      assertSame(firstA, environment.get("a"));
+      assertSame(firstB, environment.get("b"));
+      
+    } finally {
+      environment.close();
+    }
+
+    environment = environmentFactory.openEnvironment();
+    try {
+      // the same a should have been stored in the process-engine cache
+      assertSame(firstA, environment.get("a"));
+      // a new b should be created because we're in a new environment
+      Object secondB = environment.get("b");
+      assertNotNull(secondB);
+      assertNotSame(firstB, secondB);
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testCurrentEnvironment(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        " <process-engine/>" +
+        " <environment/>" +
+        "</jbpm-configuration>"
+    );
+    assertNotNull(environmentFactory);
+    
+    Environment outerEnvironment = environmentFactory.openEnvironment();
+    try {
+      assertSame(outerEnvironment, Environment.getCurrent());
+      
+      Environment innerEnvironment = environmentFactory.openEnvironment();
+      try {
+        assertSame(innerEnvironment, Environment.getCurrent());
+        
+      } finally {
+        innerEnvironment.close();
+      }
+
+      assertSame(outerEnvironment, Environment.getCurrent());
+
+    } finally {
+      outerEnvironment.close();
+    }
+    environmentFactory.close();
+  }
+  
+
+  public void testUnexistingElement() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object name='a' class='"+Object.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object name='b' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertNull(environment.get("unexisting element"));
+      
+    } finally {
+      environment.close();
+    }
+  }
+  
+  public void testNoBlockEnvironment(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        " <process-engine/>" +
+        "</jbpm-configuration>"
+    );
+    assertNotNull(environmentFactory);
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Context environmentFactoryCtxt = environment.getContext(Context.CONTEXTNAME_PROCESS_ENGINE);
+      assertNotNull(environmentFactoryCtxt);
+      Context environmentCtxt = environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environmentCtxt);
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+  
+  public void testNoApplicationEnvironment(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        " <environment/>" +
+        "</jbpm-configuration>"
+    );
+    assertNotNull(environmentFactory);
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertNotNull(environment);
+      Context environmentFactoryCtxt = environment.getContext(Context.CONTEXTNAME_PROCESS_ENGINE);
+      assertNotNull(environmentFactoryCtxt);
+      Context environmentCtxt = environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environmentCtxt);
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+  
+  public void testEmptyEnvironment(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment/>"
+    );
+    assertNotNull(environmentFactory);
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertNotNull(environment);
+      Context environmentFactoryCtxt = environment.getContext(Context.CONTEXTNAME_PROCESS_ENGINE);
+      assertNotNull(environmentFactoryCtxt);
+      Context environmentCtxt = environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environmentCtxt);
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentClassLoaderTest extends BaseJbpmTestCase {
+  
+  public static class TestClassLoader extends ClassLoader {
+  }
+
+  public void testDefaultClassLoader() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment />"
+    );
+
+    ClassLoader original = Thread.currentThread().getContextClassLoader();
+    ClassLoader testClassLoader = new TestClassLoader();
+    Thread.currentThread().setContextClassLoader(testClassLoader);
+    try {
+
+      Environment environment = environmentFactory.openEnvironment();
+      try {
+        assertSame(testClassLoader, environment.getClassLoader());
+      } finally {
+        environment.close();
+      }
+
+    } finally {
+      Thread.currentThread().setContextClassLoader(original);
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentSearchOrderTest extends BaseJbpmTestCase
+{
+
+  public void testEnvironmentDefaultSearchOrder() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='process-engine-a' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='environment-a' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      assertEquals("environment-a", environment.get("a"));
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnvironmentGivenSearchOrder() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='process-engine-a' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='environment-a' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      // only search in context 'process-engine' and then in 'environment'
+      String[] searchOrder = new String[]{"process-engine", "environment"};
+      assertEquals("process-engine-a", environment.get("a", searchOrder));
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnvironmentGivenSearchOrderUnexistingObject() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='process-engine-a' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='environment-a' />" +
+      "    <string name='b' value='environment-b' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      // only search in context 'process-engine'
+      String[] searchOrder = new String[]{"process-engine"};
+      assertNull(environment.get("b", searchOrder));
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+
+  public void testEnvironmentDefaultSearchOrderWithAddedContext() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='process-engine-a' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='environment-a' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      // create a new context
+      WireDefinition wireDefinition = WireParser.parseXmlString(
+        "<objects>" +
+        "  <string name='a' value='added-a' />" +
+        "</objects>"
+      );
+      WireContext addedContext = new WireContext(wireDefinition, "added");
+      
+      // add the new context to the enviromnent
+      environment.addContext(addedContext);
+      
+      // see what you find under key a in the default search order
+      assertEquals("added-a", environment.get("a"));
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnvironmentGivenSearchOrderWithAddedContext() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='process-engine-a' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='environment-a' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      // create a new context
+      WireDefinition wireDefinition = WireParser.parseXmlString(
+        "<objects>" +
+        "  <string name='a' value='added-a' />" +
+        "</objects>"
+      );
+      WireContext addedContext = new WireContext(wireDefinition, "added");
+      
+      // add the new context to the enviromnent
+      environment.addContext(addedContext);
+      
+      // only search in context 'process-engine' and 'environment'
+      String[] searchOrder = new String[]{"transaction", "process-engine"};
+      assertEquals("environment-a", environment.get("a", searchOrder));
+      
+    } finally {
+      environment.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentTypeLookupTest extends BaseJbpmTestCase {
+
+  public static class A {
+  }
+  
+  public void testApplicationTypeLookup() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object class='"+A.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='a' value='distraction' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      A a = environment.get(A.class);
+      assertNotNull(a);
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+
+  public void testBlockTypeLookup() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='distraction' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object class='"+A.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      A a = environment.get(A.class);
+      assertNotNull(a);
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+
+  public void testNonExistingTypeLookup() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <string name='a' value='A' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <string name='b' value='B' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      assertNull(environment.get(Thread.class));
+      
+    } finally {
+      environment.close();
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NestedEnvironmentTest extends BaseJbpmTestCase {
+  
+  public void testNestedEnvironments() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object name='a' class='"+Object.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object name='b' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      
+      assertSame(environment, Environment.getCurrent());
+      
+      Object outerB = environment.get("b");
+      assertNotNull(outerB);
+      
+      Environment nestedEnvironment = environmentFactory.openEnvironment();
+      try {
+        assertSame(nestedEnvironment, Environment.getCurrent());
+        assertNotSame(outerB, nestedEnvironment.get("b"));
+        
+      } finally {
+        nestedEnvironment.close();
+      }
+
+      assertSame(environment, Environment.getCurrent());
+      assertSame(outerB, environment.get("b"));
+      
+    } finally {
+      environment.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.eventlistener;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.activities.AutomaticActivity;
+import org.jbpm.pvm.activities.PrintLn;
+import org.jbpm.pvm.activities.TestConsoleTestCase;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+public class EventListenerTest extends TestConsoleTestCase {
+
+  public void testEventListener() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+      .startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .startEvent(Event.END)
+          .listener(new PrintLn("leaving a"))
+          .listener(new PrintLn("second message while leaving a"))
+        .endEvent()
+        .startFlow("b")
+          .listener(new PrintLn("taking transition"))
+        .endFlow()
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .startEvent(Event.START)
+          .listener(new PrintLn("entering b"))
+        .endEvent()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals("leaving a", testConsole.getLine(0));
+    assertEquals("second message while leaving a", testConsole.getLine(1));
+    assertEquals("taking transition", testConsole.getLine(2));
+    assertEquals("entering b", testConsole.getLine(3));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.eventlistener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.activities.DisplaySource;
+import org.jbpm.pvm.activities.TestConsole;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+public class EventPropagationTest extends BaseJbpmTestCase {
+
+  TestConsole testConsole;
+  
+  public void setUp() {
+    testConsole = TestConsole.install();
+  }
+
+  public void tearDown() {
+    TestConsole.uninstall();
+    testConsole = null;
+  }
+
+  public void testEventPropagationEnabled() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startActivity("composite")
+        .startEvent(Event.END)
+          .listener(new DisplaySource(), true)
+        .endEvent()
+        .startActivity("a", new WaitState())
+          .initial()
+          .transition("b")
+        .endActivity()
+        .startActivity("b", new WaitState())
+          .transition("c")
+        .endActivity()
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    List<String> expectedLines = new ArrayList<String>(); 
+    assertEquals(expectedLines, testConsole.lines);
+    
+    execution.signal();
+    
+    expectedLines.add("leaving activity(a)");
+    assertEquals(expectedLines, testConsole.lines);
+    
+    execution.signal();
+
+    expectedLines.add("leaving activity(b)");
+    expectedLines.add("leaving activity(composite)");
+    assertEquals(expectedLines, testConsole.lines);
+  }
+  
+  public void testEventPropagationDefaultDisabled() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startActivity("composite")
+        .startEvent(Event.END)
+          .listener(new DisplaySource())
+        .endEvent()
+        .startActivity("a", new WaitState())
+          .initial()
+          .transition("b")
+        .endActivity()
+        .startActivity("b", new WaitState())
+          .transition("c")
+        .endActivity()
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    List<String> expectedLines = new ArrayList<String>(); 
+    assertEquals(expectedLines, testConsole.lines);
+    
+    execution.signal();
+    
+    assertEquals(expectedLines, testConsole.lines);
+    
+    execution.signal();
+
+    expectedLines.add("leaving activity(composite)");
+    assertEquals(expectedLines, testConsole.lines);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.executionmode.embedded;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+
+/** a activity behaviour implementation that records its execution and then 
+ * just proceeds.
+ *  
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements ActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.executionmode.embedded;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EmbeddedExecutionModeTest extends BaseJbpmTestCase {
+
+  SessionFactory sessionFactory;
+  Session session;
+  Transaction transaction;
+
+  public void testLoanApprove() {
+    Configuration configuration = new Configuration();
+    configuration.configure("org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml");
+    sessionFactory = configuration.buildSessionFactory();
+
+    startTransaction();
+
+    Loan loan = new Loan("john doe", 234.0);
+    session.save(loan);
+    assertEquals("evaluate", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("evaluate", loan.getState());
+    loan.approve();
+    assertEquals("archive", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("archive", loan.getState());
+    loan.archiveComplete();
+    assertEquals("end", loan.getState());
+
+    commitTransaction();
+  }
+  
+  public void testLoanReject() {
+    Configuration configuration = new Configuration();
+    configuration.configure("org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml");
+    sessionFactory = configuration.buildSessionFactory();
+
+    startTransaction();
+
+    Loan loan = new Loan("john doe", 234.0);
+    session.save(loan);
+    assertEquals("evaluate", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("evaluate", loan.getState());
+    loan.reject();
+    assertEquals("end", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("end", loan.getState());
+  }
+
+
+  void newTransaction() {
+    commitTransaction();
+    startTransaction();
+  }
+
+  void startTransaction() {
+    session = sessionFactory.openSession();
+    transaction = session.beginTransaction();
+  }
+
+  void commitTransaction() {
+    transaction.commit();
+    session.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.executionmode.embedded;
+
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Loan {
+
+  /** the loan process definition as a static resource */
+  private static final ClientProcessDefinition processDefinition = createLoanProcess();
+  
+  private static ClientProcessDefinition createLoanProcess() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("loan")
+      .startActivity("submit loan request", new AutomaticActivity())
+        .initial()
+        .transition("evaluate")
+      .endActivity()
+      .startActivity("evaluate", new WaitState())
+        .transition("wire money", "approve")
+        .transition("end", "reject")
+      .endActivity()
+      .startActivity("wire money", new AutomaticActivity())
+        .transition("archive")
+      .endActivity()
+      .startActivity("archive", new WaitState())
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    return processDefinition;
+  }
+
+  /** exposes the process definition to the execution hibernate type */
+  private static ClientProcessDefinition getProcessDefinition() {
+    return processDefinition;
+  }
+
+  long dbid;
+  String customer;
+  double amount;
+  ClientExecution execution;
+  
+  /** constructor for persistence */
+  protected Loan() {
+  }
+
+  public Loan(String customer, double amount) {
+    this.customer = customer;
+    this.amount = amount;
+    this.execution = processDefinition.startProcessInstance();
+  }
+
+  public void approve() {
+    execution.signal("approve");
+  }
+
+  public void reject() {
+    execution.signal("reject");
+  }
+
+  public void archiveComplete() {
+    execution.signal();
+  }
+
+  public String getState() {
+    return execution.getActivityName();
+  }
+  
+  // getters //////////////////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getCustomer() {
+    return customer;
+  }
+  public double getAmount() {
+    return amount;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.executionmode.embedded;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+  
+  public WaitState() {
+  }
+
+  public void execute(ActivityExecution execution) throws Exception {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+    execution.take(signalName);
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.executionmode.object;
+
+import junit.framework.TestCase;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.activities.AutomaticActivity;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+public class ObjectExecutionModeTest extends TestCase {
+
+  
+  public void testObjectExecutionMode(){
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("loan")
+      .startActivity("submit loan request", new AutomaticActivity())
+        .initial()
+        .transition("evaluate")
+      .endActivity()
+      .startActivity("evaluate", new WaitState())
+        .transition("wire money", "approve")
+        .transition("end", "reject")
+      .endActivity()
+      .startActivity("wire money", new AutomaticActivity())
+        .transition("archive")
+      .endActivity()
+      .startActivity("archive", new WaitState())
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals("evaluate", execution.getActivityName());
+    
+    execution.signal("approve");
+    
+    execution.signal();
+    assertEquals("end", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.db.model;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CommentDbTest extends EnvironmentDbTestCase {
+
+  public void testComment()
+  {
+    Date now = new Date();
+
+    CommentImpl comment = new CommentImpl();
+    comment.setUserId("me");
+    comment.setTime(now);
+    comment.setMessage("hi");
+
+    comment = reload(comment, CommentImpl.class);
+
+    assertEquals("me", comment.getUserId());
+    assertEquals(now, comment.getTime());
+    assertEquals("hi", comment.getMessage());
+  }
+
+  public void testCommentDelete()
+  {
+    CommentImpl comment = new CommentImpl();
+    comment.setUserId("me");
+    comment.setMessage("hi");
+
+    comment = reload(comment, CommentImpl.class);
+
+    DbSession dbSession = environment.get(DbSession.class);
+    dbSession.delete(comment);
+
+    newTransaction();
+
+    dbSession = environment.get(DbSession.class);
+    assertNull(dbSession.get(CommentImpl.class, comment.getDbid()));
+  }
+
+  public void testCommentReplies()
+  {
+    CommentImpl comment = new CommentImpl();
+    comment.setMessage("how are you");
+    Comment reply = comment.createComment("good, thank you");
+    reply.createComment("you're welcome");
+    reply = comment.createComment("and how are you");
+    reply.createComment("i'm also fine");
+
+    comment = reload(comment, CommentImpl.class);
+
+    assertEquals("how are you", comment.getMessage());
+
+    List<Comment> replies = comment.getComments();
+
+    Comment reply0 = replies.get(0);
+    assertEquals("good, thank you", reply0.getMessage());
+
+    List<Comment> replyReplies = reply0.getComments();
+
+    Comment reply00 = replyReplies.get(0);
+    assertEquals("you're welcome", reply00.getMessage());
+
+    Comment reply1 = replies.get(1);
+    assertEquals("and how are you", reply1.getMessage());
+
+    replyReplies = reply1.getComments();
+
+    Comment reply10 = replyReplies.get(0);
+    assertEquals("i'm also fine", reply10.getMessage());
+  }
+
+  public void testCommentDeleteReplies()
+  {
+    CommentImpl comment = new CommentImpl();
+    comment.setMessage("how are you");
+    comment.createComment("good, thank you");
+    comment.createComment("and how are you");
+    comment.createComment("also fine a suppose");
+
+    comment = reload(comment, CommentImpl.class);
+
+    comment.removeComment(comment.getComments().get(1));
+
+    comment = reload(comment, CommentImpl.class);
+
+    assertEquals("good, thank you", comment.getComments().get(0).getMessage());
+    assertEquals("also fine a suppose", comment.getComments().get(1).getMessage());
+    assertEquals(2, comment.getComments().size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,614 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.db.model;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Guillaume Porcher
+ * 
+ */
+public class ProcessCacheDbTest extends EnvironmentDbTestCase {
+
+  /**
+   * Defines a simple process: only activities. persists it.
+   */
+  public void testCacheProcessDefinitionActivities() {
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+    pvmDbSession.save(processDefinition);
+
+    environment.get(Session.class).flush();
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+
+    // only the processDefinition.getDbid() is carried over from the previous
+    // transaction
+
+    pvmDbSession = environment.get(PvmDbSession.class);
+    processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+    List<Activity> activities = processDefinition.getActivities();
+    assertNotNull(activities);
+
+    Activity a = activities.get(0);
+    assertEquals("a", a.getName());
+    assertTrue(a.getActivities().isEmpty());
+
+    Activity b = activities.get(1);
+    assertEquals("b", b.getName());
+    assertTrue(b.getActivities().isEmpty());
+
+    Activity c = activities.get(2);
+    assertEquals("c", c.getName());
+    assertTrue(c.getActivities().isEmpty());
+
+    assertEquals(3, activities.size());
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+
+    beginCacheTest(); // /////////////
+    // only the processDefinition.getDbid() is carried over from the previous
+    // transaction
+
+    pvmDbSession = environment.get(PvmDbSession.class);
+    processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+    activities = processDefinition.getActivities();
+    assertNotNull(activities);
+
+    a = activities.get(0);
+    assertEquals("a", a.getName());
+    assertTrue(a.getActivities().isEmpty());
+
+    b = activities.get(1);
+    assertEquals("b", b.getName());
+    assertTrue(b.getActivities().isEmpty());
+
+    c = activities.get(2);
+    assertEquals("c", c.getName());
+    assertTrue(c.getActivities().isEmpty());
+
+    assertEquals(3, activities.size());
+
+    endCacheTest(); // ///////////
+  }
+
+  /**
+   * Defines a simple process: only activities. persists it.
+   */
+  public void testCacheProcessDefinitionActivityOrder() {
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    DbSession dbSession = environment.get(DbSession.class);
+    dbSession.save(processDefinition);
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+
+    // only the processDefinition.getDbid() is carried over from the previous
+    // transaction
+
+    dbSession = environment.get(DbSession.class);
+    processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+    List<Activity> activities = processDefinition.getActivities();
+    assertNotNull(activities);
+    assertEquals(3, activities.size());
+
+    Activity a = activities.get(0);
+    assertEquals("a", a.getName());
+    assertEquals(0, a.getActivities().size());
+
+    Activity b = activities.get(1);
+    assertEquals("b", b.getName());
+    assertEquals(0, b.getActivities().size());
+
+    Activity c = activities.get(2);
+    assertEquals("c", c.getName());
+    assertEquals(0, c.getActivities().size());
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+
+    dbSession = environment.get(DbSession.class);
+    processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+
+    activities = processDefinition.getActivities();
+    assertNotNull(activities);
+
+    // Pass a to the end -> activity order is "b,c,a"
+    activities.add(activities.remove(0));
+
+    activities = processDefinition.getActivities();
+    b = activities.get(0);
+    assertEquals("b", b.getName());
+    assertEquals(0, b.getActivities().size());
+
+    c = activities.get(1);
+    assertEquals("c", c.getName());
+    assertEquals(0, c.getActivities().size());
+
+    a = activities.get(2);
+    assertEquals("a", a.getName());
+    assertEquals(0, a.getActivities().size());
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+
+    dbSession = environment.get(DbSession.class);
+    processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+    activities = processDefinition.getActivities();
+    assertNotNull(activities);
+    assertEquals(3, activities.size());
+
+    b = activities.get(0);
+    assertEquals("b", b.getName());
+    assertEquals(0, b.getActivities().size());
+
+    c = activities.get(1);
+    assertEquals("c", c.getName());
+    assertEquals(0, c.getActivities().size());
+
+    a = activities.get(2);
+    assertEquals("a", a.getName());
+    assertEquals(0, a.getActivities().size());
+
+    newTransaction(); // ///////////////////////////////////////////////////////
+    beginCacheTest(); // /////////
+
+    dbSession = environment.get(DbSession.class);
+    processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(processDefinition);
+    activities = processDefinition.getActivities();
+    assertNotNull(activities);
+    assertEquals(3, activities.size());
+
+    b = activities.get(0);
+    assertEquals("b", b.getName());
+    assertEquals(0, b.getActivities().size());
+
+    c = activities.get(1);
+    assertEquals("c", c.getName());
+    assertEquals(0, c.getActivities().size());
+
+    a = activities.get(2);
+    assertEquals("a", a.getName());
+    assertEquals(0, a.getActivities().size());
+
+    endCacheTest(); // //////////////
+  }
+
+  /**
+   * Test processDefinition initial activity
+   */
+  public void testCacheProcessDefinitionInitialActivity() {
+    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
+    ActivityImpl activity = (ActivityImpl) processDefinition.createActivity();
+    activity.setName("initial activity");
+    activity.setDescription("very important activity");
+
+    processDefinition.setInitial(activity);
+
+    environment.get(DbSession.class).save(processDefinition);
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    ProcessDefinitionImpl p = environment.get(DbSession.class).get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    ActivityImpl n = p.getInitial();
+
+    assertNotNull(n);
+    assertEquals(activity.getName(), n.getName());
+    assertEquals(activity.getDescription(), n.getDescription());
+
+    newTransaction(); // /////////////////////////////////////////////////////
+    beginCacheTest(); // //////////
+
+    p = environment.get(DbSession.class).get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    n = p.getInitial();
+
+    assertNotNull(n);
+    assertEquals(activity.getName(), n.getName());
+    assertEquals(activity.getDescription(), n.getDescription());
+
+    endCacheTest(); // ///////////
+  }
+
+  /**
+   * Defines a simple process: only nested activities. persists it, reloads it and
+   * tries to access the nested activities
+   */
+  public void testCacheProcessDefinitionNestedActivities() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .startActivity("a")
+        .endActivity()
+        .startActivity("b")
+        .endActivity()
+        .startActivity("c")
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    persistenceSession.save(processDefinition);
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    persistenceSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    assertNotSame(processDefinition, p);
+    p.getActivities();
+    assertNotNull(p.getInitial());
+    assertNotNull(p.getInitial().getActivity("a"));
+    assertNotNull(p.getInitial().getActivity("b"));
+    assertNotNull(p.getInitial().getActivity("c"));
+
+    newTransaction(); // /////////////////////////////////////////////////////
+    beginCacheTest(); // /////////
+
+    persistenceSession = (DbSession) environment.get(DbSession.class);
+
+    p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    assertNotSame(processDefinition, p);
+    p.getActivities();
+    assertNotNull(p.getInitial());
+    assertNotNull(p.getInitial().getActivity("a"));
+    assertNotNull(p.getInitial().getActivity("b"));
+    assertNotNull(p.getInitial().getActivity("c"));
+
+    endCacheTest(); // ////////
+  }
+
+  /**
+   * Defines a process with nested activities with nested activities. persists it, reloads
+   * it and tries to access the nested activities
+   */
+  public void testCacheProcessDefinitionNestedNestedActivities() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .startActivity("a")
+          .startActivity("aa")
+          .endActivity()
+          .startActivity("ab")
+          .endActivity()
+          .startActivity("ac")
+          .endActivity()
+        .endActivity()
+        .startActivity("b")
+          .startActivity("ba")
+          .endActivity()
+          .startActivity("bb")
+          .endActivity()
+          .startActivity("bc")
+          .endActivity()
+        .endActivity()
+        .startActivity("c")
+          .startActivity("ca")
+          .endActivity()
+          .startActivity("cb")
+          .endActivity()
+          .startActivity("cc")
+          .endActivity()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    persistenceSession.save(processDefinition);
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    persistenceSession = (DbSession) environment.get(DbSession.class);
+
+    ClientProcessDefinition p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    assertNotSame(processDefinition, p);
+    p.getActivities();
+    assertNotNull(p.getInitial());
+    Activity n = p.getInitial().getActivity("a");
+    assertNotNull(n);
+    List<Activity> l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("aa", l.get(0).getName());
+    assertEquals("ab", l.get(1).getName());
+    assertEquals("ac", l.get(2).getName());
+
+    n = p.getInitial().getActivity("b");
+    assertNotNull(n);
+    l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("ba", l.get(0).getName());
+    assertEquals("bb", l.get(1).getName());
+    assertEquals("bc", l.get(2).getName());
+
+    n = p.getInitial().getActivity("c");
+    assertNotNull(n);
+    l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("ca", l.get(0).getName());
+    assertEquals("cb", l.get(1).getName());
+    assertEquals("cc", l.get(2).getName());
+
+    newTransaction(); // /////////////////////////////////////////////////////
+    beginCacheTest(); // //////////
+
+    persistenceSession = (DbSession) environment.get(DbSession.class);
+
+    p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+    assertNotNull(p);
+
+    assertNotSame(processDefinition, p);
+    p.getActivities();
+    assertNotNull(p.getInitial());
+    n = p.getInitial().getActivity("a");
+    assertNotNull(n);
+    l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("aa", l.get(0).getName());
+    assertEquals("ab", l.get(1).getName());
+    assertEquals("ac", l.get(2).getName());
+
+    n = p.getInitial().getActivity("b");
+    assertNotNull(n);
+    l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("ba", l.get(0).getName());
+    assertEquals("bb", l.get(1).getName());
+    assertEquals("bc", l.get(2).getName());
+
+    n = p.getInitial().getActivity("c");
+    assertNotNull(n);
+    l = n.getActivities();
+    assertEquals(3, l.size());
+    assertEquals("ca", l.get(0).getName());
+    assertEquals("cb", l.get(1).getName());
+    assertEquals("cc", l.get(2).getName());
+
+    endCacheTest(); // ///////////
+  }
+
+  /**
+   * Defines a simple process: only activities and default transitions. persists it,
+   * reloads and navigates through the transitions.
+   */
+  public void testCacheDefaultTransition() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .transition("a")
+      .endActivity()
+      .startActivity("a")
+        .transition("b")
+      .endActivity()
+      .startActivity("b")
+        .transition("c")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    persistenceSession.save(processDefinition);
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    DbSession testSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    Activity activity = p.getInitial();
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+
+    assertEquals(p.getActivity("a"), activity);
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+
+    assertEquals(p.getActivity("b"), activity);
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+    assertEquals(p.getActivity("c"), activity);
+    assertNull(activity.getDefaultTransition());
+
+    newTransaction(); // /////////////////////////////////////////////////////
+    beginCacheTest(); // //////////
+
+    testSession = (DbSession) environment.get(DbSession.class);
+
+    p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    activity = p.getInitial();
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+
+    assertEquals(p.getActivity("a"), activity);
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+
+    assertEquals(p.getActivity("b"), activity);
+    assertNotNull(activity.getDefaultTransition());
+    assertEquals(activity, activity.getDefaultTransition().getSource());
+
+    activity = activity.getDefaultTransition().getDestination();
+    assertEquals(p.getActivity("c"), activity);
+    assertNull(activity.getDefaultTransition());
+
+    endCacheTest(); // //////////
+  }
+
+  /**
+   * Defines a simple process: only activities and transitions. persists it, reloads
+   * and navigates through the transitions.
+   */
+  public void testCacheTwoTransitions() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .transition("a")
+        .transition("b")
+      .endActivity()
+      .startActivity("a")
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+    .endProcess();
+
+    persistenceSession.save(processDefinition);
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    DbSession testSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    Activity activity = p.getInitial();
+    List<Transition> l = activity.getOutgoingTransitions();
+    assertNotNull(l);
+    assertEquals(2, l.size());
+
+    Activity a = p.getActivity("a");
+    assertNotNull(a);
+
+    Activity b = p.getActivity("b");
+    assertNotNull(b);
+
+    assertEquals(activity, l.get(0).getSource());
+    assertEquals(activity, l.get(1).getSource());
+
+    assertEquals(a, l.get(0).getDestination());
+    assertEquals(b, l.get(1).getDestination());
+
+    List<Transition> la = a.getIncomingTransitions();
+    assertNotNull(la);
+    assertEquals(1, la.size());
+    assertSame(la.get(0), l.get(0));
+
+    List<Transition> lb = b.getIncomingTransitions();
+    assertNotNull(lb);
+    assertEquals(1, lb.size());
+    assertSame(lb.get(0), l.get(1));
+
+    newTransaction(); // /////////////////////////////////////////////////////
+
+    testSession = (DbSession) environment.get(DbSession.class);
+    beginCacheTest(); // ///////
+
+    p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    activity = p.getInitial();
+    l = activity.getOutgoingTransitions();
+    assertNotNull(l);
+    assertEquals(2, l.size());
+
+    a = p.getActivity("a");
+    assertNotNull(a);
+
+    b = p.getActivity("b");
+    assertNotNull(b);
+
+    assertEquals(activity, l.get(0).getSource());
+    assertEquals(activity, l.get(1).getSource());
+
+    assertEquals(a, l.get(0).getDestination());
+    assertEquals(b, l.get(1).getDestination());
+
+    la = a.getIncomingTransitions();
+    assertNotNull(la);
+    assertEquals(1, la.size());
+    assertSame(la.get(0), l.get(0));
+
+    lb = b.getIncomingTransitions();
+    assertNotNull(lb);
+    assertEquals(1, lb.size());
+    assertSame(lb.get(0), l.get(1));
+
+    endCacheTest(); // ////////
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,486 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.db.model;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.model.Event;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
+import org.jbpm.pvm.internal.model.ExceptionHandlerImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Charles Souillard
+ * @author Guillaume Porcher
+ */
+public class ProcessDefinitionDbTest extends EnvironmentDbTestCase {
+
+  public void testProcessDefinitionBasicProperties() {
+    Date deploymentTime = new Date();
+
+    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
+    processDefinition.setName("name");
+    processDefinition.setDescription("description");
+    processDefinition.setVersion(3);
+    processDefinition.setDeploymentTime(deploymentTime);
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertEquals("name", processDefinition.getName());
+    assertEquals("description", processDefinition.getDescription());
+    assertEquals(3, processDefinition.getVersion());
+    assertEquals(deploymentTime, processDefinition.getDeploymentTime());
+  }
+
+  public void testProcessDefinitionActivities() {
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertNotNull(processDefinition);
+    List<Activity> activities = processDefinition.getActivities();
+    assertNotNull(activities);
+
+    Activity a = activities.get(0);
+    assertEquals("a", a.getName());
+    assertTrue(a.getActivities().isEmpty());
+
+    Activity b = activities.get(1);
+    assertEquals("b", b.getName());
+    assertTrue(b.getActivities().isEmpty());
+
+    Activity c = activities.get(2);
+    assertEquals("c", c.getName());
+    assertTrue(c.getActivities().isEmpty());
+
+    assertEquals(3, activities.size());
+  }
+
+  public void testInitialActivity() {
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+      .startActivity("c")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    Activity initial = processDefinition.getInitial();
+    assertNotNull(initial);
+
+    // check that the initial activity is still in the list of activities
+    assertSame(processDefinition.getActivity("a"), initial);
+    // check that the initial activity is not two times in the list of activities
+    assertEquals(3, processDefinition.getActivities().size());
+  }
+
+  public void testProcessDefinitionNestedActivities() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+    
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("top")
+        .initial()
+        .startActivity("a")
+        .endActivity()
+        .startActivity("b")
+          .startActivity("b1")
+          .endActivity()
+          .startActivity("b2")
+          .endActivity()
+          .startActivity("b3")
+          .endActivity()
+        .endActivity()
+        .startActivity("c")
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertNotNull(processDefinition);
+    Activity initial = processDefinition.getInitial();
+    assertNotNull(initial);
+    assertEquals(initial, processDefinition.getActivity("top"));
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    List<Activity> activities = processDefinition.getActivities();
+    assertNotNull(activities);
+    assertEquals("expected size 1.  activity list was: " + activities.toString(), 1, activities.size());
+    Activity top = activities.get(0);
+    assertNotNull(top);
+
+    activities = top.getActivities();
+    assertNotNull(activities);
+    assertEquals("expected size 3.  activity list was: " + activities.toString(), 3, activities.size());
+    assertEquals("a", activities.get(0).getName());
+    assertEquals("b", activities.get(1).getName());
+    assertEquals("c", activities.get(2).getName());
+
+    activities = processDefinition.getActivity("top").getActivity("b").getActivities();
+    assertNotNull(activities);
+    assertEquals("expected size 3.  activity list was: " + activities.toString(), 3, activities.size());
+    assertEquals("b1", activities.get(0).getName());
+    assertEquals("b2", activities.get(1).getName());
+    assertEquals("b3", activities.get(2).getName());
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    Activity activity = processDefinition.findActivity("b2");
+    assertNotNull(activity);
+    assertEquals("b", activity.getParent().getName());
+    assertEquals("top", activity.getParent().getParent().getName());
+  }
+
+  public void testDefaultTransition() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+        .transition("a")
+        .transition("b", "tob")
+        .transition("c", "toc")
+      .endActivity()
+      .startActivity("b")
+        .transition("a", "toa")
+        .transition("b")
+        .transition("c", "toc")
+      .endActivity()
+      .startActivity("c")
+        .transition("c")
+      .endActivity()
+      .startActivity("d")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertEquals("a", processDefinition.getActivity("a").getDefaultTransition().getDestination().getName());
+    assertEquals("a", processDefinition.getActivity("b").getDefaultTransition().getDestination().getName());
+    assertEquals("c", processDefinition.getActivity("c").getDefaultTransition().getDestination().getName());
+    assertNull(processDefinition.getActivity("d").getDefaultTransition());
+  }
+
+  public void testTwoTransitionsWithoutAName() {
+    DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(persistenceSession);
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .transition("a")
+        .transition("b")
+      .endActivity()
+      .startActivity("a")
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertNotNull(processDefinition);
+    Activity activity = processDefinition.getInitial();
+    List<Transition> l = activity.getOutgoingTransitions();
+    assertNotNull(l);
+    assertEquals(2, l.size());
+
+    Activity a = processDefinition.getActivity("a");
+    assertNotNull(a);
+
+    Activity b = processDefinition.getActivity("b");
+    assertNotNull(b);
+
+    assertEquals(activity, l.get(0).getSource());
+    assertEquals(activity, l.get(1).getSource());
+
+    assertEquals(a, l.get(0).getDestination());
+    assertEquals(b, l.get(1).getDestination());
+
+    List<Transition> la = a.getIncomingTransitions();
+    assertNotNull(la);
+    assertEquals(1, la.size());
+    assertSame(la.get(0), l.get(0));
+
+    List<Transition> lb = b.getIncomingTransitions();
+    assertNotNull(lb);
+    assertEquals(1, lb.size());
+    assertSame(lb.get(0), l.get(1));
+  }
+
+  public void testEventsOnProcessDefinition() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startEvent(Event.START)
+        .listener("one")
+        .listener("two")
+      .endEvent()
+      .startEvent(Event.END)
+        .listener("three")
+        .listener("four")
+      .endEvent()
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    EventImpl event = processDefinition.getEvent(Event.START);
+    List<EventListenerReference> listenerReferences = event.getListenerReferences();
+    assertEquals("one", listenerReferences.get(0).getExpression());
+    assertEquals("two", listenerReferences.get(1).getExpression());
+
+    event = processDefinition.getEvent(Event.END);
+    listenerReferences = event.getListenerReferences();
+    assertEquals("three", listenerReferences.get(0).getExpression());
+    assertEquals("four", listenerReferences.get(1).getExpression());
+  }
+
+  public void testEventsOnActivity() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+        .startEvent(Event.START)
+          .listener("one")
+          .listener("two")
+        .endEvent()
+        .startEvent(Event.END)
+          .listener("three")
+          .listener("four")
+        .endEvent()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    EventImpl event = processDefinition.getActivity("a").getEvent(Event.START);
+    List<EventListenerReference> listenerReferences = event.getListenerReferences();
+    assertEquals("one", listenerReferences.get(0).getExpression());
+    assertEquals("two", listenerReferences.get(1).getExpression());
+
+    event = processDefinition.getActivity("a").getEvent(Event.END);
+    listenerReferences = event.getListenerReferences();
+    assertEquals("three", listenerReferences.get(0).getExpression());
+    assertEquals("four", listenerReferences.get(1).getExpression());
+  }
+
+  public void testListenersOnTransition() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+        .startFlow("b")
+          .listener("one")
+          .listener("two")
+        .endFlow()
+      .endActivity()
+      .startActivity("b")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    EventImpl event = processDefinition.getActivity("a").getDefaultTransition().getEvent();
+    List<EventListenerReference> listenerReferences = event.getListenerReferences();
+    assertEquals("one", listenerReferences.get(0).getExpression());
+    assertEquals("two", listenerReferences.get(1).getExpression());
+  }
+
+  public void testExceptionHandlersOnProcessDefinition() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startExceptionHandler(IllegalArgumentException.class)
+        .listener("one")
+        .listener("two")
+      .endExceptionHandler()
+      .startExceptionHandler(RuntimeException.class)
+        .listener("three")
+        .listener("four")
+      .endExceptionHandler()
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getExceptionHandlers();
+
+    ExceptionHandlerImpl exceptionHandler = exceptionHandlers.get(0);
+    assertEquals(IllegalArgumentException.class.getName(), exceptionHandler.getExceptionClassName());
+    assertEquals("one", exceptionHandler.getEventListenerReferences().get(0).getExpression());
+    assertEquals("two", exceptionHandler.getEventListenerReferences().get(1).getExpression());
+
+    exceptionHandler = exceptionHandlers.get(1);
+    assertEquals(RuntimeException.class.getName(), exceptionHandler.getExceptionClassName());
+    assertEquals("three", exceptionHandler.getEventListenerReferences().get(0).getExpression());
+    assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
+  }
+
+  public void testExceptionHandlersOnActivity() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+        .startExceptionHandler(IllegalArgumentException.class)
+          .listener("one")
+          .listener("two")
+        .endExceptionHandler()
+        .startExceptionHandler(RuntimeException.class)
+          .listener("three")
+          .listener("four")
+        .endExceptionHandler()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getActivity("a").getExceptionHandlers();
+
+    ExceptionHandlerImpl exceptionHandler = exceptionHandlers.get(0);
+    assertEquals(IllegalArgumentException.class.getName(), exceptionHandler.getExceptionClassName());
+    assertEquals("one", exceptionHandler.getEventListenerReferences().get(0).getExpression());
+    assertEquals("two", exceptionHandler.getEventListenerReferences().get(1).getExpression());
+
+    exceptionHandler = exceptionHandlers.get(1);
+    assertEquals(RuntimeException.class.getName(), exceptionHandler.getExceptionClassName());
+    assertEquals("three", exceptionHandler.getEventListenerReferences().get(0).getExpression());
+    assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
+  }
+
+  public void testProcessDynamicProperties() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .property("key1", "val1")
+      .property("key2", "val2")
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    assertEquals("val1", processDefinition.getProperty("key1"));
+    assertEquals("val2", processDefinition.getProperty("key2"));
+  }
+
+  public void testActivityDynamicProperties() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity()
+        .initial()
+        .property("key1", "val1")
+        .property("key2", "val2")
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    Activity activity = processDefinition.getInitial();
+    assertEquals("val1", activity.getProperty("key1"));
+    assertEquals("val2", activity.getProperty("key2"));
+  }
+
+  public void testTransitionDynamicProperties() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a")
+        .initial()
+        .startFlow("a")
+          .property("key1", "val1")
+          .property("key2", "val2")
+        .endFlow()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    Transition transition = processDefinition.getInitial().getDefaultTransition();
+    assertEquals("val1", transition.getProperty("key1"));
+    assertEquals("val2", transition.getProperty("key2"));
+  }
+
+  public void testEventDynamicProperties() {
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startEvent(Event.START)
+        .property("key1", "val1")
+        .property("key2", "val2")
+      .endEvent()
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    EventImpl event = processDefinition.getEvent(Event.START);
+    assertEquals("val1", event.getProperty("key1"));
+    assertEquals("val2", event.getProperty("key2"));
+  }
+  
+  public void testProcessDefinitionAttachments() {
+    
+    if (true) {
+      System.err.print("FIXME: JBPM-1972 finish process attachments");
+      return;
+    }
+    
+    StringBuffer text = new StringBuffer();
+    for (int i=0; i<500; i++) {
+      text.append("This is a lot of bytes! ");
+    }
+    byte[] bytes = text.toString().getBytes();
+    
+    ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .attachment("msgbytes", bytes)
+    .endProcess();
+
+    processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
+
+    byte[] retrievedBytes = processDefinition.getAttachment("msgbytes");
+    // assertTrue(Arrays.equals(bytes, retrievedBytes));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.db.model;
+
+import org.hibernate.SessionFactory;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SessionFactoryDbTest extends EnvironmentDbTestCase
+{
+
+  public void testSessionFactory()
+  {
+    environment.get(SessionFactory.class);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,600 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.db.model;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
+import org.jbpm.pvm.internal.model.WireProperties;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ByteDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.CharacterDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.DoubleDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.FloatDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.NullDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.SetDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ShortDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor;
+import org.jbpm.pvm.internal.wire.operation.FieldOperation;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Guillaume Porcher
+ * 
+ * This class uses process annotations to test wire descriptors
+ * persistence
+ */
+public class WireDbTest extends EnvironmentDbTestCase {
+
+  public void testCharacterDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    CharacterDescriptor descriptor = new CharacterDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue('c');
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (CharacterDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals('c', descriptor.construct(null));
+  }
+
+  public void testByteDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    ByteDescriptor descriptor = new ByteDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue((byte) 6);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (ByteDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals((byte) 6, descriptor.construct(null));
+  }
+
+  public void testClassDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    ClassDescriptor descriptor = new ClassDescriptor();
+    descriptor.setName("n");
+    descriptor.setClassName(EventImpl.class.getName());
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (ClassDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(EventImpl.class, WireContext.create(descriptor));
+  }
+
+  public void testDoubleDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    DoubleDescriptor descriptor = new DoubleDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue(6.666);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (DoubleDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(6.666, descriptor.construct(null));
+  }
+
+  public void testFalseDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    FalseDescriptor descriptor = new FalseDescriptor();
+    descriptor.setName("n");
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (FalseDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(Boolean.FALSE, descriptor.construct(null));
+  }
+
+  public void testFloatDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    FloatDescriptor descriptor = new FloatDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue((float) 6.666);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (FloatDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals((float) 6.666, descriptor.construct(null));
+  }
+
+  public void testIntegerDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    IntegerDescriptor descriptor = new IntegerDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue(6);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (IntegerDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(6, descriptor.construct(null));
+  }
+
+  public void testLongDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    LongDescriptor descriptor = new LongDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue(6L);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (LongDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(6L, descriptor.construct(null));
+  }
+
+  public void testNullDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    NullDescriptor descriptor = new NullDescriptor();
+    descriptor.setName("n");
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (NullDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertNull(descriptor.construct(null));
+  }
+
+  public void testShortDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    ShortDescriptor descriptor = new ShortDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue((short) 6);
+
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (ShortDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals((short) 6, descriptor.construct(null));
+  }
+
+  public void testStringDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    StringDescriptor descriptor = new StringDescriptor();
+    descriptor.setName("n");
+    descriptor.setValue("s");
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (StringDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals("s", descriptor.construct(null));
+  }
+
+  public void testTrueDescriptor() {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    TrueDescriptor descriptor = new TrueDescriptor();
+    descriptor.setName("n");
+    dbSession.save(descriptor);
+
+    newTransaction();
+    dbSession = environment.get(DbSession.class);
+
+    descriptor = (TrueDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
+    assertEquals("n", descriptor.getName());
+    assertEquals(Boolean.TRUE, descriptor.construct(null));
+  }
+
+  public void testRefDescriptor() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    WireProperties configurations = new WireProperties();
+
+    StringDescriptor referencedDescriptor = new StringDescriptor();
+    referencedDescriptor.setName("referenced");
+    referencedDescriptor.setValue("text");
+    configurations.add(referencedDescriptor);
+
+    ReferenceDescriptor descriptor = new ReferenceDescriptor();
+    descriptor.setName("reference");
+    descriptor.setValue("referenced");
+    configurations.add(descriptor);
+
+    dbSession.save(configurations);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    configurations = dbSession.get(WireProperties.class, configurations.getDbid());
+
+    assertNotNull(configurations);
+    assertEquals("text", configurations.get("reference"));
+  }
+
+  /**
+   * Check that list descriptors are persisted
+   */
+  public void testListDescriptor() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    StringDescriptor stringD = new StringDescriptor();
+    stringD.setValue("value");
+
+    StringDescriptor string2D = new StringDescriptor();
+    string2D.setValue("value2");
+
+    List<Descriptor> listValues = new ArrayList<Descriptor>();
+    listValues.add(stringD);
+    listValues.add(string2D);
+
+    ListDescriptor listD = new ListDescriptor();
+    listD.setName("list");
+    listD.setValueDescriptors(listValues);
+    listD.setClassName(LinkedList.class.getName());
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(listD)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    List<String> result = (List<String>) p.getProperty("list");
+    assertNotNull(result);
+    assertEquals(2, result.size());
+    assertEquals("value", result.get(0));
+    assertEquals("value2", result.get(1));
+
+    assertTrue(result instanceof LinkedList);
+  }
+
+  /**
+   * Check that set descriptors are persisted
+   */
+  public void testSetDescriptor() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    StringDescriptor stringD = new StringDescriptor();
+    stringD.setValue("value");
+
+    StringDescriptor string2D = new StringDescriptor();
+    string2D.setValue("value2");
+
+    List<Descriptor> listValues = new ArrayList<Descriptor>();
+    listValues.add(stringD);
+    listValues.add(string2D);
+
+    SetDescriptor setD = new SetDescriptor();
+    setD.setName("set");
+    setD.setValueDescriptors(listValues);
+    setD.setClassName(TreeSet.class.getName());
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(setD)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    Set<String> result = (Set<String>) p.getProperty("set");
+    assertNotNull(result);
+    assertTrue(result.contains("value"));
+    assertTrue(result.contains("value2"));
+    assertEquals(2, result.size());
+
+    assertTrue(result instanceof TreeSet);
+  }
+
+  /**
+   * Check that map descriptors are persisted
+   */
+  public void testMapDescriptor() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    StringDescriptor keyD = new StringDescriptor();
+    keyD.setValue("key");
+
+    StringDescriptor key2D = new StringDescriptor();
+    key2D.setValue("key2");
+
+    StringDescriptor stringD = new StringDescriptor();
+    stringD.setValue("value");
+
+    StringDescriptor string2D = new StringDescriptor();
+    string2D.setValue("value2");
+
+    List<Descriptor> mapKeys = new ArrayList<Descriptor>();
+    mapKeys.add(keyD);
+    mapKeys.add(key2D);
+
+    List<Descriptor> mapValues = new ArrayList<Descriptor>();
+    mapValues.add(stringD);
+    mapValues.add(string2D);
+
+    MapDescriptor mapD = new MapDescriptor();
+    mapD.setName("map");
+    mapD.setValueDescriptors(mapValues);
+    mapD.setKeyDescriptors(mapKeys);
+    mapD.setClassName(TreeMap.class.getName());
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(mapD)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    Map<String, String> result = (Map<String, String>) p.getProperty("map");
+    assertNotNull(result);
+    assertEquals(2, result.size());
+    assertEquals("value", result.get("key"));
+    assertEquals("value2", result.get("key2"));
+
+    assertTrue(result instanceof TreeMap);
+  }
+
+  /**
+   * Check that map descriptors are persisted
+   */
+  public void testObjectDescriptor() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    ObjectDescriptor objDefault = new ObjectDescriptor();
+    objDefault.setName("objectByEmptyConstr");
+    objDefault.setClassName(Object.class.getName());
+
+    ObjectDescriptor objConstr = new ObjectDescriptor();
+    objConstr.setName("objectByConstr");
+    objConstr.setClassName(Integer.class.getName());
+
+    ArgDescriptor argObjConstr = new ArgDescriptor();
+    argObjConstr.setTypeName(int.class.getName());
+    IntegerDescriptor argObjConstrVal = new IntegerDescriptor();
+    argObjConstrVal.setValue(42);
+    argObjConstr.setDescriptor(argObjConstrVal);
+
+    objConstr.addArgDescriptor(argObjConstr);
+
+    ObjectDescriptor objStaticMethod = new ObjectDescriptor();
+    objStaticMethod.setName("objectByStaticMethod");
+    objStaticMethod.setClassName(Integer.class.getName());
+    objStaticMethod.setMethodName("signum");
+    ArgDescriptor argStaticMethod = new ArgDescriptor();
+    argStaticMethod.setTypeName(int.class.getName());
+    IntegerDescriptor argStaticMethodValue = new IntegerDescriptor();
+    argStaticMethodValue.setValue(42);
+    argStaticMethod.setDescriptor(argStaticMethodValue);
+
+    objStaticMethod.addArgDescriptor(argStaticMethod);
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(objDefault)
+      .property(objConstr)
+      .property(objStaticMethod)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    assertNotNull(p.getProperty("objectByEmptyConstr"));
+    assertEquals(42, p.getProperty("objectByConstr"));
+    assertTrue(p.getProperty("objectByConstr") instanceof Integer);
+
+    assertEquals(1, p.getProperty("objectByStaticMethod"));
+  }
+
+  /**
+   * Check that map descriptors are persisted
+   */
+  public void testFieldOperation() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    ObjectDescriptor objDescr = new ObjectDescriptor(VariableDefinitionImpl.class.getName());
+    objDescr.setName("object");
+
+    FieldOperation fieldOp = new FieldOperation();
+    fieldOp.setFieldName("name");
+
+    StringDescriptor varNameDescriptor = new StringDescriptor();
+    varNameDescriptor.setValue("varName");
+
+    fieldOp.setDescriptor(varNameDescriptor);
+
+    objDescr.addOperation(fieldOp);
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(objDescr)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    assertNotNull(p.getProperty("object"));
+    assertTrue(p.getProperty("object") instanceof VariableDefinitionImpl);
+    assertEquals("varName", ((VariableDefinitionImpl) p.getProperty("object")).getName());
+  }
+
+  /**
+   * Check that map descriptors are persisted
+   */
+  public void testPropertyOperation() {
+    DbSession dbSession = (DbSession) environment.get(DbSession.class);
+    assertNotNull(dbSession);
+
+    ObjectDescriptor objDescr = new ObjectDescriptor();
+    objDescr.setName("object");
+    objDescr.setClassName(VariableDefinitionImpl.class.getName());
+
+    PropertyOperation propertyOp = new PropertyOperation();
+    propertyOp.setPropertyName("name");
+
+    StringDescriptor varNameDescriptor = new StringDescriptor();
+    varNameDescriptor.setValue("varName");
+
+    propertyOp.setDescriptor(varNameDescriptor);
+
+    objDescr.addOperation(propertyOp);
+
+    OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .property(objDescr)
+      .startActivity()
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    dbSession.save(processDefinition);
+
+    newTransaction();
+
+    dbSession = (DbSession) environment.get(DbSession.class);
+
+    OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+
+    assertNotNull(p);
+    assertNotSame(processDefinition, p);
+
+    assertNotNull(p.getProperty("object"));
+    assertTrue(p.getProperty("object") instanceof VariableDefinitionImpl);
+    assertEquals("varName", ((VariableDefinitionImpl) p.getProperty("object")).getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.db.model;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WireTest extends EnvironmentDbTestCase
+{
+
+  public void testObjectDescriptor()
+  {
+    DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+
+    ObjectDescriptor objStaticMethod = new ObjectDescriptor();
+    objStaticMethod.setName("objectByStaticMethod");
+    objStaticMethod.setClassName(Integer.class.getName());
+    objStaticMethod.setMethodName("signum");
+    ArgDescriptor argStaticMethod = new ArgDescriptor();
+    argStaticMethod.setTypeName(int.class.getName());
+    IntegerDescriptor argStaticMethodValue = new IntegerDescriptor();
+    argStaticMethodValue.setValue(42);
+    argStaticMethod.setDescriptor(argStaticMethodValue);
+
+    objStaticMethod.addArgDescriptor(argStaticMethod);
+
+    persistenceSession.save(argStaticMethodValue);
+    environment.get(Session.class).flush();
+
+    persistenceSession.save(objStaticMethod);
+    environment.get(Session.class).flush();
+
+    persistenceSession.save(objStaticMethod);
+    environment.get(Session.class).flush();
+
+  }
+
+  /*
+   * public void testObjectDescriptor() { DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
+   * assertNotNull(persistenceSession);
+   * 
+   * ObjectDescriptor objDefault = new ObjectDescriptor(); objDefault.setName("objectByEmptyConstr");
+   * objDefault.setClassName(Object.class.getName());
+   * 
+   * ObjectDescriptor objConstr = new ObjectDescriptor(); objConstr.setName("objectByConstr");
+   * objConstr.setClassName(Integer.class.getName());
+   * 
+   * ArgDescriptor argObjConstr = new ArgDescriptor(); argObjConstr.setTypeName(int.class.getName()); IntegerDescriptor
+   * argObjConstrVal = new IntegerDescriptor(); argObjConstrVal.setValue(42);
+   * argObjConstr.setDescriptor(argObjConstrVal);
+   * 
+   * objConstr.addArgDescriptor(argObjConstr);
+   * 
+   * ObjectDescriptor objStaticMethod = new ObjectDescriptor(); objStaticMethod.setName("objectByStaticMethod");
+   * objStaticMethod.setClassName(Integer.class.getName()); objStaticMethod.setMethodName("signum"); ArgDescriptor
+   * argStaticMethod = new ArgDescriptor(); argStaticMethod.setTypeName(int.class.getName()); IntegerDescriptor
+   * argStaticMethodValue = new IntegerDescriptor(); argStaticMethodValue.setValue(42);
+   * argStaticMethod.setDescriptor(argStaticMethodValue);
+   * 
+   * objStaticMethod.addArgDescriptor(argStaticMethod);
+   * 
+   * ProcessDefinition processDefinition = ProcessFactory.build() .configuration(objDefault) .configuration(objConstr)
+   * .configuration(objStaticMethod) .done();
+   * 
+   * persistenceSession.save(processDefinition);
+   * 
+   * newTransaction();
+   * 
+   * DbSession testSession = (DbSession) environment.get(DbSession.class);
+   * 
+   * ProcessDefinition p = (ProcessDefinition) testSession.get(ProcessDefinitionImpl.class,
+   * processDefinition.getDbid());
+   * 
+   * assertNotNull(p); assertNotSame(processDefinition, p);
+   * 
+   * assertNotNull(p.getConfigurations()); assertNotNull(p.getConfigurations().get("objectByEmptyConstr"));
+   * assertEquals(42 , p.getConfigurations().get("objectByConstr"));
+   * assertTrue(p.getConfigurations().get("objectByConstr") instanceof Integer);
+   * 
+   * assertEquals(1, p.getConfigurations().get("objectByStaticMethod")); }
+   */
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.execution;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.jbpm.Deployment;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionService;
+import org.jbpm.ProcessService;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.activities.AutomaticActivity;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.pvm.internal.svc.ProcessServiceImpl;
+import org.jbpm.pvm.test.EnvironmentFactoryTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmProcessExecutionTest extends EnvironmentFactoryTestCase {
+
+  public void testDeploy() {
+    JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+    ProcessService processService = environmentFactory.get(ProcessService.class);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("test")
+      .startActivity("start", WaitState.class)
+        .initial()
+        .transition("end", "end")
+      .endActivity()
+      .startActivity("end", AutomaticActivity.class)
+      .endActivity()
+    .endProcess();
+
+    Deployment deployment = new DeploymentImpl();
+    deployment.addObject("testProcesssss", processDefinition);
+
+    ((ProcessServiceImpl) processService).deploy(deployment);
+  }
+
+  public void testStartProcessInstance() {
+    JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+    ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+    Execution execution = executionService.startProcessInstanceById("test:1", "request17");
+  }
+
+  public void testResumeProcessInstance() {
+    JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+    ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+    Execution execution = executionService.signalExecutionById("test/request17", "end");
+  }
+
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.expr;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroovyExpressionTest extends BaseJbpmTestCase {
+
+  public void testGroovyExpression() {
+    System.out.println("FIXME: JBPM-1768 Fix groovy support");
+  }
+
+  public void dontTestGroovyExpression() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context>" +
+        "    <script-manager default-expression-language='juel'" +
+        "                    default-script-language='juel'" +
+        "                    read-contexts='execution, environment, process-engine' " +
+        "                    write-context='execution'>" +
+        "      <script-language name='groovy' factory='com.sun.script.groovy.GroovyScriptEngineFactory' />" +
+        "    </script-manager>" +
+        "  </process-engine-context>" +
+        "</jbpm-configuration>"
+    );
+
+    ScriptManager scriptManager = environmentFactory.get(ScriptManager.class);
+    
+    ClientExecution execution = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+      .endActivity()
+    .endProcess()
+    .startProcessInstance();
+    
+    execution.setVariable("pv", "hello");
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals("hello", scriptManager.evaluateExpression("pv", execution, "groovy"));
+    } finally {
+      environment.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.expr;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JuelExpressionTest extends BaseJbpmTestCase {
+  
+  public void testJuelExpression() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context>" +
+        "    <script-manager default-expression-language='juel'" +
+        "                    default-script-language='juel'" +
+        "                    read-contexts='execution, environment, process-engine' " +
+        "                    write-context='execution'>" +
+        "      <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />" +
+        "    </script-manager>" +
+        "  </process-engine-context>" +
+        "</jbpm-configuration>"
+    );
+
+    ScriptManager scriptManager = environmentFactory.get(ScriptManager.class);
+    
+    ClientExecution execution = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+      .endActivity()
+    .endProcess()
+    .startProcessInstance();
+    
+    execution.setVariable("pv", "hello");
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals("hello", scriptManager.evaluateExpression("#{pv}", execution, null));
+    } finally {
+      environment.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/identity/IdentityTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/identity/IdentityTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/identity/IdentityTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.identity;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jbpm.IdentityService;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentityTest extends JbpmTestCase {
+  
+  public void testSingleUser() throws Exception {
+    IdentityService identityService = processEngine.get(IdentityService.class);
+    
+    identityService.createUser("johndoe", "John", "Doe");
+    
+    List<User> users = identityService.getUsers();
+    assertNotNull(users);
+    assertEquals(1, users.size());
+    
+    User johndoe = users.get(0);
+    assertEquals("johndoe", johndoe.getName());
+    assertEquals("John", johndoe.getGivenName());
+    assertEquals("Doe", johndoe.getFamilyName());
+    assertEquals("John Doe", johndoe.toString());
+    
+    identityService.deleteUser("johndoe");
+    
+    assertEquals(0, identityService.getUsers().size());
+  }
+
+  public void testSingleGroup() throws Exception {
+    IdentityService identityService = processEngine.get(IdentityService.class);
+    
+    identityService.createUser("johndoe", "John", "Doe");
+    identityService.createUser("joesmoe", "Joe", "Smoe");
+    identityService.createUser("jackblack", "Jack", "Black");
+    
+    identityService.createGroup("redhat", Group.TYPE_ORGANISATION_UNIT);
+    identityService.createGroup("jboss", Group.TYPE_ORGANISATION_UNIT, "redhat");
+    identityService.createGroup("jbpm", Group.TYPE_ORGANISATION_UNIT, "jboss");
+    
+    identityService.createMembership("johndoe", "jbpm", Group.TYPE_ORGANISATION_UNIT, "developer");
+    identityService.createMembership("joesmoe", "jbpm", Group.TYPE_ORGANISATION_UNIT, "developer");
+    identityService.createMembership("jackblack", "jboss", Group.TYPE_ORGANISATION_UNIT, "manager");
+    
+    List<Group> groups = identityService.findGroupsByUserAndGroupType("jackblack", Group.TYPE_ORGANISATION_UNIT);
+
+     assertEquals(1, groups.size());
+     Group group = groups.get(0);
+     assertEquals("jboss", group.getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.activities.AutomaticActivity;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncContinuationsTest extends JbpmTestCase {
+
+  public void testContinuations() {
+    deployProcess();
+
+    Execution execution = executionService.startProcessInstanceByKey("continuations");
+    
+    assertEquals("start", execution.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, execution.getState());
+
+    executeAsyncMessage(execution);
+    execution = executionService.findExecution(execution.getId());
+
+    assertEquals("a", execution.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, execution.getState());
+
+    executeAsyncMessage(execution);
+    execution = executionService.findExecution(execution.getId());
+
+    assertEquals("b", execution.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, execution.getState());
+
+    executeAsyncMessage(execution);
+    execution = executionService.findExecution(execution.getId());
+
+    assertEquals("c", execution.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, execution.getState());
+
+    executeAsyncMessage(execution);
+
+    assertNull(executionService.findExecution(execution.getId()));
+  }
+
+  public void deployProcess() {
+    commandService.execute(new Command<Object>() {
+      public Object execute(Environment environment) throws Exception {
+        OpenProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("continuations")
+          .key("continuations")
+          .startActivity("start", AutomaticActivity.class)
+            .initial()
+            .asyncExecute()
+            .transition("a")
+          .endActivity()
+          .startActivity("a", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("b")
+          .endActivity()
+          .startActivity("b", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("c")
+          .endActivity()
+          .startActivity("c", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("end")
+          .endActivity()
+          .startActivity("end", AutomaticActivity.class)
+          .endActivity()
+        .endProcess();
+        
+        Session session = environment.get(Session.class);
+        session.save(processDefinition);
+        return null;
+      }
+    });
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1514 @@
+package org.jbpm.pvm.internal.jobexecutor.cron;
+
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TimeZone;
+import java.util.TreeSet;
+
+/**
+ * Provides a parser and evaluator for unix-like cron expressions. Cron 
+ * expressions provide the ability to specify complex time combinations such as
+ * &quot;At 8:00am every Monday through Friday&quot; or &quot;At 1:30am every 
+ * last Friday of the month&quot;. 
+ * <P>
+ * Cron expressions are comprised of 6 required fields and one optional field
+ * separated by white space. The fields respectively are described as follows:
+ * 
+ * <table cellspacing="8">
+ * <tr>
+ * <th align="left">Field Name</th>
+ * <th align="left">&nbsp;</th>
+ * <th align="left">Allowed Values</th>
+ * <th align="left">&nbsp;</th>
+ * <th align="left">Allowed Special Characters</th>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Seconds</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>0-59</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * /</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Minutes</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>0-59</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * /</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Hours</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>0-23</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * /</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Day-of-month</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>1-31</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * ? / L W</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Month</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>1-12 or JAN-DEC</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * /</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Day-of-Week</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>1-7 or SUN-SAT</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * ? / L #</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>Year (Optional)</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>empty, 1970-2099</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>, - * /</code></td>
+ * </tr>
+ * </table>
+ * <P>
+ * The '*' character is used to specify all values. For example, &quot;*&quot; 
+ * in the minute field means &quot;every minute&quot;.
+ * <P>
+ * The '?' character is allowed for the day-of-month and day-of-week fields. It
+ * is used to specify 'no specific value'. This is useful when you need to
+ * specify something in one of the two fileds, but not the other.
+ * <P>
+ * The '-' character is used to specify ranges For example &quot;10-12&quot; in
+ * the hour field means &quot;the hours 10, 11 and 12&quot;.
+ * <P>
+ * The ',' character is used to specify additional values. For example
+ * &quot;MON,WED,FRI&quot; in the day-of-week field means &quot;the days Monday,
+ * Wednesday, and Friday&quot;.
+ * <P>
+ * The '/' character is used to specify increments. For example &quot;0/15&quot;
+ * in the seconds field means &quot;the seconds 0, 15, 30, and 45&quot;. And 
+ * &quot;5/15&quot; in the seconds field means &quot;the seconds 5, 20, 35, and
+ * 50&quot;.  Specifying '*' before the  '/' is equivalent to specifying 0 is
+ * the value to start with. Essentially, for each field in the expression, there
+ * is a set of numbers that can be turned on or off. For seconds and minutes, 
+ * the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to
+ * 31, and for months 1 to 12. The &quot;/&quot; character simply helps you turn
+ * on every &quot;nth&quot; value in the given set. Thus &quot;7/6&quot; in the
+ * month field only turns on month &quot;7&quot;, it does NOT mean every 6th 
+ * month, please note that subtlety.  
+ * <P>
+ * The 'L' character is allowed for the day-of-month and day-of-week fields.
+ * This character is short-hand for &quot;last&quot;, but it has different 
+ * meaning in each of the two fields. For example, the value &quot;L&quot; in 
+ * the day-of-month field means &quot;the last day of the month&quot; - day 31 
+ * for January, day 28 for February on non-leap years. If used in the 
+ * day-of-week field by itself, it simply means &quot;7&quot; or 
+ * &quot;SAT&quot;. But if used in the day-of-week field after another value, it
+ * means &quot;the last xxx day of the month&quot; - for example &quot;6L&quot;
+ * means &quot;the last friday of the month&quot;. When using the 'L' option, it
+ * is important not to specify lists, or ranges of values, as you'll get 
+ * confusing results.
+ * <P>
+ * The 'W' character is allowed for the day-of-month field.  This character 
+ * is used to specify the weekday (Monday-Friday) nearest the given day.  As an 
+ * example, if you were to specify &quot;15W&quot; as the value for the 
+ * day-of-month field, the meaning is: &quot;the nearest weekday to the 15th of
+ * the month&quot;. So if the 15th is a Saturday, the trigger will fire on 
+ * Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the
+ * 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. 
+ * However if you specify &quot;1W&quot; as the value for day-of-month, and the
+ * 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 
+ * 'jump' over the boundary of a month's days.  The 'W' character can only be 
+ * specified when the day-of-month is a single day, not a range or list of days.
+ * <P>
+ * The 'L' and 'W' characters can also be combined for the day-of-month 
+ * expression to yield 'LW', which translates to &quot;last weekday of the 
+ * month&quot;.
+ * <P>
+ * The '#' character is allowed for the day-of-week field. This character is
+ * used to specify &quot;the nth&quot; XXX day of the month. For example, the 
+ * value of &quot;6#3&quot; in the day-of-week field means the third Friday of 
+ * the month (day 6 = Friday and &quot;#3&quot; = the 3rd one in the month). 
+ * Other examples: &quot;2#1&quot; = the first Monday of the month and 
+ * &quot;4#5&quot; = the fifth Wednesday of the month. Note that if you specify
+ * &quot;#5&quot; and there is not 5 of the given day-of-week in the month, then
+ * no firing will occur that month.
+ * <P>
+ * <!--The 'C' character is allowed for the day-of-month and day-of-week fields.
+ * This character is short-hand for "calendar". This means values are
+ * calculated against the associated calendar, if any. If no calendar is
+ * associated, then it is equivalent to having an all-inclusive calendar. A
+ * value of "5C" in the day-of-month field means "the first day included by the
+ * calendar on or after the 5th". A value of "1C" in the day-of-week field
+ * means "the first day included by the calendar on or after sunday".-->
+ * <P>
+ * The legal characters and the names of months and days of the week are not
+ * case sensitive.
+ * 
+ * <p>
+ * <b>NOTES:</b>
+ * <ul>
+ * <li>Support for specifying both a day-of-week and a day-of-month value is
+ * not complete (you'll need to use the '?' character in on of these fields).
+ * </li>
+ * </ul>
+ * </p>
+ * 
+ * 
+ * @author Sharada Jambula, James House
+ * @author Contributions from Mads Henderson
+ * @author Refactoring from CronTrigger to CronExpression by Aaron Craven
+ */
+public class CronExpression implements Serializable, Cloneable {
+
+    private static final long serialVersionUID = 12423409423L;
+    
+    protected static final int SECOND = 0;
+    protected static final int MINUTE = 1;
+    protected static final int HOUR = 2;
+    protected static final int DAY_OF_MONTH = 3;
+    protected static final int MONTH = 4;
+    protected static final int DAY_OF_WEEK = 5;
+    protected static final int YEAR = 6;
+    protected static final int ALL_SPEC_INT = 99; // '*'
+    protected static final int NO_SPEC_INT = 98; // '?'
+    protected static final Integer ALL_SPEC = new Integer(ALL_SPEC_INT);
+    protected static final Integer NO_SPEC = new Integer(NO_SPEC_INT);
+    
+    protected static Map monthMap = new HashMap(20);
+    protected static Map dayMap = new HashMap(60);
+    static {
+        monthMap.put("JAN", new Integer(0));
+        monthMap.put("FEB", new Integer(1));
+        monthMap.put("MAR", new Integer(2));
+        monthMap.put("APR", new Integer(3));
+        monthMap.put("MAY", new Integer(4));
+        monthMap.put("JUN", new Integer(5));
+        monthMap.put("JUL", new Integer(6));
+        monthMap.put("AUG", new Integer(7));
+        monthMap.put("SEP", new Integer(8));
+        monthMap.put("OCT", new Integer(9));
+        monthMap.put("NOV", new Integer(10));
+        monthMap.put("DEC", new Integer(11));
+
+        dayMap.put("SUN", new Integer(1));
+        dayMap.put("MON", new Integer(2));
+        dayMap.put("TUE", new Integer(3));
+        dayMap.put("WED", new Integer(4));
+        dayMap.put("THU", new Integer(5));
+        dayMap.put("FRI", new Integer(6));
+        dayMap.put("SAT", new Integer(7));
+    }
+
+    private String cronExpression = null;
+    private TimeZone timeZone = null;
+    protected transient TreeSet seconds;
+    protected transient TreeSet minutes;
+    protected transient TreeSet hours;
+    protected transient TreeSet daysOfMonth;
+    protected transient TreeSet months;
+    protected transient TreeSet daysOfWeek;
+    protected transient TreeSet years;
+
+    protected transient boolean lastdayOfWeek = false;
+    protected transient int nthdayOfWeek = 0;
+    protected transient boolean lastdayOfMonth = false;
+    protected transient boolean nearestWeekday = false;
+    protected transient boolean expressionParsed = false;
+    
+    /**
+     * Constructs a new <CODE>CronExpression</CODE> based on the specified 
+     * parameter.
+     * 
+     * @param cronExpression String representation of the cron expression the
+     *                       new object should represent
+     * @throws java.text.ParseException
+     *         if the string expression cannot be parsed into a valid 
+     *         <CODE>CronExpression</CODE>
+     */
+    public CronExpression(String cronExpression) throws ParseException {
+        if (cronExpression == null) {
+            throw new IllegalArgumentException("cronExpression cannot be null");
+        }
+        
+        this.cronExpression = cronExpression;
+        
+        buildExpression(cronExpression.toUpperCase(Locale.US));
+    }
+    
+    /**
+     * Indicates whether the given date satisfies the cron expression. Note that
+     * milliseconds are ignored, so two Dates falling on different milliseconds
+     * of the same second will always have the same result here.
+     * 
+     * @param date the date to evaluate
+     * @return a boolean indicating whether the given date satisfies the cron
+     *         expression
+     */
+    public boolean isSatisfiedBy(Date date) {
+        Calendar testDateCal = Calendar.getInstance();
+        testDateCal.setTime(date);
+        testDateCal.set(Calendar.MILLISECOND, 0);
+        Date originalDate = testDateCal.getTime();
+        
+        testDateCal.add(Calendar.SECOND, -1);
+        
+        Date timeAfter = getTimeAfter(testDateCal.getTime());
+        
+        return ((timeAfter != null) && (timeAfter.equals(originalDate)));
+    }
+    
+    /**
+     * Returns the next date/time <I>after</I> the given date/time which
+     * satisfies the cron expression.
+     * 
+     * @param date the date/time at which to begin the search for the next valid
+     *             date/time
+     * @return the next valid date/time
+     */
+    public Date getNextValidTimeAfter(Date date) {
+        return getTimeAfter(date);
+    }
+    
+    /**
+     * Returns the next date/time <I>after</I> the given date/time which does
+     * <I>not</I> satisfy the expression
+     * 
+     * @param date the date/time at which to begin the search for the next 
+     *             invalid date/time
+     * @return the next valid date/time
+     */
+    public Date getNextInvalidTimeAfter(Date date) {
+        long difference = 1000;
+        
+        //move back to the nearest second so differences will be accurate
+        Calendar adjustCal = Calendar.getInstance();
+        adjustCal.setTime(date);
+        adjustCal.set(Calendar.MILLISECOND, 0);
+        Date lastDate = adjustCal.getTime();
+        
+        Date newDate = null;
+        
+        //TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution.
+        
+        //keep getting the next included time until it's farther than one second
+        // apart. At that point, lastDate is the last valid fire time. We return
+        // the second immediately following it.
+        while (difference == 1000) {
+            newDate = getTimeAfter(lastDate);
+            
+            difference = newDate.getTime() - lastDate.getTime();
+            
+            if (difference == 1000) {
+                lastDate = newDate;
+            }
+        }
+        
+        return new Date(lastDate.getTime() + 1000);
+    }
+    
+    /**
+     * Returns the time zone for which this <code>CronExpression</code> 
+     * will be resolved.
+     */
+    public TimeZone getTimeZone() {
+        if (timeZone == null) {
+            timeZone = TimeZone.getDefault();
+        }
+
+        return timeZone;
+    }
+
+    /**
+     * Sets the time zone for which  this <code>CronExpression</code> 
+     * will be resolved.
+     */
+    public void setTimeZone(TimeZone timeZone) {
+        this.timeZone = timeZone;
+    }
+    
+    /**
+     * Returns the string representation of the <CODE>CronExpression</CODE>
+     * 
+     * @return a string representation of the <CODE>CronExpression</CODE>
+     */
+    public String toString() {
+        return cronExpression;
+    }
+    
+    /**
+     * Indicates whether the specified cron expression can be parsed into a 
+     * valid cron expression
+     * 
+     * @param cronExpression the expression to evaluate
+     * @return a boolean indicating whether the given expression is a valid cron
+     *         expression
+     */
+    public static boolean isValidExpression(String cronExpression) {
+        
+        try {
+            new CronExpression(cronExpression);
+        } catch (ParseException pe) {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    //
+    // Expression Parsing Functions
+    //
+    ////////////////////////////////////////////////////////////////////////////
+
+    protected void buildExpression(String expression) throws ParseException {
+        expressionParsed = true;
+
+        try {
+
+            if (seconds == null) {
+                seconds = new TreeSet();
+            }
+            if (minutes == null) {
+                minutes = new TreeSet();
+            }
+            if (hours == null) {
+                hours = new TreeSet();
+            }
+            if (daysOfMonth == null) {
+                daysOfMonth = new TreeSet();
+            }
+            if (months == null) {
+                months = new TreeSet();
+            }
+            if (daysOfWeek == null) {
+                daysOfWeek = new TreeSet();
+            }
+            if (years == null) {
+                years = new TreeSet();
+            }
+
+            int exprOn = SECOND;
+
+            StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
+                    false);
+
+            while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
+                String expr = exprsTok.nextToken().trim();
+                StringTokenizer vTok = new StringTokenizer(expr, ",");
+                while (vTok.hasMoreTokens()) {
+                    String v = vTok.nextToken();
+                    storeExpressionVals(0, v, exprOn);
+                }
+
+                exprOn++;
+            }
+
+            if (exprOn <= DAY_OF_WEEK) {
+                throw new ParseException("Unexpected end of expression.",
+                            expression.length());
+            }
+
+            if (exprOn <= YEAR) {
+                storeExpressionVals(0, "*", YEAR);
+            }
+
+        } catch (ParseException pe) {
+            throw pe;
+        } catch (Exception e) {
+            throw new ParseException("Illegal cron expression format ("
+                    + e.toString() + ")", 0);
+        }
+    }
+
+    protected int storeExpressionVals(int pos, String s, int type)
+        throws ParseException {
+        
+        int incr = 0;
+        int i = skipWhiteSpace(pos, s);
+        if (i >= s.length()) {
+            return i;
+        }
+        char c = s.charAt(i);
+        if ((c >= 'A') && (c <= 'Z') && (!s.equals("L")) && (!s.equals("LW"))) {
+            String sub = s.substring(i, i + 3);
+            int sval = -1;
+            int eval = -1;
+            if (type == MONTH) {
+                sval = getMonthNumber(sub) + 1;
+                if (sval < 0) {
+                    throw new ParseException("Invalid Month value: '" + sub + "'", i);
+                }
+                if (s.length() > i + 3) {
+                    c = s.charAt(i + 3);
+                    if (c == '-') {
+                        i += 4;
+                        sub = s.substring(i, i + 3);
+                        eval = getMonthNumber(sub) + 1;
+                        if (eval < 0) {
+                            throw new ParseException("Invalid Month value: '" + sub + "'", i);
+                        }
+                    }
+                }
+            } else if (type == DAY_OF_WEEK) {
+                sval = getDayOfWeekNumber(sub);
+                if (sval < 0) {
+                    throw new ParseException("Invalid Day-of-Week value: '"
+                                + sub + "'", i);
+                }
+                if (s.length() > i + 3) {
+                    c = s.charAt(i + 3);
+                    if (c == '-') {
+                        i += 4;
+                        sub = s.substring(i, i + 3);
+                        eval = getDayOfWeekNumber(sub);
+                        if (eval < 0) {
+                            throw new ParseException(
+                                    "Invalid Day-of-Week value: '" + sub
+                                        + "'", i);
+                        }
+                        if (sval > eval) {
+                            throw new ParseException(
+                                    "Invalid Day-of-Week sequence: " + sval 
+                                        + " > " + eval, i);
+                        }
+                    } else if (c == '#') {
+                        try {
+                            i += 4;
+                            nthdayOfWeek = Integer.parseInt(s.substring(i));
+                            if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {
+                                throw new Exception();
+                            }
+                        } catch (Exception e) {
+                            throw new ParseException(
+                                    "A numeric value between 1 and 5 must follow the '#' option",
+                                    i);
+                        }
+                    } else if (c == 'L') {
+                        lastdayOfWeek = true;
+                        i++;
+                    }
+                }
+
+            } else {
+                throw new ParseException(
+                        "Illegal characters for this position: '" + sub + "'",
+                        i);
+            }
+            if (eval != -1) {
+                incr = 1;
+            }
+            addToSet(sval, eval, incr, type);
+            return (i + 3);
+        }
+
+        if (c == '?') {
+            i++;
+            if ((i + 1) < s.length() 
+                    && (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) {
+                throw new ParseException("Illegal character after '?': "
+                            + s.charAt(i), i);
+            }
+            if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) {
+                throw new ParseException(
+                            "'?' can only be specfied for Day-of-Month or Day-of-Week.",
+                            i);
+            }
+            if (type == DAY_OF_WEEK && !lastdayOfMonth) {
+                int val = ((Integer) daysOfMonth.last()).intValue();
+                if (val == NO_SPEC_INT) {
+                    throw new ParseException(
+                                "'?' can only be specfied for Day-of-Month -OR- Day-of-Week.",
+                                i);
+                }
+            }
+
+            addToSet(NO_SPEC_INT, -1, 0, type);
+            return i;
+        }
+
+        if (c == '*' || c == '/') {
+            if (c == '*' && (i + 1) >= s.length()) {
+                addToSet(ALL_SPEC_INT, -1, incr, type);
+                return i + 1;
+            } else if (c == '/'
+                    && ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
+                            .charAt(i + 1) == '\t')) { 
+                throw new ParseException("'/' must be followed by an integer.", i);
+            } else if (c == '*') {
+                i++;
+            }
+            c = s.charAt(i);
+            if (c == '/') { // is an increment specified?
+                i++;
+                if (i >= s.length()) {
+                    throw new ParseException("Unexpected end of string.", i);
+                }
+
+                incr = getNumericValue(s, i);
+
+                i++;
+                if (incr > 10) {
+                    i++;
+                }
+                if (incr > 59 && (type == SECOND || type == MINUTE)) {
+                    throw new ParseException("Increment > 60 : " + incr, i);
+                } else if (incr > 23 && (type == HOUR)) { 
+                    throw new ParseException("Increment > 24 : " + incr, i);
+                } else if (incr > 31 && (type == DAY_OF_MONTH)) { 
+                    throw new ParseException("Increment > 31 : " + incr, i);
+                } else if (incr > 7 && (type == DAY_OF_WEEK)) { 
+                    throw new ParseException("Increment > 7 : " + incr, i);
+                } else if (incr > 12 && (type == MONTH)) {
+                    throw new ParseException("Increment > 12 : " + incr, i);
+                }
+            } else {
+                incr = 1;
+            }
+
+            addToSet(ALL_SPEC_INT, -1, incr, type);
+            return i;
+        } else if (c == 'L') {
+            i++;
+            if (type == DAY_OF_MONTH) {
+                lastdayOfMonth = true;
+            }
+            if (type == DAY_OF_WEEK) {
+                addToSet(7, 7, 0, type);
+            }
+            if(type == DAY_OF_MONTH && s.length() > i) {
+                c = s.charAt(i);
+                if(c == 'W') {
+                    nearestWeekday = true;
+                    i++;
+                }
+            }
+            return i;
+        } else if (c >= '0' && c <= '9') {
+            int val = Integer.parseInt(String.valueOf(c));
+            i++;
+            if (i >= s.length()) {
+                addToSet(val, -1, -1, type);
+            } else {
+                c = s.charAt(i);
+                if (c >= '0' && c <= '9') {
+                    ValueSet vs = getValue(val, s, i);
+                    val = vs.value;
+                    i = vs.pos;
+                }
+                i = checkNext(i, s, val, type);
+                return i;
+            }
+        } else {
+            throw new ParseException("Unexpected character: " + c, i);
+        }
+
+        return i;
+    }
+
+    protected int checkNext(int pos, String s, int val, int type)
+        throws ParseException {
+        
+        int end = -1;
+        int i = pos;
+
+        if (i >= s.length()) {
+            addToSet(val, end, -1, type);
+            return i;
+        }
+
+        char c = s.charAt(pos);
+
+        if (c == 'L') {
+            if (type == DAY_OF_WEEK) {
+                lastdayOfWeek = true;
+            } else {
+                throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i);
+            }
+            TreeSet set = getSet(type);
+            set.add(new Integer(val));
+            i++;
+            return i;
+        }
+        
+        if (c == 'W') {
+            if (type == DAY_OF_MONTH) {
+                nearestWeekday = true;
+            } else {
+                throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
+            }
+            TreeSet set = getSet(type);
+            set.add(new Integer(val));
+            i++;
+            return i;
+        }
+
+        if (c == '#') {
+            if (type != DAY_OF_WEEK) {
+                throw new ParseException("'#' option is not valid here. (pos=" + i + ")", i);
+            }
+            i++;
+            try {
+                nthdayOfWeek = Integer.parseInt(s.substring(i));
+                if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {
+                    throw new Exception();
+                }
+            } catch (Exception e) {
+                throw new ParseException(
+                        "A numeric value between 1 and 5 must follow the '#' option",
+                        i);
+            }
+
+            TreeSet set = getSet(type);
+            set.add(new Integer(val));
+            i++;
+            return i;
+        }
+
+        if (c == '-') {
+            i++;
+            c = s.charAt(i);
+            int v = Integer.parseInt(String.valueOf(c));
+            end = v;
+            i++;
+            if (i >= s.length()) {
+                addToSet(val, end, 1, type);
+                return i;
+            }
+            c = s.charAt(i);
+            if (c >= '0' && c <= '9') {
+                ValueSet vs = getValue(v, s, i);
+                int v1 = vs.value;
+                end = v1;
+                i = vs.pos;
+            }
+            if (i < s.length() && ((c = s.charAt(i)) == '/')) {
+                i++;
+                c = s.charAt(i);
+                int v2 = Integer.parseInt(String.valueOf(c));
+                i++;
+                if (i >= s.length()) {
+                    addToSet(val, end, v2, type);
+                    return i;
+                }
+                c = s.charAt(i);
+                if (c >= '0' && c <= '9') {
+                    ValueSet vs = getValue(v2, s, i);
+                    int v3 = vs.value;
+                    addToSet(val, end, v3, type);
+                    i = vs.pos;
+                    return i;
+                } else {
+                    addToSet(val, end, v2, type);
+                    return i;
+                }
+            } else {
+                addToSet(val, end, 1, type);
+                return i;
+            }
+        }
+
+        if (c == '/') {
+            i++;
+            c = s.charAt(i);
+            int v2 = Integer.parseInt(String.valueOf(c));
+            i++;
+            if (i >= s.length()) {
+                addToSet(val, end, v2, type);
+                return i;
+            }
+            c = s.charAt(i);
+            if (c >= '0' && c <= '9') {
+                ValueSet vs = getValue(v2, s, i);
+                int v3 = vs.value;
+                addToSet(val, end, v3, type);
+                i = vs.pos;
+                return i;
+            } else {
+                throw new ParseException("Unexpected character '" + c + "' after '/'", i);
+            }
+        }
+
+        addToSet(val, end, 0, type);
+        i++;
+        return i;
+    }
+
+    public String getCronExpression() {
+        return cronExpression;
+    }
+    
+    public String getExpressionSummary() {
+        StringBuffer buf = new StringBuffer();
+
+        buf.append("seconds: ");
+        buf.append(getExpressionSetSummary(seconds));
+        buf.append("\n");
+        buf.append("minutes: ");
+        buf.append(getExpressionSetSummary(minutes));
+        buf.append("\n");
+        buf.append("hours: ");
+        buf.append(getExpressionSetSummary(hours));
+        buf.append("\n");
+        buf.append("daysOfMonth: ");
+        buf.append(getExpressionSetSummary(daysOfMonth));
+        buf.append("\n");
+        buf.append("months: ");
+        buf.append(getExpressionSetSummary(months));
+        buf.append("\n");
+        buf.append("daysOfWeek: ");
+        buf.append(getExpressionSetSummary(daysOfWeek));
+        buf.append("\n");
+        buf.append("lastdayOfWeek: ");
+        buf.append(lastdayOfWeek);
+        buf.append("\n");
+        buf.append("nearestWeekday: ");
+        buf.append(nearestWeekday);
+        buf.append("\n");
+        buf.append("NthDayOfWeek: ");
+        buf.append(nthdayOfWeek);
+        buf.append("\n");
+        buf.append("lastdayOfMonth: ");
+        buf.append(lastdayOfMonth);
+        buf.append("\n");
+        buf.append("years: ");
+        buf.append(getExpressionSetSummary(years));
+        buf.append("\n");
+
+        return buf.toString();
+    }
+
+    protected String getExpressionSetSummary(java.util.Set set) {
+
+        if (set.contains(NO_SPEC)) {
+            return "?";
+        }
+        if (set.contains(ALL_SPEC)) {
+            return "*";
+        }
+
+        StringBuffer buf = new StringBuffer();
+
+        Iterator itr = set.iterator();
+        boolean first = true;
+        while (itr.hasNext()) {
+            Integer iVal = (Integer) itr.next();
+            String val = iVal.toString();
+            if (!first) {
+                buf.append(",");
+            }
+            buf.append(val);
+            first = false;
+        }
+
+        return buf.toString();
+    }
+
+    protected String getExpressionSetSummary(java.util.ArrayList list) {
+
+        if (list.contains(NO_SPEC)) {
+            return "?";
+        }
+        if (list.contains(ALL_SPEC)) {
+            return "*";
+        }
+
+        StringBuffer buf = new StringBuffer();
+
+        Iterator itr = list.iterator();
+        boolean first = true;
+        while (itr.hasNext()) {
+            Integer iVal = (Integer) itr.next();
+            String val = iVal.toString();
+            if (!first) {
+                buf.append(",");
+            }
+            buf.append(val);
+            first = false;
+        }
+
+        return buf.toString();
+    }
+
+    protected int skipWhiteSpace(int i, String s) {
+        for (; i < s.length() && (s.charAt(i) == ' ' || s.charAt(i) == '\t'); i++) {
+            ;
+        }
+
+        return i;
+    }
+
+    protected int findNextWhiteSpace(int i, String s) {
+        for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++) {
+            ;
+        }
+
+        return i;
+    }
+
+    protected void addToSet(int val, int end, int incr, int type)
+        throws ParseException {
+        
+        TreeSet set = getSet(type);
+
+        if (type == SECOND || type == MINUTE) {
+            if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
+                throw new ParseException(
+                        "Minute and Second values must be between 0 and 59",
+                        -1);
+            }
+        } else if (type == HOUR) {
+            if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {
+                throw new ParseException(
+                        "Hour values must be between 0 and 23", -1);
+            }
+        } else if (type == DAY_OF_MONTH) {
+            if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT) 
+                    && (val != NO_SPEC_INT)) {
+                throw new ParseException(
+                        "Day of month values must be between 1 and 31", -1);
+            }
+        } else if (type == MONTH) {
+            if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) {
+                throw new ParseException(
+                        "Month values must be between 1 and 12", -1);
+            }
+        } else if (type == DAY_OF_WEEK) {
+            if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT)
+                    && (val != NO_SPEC_INT)) {
+                throw new ParseException(
+                        "Day-of-Week values must be between 1 and 7", -1);
+            }
+        }
+
+        if ((incr == 0 || incr == -1) && val != ALL_SPEC_INT) {
+            if (val != -1) {
+                set.add(new Integer(val));
+            } else {
+                set.add(NO_SPEC);
+            }
+            
+            return;
+        }
+
+        int startAt = val;
+        int stopAt = end;
+
+        if (val == ALL_SPEC_INT && incr <= 0) {
+            incr = 1;
+            set.add(ALL_SPEC); // put in a marker, but also fill values
+        }
+
+        if (type == SECOND || type == MINUTE) {
+            if (stopAt == -1) {
+                stopAt = 59;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 0;
+            }
+        } else if (type == HOUR) {
+            if (stopAt == -1) {
+                stopAt = 23;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 0;
+            }
+        } else if (type == DAY_OF_MONTH) {
+            if (stopAt == -1) {
+                stopAt = 31;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 1;
+            }
+        } else if (type == MONTH) {
+            if (stopAt == -1) {
+                stopAt = 12;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 1;
+            }
+        } else if (type == DAY_OF_WEEK) {
+            if (stopAt == -1) {
+                stopAt = 7;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 1;
+            }
+        } else if (type == YEAR) {
+            if (stopAt == -1) {
+                stopAt = 2099;
+            }
+            if (startAt == -1 || startAt == ALL_SPEC_INT) {
+                startAt = 1970;
+            }
+        }
+
+        for (int i = startAt; i <= stopAt; i += incr) {
+            set.add(new Integer(i));
+        }
+    }
+
+    protected TreeSet getSet(int type) {
+        switch (type) {
+            case SECOND:
+                return seconds;
+            case MINUTE:
+                return minutes;
+            case HOUR:
+                return hours;
+            case DAY_OF_MONTH:
+                return daysOfMonth;
+            case MONTH:
+                return months;
+            case DAY_OF_WEEK:
+                return daysOfWeek;
+            case YEAR:
+                return years;
+            default:
+                return null;
+        }
+    }
+
+    protected ValueSet getValue(int v, String s, int i) {
+        char c = s.charAt(i);
+        String s1 = String.valueOf(v);
+        while (c >= '0' && c <= '9') {
+            s1 += c;
+            i++;
+            if (i >= s.length()) {
+                break;
+            }
+            c = s.charAt(i);
+        }
+        ValueSet val = new ValueSet();
+        
+        val.pos = (i < s.length()) ? i : i + 1;
+        val.value = Integer.parseInt(s1);
+        return val;
+    }
+
+    protected int getNumericValue(String s, int i) {
+        int endOfVal = findNextWhiteSpace(i, s);
+        String val = s.substring(i, endOfVal);
+        return Integer.parseInt(val);
+    }
+
+    protected int getMonthNumber(String s) {
+        Integer integer = (Integer) monthMap.get(s);
+
+        if (integer == null) {
+            return -1;
+        }
+
+        return integer.intValue();
+    }
+
+    protected int getDayOfWeekNumber(String s) {
+        Integer integer = (Integer) dayMap.get(s);
+
+        if (integer == null) {
+            return -1;
+        }
+
+        return integer.intValue();
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    //
+    // Computation Functions
+    //
+    ////////////////////////////////////////////////////////////////////////////
+
+    protected Date getTimeAfter(Date afterTime) {
+
+        Calendar cl = Calendar.getInstance(getTimeZone());
+
+        // move ahead one second, since we're computing the time *after* the
+        // given time
+        afterTime = new Date(afterTime.getTime() + 1000);
+        // CronTrigger does not deal with milliseconds
+        cl.setTime(afterTime);
+        cl.set(Calendar.MILLISECOND, 0);
+
+        boolean gotOne = false;
+        // loop until we've computed the next time, or we've past the endTime
+        while (!gotOne) {
+
+            //if (endTime != null && cl.getTime().after(endTime)) return null;
+            if(cl.get(Calendar.YEAR) > 2999) // prevent endless loop...
+                return null;
+
+            SortedSet st = null;
+            int t = 0;
+
+            int sec = cl.get(Calendar.SECOND);
+            int min = cl.get(Calendar.MINUTE);
+
+            // get second.................................................
+            st = seconds.tailSet(new Integer(sec));
+            if (st != null && st.size() != 0) {
+                sec = ((Integer) st.first()).intValue();
+            } else {
+                sec = ((Integer) seconds.first()).intValue();
+                min++;
+                cl.set(Calendar.MINUTE, min);
+            }
+            cl.set(Calendar.SECOND, sec);
+
+            min = cl.get(Calendar.MINUTE);
+            int hr = cl.get(Calendar.HOUR_OF_DAY);
+            t = -1;
+
+            // get minute.................................................
+            st = minutes.tailSet(new Integer(min));
+            if (st != null && st.size() != 0) {
+                t = min;
+                min = ((Integer) st.first()).intValue();
+            } else {
+                min = ((Integer) minutes.first()).intValue();
+                hr++;
+            }
+            if (min != t) {
+                cl.set(Calendar.SECOND, 0);
+                cl.set(Calendar.MINUTE, min);
+                setCalendarHour(cl, hr);
+                continue;
+            }
+            cl.set(Calendar.MINUTE, min);
+
+            hr = cl.get(Calendar.HOUR_OF_DAY);
+            int day = cl.get(Calendar.DAY_OF_MONTH);
+            t = -1;
+
+            // get hour...................................................
+            st = hours.tailSet(new Integer(hr));
+            if (st != null && st.size() != 0) {
+                t = hr;
+                hr = ((Integer) st.first()).intValue();
+            } else {
+                hr = ((Integer) hours.first()).intValue();
+                day++;
+            }
+            if (hr != t) {
+                cl.set(Calendar.SECOND, 0);
+                cl.set(Calendar.MINUTE, 0);
+                cl.set(Calendar.DAY_OF_MONTH, day);
+                setCalendarHour(cl, hr);
+                continue;
+            }
+            cl.set(Calendar.HOUR_OF_DAY, hr);
+
+            day = cl.get(Calendar.DAY_OF_MONTH);
+            int mon = cl.get(Calendar.MONTH) + 1;
+            // '+ 1' because calendar is 0-based for this field, and we are
+            // 1-based
+            t = -1;
+            int tmon = mon;
+            
+            // get day...................................................
+            boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
+            boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
+            if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule
+                st = daysOfMonth.tailSet(new Integer(day));
+                if (lastdayOfMonth) {
+                    if(!nearestWeekday) {
+                        t = day;
+                        day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+                    } else {
+                        t = day;
+                        day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+                        
+                        java.util.Calendar tcal = java.util.Calendar.getInstance();
+                        tcal.set(Calendar.SECOND, 0);
+                        tcal.set(Calendar.MINUTE, 0);
+                        tcal.set(Calendar.HOUR_OF_DAY, 0);
+                        tcal.set(Calendar.DAY_OF_MONTH, day);
+                        tcal.set(Calendar.MONTH, mon - 1);
+                        tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
+                        
+                        int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+                        int dow = tcal.get(Calendar.DAY_OF_WEEK);
+
+                        if(dow == Calendar.SATURDAY && day == 1) {
+                            day += 2;
+                        } else if(dow == Calendar.SATURDAY) {
+                            day -= 1;
+                        } else if(dow == Calendar.SUNDAY && day == ldom) { 
+                            day -= 2;
+                        } else if(dow == Calendar.SUNDAY) { 
+                            day += 1;
+                        }
+                    
+                        tcal.set(Calendar.SECOND, sec);
+                        tcal.set(Calendar.MINUTE, min);
+                        tcal.set(Calendar.HOUR_OF_DAY, hr);
+                        tcal.set(Calendar.DAY_OF_MONTH, day);
+                        tcal.set(Calendar.MONTH, mon - 1);
+                        Date nTime = tcal.getTime();
+                        if(nTime.before(afterTime)) {
+                            day = 1;
+                            mon++;
+                        }
+                    }
+                } else if(nearestWeekday) {
+                    t = day;
+                    day = ((Integer) daysOfMonth.first()).intValue();
+
+                    java.util.Calendar tcal = java.util.Calendar.getInstance();
+                    tcal.set(Calendar.SECOND, 0);
+                    tcal.set(Calendar.MINUTE, 0);
+                    tcal.set(Calendar.HOUR_OF_DAY, 0);
+                    tcal.set(Calendar.DAY_OF_MONTH, day);
+                    tcal.set(Calendar.MONTH, mon - 1);
+                    tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
+                    
+                    int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+                    int dow = tcal.get(Calendar.DAY_OF_WEEK);
+
+                    if(dow == Calendar.SATURDAY && day == 1) {
+                        day += 2;
+                    } else if(dow == Calendar.SATURDAY) {
+                        day -= 1;
+                    } else if(dow == Calendar.SUNDAY && day == ldom) { 
+                        day -= 2;
+                    } else if(dow == Calendar.SUNDAY) { 
+                        day += 1;
+                    }
+                        
+                
+                    tcal.set(Calendar.SECOND, sec);
+                    tcal.set(Calendar.MINUTE, min);
+                    tcal.set(Calendar.HOUR_OF_DAY, hr);
+                    tcal.set(Calendar.DAY_OF_MONTH, day);
+                    tcal.set(Calendar.MONTH, mon - 1);
+                    Date nTime = tcal.getTime();
+                    if(nTime.before(afterTime)) {
+                        day = ((Integer) daysOfMonth.first()).intValue();;
+                        mon++;
+                    }
+                } else if (st != null && st.size() != 0) {
+                    t = day;
+                    day = ((Integer) st.first()).intValue();
+                } else {
+                    day = ((Integer) daysOfMonth.first()).intValue();
+                    mon++;
+                }
+                
+                if (day != t || mon != tmon) {
+                    cl.set(Calendar.SECOND, 0);
+                    cl.set(Calendar.MINUTE, 0);
+                    cl.set(Calendar.HOUR_OF_DAY, 0);
+                    cl.set(Calendar.DAY_OF_MONTH, day);
+                    cl.set(Calendar.MONTH, mon - 1);
+                    // '- 1' because calendar is 0-based for this field, and we
+                    // are 1-based
+                    continue;
+                }
+            } else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule
+                if (lastdayOfWeek) { // are we looking for the last XXX day of
+                    // the month?
+                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    // d-o-w
+                    int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+                    int daysToAdd = 0;
+                    if (cDow < dow) {
+                        daysToAdd = dow - cDow;
+                    }
+                    if (cDow > dow) {
+                        daysToAdd = dow + (7 - cDow);
+                    }
+
+                    int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+
+                    if (day + daysToAdd > lDay) { // did we already miss the
+                        // last one?
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, 1);
+                        cl.set(Calendar.MONTH, mon);
+                        // no '- 1' here because we are promoting the month
+                        continue;
+                    }
+
+                    // find date of last occurance of this day in this month...
+                    while ((day + daysToAdd + 7) <= lDay) {
+                        daysToAdd += 7;
+                    }
+
+                    day += daysToAdd;
+
+                    if (daysToAdd > 0) {
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, day);
+                        cl.set(Calendar.MONTH, mon - 1);
+                        // '- 1' here because we are not promoting the month
+                        continue;
+                    }
+
+                } else if (nthdayOfWeek != 0) {
+                    // are we looking for the Nth XXX day in the month?
+                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    // d-o-w
+                    int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+                    int daysToAdd = 0;
+                    if (cDow < dow) {
+                        daysToAdd = dow - cDow;
+                    } else if (cDow > dow) {
+                        daysToAdd = dow + (7 - cDow);
+                    }
+
+                    boolean dayShifted = false;
+                    if (daysToAdd > 0) {
+                        dayShifted = true;
+                    }
+
+                    day += daysToAdd;
+                    int weekOfMonth = day / 7;
+                    if (day % 7 > 0) {
+                        weekOfMonth++;
+                    }
+
+                    daysToAdd = (nthdayOfWeek - weekOfMonth) * 7;
+                    day += daysToAdd;
+                    if (daysToAdd < 0
+                            || day > getLastDayOfMonth(mon, cl
+                                    .get(Calendar.YEAR))) {
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, 1);
+                        cl.set(Calendar.MONTH, mon);
+                        // no '- 1' here because we are promoting the month
+                        continue;
+                    } else if (daysToAdd > 0 || dayShifted) {
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, day);
+                        cl.set(Calendar.MONTH, mon - 1);
+                        // '- 1' here because we are NOT promoting the month
+                        continue;
+                    }
+                } else {
+                    int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
+                    int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+                    // d-o-w
+                    st = daysOfWeek.tailSet(new Integer(cDow));
+                    if (st != null && st.size() > 0) {
+                        dow = ((Integer) st.first()).intValue();
+                    }
+
+                    int daysToAdd = 0;
+                    if (cDow < dow) {
+                        daysToAdd = dow - cDow;
+                    }
+                    if (cDow > dow) {
+                        daysToAdd = dow + (7 - cDow);
+                    }
+
+                    int lDay = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
+
+                    if (day + daysToAdd > lDay) { // will we pass the end of
+                        // the month?
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, 1);
+                        cl.set(Calendar.MONTH, mon);
+                        // no '- 1' here because we are promoting the month
+                        continue;
+                    } else if (daysToAdd > 0) { // are we swithing days?
+                        cl.set(Calendar.SECOND, 0);
+                        cl.set(Calendar.MINUTE, 0);
+                        cl.set(Calendar.HOUR_OF_DAY, 0);
+                        cl.set(Calendar.DAY_OF_MONTH, day + daysToAdd);
+                        cl.set(Calendar.MONTH, mon - 1);
+                        // '- 1' because calendar is 0-based for this field,
+                        // and we are 1-based
+                        continue;
+                    }
+                }
+            } else { // dayOfWSpec && !dayOfMSpec
+                throw new UnsupportedOperationException(
+                        "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
+                // TODO:
+            }
+            cl.set(Calendar.DAY_OF_MONTH, day);
+
+            mon = cl.get(Calendar.MONTH) + 1;
+            // '+ 1' because calendar is 0-based for this field, and we are
+            // 1-based
+            int year = cl.get(Calendar.YEAR);
+            t = -1;
+
+            // test for expressions that never generate a valid fire date,
+            // but keep looping...
+            if (year > 2099) {
+                return null;
+            }
+
+            // get month...................................................
+            st = months.tailSet(new Integer(mon));
+            if (st != null && st.size() != 0) {
+                t = mon;
+                mon = ((Integer) st.first()).intValue();
+            } else {
+                mon = ((Integer) months.first()).intValue();
+                year++;
+            }
+            if (mon != t) {
+                cl.set(Calendar.SECOND, 0);
+                cl.set(Calendar.MINUTE, 0);
+                cl.set(Calendar.HOUR_OF_DAY, 0);
+                cl.set(Calendar.DAY_OF_MONTH, 1);
+                cl.set(Calendar.MONTH, mon - 1);
+                // '- 1' because calendar is 0-based for this field, and we are
+                // 1-based
+                cl.set(Calendar.YEAR, year);
+                continue;
+            }
+            cl.set(Calendar.MONTH, mon - 1);
+            // '- 1' because calendar is 0-based for this field, and we are
+            // 1-based
+
+            year = cl.get(Calendar.YEAR);
+            t = -1;
+
+            // get year...................................................
+            st = years.tailSet(new Integer(year));
+            if (st != null && st.size() != 0) {
+                t = year;
+                year = ((Integer) st.first()).intValue();
+            } else {
+                return null; // ran out of years...
+            }
+
+            if (year != t) {
+                cl.set(Calendar.SECOND, 0);
+                cl.set(Calendar.MINUTE, 0);
+                cl.set(Calendar.HOUR_OF_DAY, 0);
+                cl.set(Calendar.DAY_OF_MONTH, 1);
+                cl.set(Calendar.MONTH, 0);
+                // '- 1' because calendar is 0-based for this field, and we are
+                // 1-based
+                cl.set(Calendar.YEAR, year);
+                continue;
+            }
+            cl.set(Calendar.YEAR, year);
+
+            gotOne = true;
+        } // while( !done )
+
+        return cl.getTime();
+    }
+
+    /**
+     * Advance the calendar to the particular hour paying particular attention
+     * to daylight saving problems.
+     * 
+     * @param cal
+     * @param hour
+     */
+    protected void setCalendarHour(Calendar cal, int hour) {
+        cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
+        if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
+            cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
+        }
+    }
+
+    /**
+     * NOT YET IMPLEMENTED: Returns the time before the given time
+     * that the <code>CronExpression</code> matches.
+     */ 
+    protected Date getTimeBefore(Date endTime) { 
+        // TODO: implement QUARTZ-423
+        return null;
+    }
+
+    /**
+     * NOT YET IMPLEMENTED: Returns the final time that the 
+     * <code>CronExpression</code> will match.
+     */
+    public Date getFinalFireTime() {
+        // TODO: implement QUARTZ-423
+        return null;
+    }
+    
+    protected boolean isLeapYear(int year) {
+        return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
+    }
+
+    protected int getLastDayOfMonth(int monthNum, int year) {
+
+        switch (monthNum) {
+            case 1:
+                return 31;
+            case 2:
+                return (isLeapYear(year)) ? 29 : 28;
+            case 3:
+                return 31;
+            case 4:
+                return 30;
+            case 5:
+                return 31;
+            case 6:
+                return 30;
+            case 7:
+                return 31;
+            case 8:
+                return 31;
+            case 9:
+                return 30;
+            case 10:
+                return 31;
+            case 11:
+                return 30;
+            case 12:
+                return 31;
+            default:
+                throw new IllegalArgumentException("Illegal month number: "
+                        + monthNum);
+        }
+    }
+    
+
+    private void readObject(java.io.ObjectInputStream stream)
+        throws java.io.IOException, ClassNotFoundException {
+        
+        stream.defaultReadObject();
+        try {
+            buildExpression(cronExpression);
+        } catch (Exception ignore) {
+        } // never happens
+    }    
+    
+    public Object clone() {
+        CronExpression copy = null;
+        try {
+            copy = new CronExpression(getCronExpression());
+            copy.setTimeZone(getTimeZone());
+        } catch (ParseException ex) { // never happens since the source is valid...
+            throw new IncompatibleClassChangeError("Not Cloneable.");
+        }
+        return copy;
+    }        
+}
+
+class ValueSet {
+    public int value;
+
+    public int pos;
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,968 @@
+/* 
+ * Copyright 2004-2005 OpenSymphony 
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
+ * use this file except in compliance with the License. You may obtain a copy 
+ * of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0 
+ *   
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
+ * License for the specific language governing permissions and limitations 
+ * under the License.
+ * 
+ */
+
+/*
+ * Previously Copyright (c) 2001-2004 James House
+ */
+package org.jbpm.pvm.internal.jobexecutor.cron;
+
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * <p>
+ * A concrete <code>{@link Trigger}</code> that is used to fire a <code>{@link org.quartz.JobDetail}</code>
+ * at given moments in time, defined with Unix 'cron-like' definitions.
+ * </p>
+ * 
+ * <p>
+ * For those unfamiliar with "cron", this means being able to create a firing
+ * schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am
+ * every last Friday of the month".
+ * </p>
+ * 
+ * <p>
+ * The format of a "Cron-Expression" string is documented on the 
+ * {@link org.quartz.CronExpression} class.
+ * </p>
+ * 
+ * <p>
+ * Here are some full examples: <br><table cellspacing="8">
+ * <tr>
+ * <th align="left">Expression</th>
+ * <th align="left">&nbsp;</th>
+ * <th align="left">Meaning</th>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 0 12 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 12pm (noon) every day</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * *"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am every day</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am every day</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 * * ? *"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am every day</code></td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 * * ? 2005"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am every day during the year 2005</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 * 14 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire every minute starting at 2pm and ending at 2:59pm, every day</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 0/5 14 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 0/5 14,18 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 0-5 14 * * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire every minute starting at 2pm and ending at 2:05pm, every day</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 10,44 14 ? 3 WED"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * MON-FRI"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 15 * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on the 15th day of every month</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 L * ?"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on the last day of every month</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * 6L"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on the last Friday of every month</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * 6L"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on the last Friday of every month</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * 6L 2002-2005"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005</code>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="left"><code>"0 15 10 ? * 6#3"</code></td>
+ * <td align="left">&nbsp;</th>
+ * <td align="left"><code>Fire at 10:15am on the third Friday of every month</code>
+ * </td>
+ * </tr>
+ * </table>
+ * </p>
+ * 
+ * <p>
+ * Pay attention to the effects of '?' and '*' in the day-of-week and
+ * day-of-month fields!
+ * </p>
+ * 
+ * <p>
+ * <b>NOTES:</b>
+ * <ul>
+ * <li>Support for specifying both a day-of-week and a day-of-month value is
+ * not complete (you'll need to use the '?' character in on of these fields).
+ * </li>
+ * <li>Be careful when setting fire times between mid-night and 1:00 AM -
+ * "daylight savings" can cause a skip or a repeat depending on whether the
+ * time moves back or jumps forward.</li>
+ * </ul>
+ * </p>
+ * 
+ * @see Trigger
+ * @see SimpleTrigger
+ * @see TriggerUtils
+ * 
+ * @author Sharada Jambula, James House
+ * @author Contributions from Mads Henderson
+ */
+public class CronTrigger {
+
+    /*
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     * 
+     * Constants.
+     * 
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     */
+
+    /**
+     * <p>
+     * Instructs the <code>{@link Scheduler}</code> that upon a mis-fire
+     * situation, the <code>updateAfterMisfire()</code> method will be called
+     * on the <code>Trigger</code> to determine the mis-fire instruction.
+     * </p>
+     * 
+     * <p>
+     * In order to see if this instruction fits your needs, you should look at
+     * the documentation for the <code>getSmartMisfirePolicy()</code> method
+     * on the particular <code>Trigger</code> implementation you are using.
+     * </p>
+     */
+    public static final int MISFIRE_INSTRUCTION_SMART_POLICY = 0;
+
+    /**
+     * <p>
+     * Instructs the <code>{@link Scheduler}</code> that upon a mis-fire
+     * situation, the <code>{@link CronTrigger}</code> wants to be fired now
+     * by <code>Scheduler</code>.
+     * </p>
+     */
+    public static final int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW = 1;
+
+    /**
+     * <p>
+     * Instructs the <code>{@link Scheduler}</code> that upon a mis-fire
+     * situation, the <code>{@link CronTrigger}</code> wants to have it's
+     * next-fire-time updated to the next time in the schedule after the
+     * current time (taking into account any associated <code>{@link Calendar}</code>,
+     * but it does not want to be fired now.
+     * </p>
+     */
+    public static final int MISFIRE_INSTRUCTION_DO_NOTHING = 2;
+
+    /*
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     * 
+     * Data members.
+     * 
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     */
+
+    private CronExpression cronEx = null;
+    private Date startTime = null;
+    private Date endTime = null;
+    private Date nextFireTime = null;
+    private Date previousFireTime = null;
+    private transient TimeZone timeZone = null;
+
+    /*
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     * 
+     * Constructors.
+     * 
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     */
+
+    /**
+     * <p>
+     * Create a <code>CronTrigger</code> with no settings.
+     * </p>
+     * 
+     * <p>
+     * The start-time will also be set to the current time, and the time zone
+     * will be set the the system's default time zone.
+     * </p>
+     */
+    public CronTrigger() {
+        super();
+        setStartTime(new Date());
+        setTimeZone(TimeZone.getDefault());
+    }
+
+    /**
+     * <p>
+     * Create a <code>CronTrigger</code> with the given name, group and
+     * expression.
+     * </p>
+     * 
+     * <p>
+     * The start-time will also be set to the current time, and the time zone
+     * will be set the the system's default time zone.
+     * </p>
+     */
+    public CronTrigger(String cronExpression)
+        throws ParseException {
+        
+        setCronExpression(cronExpression);
+        setStartTime(new Date());
+        setTimeZone(TimeZone.getDefault());
+    }
+
+    /**
+     * <p>
+     * Create a <code>CronTrigger</code> with the given name and group,
+     * associated with the identified <code>{@link org.quartz.JobDetail}</code>,
+     * and with the given "cron" expression resolved with respect to the <code>TimeZone</code>.
+     * </p>
+     */
+    public CronTrigger(String cronExpression, TimeZone timeZone)
+        throws ParseException {
+      setCronExpression(cronExpression);
+      setStartTime(new Date());
+      setTimeZone(timeZone);
+    }
+
+    /**
+     * <p>
+     * Create a <code>CronTrigger</code> that will occur at the given time,
+     * until the given end time.
+     * </p>
+     * 
+     * <p>
+     * If null, the start-time will also be set to the current time, the time
+     * zone will be set the the system's default.
+     * </p>
+     * 
+     * @param startTime
+     *          A <code>Date</code> set to the time for the <code>Trigger</code>
+     *          to fire.
+     * @param endTime
+     *          A <code>Date</code> set to the time for the <code>Trigger</code>
+     *          to quit repeat firing.
+     */
+    public CronTrigger(Date startTime, Date endTime, String cronExpression)
+        throws ParseException {
+        setCronExpression(cronExpression);
+
+        if (startTime == null) {
+            startTime = new Date();
+        }
+        setStartTime(startTime);
+        if (endTime != null) {
+            setEndTime(endTime);
+        }
+        setTimeZone(TimeZone.getDefault());
+    }
+
+    /**
+     * <p>
+     * Create a <code>CronTrigger</code> with fire time dictated by the
+     * <code>cronExpression</code> resolved with respect to the specified
+     * <code>timeZone</code> occuring from the <code>startTime</code> until
+     * the given <code>endTime</code>.
+     * </p>
+     * 
+     * <p>
+     * If null, the start-time will also be set to the current time. If null,
+     * the time zone will be set to the system's default.
+     * </p>
+     * 
+     * @param name
+     *          of the <code>Trigger</code>
+     * @param group
+     *          of the <code>Trigger</code>
+     * @param jobName
+     *          name of the <code>{@link org.quartz.JobDetail}</code>
+     *          executed on firetime
+     * @param jobGroup
+     *          group of the <code>{@link org.quartz.JobDetail}</code>
+     *          executed on firetime
+     * @param startTime
+     *          A <code>Date</code> set to the earliest time for the <code>Trigger</code>
+     *          to start firing.
+     * @param endTime
+     *          A <code>Date</code> set to the time for the <code>Trigger</code>
+     *          to quit repeat firing.
+     * @param cronExpression
+     *          A cron expression dictating the firing sequence of the <code>Trigger</code>
+     * @param timeZone
+     *          Specifies for which time zone the <code>cronExpression</code>
+     *          should be interprted, i.e. the expression 0 0 10 * * ?, is
+     *          resolved to 10:00 am in this time zone.
+     * @throws ParseException
+     *           if the <code>cronExpression</code> is invalid.
+     */
+    public CronTrigger(Date startTime, Date endTime,
+            String cronExpression, TimeZone timeZone) throws ParseException {
+        setCronExpression(cronExpression);
+
+        if (startTime == null) {
+            startTime = new Date();
+        }
+        setStartTime(startTime);
+        if (endTime != null) {
+            setEndTime(endTime);
+        }
+        if (timeZone == null) {
+            setTimeZone(TimeZone.getDefault());
+        } else {
+            setTimeZone(timeZone);
+        }
+    }
+
+    /*
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     * 
+     * Interface.
+     * 
+     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+     */
+    
+    public void setCronExpression(String cronExpression) throws ParseException {
+        this.cronEx = new CronExpression(cronExpression);
+        this.cronEx.setTimeZone(getTimeZone());
+    }
+
+    public String getCronExpression() {
+        return cronEx == null ? null : cronEx.getCronExpression();
+    }
+
+    public void setCronExpression(CronExpression cronExpression) {
+        this.cronEx = cronExpression;
+        this.timeZone = cronExpression.getTimeZone();
+    }
+    
+    /**
+     * <p>
+     * Get the time at which the <code>CronTrigger</code> should occur.
+     * </p>
+     */
+    public Date getStartTime() {
+        return this.startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        if (startTime == null) {
+            throw new IllegalArgumentException("Start time cannot be null");
+        }
+
+        Date eTime = getEndTime();
+        if (eTime != null && startTime != null && eTime.before(startTime)) {
+            throw new IllegalArgumentException(
+                "End time cannot be before start time");
+        }
+        
+        // round off millisecond...
+        // Note timeZone is not needed here as parameter for
+        // Calendar.getInstance(),
+        // since time zone is implicit when using a Date in the setTime method.
+        Calendar cl = Calendar.getInstance();
+        cl.setTime(startTime);
+        cl.set(Calendar.MILLISECOND, 0);
+
+        this.startTime = cl.getTime();
+    }
+
+    /**
+     * <p>
+     * Get the time at which the <code>CronTrigger</code> should quit
+     * repeating - even if repeastCount isn't yet satisfied.
+     * </p>
+     * 
+     * @see #getFinalFireTime()
+     */
+    public Date getEndTime() {
+        return this.endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        Date sTime = getStartTime();
+        if (sTime != null && endTime != null && sTime.after(endTime)) {
+            throw new IllegalArgumentException(
+                    "End time cannot be before start time");
+        }
+
+        this.endTime = endTime;
+    }
+
+    /**
+     * <p>
+     * Returns the next time at which the <code>CronTrigger</code> will fire.
+     * If the trigger will not fire again, <code>null</code> will be
+     * returned. The value returned is not guaranteed to be valid until after
+     * the <code>Trigger</code> has been added to the scheduler.
+     * </p>
+     */
+    public Date getNextFireTime() {
+        return this.nextFireTime;
+    }
+
+    /**
+     * <p>
+     * Returns the previous time at which the <code>CronTrigger</code> will
+     * fire. If the trigger has not yet fired, <code>null</code> will be
+     * returned.
+     */
+    public Date getPreviousFireTime() {
+        return this.previousFireTime;
+    }
+
+    /**
+     * <p>
+     * Sets the next time at which the <code>CronTrigger</code> will fire.
+     * <b>This method should not be invoked by client code.</b>
+     * </p>
+     */
+    public void setNextFireTime(Date nextFireTime) {
+        this.nextFireTime = nextFireTime;
+    }
+
+    /**
+     * <p>
+     * Set the previous time at which the <code>CronTrigger</code> fired.
+     * </p>
+     * 
+     * <p>
+     * <b>This method should not be invoked by client code.</b>
+     * </p>
+     */
+    public void setPreviousFireTime(Date previousFireTime) {
+        this.previousFireTime = previousFireTime;
+    }
+
+    /**
+     * <p>
+     * Returns the time zone for which the <code>cronExpression</code> of
+     * this <code>CronTrigger</code> will be resolved.
+     * </p>
+     */
+    public TimeZone getTimeZone() {
+        
+        if(cronEx != null) {
+            return cronEx.getTimeZone();
+        }
+        
+        if (timeZone == null) {
+            timeZone = TimeZone.getDefault();
+        }
+        return timeZone;
+    }
+
+    /**
+     * <p>
+     * Sets the time zone for which the <code>cronExpression</code> of this
+     * <code>CronTrigger</code> will be resolved.
+     * </p>
+     */
+    public void setTimeZone(TimeZone timeZone) {
+        if(cronEx != null) {
+            cronEx.setTimeZone(timeZone);
+        }
+        this.timeZone = timeZone;
+    }
+
+    /**
+     * <p>
+     * Returns the next time at which the <code>CronTrigger</code> will fire,
+     * after the given time. If the trigger will not fire after the given time,
+     * <code>null</code> will be returned.
+     * </p>
+     * 
+     * <p>
+     * Note that the date returned is NOT validated against the related
+     * org.quartz.Calendar (if any)
+     * </p>
+     */
+    public Date getFireTimeAfter(Date afterTime) {
+        if (afterTime == null) {
+            afterTime = new Date();
+        }
+
+        if (getStartTime().after(afterTime)) {
+            afterTime = new Date(getStartTime().getTime() - 1000l);
+        }
+
+        if (getEndTime() != null && (afterTime.compareTo(getEndTime()) >= 0)) {
+            return null;
+        }
+        
+        Date pot = getTimeAfter(afterTime);
+        if (getEndTime() != null && pot != null && pot.after(getEndTime())) {
+            return null;
+        }
+
+        return pot;
+    }
+
+    /**
+     * <p>
+     * NOT YET IMPLEMENTED: Returns the final time at which the 
+     * <code>CronTrigger</code> will fire.
+     * </p>
+     * 
+     * <p>
+     * Note that the return time *may* be in the past. and the date returned is
+     * not validated against org.quartz.calendar
+     * </p>
+     */
+    public Date getFinalFireTime() {
+        Date resultTime;
+        if (getEndTime() != null) {
+            resultTime = getTimeBefore(new Date(getEndTime().getTime() + 1000l));
+        } else {
+            resultTime = (cronEx == null) ? null : cronEx.getFinalFireTime();
+        }
+        
+        if ((resultTime != null) && (getStartTime() != null) && (resultTime.before(getStartTime()))) {
+            return null;
+        } 
+        
+        return resultTime;
+    }
+
+    /**
+     * <p>
+     * Determines whether or not the <code>CronTrigger</code> will occur
+     * again.
+     * </p>
+     */
+    public boolean mayFireAgain() {
+        return (getNextFireTime() != null);
+    }
+
+    protected boolean validateMisfireInstruction(int misfireInstruction) {
+        if (misfireInstruction < MISFIRE_INSTRUCTION_SMART_POLICY) {
+            return false;
+        }
+
+        if (misfireInstruction > MISFIRE_INSTRUCTION_DO_NOTHING) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * <p>
+     * Updates the <code>CronTrigger</code>'s state based on the
+     * MISFIRE_INSTRUCTION_XXX that was selected when the <code>CronTrigger</code>
+     * was created.
+     * </p>
+     * 
+     * <p>
+     * If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY,
+     * then the following scheme will be used: <br>
+     * <ul>
+     * <li>The instruction will be interpreted as <code>MISFIRE_INSTRUCTION_FIRE_ONCE_NOW</code>
+     * </ul>
+     * </p>
+    public void updateAfterMisfire(org.quartz.Calendar cal) {
+        int instr = getMisfireInstruction();
+
+        if (instr == MISFIRE_INSTRUCTION_SMART_POLICY) {
+            instr = MISFIRE_INSTRUCTION_FIRE_ONCE_NOW;
+        }
+
+        if (instr == MISFIRE_INSTRUCTION_DO_NOTHING) {
+            Date newFireTime = getFireTimeAfter(new Date());
+            while (newFireTime != null && cal != null
+                    && !cal.isTimeIncluded(newFireTime.getTime())) {
+                newFireTime = getFireTimeAfter(newFireTime);
+            }
+            setNextFireTime(newFireTime);
+        } else if (instr == MISFIRE_INSTRUCTION_FIRE_ONCE_NOW) {
+            setNextFireTime(new Date());
+        }
+    }
+     */
+
+    /**
+     * <p>
+     * Determines whether the date and (optionally) time of the given Calendar 
+     * instance falls on a scheduled fire-time of this trigger.
+     * </p>
+     * 
+     * <p>
+     * Equivalent to calling <code>willFireOn(cal, false)</code>.
+     * </p>
+     * 
+     * @param test the date to compare
+     * 
+     * @see #willFireOn(Calendar, boolean)
+     */
+    public boolean willFireOn(Calendar test) {
+        return willFireOn(test, false);
+    }
+    
+    /**
+     * <p>
+     * Determines whether the date and (optionally) time of the given Calendar 
+     * instance falls on a scheduled fire-time of this trigger.
+     * </p>
+     * 
+     * <p>
+     * Note that the value returned is NOT validated against the related
+     * org.quartz.Calendar (if any)
+     * </p>
+     * 
+     * @param test the date to compare
+     * @param dayOnly if set to true, the method will only determine if the
+     * trigger will fire during the day represented by the given Calendar
+     * (hours, minutes and seconds will be ignored).
+     * @see #willFireOn(Calendar)
+     */
+    public boolean willFireOn(Calendar test, boolean dayOnly) {
+
+        test = (Calendar) test.clone();
+        
+        test.set(Calendar.MILLISECOND, 0); // don't compare millis.
+        
+        if(dayOnly) {
+            test.set(Calendar.HOUR, 0); 
+            test.set(Calendar.MINUTE, 0); 
+            test.set(Calendar.SECOND, 0); 
+        }
+        
+        Date testTime = test.getTime();
+        
+        Date fta = getFireTimeAfter(new Date(test.getTime().getTime() - 1000));
+
+        Calendar p = Calendar.getInstance(test.getTimeZone());
+        p.setTime(fta);
+        
+        int year = p.get(Calendar.YEAR);
+        int month = p.get(Calendar.MONTH);
+        int day = p.get(Calendar.DATE);
+        
+        if(dayOnly) {
+            return (year == test.get(Calendar.YEAR) 
+                    && month == test.get(Calendar.MONTH) 
+                    && day == test.get(Calendar.DATE));
+        }
+        
+        while(fta.before(testTime)) {
+            fta = getFireTimeAfter(fta);
+        }
+        
+        if(fta.equals(testTime)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * Called after the <code>{@link Scheduler}</code> has executed the
+     * <code>{@link org.quartz.JobDetail}</code> associated with the <code>Trigger</code>
+     * in order to get the final instruction code from the trigger.
+     * </p>
+     * 
+     * @param context
+     *          is the <code>JobExecutionContext</code> that was used by the
+     *          <code>JobImpl</code>'s<code>execute(xx)</code> method.
+     * @param result
+     *          is the <code>JobExecutionException</code> thrown by the
+     *          <code>JobImpl</code>, if any (may be null).
+     * @return one of the Trigger.INSTRUCTION_XXX constants.
+     * 
+     * @see #INSTRUCTION_NOOP
+     * @see #INSTRUCTION_RE_EXECUTE_JOB
+     * @see #INSTRUCTION_DELETE_TRIGGER
+     * @see #INSTRUCTION_SET_TRIGGER_COMPLETE
+     * @see #triggered(Calendar)
+    public int executionComplete(JobExecutionContext context,
+            JobExecutionException result) {
+        if (result != null && result.refireImmediately()) {
+            return INSTRUCTION_RE_EXECUTE_JOB;
+        }
+
+        if (result != null && result.unscheduleFiringTrigger()) {
+            return INSTRUCTION_SET_TRIGGER_COMPLETE;
+        }
+
+        if (result != null && result.unscheduleAllTriggers()) {
+            return INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE;
+        }
+
+        if (!mayFireAgain()) {
+            return INSTRUCTION_DELETE_TRIGGER;
+        }
+
+        return INSTRUCTION_NOOP;
+    }
+     */
+
+    /**
+     * <p>
+     * Called when the <code>{@link Scheduler}</code> has decided to 'fire'
+     * the trigger (execute the associated <code>JobImpl</code>), in order to
+     * give the <code>Trigger</code> a chance to update itself for its next
+     * triggering (if any).
+     * </p>
+     * 
+     * @see #executionComplete(JobExecutionContext, JobExecutionException)
+     */
+    public void triggered(/*org.quartz.Calendar calendar*/) {
+        previousFireTime = nextFireTime;
+        nextFireTime = getFireTimeAfter(nextFireTime);
+
+        while (nextFireTime != null /* && calendar != null
+                                       && !calendar.isTimeIncluded(nextFireTime.getTime()) */
+              ) {
+            nextFireTime = getFireTimeAfter(nextFireTime);
+        }
+    }
+
+    /**
+     *  
+     * @see org.quartz.Trigger#updateWithNewCalendar(org.quartz.Calendar, long)
+    public void updateWithNewCalendar(org.quartz.Calendar calendar, long misfireThreshold)
+    {
+        nextFireTime = getFireTimeAfter(previousFireTime);
+        
+        Date now = new Date();
+        do {
+            while (nextFireTime != null && calendar != null
+                    && !calendar.isTimeIncluded(nextFireTime.getTime())) {
+                nextFireTime = getFireTimeAfter(nextFireTime);
+            }
+            
+            if(nextFireTime != null && nextFireTime.before(now)) {
+                long diff = now.getTime() - nextFireTime.getTime();
+                if(diff >= misfireThreshold) {
+                    nextFireTime = getFireTimeAfter(nextFireTime);
+                    continue;
+                }
+            }
+        }while(false);
+    }
+     */
+
+    /**
+     * <p>
+     * Called by the scheduler at the time a <code>Trigger</code> is first
+     * added to the scheduler, in order to have the <code>Trigger</code>
+     * compute its first fire time, based on any associated calendar.
+     * </p>
+     * 
+     * <p>
+     * After this method has been called, <code>getNextFireTime()</code>
+     * should return a valid answer.
+     * </p>
+     * 
+     * @return the first time at which the <code>Trigger</code> will be fired
+     *         by the scheduler, which is also the same value <code>getNextFireTime()</code>
+     *         will return (until after the first firing of the <code>Trigger</code>).
+     *         </p>
+     */
+    public Date computeFirstFireTime(/*org.quartz.Calendar calendar*/) {
+        nextFireTime = getFireTimeAfter(new Date(getStartTime().getTime() - 1000l));
+
+        while (nextFireTime != null /* && calendar != null
+                                       && !calendar.isTimeIncluded(nextFireTime.getTime()) */
+               ) { 
+            nextFireTime = getFireTimeAfter(nextFireTime);
+        }
+
+        return nextFireTime;
+    }
+
+    public String getExpressionSummary() {
+        return cronEx == null ? null : cronEx.getExpressionSummary();
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    //
+    // Computation Functions
+    //
+    ////////////////////////////////////////////////////////////////////////////
+
+    protected Date getTimeAfter(Date afterTime) {
+        return (cronEx == null) ? null : cronEx.getTimeAfter(afterTime);
+    }
+
+    /**
+     * NOT YET IMPLEMENTED: Returns the time before the given time
+     * that this <code>CronTrigger</code> will fire.
+     */ 
+    protected Date getTimeBefore(Date endTime) {
+        return (cronEx == null) ? null : cronEx.getTimeBefore(endTime);
+    }
+
+    /*
+    public static void main(String[] args) // TODO: remove method after good
+        // unit testing
+        throws Exception {
+
+        String expr = "15 10 0/4 * * ?";
+        if(args != null && args.length > 0 && args[0] != null) {
+            expr = args[0];
+        }
+    
+        CronTrigger ct = new CronTrigger("t", "g", "j", "g", new Date(), null, expr);
+        ct.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
+        System.err.println(ct.getExpressionSummary());
+        System.err.println("tz=" + ct.getTimeZone().getID());
+        System.err.println();
+    
+        java.util.List times = TriggerUtils.computeFireTimes(ct, null, 25);
+    
+        for (int i = 0; i < times.size(); i++) {
+            System.err.println("firetime = " + times.get(i));
+        }
+        
+        Calendar tt = Calendar.getInstance();
+        tt.set(Calendar.DATE, 17);
+        tt.set(Calendar.MONTH, 5 - 1);
+        tt.set(Calendar.HOUR, 11);
+        tt.set(Calendar.MINUTE, 0);
+        tt.set(Calendar.SECOND, 7);
+        
+        System.err.println("\nWill fire on: " + tt.getTime() + " -- " + ct.willFireOn(tt, false));
+        
+      
+//            CRON Expression: 0 0 9 * * ?
+//
+//                    TimeZone.getDefault().getDisplayName() = Central African Time
+//                    TimeZone.getDefault().getID() = Africa/Harare            
+    //
+////        System.err.println();
+////        System.err.println();
+////        System.err.println();
+////        System.err.println("Daylight test:");
+////
+////        CronTrigger trigger = new CronTrigger();
+////
+////        TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles");
+////        //    TimeZone timeZone = TimeZone.getDefault();
+////
+////        trigger.setTimeZone(timeZone);
+////        trigger.setCronExpression("0 0 1 ? 4 *");
+////
+////        Date start = new Date(1056319200000L);
+////        Date end = new Date(1087682399000L);
+////
+////        trigger.setStartTime(start);
+////        trigger.setEndTime(end);
+////
+////        Date next = new Date(1056232800000L);
+////        while (next != null) {
+////            next = trigger.getFireTimeAfter(next);
+////            if (next != null) {
+////                Calendar cal = Calendar.getInstance();
+////                cal.setTimeZone(timeZone);
+////                cal.setTime(next);
+////                System.err.println(cal.get(Calendar.MONTH) + "/"
+////                        + cal.get(Calendar.DATE) + "/" + cal.get(Calendar.YEAR)
+////                        + " - " + cal.get(Calendar.HOUR_OF_DAY) + ":"
+////                        + cal.get(Calendar.MINUTE));
+////            }
+////        }
+////
+////        System.err.println();
+////        System.err.println();
+////        System.err.println();
+////        System.err.println("Midnight test:");
+////
+////        trigger = new CronTrigger();
+////
+////        timeZone = TimeZone.getTimeZone("Asia/Jerusalem");
+////        //    timeZone = TimeZone.getTimeZone("America/Los_Angeles");
+////        //    TimeZone timeZone = TimeZone.getDefault();
+////
+////        trigger.setTimeZone(timeZone);
+////        trigger.setCronExpression("0 /15 * ? 4 *");
+////
+////        start = new Date(1056319200000L);
+////        end = new Date(1087682399000L);
+////
+////        trigger.setStartTime(start);
+////        trigger.setEndTime(end);
+////
+////        next = new Date(1056232800000L);
+////        while (next != null) {
+////            next = trigger.getFireTimeAfter(next);
+////            if (next != null) {
+////                Calendar cal = Calendar.getInstance();
+////                cal.setTimeZone(timeZone);
+////                cal.setTime(next);
+////                System.err.println(cal.get(Calendar.MONTH) + "/"
+////                        + cal.get(Calendar.DATE) + "/" + cal.get(Calendar.YEAR)
+////                        + " - " + cal.get(Calendar.HOUR_OF_DAY) + ":"
+////                        + cal.get(Calendar.MINUTE));
+////            }
+////        }
+    }
+ */
+}
+

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,235 @@
+package org.jbpm.pvm.internal.tx;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Configuration;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.WireTestCase;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class EnlistTest extends WireTestCase {
+
+  public void setUp() throws Exception {
+    super.setUp();
+    MyResource.events = new ArrayList<String>();
+  }
+
+  public void tearDown() throws Exception {
+    MyResource.events = null;
+    super.tearDown();
+  }
+  
+  public static Environment openEnvironment(String xmlString) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) 
+        new Configuration().setXmlString(xmlString).buildProcessEngine();
+    return environmentFactory.openEnvironment();
+  }
+
+  public static class MyResource implements StandardResource {
+    public static List<String> events = null;
+    public void commit() { events.add("commit"); }
+    public void flush() { events.add("flush"); }
+    public void prepare() { events.add("prepare"); }
+    public void rollback() { events.add("rollback"); }
+  }
+
+  public void testEnlist() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction name='tx' />" +
+      "    <object name='o' class='"+ MyResource.class.getName()+"'>" +
+      "      <enlist transaction='tx'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try {
+      Object o = environment.get("o");
+      assertNotNull(o);
+      StandardTransaction t = (StandardTransaction) environment.get("tx");
+      t.begin();
+      assertNotNull(t);
+      assertTrue(t.getResources().contains(o));
+      assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+      t.complete();
+      assertEquals(MyResource.events.toString(), 2, MyResource.events.size());
+      assertEquals("prepare", MyResource.events.get(0));
+      assertEquals("commit", MyResource.events.get(1));
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnlistRollback() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction name='tx' />" +
+      "    <object name='o' class='"+ MyResource.class.getName()+"'>" +
+      "      <enlist transaction='tx'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try {
+      Object o = environment.get("o");
+      assertNotNull(o);
+      StandardTransaction t = (StandardTransaction) environment.get("tx");
+      t.begin();
+      assertNotNull(t);
+      assertTrue(t.getResources().contains(o));
+      assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+      t.setRollbackOnly();
+      t.complete();
+      assertEquals(MyResource.events.toString(), 1, MyResource.events.size());
+      assertEquals("rollback", MyResource.events.get(0));
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnlistInOtherContext() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction name='tx' />" +
+      "    <object name='o' class='"+ MyResource.class.getName()+"'>" +
+      "      <enlist transaction='tx'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try {
+      WireContext context = createWireContext("<objects>" + " <object name='o' class='" + MyResource.class.getName() + "'>" + "  <enlist transaction='tx'/>"
+              + " </object>" + "</objects>");
+      environment.addContext(context);
+      Object o = environment.get("o");
+      assertNotNull(o);
+      StandardTransaction t = (StandardTransaction) environment.get("tx");
+      t.begin();
+      assertNotNull(t);
+      assertTrue(t.getResources().contains(o));
+      assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+      t.complete();
+      assertEquals(MyResource.events.toString(), 2, MyResource.events.size());
+      assertEquals("prepare", MyResource.events.get(0));
+      assertEquals("commit", MyResource.events.get(1));
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnlistInOtherContextWithRollback() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction name='tx' />" +
+      "    <object name='o' class='"+ MyResource.class.getName()+"'>" +
+      "      <enlist transaction='tx'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try {
+      WireContext context = createWireContext("<objects>" + " <object name='o' class='" + MyResource.class.getName() + "'>" + "  <enlist transaction='tx'/>"
+              + " </object>" + "</objects>");
+      environment.addContext(context);
+      Object o = environment.get("o");
+      assertNotNull(o);
+      StandardTransaction t = (StandardTransaction) environment.get("tx");
+      t.begin();
+      assertNotNull(t);
+      assertTrue(t.getResources().contains(o));
+      assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+      t.setRollbackOnly();
+      t.complete();
+      assertEquals(MyResource.events.toString(), 1, MyResource.events.size());
+      assertEquals("rollback", MyResource.events.get(0));
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnlistNotAResource() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction name='transaction' />" +
+      "    <object name='o' class='java.lang.Object'>" +
+      "      <enlist transaction='transaction'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    
+    try{
+      environment.get("o");
+      fail("expected exeption");
+    } catch (WireException e) {
+      assertTextPresent("couldn't initialize object 'o':", e.getMessage());
+      assertTextPresent("operation enlist can only be applied on objects that implement org.jbpm.pvm.internal.tx.StandardResource", e.getMessage());
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testEnlistNotATransaction() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <object name='o' class='"+MyResource.class.getName()+"'>" +
+      "      <enlist transaction='tx'/>" +
+      "    </object>" +
+      "    <object name='tx' class='java.lang.Object'/>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try{
+      environment.get("o");
+      fail("expected exeption");
+    } catch (WireException e) {
+      assertTextPresent("couldn't initialize object 'o':", e.getMessage());
+      assertTextPresent("couldn't find org.jbpm.pvm.internal.tx.StandardTransaction 'tx' to enlist resource ", e.getMessage());
+    } finally {
+      environment.close();
+    }
+  }
+
+  public void testMissingTransactionName() {
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    try{
+      assertNotNull(environment.get(Transaction.class));
+      assertNotNull(environment.get(StandardTransaction.class));
+    } finally {
+      environment.close();
+    }
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+
+public class TestResource implements StandardResource {
+  
+  boolean isPrepared;
+  boolean isCommitted;
+  boolean isRolledBack;
+  
+  public void prepare() {
+    isPrepared = true;
+  }
+  public void commit() {
+    isCommitted = true;
+  }
+  public void rollback() {
+    isRolledBack = true;
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.Configuration;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionFailingCommitTest extends BaseJbpmTestCase {
+  
+  public static class CommitException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+    public CommitException(String msg) {
+      super(msg);
+    }
+  }
+  
+  public static class FailingPrepareResource extends TestResource {
+    public void prepare() {
+      super.prepare();
+      throw new CommitException("resource couldn't prepare");
+    }
+  }
+
+  public static Environment openEnvironment(String xmlString) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) 
+        new Configuration().setXmlString(xmlString).buildProcessEngine();
+    return environmentFactory.openEnvironment();
+  }
+
+
+  public void testMultipleResourcesFailingPrepare() {
+    TestResource resourceOne = null;
+    TestResource resourceTwo = null;
+    TestResource resourceThree = null;
+    
+    try {
+      Environment environment = openEnvironment(
+        "<jbpm-configuration>" +
+        "  <process-engine/>"+
+        "  <transaction-context>" +
+        "    <transaction />" +
+        "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "    <object name='resourceTwo' class='"+FailingPrepareResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+      );
+      try {
+        StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+        standardTransaction.begin();
+
+        resourceOne = (TestResource) environment.get("resourceOne");
+        assertFalse(resourceOne.isPrepared);
+        assertFalse(resourceOne.isCommitted);
+        assertFalse(resourceOne.isRolledBack);
+
+        resourceTwo = (TestResource) environment.get("resourceTwo");
+        assertFalse(resourceTwo.isPrepared);
+        assertFalse(resourceTwo.isCommitted);
+        assertFalse(resourceTwo.isRolledBack);
+        
+        resourceThree = (TestResource) environment.get("resourceThree");
+        assertFalse(resourceThree.isPrepared);
+        assertFalse(resourceThree.isCommitted);
+        assertFalse(resourceThree.isRolledBack);
+        
+        standardTransaction.complete();
+
+      } finally {
+        environment.close();
+      }
+      fail("expected exception");
+    } catch (CommitException e) {
+      // OK
+    }
+    
+    assertTrue(resourceOne.isPrepared);
+    assertFalse(resourceOne.isCommitted);
+    assertTrue(resourceOne.isRolledBack);
+    
+    assertTrue(resourceTwo.isPrepared);
+    assertFalse(resourceTwo.isCommitted);
+    assertTrue(resourceTwo.isRolledBack);
+    
+    assertFalse(resourceThree.isPrepared);
+    assertFalse(resourceThree.isCommitted);
+    assertTrue(resourceThree.isRolledBack);
+  }
+
+  public static class FailingCommitResource extends TestResource {
+    public void commit() {
+      super.commit();
+      throw new CommitException("resource couldn't commit");
+    }
+  }
+
+  public void testMultipleResourcesFailingCommit() {
+    TestResource resourceOne = null;
+    TestResource resourceTwo = null;
+    TestResource resourceThree = null;
+    
+    try {
+      Environment environment = openEnvironment(
+        "<jbpm-configuration>" +
+        "  <process-engine/>"+
+        "  <transaction-context>" +
+        "    <transaction />" +
+        "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "    <object name='resourceTwo' class='"+FailingCommitResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+        "      <enlist />" +
+        "    </object>" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+      );
+      try {
+        StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+        standardTransaction.begin();
+
+        resourceOne = (TestResource) environment.get("resourceOne");
+        assertFalse(resourceOne.isPrepared);
+        assertFalse(resourceOne.isCommitted);
+        assertFalse(resourceOne.isRolledBack);
+
+        resourceTwo = (TestResource) environment.get("resourceTwo");
+        assertFalse(resourceTwo.isPrepared);
+        assertFalse(resourceTwo.isCommitted);
+        assertFalse(resourceTwo.isRolledBack);
+        
+        resourceThree = (TestResource) environment.get("resourceThree");
+        assertFalse(resourceThree.isPrepared);
+        assertFalse(resourceThree.isCommitted);
+        assertFalse(resourceThree.isRolledBack);
+        
+        standardTransaction.complete();
+
+      } finally {
+        environment.close();
+      }
+      fail("expected exception");
+    } catch (CommitException e) {
+      // OK
+    }
+    
+    assertTrue(resourceOne.isPrepared);
+    assertTrue(resourceOne.isCommitted);
+    assertFalse(resourceOne.isRolledBack);
+    
+    assertTrue(resourceTwo.isPrepared);
+    assertTrue(resourceTwo.isCommitted);
+    assertFalse(resourceTwo.isRolledBack);
+    
+    assertTrue(resourceThree.isPrepared);
+    assertTrue(resourceThree.isCommitted);
+    assertFalse(resourceThree.isRolledBack);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.Configuration;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionResourcesCommitTest extends BaseJbpmTestCase {
+  
+  public static Environment openEnvironment(String xmlString) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) 
+        new Configuration().setXmlString(xmlString).buildProcessEngine();
+    return environmentFactory.openEnvironment();
+  }
+
+
+  public void testOneResourceCommit() {
+
+    TestResource resourceOne = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceOne = (TestResource) environment.get("resourceOne");
+      
+      assertFalse(resourceOne.isPrepared);
+      assertFalse(resourceOne.isCommitted);
+      assertFalse(resourceOne.isRolledBack);
+      
+      standardTransaction.complete();
+
+    } finally {
+      environment.close();
+    }
+    
+    assertTrue(resourceOne.isPrepared);
+    assertTrue(resourceOne.isCommitted);
+    assertFalse(resourceOne.isRolledBack);
+  }
+
+  public void testMultipleResourcesCommit() {
+    TestResource resourceOne = null;
+    TestResource resourceTwo = null;
+    TestResource resourceThree = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceOne = (TestResource) environment.get("resourceOne");
+      assertFalse(resourceOne.isPrepared);
+      assertFalse(resourceOne.isCommitted);
+      assertFalse(resourceOne.isRolledBack);
+
+      resourceTwo = (TestResource) environment.get("resourceTwo");
+      assertFalse(resourceTwo.isPrepared);
+      assertFalse(resourceTwo.isCommitted);
+      assertFalse(resourceTwo.isRolledBack);
+   
+      resourceThree = (TestResource) environment.get("resourceThree");
+      assertFalse(resourceThree.isPrepared);
+      assertFalse(resourceThree.isCommitted);
+      assertFalse(resourceThree.isRolledBack);
+
+      standardTransaction.complete();
+
+    } finally {
+      environment.close();
+    }
+    
+    assertTrue(resourceOne.isPrepared);
+    assertTrue(resourceOne.isCommitted);
+    assertFalse(resourceOne.isRolledBack);
+    
+    assertTrue(resourceTwo.isPrepared);
+    assertTrue(resourceTwo.isCommitted);
+    assertFalse(resourceTwo.isRolledBack);
+    
+    assertTrue(resourceThree.isPrepared);
+    assertTrue(resourceThree.isCommitted);
+    assertFalse(resourceThree.isRolledBack);
+  }
+
+  public void testFetchOneResourceOutOfManyCommit() {
+    TestResource resourceTwo = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceTwo = (TestResource) environment.get("resourceTwo");
+      assertFalse(resourceTwo.isPrepared);
+      assertFalse(resourceTwo.isCommitted);
+      assertFalse(resourceTwo.isRolledBack);
+      
+      assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+      standardTransaction.complete();
+
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+    assertTrue(resourceTwo.isPrepared);
+    assertTrue(resourceTwo.isCommitted);
+    assertFalse(resourceTwo.isRolledBack);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.Configuration;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionResourcesSetRollbackOnlyTest extends BaseJbpmTestCase {
+
+  public static Environment openEnvironment(String xmlString) {
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) 
+        new Configuration().setXmlString(xmlString).buildProcessEngine();
+    return environmentFactory.openEnvironment();
+  }
+
+
+  public void testOneResourceSetRollbackOnly() {
+
+    TestResource resourceOne = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceOne = (TestResource) environment.get("resourceOne");
+      
+      environment.get(Transaction.class).setRollbackOnly();
+      
+      assertFalse(resourceOne.isPrepared);
+      assertFalse(resourceOne.isCommitted);
+      assertFalse(resourceOne.isRolledBack);
+      
+      standardTransaction.complete();
+      
+    } finally {
+      environment.close();
+    }
+    
+    assertFalse(resourceOne.isPrepared);
+    assertFalse(resourceOne.isCommitted);
+    assertTrue(resourceOne.isRolledBack);
+  }
+
+  public void testMultipleResourcesSetRollbackOnly() {
+    TestResource resourceOne = null;
+    TestResource resourceTwo = null;
+    TestResource resourceThree = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceOne = (TestResource) environment.get("resourceOne");
+      assertFalse(resourceOne.isPrepared);
+      assertFalse(resourceOne.isCommitted);
+      assertFalse(resourceOne.isRolledBack);
+
+      environment.get(Transaction.class).setRollbackOnly();
+      
+      resourceTwo = (TestResource) environment.get("resourceTwo");
+      assertFalse(resourceTwo.isPrepared);
+      assertFalse(resourceTwo.isCommitted);
+      assertFalse(resourceTwo.isRolledBack);
+      
+      resourceThree = (TestResource) environment.get("resourceThree");
+      assertFalse(resourceThree.isPrepared);
+      assertFalse(resourceThree.isCommitted);
+      assertFalse(resourceThree.isRolledBack);
+      
+      standardTransaction.complete();
+      
+    } finally {
+      environment.close();
+    }
+    
+    assertFalse(resourceOne.isPrepared);
+    assertFalse(resourceOne.isCommitted);
+    assertTrue(resourceOne.isRolledBack);
+    
+    assertFalse(resourceTwo.isPrepared);
+    assertFalse(resourceTwo.isCommitted);
+    assertTrue(resourceTwo.isRolledBack);
+    
+    assertFalse(resourceThree.isPrepared);
+    assertFalse(resourceThree.isCommitted);
+    assertTrue(resourceThree.isRolledBack);
+  }
+
+  public void testFetchOneResourceOutOfManySetRollbackOnly() {
+    TestResource resourceTwo = null;
+    
+    Environment environment = openEnvironment(
+      "<jbpm-configuration>" +
+      "  <process-engine/>"+
+      "  <transaction-context>" +
+      "    <transaction />" +
+      "    <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "    <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+      "      <enlist />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+    try {
+      StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+      standardTransaction.begin();
+
+      resourceTwo = (TestResource) environment.get("resourceTwo");
+      assertFalse(resourceTwo.isPrepared);
+      assertFalse(resourceTwo.isCommitted);
+      assertFalse(resourceTwo.isRolledBack);
+
+      environment.get(Transaction.class).setRollbackOnly();
+
+      assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+      
+      standardTransaction.complete();
+      
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+    assertFalse(resourceTwo.isPrepared);
+    assertFalse(resourceTwo.isCommitted);
+    assertTrue(resourceTwo.isRolledBack);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TxTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("org.jbpm.pvm.internal.tx");
+    //$JUnit-BEGIN$
+    suite.addTestSuite(TransactionResourcesCommitTest.class);
+    suite.addTestSuite(TransactionResourcesSetRollbackOnlyTest.class);
+    suite.addTestSuite(EnlistTest.class);
+    suite.addTestSuite(TransactionFailingCommitTest.class);
+    //$JUnit-END$
+    return suite;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,297 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.type;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.type.variable.BlobVariable;
+import org.jbpm.pvm.internal.type.variable.ClobVariable;
+import org.jbpm.pvm.internal.type.variable.DoubleVariable;
+import org.jbpm.pvm.internal.type.variable.LongVariable;
+import org.jbpm.pvm.internal.type.variable.StringVariable;
+import org.jbpm.pvm.test.EnvironmentTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableAutoTypeResolutionTest extends EnvironmentTestCase {
+
+  public VariableAutoTypeResolutionTest() {
+    super("org/jbpm/pvm/internal/type/environment.cfg.xml");
+  }
+
+  public static ExecutionImpl startProcessInstance() {
+    return (ExecutionImpl) ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity(WaitState.class).initial()
+      .endActivity()
+    .endProcess()
+    .startProcessInstance();
+  }
+  
+  public void testStringVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", "hello");
+    
+    Variable variable = execution.getVariableObject("v");
+    
+    assertEquals(StringVariable.class, variable.getClass());
+    StringVariable stringVariable = (StringVariable) variable;
+    assertEquals("hello", stringVariable.getObject());
+    
+    assertEquals("hello", execution.getVariable("v"));
+  }
+
+  public void testLongVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Long(5));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(LongVariable.class, variable.getClass());
+    LongVariable longVariable = (LongVariable) variable;
+    assertEquals(new Long(5), longVariable.getObject());
+
+    assertEquals(new Long(5), execution.getVariable("v"));
+  }
+
+  public void testDoubleVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Double(5.5));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(DoubleVariable.class, variable.getClass());
+    DoubleVariable doubleVariable = (DoubleVariable) variable;
+    assertEquals(new Double(5.5), doubleVariable.getObject());
+
+    assertEquals(new Double(5.5), execution.getVariable("v"));
+  }
+
+  public void testDateVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    Calendar calendar = new GregorianCalendar();
+    calendar.set(Calendar.YEAR, 2007);
+    calendar.set(Calendar.MONTH, 10); // (10 == november)
+    calendar.set(Calendar.DAY_OF_MONTH, 22);
+    calendar.set(Calendar.HOUR_OF_DAY, 15);
+    calendar.set(Calendar.MINUTE, 28);
+    calendar.set(Calendar.SECOND, 57);
+    calendar.set(Calendar.MILLISECOND, 374);
+    
+    execution.setVariable("v", calendar.getTime());
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(StringVariable.class, variable.getClass());
+    StringVariable stringVariable = (StringVariable) variable;
+    assertEquals("2007-11-22 15:28:57,374", stringVariable.getObject());
+
+    assertEquals(calendar.getTime(), execution.getVariable("v"));
+  }
+
+  public void testBooleanVariable() {
+    ExecutionImpl execution = startProcessInstance();
+
+    execution.setVariable("affirmative", Boolean.TRUE);
+    execution.setVariable("negative", Boolean.FALSE);
+    
+    Variable variable = execution.getVariableObject("affirmative");
+    assertEquals(StringVariable.class, variable.getClass());
+    StringVariable stringVariable = (StringVariable) variable;
+    assertEquals("T", stringVariable.getObject());
+    
+    variable = execution.getVariableObject("negative");
+    assertEquals(StringVariable.class, variable.getClass());
+    stringVariable = (StringVariable) variable;
+    assertEquals("F", stringVariable.getObject());
+
+    assertEquals(Boolean.TRUE, execution.getVariable("affirmative"));
+    assertEquals(Boolean.FALSE, execution.getVariable("negative"));
+  }
+
+  public void testCharacterVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Character('c'));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(StringVariable.class, variable.getClass());
+    StringVariable stringVariable = (StringVariable) variable;
+    assertEquals("c", stringVariable.getObject());
+    
+    assertEquals(new Character('c'), execution.getVariable("v"));
+  }
+
+  public void testByteVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Byte((byte)78));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(LongVariable.class, variable.getClass());
+    LongVariable longVariable = (LongVariable) variable;
+    assertEquals(new Long(78), longVariable.getObject());
+    
+    assertEquals(new Byte((byte)78), execution.getVariable("v"));
+  }
+
+  public void testShortVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Short((short)78));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(LongVariable.class, variable.getClass());
+    LongVariable longVariable = (LongVariable) variable;
+    assertEquals(new Long(78), longVariable.getObject());
+    
+    assertEquals(new Short((short)78), execution.getVariable("v"));
+  }
+
+  public void testIntegerVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Integer(78));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(LongVariable.class, variable.getClass());
+    LongVariable longVariable = (LongVariable) variable;
+    assertEquals(new Long(78), longVariable.getObject());
+    
+    assertEquals(new Integer(78), execution.getVariable("v"));
+  }
+
+  public void testFloatVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    execution.setVariable("v", new Float(78.65));
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(DoubleVariable.class, variable.getClass());
+    DoubleVariable doubleVariable = (DoubleVariable) variable;
+    assertEquals(new Double((float)78.65), doubleVariable.getObject());
+    
+    assertEquals(new Float(78.65), execution.getVariable("v"));
+  }
+
+  public void testBytesVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    byte[] bytes = generateBytes("a lot of bytes ", 500);
+    execution.setVariable("v", bytes);
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(BlobVariable.class, variable.getClass());
+    
+    BlobVariable blobVariable = (BlobVariable) variable;
+    byte[] blobVariableBytes = (byte[]) blobVariable.getValue();
+    assertTrue(Arrays.equals(bytes, blobVariableBytes));
+  }
+
+  public void testCharsVariable() {
+    ExecutionImpl execution = startProcessInstance();
+    
+    char[] chars = generateChars("a lot of bytes ", 500);
+    execution.setVariable("v", chars);
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(ClobVariable.class, variable.getClass());
+    
+    assertTrue(Arrays.equals(chars, (char[]) execution.getVariable("v")));
+  }
+
+  public static class TestSerializable implements Serializable {
+    private static final long serialVersionUID = 1L;
+    int member;
+    TestSerializable(int member){this.member = member;}
+    public boolean equals(Object o) {
+      if (! (o instanceof TestSerializable)) return false;
+      return ( member == ((TestSerializable)o).member );
+    }
+  }
+
+  public void testSerializableVariable() throws Exception {
+    ExecutionImpl execution = startProcessInstance();
+    
+    TestSerializable testSerializable = new TestSerializable(76);
+    execution.setVariable("v", testSerializable);
+    
+    Variable variable = execution.getVariableObject("v");
+    
+    assertEquals(BlobVariable.class, variable.getClass());
+    BlobVariable blobVariable = (BlobVariable) variable;
+
+    // blobVariable.getObject(); is used to get the bare bytes.
+    // blobVariable.getValue() would also use the converter and 
+    // then the deserialized object is returned
+    // ...good idea i'll test that as well below :-)
+    byte[] blobVariableBytes = (byte[]) blobVariable.getObject();
+    byte[] expected = serialize(testSerializable);
+
+    assertTrue(Arrays.equals(expected, blobVariableBytes));
+    
+    Object deserialized = blobVariable.getValue();
+    assertNotNull(deserialized);
+    assertEquals(testSerializable, deserialized);
+  }
+
+  private byte[] serialize(TestSerializable testSerializable) {
+    try {
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+      oos.writeObject(testSerializable);
+      oos.flush();
+      oos.close();
+      return baos.toByteArray();
+    } catch (IOException e) {
+      throw new RuntimeException("couldn't serialize", e);
+    }
+  }
+  
+  String generateString(String base, int multiplier) {
+    StringBuffer buffer = new StringBuffer();
+    for (int i=0; i<multiplier; i++) {
+      buffer.append(base);
+    }
+    String string = buffer.toString();
+    return string;
+  }
+
+  byte[] generateBytes(String base, int multiplier) {
+    return generateString(base, multiplier).getBytes();
+  }
+
+  char[] generateChars(String base, int multiplier) {
+    return generateString(base, multiplier).toCharArray();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/util/FileUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/util/FileUtil.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/util/FileUtil.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.util;
+
+import java.io.File;
+import java.net.URL;
+import java.util.StringTokenizer;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class FileUtil {
+
+  private static final String FILE_SEPARATOR = System.getProperty("file.separator");
+
+  public static String getFileNameForResource(String resource) throws Exception {
+    String testClassesUrl = FileUtil.class.getProtectionDomain().getCodeSource().getLocation().toString();
+    URL fileUrl = new URL(testClassesUrl);
+    File file = new File(fileUrl.toURI());
+    String fileName = file.getAbsolutePath();
+
+    StringTokenizer tokenizer = new StringTokenizer(resource, "/");
+    while (tokenizer.hasMoreTokens()) {
+      fileName = fileName+FILE_SEPARATOR+tokenizer.nextToken(); 
+    }
+    
+    return fileName; 
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class AutoWireTest extends WireTestCase {
+
+  public static class Shape {
+  }
+  public static class Square extends Shape {
+  }
+
+  public static class PieceOfCake {
+
+    // auto-wire means that when an object like this is create,
+    // that the WireScope will try to look for objects with
+    // the same name as the fields in the class.  If it finds
+    // an object with that name, and if it is assignable to the
+    // field's type, it is automatically injected, without the
+    // need for explicit <field /> tag that specifies the injection
+    // in the wiring xml.
+
+    String color;
+    long size;
+    Shape shape;
+
+    public String getColor() {
+      return color;
+    }
+    public Shape getShape() {
+      return shape;
+    }
+    public long getSize() {
+      return size;
+    }
+  }
+
+  public void testAutoWireDefaultOff() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='pieceOfCake' class='"+PieceOfCake.class.getName()+"' />" +
+      "  <string name='color' value='green' />" +
+      "  <long name='size' value='23' />" +
+      "  <object name='shape' class='"+Square.class.getName()+"' />" +
+      "</objects>"
+    );
+
+    PieceOfCake pieceOfCake = (PieceOfCake) wireContext.get("pieceOfCake");
+    assertNull("green", pieceOfCake.getColor());
+    assertNull(pieceOfCake.getShape());
+    assertEquals(0L, pieceOfCake.getSize());
+  }
+
+  public void testAutoWire() {
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        // auto-wire values can be one of enabled, on, yes, true
+        "  <object auto-wire='enabled' name='pieceOfCake' class='"+PieceOfCake.class.getName()+"' />" +
+        "  <string name='color' value='green' />" +
+        "  <long name='size' value='23' />" +
+        "  <object name='shape' class='"+Square.class.getName()+"' />" +
+        "</objects>"
+      );
+
+    PieceOfCake pieceOfCake = (PieceOfCake) wireContext.get("pieceOfCake");
+    assertEquals("green", pieceOfCake.getColor());
+    assertEquals(Square.class, pieceOfCake.getShape().getClass());
+    assertEquals(23L, pieceOfCake.getSize());
+  }
+
+  public void testAutoWireWrongType() {
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        // auto-wire values can be one of enabled, on, true
+        "  <object auto-wire='enabled' name='pieceOfCake' class='"+PieceOfCake.class.getName()+"' />" +
+        "  <long name='color' value='23' />" +
+        "  <string name='size' value='green' />" +
+        "  <object name='shape' class='"+Square.class.getName()+"' />" +
+        "</objects>"
+      );
+
+    PieceOfCake pieceOfCake = (PieceOfCake) wireContext.get("pieceOfCake");
+    assertNull(pieceOfCake.getColor());
+    assertEquals(Square.class, pieceOfCake.getShape().getClass());
+    assertEquals(0L, pieceOfCake.getSize());
+  }
+
+  public void testAutoWireBadValue() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        // auto-wire values can be one of enabled, on, true
+        "  <object auto-wire='bad-value' name='pieceOfCake' class='"+PieceOfCake.class.getName()+"' />" +
+        "</objects>"
+      );
+
+    assertNotNull(problems);
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("attribute <object auto-wire=\"bad-value\" value not in {true, enabled, on, false, disabled, off}", problems.get(0).getMsg());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/BasicTypeWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,288 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ *
+ */
+public class BasicTypeWireTest extends WireTestCase {
+
+  public void testBooleanTrue() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <true name='a' />" +
+      "</objects>"
+    );
+
+    assertEquals(Boolean.TRUE, wireContext.get("a"));
+  }
+
+  public void testBooleanFalse() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <false name='a' />" +
+      "</objects>"
+    );
+
+    assertEquals(Boolean.FALSE, wireContext.get("a"));
+  }
+
+  public void testCharacter() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <char name='sizeof chruches' value='L' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Character('L'), wireContext.get("sizeof chruches"));
+  }
+
+  public void testCharacterWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <char name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'char'", problems.get(0).toString());
+  }
+
+  public void testCharacterInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <char name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("char has invalid formatted value", problems.get(0).toString());
+    assertTextPresent("length of value must be 1", problems.get(0).toString());
+  }
+
+  public void testDouble() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <double name='lenght of surgery cut' value='12.3' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Double(12.3), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testDoubleWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <double name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'double'", problems.get(0).toString());
+  }
+
+  public void testDoubleInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <double name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to a double", problems.get(0).toString());
+  }
+
+  public void testFloat() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <float name='lenght of surgery cut' value='12.3' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Float(12.3), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testFloatWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <float name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'float'", problems.get(0).toString());
+  }
+
+  public void testFloatInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <float name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to a float", problems.get(0).toString());
+  }
+
+  public void testInteger() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <int name='lenght of surgery cut' value='12' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Integer(12), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testIntegerWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <int name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'int'", problems.get(0).toString());
+  }
+
+  public void testIntegerInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <int name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to an int", problems.get(0).toString());
+  }
+
+  public void testShort() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <short name='lenght of surgery cut' value='12' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Short((short) 12), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testShortWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <short name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'short'", problems.get(0).toString());
+  }
+
+  public void testShortInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <short name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to a short", problems.get(0).toString());
+  }
+
+  public void testLong() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <long name='lenght of surgery cut' value='12' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Long((long) 12), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testLongWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <long name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'long'", problems.get(0).toString());
+  }
+
+  public void testLongInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <long name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to a long", problems.get(0).toString());
+  }
+
+  public void testByte() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <byte name='lenght of surgery cut' value='12' />" +
+      "</objects>"
+    );
+
+    assertEquals(new Byte((byte) 12), wireContext.get("lenght of surgery cut"));
+  }
+
+  public void testByteWithoutValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <byte name='buzz' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'value' is required in element 'byte'", problems.get(0).toString());
+  }
+
+  public void testByteInvalidValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <byte name='buzz' value='ooops' />" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("'ooops' cannot be parsed to a byte", problems.get(0).toString());
+  }
+
+  public void testNamedNull() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <null name='n' />" +
+      "</objects>"
+    );
+
+    assertNull(wireContext.get("n"));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ClassWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,95 @@
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.env.Environment;
+
+/**
+ * Tests for the ClassDescriptor
+ *
+ * @author Guillaume Porcher
+ *
+ */
+public class ClassWireTest extends WireTestCase {
+
+  /**
+   * Tests if a valid definition works.
+   */
+  public void testClass(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <class name='o' class-name='"+ClassWireTest.class.getName()+"' />" +
+        "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(ClassWireTest.class, o);
+  }
+
+  public void testNoClassName() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <class name='o'/>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(1, problems.size());
+    assertTextPresent("class must have classname attribute: ", problems.get(0).getMsg());
+  }
+  /**
+   * Tests the error raised when the class is not found.
+   */
+  public void testClassNotFound(){
+    String className = "i am not a valid class";
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <class name='o' class-name='"+ className +"' />" +
+        "</objects>"
+    );
+    try {
+      wireContext.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't load class '"+className+"'", e.getMessage());
+    }
+  }
+
+  public class InnerClass {
+  }
+
+  /**
+   * Tests if inner class loading works.
+   */
+  public void testInnerClass(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <class name='o' class-name='"+ InnerClass.class.getName() +"' />" +
+        "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(InnerClass.class, o);
+  }
+
+  /**
+   * Tests if loading a class defined in another package works.
+   */
+  public void testExternalClass() {
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <class name='o' class-name='"+Environment.class.getName()+"' />" +
+        "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(org.jbpm.env.Environment.class, o);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ConcurrentWiringTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ConcurrentWiringTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ConcurrentWiringTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConcurrentWiringTest extends WireTestCase {
+
+  public static class A {
+    public A() {
+      sleepTight(10);
+    }
+  }
+  
+  public static class B {
+    A a;
+    public B() {
+      sleepTight(10);
+    }
+    public void setA(A a) {
+      sleepTight(4);
+      this.a = a;
+    }
+  }
+  
+  public static class C {
+    B b;
+    public C() {
+      sleepTight(10);
+    }
+    public void setB(B b) {
+      sleepTight(3);
+      this.b = b;
+    }
+  }
+  
+  public static class D {
+    A a;
+    B b;
+    public D() {
+      sleepTight(10);
+    }
+    public void setA(A a) {
+      this.a = a;
+    }
+  }
+
+  public class Collector extends Thread {
+    WireContext wireContext;
+    String objectName;
+    Object result;
+    public Collector(WireContext wireContext, String objectName, String name) {
+      super(name);
+      this.wireContext = wireContext;
+      this.objectName = objectName;
+    }
+    public void run() {
+      sleepTight(5);
+      result = wireContext.get(objectName);
+    }
+  }
+
+  public void testConcurrency() throws Exception {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='a' class='"+A.class.getName()+"' />" +
+      "  <object name='b' class='"+B.class.getName()+"'>" +
+      "    <property name='a'><ref object='a' /></property>" +
+      "  </object>" +
+      "  <object name='c' class='"+C.class.getName()+"'>" +
+      "    <property name='b'><ref object='b' /></property>" +
+      "  </object>" +
+      "  <object name='d' class='"+D.class.getName()+"'>" +
+      "    <property name='a'><ref object='a' /></property>" +
+      "    <field name='b'><ref object='b' /></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    
+    List<Collector> collectors = new ArrayList<Collector>();
+    for (int i=0; i<10; i++) {
+      collectors.add(new Collector(wireContext, "b", "b"+i));
+      collectors.add(new Collector(wireContext, "c", "c"+i));
+      collectors.add(new Collector(wireContext, "d", "d"+i));
+    }
+    collectors.add(new Collector(wireContext, "a", "a"));
+    
+    for (Thread collector: collectors) {
+      collector.start();
+    }
+
+    for (Thread collector: collectors) {
+      boolean isJoined = false;
+      while (collector.isAlive() && !isJoined) {
+        try {
+          collector.join();
+          isJoined = true;
+        } catch (InterruptedException e) {
+          log.info("ignoring interrupted exception while joining "+collector);
+        }
+      }
+    }
+    
+    Object a = wireContext.get("a");
+    Object b = wireContext.get("b");
+    Object c = wireContext.get("c");
+    Object d = wireContext.get("d");
+    
+    for (Collector collector: collectors) {
+      if ("a".equals(collector.objectName)) {
+        assertSame(a, collector.result);
+      } else if ("b".equals(collector.objectName)) {
+        assertSame(b, collector.result);
+      } else if ("c".equals(collector.objectName)) {
+        assertSame(c, collector.result);
+      } else if ("d".equals(collector.objectName)) {
+        assertSame(d, collector.result);
+      }
+    }
+  }
+
+  static void sleepTight(int millis) {
+    try {
+      log.debug("sleeping for "+millis);
+      Thread.sleep(millis);
+      log.debug("woke up");
+    } catch (InterruptedException e) {
+      throw new RuntimeException("interrupted exception", e);
+    }
+  }
+  private static Log log = Log.getLog(ConcurrentWiringTest.class.getName());
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,565 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.WireObjectEventInfo;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class ContextBlockSubscriptionTest extends SubscriptionTestCase {
+
+  // these are the different ways of specifying observables:
+  // scope is always optional.  if the scope is not mentioned, the current scope is intended.
+
+  // <subscribe [context='contextName'] [event(s)='...']... /> will use the scope as the observable
+  // <subscribe [context='contextName'] object(s)='objectName' [event(s)='...'] ... /> will use the object(s) with the given name in the specified scope
+  // <subscribe [context='contextName'] wire-events='...' object='...' ... /> will listen to wire events of a specific object in the specified scope
+  // <subscribe [context='contextName'] object='objectName' [events='...']... /> will use the object with the given name in the same scope as the target object
+
+  // wireXmlParseResult.addProblem("observable in subscribe must be 'environment' or 'scope': "+XmlUtil.toString(element));
+
+  // wireXmlParseResult.addProblem("subscriber to wire-events must have one or more objects specified: "+XmlUtil.toString(element));
+  
+  public void testSubscriptionNoEnvironment() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is no eager initialization
+
+    WireContext context = new WireContext((WireDefinition) WireParser.getInstance().parseXmlString(
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "      <subscribe context='foo'/>" +
+      "    </object>" +
+      "  </transaction-context>"
+    ));
+
+    try{
+      context.get("recorder");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't get context foo for subscribe because no environment available in context ", e.getMessage());
+    }
+
+  }
+
+  public void testEventReception() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is no eager initialization
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "      <subscribe />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      WireContext contextBlockContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environment.get("recorder"));
+
+      // The recorder object will be subscribed to the environment WireScope
+      // during initialization.  So the wiring events 'initializing' and 'constructing'
+      // will not be recorded.  But events events 'constructed' and 'set'
+      // will be received.
+
+      // Object wiring events are fired on the descriptors *and* on the WireScope.  Here
+      // we subscribe to the environment WireScope, so we receive also the wire events.
+      assertEquals(events.toString(), 2, events.size());
+      assertEquals("constructed", events.get(0).eventName);
+      assertEquals("set", events.get(1).eventName);
+
+      contextBlockContext.fire("interestingevent", null);
+      assertEquals(events.toString(), 3, events.size());
+      assertEquals("interestingevent", events.get(2).eventName);
+
+      Descriptor descriptor = contextBlockContext.getWireDefinition().getDescriptor("recorder");
+      // this event is fired directly on the descriptor and should therefor not be received
+      descriptor.fire("descriptorEvent", null);
+      assertEquals(events.toString(), 3, events.size());
+
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(events.toString(), 4, events.size());
+    assertEquals("close", events.get(3).eventName);
+
+    environmentFactory.close();
+  }
+
+  public void testEventReceptionWithEagerInit() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals(events.toString(), 3, events.size());
+      int index=0;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("open", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testEventReceptionFromOtherObject() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe />" +
+      "    </object>" +
+      "    <object name='o' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 7, events.size());
+      // ignoring the first 3 events: constructed(recorder), set(recorder), open(environment)
+      int index=3;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testEventFiltering() {
+    // <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe event='interestingevent'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals(events.toString(), 0, events.size());
+
+      WireContext contextBlockContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      contextBlockContext.fire("interestingevent", null);
+
+      assertEquals(events.toString(), 1, events.size());
+
+      int index=0;
+      assertEquals("interestingevent", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+    } finally {
+      environment.close();
+    }
+    assertEquals(events.toString(), 1, events.size());
+
+    environmentFactory.close();
+  }
+
+  public void testEventsFiltering() {
+    // <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe events='constructing, open, constructed, interestingevent, close'/>" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      WireContext contextBlockContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+
+      assertEquals(events.toString(), 2, events.size());
+      int index=0;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("open", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+      contextBlockContext.fire("interestingevent", null);
+
+      assertEquals(events.toString(), 3, events.size());
+      index++;
+      assertEquals("interestingevent", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+      contextBlockContext.fire("boringevent", null);
+
+      assertEquals(events.toString(), 3, events.size());
+
+    } finally {
+      environment.close();
+    }
+    assertEquals(events.toString(), 4, events.size());
+    assertEquals("close", events.get(3).eventName);
+
+    environmentFactory.close();
+  }
+
+  public void testEventsFilteringOnOtherObject() {
+    // <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe events='constructing, open, constructed, interestingevent, close'/>" +
+      "    </object>" +
+      "    <object name='o' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 4, events.size());
+      // ignoring the first 2 events: constructed(recorder), open(environment)
+      int index=2;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+
+
+    } finally {
+      environment.close();
+    }
+    assertEquals(events.toString(), 5, events.size());
+    assertEquals("close", events.get(4).eventName);
+
+    environmentFactory.close();
+  }
+
+  public void testOtherWireScope() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object name='factory' class='"+Object.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe context='process-engine'/>" +
+      "    </object>" +
+      "    <object name='product' factory='factory' method='getClass' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    int index=0;
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("product"));
+
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("factory", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("factory", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("factory", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("factory", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+
+
+    } finally {
+      environment.close();
+    }
+
+    environmentFactory.close();
+
+    index++;
+    assertEquals("close", events.get(index).eventName);
+    JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) environmentFactory;
+    WireContext applicationWireContext = jbpmConfiguration.getEnvironmentFactoryCtxWireContext();
+    assertEquals(applicationWireContext, events.get(index).source);
+    assertNull(events.get(index).info);
+  }
+
+  public void testOtherWireScopeWithEventFiltering() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context>" +
+      "    <object name='factory' class='"+Object.class.getName()+"' />" +
+      "  </process-engine-context>" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe context='process-engine' events='initializing' />" +
+      "    </object>" +
+      "    <object name='product' factory='factory' method='getClass' />" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    int index=0;
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("product"));
+
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("factory", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+
+
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(events.toString(), 1, events.size());
+
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 1, events.size());
+  }
+
+  public void testUnexistingScope() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe context='unexistingcontext' />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    assertNull(Environment.getCurrent());
+    try {
+      environmentFactory.openEnvironment();
+      fail("expected exception");
+    } catch (WireException e) {
+      assertNull(Environment.getCurrent());
+      assertTextPresent("couldn't initialize object 'recorder': couldn't subscribe because context unexistingcontext doesn't exist", e.getMessage());
+    }
+  }
+
+
+  public static class A {
+    Object o;
+  }
+  public void testEventReceptionNested() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is no eager initialization
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='a' class='"+A.class.getName()+"'>" +
+      "      <field name='o'>" +
+      "         <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "           <subscribe />" +
+      "         </object>" +
+      "      </field>" +
+      "     </object>"+
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      WireContext contextBlockContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environment.get("a"));
+
+      // The recorder object will be subscribed to the environment WireContext
+      // during initialization.  So the wiring events 'initializing' and 'constructing'
+      // will not be recorded.  But events events 'constructed' and 'set'
+      // will be received.
+
+      // Object wiring events are fired on the descriptors *and* on the WireContext.  Here
+      // we subscribe to the environment WireContext, so we receive also the wire events.
+      assertEquals(events.toString(), 4, events.size());
+      assertEquals("constructed", events.get(0).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(0).info).getObjectName());
+      assertEquals("set", events.get(1).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(1).info).getObjectName());
+      assertEquals("constructed", events.get(2).eventName);
+      assertEquals("a", ((WireObjectEventInfo)events.get(2).info).getObjectName());
+      assertEquals("set", events.get(3).eventName);
+      assertEquals("a", ((WireObjectEventInfo)events.get(3).info).getObjectName());
+      contextBlockContext.fire("interestingevent", null);
+      assertEquals(events.toString(), 5, events.size());
+      assertEquals("interestingevent", events.get(4).eventName);
+
+      Descriptor descriptor = contextBlockContext.getWireDefinition().getDescriptor("recorder");
+      // this event is fired directly on the descriptor and should therefore not be received
+      descriptor.fire("descriptorEvent", null);
+      assertEquals(events.toString(), 5, events.size());
+
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(events.toString(), 6, events.size());
+    assertEquals("close", events.get(5).eventName);
+
+    environmentFactory.close();
+  }
+
+  public void testEventReceptionNestedTwoTimes() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is no eager initialization
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<jbpm-configuration>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='a' class='"+A.class.getName()+"'>" +
+      "      <field name='o'>" +
+      "        <object name='b' class='"+A.class.getName()+"'>" +
+      "          <field name='o'>" +
+      "            <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "              <subscribe />" +
+      "            </object>" +
+      "          </field>" +
+      "        </object>"+
+      "      </field>" +
+      "     </object>"+
+      "  </transaction-context>" +
+      "</jbpm-configuration>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      WireContext contextBlockContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+      assertNotNull(environment.get("a"));
+
+      // The recorder object will be subscribed to the environment WireContext
+      // during initialization.  So the wiring events 'initializing' and 'constructing'
+      // will not be recorded.  But events events 'constructed' and 'set'
+      // will be received.
+
+      // Object wiring events are fired on the descriptors *and* on the WireContext.  Here
+      // we subscribe to the environment WireContext, so we receive also the wire events.
+      assertEquals(events.toString(), 6, events.size());
+      
+      assertEquals("constructed", events.get(0).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(0).info).getObjectName());
+      assertEquals("set", events.get(1).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(1).info).getObjectName());
+      
+      assertEquals("constructed", events.get(2).eventName);
+      assertEquals("b", ((WireObjectEventInfo)events.get(2).info).getObjectName());
+      assertEquals("set", events.get(3).eventName);
+      assertEquals("b", ((WireObjectEventInfo)events.get(3).info).getObjectName());
+
+      assertEquals("constructed", events.get(4).eventName);
+      assertEquals("a", ((WireObjectEventInfo)events.get(4).info).getObjectName());
+      assertEquals("set", events.get(5).eventName);
+      assertEquals("a", ((WireObjectEventInfo)events.get(5).info).getObjectName());
+
+      contextBlockContext.fire("interestingevent", null);
+      assertEquals(events.toString(), 7, events.size());
+      assertEquals("interestingevent", events.get(6).eventName);
+
+      Descriptor descriptor = contextBlockContext.getWireDefinition().getDescriptor("recorder");
+      // this event is fired directly on the descriptor and should therefore not be received
+      descriptor.fire("descriptorEvent", null);
+      assertEquals(events.toString(), 7, events.size());
+
+    } finally {
+      environment.close();
+    }
+
+    assertEquals(events.toString(), 8, events.size());
+    assertEquals("close", events.get(7).eventName);
+
+    environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,166 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.pvm.internal.wire;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class ContextTest extends WireTestCase {
+
+  public void testLazyCreation() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <string name='o' value='test'/>" +
+      "</objects>"
+    );
+
+    assertFalse(wireContext.hasCached("o"));
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(String.class, o.getClass());
+    assertEquals("test", o);
+  }
+  
+  public void testEagerCreation() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <string name='o' value='test' init='eager'/>" +
+      "</objects>"
+    );
+
+    assertTrue(wireContext.hasCached("o"));
+  }
+
+  public void testObjectRemoved() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <string name='o' value='test' init='eager'/>" +
+      "  <string name='s' value='foo' init='eager'/>" +
+      "</objects>"
+    );
+
+    assertTrue(wireContext.hasCached("o"));
+    assertTrue(wireContext.hasCached("s"));
+    wireContext.remove("o");
+    assertFalse(wireContext.hasCached("o"));
+    assertTrue(wireContext.hasCached("s"));
+    
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+    assertEquals(String.class, o.getClass());
+    
+    assertTrue(wireContext.hasCached("o"));
+    assertTrue(wireContext.hasCached("s"));
+    
+    assertEquals("test", o);
+  }
+  
+  public void testCacheCleared() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <string name='o' value='test' init='eager'/>" +
+      "  <string name='s' value='foo' init='eager'/>" +
+      "</objects>"
+    );
+
+    assertTrue(wireContext.hasCached("o"));
+    assertTrue(wireContext.hasCached("s"));
+    wireContext.clear();
+    assertFalse(wireContext.hasCached("o"));
+    assertFalse(wireContext.hasCached("s"));
+    
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+    assertEquals(String.class, o.getClass());
+    
+    assertTrue(wireContext.hasCached("o"));
+    assertFalse(wireContext.hasCached("s"));
+    
+    assertEquals("test", o);
+  }
+  
+  
+  public void testEmptyCacheCleared() {
+    WireContext wireContext = createWireContext(
+      "<objects/>"
+    );
+
+    wireContext.clear();
+  }
+  
+  public void testRemoveObjectNotInCache(){
+    WireContext wireContext = createWireContext(
+        "<objects/>"
+      );
+
+      wireContext.remove("o"); 
+  }
+  
+  public void testKeys(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <string name='o' value='test' init='eager'/>" +
+        "  <string name='s' value='foo'/>" +
+        "  <string name='t' value='bar' init='eager'/>" +
+        "</objects>"
+    );
+    
+    assertTrue(wireContext.has("o"));
+    assertTrue(wireContext.has("s"));
+    assertTrue(wireContext.has("t"));
+    assertTrue(wireContext.hasCached("o"));
+    assertFalse(wireContext.hasCached("s"));
+    assertTrue(wireContext.hasCached("t"));
+    
+    Set<String> expectedKeys = new HashSet<String>();
+    expectedKeys.add("o");
+    expectedKeys.add("s");
+    expectedKeys.add("t");
+    
+    assertEquals(expectedKeys, wireContext.keys());
+  }
+  
+  public void testHasOnEmptyContext(){
+    WireContext wireContext = createWireContext(
+        "<objects/>"
+    );
+    
+    assertFalse(wireContext.has("foo"));
+  }
+  
+  public void testHasOnEmptyEnv(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes/>"
+      );
+
+      Environment environment = environmentFactory.openEnvironment();
+
+      try {
+        Object foo = environment.get("foo");
+        assertNull(foo);
+      } finally {
+        environment.close();
+      }
+      environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DelayedInitTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DelayedInitTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DelayedInitTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,203 @@
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class DelayedInitTest extends WireTestCase {
+
+  public static class NeedInitClass {
+    private List<?> l;
+
+    public int getSize() {
+      return l.size();
+    }
+  }
+
+  public void testMethodAndDelayedInit() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+NeedInitClass.class.getName()+"'>" +
+          "<field name='l'>" +
+          "   <list /> " +
+          "</field>" +
+      "  </object>" +
+      "  <object name='q' factory='o' method='getSize' />" +
+      "</objects>"
+    );
+    Object q = wireContext.get("q");
+
+    assertNotNull(q);
+    assertEquals(Integer.class, q.getClass());
+  }
+
+  public void testFactoryAndDelayedInit() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='q' method='getSize'>" +
+      "    <factory>" +
+      "      <object name='o' class='"+NeedInitClass.class.getName()+"'>" +
+      "        <field name='l'>" +
+      "          <list /> " +
+      "        </field>" +
+      "      </object>" +
+      "    </factory>" +
+      "  </object>" +
+      "</objects>"
+    );
+    Object q = wireContext.get("q");
+
+    assertNotNull(q);
+    assertEquals(Integer.class, q.getClass());
+  }
+
+  public void testRefAndDelayedInit() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+NeedInitClass.class.getName()+"'>" +
+          "<field name='l'>" +
+          "   <list /> " +
+          "</field>" +
+      "  </object>" +
+      "  <object name='q' method='getSize'>" +
+      "    <factory>" +
+      "       <ref object='o' init='required'/>" +
+      "    </factory>" +
+      "  </object>" +
+      "</objects>"
+    );
+    Object q = wireContext.get("q");
+
+    assertNotNull(q);
+    assertEquals(Integer.class, q.getClass());
+  }
+
+  public static class A {
+    public B b;
+  }
+
+  public static class B {
+    public A a;
+  }
+
+  public void testBidirectionnalInitDefault(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='a' class='"+A.class.getName()+"'>" +
+        "   <field name='b'>" +
+        "     <ref object='b'/>" +
+        "   </field>" +
+        "  </object>" +
+        "  <object name='b' class='"+B.class.getName()+"'>" +
+        "    <field name='a'>" +
+        "     <ref object='a'/>" +
+        "    </field>" +
+        "  </object>"+
+        "</objects>"
+      );
+      Object b = wireContext.get("b");
+
+      assertNotNull(b);
+      assertEquals(B.class, b.getClass());
+      Object a = ((B)b).a;
+      assertNotNull(a);
+      assertEquals(A.class, a.getClass());
+      assertEquals(b, ((A)((B)b).a).b);
+      assertEquals(a, wireContext.get("a"));
+    }
+
+  /**
+   * In this test, "b" is created, and initialized.
+   * During the initialization, "a" is created and initialized.
+   * As "b" is already created and we don't require it to be initialized, "a" can be initialized and the test is OK.
+   */
+  public void testBidirectionnalInitARefRequired(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='a' class='"+A.class.getName()+"'>" +
+        "   <field name='b'>" +
+        "     <ref object='b'/>" +
+        "   </field>" +
+        "  </object>" +
+        "  <object name='b' class='"+B.class.getName()+"'>" +
+        "    <field name='a'>" +
+        "     <ref object='a' init='required'/>" +
+        "    </field>" +
+        "  </object>"+
+        "</objects>"
+      );
+      Object b = wireContext.get("b");
+
+      assertNotNull(b);
+      assertEquals(B.class, b.getClass());
+      Object a = ((B)b).a;
+      assertNotNull(a);
+      assertEquals(A.class, a.getClass());
+      assertEquals(b, ((A)((B)b).a).b);
+      assertEquals(a, wireContext.get("a"));
+    }
+
+  /**
+   * In this test, "b" is created, and initialized.
+   * During the initialization, "a" is created and initialized.
+   * As "b" is already created and we don't require it to be initialized,
+   * "a" can be initialized and the test is OK.
+   */
+  public void testBidirectionnalInitARequired(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='a' class='"+A.class.getName()+"' init='required'>" +
+        "   <field name='b'>" +
+        "     <ref object='b'/>" +
+        "   </field>" +
+        "  </object>" +
+        "  <object name='b' class='"+B.class.getName()+"'>" +
+        "    <field name='a'>" +
+        "     <ref object='a'/>" +
+        "    </field>" +
+        "  </object>"+
+        "</objects>"
+      );
+      Object b = wireContext.get("b");
+
+      assertNotNull(b);
+      assertEquals(B.class, b.getClass());
+      Object a = ((B)b).a;
+      assertNotNull(a);
+      assertEquals(A.class, a.getClass());
+      assertEquals(b, ((A)((B)b).a).b);
+      assertEquals(a, wireContext.get("a"));
+    }
+
+  /**
+   * Circular dependencies during initialization of 'b'
+   */
+  public void testBidirectionnalInitAandBRequired(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='a' class='"+A.class.getName()+"'>" +
+        "   <field name='b'>" +
+        "     <ref object='b' init='required'/>" +
+        "   </field>" +
+        "  </object>" +
+        "  <object name='b' class='"+B.class.getName()+"'>" +
+        "    <field name='a'>" +
+        "     <ref object='a' init='required'/>" +
+        "    </field>" +
+        "  </object>"+
+        "</objects>"
+      );
+
+    try {
+      wireContext.get("b");
+      fail("expected exception");
+    } catch(WireException e) {
+      assertTextPresent("circular dependency", e.getMessage());
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DependencyTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DependencyTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/DependencyTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DependencyTest extends WireTestCase {
+  
+  public static class A {
+    public A(){}
+    public A(B b) {this.b = b;}
+    B b;
+  }
+  
+  public static class B {
+    public B(){}
+    public B(A a) {this.a = a;}
+    A a;
+  }
+
+  public void testResolvableBidirectionalDependency() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='a' class='"+A.class.getName()+"'>" +
+      "    <field name='b'>" +
+      "      <ref object='b' />" +
+      "    </field>" +
+      "  </object>" +
+      "  <object name='b' class='"+B.class.getName()+"'>" +
+      "    <field name='a'>" +
+      "      <ref object='a' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    A a = (A) wireContext.get("a");
+    B b = (B) wireContext.get("b");
+
+    assertSame(b, a.b);
+    assertSame(a, b.a);
+  }
+
+  public void testUnresolvableBidirectionalDependency() {
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='a' class='"+A.class.getName()+"'>" +
+        "    <constructor>" +
+        "      <arg>" +
+        "        <ref object='b' />" +
+        "      </arg>" +
+        "    </constructor>" +
+        "  </object>" +
+        "  <object name='b' class='"+B.class.getName()+"'>" +
+        "    <constructor>" +
+        "      <arg>" +
+        "        <ref object='a' />" +
+        "      </arg>" +
+        "    </constructor>" +
+        "  </object>" +
+        "</objects>"
+      );
+
+    try {
+      wireContext.get("a");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("circular dependency", e.getMessage());
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EagerInitTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EagerInitTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EagerInitTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class EagerInitTest extends WireTestCase {
+
+  // test simple eager initialization /////////////////////////////////////////
+
+  public static class A {
+    static boolean isConstructed = false;
+    static boolean isInitialized = false;
+    public A() {
+      isConstructed = true;
+    }
+  }
+
+  /**
+   * Tests that eager objects are created and initialized with the context.
+   */
+  public void testEagerInitialization() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='a' class='"+A.class.getName()+"' init='eager'>" +
+      "    <field name='isInitialized'>" +
+      "      <true/>" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    assertTrue(A.isConstructed);
+    assertTrue(A.isInitialized);
+    assertTrue(wireContext.hasCached("a"));
+  }
+
+
+  // test default lazy initialization /////////////////////////////////////////
+
+  public static class B {
+    static boolean isConstructed = false;
+    public B() {
+      isConstructed = true;
+    }
+  }
+
+  public void testLazyInitializationDefault() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      // the default init behaviour is lazy
+      "  <object name='b' class='"+B.class.getName()+"' />" +
+      "</objects>"
+    );
+
+    assertFalse(B.isConstructed);
+    assertFalse(wireContext.hasCached("b"));
+  }
+
+
+  // test eager initialization sequence ///////////////////////////////////////
+
+  static List<Class<?>> sequence = new ArrayList<Class<?>>();
+
+  public static class Seq0 { public Seq0() { sequence.add(Seq0.class); } }
+  public static class Seq1 { public Seq1() { sequence.add(Seq1.class); } }
+  public static class Seq2 { public Seq2() { sequence.add(Seq2.class); } }
+  public static class Seq3 { public Seq3() { sequence.add(Seq3.class); } }
+  public static class Seq4 { public Seq4() { sequence.add(Seq4.class); } }
+
+  public void testEagerInitializationSequence() {
+    sequence = new ArrayList<Class<?>>();
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='0' class='"+Seq0.class.getName()+"' init='eager' />" +
+      "  <object name='1' class='"+Seq1.class.getName()+"' init='eager' />" +
+      "  <object name='2' class='"+Seq2.class.getName()+"' init='eager' />" +
+      "  <object name='3' class='"+Seq3.class.getName()+"' init='eager' />" +
+      "  <object name='4' class='"+Seq4.class.getName()+"' init='eager' />" +
+      "</objects>"
+    );
+
+    List<Class<?>> expectedSequence = new ArrayList<Class<?>>();
+    expectedSequence.add(Seq0.class);
+    expectedSequence.add(Seq1.class);
+    expectedSequence.add(Seq2.class);
+    expectedSequence.add(Seq3.class);
+    expectedSequence.add(Seq4.class);
+
+    assertEquals(expectedSequence, sequence);
+
+    assertTrue(wireContext.hasCached("0"));
+    assertTrue(wireContext.hasCached("1"));
+    assertTrue(wireContext.hasCached("2"));
+    assertTrue(wireContext.hasCached("3"));
+    assertTrue(wireContext.hasCached("4"));
+  }
+
+  public void testEagerInitializationListSequence() {
+    sequence = new ArrayList<Class<?>>();
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <list name='list1' init='eager'>" +
+      "    <object name='0' class='"+Seq0.class.getName()+"'/>" +
+      "    <object name='1' class='"+Seq1.class.getName()+"'/>" +
+      "    <object name='2' class='"+Seq2.class.getName()+"'/>" +
+      "    <object name='3' class='"+Seq3.class.getName()+"'/>" +
+      "    <object name='4' class='"+Seq4.class.getName()+"'/>" +
+      "  </list>" +
+      "</objects>"
+    );
+
+    // in this test, we cannot be sure of the initialization sequence
+    // in this config, the sequence is 2,3,4,0,1
+    // if we rename list1 to list2 and list2 to list 1, the sequence would be 0,1,2,3,4
+    assertEquals(5, sequence.size());
+
+    assertTrue(wireContext.hasCached("0"));
+    assertTrue(wireContext.hasCached("1"));
+    assertTrue(wireContext.hasCached("2"));
+    assertTrue(wireContext.hasCached("3"));
+    assertTrue(wireContext.hasCached("4"));
+}
+
+
+  public void testImmediateInitializationListSequence() {
+    sequence = new ArrayList<Class<?>>();
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <list name='l' init='immediate'>" +
+        "    <object name='0' class='"+Seq0.class.getName()+"'/>" +
+        "    <object name='1' class='"+Seq1.class.getName()+"'/>" +
+        "    <object name='2' class='"+Seq2.class.getName()+"'/>" +
+        "    <object name='3' class='"+Seq3.class.getName()+"'/>" +
+        "    <object name='4' class='"+Seq4.class.getName()+"'/>" +
+        "  </list>" +
+        "</objects>"
+    );
+
+    List<Class<?>> expectedSequence = new ArrayList<Class<?>>();
+    expectedSequence.add(Seq0.class);
+    expectedSequence.add(Seq1.class);
+    expectedSequence.add(Seq2.class);
+    expectedSequence.add(Seq3.class);
+    expectedSequence.add(Seq4.class);
+
+    assertEquals(expectedSequence, sequence);
+
+    assertTrue(wireContext.hasCached("0"));
+    assertTrue(wireContext.hasCached("1"));
+    assertTrue(wireContext.hasCached("2"));
+    assertTrue(wireContext.hasCached("3"));
+    assertTrue(wireContext.hasCached("4"));
+  }
+
+  /** 
+   * Tests eager initialization of a descriptor that does not implement initializable. 
+   * The object is eagerly created. 
+   */
+  public void testEagerInitNotInitializable() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      // the default init behaviour is lazy
+      "  <string name='a' value='a-string' init='immediate' />" +
+      "</objects>"
+    );
+
+    assertTrue(wireContext.hasCached("a"));
+  }
+  
+  /**
+   * Tests that the referenced object is created and initialized.
+   */
+  public static class C {
+    static boolean isConstructed = false;
+    static boolean isInitialized = false;
+    public C() {
+      isConstructed = true;
+    }
+  }
+  
+  public void testEagerRef() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      // the default init behaviour is lazy
+      "  <object name='o' class='"+C.class.getName()+"'>" +
+  		"    <field name='isInitialized'>" +
+   		"      <true/>" +
+   		"    </field>" +
+      "  </object>" +
+      "  <ref name='r' object='o' init='eager' />" +
+      "</objects>"
+    );
+
+    assertTrue(C.isConstructed);
+    assertTrue(C.isInitialized);
+    assertTrue(wireContext.hasCached("o"));
+    assertTrue(wireContext.hasCached("r"));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,108 @@
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Guillaume Porcher
+ *
+ */
+public class EnvWireTest extends WireTestCase {
+
+  public void testEnvironmentWire(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context /> " +
+        "  <transaction-context>" +
+        "    <env-ref name='e' />" +
+        "  </transaction-context>" +
+        "</environment-scopes>"
+      );
+
+      Environment environment = environmentFactory.openEnvironment();
+
+      try{
+        Object e = environment.get("e");
+
+        assertNotNull(e);
+        assertEquals(environment, e);
+        assertEquals(e, ((Environment) e).get("e"));
+      } finally {
+        environment.close();
+      }
+      environmentFactory.close();
+  }
+
+  public void testEnvironmentFactoryWire(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "    <process-engine-ref name='f' />" +
+        "  </transaction-context>" +
+        "</environment-scopes>"
+      );
+
+      Environment environment = environmentFactory.openEnvironment();
+
+      try {
+        Object f = environment.get("f");
+
+        assertNotNull(f);
+        assertEquals(environmentFactory, f);
+      } finally {
+        environment.close();
+      }
+      environmentFactory.close();
+  }
+
+  public void testContextRefEnvironmentWire(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "    <context-ref name='c' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+      );
+
+      Environment environment = environmentFactory.openEnvironment();
+
+      try {
+        Object c = environment.get("c");
+
+        assertNotNull(c);
+        assertEquals(WireContext.class, c.getClass());
+        assertEquals(environment.getContext("transaction"), c);
+      } finally {
+        environment.close();
+      }
+      environmentFactory.close();
+  }
+
+  public void testContextRefEnvironmentFactoryWire(){
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context>" +
+        "    <context-ref name='c' />" +
+        "  </process-engine-context>" +
+        "  <environment/>" +
+        "</environment-scopes>"
+      );
+
+      Environment environment = environmentFactory.openEnvironment();
+
+      try {
+        Object c = environment.get("c");
+
+        assertNotNull(c);
+        assertEquals(WireContext.class, c.getClass());
+        assertEquals(environment.getContext("process-engine"), c);
+      } finally {
+        environment.close();
+      }
+      environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/HibernateSessionFactoryWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/HibernateSessionFactoryWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/HibernateSessionFactoryWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import org.hibernate.SessionFactory;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionFactoryWireTest extends WireTestCase {
+
+  public void testEmptyHibernateSessionFactory() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <hibernate-session-factory name='sf'>" +
+      "    <properties>" +
+      "      <property name='hibernate.dialect' value='org.hibernate.dialect.HSQLDialect' />" +
+      "    </properties>" +
+      "  </hibernate-session-factory>" +
+      "</objects>"
+    );
+
+    SessionFactory sessionFactory = (SessionFactory) wireContext.get("sf");
+    assertNotNull(sessionFactory);
+  }
+
+  public void testHibernateSessionFactoryWithSeparateConfiguration() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <hibernate-configuration name='c'>" +
+      "    <properties>" +
+      "      <property name='hibernate.dialect' value='org.hibernate.dialect.HSQLDialect' />" +
+      "    </properties>" +
+      "  </hibernate-configuration>" +
+      "  <hibernate-session-factory name='sf' configuration='c' />" +
+      "</objects>"
+    );
+
+    SessionFactory sessionFactory = (SessionFactory) wireContext.get("sf");
+    assertNotNull(sessionFactory);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class ListWireTest extends WireTestCase {
+
+  public void testMixedElementTypes() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <list name='l'>" +
+      "    <true />" +
+      "    <string value='v' />" +
+      "    <null />" +
+      "  </list>" +
+      "</objects>"
+    );
+
+    List<Object> values = (List<Object>) wireContext.get("l");
+    // make a copy so that we can compare 2 ArrayLists
+    values = new ArrayList<Object>(values);
+
+    List<Object> expected = new ArrayList<Object>(3);
+    expected.add(Boolean.TRUE);
+    expected.add("v");
+    expected.add(null);
+
+    assertEquals(expected, values);
+  }
+
+  public void testCustomListType() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <list name='l' class='java.util.LinkedList' />" +
+      "</objects>"
+    );
+    Object l = wireContext.get("l");
+    assertNotNull(l);
+    assertEquals("java.util.LinkedList", l.getClass().getName());
+  }
+
+  public void testInvalidListType() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <list name='l' class='invalid-list-type'/>" +
+      "</objects>"
+    );
+
+    assertTextPresent("class invalid-list-type could not be found", problems.get(0).getMsg());
+  }
+
+  public void testNotAListType() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <list name='l' class='"+HashSet.class.getName()+"'/>" +
+        "</objects>"
+    );
+
+    assertTextPresent("class "+HashSet.class.getName()+" is not a "+List.class.getName(), problems.get(0).getMsg());
+  }
+
+  public void testProblemUnknownValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <list name='l'>" +
+      "    <unknown-descriptor />" +
+      "  </list>" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("no element parser for tag unknown-descriptor", problems.get(0).getMsg());
+  }
+
+  public static class TextElement {
+    String text;
+  }
+  
+  public void testElementsWithInitialization() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <list name='l'>" +
+      "    <object class='"+TextElement.class.getName()+"'>" +
+      "      <field name='text'>" +
+      "        <string value='a'/>" +
+      "      </field>" +
+      "    </object>" +
+      "    <object class='"+TextElement.class.getName()+"'>" +
+      "      <field name='text'>" +
+      "        <string value='b'/>" +
+      "      </field>" +
+      "    </object>" +
+      "    <object class='"+TextElement.class.getName()+"'>" +
+      "      <field name='text'>" +
+      "        <string value='c'/>" +
+      "      </field>" +
+      "    </object>" +
+      "  </list>" +
+      "</objects>"
+    );
+    List<TextElement> l = (List<TextElement>) wireContext.get("l");
+    assertEquals(l.toString(), 3, l.size());
+    assertEquals("a", l.get(0).text);
+    assertEquals("b", l.get(1).text);
+    assertEquals("c", l.get(2).text);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class MapWireTest extends WireTestCase {
+
+  public void testMap() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <map name='m'>" +
+      "    <entry>" +
+      "      <key>" +
+      "        <true/>" +
+      "      </key>" +
+      "      <value>" +
+      "        <null/>" +
+      "      </value>" +
+      "    </entry>" +
+      "    <entry>" +
+      "      <key>" +
+      "        <string value='a'/>" +
+      "      </key>" +
+      "      <value>" +
+      "        <long value='5'/>" +
+      "      </value>" +
+      "    </entry>" +
+      "  </map>" +
+      "</objects>"
+    );
+
+    Map m = (Map) wireContext.get("m");
+    assertEquals(m.toString(), 2, m.size());
+    assertNull(m.get(Boolean.TRUE));
+    assertEquals(new Long(5), m.get("a"));
+  }
+
+  public void testCustomMapType() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <map name='m' class='java.util.TreeMap' />" +
+      "</objects>"
+    );
+    assertEquals(TreeMap.class, wireContext.get("m").getClass());
+  }
+
+  public void testInvalidMapType() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <map name='m' class='invalid-map-type'/>" +
+        "</objects>"
+    );
+
+    assertTextPresent("class invalid-map-type could not be found", problems.get(0).getMsg());
+  }
+
+  public void testMapWithNonEntries() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <map name='m'>" +
+      "    <true />" +
+      "    <string value='' />" +
+      "    <null />" +
+      "  </map>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(problems.toString(), 3, problems.size());
+    assertTextPresent("map can only contain entry elements", problems.get(0).getMsg());
+    assertTextPresent("map can only contain entry elements", problems.get(1).getMsg());
+    assertTextPresent("map can only contain entry elements", problems.get(2).getMsg());
+  }
+
+  public void testMapWithBadEntries() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <map name='m'>" +
+      "    <entry/>" +
+      "    <entry><key><null/></key></entry>" +
+      "    <entry><value><null/></value></entry>" +
+      "    <entry><key/><value><null/></value></entry>" +
+      "  </map>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(problems.toString(), 4, problems.size());
+    assertTextPresent("entry must have key and value element with a single descriptor as contents", problems.get(0).getMsg());
+    assertTextPresent("entry must have key and value element with a single descriptor as contents", problems.get(1).getMsg());
+    assertTextPresent("entry must have key and value element with a single descriptor as contents", problems.get(2).getMsg());
+    assertTextPresent("entry must have key and value element with a single descriptor as contents", problems.get(3).getMsg());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,462 @@
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.util.DefaultObservable;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * Test subscription using a specified method.
+ * @author Guillaume Porcher
+ *
+ */
+public class MethodSubscriptionTest extends SubscriptionTestCase {
+
+  /**
+   * Records calls to logEvent methods.
+   */
+  public static class NonListenerRecorder {
+    public void logEvent(Object source, String eventName, Object info) {
+      events.add(new Event(source, eventName, info));
+    }
+
+    public void logEvent(Object source, String eventName) {
+      logEvent(source, eventName, null);
+    }
+
+    public void logEvent(String eventName) {
+      logEvent(null, eventName, null);
+    }
+
+    public void logEvent() {
+      logEvent(null,null,null);
+    }
+
+    public static int getNumberOfEvents() {
+      return events.size();
+    }
+  }
+
+  /**
+   * Test subscription using a specified method with no argument.
+   * The recorder is eagerly initialized.
+   */
+  public void testMethodWithNoArg() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='logEvent' />" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      a.fire("ping", null);
+      a.fire("pong", null);
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertNull(events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+      index++;
+      assertNull(events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+  /**
+   * Test subscription using a non existing method.
+   * The recorder is eagerly initialized.
+   */
+  public void testMethodWithBadName() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='i-am-not-a-method' />" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      try {
+        a.fire("ping", null);
+        fail("expected exception");
+      } catch (WireException e) {
+        assertTextPresent("method i-am-not-a-method() unavailable", e.getMessage());
+      }
+
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  /**
+   * Test subscription using a specified method with one argument.
+   * The recorder is eagerly initialized.
+   */
+  public void testMethodWithOneArg() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='logEvent' >" +
+        "       <arg>" +
+        "         <string value='a'/>" +
+        "       </arg>" +
+        "    </subscribe>" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      a.fire("ping", null);
+      a.fire("pong", null);
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertEquals("a", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+      index++;
+      assertEquals("a", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  /**
+   * Test subscription using a specified method with two arguments.
+   * The recorder is eagerly initialized.
+   */
+  public void testMethodWithTwoArgs() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context /> "+
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='logEvent' event='ping'>" +
+        "       <arg type='java.lang.Object'>" +
+        "         <ref object='a'/>" +
+        "       </arg>" +
+        "       <arg>" +
+        "         <string value='hello'/>" +
+        "       </arg>" +
+        "    </subscribe>" +
+        "    <subscribe object='a' method='logEvent' event='pong'>" +
+        "       <arg type='java.lang.Object'>" +
+        "         <ref object='a'/>" +
+        "       </arg>" +
+        "       <arg>" +
+        "         <string value='world'/>" +
+        "       </arg>" +
+        "    </subscribe>" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      a.fire("ping", null);
+      a.fire("pong", null);
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertEquals("hello", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertEquals(a, events.get(index).source);
+      index++;
+      assertEquals("world", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertEquals(a, events.get(index).source);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+
+  /**
+   * Test subscription using a specified method with 3 arguments.
+   * The info argument is taken from a method invocation.
+   * The recorder is eagerly initialized.
+   */
+  public void testMethodWithThreeArgs() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<jbpm-configuration>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='logEvent'>" +
+        "       <arg type='java.lang.Object'>" +
+        "         <ref object='a'/>" +
+        "       </arg>" +
+        "       <arg>" +
+        "         <string value='hello'/>" +
+        "       </arg>" +
+        "       <arg type='java.lang.Object'>" +
+        "         <object class='"+NonListenerRecorder.class.getName()+"' method='getNumberOfEvents' />" +
+        "       </arg>" +
+        "    </subscribe>" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</jbpm-configuration>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      a.fire("ping", null);
+      a.fire("pong", null);
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertEquals("hello", events.get(index).eventName);
+      assertEquals(0, events.get(index).info);
+      assertEquals(a, events.get(index).source);
+      index++;
+      assertEquals("hello", events.get(index).eventName);
+      assertEquals(1, events.get(index).info);
+      assertEquals(a, events.get(index).source);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  /**
+   * Test subscription using a specified method and two objects.
+   */
+  public void testMethodWithArgsAndMultipleObjectsSubcription() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "  <object name='l' class='"+NonListenerRecorder.class.getName()+"' init='eager'>" +
+        "    <subscribe object='a' method='logEvent' >" +
+        "       <arg>" +
+        "        <string value='a'/>" +
+        "      </arg>" +
+        "   </subscribe>" +
+        "   <subscribe object='b' method='logEvent' >" +
+        "      <arg>" +
+        "       <string value='b'/>" +
+        "     </arg>" +
+        "    </subscribe>" +
+        "  </object>" +
+        "  <object name='a' class='"+DefaultObservable.class.getName()+"' />" +
+        "  <object name='b' class='"+DefaultObservable.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</environment-scopes>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable a = (Observable) environment.get("a");
+      assertNotNull(a);
+      Observable b = (Observable) environment.get("b");
+      assertNotNull(b);
+
+      a.fire("ping", null);
+      b.fire("ping", null);
+      a.fire("ping", null);
+      b.fire("ping", null);
+
+      assertEquals(events.toString(), 4, events.size());
+
+      int index=0;
+      assertEquals("a", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+      index++;
+      assertEquals("b", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+      index++;
+      assertEquals("a", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+      index++;
+      assertEquals("b", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertNull(events.get(index).source);
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+
+  /**
+   * Test subscription using a specified method.
+   */
+  public static class OverloadingTestClass extends DefaultObservable{
+    Object o;
+    public Object getO() {
+      return o;
+    }
+    public void setO(Object o) {
+      this.o = o;
+    }
+  }
+
+  /**
+   * Records calls to logEvent methods.
+   */
+  public static class OverloadingRecorder {
+
+    public void logEvent(Object o) {
+      events.add(new Event(null, "Event(Object) : " + o, null));
+    }
+
+    public void logEvent(String name) {
+      events.add(new Event(null, "Event(String) : " + name, null));
+    }
+
+    public void logEvent(Integer num) {
+      events.add(new Event(null, "Event(Integer) : " + num, null));
+    }
+
+  }
+
+  public void testMethodAndOverLoading() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "    <object name='l' class='"+OverloadingRecorder.class.getName()+"' init='eager'>" +
+        "      <subscribe object='a' method='logEvent' >" +
+        "        <arg type='java.lang.Object'>" +
+        "          <object factory='a' method='getO' />" +
+        "        </arg>" +
+        "      </subscribe>" +
+        "    </object>" +
+        "    <object name='a' class='"+OverloadingTestClass.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</environment-scopes>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      OverloadingRecorder r = (OverloadingRecorder) environment.get("l");
+      assertNotNull(r);
+      OverloadingTestClass a = (OverloadingTestClass) environment.get("a");
+      assertNotNull(a);
+
+      r.logEvent(a.getO());
+      a.fire("ping", null);
+
+      a.setO("toto");
+      r.logEvent(a.getO());
+      a.fire("ping", null);
+
+      a.setO(Integer.valueOf(42));
+      r.logEvent(a.getO());
+      a.fire("ping", null);
+
+      a.setO(Boolean.TRUE);
+      r.logEvent(a.getO());
+      a.fire("ping", null);
+
+      assertEquals(events.toString(), 8, events.size());
+
+      int index=0;
+      assertEquals(events.get(index).eventName, events.get(index+1).eventName, events.get(index).eventName);
+      index+=2;
+      assertEquals(events.get(index).eventName, events.get(index+1).eventName, events.get(index).eventName);
+      index+=2;
+      assertEquals(events.get(index).eventName, events.get(index+1).eventName, events.get(index).eventName);
+      index+=2;
+      assertEquals(events.get(index).eventName, events.get(index+1).eventName, events.get(index).eventName);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testMethodAndBadArg() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+        "<environment-scopes>" +
+        "  <process-engine-context />" +
+        "  <transaction-context>" +
+        "    <object name='l' class='"+OverloadingRecorder.class.getName()+"' init='eager'>" +
+        "      <subscribe object='a' method='logEvent' >" +
+        "        <arg type='java.lang.Integer'>" +
+        "          <string value='test' />" +
+        "        </arg>" +
+        "      </subscribe>" +
+        "    </object>" +
+        "    <object name='a' class='"+OverloadingTestClass.class.getName()+"' />" +
+        "  </transaction-context>" +
+        "</environment-scopes>"
+    );
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      OverloadingRecorder r = (OverloadingRecorder) environment.get("l");
+      assertNotNull(r);
+      OverloadingTestClass a = (OverloadingTestClass) environment.get("a");
+      assertNotNull(a);
+
+      a.fire("ping", null);
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't invoke listener method logEvent", e.getMessage());
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,312 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.util.DefaultObservable;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.wire.WireException;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class ObjectSubscriptionTest extends SubscriptionTestCase {
+
+  public void testObjectSubscriptionLazyInit() {
+    // <subscribe object='...' /> will use the object as the observable
+    // In this test, there is no eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "      <subscribe object='o' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable observable = (Observable) environment.get("o");
+      assertNotNull(observable);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      observable.fire("gun", null);
+      assertEquals(events.toString(), 0, events.size());
+
+      // initialize the recorder and subscribe to the observer
+      environment.get("recorder");
+
+      observable.fire("bazooka", null);
+      assertEquals(events.toString(), 1, events.size());
+
+      int index=0;
+      assertEquals("bazooka", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testObjectSubscriptionEagerInit() {
+    // <subscribe object='...' /> will use the object as the observable
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe object='o' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable observable = (Observable) environment.get("o");
+      assertNotNull(observable);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      observable.fire("gun", null);
+      assertEquals(events.toString(), 1, events.size());
+
+      int index=0;
+      assertEquals("gun", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+      // initialize the recorder and subscribe to the observer
+      environment.get("recorder");
+
+      observable.fire("bazooka", null);
+      assertEquals(events.toString(), 2, events.size());
+
+      index++;
+      assertEquals("bazooka", events.get(index).eventName);
+      assertNull(events.get(index).info);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testMultipleObjects() {
+    // <subscribe objects='...' /> will use the object as the observable
+    // In this test, there is eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe objects='newsletter, blog, newspaper' />" +
+      "    </object>" +
+      "    <object name='newsletter' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='blog' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='newspaper' class='"+DefaultObservable.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    int index=0;
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      // fire 2 events on newsletter: "look at our website" and "buy our product"
+      Observable newsletter = (Observable) environment.get("newsletter");
+      assertNotNull(newsletter);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      newsletter.fire("look at our website", null);
+
+      assertEquals(events.toString(), index+1, events.size());
+      assertEquals("look at our website", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertSame(newsletter, events.get(index).source);
+
+      newsletter.fire("buy our product", null);
+
+      index++;
+      assertEquals(events.toString(), index+1, events.size());
+      assertEquals("buy our product", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertSame(newsletter, events.get(index).source);
+
+      // fire 1 event on blog: 'the most stupid test'
+      Observable blog = (Observable) environment.get("blog");
+      blog.fire("The most stupid test", "Today, I saw the most stupid test ever...");
+
+      index++;
+      assertEquals(events.toString(), index+1, events.size());
+      assertEquals("The most stupid test", events.get(index).eventName);
+      assertEquals("Today, I saw the most stupid test ever...", events.get(index).info);
+      assertSame(blog, events.get(index).source);
+
+      // fire 1 event on newspaper: 'peace in the middle east'
+      Observable newspaper = (Observable) environment.get("newspaper");
+      newspaper.fire("peace in the middle east", null);
+
+      index++;
+      assertEquals(events.toString(), index+1, events.size());
+      assertEquals("peace in the middle east", events.get(index).eventName);
+      assertNull(events.get(index).info);
+      assertSame(newspaper, events.get(index).source);
+
+    } finally {
+      environment.close();
+      assertEquals(events.toString(), index+1, events.size());
+    }
+    environmentFactory.close();
+    assertEquals(events.toString(), index+1, events.size());
+  }
+
+  public void testUnexistingObject() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe object='unexistingobject' />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    try {
+      environmentFactory.openEnvironment();
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't initialize object 'recorder': couldn't subscribe to object in context transaction: object unexistingobject unavailable", e.getMessage());
+    }
+  }
+
+  public void testEventFilter() {
+    // <subscribe object='...' /> will use the object as the observable
+    // In this test, there is eager initialization
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe object='o' events='ping, pong' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable observable = (Observable) environment.get("o");
+      assertNotNull(observable);
+
+      observable.fire("ping", null);
+      observable.fire("en", null);
+      observable.fire("pong", null);
+      observable.fire("gingen", null);
+      observable.fire("samen", null);
+      observable.fire("pingpong", null);
+      observable.fire("spelen.", null);
+      observable.fire("Pang", null);
+      observable.fire("zei", null);
+      observable.fire("ping", null);
+      observable.fire("en", null);
+      observable.fire("pong", null);
+      observable.fire("stond", null);
+      observable.fire("paf", null);
+
+      assertEquals(events.toString(), 4, events.size());
+
+      int index=0;
+      assertEquals("ping", events.get(index).eventName);
+      index++;
+      assertEquals("pong", events.get(index).eventName);
+      index++;
+      assertEquals("ping", events.get(index).eventName);
+      index++;
+      assertEquals("pong", events.get(index).eventName);
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+
+  public void testNotObservableObject() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      "      <subscribe object='o' />" +
+      "    </object>" +
+      "    <object name='o' class='java.lang.Object' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    try {
+      environmentFactory.openEnvironment();
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't initialize object 'recorder': couldn't subscribe to object in context transaction: object o (java.lang.Object) isn't "+Observable.class.getName(), e.getMessage());
+    }
+    environmentFactory.close();
+  }
+
+  public void testNotListener() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='java.lang.Object' init='eager'>" +
+      "      <subscribe object='o' />" +
+      "    </object>" +
+      "    <object name='o' class='" + DefaultObservable.class.getName() +"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    try {
+      environmentFactory.openEnvironment();
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't initialize object 'recorder': couldn't subscribe object", e.getMessage());
+      assertTextPresent("because it is not a Listener", e.getMessage());
+    }
+    environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1091 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.JbpmException;
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class ObjectWireTest extends WireTestCase {
+
+  public static class DefaultConstructorClass {
+  }
+
+  public void testDefaultConstructor() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+DefaultConstructorClass.class.getName()+"' />" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(DefaultConstructorClass.class, o.getClass());
+  }
+
+  public void testDefaultConstructorWithWrongArgs() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+DefaultConstructorClass.class.getName()+"' >" +
+      "    <constructor>" +
+      "      <arg>" +
+      "        <string value='constructorparametervalue' />" +
+      "      </arg>" +
+      "    </constructor>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    try {
+      wireContext.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("couldn't find constructor "+
+          DefaultConstructorClass.class.getName() +
+          " with args [constructorparametervalue]", e.getMessage());
+    }
+  }
+
+  public void testEmptyArgDescriptor() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' class='"+DefaultConstructorClass.class.getName()+"' >" +
+        "    <constructor>" +
+        "      <arg/>" +
+        "    </constructor>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("arg must contain exactly one descriptor element out of ", problems.get(0).getMsg());
+  }
+
+  public void testMissingObjectClassName() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object />" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' must have one of {attribute 'class', attribute 'factory' or element 'factory'}", problems.get(0).getMsg());
+  }
+
+  public void testInvalidObjectType() {
+    try {
+      createWireContext(
+        "<objects>" +
+        "  <object name='o' class='invalid-object-type'/>" +
+        "</objects>"
+      );
+
+      fail("expected exception");
+    } catch (JbpmException e) {
+      assertTextPresent("couldn't get type of 'o'", e.getMessage());
+      assertTextPresent("couldn't load class invalid-object-type", e.getMessage());
+    }
+  }
+
+
+  public static class StringConstructorClass {
+    String text;
+    public StringConstructorClass(String text) {
+      this.text = text;
+    }
+  }
+
+  public void testStringConstructor() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+StringConstructorClass.class.getName()+"'>" +
+      "    <constructor>" +
+      "      <arg>" +
+      "        <string value='constructorparametervalue' />" +
+      "      </arg>" +
+      "    </constructor>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(StringConstructorClass.class, o.getClass());
+    assertEquals("constructorparametervalue", ((StringConstructorClass)o).text);
+  }
+
+  public static class StringStringConstructorClass {
+    String one;
+    String two;
+    public StringStringConstructorClass(String one, String two) {
+      this.one = one;
+      this.two = two;
+    }
+  }
+
+  public void testStringStringConstructor() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+StringStringConstructorClass.class.getName()+"'>" +
+      "    <constructor>" +
+      "      <arg>" +
+      "        <string value='one' />" +
+      "      </arg>" +
+      "      <arg>" +
+      "        <string value='two' />" +
+      "      </arg>" +
+      "    </constructor>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(StringStringConstructorClass.class, o.getClass());
+    assertEquals("one", ((StringStringConstructorClass)o).one);
+    assertEquals("two", ((StringStringConstructorClass)o).two);
+  }
+
+  public void testMethodWithoutObjectNorClass() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' method='m' />" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' must have one of {attribute 'class', attribute 'factory' or element 'factory'}", problems.get(0).getMsg());
+  }
+
+  public static class StaticFactoryMethodWithoutParametersClass {
+    private StaticFactoryMethodWithoutParametersClass() {
+    }
+    public static StaticFactoryMethodWithoutParametersClass create() {
+      return new StaticFactoryMethodWithoutParametersClass();
+    }
+  }
+  public void testStaticFactoryMethodWithoutParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+StaticFactoryMethodWithoutParametersClass.class.getName()+"' method='create' />" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertSame(StaticFactoryMethodWithoutParametersClass.class, o.getClass());
+  }
+
+  public static class NonStaticFactoryMethodClass {
+    private NonStaticFactoryMethodClass() {
+    }
+    public NonStaticFactoryMethodClass create() {
+      return new NonStaticFactoryMethodClass();
+    }
+  }
+
+  public void testNonStaticFactoryMethod(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='o' class='"+NonStaticFactoryMethodClass.class.getName()+"' method='create' />" +
+        "</objects>"
+    );
+
+    try {
+      wireContext.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("method " + NonStaticFactoryMethodClass.class.getName() + ".create() is not static.", e.getMessage());
+      assertTextPresent("It cannot be called on a null object.", e.getMessage());
+    }
+  }
+
+  public static class StaticFactoryMethodWithParametersClass {
+    String one;
+    String two;
+    StaticFactoryMethodWithParametersClass() {
+      throw new RuntimeException("buzzz");
+    }
+    StaticFactoryMethodWithParametersClass(String one, String two, Integer dummy) {
+      this.one = one;
+      this.two = two;
+    }
+    public static StaticFactoryMethodWithParametersClass create(String one, String two) {
+      return new StaticFactoryMethodWithParametersClass(one, two, null);
+    }
+  }
+
+  public void testStaticFactoryMethodWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+StaticFactoryMethodWithParametersClass.class.getName()+"' method='create'>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(StaticFactoryMethodWithParametersClass.class, o.getClass());
+    assertEquals("one", ((StaticFactoryMethodWithParametersClass)o).one);
+    assertEquals("two", ((StaticFactoryMethodWithParametersClass)o).two);
+  }
+
+  public static class FactoryMethodWithoutParametersClass {
+    public Object create() {
+      return "factoried from another object";
+    }
+  }
+  public void testObjectFactoryDescriptorWithoutParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' method='create'>" +
+      "    <factory>" +
+      "      <object class='"+FactoryMethodWithoutParametersClass.class.getName()+"' />" +
+      "    </factory>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("factoried from another object", o);
+  }
+
+  public static class FactoryMethodWithParametersClass {
+    public Object create(String one, String two) {
+      return new String[]{one, two};
+    }
+  }
+
+  public void testFactoryObjectWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' method='create'>" +
+      "    <factory>" +
+      "      <object class='"+FactoryMethodWithParametersClass.class.getName()+"' />" +
+      "    </factory>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("one", ((String[])o)[0]);
+    assertEquals("two", ((String[])o)[1]);
+  }
+
+  public void testReferencedFactoryObjectWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' factory='f' method='create'>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "  <object name='f' class='"+FactoryMethodWithParametersClass.class.getName()+"' />" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("one", ((String[])o)[0]);
+    assertEquals("two", ((String[])o)[1]);
+  }
+
+  public static class InheritedFactoryMethodMethod extends FactoryMethodWithParametersClass {
+  }
+
+  public void testInheritedFactoryMethodWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' method='create'>" +
+      "    <factory>" +
+      "      <object class='"+InheritedFactoryMethodMethod.class.getName()+"' />" +
+      "    </factory>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("one", ((String[])o)[0]);
+    assertEquals("two", ((String[])o)[1]);
+  }
+
+  public void testReferencedInheritedFactoryMethodWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' factory='f' method='create'>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "  <object name='f' class='"+InheritedFactoryMethodMethod.class.getName()+"' />" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("one", ((String[])o)[0]);
+    assertEquals("two", ((String[])o)[1]);
+  }
+
+  public static class OverloadedFactoryMethodMethod extends FactoryMethodWithParametersClass {
+    public Object create(String one, String two, String three) {
+      throw new RuntimeException("this method shouldn't be called");
+    }
+  }
+
+  public void testOverloadedFactoryMethodWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' method='create'>" +
+      "    <factory>" +
+      "      <object class='"+OverloadedFactoryMethodMethod.class.getName()+"' />" +
+      "    </factory>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("one", ((String[])o)[0]);
+    assertEquals("two", ((String[])o)[1]);
+  }
+
+  public static class OverriddenFactoryMethodMethod extends FactoryMethodWithParametersClass {
+    public Object create(String one, String two) {
+      return one+two;
+    }
+  }
+
+  public void testOverridenFactoryMethodWithParameters() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' method='create'>" +
+      "    <factory>" +
+      "      <object class='"+OverriddenFactoryMethodMethod.class.getName()+"' />" +
+      "    </factory>" +
+      "    <arg>" +
+      "      <string value='one'/>" +
+      "    </arg>" +
+      "    <arg>" +
+      "      <string value='two'/>" +
+      "    </arg>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals("onetwo", o);
+  }
+
+  public static class FieldInjectionClass {
+    static String INITVALUE = "";
+    String txtOne = INITVALUE;
+    String txtTwo = INITVALUE;
+  }
+
+  public void testFieldInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+FieldInjectionClass.class.getName()+"'>" +
+      "    <field name='txtOne'>" +
+      "      <string value='hello' />" +
+      "    </field>" +
+      "    <field name='txtTwo'>" +
+      "      <string value='world' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(FieldInjectionClass.class, o.getClass());
+    assertEquals("hello", ((FieldInjectionClass)o).txtOne);
+    assertEquals("world", ((FieldInjectionClass)o).txtTwo);
+  }
+
+  public void testMissingFieldName() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <field><null/></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("field must have name", problems.get(0).getMsg());
+  }
+
+  public void testMissingFieldDescriptor() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <field name='a'></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("field must have 1 descriptor element out of", problems.get(0).getMsg());
+  }
+
+  public void testBadFieldDescriptor() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <field name='a'><bad-descriptor /></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(2L, problems.size());
+    assertTextPresent("no element parser for tag bad-descriptor in category descriptor", problems.get(0).getMsg());
+    assertTextPresent("unknown descriptor element bad-descriptor inside field operation: ", problems.get(1).getMsg());
+  }
+
+  public static class InheritedFieldInjectionClass extends FieldInjectionClass {
+  }
+
+  public void testInheritedFieldInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+InheritedFieldInjectionClass.class.getName()+"'>" +
+      "    <field name='txtOne'>" +
+      "      <string value='hello' />" +
+      "    </field>" +
+      "    <field name='txtTwo'>" +
+      "      <string value='world' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(InheritedFieldInjectionClass.class, o.getClass());
+    assertEquals("hello", ((InheritedFieldInjectionClass)o).txtOne);
+    assertEquals("world", ((InheritedFieldInjectionClass)o).txtTwo);
+  }
+
+  public static class OverriddenFieldInjectionClass extends FieldInjectionClass {
+    String txtOne = null;
+  }
+
+  public void testOverriddenFieldInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+OverriddenFieldInjectionClass.class.getName()+"'>" +
+      "    <field name='txtOne'>" +
+      "      <string value='hello' />" +
+      "    </field>" +
+      "    <field name='txtTwo'>" +
+      "      <string value='world' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(OverriddenFieldInjectionClass.class, o.getClass());
+    assertEquals("hello", ((OverriddenFieldInjectionClass)o).txtOne);
+    assertEquals("world", ((OverriddenFieldInjectionClass)o).txtTwo);
+  }
+
+  public static class IntFieldInjectionClass {
+    int val = 0;
+    void addToVal(int a){
+      val += a;
+    }
+  }
+
+  public void testIntFieldInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+IntFieldInjectionClass.class.getName()+"'>" +
+      "    <field name='val'>" +
+      "      <int value='10' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(IntFieldInjectionClass.class, o.getClass());
+    assertEquals(10L, ((IntFieldInjectionClass)o).val);
+  }
+
+  public void testIntFieldInjectionBadType() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+IntFieldInjectionClass.class.getName()+"'>" +
+      "    <field name='val'>" +
+      "      <string value='test' />" +
+      "    </field>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    try{
+      wireContext.get("o");
+      fail("expected exception");
+    } catch (WireException e){
+      assertTextPresent("couldn't initialize object 'o': couldn't set val to test", e.getMessage());
+    }
+  }
+
+  public void testIntPropertyInjectionWithNoSetter(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='o' class='"+IntFieldInjectionClass.class.getName()+"'>" +
+        "    <property name='val'>" +
+        "      <int value='10' />" +
+        "    </property>" +
+        "  </object>" +
+        "</objects>"
+      );
+
+    try{
+      wireContext.get("o");
+      fail("expected exception");
+    } catch (WireException e){
+      assertTextPresent("couldn't initialize object 'o': couldn't find property setter setVal for value 10", e.getMessage());
+    }
+  }
+
+  public static class PropertyInjectionClass {
+    String p = null;
+    String q = null;
+    String propertyP = null;
+    String propertyQ = null;
+    public void setP(String p) {
+      propertyP = p;
+    }
+    public void setQ(String q) {
+      propertyQ = q;
+    }
+  }
+
+  public void testPropertyInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+PropertyInjectionClass.class.getName()+"'>" +
+      "    <property name='p'>" +
+      "      <string value='hello' />" +
+      "    </property>" +
+      "    <property name='q'>" +
+      "      <string value='world' />" +
+      "    </property>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(PropertyInjectionClass.class, o.getClass());
+    assertNull(((PropertyInjectionClass)o).p);
+    assertNull(((PropertyInjectionClass)o).q);
+    assertEquals("hello", ((PropertyInjectionClass)o).propertyP);
+    assertEquals("world", ((PropertyInjectionClass)o).propertyQ);
+  }
+
+  public void testPropertyInjectionWithSetter() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+PropertyInjectionClass.class.getName()+"'>" +
+      "    <property setter='setP'>" +
+      "      <string value='hello' />" +
+      "    </property>" +
+      "    <property setter='setQ'>" +
+      "      <string value='world' />" +
+      "    </property>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(PropertyInjectionClass.class, o.getClass());
+    assertNull(((PropertyInjectionClass)o).p);
+    assertNull(((PropertyInjectionClass)o).q);
+    assertEquals("hello", ((PropertyInjectionClass)o).propertyP);
+    assertEquals("world", ((PropertyInjectionClass)o).propertyQ);
+  }
+
+  public void testBadPropertyDescriptor() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <property name='p'><bad-descriptor /></property>" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(2L, problems.size());
+    assertTextPresent("no element parser for tag bad-descriptor in category descriptor", problems.get(0).getMsg());
+    assertTextPresent("couldn't parse property content element as a value descriptor: ", problems.get(1).getMsg());
+  }
+
+  public void testMissingPropertySetter() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <property><null/></property>" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("property must have name or setter", problems.get(0).getMsg());
+  }
+
+  public void testMissingPropertyValueDescriptor() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <property name='bar' />" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("property must have 1 descriptor element out of", problems.get(0).getMsg());
+  }
+
+  public static class InheritedPropertyInjectionClass extends PropertyInjectionClass {
+  }
+
+  public void testInheritedPropertyInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+InheritedPropertyInjectionClass.class.getName()+"'>" +
+      "    <property name='p'>" +
+      "      <string value='hello' />" +
+      "    </property>" +
+      "    <property name='q'>" +
+      "      <string value='world' />" +
+      "    </property>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(InheritedPropertyInjectionClass.class, o.getClass());
+    assertNull(((InheritedPropertyInjectionClass)o).p);
+    assertNull(((InheritedPropertyInjectionClass)o).q);
+    assertEquals("hello", ((InheritedPropertyInjectionClass)o).propertyP);
+    assertEquals("world", ((InheritedPropertyInjectionClass)o).propertyQ);
+  }
+
+  public static class OverwrittenPropertyInjectionClass extends PropertyInjectionClass {
+    String overwrittenPropertyQ = null;
+    public void setQ(String q) {
+      overwrittenPropertyQ = q;
+    }
+  }
+
+  public void testOverwrittenPropertyInjection() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+OverwrittenPropertyInjectionClass.class.getName()+"'>" +
+      "    <property name='p'>" +
+      "      <string value='hello' />" +
+      "    </property>" +
+      "    <property name='q'>" +
+      "      <string value='world' />" +
+      "    </property>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(OverwrittenPropertyInjectionClass.class, o.getClass());
+    assertNull(((OverwrittenPropertyInjectionClass)o).p);
+    assertNull(((OverwrittenPropertyInjectionClass)o).q);
+    assertEquals("hello", ((OverwrittenPropertyInjectionClass)o).propertyP);
+    assertNull(((OverwrittenPropertyInjectionClass)o).propertyQ);
+    assertEquals("world", ((OverwrittenPropertyInjectionClass)o).overwrittenPropertyQ);
+  }
+
+  public static class InvokeClass {
+    String text = "";
+    public void name(String name) {
+      text+=name;
+    }
+    public void wasHere() {
+      text+=" was here !";
+    }
+  }
+
+  public void testInvoke() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+InvokeClass.class.getName()+"'>" +
+      "    <invoke method='name'>" +
+      "      <arg>" +
+      "        <string value='Killroy' />" +
+      "      </arg>" +
+      "    </invoke>" +
+      "    <invoke method='wasHere' />" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(InvokeClass.class, o.getClass());
+    assertEquals("Killroy was here !", ((InvokeClass)o).text);
+  }
+
+  public void testInvokeBadMethod() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+InvokeClass.class.getName()+"'>" +
+      "    <invoke method='this-is-not-a-method'>" +
+      "      <arg>" +
+      "        <string value='that-is-true' />" +
+      "      </arg>" +
+      "    </invoke>" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    try{
+      wireContext.get("o");
+      fail("expected exception");
+    } catch(WireException e) {
+      assertTextPresent("couldn't initialize object 'o': method this-is-not-a-method(java.lang.String) unavailable", e.getMessage());
+    }
+  }
+
+  public void testInvokeBadArgs(){
+    WireContext wireContext = createWireContext(
+        "<objects>" +
+        "  <object name='o' class='"+IntFieldInjectionClass.class.getName()+"'>" +
+        "    <invoke method='addToVal'>" +
+        "      <arg type='int'>" +
+        "        <string value='foo' />" +
+        "      </arg>" +
+        "    </invoke>" +
+        "  </object>" +
+        "</objects>"
+      );
+
+      try{
+        wireContext.get("o");
+        fail("expected exception");
+      } catch(WireException e) {
+        assertTextPresent("couldn't initialize object 'o': couldn't invoke method addToVal", e.getMessage());
+        assertTextPresent("couldn't invoke 'addToVal' with [foo]", e.getMessage());
+      }
+  }
+
+  public void testInvokeWithoutMethodName() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <object name='o' class='java.lang.String'>" +
+      "    <invoke />" +
+      "  </object>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("invoke must have method", problems.get(0).getMsg());
+  }
+
+  public static class InheritedInvokeClass extends InvokeClass {
+  }
+
+  public void testInheritedInvoke() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+InheritedInvokeClass.class.getName()+"'>" +
+      "    <invoke method='name'>" +
+      "      <arg>" +
+      "        <string value='Killroy' />" +
+      "      </arg>" +
+      "    </invoke>" +
+      "    <invoke method='wasHere' />" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(InheritedInvokeClass.class, o.getClass());
+    assertEquals("Killroy was here !", ((InheritedInvokeClass)o).text);
+  }
+
+  public static class OverwrittenInvokeClass extends InvokeClass {
+    public void wasHere() {
+      text += "'s presence got overwritten :)";
+    }
+  }
+
+  public void testOverwrittenInvoke() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+OverwrittenInvokeClass.class.getName()+"'>" +
+      "    <invoke method='name'>" +
+      "      <arg>" +
+      "        <string value='Killroy' />" +
+      "      </arg>" +
+      "    </invoke>" +
+      "    <invoke method='wasHere' />" +
+      "  </object>" +
+      "</objects>"
+    );
+
+    Object o = wireContext.get("o");
+
+    assertNotNull(o);
+    assertEquals(OverwrittenInvokeClass.class, o.getClass());
+    assertEquals("Killroy's presence got overwritten :)", ((OverwrittenInvokeClass)o).text);
+  }
+
+  public void testFactoryAttributeWithoutMethod() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <string name='s' value='hello' />" +
+        "  <object name='o' factory='s' />" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' with a element 'factory' or a attribute 'factory' must have a attribute 'method'", problems.get(0).getMsg());
+  }
+
+  public void testFactoryElementWithoutMethod() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' >" +
+        "     <factory><string name='s' value='hello' /></factory>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' with a element 'factory' or a attribute 'factory' must have a attribute 'method'", problems.get(0).getMsg());
+  }
+
+  public void testFactoryElementAndClass(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' class='"+DefaultConstructorClass.class.getName()+"'>" +
+        "     <factory><string name='s' value='hello' /></factory>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'factory' is specified together with attribute 'class' in element 'object': ", problems.get(0).getMsg());
+  }
+
+  public void testFactoryAttributeAndClass(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' class='"+DefaultConstructorClass.class.getName()+"' factory='foo' />" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("attribute 'factory' is specified together with attribute 'class' in element 'object': ", problems.get(0).getMsg());
+  }
+
+  public void testFactoryElementAndAttribute(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' factory='foo'>" +
+        "     <factory><string name='s' value='hello' /></factory>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'factory' is specified together with attribute 'factory' in element 'object': ", problems.get(0).getMsg());
+  }
+  
+  public static class Foo {
+    public static Object bar() {
+      return null;
+    }
+  }
+
+  public void testClassConstructorAndMethod(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' class='"+Foo.class.getName()+"' method='bar'>" +
+        "     <constructor/>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("attributes 'class' and 'method' indicate static method and also a 'constructor' element is specified for element 'object': ", problems.get(0).getMsg());
+  }
+
+  /* this error message has been removed because object binding is reused in 
+   * the context of jpdl parsing, in which case other elements are allowed. 
+  public void testBadOperation(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' class='java.lang.String'>" +
+        "     <bad-operation/>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(problems.toString(), 2, problems.size());
+    assertTextPresent("no element parser for tag bad-operation in category operation", problems.get(0).getMsg());
+    assertTextPresent("element 'object' can only have 'factory', 'arg', 'constructor' elements or an operation element", problems.get(1).getMsg());
+    assertTextPresent("Invalid element 'bad-operation' in: ", problems.get(1).getMsg());
+  }
+  */
+
+  public void testConstructorAndFactoryAttribute(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' factory='foo' method='bar'>" +
+        "     <constructor/>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' with a element 'factory' or a attribute 'factory' can't have a 'constructor' element: ", problems.get(0).getMsg());
+  }
+
+  public void testConstructorAndFactoryElement(){
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <object name='o' method='bar'>" +
+        "     <factory>" +
+        "       <null/>" +
+        "     </factory>" +
+        "     <constructor/>" +
+        "  </object>" +
+        "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("element 'object' with a element 'factory' or a attribute 'factory' can't have a 'constructor' element: ", problems.get(0).getMsg());
+  }
+
+  public void testFactoryAttributeUnknownObject(){
+    WireContext context = createWireContext(
+        "<objects>" +
+        "  <object name='o'  factory='foo' method='bar'/>" +
+        "</objects>"
+    );
+
+    try{
+      context.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("can't invoke method 'bar' on null, resulted from fetching object 'foo' from this wiring environment", e.getMessage());
+    }
+  }
+
+  public void testFactoryAttributeNullObject(){
+    WireContext context = createWireContext(
+        "<objects>" +
+        "  <object name='o'  factory='foo' method='bar'/>" +
+        "  <null name='foo'/>" +
+        "</objects>"
+    );
+
+    try{
+      context.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("can't invoke method 'bar' on null, resulted from fetching object 'foo' from this wiring environment", e.getMessage());
+    }
+  }
+
+  public void testFactoryElementNullObject(){
+    WireContext context = createWireContext(
+        "<objects>" +
+        "  <object name='o' method='bar'>" +
+        "    <factory>" +
+        "       <null/>" +
+        "    </factory>" +
+        "  </object>" +
+        "</objects>"
+    );
+
+    try{
+      context.get("o");
+      fail("expected exception");
+    } catch (WireException e) {
+      assertTextPresent("created factory object is null, can't invoke method 'bar' on it", e.getMessage());
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/PropertiesWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jbpm.Problem;
+import org.jbpm.pvm.internal.util.FileUtil;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PropertiesWireTest extends WireTestCase {
+
+  public void testEmptyProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' />" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 0, p.size());
+  }
+
+  public void testInlineProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p'>" +
+      "    <property name='1' value='a' />" +
+      "    <property name='2' value='b' />" +
+      "    <property name='3' value='c' />" +
+      "  </properties>" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("a", p.getProperty("1"));
+    assertEquals("b", p.getProperty("2"));
+    assertEquals("c", p.getProperty("3"));
+  }
+
+  public void testPropertyWithoutNameOrValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <properties name='p'>" +
+      "    <property />" +
+      "  </properties>" +
+      "</objects>"
+    );
+
+    assertEquals(problems.toString(), 1, problems.size());
+    assertTextPresent("property must have name and value attribute", problems.get(0).toString());
+  }
+
+  public void testFileProperties() throws Exception {
+    String propertiesFile = FileUtil.getFileNameForResource("org/jbpm/pvm/internal/wire/file.properties"); 
+
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' file='"+propertiesFile+"' />" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("flute", p.getProperty("1"));
+    assertEquals("fagot", p.getProperty("2"));
+    assertEquals("fecundity", p.getProperty("3"));
+  }
+
+  public void testUnexistingFileProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' file='unexisting-file' />" +
+      "</objects>"
+    );
+
+    try {
+      wireContext.get("p");
+    } catch (WireException e) {
+      assertTextPresent("couldn't read properties from file unexisting-file", e.getMessage());
+    }
+  }
+
+  public void testUrlProperties() {
+    String testClassesUrl = PropertiesWireTest.class.getProtectionDomain().getCodeSource().getLocation().toString();
+    String propertiesFile = testClassesUrl+"/org/jbpm/wire/url.properties"; 
+
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' url='"+propertiesFile+"' />" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("umbrella", p.getProperty("1"));
+    assertEquals("ultraviolet", p.getProperty("2"));
+    assertEquals("ubiquitous", p.getProperty("3"));
+  }
+
+  public void testUnexistingUrlProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' url='buzzzzz' />" +
+      "</objects>"
+    );
+
+    try {
+      wireContext.get("p");
+    } catch (WireException e) {
+      assertTextPresent("couldn't read properties from url buzzzzz", e.getMessage());
+    }
+  }
+
+  public void testResourceProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' resource='org/jbpm/wire/resource.properties' />" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("rubber", p.getProperty("1"));
+    assertEquals("rack", p.getProperty("2"));
+    assertEquals("ramblas", p.getProperty("3"));
+  }
+
+  public void testUnexistingResourceProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' resource='unexisting-resource' />" +
+      "</objects>"
+    );
+
+    try {
+      wireContext.get("p");
+    } catch (WireException e) {
+      assertTextPresent("couldn't read properties from resource unexisting-resource", e.getMessage());
+    }
+  }
+
+  public void testOverridenFileProperties() throws Exception {
+    String propertiesFile = FileUtil.getFileNameForResource("/org/jbpm/wire/file.properties"); 
+
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' file='"+propertiesFile+"'>" +
+      "    <property name='2' value='overwritten' />" +
+      "  </properties>" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("flute", p.getProperty("1"));
+    assertEquals("overwritten", p.getProperty("2"));
+    assertEquals("fecundity", p.getProperty("3"));
+  }
+
+  public void testOverridenUrlProperties() {
+    String testClassesUrl = PropertiesWireTest.class.getProtectionDomain().getCodeSource().getLocation().toString();
+    String propertiesFile = testClassesUrl+"/org/jbpm/wire/url.properties"; 
+
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' url='"+propertiesFile+"'>" +
+      "    <property name='2' value='overwritten' />" +
+      "  </properties>" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("umbrella", p.getProperty("1"));
+    assertEquals("overwritten", p.getProperty("2"));
+    assertEquals("ubiquitous", p.getProperty("3"));
+  }
+
+  public void testOverridenResourceProperties() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <properties name='p' resource='org/jbpm/wire/resource.properties'>" +
+      "    <property name='2' value='overwritten' />" +
+      "  </properties>" +
+      "</objects>"
+    );
+
+    Properties p = (Properties) wireContext.get("p");
+    assertEquals(p.toString(), 3, p.size());
+    assertEquals("rubber", p.getProperty("1"));
+    assertEquals("overwritten", p.getProperty("2"));
+    assertEquals("ramblas", p.getProperty("3"));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Problem;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class RefWireTest extends WireTestCase {
+
+  public void testSimpleAlias() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+Object.class.getName()+"' />" +
+      "  <ref name='r' object='o' />" +
+      "</objects>"
+    );
+
+    Object r = wireContext.get("r");
+    assertNotNull(r);
+
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+
+    assertSame(o, r);
+  }
+
+  public void testMissingObjectName() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <ref name='r'/>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertEquals(1, problems.size());
+    assertTextPresent("ref must have object attribute: ", problems.get(0).getMsg());
+  }
+
+  public void testReferenceInList() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+Object.class.getName()+"' />" +
+      "  <list name='l'>" +
+      "    <ref object='o' />" +
+      "  </list>" +
+      "</objects>"
+    );
+
+    List l = (List) wireContext.get("l");
+    assertNotNull(l);
+
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+
+    assertSame(o, l.get(0));
+  }
+
+  public void testReferenceInMap() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+Object.class.getName()+"' />" +
+      "  <map name='m'>" +
+      "    <entry>" +
+      "      <key>" +
+      "        <string value='k' />" +
+      "      </key>" +
+      "      <value>" +
+      "        <ref object='o' />" +
+      "      </value>" +
+      "    </entry>" +
+      "  </map>" +
+      "</objects>"
+    );
+
+    Map m = (Map) wireContext.get("m");
+    assertNotNull(m);
+
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+
+    assertSame(o, m.get("k"));
+  }
+
+  public void testReferenceInSet() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='o' class='"+Object.class.getName()+"' />" +
+      "  <set name='s'>" +
+      "    <ref object='o' />" +
+      "  </set>" +
+      "</objects>"
+    );
+
+    Set s = (Set) wireContext.get("s");
+    assertNotNull(s);
+
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+
+    assertSame(o, s.iterator().next());
+  }
+
+  public static class X {
+    String constructorArgValue;
+    String fieldValue;
+    String propertyValue;
+    String invokeFirstArg;
+    String invokeSecondArg;
+    public X() {
+    }
+    public X(String constructorArgValue) {
+      this.constructorArgValue = constructorArgValue;
+    }
+    public String getPropertyValue() {
+      return propertyValue;
+    }
+    public void setP(String propertyValue) {
+      this.propertyValue = propertyValue;
+    }
+    public void invoke(String invokeFirstArg, String invokeSecondArg) {
+      this.invokeFirstArg = invokeFirstArg;
+      this.invokeSecondArg = invokeSecondArg;
+    }
+  }
+
+  public void testConstructorArgument() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='x' class='"+X.class.getName()+"'>" +
+      "    <constructor>" +
+      "      <arg><ref object='AMS' /></arg>" +
+      "    </constructor>" +
+      "  </object>" +
+      "  <string name='AMS' value='xxx' />" +
+      "</objects>"
+    );
+
+    X x = (X) wireContext.get("x");
+    assertEquals("xxx", x.constructorArgValue);
+  }
+
+  public void testFieldArgument() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='x' class='"+X.class.getName()+"'>" +
+      "    <field name='fieldValue'><ref object='AMS' /></field>" +
+      "  </object>" +
+      "  <string name='AMS' value='xxx' />" +
+      "</objects>"
+    );
+
+    X x = (X) wireContext.get("x");
+    assertEquals("xxx", x.fieldValue);
+  }
+
+  public void testPropertyArgument() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='x' class='"+X.class.getName()+"'>" +
+      "    <property name='p'><ref object='AMS' /></property>" +
+      "  </object>" +
+      "  <string name='AMS' value='xxx' />" +
+      "</objects>"
+    );
+
+    X x = (X) wireContext.get("x");
+    assertEquals("xxx", x.propertyValue);
+  }
+
+  public void testInvokeArgument() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object name='x' class='"+X.class.getName()+"'>" +
+      "    <invoke method='invoke'>" +
+      "      <arg><ref object='AMS' /></arg>" +
+      "      <arg><ref object='HAM' /></arg>" +
+      "    </invoke>" +
+      "  </object>" +
+      "  <string name='AMS' value='xxx' />" +
+      "  <string name='HAM' value='hamburger' />" +
+      "</objects>"
+    );
+
+    X x = (X) wireContext.get("x");
+    assertEquals("xxx", x.invokeFirstArg);
+    assertEquals("hamburger", x.invokeSecondArg);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,64 @@
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.Problem;
+
+public class SetWireTest extends WireTestCase {
+
+  public void testSet() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <set name='s'>" +
+      "    <true />" +
+      "    <string value='' />" +
+      "    <null />" +
+      "    <object name='o' class='"+Object.class.getName()+"' />" +
+      "  </set>" +
+      "</objects>"
+    );
+    
+    Set s = (Set) wireContext.get("s");
+    assertEquals(s.toString(), 4, s.size());
+    assertTrue(s.contains(Boolean.TRUE));
+    assertTrue(s.contains(""));
+    assertTrue(s.contains(null));
+    
+    Object o = wireContext.get("o");
+    assertNotNull(o);
+    assertTrue(s.contains(o));
+  }
+
+  public void testCustomListType() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <set name='s' class='java.util.TreeSet' />" +
+      "</objects>"
+    );
+    assertEquals(java.util.TreeSet.class, wireContext.get("s").getClass());
+  }
+
+  public void testInvalidSetType() {
+    List<Problem> problems = parseProblems(
+        "<objects>" +
+        "  <set name='s' class='invalid-set-type'/>" +
+        "</objects>"
+    );
+
+    assertTextPresent("class invalid-set-type could not be found", problems.get(0).getMsg());
+  }
+
+  public void testUnknownValue() {
+    List<Problem> problems = parseProblems(
+      "<objects>" +
+      "  <set name='s'>" +
+      "    <unknown-descriptor />" +
+      "  </set>" +
+      "</objects>"
+    );
+    assertNotNull(problems);
+    assertTextPresent("no element parser for tag unknown-descriptor", problems.get(0).getMsg());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SubscriptionTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SubscriptionTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SubscriptionTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class SubscriptionTestCase extends BaseJbpmTestCase {
+
+  public static class Event {
+    Object source;
+    String eventName;
+    Object info;
+    public Event(Object source, String eventName, Object info) {
+      this.source = source;
+      this.eventName = eventName;
+      this.info = info;
+    }
+    public String toString() {
+      return "("+source+"|"+eventName+"|"+info+")";
+    }
+  }
+  
+  static List<Event> events = null;
+  
+  public void setUp() throws Exception {
+    super.setUp();
+    events = new ArrayList<Event>();
+  }
+
+  public void tearDown() throws Exception {
+    events = null;
+    super.tearDown();
+  }
+
+  public static class Recorder implements Listener {
+    public void event(Object source, String eventName, Object info) {
+      events.add(new Event(source, eventName, info));
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/TypeLookupTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/TypeLookupTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/TypeLookupTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TypeLookupTest extends WireTestCase {
+  
+  public static class A {
+  }
+
+  public void testTypeLookup() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object class='"+A.class.getName()+"' />" +
+      "</objects>"
+    );
+    
+    A a = wireContext.get(A.class);
+    assertNotNull(a);
+  }
+
+  public static class B extends A {
+  }
+
+  public void testTypeLookupWithInheritence() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object class='"+B.class.getName()+"' />" +
+      "</objects>"
+    );
+    
+    A a = wireContext.get(A.class);
+    assertNotNull(a);
+    assertEquals(B.class, a.getClass());
+  }
+
+  public static class Text {
+    String text;
+  }
+
+  public void testTypeLookupOrder() {
+    WireContext wireContext = createWireContext(
+      "<objects>" +
+      "  <object class='"+Text.class.getName()+"'>" +
+      "    <field name='text'><string value='a'/></field>" +
+      "  </object>" +
+      "  <object class='"+Text.class.getName()+"'>" +
+      "    <field name='text'><string value='b'/></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    
+    assertEquals("a", wireContext.get(Text.class).text);
+
+    wireContext = createWireContext(
+      "<objects>" +
+      "  <object class='"+Text.class.getName()+"'>" +
+      "    <field name='text'><string value='b'/></field>" +
+      "  </object>" +
+      "  <object class='"+Text.class.getName()+"'>" +
+      "    <field name='text'><string value='a'/></field>" +
+      "  </object>" +
+      "</objects>"
+    );
+    
+    assertEquals("b", wireContext.get(Text.class).text);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,313 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.util.DefaultObservable;
+import org.jbpm.pvm.internal.util.Observable;
+import org.jbpm.pvm.internal.wire.WireObjectEventInfo;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WireEventsSubscriptionTest extends SubscriptionTestCase {
+
+  // <subscribe to='wire-events' ... /> will use the descriptors in the 
+  // WireDefinition as observables.  They will notify the subscriber
+  // of the wire events as defined in the static contants found in 
+  // class Descriptor
+
+  public void testRegisterToAllDescriptors() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      // If no object(s) are specified, the subscriber will be informed of 
+      // events on *all* descriptors.
+      "      <subscribe to='wire-events' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      Observable observable = (Observable) environment.get("o");
+      assertNotNull(observable);
+
+      assertEquals(events.toString(), 0, events.size());
+
+      environment.get("recorder");
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("recorder", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 2, events.size());
+  }
+
+  public void testOneObjectDescriptor() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      // only subscribe to wire-events of object o, which means that recorder will 
+      // be notified of any event produced by the descriptor of object o
+      "      <subscribe to='wire-events' object='o' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='p' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 4, events.size());
+
+      int index=0;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      assertNotNull(environment.get("p"));
+      
+      assertEquals(events.toString(), 4, events.size());
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 4, events.size());
+  }
+
+  public void testMultipleObjectDescriptors() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      // record all wire events coming from the descriptors of objects o and p  
+      "      <subscribe to='wire-events' objects='o, p' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='p' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 4, events.size());
+
+      int index=0;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      assertNotNull(environment.get("p"));
+      
+      assertEquals(events.toString(), 8, events.size());
+
+      index++;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("set", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 8, events.size());
+  }
+
+  public void testOneObjectDescriptorWithEventFilter() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      // record only 'initializing' wire events produced by the descriptor of object o. 
+      "      <subscribe to='wire-events' object='o' event='initializing' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='p' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 1, events.size());
+
+      int index=0;
+      assertEquals("initializing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      assertNotNull(environment.get("p"));
+      
+      assertEquals(events.toString(), 1, events.size());
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 1, events.size());
+  }
+
+  public void testMultipleObjectDescriptorsWithEventFilter() {
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"' init='eager'>" +
+      // record 'constructing' and 'constructed' events fired by descriptors for objects o and p 
+      "      <subscribe to='wire-events' objects='o, p' events='constructing, constructed' />" +
+      "    </object>" +
+      "    <object name='o' class='"+DefaultObservable.class.getName()+"' />" +
+      "    <object name='p' class='"+Object.class.getName()+"' />" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+
+      assertEquals(events.toString(), 0, events.size());
+
+      assertNotNull(environment.get("o"));
+
+      assertEquals(events.toString(), 2, events.size());
+
+      int index=0;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("o", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      assertNotNull(environment.get("p"));
+      
+      assertEquals(events.toString(), 4, events.size());
+
+      index++;
+      assertEquals("constructing", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+      index++;
+      assertEquals("constructed", events.get(index).eventName);
+      assertEquals("p", ((WireObjectEventInfo)events.get(index).info).getObjectName());
+      assertEquals(ObjectDescriptor.class, events.get(index).source.getClass());
+      
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+
+    assertEquals(events.toString(), 4, events.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.env.Context;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.util.Listener;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WireObservableTest extends BaseJbpmTestCase
+{
+  
+  public static class Recorder implements Listener {
+    public void event(Object source, String eventName, Object info) {
+    }
+  }
+
+  public void testSubscription() {
+    // <subscribe /> will use the scope as the observable
+    // In this test, there is no eager initialisation
+
+    EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+      "<environment-scopes>" +
+      "  <process-engine-context />" +
+      "  <transaction-context>" +
+      "    <object name='recorder' class='"+Recorder.class.getName()+"'>" +
+      "      <subscribe />" +
+      "    </object>" +
+      "  </transaction-context>" +
+      "</environment-scopes>"
+    );
+
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      WireContext environmentContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
+
+      // this test also checks non-eager-initialized subscription
+      // subscription should only be done when the object is created the first time
+      List<Listener> listeners = environmentContext.getListeners();
+      int beforeListenersSize = (listeners!=null ? listeners.size() : 0);
+      
+      assertNotNull(environment.get("recorder"));
+      
+      listeners = environmentContext.getListeners();
+      int afterListenersSize = (listeners!=null ? listeners.size() : 0);
+      int addedListeners = afterListenersSize - beforeListenersSize;
+      assertEquals(1, addedListeners);
+      
+
+    } finally {
+      environment.close();
+    }
+    environmentFactory.close();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire;
+
+import java.util.List;
+
+import org.jbpm.Problem;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class WireTestCase extends BaseJbpmTestCase {
+
+  public static WireContext createWireContext(String wireDefinitionXml) {
+    WireDefinition wireDefinition = (WireDefinition) WireParser.getInstance()
+            .createParse()
+            .setString(wireDefinitionXml)
+            .execute()
+            .checkProblems("wire definition xml string")
+            .getDocumentObject();
+    return new WireContext(wireDefinition);
+  }
+
+  public static List<Problem> parseProblems(String wireDefinitionXml) {
+    return WireParser.getInstance()
+            .createParse()
+            .setString(wireDefinitionXml)
+            .execute()
+            .getProblems();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/println/PrintlnTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/println/PrintlnTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/println/PrintlnTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.println;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.activities.PrintLnBuilder;
+import org.jbpm.pvm.activities.TestConsoleTestCase;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+public class PrintlnTest extends TestConsoleTestCase {
+  
+  public void testHelloWorld() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity()
+        .initial()
+        .startBehaviour(PrintLnBuilder.class)
+          .message("print me")
+        .endBehaviour()
+      .endActivity()
+    .endProcess();
+
+    processDefinition.startProcessInstance();
+    
+    assertEquals("print me", testConsole.getLine(0));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/spring/SpringTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/spring/SpringTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/spring/SpringTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.spring;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.test.BaseJbpmTestCase;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SpringTest extends BaseJbpmTestCase {
+
+  public void testSpringTransactions() {
+    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/jbpm/pvm/spring/spring.beans.xml");
+    EnvironmentFactory environmentFactory = (EnvironmentFactory) applicationContext.getBean("environmentFactory");
+    
+    CommandService commandService = environmentFactory.get(CommandService.class);
+    
+    assertNull(Environment.getCurrent());
+
+    Session session = (Session) commandService.execute(new Command<Object>() {
+      public Object execute(Environment environment) throws Exception {
+        assertNotNull(environment);
+        Session session = environment.get(Session.class);
+        assertNotNull(session);
+        assertTrue(session.isOpen());
+        assertSame(session, environment.get(Session.class));
+        return session;
+      }
+    });
+
+    assertFalse(session.isOpen());
+
+    assertNull(Environment.getCurrent());
+
+    /* TODO translate the DeployerManager to a data structure that is 
+     * easy to wire up with spring
+    ProcessService processService = environmentFactory.get(ProcessService.class);
+
+    ProcessDefinition processDefinition = ProcessFactory.build("basic")
+      .activity("a").initial().behaviour(WaitState.class)
+        .transition().to("b")
+      .activity("b").behaviour(WaitState.class)
+        .transition().to("c")
+      .activity("c").behaviour(AutomaticActivity.class)
+        .transition().to("d")
+      .activity("d").behaviour(AutomaticActivity.class)
+        .transition().to("e")
+      .activity("e").behaviour(WaitState.class)
+    .done();
+  
+    processService.deploy(processDefinition);
+  
+    Execution execution = processService.startExecution("basic", "one");
+  
+    assertEquals("a", execution.getActivity().getName());
+  
+    execution = processService.signalExecution("basic", "one");
+  
+    assertEquals("b", execution.getActivity().getName());
+  
+    execution = processService.signalExecution("basic", "one");
+  
+    assertEquals("e", execution.getActivity().getName());
+     */ 
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentDbTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentDbTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentDbTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.test;
+
+import java.lang.reflect.Field;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.jbpm.Execution;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.session.DbSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.Db;
+
+
+/** for tests that use persistence inside environment blocks.
+ * 
+ * An environment is opened in the setUp and closed in the tearDown.
+ * DB is cleaned inbetween tests. Extra convenience methods for usage 
+ * inside an environment block are provided. 
+ * 
+ * @author Tom Baeyens
+ */
+public abstract class EnvironmentDbTestCase extends EnvironmentTestCase {
+  
+  Transaction transaction = null;
+  
+  public EnvironmentDbTestCase() {
+  }
+
+  public EnvironmentDbTestCase(String configResource) {
+    super(configResource);
+  }
+
+  public void setUp() throws Exception {
+    if (isEnvironmentFactoryCached()) {
+      Db.clean(getEnvironmentFactory());
+    }
+    super.setUp();
+    beginTransaction();
+  }
+  
+  public void tearDown() throws Exception {
+    commitTransaction();
+    super.tearDown();
+  }
+
+  void beginTransaction() {
+    Session session = environment.get(Session.class);
+    transaction = session.beginTransaction();
+  }
+
+  void commitTransaction() {
+    transaction.commit();
+    transaction = null;
+  }
+  
+  void rollbackTransaction() {
+    transaction.rollback();
+    transaction = null;
+  }
+  
+  public DbSession getDbSession() {
+    return environment.get(DbSession.class);
+  }
+  
+  public void rollbackAndBeginNewTransaction() {
+    rollbackTransaction();
+    closeEnvironment();
+    openEnvironment();
+    beginTransaction();
+  }
+  
+  public void newTransaction() {
+    try {
+      commitTransaction();
+      closeEnvironment();
+    } finally {
+      openEnvironment();
+      beginTransaction();
+    }
+  }
+
+  public void beginCacheTest() {
+    SessionFactory sessionFactory = environment.get(SessionFactory.class);
+    if (sessionFactory != null) {
+      log.debug("=================================================================");
+      log.debug("Beginning of the cache test, no more sql query should be performed before the end of the test");
+      log.debug("=================================================================");
+
+      sessionFactory.getStatistics().clear();
+      sessionFactory.getStatistics().setStatisticsEnabled(true);
+    }
+  }
+  
+  public void endCacheTest() {
+    SessionFactory sessionFactory = environment.get(SessionFactory.class);
+    if (sessionFactory != null) {
+      assertEquals(0, sessionFactory.getStatistics().getEntityLoadCount());
+      assertEquals(0, sessionFactory.getStatistics().getCollectionLoadCount());
+    }
+  }
+  
+  public <T> T reload(Object object, Class<T> persistentClass) {
+    environment.get(DbSession.class).save(object);
+    newTransaction();
+    
+    Long dbid = null;
+    try {
+      Field dbidField = getDbidField(persistentClass);
+      dbidField.setAccessible(true);
+      dbid = (Long) dbidField.get(object);
+    } catch (RuntimeException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+    
+    return environment.get(DbSession.class).get(persistentClass, dbid);
+  }
+  
+  private Field getDbidField(Class<?> clazz) {
+    Field[] fields = clazz.getDeclaredFields();
+    for (int i=0; i<fields.length; i++) {
+      if  ("dbid".equals(fields[i].getName())) {
+        return fields[i];
+      }
+    }
+    Class<?> superClass = clazz.getSuperclass();
+    if (superClass!=null) {
+      return getDbidField(superClass);
+    }
+    throw new RuntimeException("no dbid field in object to reload");
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentFactoryTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentFactoryTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentFactoryTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Configuration;
+import org.jbpm.JbpmException;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class EnvironmentFactoryTestCase extends BaseJbpmTestCase {
+  
+  String configResource;
+
+  static Map<String, EnvironmentFactory> environmentFactories = new HashMap<String, EnvironmentFactory>();
+  
+  public EnvironmentFactoryTestCase() {
+    this("jbpm.cfg.xml");
+  }
+  
+  public EnvironmentFactoryTestCase(String configResource) {
+    this.configResource = configResource;
+  }
+
+  public EnvironmentFactory getEnvironmentFactory() {
+    if (isEnvironmentFactoryCached()) {
+      return environmentFactories.get(configResource);
+    }
+    return createEnvironmentFactory();
+  }
+
+  boolean isEnvironmentFactoryCached() {
+    return environmentFactories.containsKey(configResource);
+  }
+
+  EnvironmentFactory createEnvironmentFactory() {
+    return createEnvironmentFactory(configResource);
+  }
+
+  static EnvironmentFactory createEnvironmentFactory(String configResource) {
+    try {
+      log.debug("creating environment factory for ["+configResource+"]");
+      EnvironmentFactory newEnvironmentFactory = (EnvironmentFactory) new Configuration().setResource(configResource).buildProcessEngine();
+      environmentFactories.put(configResource, newEnvironmentFactory);
+      return newEnvironmentFactory;
+    } catch (Exception e) {
+      throw new JbpmException("Exception during creation of environment factory for "+configResource, e);
+    }
+  }
+
+  static void closeEnvironmentFactory(String configResource) {
+    EnvironmentFactory environmentFactory = environmentFactories.remove(configResource);
+    if (environmentFactory!=null) {
+      log.debug("closing environment factory for ["+configResource+"]");
+      environmentFactory.close();
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/test/EnvironmentTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.test;
+
+import org.jbpm.env.Environment;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class EnvironmentTestCase extends EnvironmentFactoryTestCase {
+
+  protected Environment environment;
+  
+  public EnvironmentTestCase() {
+  }
+
+  public EnvironmentTestCase(String configResource) {
+    super(configResource);
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    openEnvironment();
+  }
+
+  public void tearDown() throws Exception {
+    closeEnvironment();
+    super.tearDown();
+  }
+  
+  void closeEnvironment() {
+    environment.close();
+    environment = null;
+  }
+
+  void openEnvironment() {
+    environment = getEnvironmentFactory().openEnvironment();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.tx;
+
+import java.util.List;
+
+import javax.transaction.Synchronization;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.env.Transaction;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.type.variable.StringVariable;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicTransactionTest extends JbpmTestCase {
+
+  public void testCommit() {
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        session.save(new CommentImpl("if i only had the time to write code"));
+        return null;
+      }
+    });
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertEquals("if i only had the time to write code", comments.get(0).getMessage());
+        return null;
+      }
+    });
+  }
+
+  public static class MyOwnRuntimeException extends RuntimeException {
+  }
+
+  public void testRollbackRuntimeException() {
+    try {
+      commandService.execute(new Command<Object>() {
+
+        public Object execute(Environment environment) {
+          Session session = environment.get(Session.class);
+          session.save(new CommentImpl("if i only had the time to write code"));
+          throw new MyOwnRuntimeException();
+        }
+      });
+      fail("expected exception");
+    } catch (MyOwnRuntimeException e) {
+      // OK
+    }
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertEquals(0, comments.size());
+        return null;
+      }
+    });
+  }
+
+  public static class MyOwnCheckedException extends Exception {
+  }
+
+  public void testRollbackCheckedException() {
+    try {
+      commandService.execute(new Command<Object>() {
+
+        public Object execute(Environment environment) throws Exception {
+          Session session = environment.get(Session.class);
+          session.save(new CommentImpl("if i only had the time to write code"));
+          throw new MyOwnCheckedException();
+        }
+      });
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertSame(MyOwnCheckedException.class, e.getCause().getClass());
+    }
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertEquals(0, comments.size());
+        return null;
+      }
+    });
+  }
+
+  public static class SuccessfulSynchronization implements Synchronization {
+
+    public void beforeCompletion() {
+      Environment environment = Environment.getCurrent();
+      Session session = environment.get(Session.class);
+      StringVariable stringVariable = new StringVariable();
+      stringVariable.setValue("hello");
+      session.save(stringVariable);
+    }
+
+    public void afterCompletion(int arg0) {
+    }
+  }
+
+  public void testSuccessfulSynchronization() {
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) throws Exception {
+        Session session = environment.get(Session.class);
+        session.save(new CommentImpl("if i only had the time to write code"));
+        Transaction transaction = environment.get(Transaction.class);
+        SuccessfulSynchronization successfulSynchronization = new SuccessfulSynchronization();
+        transaction.registerSynchronization(successfulSynchronization);
+        return null;
+      }
+    });
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertEquals("if i only had the time to write code", comments.get(0).getMessage());
+        List<StringVariable> stringVariables = session.createQuery("from " + StringVariable.class.getName()).list();
+        assertEquals("hello", stringVariables.get(0).getValue());
+        return null;
+      }
+    });
+  }
+
+  public static class UnsuccessfulSynchronization implements Synchronization {
+
+    public void beforeCompletion() {
+      Environment environment = Environment.getCurrent();
+      Session session = environment.get(Session.class);
+      StringVariable stringVariable = new StringVariable();
+      stringVariable.setValue("hello");
+      session.save(stringVariable);
+      throw new MyOwnRuntimeException();
+    }
+
+    public void afterCompletion(int arg0) {
+    }
+  }
+
+  public void testUnsuccessfulSynchronization() {
+    try {
+      commandService.execute(new Command<Object>() {
+
+        public Object execute(Environment environment) throws Exception {
+          Session session = environment.get(Session.class);
+          session.save(new CommentImpl("if i only had the time to write code"));
+          Transaction transaction = environment.get(Transaction.class);
+          UnsuccessfulSynchronization unsuccessfulSynchronization = new UnsuccessfulSynchronization();
+          transaction.registerSynchronization(unsuccessfulSynchronization);
+          return null;
+        }
+      });
+      fail("expected exception");
+    } catch (MyOwnRuntimeException e) {
+      // OK
+    }
+
+    // the exception in the beforeCompletion in the synchronization should have
+    // caused
+    // the previous transaction to rollback
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertEquals(0, comments.size());
+        List<StringVariable> stringVariables = session.createQuery("from " + StringVariable.class.getName()).list();
+        assertEquals(0, stringVariables.size());
+        return null;
+      }
+    });
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.variables;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.pvm.internal.type.variable.DateVariable;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.test.EnvironmentDbTestCase;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class CustomTypeVariableTest extends EnvironmentDbTestCase {
+
+  private static final String ENVIRONMENT_CFG_XML = "org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml";
+
+  public CustomTypeVariableTest() {
+    super(ENVIRONMENT_CFG_XML);
+  }
+
+  public void testDateVariable() {
+    ClientProcessDefinition clientProcessDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity(
+          new ObjectDescriptor(WaitState.class)
+        )
+        .initial()
+      .endActivity()
+    .endProcess();
+
+    getDbSession().save(clientProcessDefinition);
+
+    ExecutionImpl execution = (ExecutionImpl) clientProcessDefinition.startProcessInstance();
+
+    execution = reload(execution, ExecutionImpl.class);
+
+    Calendar calendar = new GregorianCalendar();
+    calendar.set(Calendar.YEAR, 2007);
+    calendar.set(Calendar.MONTH, 10); // (10 == november)
+    calendar.set(Calendar.DAY_OF_MONTH, 22);
+    calendar.set(Calendar.HOUR_OF_DAY, 15);
+    calendar.set(Calendar.MINUTE, 28);
+    calendar.set(Calendar.SECOND, 57);
+    calendar.set(Calendar.MILLISECOND, 374);
+
+    execution.setVariable("v", calendar.getTime());
+
+    execution = reload(execution, ExecutionImpl.class);
+
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(DateVariable.class, variable.getClass());
+
+    assertEquals(calendar.getTime(), execution.getVariable("v"));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/META-INF/persistence.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/META-INF/persistence.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/META-INF/persistence.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+             http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+             version="1.0">
+
+  <persistence-unit name="jboss-identity-jbpm" transaction-type="RESOURCE_LOCAL">
+
+    <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</class>
+    <class>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</class>
+
+    <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    
+    <properties>
+      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
+      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
+      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:." />
+      <property name="hibernate.connection.username" value="sa" />
+      <property name="hibernate.connection.password" value="" />
+      <property name="hibernate.hbm2ddl.auto" value="create-drop" />
+    </properties>
+
+  </persistence-unit>
+
+</persistence>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cache.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cache.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cache.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+<hibernate-cache>
+
+  <class-cache class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ActivityImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.TransitionImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.EventImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ExceptionHandlerImpl" />
+	<class-cache class="org.jbpm.pvm.internal.model.ObjectReference" />
+  <class-cache class="org.jbpm.pvm.internal.model.VariableDefinitionImpl" />
+  <class-cache class="org.jbpm.pvm.internal.model.TimerDefinitionImpl" />
+  <class-cache class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.events" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.activities" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.variableDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.timerDefinitions" />
+  <collection-cache collection="org.jbpm.pvm.internal.model.ProcessDefinitionImpl.attachments" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.events" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.activities" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.variableDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.timerDefinitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.incomingTransitions" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.ActivityImpl.outgoingTransitions" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.TransitionImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.TransitionImpl.events" />
+
+	<collection-cache collection="org.jbpm.pvm.internal.model.EventImpl.exceptionHandlers" />
+	<collection-cache collection="org.jbpm.pvm.internal.model.EventImpl.listenerReferences" />
+	  
+	<collection-cache collection="org.jbpm.pvm.internal.model.ExceptionHandlerImpl.eventListenerReferences" />
+
+  <collection-cache collection="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.argDescriptors" />
+  <collection-cache collection="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.operations" />
+	
+</hibernate-cache>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <process-service />
+    <execution-service />
+    <history-service />
+    <management-service />
+    <identity-service />
+    <task-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration cfg="jbpm.hibernate.cfg.xml">     
+      <cache-configuration resource="jbpm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+
+    <hibernate-session-factory />
+
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+
+    <script-manager default-expression-language="juel"
+                    default-script-language="juel"
+                    read-contexts="execution, environment, process-engine"
+                    write-context="">
+        <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+    </script-manager>
+
+    <job-executor auto-start="false" />
+
+    <id-generator />
+    <types resource="jbpm.variable.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <task-db-session />
+    <message-session />
+    <timer-session />
+    <history-session />
+    <identity-session realm="realm://jbpm-identity" />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.definition.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.definition.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.definition.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,641 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.model" default-access="field">
+
+  <!-- ### PROCESS DEFINITION ############################################# -->
+  <class name="ProcessDefinitionImpl" table="JBPM_PROCESS">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_PROCDEF_PROPS"
+                 index="IDX_PROCDEF_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_PROCESS">
+        <column name="PROCESS_" index="IDX_EXHDLR_PROCESS"/>
+      </key>
+      <index column="PROCESS_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl"/>
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <property name="description" column="DESCR_" />
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_PROCESS">
+        <column name="PROCESS_" index="IDX_EVENT_PROCESS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl"/>
+    </map>
+
+    <!-- CompositeElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <list name="activities" cascade="all" inverse="false">
+      <key foreign-key="FK_ACTS_PROCESS">
+        <column name="ACTSPROCESS_" index="IDX_ACTS_PROCESS"/>
+      </key>
+      <list-index column="ACTSPROCESS_IDX_" />
+      <one-to-many class="ActivityImpl" />
+    </list>
+    <property name="hasVariableDefinitions" column="HAS_VAR_DEF_" />
+    <list name="variableDefinitions" cascade="all">
+      <key foreign-key="FK_VARDEF_PROCESS">
+        <column name="PROCESS_" index="IDX_VARDEF_PROCESS"/>
+      </key>
+      <index column="PROCESS_IDX_" />
+      <one-to-many class="VariableDefinitionImpl" />
+    </list>
+    <property name="hasTimerDefinitions" column="HAS_TIMER_DEF_" />
+    <set name="timerDefinitions" cascade="all">
+      <key foreign-key="FK_TMRDEF_PROCESS">
+        <column name="PROCESS_" index="IDX_TMRDEF_PROCESS"/>
+      </key>
+      <one-to-many class="TimerDefinitionImpl" />
+    </set>
+
+    <!-- ProcessDefinitionImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="key" column="KEY_" />
+    <property name="id" column="ID_" unique="true" />
+
+    <property name="packageName" column="PACKAGE_" />
+    <property name="version" column="VERSION_" />
+    <property name="deploymentTime" column="DEPLOYED_" />
+    <many-to-one name="initial" 
+                 column="INITIAL_"
+                 class="ActivityImpl"
+                 cascade="all" 
+                 foreign-key="FK_PROCDEF_INITIAL"
+                 index="IDX_PROCDEF_INIT"
+                 fetch="select" />
+
+    <map name="attachments" cascade="all-delete-orphan">
+      <key foreign-key="FK_LOB_PROCESS">
+        <column name="PROCESS_" index="IDX_LOB_PROCESS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.lob.Lob"/>
+    </map>
+  </class>
+
+  <!-- ### Activity ############################################################## -->
+  <class name="ActivityImpl" table="JBPM_ACTIVITY">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESS_" 
+                 foreign-key="FK_ACT_PROCESS"
+                 index="IDX_ACT_PROCESS" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_ACT_PROPS"
+                 index="IDX_ACT_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_ACT">
+        <column name="ACT_" index="IDX_EXHDLR_ACT"/>
+      </key>
+      <index column="ACT_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_ACT">
+        <column name="ACT_" index="IDX_EVENT_ACT" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl" />
+    </map>
+
+    <!-- CompositeElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <list name="activities" cascade="all" inverse="false">
+      <key column="PARENT_" foreign-key="none" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="ActivityImpl" />
+    </list>
+    <property name="hasVariableDefinitions" column="HAS_VAR_DEF_" />
+    <list name="variableDefinitions" cascade="all">
+      <key foreign-key="FK_VARDEF_ACT">
+        <column name="ACT_" index="IDX_VARDEF_ACT"/>
+      </key>
+      <index column="ACT_IDX_" />
+      <one-to-many class="VariableDefinitionImpl" />
+    </list>
+    <property name="hasTimerDefinitions" column="HAS_TIMER_DEF_" />
+    <set name="timerDefinitions" cascade="all">
+      <key foreign-key="FK_TMRDEF_ACT">
+        <column name="ACT_" index="IDX_TMRDEF_ACT"/>
+      </key>
+      <one-to-many class="TimerDefinitionImpl" />
+    </set>
+
+    <!-- ActivityImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="isLocalScope" column="LOCAL_SCOPE_" />
+    <property name="isExecutionAsync" column="EXEC_ASYNC_" />
+    <property name="isSignalAsync" column="SIGNAL_ASYNC_" />
+    <property name="isPreviousNeeded" column="PREV_NEEDED_" />
+
+    <many-to-one name="parentActivity" 
+                 column="PARENT_"
+                 class="ActivityImpl"
+                 cascade="all"
+                 foreign-key="FK_ACT_PARENT" 
+                 index="IDX_ACT_PARENT" />
+
+    <many-to-one name="defaultTransition"
+                 column="DEFTRANS_" 
+                 class="TransitionImpl"
+                 fetch="select"
+                 foreign-key="FK_ACT_DEFTRANS" 
+                 index="IDX_ACT_DEFTRANS" />
+
+    <list name="incomingTransitions" inverse="false">
+      <key column="DESTINATION_" />
+      <index column="IN_IDX_" />
+      <one-to-many class="TransitionImpl" />
+    </list>
+
+    <list name="outgoingTransitions" inverse="false" cascade="all">
+      <key column="SOURCE_" />
+      <index column="OUT_IDX_" />
+      <one-to-many class="TransitionImpl" />
+    </list>
+
+    <component name="behaviourReference" class="ObjectReference">
+      <many-to-one name="descriptor"
+                   column="BEHAV_DESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_NODE_BEHAV_DESCR"
+                   index="IDX_NODE_BEHAV_DESCR" />
+      <any name="object" id-type="long" cascade="all">
+        <!--  TODO: Specify names for classes -->
+        <!--        <meta-value value="bpel::activity" class="org.jbpm.pvm.bpel.BpelActivity"/> -->
+        <column name="BEHAV_CLASS_" />
+        <column name="BEHAV_ID_" />
+      </any>
+    </component>
+  </class>
+
+  <!-- ### TRANSITION ##################################################### -->
+  <class name="TransitionImpl" table="JBPM_TRANSITION">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESS_" 
+                 foreign-key="FK_TRANS_PROCDEF"
+                 index="IDX_TRANS_PROCDEF" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_TRANS_PROPS"
+                 index="IDX_TRANS_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_TRANS">
+        <column name="TRANSITION_" index="IDX_EXHDLR_TRANS" />
+      </key>
+      <index column="TRANSITION_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- ObservableElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <property name="description" column="DESCR_" />
+    <map name="events" cascade="all-delete-orphan">
+      <key foreign-key="FK_EVENT_TRANS">
+        <column name="TRANSITION_" index="IDX_EVENT_TRANS" />
+      </key>
+      <map-key type="string" column="NAME_" />
+      <one-to-many class="org.jbpm.pvm.internal.model.EventImpl" />
+    </map>
+    
+    <!-- TransitionImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <many-to-one name="source"
+                 column="SRC_" 
+                 class="ActivityImpl" 
+                 fetch="select" 
+                 foreign-key="FK_TRANS_SRC" 
+                 index="IDX_TRANS_SRC" />
+
+    <many-to-one name="destination"
+                 column="DEST_" 
+                 class="ActivityImpl" 
+                 fetch="select"
+                 cascade="all"
+                 foreign-key="FK_TRANS_DST" 
+                 index="IDX_TRANS_DST" />
+
+    <many-to-one name="conditionDescriptor" 
+                 column="COND_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_TRANS_COND"
+                 index="IDX_TRANS_COND" />
+                 
+    <!-- 
+    <many-to-one name="waitConditionDescriptor" 
+                 column="WAIT_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_TRANS_WAIT_DESCR" 
+                 index="IDX_TRANS_WAIT_DESCR" />
+    -->
+    
+    <property name="isTakeAsync" column="TAKEASYNC_" />
+  </class>
+
+  <!-- ### EVENT ########################################################## -->
+  <class name="EventImpl" table="JBPM_EVENT">
+    <!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="processDefinition"
+                 class="ProcessDefinitionImpl" 
+                 column="PROCESSDEF_" 
+                 foreign-key="FK_EVENT_PROCDEF" 
+                 index="IDX_EVENT_PROCDEF" />
+    <many-to-one name="properties"
+                 class="WireProperties" 
+                 column="PROPS_" 
+                 foreign-key="FK_EVENT_PROPS"
+                 index="IDX_EVENT_PROPS"
+                 cascade="all" />
+    <list name="exceptionHandlers" cascade="all">
+      <key foreign-key="FK_EXHDLR_EVENT">
+        <column name="EVENT_" index="IDX_EXHDLR_EVENT"/>
+      </key>
+      <index column="EVENT_IDX_" />
+      <one-to-many class="ExceptionHandlerImpl" />
+    </list>
+
+    <!-- EventImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <property name="name" column="NAME_" />
+    <list name="listenerReferences" table="JBPM_OBJECTREFERENCES" cascade="all-delete-orphan">
+      <key foreign-key="FK_OBJECTREF_EVENT">
+        <column name="EVENT_" index="IDX_OBJREF_EVENT"/>
+      </key>
+      <list-index column="EVENT_IDX_" />
+      <one-to-many class="EventListenerReference" />
+    </list>
+  </class>
+  
+  <!-- ### EXCEPTION HANDLER ############################################## -->
+  <class name="ExceptionHandlerImpl" table="JBPM_EXCEPTHNDLR">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="exceptionClassName" column="EXCEPT_CLASS_" />
+    <property name="isTransactional" column="TRANSACT_" />
+    <property name="isRethrowMasked" column="RETHROW_MASKED_"/>
+    <property name="transitionName" column="TRANSITIONNAME_" />
+    <property name="activityName" column="NODENAME_" />
+    <list name="eventListenerReferences" 
+          inverse="false"
+          cascade="all-delete-orphan"
+          table="JBPM_OBJECTREFERENCES">
+      <key foreign-key="FK_OBJREF_EXHNDLR" not-null="false">
+        <column name="EXHNDLR_" index="IDX_OBJREF_EXHNDLR" />
+      </key>
+      <list-index column="EXHNDLR_IDX_" />
+      <one-to-many class="ObjectReference" />
+    </list>
+  </class>
+  
+  <!-- ### OBJECT REFERENCE ############################################### -->
+  <class name="ObjectReference" discriminator-value="objref" table="JBPM_OBJECTREF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+    <many-to-one name="descriptor"
+                 column="OBJ_DESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_OBJREF_EVENT" 
+                 index="IDX_OBJREF_EVENT"/>
+    <any name="object" id-type="long" cascade="all">
+      <!--  TODO: Specify names for classes -->
+      <column name="OBJ_CLASS_" />
+      <column name="OBJ_ID_" />
+    </any>
+    <property name="expression" column="OBJ_EXPRESSION_"/>
+    <property name="expressionLanguage" column="OBJ_EXPRLANG_"/>
+    
+    <subclass name="EventListenerReference" discriminator-value="evtlis">
+      <property name="isPropagationEnabled" column="PROPAGATE_" />
+    </subclass>
+        
+  </class>
+
+  <!-- ### VARIABLE DEFINITION ############################################ -->
+  <class name="VariableDefinitionImpl" table="JBPM_VARIABLEDEF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="name" column="NAME_"/>
+    <property name="typeName" column="TYPE_"/>
+    
+    <property name="inVariableName" column="INVAR_" />
+    <property name="inExpression" column="INEXPR_" />
+    <many-to-one name="inDescriptor" 
+                 column="INDESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 cascade="all"
+                 foreign-key="FK_VARDEF_INDES" 
+                 index="IDX_VARDEF_INDES"/>
+    <property name="outVariableName" column="OUTVAR_" />
+    <property name="outExpression" column="OUTEXPR_" />
+  </class>
+
+  <!-- ### TIMER DEFINITION ############################################### -->
+  <class name="TimerDefinitionImpl" table="JBPM_TIMERDEF">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="dueDateDescription" column="DUEDATEDESCR_"/>
+    <property name="repeat" column="REPEAT_"/>
+    <property name="isExclusive" column="ISEXCL_"/>
+    <property name="retries" column="RETRIES_"/>
+    <property name="eventName" column="EVENT_"/>
+    <property name="signalName" column="SIGNAL_"/>
+    <property name="dueDate" column="DUEDATE_" type="timestamp"/>
+  </class>
+  
+  <!-- ### DESCRIPTORS #################################################### -->
+  <class name="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" table="JBPM_DESCRIPTOR" abstract="true"
+    discriminator-value="abstract">
+    <!--
+    byte     : ByteDescriptor 
+    string   : StringDescriptor
+    char     : CharacterDescriptor
+    class    : ClassDescriptor
+    double   : DoubleDescriptor
+    expr     : ExpressionDescriptor
+    float    : FloatDescriptor 
+    long     : LongDescriptor
+    int      : IntegerDescriptor
+    short    : ShortDescriptor
+    coll     : CollectionDescriptor 
+    map      : MapDescriptor
+    list     : ListDescriptor
+    set      : SetDescriptor
+    object   : ObjectDescriptor
+    ref      : ReferenceDescriptor
+    null     : NullDescriptor
+    true     : TrueDescriptor
+    false    : FalseDescriptor
+    provided : ProvidedObjectDescriptor
+    -->
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="name" column="NAME_" />
+    <property name="init" column="INIT_" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.NullDescriptor" discriminator-value="null_" />
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor" discriminator-value="true" />
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor" discriminator-value="false" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.StringDescriptor" discriminator-value="string">
+      <property name="text" column="TEXT_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.CharacterDescriptor" discriminator-value="char">
+      <property name="text" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor" discriminator-value="class">
+      <property name="text" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor" discriminator-value="ref">
+      <property name="text" column="TEXT_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.DoubleDescriptor" discriminator-value="double">
+      <property name="doubleVal" column="DOUBLEVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.FloatDescriptor" discriminator-value="float">
+      <property name="doubleVal" column="DOUBLEVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.LongDescriptor" discriminator-value="long">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor" discriminator-value="int">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ShortDescriptor" discriminator-value="short">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ByteDescriptor" discriminator-value="byte">
+      <property name="longVal" column="LONGVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor" discriminator-value="coll">
+      <property name="className" column="CLASSNAME_" />
+      <list name="valueDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_DESCR_VALDESCR">
+          <column name="VALUEDESCR_" index="IDX_DESCR_VALDESCR" />
+        </key>
+        <list-index column="VALUEDESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+      </list>
+
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.MapDescriptor" discriminator-value="map">
+        <list name="keyDescriptors" cascade="all-delete-orphan">
+          <key column="KEYDESCR_" foreign-key="FK_DESCR_KEYDESCR" />
+          <list-index column="KEYDESCR_IDX_" />
+          <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+        </list>
+      </subclass>
+
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor" discriminator-value="list" />
+      <subclass name="org.jbpm.pvm.internal.wire.descriptor.SetDescriptor" discriminator-value="set" />
+    </subclass>
+
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor" discriminator-value="object">
+      <property name="className" column="TEXT_" />
+      <property name="methodName" column="METHOD_" />
+      <property name="isAutoWireEnabled" column="BOOLVAL_" />
+      <property name="factoryObjectName" column="FACTORYNAME_" />
+
+      <many-to-one name="factoryDescriptor" class="AbstractDescriptor" column="FACTORYDESCR_"
+        foreign-key="FK_DESCR_ARG_REF" index="IDX_DESCR_ARG_REF" cascade="all" />
+
+      <list name="argDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_OBJARG_DESCR">
+          <column name="OBJARG_DESCR_" index="IDX_OBJARG_DESCR" />
+        </key>
+        <list-index column="OBJARG_DESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" />
+      </list>
+
+      <list name="operations" cascade="all-delete-orphan">
+        <key foreign-key="FK_OBJOPER_DESCR">
+          <column name="OBJOPER_DESCR_" index="IDX_OBJOPER_DESCR" />
+        </key>
+        <list-index column="OBJOPER_DESCR_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.operation.AbstractOperation" />
+      </list>
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ExpressionDescriptor" discriminator-value="expr">
+      <property name="expr" column="TEXT_" />
+      <property name="lang" column="METHOD_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor" discriminator-value="provided">
+      <any name="providedObject" id-type="long" cascade="all">
+        <column name="TEXT_" />
+        <column name="LONGVAL_" />
+      </any>
+      <property name="exposeType" column="BOOLVAL_" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.descriptor.EnvDescriptor" discriminator-value="env">
+      <property name="objectName" column="TEXT_" />
+      <property name="typeName" column="CLASSNAME_" />
+    </subclass>
+
+  </class>
+
+  <!-- ### OPERATIONS ##################################################### -->
+  <class name="org.jbpm.pvm.internal.wire.operation.AbstractOperation" abstract="true"
+    table="JBPM_OPERATION" discriminator-value="oper">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.FieldOperation"
+      discriminator-value="field">
+      <property name="fieldName" column="TEXT_" />
+      <many-to-one name="descriptor" column="DESCR_" cascade="all" 
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+        foreign-key="FK_OPER_DESC" index="IDX_OPER_DESC" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.PropertyOperation"
+      discriminator-value="prop">
+      <property name="setterName" column="TEXT_" />
+      <many-to-one name="descriptor" column="DESCR_" cascade="all" 
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+    </subclass>
+
+    <subclass name="org.jbpm.pvm.internal.wire.operation.InvokeOperation"
+      discriminator-value="invoke">
+      <property name="methodName" column="TEXT_" />
+      <list name="argDescriptors" cascade="all-delete-orphan">
+        <key foreign-key="FK_ARGDSCR_OPER">
+          <column name="OPER_" index="IDX_ARGDSCR_OPER" />
+        </key>
+        <list-index column="OPER_IDX_" />
+        <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" />
+      </list>
+    </subclass>
+  </class>
+
+  <!-- ### ARG DESCRIPTOR ################################################# -->
+  <class name="org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor" table="JBPM_ARGDESCRIPTOR">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="typeName" column="TYPENAME_" />
+    <many-to-one name="descriptor" column="DESCRIPTOR_" 
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+      foreign-key="FK_ARGDESCR_DESCR" index="IDX_ARGDESCR_DESCR" cascade="all" />
+  </class>
+
+  <!-- ### PROPERTIES ##################################################### -->
+  <class name="org.jbpm.pvm.internal.model.WireProperties" table="JBPM_WIREPROPS">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <component name="wireContext" class="org.jbpm.pvm.internal.wire.WireContext">
+      <component name="wireDefinition" class="org.jbpm.pvm.internal.wire.WireDefinition">
+        <map name="descriptors" cascade="all-delete-orphan" lazy="false">
+          <key foreign-key="FK_DESCR_PROPS">
+            <column name="PROPS_" index="IDX_DESCR_PROPS" />
+          </key>
+          <map-key type="string" column="NAME_" />
+          <one-to-many class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" />
+        </map>
+      </component>
+    </component>
+  </class>
+  
+  
+  <!-- ### QUERIES ######################################################## -->
+  
+  <query name="findProcessDefinitionKeys">
+    <![CDATA[
+     select distinct process.key
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     order by process.key asc
+    ]]>
+  </query>
+
+  <query name="findProcessDefinitionsByKey">
+    <![CDATA[
+     select process
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.key = :key
+     order by process.version desc    
+    ]]>
+  </query>
+
+  <query name="findProcessDefinitionById">
+    <![CDATA[
+     select process
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.id = :id
+    ]]>
+  </query>
+  
+  <query name="findProcessDefinitionKeysByName">
+    <![CDATA[
+     select process.key
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.name = :name
+    ]]>
+  </query>
+  
+  <query name="findProcessDefinitionNamesByKey">
+    <![CDATA[
+     select process.name
+     from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
+     where process.key = :key
+    ]]>
+  </query>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.execution.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.execution.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,379 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.model" default-access="field">
+
+  <!-- ### PROCESS DEFINITION ############################################# -->
+  <class name="ExecutionImpl" table="JBPM_EXECUTION">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <many-to-one name="activity" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="ACT_"
+                 lazy="false"
+                 foreign-key="FK_EXEC_ACT"
+                 index="IDX_EXEC_ACT" />
+
+    <property name="hasVariables" column="HASVARS_" />
+    <map name="variables"
+         cascade="all-delete-orphan"
+         table="JBPM_VARIABLE">
+      <key foreign-key="FK_VAR_EXECUTION">
+         <column name="EXECUTION_" index="IDX_VAR_EXECUTION"/>
+      </key>
+      <map-key type="string" column="KEY_" />
+      <one-to-many class="org.jbpm.pvm.internal.type.Variable" />
+    </map>
+    
+    <property name="hasTimers" column="HASTIMERS_" />
+    <set name="timers"
+         cascade="all-delete-orphan">
+      <key foreign-key="FK_TMR_EXECUTION">
+         <column name="EXECUTION_" />
+      </key>
+      <one-to-many class="org.jbpm.pvm.internal.job.TimerImpl" />
+    </set>
+
+    <property name="name" column="NAME_" />
+    <property name="key" column="KEY_" />
+    <property name="id" column="ID_" unique="true" />
+
+    <property name="state" column="STATE_" />
+
+    <property name="priority" column="PRIORITY_" />
+    <property name="historyActivityInstanceDbid" column="HISACTINST_" />
+
+    <many-to-one name="processDefinition"
+                 class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" 
+                 column="PROCESS_"
+                 foreign-key="FK_EXEC_PROCESS" 
+                 index="IDX_EXEC_PROCESS" />
+
+    <many-to-one name="transition" column="TRANSITION_" class="TransitionImpl" />
+
+    <many-to-one name="transitionOrigin" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="TRANSORIG_"
+                 foreign-key="FK_EXEC_TRANSORIG"
+                 index="IDX_EXEC_TRANSORIG" />
+
+    <list name="executions" 
+          cascade="all-delete-orphan"
+          inverse="false">
+      <key column="PARENT_" foreign-key="FK_EXEC_PARENT" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="ExecutionImpl" />
+    </list>
+
+    <many-to-one name="parent"
+                 column="PARENT_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_PARENT"
+                 index="IDX_EXEC_PARENT" />
+
+    <many-to-one name="processInstance"
+                 class="ExecutionImpl" 
+                 column="INSTANCE_"
+                 foreign-key="FK_EXEC_INSTANCE"
+                 index="IDX_EXEC_INSTANCE" />
+
+    <many-to-one name="superProcessExecution"
+                 column="SUPEREXEC_"
+                 class="ExecutionImpl"
+                 foreign-key="FK_EXEC_SUPEREXEC"
+                 index="IDX_EXEC_SUPEREXEC" />
+  </class>
+
+  <!-- ### COMMENTS ####################################################### -->
+  <class name="CommentImpl" table="JBPM_COMMENT">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="userId" column="USERID_" />
+    <property name="time" column="TIME_" />
+    <property name="message" column="MESSAGE_" />
+
+    <list name="comments" 
+          cascade="all-delete-orphan"
+          inverse="false">
+      <key column="PARENT_" foreign-key="none" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="CommentImpl" />
+    </list>
+  </class>
+  
+  <!-- ### VARIABLE ####################################################### -->
+  
+  <typedef name="converter" class="org.jbpm.pvm.internal.hibernate.ConverterType">
+    <param name="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter"    >bool-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.ByteToLongConverter"         >byte-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter"  >char-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DateToLongConverter"         >date-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DateToStringConverter"       >date-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.DoubleToStringConverter"     >double-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter"      >float-double</param>
+    <param name="org.jbpm.pvm.internal.type.converter.FloatToStringConverter"      >float-str</param>
+    <param name="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter"      >int-long</param>
+    <param name="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter">ser-bytes</param>
+    <param name="org.jbpm.pvm.internal.type.converter.ShortToLongConverter"        >short-long</param>
+  </typedef>
+  
+  
+  <class name="org.jbpm.pvm.internal.type.Variable" abstract="true" discriminator-value=" " table="JBPM_VARIABLE">
+    <!-- discriminator values:
+    date   : org.jbpm.pvm.internal.type.variable.DateVariable
+    double : org.jbpm.pvm.internal.type.variable.DoubleVariable
+    hibl   : org.jbpm.pvm.internal.type.variable.HibernateLongVariable
+    long   : org.jbpm.pvm.internal.type.variable.LongVariable
+    hibs   : org.jbpm.pvm.internal.type.variable.HibernateStringVariable
+    string : org.jbpm.pvm.internal.type.variable.StringVariable
+    null   : org.jbpm.pvm.internal.type.variable.NullVariable
+    blob   : org.jbpm.pvm.internal.type.variable.BlobVariable
+    clob   : org.jbpm.pvm.internal.type.variable.ClobVariable
+    -->
+  
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="key" column="KEY_"/>
+    <property name="queryText" column="QUERYTEXT_" />
+    <property name="converter" type="converter" column="CONVERTER_" />
+    <many-to-one name="processInstance"
+                 column="PROCINST_" 
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"
+                 foreign-key="FK_VAR_PROCINST"
+                 index="IDX_VAR_PROCINST"/>
+  </class>
+
+  <subclass name="org.jbpm.pvm.internal.type.variable.DateVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="T">
+    <property name="date" column="DATE_VALUE_" type="timestamp"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.DoubleVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="D">
+    <property name="d" column="DOUBLE_VALUE_" type="double"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="l">
+    <property name="hibernatable" column="LONG_VALUE_" type="long"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.LongVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="L">
+    <property name="l" column="LONG_VALUE_" type="long"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="s">
+    <property name="hibernatable" column="STRING_VALUE_" type="string"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.StringVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="S">
+    <property name="string" column="STRING_VALUE_" type="string"/>
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.NullVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="N">
+  </subclass>
+  
+  <subclass name="org.jbpm.pvm.internal.type.variable.BlobVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="B">
+    <many-to-one name="lob"
+                 column="LOB_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.lob.Lob"
+                 foreign-key="FK_VAR_LOB"
+                 index="IDX_VAR_LOB" />
+  </subclass>
+
+  <subclass name="org.jbpm.pvm.internal.type.variable.ClobVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="C">
+    <many-to-one name="lob"
+                 column="LOB_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.lob.Lob"
+                 foreign-key="none"/>
+  </subclass>
+  
+  <!-- ### LOB ############################################################ -->
+  <class name="org.jbpm.pvm.internal.lob.Lob" table="JBPM_LOB">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    <property name="blob" type="blob" column="BLOB_VALUE_" />
+    <property name="bytes" type="binary" column="BINARY_VALUE_"/>
+    <property name="clob" type="clob" column="CLOB_VALUE_" />
+    <property name="text" type="text" column="TEXT_VALUE_"/>
+  </class>
+  
+    <class name="org.jbpm.pvm.internal.job.JobImpl" table="JBPM_JOB" discriminator-value="Job">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="dueDate" column="DUEDATE_" type="timestamp" index="IDX_JOBDUEDATE"  />
+    <property name="isSuspended" column="ISSUSPENDED_" />
+    <property name="isExclusive" column="ISEXCLUSIVE_" />
+    <property name="lockOwner" column="LOCKOWNER_" />
+    <property name="lockExpirationTime" column="LOCKEXPTIME_" index="IDX_JOBLOCKEXP" />
+    <property name="info" column="INFO_" />
+    <property name="exception" column="EXCEPTION_" type="text" />
+    <property name="retries" column="RETRIES_" index="IDX_JOBRETRIES" />
+    
+    <many-to-one name="processInstance"   
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"   
+                 column="PROCESSINSTANCE_" 
+                 cascade="none"
+                 foreign-key="FK_JOB_PRINST"
+                 index="IDX_JOB_PRINST"/>
+    <many-to-one name="execution"
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl"   
+                 column="EXECUTION_" 
+                 cascade="none"
+                 foreign-key="FK_JOB_EXE"
+                 index="IDX_JOB_EXE"/>
+    <many-to-one name="commandDescriptor"
+                 column="CMDDESCR_"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor" 
+                 cascade="all"
+                 foreign-key="FK_JOB_CMDDESCR"
+                 index="IDX_JOB_CMDDESCR"/>
+
+    <subclass name="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="Msg">
+      <subclass name="org.jbpm.pvm.internal.model.op.ExecuteActivityMessage" discriminator-value="ExeActivityMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.SignalMessage" discriminator-value="SignalMsg">
+        <property name="signalName" column="SIGNAL_" />
+        <many-to-one name="activity"   
+                     column="NODE_" 
+                     cascade="none"
+                     foreign-key="FK_JOB_NODE"/>
+      </subclass>
+      <subclass name="org.jbpm.pvm.internal.model.op.TakeTransitionMessage" discriminator-value="TakeTrMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.ProceedToDestinationMessage" discriminator-value="ProceedDestMsg" />
+      <subclass name="org.jbpm.pvm.internal.job.CommandMessage" discriminator-value="CmdMsg" />
+    </subclass>
+    
+    <subclass name="org.jbpm.pvm.internal.job.TimerImpl" discriminator-value="Timer">
+      <property name="signalName" column="SIGNAL_" />
+      <property name="eventName" column="EVENT_" />
+      <property name="repeat" column="REPEAT_" />
+    </subclass>
+     
+  </class>
+
+  <!-- ### HibernatePvmDbSession QUERIES ################################## -->
+
+  <query name="findTimers">
+    <![CDATA[
+     select t
+     from org.jbpm.pvm.internal.job.TimerImpl as t
+     order by dueDate asc
+    ]]>
+  </query>
+
+  <query name="findMessages">
+    <![CDATA[
+     select m
+     from org.jbpm.pvm.internal.job.MessageImpl as m
+    ]]>
+  </query>
+
+  <query name="findJobsWithException">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.retries = 0 
+     order by dueDate asc
+    ]]>
+  </query>
+
+  <!-- ### HibernateJobDbSession QUERIES ################################## -->
+
+  <query name="findFirstAcquirableJob">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where ( ( (job.lockExpirationTime is null)
+               or (job.lockExpirationTime <= :now) 
+             )
+             and 
+             ( (job.dueDate is null)
+               or (job.dueDate <= :now) 
+             ) 
+             and 
+             ( job.retries > 0 ) 
+           )
+     order by job.dueDate asc
+    ]]>
+  </query>
+
+  <query name="findExclusiveJobs">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.lockOwner is null
+       and job.processInstance = :processInstance 
+       and job.isExclusive = true 
+       and job.retries > 0 
+       and ( (job.dueDate is null)
+             or (job.dueDate <= :now) 
+           )
+     order by job.dueDate asc
+    ]]>
+  </query>
+  
+  <query name="findFirstDueJob">
+    <![CDATA[
+     select job
+     from org.jbpm.pvm.internal.job.JobImpl as job
+     where job.lockOwner is null
+       and job.retries > 0 
+     order by job.dueDate asc
+    ]]>
+  </query>
+  
+
+  <!-- ### HibernatePvmDbSession QUERIES ############################################# -->
+
+  <query name="findExecutionById">
+    <![CDATA[
+     select execution
+     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
+     where execution.id = :id
+    ]]>
+  </query>
+
+  <query name="findProcessInstanceById">
+    <![CDATA[
+     select processInstance
+     from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+     where processInstance.id = :processInstanceId
+       and processInstance.parent is null
+    ]]>
+  </query>
+
+  <query name="findExecutionByKey">
+    <![CDATA[
+     select execution
+     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
+     where execution.key = :executionKey
+       and execution.processDefinition.name = :processDefinitionName
+    ]]>
+  </query>
+  
+  <query name="findProcessInstanceIds">
+    <![CDATA[
+     select processInstance.id
+     from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+     where processInstance.processDefinition.id = :processDefinitionId
+       and processInstance.parent is null
+    ]]>
+  </query>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.hibernate.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+  <session-factory>
+      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
+      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
+      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:." />
+      <property name="hibernate.connection.username" value="sa" />
+      <property name="hibernate.connection.password" value="" />
+      <property name="hibernate.hbm2ddl.auto" value="create-drop" />
+      <property name="hibernate.format_sql" value="true" />
+      <mapping resource="jbpm.definition.hbm.xml" />
+      <mapping resource="jbpm.execution.hbm.xml" />
+      <mapping resource="jbpm.history.hbm.xml" />
+      <mapping resource="jbpm.task.hbm.xml" />
+  </session-factory>
+</hibernate-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.history.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.history.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.history.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.history.model" default-access="field">
+
+  <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+  <class name="HistoryProcessInstanceImpl" table="JBPM_HIST_PROCINST">
+    <id name="processInstanceId" column="ID_">
+      <generator class="assigned" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="processDefinitionId" column="PROCDEFID_" />
+    <property name="key" column="KEY_" />
+    <property name="startTime" column="START_" type="timestamp" />
+    <property name="endTime" column="END_" type="timestamp" />
+    <property name="duration" column="DURATION_" />
+    <property name="state" column="STATE_" />
+    <property name="endActivityName" column="ENDACTIVITY_" />
+
+    <many-to-one name="processDefinition" 
+                 class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl" 
+                 column="PROCDEF_"
+                 foreign-key="FK_HISTPI_PROCDEF"
+                 index="IDX_HISTPI_PROCDEF" />
+                 
+    <set name="historyActivityInstances"
+         cascade="all">
+      <key>
+         <column name="HPI_" />
+      </key>
+      <one-to-many class="HistoryActivityInstanceImpl" />
+    </set>
+                 
+  </class>
+
+  <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+  <class name="HistoryActivityInstanceImpl" table="JBPM_HIST_ACTINST" discriminator-value="ACT">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <many-to-one name="historyProcessInstance" 
+                 class="HistoryProcessInstanceImpl" 
+                 column="HPI_"
+                 foreign-key="FK_HAI_HPI"
+                 index="IDX_HAI_HPI" />
+
+    <many-to-one name="activity" 
+                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
+                 column="ACTIVITY_"
+                 foreign-key="FK_HISTAI_ACT"
+                 index="IDX_HISTAI_ACT" />
+
+    <property name="executionId" column="EXECUTION_" />
+    <property name="activityName" column="ACTIVITY_NAME_" />
+    <property name="startTime" column="START_" type="timestamp" />
+    <property name="endTime" column="END_" type="timestamp" />
+    <property name="duration" column="DURATION_" />
+    <property name="transitionName" column="TRANSITION_" />
+
+    <subclass name="HistoryAutomaticInstanceImpl" discriminator-value="AUT">
+      <subclass name="HistoryExclusiveInstanceImpl" discriminator-value="EXCL" />
+    </subclass>
+    
+    <subclass name="HistoryTaskInstanceImpl" discriminator-value="TASK">
+      <property name="assignee" column="ASSIGNEE_" />
+    </subclass>
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.identity.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.identity.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.identity.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
+                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
+  <realms>
+    <realm>
+      <id>realm://jbpm-identity</id>
+      <repository-id-ref>jBPM Identity DB</repository-id-ref>
+      <identity-type-mappings>
+        <identity-mapping>IDENTITY</identity-mapping>
+      </identity-type-mappings>
+    </realm>
+  </realms>
+
+  <repositories>
+    <repository>
+      <id>jBPM Identity DB</id>
+      <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+      <external-config/>
+      <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
+      <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
+      <options>
+        <option>
+          <name>allowNotDefinedAttributes</name>
+          <value>true</value>
+        </option>
+      </options>
+    </repository>
+  </repositories>
+
+  <stores>
+    <attribute-stores/>
+    <identity-stores>
+      <identity-store>
+        <id>Hibernate Identity Store</id>
+        <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+        <external-config/>
+        <supported-relationship-types>
+          <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+          <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+        </supported-relationship-types>
+        <supported-identity-object-types>
+          <identity-object-type>
+            <name>IDENTITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>OFFICE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>SECURITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>PROJECT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+                <identity-object-type-ref>PEOPLE</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials>
+              <credential-type>PASSWORD</credential-type>
+            </credentials>
+            <attributes>
+              <attribute>
+                <name>picture</name>
+                <mapping>user.picture</mapping>
+                <type>binary</type>
+                <isRequired>false</isRequired>
+                <isMultivalued>false</isMultivalued>
+                <isReadOnly>false</isReadOnly>
+              </attribute>
+            </attributes>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ORGANIZATION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DIVISION</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ORGANIZATION_UNIT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DIVISION</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>OFFICE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>PEOPLE</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>PROJECT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>DIVISION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>DEPARTMENT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>DEPARTMENT</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION_UNIT</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>PROJECT</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>PEOPLE</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>ADMINISTRATION</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>COMMUNITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>OFFICE</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>SECURITY</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+          <identity-object-type>
+            <name>SYSTEM</name>
+            <relationships>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>IDENTITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>SECURITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>COMMUNITY</identity-object-type-ref>
+              </relationship>
+              <relationship>
+                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+                <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+              </relationship>
+            </relationships>
+            <credentials/>
+            <attributes/>
+            <options/>
+          </identity-object-type>
+        </supported-identity-object-types>
+        <options>
+          <option>
+            <name>persistenceUnit</name>
+            <value>jboss-identity-jbpm</value>
+          </option>
+          <option>
+            <name>populateRelationshipTypes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>populateIdentityObjectTypes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>allowNotDefinedAttributes</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>isRealmAware</name>
+            <value>true</value>
+          </option>
+          <option>
+            <name>allowNotDefinedAttributes</name>
+            <value>true</value>
+          </option>
+        </options>
+      </identity-store>
+    </identity-stores>
+  </stores>
+</jboss-identity>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlProcessDefinition" table="JBPM_JPDL_PROCDEF"  extends="org.jbpm.pvm.internal.model.ProcessDefinitionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <joined-subclass name="org.jbpm.jpdl.internal.model.JpdlExecution" table="JBPM_JPDL_EXECUTION" extends="org.jbpm.pvm.internal.model.ExecutionImpl">
+    <key column="DBID_"/>
+  </joined-subclass>
+
+  <class name="org.jbpm.jpdl.internal.activity.JpdlActivity" table="JBPM_JPDL_ACTIVITY"  abstract="true" discriminator-value="X">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <subclass name="org.jbpm.jpdl.internal.activity.StartActivity" discriminator-value="start" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveConditionActivity" discriminator-value="excl-cond" />
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveExpressionActivity" discriminator-value="excl-expr">
+      <property name="expr" column="TEXT_" />
+      <property name="lang" column="TEXT2_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler">
+      <property name="exclusiveHandlerName" column="TEXT_" />
+      <many-to-one name="exclusiveHandlerDescriptor"
+                   column="EXCLDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_EXCLDESCR"
+                   index="IDX_ACT_EXCLDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.StateActivity" discriminator-value="state" />
+    <subclass name="org.jbpm.jpdl.internal.activity.EndActivity" discriminator-value="end">
+      <property name="endProcessInstance" column="ENDPI_" />
+      <property name="state" column="TEXT_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ForkActivity" discriminator-value="fork" />
+    <subclass name="org.jbpm.jpdl.internal.activity.JoinActivity" discriminator-value="join" />
+    <subclass name="org.jbpm.jpdl.internal.activity.HqlActivity" discriminator-value="hql">
+      <property name="query" column="TEXT_" />
+      <property name="resultVariableName" column="TEXT2_" />
+      <property name="isResultUnique" column="ISUNIQ_" />
+      <many-to-one name="parametersDescriptor"
+                   column="PARAMDESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+                   foreign-key="FK_ACT_PARAMDESCR"
+                   index="IDX_ACT_PARAMDESCR" />
+      
+      <subclass name="org.jbpm.jpdl.internal.activity.SqlActivity" discriminator-value="sql" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.JavaActivity" discriminator-value="java">
+      <property name="methodName" column="TEXT_" />
+      <property name="variableName" column="TEXT2_" />
+      <many-to-one name="descriptor"
+                   column="JAVADESCR_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                   foreign-key="FK_ACT_JAVADESCR"
+                   index="IDX_ACT_JAVADESCR" />
+      <many-to-one name="invokeOperation"
+                   column="INVOPER_" 
+                   cascade="all"
+                   class="org.jbpm.pvm.internal.wire.operation.InvokeOperation"
+                   foreign-key="FK_ACT_INVKOPER"
+                   index="IDX_ACT_INVKOPER" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.ScriptActivity" discriminator-value="script">
+      <property name="script" column="TEXT_" />
+      <property name="language" column="TEXT2_" />
+      <property name="variableName" column="TEXT3_" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.EsbActivity" discriminator-value="esb">
+      <property name="service" column="TEXT_" />
+      <property name="category" column="TEXT2_" />
+      <many-to-one name="partsListDescriptor"
+               column="PARTSDESCR_" 
+               cascade="all"
+               class="org.jbpm.pvm.internal.wire.descriptor.ListDescriptor"
+               foreign-key="FK_ACT_PARTSDESCR"
+               index="IDX_ACT_PARTSDESCR" />
+    </subclass>
+    <subclass name="org.jbpm.jpdl.internal.activity.TaskActivity" discriminator-value="task">
+      <property name="assignee" column="TEXT_" />
+    </subclass>
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,174 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping auto-import="false" package="org.jbpm.pvm.internal.task" default-access="field">
+
+  <!-- ### TASK DEFINITION ################################################ -->
+  <class name="TaskDefinitionImpl" discriminator-value="T">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator type="char" column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+
+    <property name="priority" column="PRIORITY_"/>
+    <property name="dueDateDuration" column="DUEDATE_"/>
+    <property name="isBlocking" column="BLOCK_"/>
+    <property name="isSignalling" column="SIGNAL_"/>
+    <property name="assigneeExpression" column="ASSIGNEE_EXPR_"/>
+    <property name="candidatesExpression" column="CANDIDATES_EXPR_"/>
+
+    <many-to-one name="assignerDescriptor"
+                 column="ASSIGNER_DESCR_" 
+                 cascade="all"
+                 class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+                 foreign-key="FK_TSK_ASIG_DESCR"
+                 index="IDX_TSK_ASIG_DESCR" />
+
+    <many-to-one name="swimlaneDefinition"
+                 column="SWIMLANE_DEF_" 
+                 cascade="all"
+                 class="SwimlaneDefinitionImpl"
+                 foreign-key="FK_TSK_SWIML_DEF"
+                 index="IDX_TSK_SWIML_DEF" />
+
+		<list name="subTaskDefinitions" cascade="all-delete-orphan">
+			<key column="TASKDEF_" />
+			<list-index column="TASKDEF_IDX_" />
+			<one-to-many class="TaskDefinitionImpl" />
+		</list>
+  </class>
+  
+  <!-- ### TASK ########################################################### -->
+  <class name="TaskImpl" 
+         discriminator-value="T">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator type="char" column="CLASS_"/>
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="id" column="ID_" unique="true" />
+    <property name="name" column="NAME_"/>
+    <property name="description" column="DESCR_"/>
+    <property name="assignee" column="ASSIGNEE_"/>
+    
+    <set name="participants" cascade="all-delete-orphan">
+      <key column="TASK_" />
+      <one-to-many class="ParticipantImpl" />
+    </set>
+    
+    <property name="priority" column="PRIORITY_"/>
+    <property name="create" column="CREATE_"/>
+    <property name="dueDate" column="DUEDATE_"/>
+    <property name="progress" column="PROGRESS_"/>
+    
+    <!-- 
+    <many-to-one name="variableMap"
+                 class="org.jbpm.pvm.impl.VariableMap" 
+                 column="VARMAP_" 
+                 foreign-key="FK_TASK_VARMAP"
+                 cascade="all" />
+    -->
+
+    <many-to-one name="superTask"
+                 class="TaskImpl" 
+                 column="SUPERTASK_" 
+                 foreign-key="FK_TASK_SUPERTASK" 
+                 index="IDX_TASK_SUPERTASK" />
+
+    <many-to-one name="execution"
+                 class="org.jbpm.pvm.internal.model.ExecutionImpl" 
+                 column="EXECUTION_" 
+                 foreign-key="FK_TASK_EXEC" />
+
+    <many-to-one name="swimlane"
+                 class="SwimlaneImpl" 
+                 column="SWIMLANE_" 
+                 foreign-key="FK_TASK_SWIML" />
+
+		<list name="comments" cascade="all-delete-orphan">
+			<key column="TASK_" />
+			<list-index column="TASK_IDX_" />
+			<one-to-many class="org.jbpm.pvm.internal.model.CommentImpl" />
+		</list>
+
+    <set name="subTasks" cascade="all-delete-orphan">
+      <key column="SUPERTASK_" />
+      <one-to-many class="TaskImpl" />
+    </set>
+    
+  </class>
+  
+  <!-- ### PARTICIPANT #################################################### -->
+  <class name="ParticipantImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="identityType" column="IDENTITYTYPE_"/>
+    <property name="identityId" column="IDENTITYID_"/>
+    <property name="participation" column="PARTICIPATION_" />
+
+    <many-to-one name="task"
+                 class="TaskImpl" 
+                 column="TASK_" 
+                 index="IDX_PART_TASK"
+                 foreign-key="FK_PART_TASK" />
+
+    <many-to-one name="swimlane"
+                 class="SwimlaneImpl" 
+                 column="SWIMLANE_" 
+                 foreign-key="FK_PART_SWIMLANE" />
+
+  </class>
+  
+  <!-- ### SWIMLANE DEFINITION ############################################ -->
+  <class name="SwimlaneDefinitionImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="name" column="NAME_"/>
+  </class>
+
+
+  <!-- ### SWIMLANE ####################################################### -->
+  <class name="SwimlaneImpl">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
+    
+    <property name="name" column="NAME_"/>
+    <property name="assignee" column="ASSIGNEE_"/>
+
+    <many-to-one name="swimlaneDefinition"
+                 class="SwimlaneDefinitionImpl" 
+                 column="SWIMLANEDEF_" 
+                 foreign-key="FK_SWIMLANE_DEF" />
+
+    <set name="participants" cascade="all-delete-orphan">
+      <key column="SWIMLANE_" />
+      <one-to-many class="ParticipantImpl" />
+    </set>
+    
+  </class>
+  
+  
+  <!-- ### QUERIES ######################################################## -->
+
+  <query name="findTasks">
+    <![CDATA[
+     select task
+     from org.jbpm.pvm.internal.task.TaskImpl as task
+    ]]>
+  </query>
+
+</hibernate-mapping>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.lifecycle.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.lifecycle.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.lifecycle.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,13 @@
+<task-lifecycle initial="open">
+  <state name="open">
+    <transition name="complete" to="completed" />
+    <transition name="suspend" to="suspended" />
+    <transition name="cancel" to="cancelled" />
+  </state>
+  <state name="suspended">
+    <transition name="resume" to="open" />
+    <transition name="cancel" to="cancelled" />
+  </state>
+  <state name="cancelled" />
+  <state name="completed" />
+</task-lifecycle>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.variable.types.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.variable.types.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.variable.types.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,34 @@
+<types>
+
+  <!-- types stored in a native column -->
+  <type name="string" class="java.lang.String" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="long"   class="java.lang.Long" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="double" class="java.lang.Double" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+  <!-- types converted to a string -->
+  <type name="date"    class="java.util.Date" converter="org.jbpm.pvm.internal.type.converter.DateToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="boolean" class="java.lang.Boolean" converter="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+  <type name="char"    class="java.lang.Character" converter="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter" variable-class="org.jbpm.pvm.internal.type.variable.StringVariable" />
+
+  <!-- types converted to a long -->
+  <type name="byte"    class="java.lang.Byte" converter="org.jbpm.pvm.internal.type.converter.ByteToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="short"   class="java.lang.Short" converter="org.jbpm.pvm.internal.type.converter.ShortToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+  <type name="integer" class="java.lang.Integer" converter="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter" variable-class="org.jbpm.pvm.internal.type.variable.LongVariable" />
+
+  <!-- types converted to a double -->
+  <type name="float" class="java.lang.Float" converter="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter" variable-class="org.jbpm.pvm.internal.type.variable.DoubleVariable" />
+
+  <!-- byte[] and char[] -->
+  <type name="byte[]" class="[B" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+  <type name="char[]" class="[C" variable-class="org.jbpm.pvm.internal.type.variable.ClobVariable" />
+
+  <type name="hibernate-long-id"   class="hibernate" id-type="long" variable-class="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" />
+  <type name="hibernate-string-id" class="hibernate" id-type="string" variable-class="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" />
+
+  <type name="serializable" class="serializable" converter="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter" variable-class="org.jbpm.pvm.internal.type.variable.BlobVariable" />
+
+  <!-- TODO: add ejb3 entity bean support -->
+  <!-- TODO: add JCR activity support -->
+  <!-- TODO: add collection support -->
+  
+</types>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.wire.bindings.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+<wire-bindings>
+
+  <!-- ########################### -->
+  <!-- ### Descriptor bindings ### -->
+  <!-- ########################### -->
+  <!-- basic types -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.TrueBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FalseBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CharBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.DoubleBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FloatBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IntBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ShortBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ByteBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.LongBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.StringBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.NullBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ClassBinding" />
+  <!-- object and ref --> 
+  <binding class="org.jbpm.pvm.internal.wire.binding.ObjectBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.RefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JndiBinding" />
+  <!-- collections -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.ListBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SetBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.MapBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.PropertiesBinding" />
+  <!-- environment refs -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentFactoryRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ContextRefBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TransactionRefBinding" />
+  <!-- various specials -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.TransactionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobExecutorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobTestHelperBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ScriptManagerBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
+  <!-- hibernate bindings -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HibernateSessionFactoryBinding" />
+  <!-- sessions -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.MessageSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TimerSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionFactoryBinding" />
+  <!-- db sessions -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.PvmDbSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.JobDbSessionBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TaskDbSessionBinding" />
+  
+  <!-- dynamic type mapping configuration  -->    
+  <binding class="org.jbpm.pvm.internal.wire.binding.TypesBinding" />
+  <!-- services  -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.StandardCommandServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AsyncCommandServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ProcessServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ExecutionServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.ManagementServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdentityServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.HistoryServiceBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.TaskServiceBinding" />
+  
+  <!-- deployers -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.DeployerManagerBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AssignFileTypesBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CheckProcessBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.CheckProblemsBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SaveBinding" />
+
+  <!-- interceptors -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.AuthorizationInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.RetryInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.StandardTransactionInterceptorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.EnlistBinding" />
+
+  <!-- operation -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.PropertyBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.FieldBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.InvokeBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.SubscribeBinding" />
+
+
+</wire-bindings>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.level=FINE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/Dummy.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/Dummy.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/Dummy.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Dummy {
+
+}

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/continuation/ContinuationTest.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/continuation/ContinuationTest.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/continuation/ContinuationTest.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,43 @@
+<jbpm-configuration>
+
+	<process-engine-context>
+
+    <object class="org.jbpm.pvm.internal.hibernate.PvmNamingStrategy" auto-wire="true" />
+
+    <object class="org.jbpm.pvm.api.db.continuation.Recorder" />
+
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+
+    <hibernate-session-factory />
+
+    <job-executor auto-start="true" />
+    
+    <command-service>
+      <environment-interceptor />
+      <transaction-interceptor />
+    </command-service>
+
+  </process-engine-context>
+
+  <transaction-context>
+
+    <transaction />
+    <hibernate-session />
+    <message-session />
+
+    <pvm-db-session />
+    <job-db-session />
+
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+    
+    <process-service />
+    <execution-service />
+    <management-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <transaction-interceptor />
+    </command-service>
+  
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    <hibernate-session-factory />
+    <types resource="jbpm.pvm.types.xml" />
+  </process-engine-context>
+
+  <transaction-context>
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+
+    <job-test-helper />
+    
+    <process-service />
+    <execution-service />
+    <management-service />
+    
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <transaction-interceptor />
+    </command-service>
+
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+  
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    <hibernate-session-factory />
+
+    <types resource="jbpm.pvm.types.xml" />
+    
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+    
+  </process-engine-context>
+
+  <transaction-context>
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+    <message-session target="test" />
+    <timer-session target="test" />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping default-access="field" auto-import="false">
+  <class name="org.jbpm.pvm.enterprise.custom.Phrase" table="TEST_PHRASE">
+    <id name="id" column="ID_">
+      <generator class="native" />
+    </id>
+    <property name="text" column="TEXT_" />
+  </class>
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<jbpm-configuration>
+
+  <process-engine-context>
+    <types resource="jbpm.pvm.types.xml" />
+  </process-engine-context>
+
+  <transaction-context>
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/Loan.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/Loan.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/Loan.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC 
+          "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
+          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.executionmode.embedded" default-access="field">
+
+  <typedef name="execution" class="org.jbpm.pvm.internal.hibernate.ExecutionType" />
+
+  <class name="Loan" table="LOAN">
+
+    <id name="dbid">
+      <generator class="sequence"/>
+    </id>
+
+    <property name="execution" type="execution" />
+    <property name="customer" />
+    <property name="amount" />
+    
+  </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+  <session-factory>
+
+    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+    <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+    <property name="hibernate.connection.username">sa</property>
+    <property name="hibernate.connection.password"></property>
+    <property name="hibernate.hbm2ddl.auto">create</property>
+    <property name="hibernate.show_sql">true"</property>
+    <property name="hibernate.format_sql">true"</property>
+    <property name="hibernate.use_sql_comments">true"</property>
+    
+    <mapping resource="org/jbpm/pvm/executionmode/embedded/Loan.hbm.xml"/>
+    
+  </session-factory>
+</hibernate-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/model/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/model/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/model/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+<jbpm-configuration>
+
+	<process-engine-context>
+	
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    <types resource="jbpm.pvm.types.xml" />
+
+  </process-engine-context>
+
+  <transaction-context>
+
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,49 @@
+<jbpm-configuration>
+
+	<process-engine-context>
+	
+	  <job-executor threads="1" auto-start="false" />
+	  
+	  <command-service>
+      <environment-interceptor />
+      <transaction-interceptor />
+    </command-service>
+	
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <mapping resource="org/jbpm/pvm/internal/jobexecutor/mappings.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+
+    <types resource="jbpm.pvm.types.xml" />
+
+    <!-- used in JobExecutorTest -->
+    <list name="processedMessageIds" synchronized="true" />
+    <map name="exclusiveThreadIds" synchronized="true" />
+    <list name="failOnceMessageIds" synchronized="true" />
+
+    <!-- used in JobExecutorTimerSessionTest -->
+    <map name="timerVariables" synchronized="true" />
+  </process-engine-context>
+
+  <transaction-context>
+  
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+    <job-db-session />
+
+    <message-session />
+    <timer-session />
+
+  </transaction-context> 
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/mappings.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/mappings.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/jobexecutor/mappings.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC
+      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.jobexecutor" default-access="field">
+
+	<subclass name="TestMessage" extends="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="T">
+		<property name="messageId" />
+	</subclass>
+  
+	<subclass name="FailingTestMessage" extends="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="F">
+	</subclass>
+  
+	<subclass name="ExclusiveTestMessage" extends="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="E">
+	</subclass>
+  
+	<subclass name="FailOnceTestMessage" extends="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="O">
+		<property name="messageId" />
+	</subclass>
+  
+  <subclass name="TestTimer" extends="org.jbpm.pvm.internal.job.TimerImpl" discriminator-value="TestTimer">
+    <property name="name" />
+    <property name="nbMaxExecution" />
+    <property name="nbExecution" />
+    <property name="variableName" />
+  </subclass>
+
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/type/environment.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/type/environment.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/type/environment.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<jbpm-configuration>
+
+  <process-engine-context>
+    <types resource="jbpm.pvm.types.xml" />
+  </process-engine-context>
+
+  <transaction-context>
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/file.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/file.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/file.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=flute
+2=fagot
+3=fecundity

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/resource.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/resource.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/resource.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=rubber
+2=rack
+3=ramblas

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/url.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/url.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/wire/url.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=umbrella
+2=ultraviolet
+3=ubiquitous

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/dombuildertest.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/dombuildertest.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/dombuildertest.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<!-- 1 --><car-park>
+<!-- 2 --> <car id="a" />
+<!-- 3 --> <car id="b" />
+<!-- 4 -->
+<!-- 5 -->
+<!-- 6 --> <car id="c" />
+<!-- 7 --> <car id="d" />
+<!-- 8 --> <car id="e" />
+<!-- 9 --> <car id="f" />
+<!--10 --></car-park>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/schematest.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/schematest.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/internal/xml/schematest.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<object xmlns="http://jbpm.org/xsd/cfg">
+
+  <constructor>
+    <arg/>
+    <arg/>
+    <arg/>
+  </constructor>
+
+</object>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/spring/spring.beans.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/spring/spring.beans.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/spring/spring.beans.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+       
+  <!-- SINGLETONS
+    SpringEnvironmentFactory will only see the singleton beans.  
+  -->       
+
+  <bean id="processService" 
+        class="org.jbpm.pvm.internal.svc.ProcessServiceImpl"
+        scope="singleton">
+    <property name="commandService" ref="commandService" />
+  </bean>
+       
+  <bean id="commandService" 
+        class="org.jbpm.pvm.internal.spring.SpringCommandService"
+        scope="singleton">
+    <property name="transactionManager" ref="transactionManager" />
+    <property name="environmentFactory" ref="environmentFactory"/>
+  </bean>
+  
+  <bean id="transactionManager" 
+        class="org.springframework.orm.hibernate3.HibernateTransactionManager"
+        scope="singleton">
+    <property name="sessionFactory" ref="sessionFactory"/>
+  </bean>
+
+  <bean id="environmentFactory" 
+        class="org.jbpm.pvm.internal.cfg.SpringConfiguration"
+        scope="singleton" />
+
+  <bean id="sessionFactory" 
+        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
+        scope="singleton">
+    <property name="mappingResources">
+      <list>
+        <value>jbpm.pvm.typedefs.hbm.xml</value>
+        <value>jbpm.pvm.wire.hbm.xml</value>
+        <value>jbpm.pvm.definition.hbm.xml</value>
+        <value>jbpm.pvm.execution.hbm.xml</value>
+        <value>jbpm.pvm.variable.hbm.xml</value>
+        <value>jbpm.pvm.job.hbm.xml</value>
+      </list>
+    </property>
+    <property name="hibernateProperties"><value>
+      hibernate.dialect =                      org.hibernate.dialect.HSQLDialect
+      hibernate.connection.driver_class =      org.hsqldb.jdbcDriver
+      hibernate.connection.url =               jdbc:hsqldb:mem:.
+      hibernate.connection.username =          sa
+      hibernate.connection.password =
+      hibernate.hbm2ddl.auto =                 create-drop
+      hibernate.cache.use_second_level_cache = true
+      hibernate.cache.provider_class =         org.hibernate.cache.HashtableCacheProvider
+    </value></property>
+  </bean>
+  
+  <bean id="hibernateSessionManager" 
+        class="org.jbpm.pvm.internal.spring.HibernateSessionManager" 
+        scope="singleton">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+  
+  <!-- PROTOTYPES
+    The PVM environment scope will only see prototype beans.
+    Each environment will cache the prototype beans that are fetched 
+    through it.
+  -->       
+
+  <bean id="session" 
+        factory-bean="hibernateSessionManager" 
+        factory-method="getSession" 
+        scope="prototype" />
+
+</beans>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+<jbpm-configuration>
+
+  <process-engine-context>
+  
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+      <mapping resource="jbpm.pvm.wire.hbm.xml" />
+      <mapping resource="jbpm.pvm.definition.hbm.xml" />
+      <mapping resource="jbpm.pvm.execution.hbm.xml" />
+      <mapping resource="jbpm.pvm.variable.hbm.xml" />
+      <mapping resource="jbpm.pvm.job.hbm.xml" />
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    <types>
+      <type name="date" class="java.util.Date" variable-class="org.jbpm.pvm.internal.type.variable.DateVariable" />
+    </types>
+  </process-engine-context>
+
+  <transaction-context>
+
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/file.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/file.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/file.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=flute
+2=fagot
+3=fecundity

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/resource.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/resource.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/resource.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=rubber
+2=rack
+3=ramblas

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/url.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/url.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/wire/url.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,3 @@
+1=umbrella
+2=ultraviolet
+3=ubiquitous

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/dombuildertest.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/dombuildertest.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/dombuildertest.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,10 @@
+<!-- 1 --><car-park>
+<!-- 2 --> <car id="a" />
+<!-- 3 --> <car id="b" />
+<!-- 4 -->
+<!-- 5 -->
+<!-- 6 --> <car id="c" />
+<!-- 7 --> <car id="d" />
+<!-- 8 --> <car id="e" />
+<!-- 9 --> <car id="f" />
+<!--10 --></car-park>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/schematest.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/schematest.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/org/jbpm/xml/schematest.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<object xmlns="http://jbpm.org/xsd/cfg">
+
+  <constructor>
+    <arg/>
+    <arg/>
+    <arg/>
+  </constructor>
+
+</object>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-base/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/test-base/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test-base</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/test-base/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 2734 2008-11-01 09:59:11Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Test Base</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-test-base</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-log</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate</artifactId>
+    </dependency>
+  </dependencies>
+  
+  <!-- Plugins -->
+  <build>
+    <plugins>
+    </plugins>
+  </build>
+  
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Jdk14LogFactory;
+import org.jbpm.internal.log.Log;
+import org.jbpm.internal.log.LogFormatter;
+
+/** base class for jbpm test cases.
+ * 
+ * When this class is loaded (defined), then a search for a logging.properties 
+ * file will be done.
+ * 
+ * If a logging.properties file is present in the root of the classpath, 
+ * it will be used to initialize the java.util.logging logging framework.
+ * 
+ * If this logging.properties contains property 'redirect.commons.logging'
+ * then all commons logging will be redirected to java.util.logging during 
+ * this logging initialization.
+ * 
+ * Apart from logging initialization, this class will add some logging 
+ * to setUp and tearDown.
+ * 
+ * If the JbpmLogFormatter is used, it will display multiple threads with 
+ * indentation.  
+ * 
+ * @author Tom Baeyens
+ */
+public abstract class BaseJbpmTestCase extends TestCase {
+
+  static {
+    Jdk14LogFactory.initializeJdk14Logging(); 
+  }
+
+  static protected Log log = Log.getLog(BaseJbpmTestCase.class.getName());
+
+  protected void setUp() throws Exception {
+    assertNull(Environment.getCurrent());
+    LogFormatter.resetIndentation();
+    log.debug("=== starting "+getName()+" =============================");
+  }
+
+  protected void tearDown() throws Exception {
+    log.debug("=== ending "+getName()+" =============================\n");
+    assertNull(Environment.getCurrent());
+  }
+
+  public void assertTextPresent(String expected, String value) {
+    if ( (value==null)
+         || (value.indexOf(expected)==-1)
+       ) {
+      fail("expected presence of '"+expected+"' but was '"+value+"'");
+    }
+  }
+  
+  protected void runTest() throws Throwable {
+    try {
+      super.runTest();
+    } catch (AssertionFailedError e) {
+      log.error("");
+      log.error("ASSERTION FAILURE: "+e.getMessage(), e);
+      log.error("");
+      throw e;
+    } catch (Throwable t) {
+      log.error("");
+      log.error("TEST THROWS EXCEPTION: "+t.getMessage(), t);
+      log.error("");
+      throw t;
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/Db.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/Db.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/Db.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.Hibernate;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.Table;
+import org.jbpm.ProcessEngine;
+import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Db {
+  
+  private static final Log log = Log.getLog(Db.class.getName());
+
+  private static final String TABLE_NAMES_KEY = "tableNames";
+  private static final String CLEAN_SQL_KEY = "cleanSql";
+
+  public static void clean(ProcessEngine processEngine) {
+    clean((EnvironmentFactory) processEngine);
+  }
+
+  public static void verifyClean(ProcessEngine processEngine) {
+    verifyClean((EnvironmentFactory) processEngine);
+  }
+
+  public static void clean(EnvironmentFactory environmentFactory) {
+    SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
+    String[] cleanSql = (String[]) environmentFactory.get(CLEAN_SQL_KEY);
+
+    if (cleanSql == null) {
+      Configuration configuration = environmentFactory.get(Configuration.class);
+      
+      SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
+      Dialect dialect = sessionFactoryImplementor.getDialect();
+
+      // loop over all foreign key constraints
+      List<String> dropForeignKeysSql = new ArrayList<String>();
+      List<String> createForeignKeysSql = new ArrayList<String>();
+      Iterator<Table> iter = configuration.getTableMappings();
+      while (iter.hasNext()) {
+        Table table = (Table) iter.next();
+        if (table.isPhysicalTable()) {
+          String catalog = table.getCatalog();
+          String schema = table.getSchema();
+          Iterator<ForeignKey> subIter = table.getForeignKeyIterator();
+          while (subIter.hasNext()) {
+            ForeignKey fk = (ForeignKey) subIter.next();
+            if (fk.isPhysicalConstraint()) {
+              // collect the drop foreign key constraint sql
+              dropForeignKeysSql.add(fk.sqlDropString(dialect, catalog, schema));
+              // MySQLDialect creates an index for each foreign key.
+              // see
+              // http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
+              // This index should be dropped or an error will be thrown during
+              // the creation phase
+              if (dialect instanceof MySQLDialect) {
+                dropForeignKeysSql.add("alter table " + table.getName() + " drop key " + fk.getName());
+              }
+              // and collect the create foreign key constraint sql
+              createForeignKeysSql.add(fk.sqlCreateString(dialect, sessionFactoryImplementor, catalog, schema));
+            }
+          }
+        }
+      }
+
+      List<String> deleteSql = new ArrayList<String>();
+      iter = configuration.getTableMappings();
+      while (iter.hasNext()) {
+        Table table = (Table) iter.next();
+        if (table.isPhysicalTable()) {
+          deleteSql.add("delete from " + table.getName());
+        }
+      }
+
+      // glue
+      // - drop foreign key constraints
+      // - delete contents of all tables
+      // - create foreign key constraints
+      // together to form the clean script
+      List<String> cleanSqlList = new ArrayList<String>();
+      cleanSqlList.addAll(dropForeignKeysSql);
+      cleanSqlList.addAll(deleteSql);
+      cleanSqlList.addAll(createForeignKeysSql);
+
+      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
+      
+      environmentFactory.set(CLEAN_SQL_KEY, cleanSql);
+    }
+
+    Session session = sessionFactory.openSession();
+    try {
+      for (String query : cleanSql) {
+        // log.trace(query);
+        session.createSQLQuery(query).executeUpdate();
+      }
+    } finally {
+      session.close();
+    }
+  }
+
+  public static void verifyClean(EnvironmentFactory environmentFactory) {
+    SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
+    String[] tableNames = (String[]) environmentFactory.get(TABLE_NAMES_KEY);
+
+    if (tableNames == null) {
+      Configuration configuration = environmentFactory.get(Configuration.class);
+      
+      SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
+      Dialect dialect = sessionFactoryImplementor.getDialect();
+
+      // loop over all foreign key constraints
+      List<String> tableNamesList = new ArrayList<String>();
+      Iterator iter = configuration.getTableMappings();
+      while (iter.hasNext()) {
+        Table table = (Table) iter.next();
+        if (table.isPhysicalTable()) {
+          tableNamesList.add(table.getName());
+        }
+      }
+
+      tableNames = (String[]) tableNamesList.toArray(new String[tableNamesList.size()]);
+      
+      environmentFactory.set(TABLE_NAMES_KEY, tableNames);
+    }
+
+    boolean recordsLeft = false;
+    Session session = sessionFactory.openSession();
+    try {
+      for (String tableName : tableNames) {
+        String countSql = "select count(*) recordCount from "+tableName;
+        SQLQuery sqlQuery = session.createSQLQuery(countSql);
+        sqlQuery.addScalar("recordCount", Hibernate.INTEGER);
+        Integer recordCount = (Integer) sqlQuery.uniqueResult();
+        if (recordCount>0) {
+          recordsLeft = true;
+          log.error("FIXME: JBPM-2004 "+recordCount+" records left in table "+tableName);
+        }
+      }
+    } finally {
+      session.close();
+    }
+    
+    if (recordsLeft) {
+      clean(environmentFactory);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.jbpm.Configuration;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionService;
+import org.jbpm.HistoryService;
+import org.jbpm.ManagementService;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessEngine;
+import org.jbpm.ProcessService;
+import org.jbpm.TaskService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.job.Job;
+import org.jbpm.task.Task;
+
+/** base class for persistent jBPM tests.
+ * 
+ * This class exposes a lot of extra convenience methods for testing 
+ * process executions.
+ * 
+ * The ProcessEngine services will be initialized and available as 
+ * member fields.
+ * 
+ * This test assumes that each test will clean the DB itself and that 
+ * no data is in the DB tables when the test finishes.  
+ *  
+ * During tearDown, a check will be done if all the DB tables are 
+ * empty.  If not, that is logged with a F I X M E and the DB tables 
+ * are cleaned. 
+ * 
+ * Convenience methods {@link #deployJpdlXmlString(String)} and 
+ * {@link #deployJpdlResource(String)} will automatically keep track
+ * of the deployed process and delete it (and all the related executions)
+ * before the check is done.
+ * 
+ * Similarly, the {@link #saveAndRegisterTask(Task)} will delete 
+ * the task before the check is done in the tearDown.
+ * 
+ * @author Tom Baeyens
+ */
+public abstract class JbpmTestCase extends BaseJbpmTestCase {
+  
+  protected static ProcessEngine processEngine = null;
+  
+  protected static ProcessService processService;
+  protected static ExecutionService executionService;
+  protected static ManagementService managementService;
+  protected static TaskService taskService;
+  protected static HistoryService historyService;
+
+  protected static CommandService commandService;
+
+  /** registered process definitions will be deleted automatically in the tearDown.
+   * This is a convenience function as each test is expected to clean up the DB. */
+  protected List<ProcessDefinition> registeredProcessDefinitions;
+  /** registered tasks will be deleted automatically in the tearDown.
+   * This is a convenience function as each test is expected to clean up the DB. */
+  protected List<Long> registeredTaskIds;
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    initialize();
+  }
+
+  protected synchronized void initialize() {
+    if (processEngine==null) {
+
+      String jbpmTestCfgType = System.getProperty("jbpm.test.cfg.type");
+      Configuration configuration = new Configuration(jbpmTestCfgType);
+
+      String jbpmTestCfgResource = System.getProperty("jbpm.test.cfg.resource");
+      if (jbpmTestCfgResource!=null) {
+        configuration.setResource(jbpmTestCfgResource);
+      }
+
+      processEngine = configuration.buildProcessEngine();
+
+      processService = processEngine.getProcessService();
+      executionService = processEngine.getExecutionService();
+      historyService = processEngine.getHistoryService();
+      managementService = processEngine.getManagementService();
+      taskService = processEngine.getTaskService();
+      commandService = processEngine.get(CommandService.class);
+    }
+  }
+
+  protected void tearDown() throws Exception {
+    if (registeredProcessDefinitions!=null) {
+      for (ProcessDefinition processDefinition : registeredProcessDefinitions) {
+        processService.deleteProcessDefinitionCascade(processDefinition.getId());
+      }
+    }
+
+    if (registeredTaskIds != null) {
+      for (Long taskDbid : registeredTaskIds) {
+        taskService.deleteTask(taskDbid);
+      }
+    }
+
+    Db.verifyClean(processEngine);
+    
+    super.tearDown();
+  }
+
+  public ProcessDefinition deployJpdlXmlString(String jpdlXmlString) {
+    List<ProcessDefinition> deployedProcessDefinitions = 
+      processService.createDeployment()
+        .addString("xmlstring.jpdl.xml", jpdlXmlString)
+        .deploy()
+        .getProcessDefinitions();
+    
+    return registerDeployedProcessDefinitions(deployedProcessDefinitions);
+  }
+
+  public ProcessDefinition deployJpdlResource(String resource) {
+    List<ProcessDefinition> deployedProcessDefinitions = 
+      processService.createDeployment()
+        .addResource(resource)
+        .deploy()
+        .getProcessDefinitions();
+    
+    return registerDeployedProcessDefinitions(deployedProcessDefinitions);
+  }
+
+  protected ProcessDefinition addDeployedProcessDefinition(ProcessDefinition deployedProcessDefinition) {
+    if (registeredProcessDefinitions==null) {
+      registeredProcessDefinitions = new ArrayList<ProcessDefinition>();
+    }
+    
+    registeredProcessDefinitions.add(deployedProcessDefinition);
+    
+    return deployedProcessDefinition;
+  }
+
+  protected ProcessDefinition registerDeployedProcessDefinitions(List<ProcessDefinition> deployedProcessDefinitions) {
+    if (registeredProcessDefinitions==null) {
+      registeredProcessDefinitions = new ArrayList<ProcessDefinition>();
+    }
+    
+    registeredProcessDefinitions.addAll(deployedProcessDefinitions);
+    
+    if (deployedProcessDefinitions.size()>=1) {
+      return deployedProcessDefinitions.get(0);
+    } 
+    
+    return null;
+  }
+
+  public void saveAndRegisterTask(Task task) {
+    taskService.saveTask(task);
+    
+    if (registeredTaskIds == null) {
+      registeredTaskIds = new ArrayList<Long>();
+    }
+    registeredTaskIds.add(task.getDbid());
+  }
+
+  public HashSet<String> getActivityNames(String processInstanceId) {
+    HashSet<String> activityNames = new HashSet<String>();
+    
+    List<Execution> executions = executionService.findExecutions(processInstanceId);
+    for (Execution execution: executions) {
+      String activityName = execution.getActivityName();
+      if (activityName!=null) {
+        activityNames.add(activityName);
+      }
+    }
+    
+    return activityNames;
+  }
+
+  public Execution findExecution(String processInstanceId, String activityName) {
+    List<Execution> executions = executionService.findExecutions(processInstanceId);
+    for (Execution execution: executions) {
+      if (activityName.equals(execution.getActivityName())) {
+        return execution;
+      }
+    }
+    
+    return null;
+  }
+
+  public static Task getTask(List<Task> taskList, String taskName) {
+    for (Task task : taskList) {
+      if (taskName.equals(task.getName())) {
+        return task;
+      }
+    }
+    return null;
+  }
+  
+  public static void assertContainsTask(List<Task> taskList, String taskName) {
+    if (getTask(taskList, taskName)==null) {
+      fail("tasklist doesn't contain task '"+taskName+"': "+taskList);
+    }
+  }
+
+  public static Task getTask(List<Task> taskList, String taskName, String assignee) {
+    for (Task task : taskList) {
+      if (taskName.equals(task.getName())) {
+        if (assignee==null) {
+          if (task.getAssignee()==null) {
+            return task;
+          }
+        } else {
+          if (assignee.equals(task.getAssignee())) {
+            return task;
+          }
+        }
+      }
+    }
+    return null;
+  }
+  
+  public void executeAsyncMessage(Execution execution) {
+    List<Job> jobs = managementService
+      .createJobQuery()
+      .messages()
+      .processInstanceId(execution.getId())
+      .execute();
+    
+    if (jobs.isEmpty()) {
+      fail("no async message");
+    }
+    
+    if (jobs.size()>1) {
+      fail("more then one async message");
+    }
+    
+    managementService.executeJob(jobs.get(0).getDbid());
+  }
+
+  public static void assertContainsTask(List<Task> taskList, String taskName, String assignee) {
+    if (getTask(taskList, taskName, assignee)==null) {
+      fail("tasklist doesn't contain task '"+taskName+"' for assignee '"+assignee+"': "+taskList);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/MessageFinder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/MessageFinder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/MessageFinder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MessageFinder {
+  
+  protected JbpmTestCase jbpmTestCase;
+
+  public MessageFinder(JbpmTestCase jbpmTestCase) {
+    this.jbpmTestCase = jbpmTestCase;
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+  <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/test-db/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test-db</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/test-db/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/.settings/org.eclipse.jdt.core.prefs	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,5 @@
+#Fri Feb 13 11:21:25 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: jbpm4/branches/tbaeyens/modules/test-db/jbpm4-test-db.iml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/jbpm4-test-db.iml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/jbpm4-test-db.iml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,411 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="jbpm4-jpdl" exported="" />
+    <orderEntry type="module" module-name="jbpm4-pvm" exported="" />
+    <orderEntry type="module" module-name="jbpm4-test-base" exported="" />
+    <orderEntry type="module" module-name="jbpm4-task" exported="" />
+    <orderEntry type="module" module-name="jbpm4-toplevel" exported="" />
+    <orderEntry type="module" module-name="toplevel" />
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.transaction:jta:jar:1.0.1B:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: junit:junit:jar:3.8.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:jbossesb-rosetta:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/jbossesb-rosetta/4.4.0.GA/jbossesb-rosetta-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate:jar:3.2.6.ga:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-logging:commons-logging:jar:1.0.4:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax-api:jar:1.0.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.client:jbossall-client:jar:4.2.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/client/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: stax:stax:jar:1.2.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/stax/stax/1.2.0/stax-1.2.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: hsqldb:hsqldb:jar:1.8.0.7:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: net.sf.ehcache:ehcache:jar:1.2.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: cglib:cglib:jar:2.1_3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: asm:asm-attrs:jar:1.5.3:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jbpm.jbpm4.dependencies.esb:test-util:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jbpm/jbpm4/dependencies/esb/test-util/4.4.0.GA/test-util-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: commons-collections:commons-collections:jar:2.1.1:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jboss.jbossts:jbossts-common:jar:4.4.0.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jboss/jbossts/jbossts-common/4.4.0.GA/jbossts-common-4.4.0.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: log4j:log4j:jar:1.2.14:compile">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.livetribe:livetribe-jsr223:jar:2.0.5:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/livetribe/livetribe-jsr223/2.0.5/livetribe-jsr223-2.0.5.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-engine:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-engine/2.1.0/juel-engine-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel/2.1.0/juel-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: juel:juel-impl:jar:2.1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/juel/juel-impl/2.1.0/juel-impl-2.1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-spi:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-spi/1.0.0-SNAPSHOT/idm-spi-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.bind:jaxb-api:jar:2.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.cache:jbosscache-core:jar:3.0.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/cache/jbosscache-core/3.0.2.GA/jbosscache-core-3.0.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.xml.stream:stax-api:jar:1.0-2:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-api:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-api/1.0.0-SNAPSHOT/idm-api-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.persistence:persistence-api:jar:1.0:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm/1.0.0-SNAPSHOT/idm-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.identity:idm-common:jar:1.0.0-SNAPSHOT:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/identity/idm-common/1.0.0-SNAPSHOT/idm-common-1.0.0-SNAPSHOT.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:ejb3-persistence:jar:1.0.1.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/ejb3-persistence/1.0.1.GA/ejb3-persistence-1.0.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: jgroups:jgroups:jar:2.6.7.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/jgroups/jgroups/2.6.7.GA/jgroups-2.6.7.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javax.activation:activation:jar:1.1:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javax/activation/activation/1.1/activation-1.1-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: com.sun.xml.bind:jaxb-impl:jar:2.1.8:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.8/jaxb-impl-2.1.8.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-annotations:jar:3.3.1.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-annotations/3.3.1.GA/hibernate-annotations-3.3.1.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss:jboss-common-core:jar:2.2.10.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-entitymanager/3.3.2.GA/hibernate-entitymanager-3.3.2.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="M2 Dep: javassist:javassist:jar:3.4.GA:test">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: jbpm4/branches/tbaeyens/modules/test-db/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3768 2009-02-04 08:40:26Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Test DB</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-test-db</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-base</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+  </dependencies>
+
+  <!-- Plugins -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- this tells surefire that the test classes are 
+          to be found in the src directory src/main/java.
+          The test classes are in the source directory to make 
+          a distinction between the compile time classpath and the 
+          runtime test classpath.  The compile time classpath only should 
+          have the api module in its dependencies. -->
+          <testSourceDirectory>src/main/java</testSourceDirectory>
+          <classesDirectory>target/classes</classesDirectory>
+          <testClassesDirectory>target/classes</testClassesDirectory>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack.jbpm.db</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jbpm.jbpm4</groupId>
+                  <artifactId>jbpm-jpdl</artifactId>
+                  <classifier>config</classifier>
+                  <overWrite>true</overWrite>
+                </artifactItem>
+              </artifactItems>
+              <excludeTransitive>true</excludeTransitive>
+              <outputDirectory>target/jpdl-config</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>install.hibernate.database.properties</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>                 
+            <configuration>
+              <tasks>
+               <copy file="target/jpdl-config/hibernate.cfg.${database}.xml"
+                      tofile="target/classes/testDb-hibernate.cfg.xml"
+                      overwrite="true" />         
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTest extends JbpmTestCase {
+
+  public void testExclusiveExpression() {
+    deployJpdlXmlString(
+      "<process name='Poolcar'>" +
+      "  <start>" +
+      "    <transition to='How far?' />" +
+      "  </start>" +
+      "  <exclusive name='How far?' expr='#{distance}'>" +
+      "    <transition name='far'    to='Big car' />" +
+      "    <transition name='nearby' to='Small car' />" +
+      "  </exclusive>" +
+      "  <state name='Big car' />" +
+      "  <state name='Small car' />" +
+      "</process>"
+    );
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("distance", "far");
+    Execution execution = executionService.startProcessInstanceByKey("Poolcar", variables);
+    assertEquals("Big car", execution.getActivityName());
+
+    variables.put("distance", "nearby");
+    execution = executionService.startProcessInstanceByKey("Poolcar", variables);
+    assertEquals("Small car", execution.getActivityName());
+  }
+
+  public void testExclusiveWithConditions() {
+    deployJpdlXmlString(
+      "<process name='Poolcar'>" +
+      "  <start>" +
+      "    <transition to='How far?' />" +
+      "  </start>" +
+      "  <exclusive name='How far?'>" +
+      "    <transition to='Big car'>" +
+      "      <condition expr='#{distance &gt; 10}' />" +
+      "    </transition>" +
+      "    <transition to='Small car'>" +
+      "      <condition expr='#{distance &gt;= 3}' />" +
+      "    </transition>" +
+      "    <transition to='No car' />" +
+      "  </exclusive>" +
+      "  <state name='Big car' />" +
+      "  <state name='Small car' />" +
+      "  <state name='No car' />" +
+      "</process>"
+    );
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("distance", new Integer(69));
+    Execution execution = executionService.startProcessInstanceByKey("Poolcar", variables);
+    assertEquals("Big car", execution.getActivityName());
+
+    variables.put("distance", new Integer(6));
+    execution = executionService.startProcessInstanceByKey("Poolcar", variables);
+    assertEquals("Small car", execution.getActivityName());
+
+    variables.put("distance", new Integer(2));
+    execution = executionService.startProcessInstanceByKey("Poolcar", variables);
+    assertEquals("No car", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateTest extends JbpmTestCase {
+
+  public void testWaitStatesSequence() {
+    deployJpdlXmlString(
+      "<process name='ThreeStates'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'>" +
+      "    <transition to='c' />" +
+      "  </state>" +
+      "  <state name='c'>" +
+      "    <transition to='d' />" +
+      "  </state>" +
+      "  <end name='d' />" +
+      "</process>"
+    );
+    
+    Execution execution = executionService.startProcessInstanceById("ThreeStates:1");
+    assertEquals("b", execution.getActivityName());
+
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("c", execution.getActivityName());
+
+    execution = executionService.signalExecutionById(executionId);
+    assertEquals("d", execution.getActivityName());
+    assertTrue(execution.isEnded());
+  }
+
+  public void testExternalDecision() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='ed' />" +
+      "  </start>" +
+      "  <state name='ed'>" +
+      "    <transition name='left'   to='b' />" +
+      "    <transition name='middle' to='c' />" +
+      "    <transition name='right'  to='d' />" +
+      "  </state>" +
+      "  <state name='b' />" +
+      "  <state name='c' />" +
+      "  <state name='d' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("p", "one");
+    assertEquals("ed", execution.getActivityName());
+    execution = executionService.signalExecutionById("p/one", "left");
+    assertEquals("b", execution.getActivityName());
+
+    executionService.startProcessInstanceById("p:1", "two");
+    execution = executionService.signalExecutionById("p/two", "middle");
+    assertEquals("c", execution.getActivityName());
+
+    executionService.startProcessInstanceById("p:1", "three");
+    execution = executionService.signalExecutionById("p/three", "right");
+    assertEquals("d", execution.getActivityName());
+  }
+
+  public void testDefaultSignalWithNamedTransitions() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a'>" +
+      "    <transition name='left'   to='b' />" +
+      "    <transition name='middle' to='c' />" +
+      "    <transition name='right'  to='d' />" +
+      "  </state>" +
+      "  <state name='b' />" +
+      "  <state name='c' />" +
+      "  <state name='d' />" +
+      "</process>"
+    );
+
+    executionService.startProcessInstanceByKey("p", "one");
+    try {
+      executionService.signalExecutionById("p/one", "left");
+    } catch (JbpmException e) {
+      assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
+    }
+  }
+
+  public void testNamedSignalWithoutMatchingTransition() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a'>" +
+      "    <transition name='left'   to='b' />" +
+      "    <transition name='middle' to='c' />" +
+      "    <transition name='right'  to='d' />" +
+      "  </state>" +
+      "  <state name='b' />" +
+      "  <state name='c' />" +
+      "  <state name='d' />" +
+      "</process>"
+    );
+
+    executionService.startProcessInstanceByKey("p", "one");
+    Execution execution = executionService.signalExecutionById("p/one", "up");
+    assertEquals("a", execution.getActivityName());
+  }
+
+  public void testDefaultSignalWithoutTransitions() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    executionService.startProcessInstanceByKey("p", "one");
+    Execution execution = executionService.signalExecutionById("p/one");
+    assertEquals("a", execution.getActivityName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.cfg;
+
+import org.jbpm.Configuration;
+import org.jbpm.ProcessEngine;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConfigurationTest extends BaseJbpmTestCase {
+
+  public void testDefaultConfiguration() {
+    ProcessEngine processEngine = new Configuration()
+        .buildProcessEngine();
+    assertNotNull(processEngine);
+  }
+
+  public void testMinimalConfiguration() {
+    ProcessEngine processEngine = new Configuration()
+        .setXmlString("<jbpm-configuration />")
+        .buildProcessEngine();
+    assertNotNull(processEngine);
+  }
+
+  public void testConfigurationServices() {
+    ProcessEngine processEngine = new Configuration()
+        .setXmlString(
+            "<jbpm-configuration>" +
+            "  <process-engine-context>" +
+            "    <process-service />" +
+            "    <execution-service />" +
+            "    <management-service />" +
+            "  </process-engine-context>" +
+            "</jbpm-configuration>"
+        )
+        .buildProcessEngine();
+    assertNotNull(processEngine);
+    assertNotNull(processEngine.getProcessService());
+    assertNotNull(processEngine.getExecutionService());
+    assertNotNull(processEngine.getManagementService());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/FindExecutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionTest extends JbpmTestCase {
+
+  public void testFindExecutionById() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("p");
+
+    // take the id and see if the execution service can still find it back
+    execution = executionService.findExecution(execution.getId());
+    assertNotNull(execution);
+    assertEquals("a", execution.getActivityName());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/SignalExecutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,254 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalExecutionTest extends JbpmTestCase {
+  
+  public void testSignalExecutionByKey() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a'>" +
+      "    <transition to='b' />" +
+      "  </state>" +
+      "  <state name='b'>" +
+      "    <transition to='c' />" +
+      "  </state>" +
+      "  <state name='c' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL", "82436");
+    
+    assertEquals("a", execution.getActivityName());
+    
+    execution = executionService.signalExecutionByKey("ICL", "82436");
+
+    assertEquals("b", execution.getActivityName());
+
+    execution = executionService.signalExecutionByKey("ICL", "82436");
+
+    assertEquals("c", execution.getActivityName());
+  }
+
+  public void testSignalExecutionById() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a'>" +
+      "    <transition to='b' />" +
+      "  </state>" +
+      "  <state name='b'>" +
+      "    <transition to='c' />" +
+      "  </state>" +
+      "  <state name='c' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL", "82436");
+    
+    assertEquals("a", execution.getActivityName());
+    
+    execution = executionService.signalExecutionById("ICL/82436");
+
+    assertEquals("b", execution.getActivityName());
+
+    execution = executionService.signalExecutionById("ICL/82436");
+
+    assertEquals("c", execution.getActivityName());
+  }
+
+  public void testSignalExecutionWithVariables() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a'>" +
+      "    <transition to='b' />" +
+      "  </state>" +
+      "  <state name='b' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL", "82436");
+
+    Map<String,Object> variables = new HashMap<String,Object>();
+    variables.put("customer", "John Doe");
+    variables.put("type", "Accident");
+    variables.put("amount", new Float(763.74));
+
+    execution = executionService.signalExecutionById("ICL/82436", variables);
+
+    assertNotNull(execution);
+    String executionId = execution.getId();
+    assertEquals("b", execution.getActivityName());
+    
+    Map<String,Object> expectedVariables = new HashMap<String, Object>(variables); 
+    Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+    Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+    assertEquals(expectedVariableNames, variableNames);
+    
+    variables = executionService.getVariables(executionId, variableNames);
+    assertEquals(expectedVariables, variables);
+  }
+
+  
+  public void testDefaultSignalWithoutTransitions() {
+    deployJpdlXmlString(
+      "<process name='p'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("p");
+    execution = executionService.signalExecutionById(execution.getId());
+    assertEquals("a", execution.getActivityName());
+  }
+
+  /*
+
+  public void testSetVariable()
+  {
+    Execution execution = startExecution();
+
+    String executionId = execution.getId();
+    // set variable a to value text
+    executionService.setVariable(executionId, "a", "text");
+    // check if we can read that value back
+    assertEquals("text", executionService.getVariable(executionId, "a"));
+
+    // overwrite the value of variable a with another text
+    executionService.setVariable(executionId, "a", "another text");
+    // see if we can read another text back from the variable
+    assertEquals("another text", executionService.getVariable(executionId, "a"));
+  }
+
+  public void testSetVariables()
+  {
+    Execution execution = startExecution();
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("a", new Integer(1));
+    variables.put("b", "text");
+
+    // set variables in bulk by providing a map
+    executionService.setVariables(execution.getId(), variables);
+
+    Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+    Set<String> variableNames = new HashSet<String>();
+    variableNames.add("a");
+    variableNames.add("b");
+
+    // read the variables back and compare
+    assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+
+    // now set variables b and c with a map
+    variables = new HashMap<String, Object>();
+    variables.put("b", new Integer(99));
+    variables.put("c", "another text");
+
+    // this should leave a untouched, overwrite b and create c
+    executionService.setVariables(execution.getId(), variables);
+
+    // update the expected map
+    expected.put("b", new Integer(99));
+    expected.put("c", "another text");
+
+    // add c to the variable names that should be collected
+    variableNames.add("c");
+
+    // read the variables back and compare
+    assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+  }
+
+  // helper methods ///////////////////////////////////////////////////////////
+
+  /**
+   * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+   * 'publish book'
+  void deployMultipleVersionsOfProcesses()
+  {
+    ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+    ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(
+        WaitState.class).done();
+    DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+    deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+    deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+    deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    processDefinition = ProcessFactory.build("publish book").key("PBO").activity("initial").initial().behaviour(WaitState.class).done();
+    deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+    deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+  }
+
+  Execution startExecution()
+  {
+    ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+    ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").activity("initial").initial().behaviour(WaitState.class)
+        .done();
+    DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+    processService.deploy(deploymentImpl);
+
+    ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+    return executionService.startExecutionByName("nuclear fusion");
+  }
+
+   */
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/execution/StartExecutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionTest extends JbpmTestCase {
+
+  public void testStartNewExecutionByKey() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL");
+
+    assertNotNull(execution);
+    assertEquals("a", execution.getActivityName());
+  }
+
+  public void testStartNewExecutionInLatestProcessDefinition() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL");
+
+    assertNotNull(execution);
+    assertEquals("a", execution.getActivityName());
+
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b' />" +
+      "</process>"
+    );
+
+    execution = executionService.startProcessInstanceByKey("ICL");
+
+    assertNotNull(execution);
+    assertEquals("b", execution.getActivityName());
+  }
+  
+  public void testStartExecutionInLatestByNameWithVariables() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b' />" +
+      "</process>"
+    );
+
+    // create variables that are fed into the process before it starts executing
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("a", new Integer(1));
+    variables.put("b", "text");
+
+    // feed the variables in
+    Execution execution = executionService.startProcessInstanceByKey("ICL", variables);
+    String executionId = execution.getId();
+    assertEquals("b", execution.getActivityName());
+
+    // verify that the variables are actually set
+    assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+    assertEquals("text", executionService.getVariable(executionId, "b"));
+
+    // in the generated id, we can see if the right process definition version was taken
+    assertTrue(execution.getId().startsWith("ICL/"));
+  }
+
+  public void testStartNewProcessInstanceWithAKey() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL", "one");
+
+    assertNotNull(execution);
+    assertEquals("ICL/one", execution.getId());
+  }
+
+  public void testStartNewProcessInstanceWithVariables() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+    
+    Map<String,Object> variables = new HashMap<String,Object>();
+    variables.put("customer", "John Doe");
+    variables.put("type", "Accident");
+    variables.put("amount", new Float(763.74));
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL", variables);
+    
+    String executionId = execution.getId();
+
+    assertNotNull(execution);
+    
+    Map<String,Object> expectedVariables = new HashMap<String, Object>(variables); 
+    Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+    Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+    assertEquals(expectedVariableNames, variableNames);
+    
+    variables = executionService.getVariables(executionId, variableNames);
+    assertEquals(expectedVariables, variables);
+  }
+
+  public void testStartExecutionById() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+    
+    ProcessDefinition processDefinition = processService.findProcessDefinitionsByKey("ICL").get(0);
+    
+    // start an execution for the process with the given id
+    Execution execution = executionService.startProcessInstanceById("ICL:1");
+    assertNotNull(execution);
+
+    // checking the state
+    assertEquals("a", execution.getActivityName());
+
+    // checking the generated id
+    assertNull(execution.getName());
+    assertNull(execution.getKey());
+    // if there is no user defined name or key specified in the execution,
+    // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
+    assertTrue(execution.getId().startsWith("ICL/"));
+    // the last part of the execution key should be the dbid.
+    Long.parseLong(execution.getId().substring(4));
+  }
+
+  public void testStartExecutionByIdWithVariables() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' />" +
+      "</process>"
+    );
+
+    // create the map with variables
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("a", new Integer(1));
+    variables.put("b", "text");
+
+    // provide the variables in the start execution method
+    Execution execution = executionService.startProcessInstanceById("ICL:1", variables);
+    String executionId = execution.getId();
+
+    assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+    assertEquals("text", executionService.getVariable(executionId, "b"));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/AvgDurationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/AvgDurationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/AvgDurationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.history;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AvgDurationTest extends JbpmTestCase {
+
+  public void testAvgDuration() throws Exception {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='one' />" +
+      "  </start>" +
+      "  <state name='one'>" +
+      "    <transition to='two' />" +
+      "  </state>" +
+      "  <state name='two'>" +
+      "    <transition to='three' />" +
+      "  </state>" +
+      "  <state name='three'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+
+    executeProcess();
+    executeProcess();
+    executeProcess();
+
+    Map<String, Long> avgDurations = historyService.avgDurationPerActivity("ICL:1");
+
+
+    Long avgDurationOne = avgDurations.get("one");
+    assertNotNull(avgDurationOne);
+    assertTrue(avgDurationOne>50);
+    Long avgDurationTwo = avgDurations.get("two");
+    assertNotNull(avgDurationTwo);
+    assertTrue(avgDurationTwo>20);
+    Long avgDurationThree = avgDurations.get("three");
+    assertNotNull(avgDurationThree);
+    assertTrue(avgDurationThree>0);
+
+    assertEquals(3, avgDurations.size());
+  }
+
+  protected void executeProcess() throws InterruptedException {
+    Execution execution = executionService.startProcessInstanceByKey("ICL");
+    Thread.sleep(50);
+    executionService.signalExecutionById(execution.getId());
+    Thread.sleep(20);
+    executionService.signalExecutionById(execution.getId());
+    executionService.signalExecutionById(execution.getId());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ChoiceDistributionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ChoiceDistributionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ChoiceDistributionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.history;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ChoiceDistributionTest extends JbpmTestCase {
+
+  public void testExclusiveExpression() {
+    deployJpdlXmlString(
+      "<process name='Transport Selection' key='TRS'>" +
+      "  <start>" +
+      "    <transition to='How far?' />" +
+      "  </start>" +
+      "  <exclusive name='How far?' expr='#{distance}'>" +
+      "    <transition name='far'           to='Big car' />" +
+      "    <transition name='nearby'        to='Small car' />" +
+      "    <transition name='other country' to='Airoplane' />" +
+      "  </exclusive>" +
+      "  <state name='Big car' />" +
+      "  <state name='Small car' />" +
+      "  <state name='Airoplane' />" +
+      "</process>"
+    );
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("distance", "far");
+    executionService.startProcessInstanceByKey("TRS", variables);
+
+    variables.put("distance", "nearby");
+    executionService.startProcessInstanceByKey("TRS", variables);
+    executionService.startProcessInstanceByKey("TRS", variables);
+    executionService.startProcessInstanceByKey("TRS", variables);
+
+    variables.put("distance", "other country");
+    executionService.startProcessInstanceByKey("TRS", variables);
+    executionService.startProcessInstanceByKey("TRS", variables);
+
+    Map<String, Integer> choiceDistribution = historyService.choiceDistribution("TRS:1", "How far?");
+    
+    assertEquals(1, (int)choiceDistribution.get("far"));
+    assertEquals(3, (int)choiceDistribution.get("nearby"));
+    assertEquals(2, (int)choiceDistribution.get("other country"));
+      
+  }
+
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/EndProcessInstanceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/EndProcessInstanceTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/EndProcessInstanceTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.history;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndProcessInstanceTest extends JbpmTestCase {
+
+  public void testCancelProcessInstance() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='wait' />" +
+      "  </start>" +
+      "  <state name='wait'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("ICL");
+    String processInstanceId = execution.getId();
+    executionService.endProcessInstance(processInstanceId, Execution.STATE_CANCELLED);
+
+    List<Execution> executions = executionService.createExecutionQuery()
+        .processInstanceId(processInstanceId)
+        .execute();
+    assertEquals(0, executions.size());
+
+    HistoryProcessInstance historyProcessInstance = historyService.createHistoryProcessInstanceQuery()
+      .processInstanceId(processInstanceId)
+      .executeUniqueResult();
+
+    assertNotNull(historyProcessInstance.getEndTime());
+    assertEquals(Execution.STATE_CANCELLED, historyProcessInstance.getState());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.history;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.history.HistoryProcessInstanceQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceHistoryTest extends JbpmTestCase {
+
+  public void testProcessInstanceHistory() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start>" +
+      "    <transition to='end' />" +
+      "  </start>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+
+    executionService.startProcessInstanceByKey("ICL");
+    executionService.startProcessInstanceByKey("ICL");
+    executionService.startProcessInstanceByKey("ICL");
+    
+    List<HistoryProcessInstance> historyProcessInstances = historyService
+      .createHistoryProcessInstanceQuery()
+      .processDefinitionId("ICL:1")
+      .orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME)
+      .execute();
+
+    assertEquals(3, historyProcessInstances.size());
+    
+    for (HistoryProcessInstance historyProcessInstance: historyProcessInstances) {
+      assertTrue(historyProcessInstance.getProcessInstanceId().startsWith("ICL"));
+      assertEquals(HistoryProcessInstance.STATE_ENDED, historyProcessInstance.getState());
+      assertNotNull(historyProcessInstance.getStartTime());
+      assertNotNull(historyProcessInstance.getEndTime());
+    }
+    
+    // also check that the ended process instances have been removed from the 
+    // runtime database
+    List<Execution> executions = executionService
+      .createExecutionQuery()
+      .processDefinitionId("ICL:1")
+      .execute();
+
+    assertEquals(0, executions.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessAttachmentsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessAttachmentsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessAttachmentsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.io.ByteArrayInputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessAttachmentsTest extends JbpmTestCase {
+
+  public void testProcessWithNameOnly() {
+    byte[] lotOfBytes = generateString("a lot of bytes ", 5000).getBytes();
+    byte[] otherBytes = generateString("other bytes ", 5000).getBytes();
+    
+    List<ProcessDefinition> deployedProcessDefinitions = 
+    processService.createDeployment()
+      .addString("xmlstring.jpdl.xml", 
+                 "<process name='Insurance claim'>" +
+                 "  <start />" +
+                 "</process>")
+      .addInputStream("a lot of attachment", new ByteArrayInputStream(lotOfBytes))
+      .addInputStream("other attachment", new ByteArrayInputStream(otherBytes))
+      .deploy()
+      .getProcessDefinitions();
+    ProcessDefinition processDefinition = registerDeployedProcessDefinitions(deployedProcessDefinitions);
+
+    byte[] retrievedLotOfBytes = processService.getAttachment(processDefinition.getId(), "a lot of attachment");
+    assertTrue(Arrays.equals(lotOfBytes, retrievedLotOfBytes));
+    
+    byte[] retrievedOtherBytes = processService.getAttachment(processDefinition.getId(), "other attachment");
+    assertTrue(Arrays.equals(otherBytes, retrievedOtherBytes));
+  }
+
+  protected String generateString(String base, int multiplier) {
+    StringBuffer buffer = new StringBuffer();
+    for (int i=0; i<multiplier; i++) {
+      buffer.append(base);
+    }
+    String string = buffer.toString();
+    return string;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryTest extends JbpmTestCase {
+
+  public void testQueryProcessDefinitionsEmpty() {
+    List<ProcessDefinition> processDefinitions = processService
+      .createProcessDefinitionQuery()
+      .execute();
+    
+    assertEquals(0, processDefinitions.size());
+  }
+
+  public void testQueryProcessDefinitionsNameLike() {
+    deployJpdlXmlString(
+      "<process name='make print'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='use phone'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='make friends'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='clean whiteboard'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='fix coffeemaker'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+      .nameLike("%make%")
+      .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+      .execute();
+
+    assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
+    assertEquals("make friends",    processDefinitions.get(1).getName());
+    assertEquals("make print",      processDefinitions.get(2).getName());
+  }
+
+  public void testQueryProcessDefinitionsKeyLike() {
+    deployJpdlXmlString(
+      "<process name='make print'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='use phone'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='make friends'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='make friends'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='make friends'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='clean whiteboard'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='fix coffeemaker'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+      .keyLike("make%")
+      .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+      .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+      .execute();
+
+    assertEquals("make_friends:3", processDefinitions.get(0).getId());
+    assertEquals("make_friends:2", processDefinitions.get(1).getId());
+    assertEquals("make_friends:1", processDefinitions.get(2).getId());
+    assertEquals("make_print:1",   processDefinitions.get(3).getId());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,356 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceTest extends JbpmTestCase {
+
+  public void testProcessWithNameOnly() {
+    ProcessDefinition processDefinition = deployJpdlXmlString(
+      "<process name='Insurance claim'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    assertNotNull(processDefinition);
+    assertEquals("Insurance claim", processDefinition.getName());
+    assertEquals("Insurance_claim", processDefinition.getKey());
+    assertEquals(1, processDefinition.getVersion());
+    assertEquals("Insurance_claim:1", processDefinition.getId());
+  }
+
+  public void testProcessWithNameAndKey() {
+    deployJpdlXmlString(
+      "<process name='Insurance claim' key='ICL'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
+
+    assertNotNull(processDefinition);
+    assertEquals("Insurance claim", processDefinition.getName());
+    assertEquals("ICL", processDefinition.getKey());
+    assertEquals(1, processDefinition.getVersion());
+    assertEquals("ICL:1", processDefinition.getId());
+  }
+
+  // interface methods ////////////////////////////////////////////////////////
+
+  public void testFindProcessDefinitionKeys() {
+    deployMultipleVersionsOfProcesses();
+
+    List<String> processKeys = processService.findProcessDefinitionKeys();
+
+    List<String> expected = new ArrayList<String>();
+    expected.add("nuclear_fusion");
+    expected.add("publish_book");
+    expected.add("ultimate_seduction");
+
+    assertEquals(expected, processKeys);
+  }
+
+
+  public void testFindProcessByKey() {
+    deployJpdlXmlString(
+      "<process name='Name with spaces'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
+    assertNotNull(processDefinition);
+    assertEquals("Name with spaces", processDefinition.getName());
+    assertEquals("Name_with_spaces", processDefinition.getKey());
+    assertEquals(1, processDefinition.getVersion());
+    assertEquals("Name_with_spaces:1", processDefinition.getId());
+  }
+
+  public void testFindProcessDefinitions() {
+    deployMultipleVersionsOfProcesses();
+
+    List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
+    assertNotNull(processDefinitions);
+
+    assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
+    assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+    assertEquals(3, processDefinitions.get(0).getVersion());
+
+    assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+    assertEquals(2, processDefinitions.get(1).getVersion());
+
+    assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+    assertEquals(1, processDefinitions.get(2).getVersion());
+  }
+
+  public void testFindLatestProcessDefinition() {
+    deployMultipleVersionsOfProcesses();
+
+    ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
+    assertNotNull(retrieved);
+
+    assertEquals(3, retrieved.getVersion());
+    assertEquals("nuclear fusion", retrieved.getName());
+    assertEquals("nuclear_fusion", retrieved.getKey());
+  }
+
+  public void testFindProcessDefinitionById() {
+    deployJpdlXmlString(
+      "<process name='given' version='33'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    // load it
+    ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
+    assertNotNull(processDefinition);
+    assertEquals("given", processDefinition.getName());
+    assertEquals(33, processDefinition.getVersion());
+  }
+
+  public void testDeleteProcessDefinition() {
+    processService.createDeployment()
+        .addString("xmlstring.jpdl.xml", 
+            "<process name='deleteme' version='33'>" +
+            "  <start />" +
+            "</process>")
+        .deploy();
+
+    // delete it
+    processService.deleteProcessDefinition("deleteme:33");
+
+    // check if the db is empty
+    assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+  }
+
+  public void testDeleteProcessDefinitionAndInstances() {
+    processService.createDeployment()
+        .addString("xmlstring.jpdl.xml", 
+          "<process name='deleteme' version='33'>" +
+          "  <start>" +
+          "    <transition to='w' />" +
+          "  </start>" +
+          "  <state name='w' />" +
+          "</process>")
+        .deploy();
+    
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    
+    // delete it all
+    processService.deleteProcessDefinitionCascade("deleteme:33");
+
+    // check if the db is empty
+    assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
+    assertEquals(0, executionService.createExecutionQuery().execute().size());
+  }
+  
+  public void testDeleteProcessDefinitionButNotInstances() {
+    deployJpdlXmlString(
+      "<process name='deleteme' version='33'>" +
+      "  <start>" +
+      "    <transition to='w' />" +
+      "  </start>" +
+      "  <state name='w' />" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    executionService.startProcessInstanceByKey("deleteme");
+    
+    // delete it all
+    try {
+      processService.deleteProcessDefinition("deleteme:33");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
+    }
+  }
+  
+  // various other aspects ////////////////////////////////////////////////////
+  
+  public void testAutomaticVersioning() {
+    deployJpdlXmlString(
+      "<process name='versionme'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    // look it up again
+    List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+    assertNotNull(processDefinitions);
+    // verify that there is only one
+    assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+    ProcessDefinition processDefinition = processDefinitions.get(0);
+    // and check that automatically assigned version starts with 1
+    assertEquals(1, processDefinition.getVersion());
+
+    deployJpdlXmlString(
+      "<process name='versionme'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    // look them up again
+    processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+    // verify that there is only one
+    assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+    // and check that automatically assigned version starts with 1
+    assertEquals(2, processDefinitions.get(0).getVersion());
+    assertEquals(1, processDefinitions.get(1).getVersion());
+  }
+
+  public void testUserProvidedVersion() {
+    deployJpdlXmlString(
+      "<process name='takethis' version='234'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    // load it
+    List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
+    assertNotNull(processDefinitions);
+    assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+    ProcessDefinition processDefinition = processDefinitions.get(0);
+    // verify that the user specified version was used
+    // (and not overwritten by an automatically assigned versioning)
+    assertEquals(234, processDefinition.getVersion());
+  }
+
+  public void testDuplicateUserProvidedVersion()  {
+    deployJpdlXmlString(
+      "<process name='takethis' version='234'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    try {
+      deployJpdlXmlString(
+        "<process name='takethis' version='234'>" +
+        "  <start />" +
+        "</process>"
+      );
+      fail("expected exception");
+    } catch (JbpmException e) {
+      assertTextPresent("process 'takethis:234' already exists", e.getMessage());
+    }
+  }
+
+  /**
+   * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+   * 'publish book'
+   */
+  void deployMultipleVersionsOfProcesses() {
+    deployJpdlXmlString(
+      "<process name='nuclear fusion'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='ultimate seduction'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='ultimate seduction'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='ultimate seduction'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='ultimate seduction'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='publish book'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='nuclear fusion'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    deployJpdlXmlString(
+      "<process name='nuclear fusion'>" +
+      "  <start />" +
+      "</process>"
+    );
+  }
+
+  public void testMinimalProcess() {
+    deployJpdlXmlString(
+      "<process name='minimal'>" +
+      "  <start>" +
+      "    <transition to='end' />" +
+      "  </start>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+    
+    Execution execution = executionService.startProcessInstanceByKey("minimal");
+    
+    assertEquals("end", execution.getActivityName());
+    assertTrue(execution.isEnded());
+    assertFalse(execution.isActive());
+  }
+
+  public void testMostMinimalProcess() {
+    deployJpdlXmlString(
+      "<process name='minimal'>" +
+      "  <start />" +
+      "</process>"
+    );
+
+    Execution execution = executionService.startProcessInstanceByKey("minimal");
+    
+    assertTrue(execution.isEnded());
+    assertFalse(execution.isActive());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubTaskTest extends JbpmTestCase {
+
+  public void testTaskParticipants() {
+    
+    // create top level task
+    // * clean da house
+    
+    Task task = taskService.newTask();
+    task.setName("clean da house");
+    saveAndRegisterTask(task);
+    long taskDbid = task.getDbid();
+    
+    // create 3 sub tasks: 
+    // * clean da house
+    //   * dishes
+    //   * laundry
+    //   * sweep floor
+    
+    Task subTask = taskService.newTask(taskDbid);
+    subTask.setName("dishes");
+    taskService.saveTask(subTask);
+    long dishesTaskDbid = subTask.getDbid();
+    
+    subTask = taskService.newTask(taskDbid);
+    subTask.setName("laundry");
+    taskService.saveTask(subTask);
+    long laundryTaskDbid = subTask.getDbid();
+    
+    subTask = taskService.newTask(taskDbid);
+    subTask.setName("sweep floor");
+    taskService.saveTask(subTask);
+    long sweepFloorTaskDbid = subTask.getDbid();
+    
+    // verify 3 sub tasks of clean da house
+    
+    List<Task> subTasks = taskService.getSubTasks(taskDbid);
+    Set<String> subTaskNames = getTaskNames(subTasks);
+    
+    Set<String> expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("dishes");
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+
+    // add 3 sub tasks for sweep floor: 
+    // * clean da house
+    //   * dishes
+    //   * laundry
+    //   * sweep floor
+    //     * find broom
+    //     * find water
+    //     * scrub
+
+    // now second level subtasks under sweep floor
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("find broom");
+    taskService.saveTask(subTask);
+
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("find water");
+    taskService.saveTask(subTask);
+
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("scrub");
+    taskService.saveTask(subTask);
+
+    // verify all the sub tasks of 'clean da house' and 'sweep floor'
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("dishes");
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("find broom");
+    expectedTaskNames.add("find water");
+    expectedTaskNames.add("scrub");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    // delete task dishes
+    taskService.deleteTask(dishesTaskDbid);
+
+    // verify all the sub tasks of 'clean da house' and 'sweep floor'
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("find broom");
+    expectedTaskNames.add("find water");
+    expectedTaskNames.add("scrub");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+
+    // delete laundry and delete sweep floor
+    // NOTE: deleting sweep floor should recursively delete the subtasks
+    taskService.deleteTask(laundryTaskDbid);
+    taskService.deleteTask(sweepFloorTaskDbid);
+
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+
+    expectedTaskNames = new HashSet<String>();
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    assertEquals(expectedTaskNames, subTaskNames);
+  }
+
+  private Set<String> getTaskNames(List<Task> tasks) {
+    Set<String> taskNames = new HashSet<String>();
+    for (Task task: tasks) {
+      taskNames.add(task.getName());
+    }
+    return taskNames;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.List;
+
+import org.jbpm.model.Comment;
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskCommentsTest extends JbpmTestCase {
+  
+  public void testComments() {
+    Task task = taskService.newTask();
+    task.setName("clean da house");
+    taskService.saveTask(task);
+    long taskDbid = task.getDbid();
+
+    // what a party yesterday
+    //   - what! you had a party while i was out ?!
+    //      - euh yes.  it was a great party :-)
+    // i'll clean up the mess
+    Comment comment = taskService.addTaskComment(taskDbid, "what a party yesterday");
+    long whatAPartyDbid = comment.getDbid();
+    comment = taskService.addReplyComment(whatAPartyDbid, "what! you had a party while i was out ?!");
+    long youHadAPartyDbid = comment.getDbid();
+    taskService.addReplyComment(youHadAPartyDbid, "euh yes.  it was a great party :-)");
+
+    taskService.addTaskComment(taskDbid, "i'll clean up the mess");
+    
+    List<Comment> taskComments = taskService.getTaskComments(taskDbid);
+    assertEquals("what a party yesterday", taskComments.get(0).getMessage());
+    assertEquals("i'll clean up the mess", taskComments.get(1).getMessage());
+    
+    taskComments = taskComments.get(0).getComments();
+    assertEquals("what! you had a party while i was out ?!", taskComments.get(0).getMessage());
+    
+    taskComments = taskComments.get(0).getComments();
+    assertEquals("euh yes.  it was a great party :-)", taskComments.get(0).getMessage());
+    
+    taskService.deleteComment(whatAPartyDbid);
+
+    taskComments = taskService.getTaskComments(taskDbid);
+    assertEquals("i'll clean up the mess", taskComments.get(0).getMessage());
+    
+    // the following should delete the remaining comment.  if not, this 
+    // will show up as a fixme.
+    taskService.deleteTask(taskDbid);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.Date;
+import java.text.DateFormat;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskCreateUpdateDeleteTest extends JbpmTestCase {
+
+  public void testNewTask() {
+    // creation of a new non-persisted task
+    Task task = taskService.newTask();
+    task = taskService.getTask(task.getDbid());
+    assertNull(task);
+  }
+
+  public void testSaveTask() {
+    Task task = taskService.newTask();
+    saveAndRegisterTask(task);
+    long taskDbid = task.getDbid();
+    // task was made persistent
+    task = taskService.getTask(taskDbid); 
+    assertNotNull("expected non-null task", task);
+    // make some change
+    Date dueDate = new Date();
+    task.setDueDate(dueDate);
+    taskService.saveTask(task);
+    // verify change is applied
+    task = taskService.getTask(taskDbid);
+    
+    // task.getDueDate() return an java.sql.Timestamp
+    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
+    assertEquals(df.format(dueDate), df.format(task.getDueDate()));
+  }
+
+  public void testDeleteTask() {
+    Task task = taskService.newTask();
+    taskService.saveTask(task);
+    long taskDbid = task.getDbid();
+    
+    // task was made persistent
+    assertNotNull("expected non-null task", taskService.getTask(taskDbid));
+    // delete task and verify it does not exist
+    taskService.deleteTask(taskDbid);
+    task = taskService.getTask(taskDbid);
+    assertNull("expected null, but was " + task, task);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.List;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskListTest extends JbpmTestCase {
+
+  public void testPersonalTaskList() {
+    Task task = taskService.newTask();
+    task.setName("do laundry");
+    task.setAssignee("johndoe");
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("get good idea");
+    task.setAssignee("joesmoe");
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("find venture capital");
+    task.setAssignee("joesmoe");
+    saveAndRegisterTask(task);
+    
+    task = taskService.newTask();
+    task.setName("start new business");
+    task.setAssignee("joesmoe");
+    saveAndRegisterTask(task);
+
+    List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+    assertNotNull(taskList);
+    
+    assertEquals("do laundry", taskList.get(0).getName());
+    assertEquals(1, taskList.size());
+
+    taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+    assertNotNull(taskList);
+    
+    assertContainsTask(taskList, "get good idea");
+    assertContainsTask(taskList, "start new business");
+    assertContainsTask(taskList, "find venture capital");
+
+    assertEquals(3, taskList.size());
+  }
+
+  public void testPersonalTaskListDefaultSortOrder() {
+    Task task = taskService.newTask();
+    task.setName("get good idea");
+    task.setAssignee("joesmoe");
+    task.setPriority(3);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("find venture capital");
+    task.setAssignee("joesmoe");
+    task.setPriority(2);
+    saveAndRegisterTask(task);
+    
+    task = taskService.newTask();
+    task.setName("start new business");
+    task.setAssignee("joesmoe");
+    task.setPriority(1);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("take a day off");
+    task.setAssignee("joesmoe");
+    task.setPriority(-5);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("make profit");
+    task.setAssignee("joesmoe");
+    task.setPriority(10);
+    saveAndRegisterTask(task);
+
+    List<Task> taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+    assertNotNull(taskList);
+    
+    // default sort order is based on the priority
+    assertEquals("make profit",          taskList.get(0).getName());
+    assertEquals("get good idea",        taskList.get(1).getName());
+    assertEquals("find venture capital", taskList.get(2).getName());
+    assertEquals("start new business",   taskList.get(3).getName());
+    assertEquals("take a day off",       taskList.get(4).getName());
+
+    assertEquals(5, taskList.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+import org.jbpm.task.UserRef;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskParticipationsTest extends JbpmTestCase {
+
+  public void testTaskParticipants() {
+    Task task = taskService.newTask();
+    task.setName("do laundry");
+    saveAndRegisterTask(task);
+    
+    long taskDbid = task.getDbid();
+
+    taskService.addTaskParticipant(taskDbid, new UserRef("johndoe"), Participant.CANDIDATE);
+    taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.CANDIDATE);
+    taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.OWNER);
+    taskService.addTaskParticipant(taskDbid, new GroupRef("losers"), Participant.CANDIDATE);
+    taskService.addTaskParticipant(taskDbid, new GroupRef("dummies"), Participant.CANDIDATE);
+    
+    List<Participant> taskParticipants = taskService.getTaskParticipants(taskDbid);
+
+    Set<IdentityRef> candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.CANDIDATE);
+
+    Set<IdentityRef> expectedIdentityRefs = new HashSet<IdentityRef>();
+    expectedIdentityRefs.add(new UserRef("johndoe"));
+    expectedIdentityRefs.add(new UserRef("joesmoe"));
+    expectedIdentityRefs.add(new GroupRef("losers"));
+    expectedIdentityRefs.add(new GroupRef("dummies"));
+
+    assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+    
+    candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.OWNER);
+
+    expectedIdentityRefs = new HashSet<IdentityRef>();
+    expectedIdentityRefs.add(new UserRef("joesmoe"));
+
+    assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+    
+    taskService.removeTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.OWNER);
+    taskService.removeTaskParticipant(taskDbid, new GroupRef("losers"), Participant.CANDIDATE);
+
+    
+    taskParticipants = taskService.getTaskParticipants(taskDbid);
+
+    candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.CANDIDATE);
+
+    expectedIdentityRefs = new HashSet<IdentityRef>();
+    expectedIdentityRefs.add(new UserRef("johndoe"));
+    expectedIdentityRefs.add(new UserRef("joesmoe"));
+    expectedIdentityRefs.add(new GroupRef("dummies"));
+
+    assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+    
+    candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.OWNER);
+
+    expectedIdentityRefs = new HashSet<IdentityRef>();
+
+    assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+  }
+
+  public Set<IdentityRef> getIdentityRefs(List<Participant> taskParticipants, String participation) {
+    Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
+    for (Participant participant: taskParticipants) {
+      if (participation.equals(participant.getParticipation())) {
+        identityRefs.add(participant.getIdentityRef());
+      }
+    }
+    return identityRefs;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/task/TaskQueryTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.task;
+
+import java.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryTest extends JbpmTestCase {
+
+  public void testSimplestTaskQuery() {
+    Task task = taskService.newTask();
+    task.setName("do laundry");
+    task.setAssignee("johndoe");
+    task.setPriority(3);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("change dyper");
+    task.setAssignee("johndoe");
+    task.setPriority(1);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("start new business");
+    task.setAssignee("joesmoe");
+    task.setPriority(4);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("find venture capital");
+    task.setPriority(4);
+    saveAndRegisterTask(task);
+
+    List<Task> taskList = taskService
+      .createTaskQuery()
+      .execute();
+    assertNotNull(taskList);
+    
+    assertContainsTask(taskList, "do laundry");
+    assertContainsTask(taskList, "change dyper");
+    assertContainsTask(taskList, "start new business");
+    assertContainsTask(taskList, "find venture capital");
+
+    assertEquals(4, taskList.size());
+  }
+
+  public void testSimplestTaskQuerySortBy() {
+    Task task = taskService.newTask();
+    task.setName("do laundry");
+    task.setAssignee("johndoe");
+    task.setPriority(3);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("change dyper");
+    task.setAssignee("johndoe");
+    task.setPriority(1);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("start new business");
+    task.setAssignee("joesmoe");
+    task.setPriority(4);
+    saveAndRegisterTask(task);
+
+    task = taskService.newTask();
+    task.setName("find venture capital");
+    task.setPriority(7);
+    saveAndRegisterTask(task);
+
+    List<Task> taskList = taskService
+      .createTaskQuery()
+      .orderAsc(TaskQuery.PROPERTY_NAME)
+      .execute();
+    assertNotNull(taskList);
+    
+    assertEquals("change dyper",         taskList.get(0).getName());
+    assertEquals("do laundry",           taskList.get(1).getName());
+    assertEquals("find venture capital", taskList.get(2).getName());
+    assertEquals("start new business",   taskList.get(3).getName());
+
+    assertEquals(4, taskList.size());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicVariablesTest extends JbpmTestCase {
+
+  public void testStartProcessInstanceWithoutVariables() {
+    deployJpdlXmlString(
+      "<process name='var'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'/>" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("var", "one");
+    Set<String> variableNames = executionService.getVariableNames("var/one");
+    assertNotNull(variableNames);
+    assertEquals(0, variableNames.size());
+  }
+
+  public void testStartProcessInstanceWithThreeVariables() {
+    deployJpdlXmlString(
+      "<process name='var'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'/>" +
+      "</process>"
+    );
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("customer", "John Doe");
+    variables.put("type", "Accident");
+    variables.put("amount", new Float(763.74));
+
+    Set<String> expectedVariableNames = new HashSet<String>(variables.keySet());
+    Map<String, Object> expectedVariables = new HashMap<String, Object>(variables);
+
+    executionService.startProcessInstanceByKey("var", variables, "one");
+    
+    Set<String> variableNames = executionService.getVariableNames("var/one");
+    assertNotNull(variableNames);
+    
+    assertEquals(expectedVariableNames, variableNames);
+
+    variables = executionService.getVariables("var/one", variableNames);
+
+    assertEquals(expectedVariables, variables);
+  }
+
+  public void testSetAndUpdateVariable() {
+    deployJpdlXmlString(
+      "<process name='var'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'/>" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("var", "one");
+    executionService.setVariable("var/one", "msg", "hello");
+    assertEquals("hello", executionService.getVariable("var/one", "msg"));
+    executionService.setVariable("var/one", "msg", "world");
+    assertEquals("world", executionService.getVariable("var/one", "msg"));
+  }
+
+  public void testUpdateVariableToDifferentType() {
+    deployJpdlXmlString(
+      "<process name='var'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'/>" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("var", "one");
+    executionService.setVariable("var/one", "msg", "hello");
+    assertEquals("hello", executionService.getVariable("var/one", "msg"));
+    executionService.setVariable("var/one", "msg", new Integer(5));
+    assertEquals(new Integer(5), executionService.getVariable("var/one", "msg"));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/java/org/jbpm/test/variables/VariableBasicTypesTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.variables;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableBasicTypesTest extends JbpmTestCase {
+
+  public void checkVariableValue(Object variableValue) {
+    deployJpdlXmlString(
+      "<process name='var'>" +
+      "  <start name='a'>" +
+      "    <transition to='b' />" +
+      "  </start>" +
+      "  <state name='b'/>" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("var", "one");
+    executionService.setVariable("var/one", "msg", variableValue);
+    assertEquals(variableValue, executionService.getVariable("var/one", "msg"));
+  }
+
+  public void testVariableTypeString() {
+    checkVariableValue("hello");
+  }
+
+  public void testVariableTypeCharacter() {
+    checkVariableValue(new Character('x'));
+  }
+
+  public void testVariableTypeBoolean() {
+    checkVariableValue(Boolean.TRUE);
+  }
+
+  public void testVariableTypeByte() {
+    checkVariableValue(new Byte((byte)5));
+  }
+
+  public void testVariableTypeShort() {
+    checkVariableValue(new Short((short)5));
+  }
+
+  public void testVariableTypeInteger() {
+    checkVariableValue(new Integer(5));
+  }
+
+  public void testVariableTypeLong() {
+    checkVariableValue(new Long(5));
+  }
+
+  public void testVariableTypeFloat() {
+    checkVariableValue(new Float(5.7));
+  }
+
+  public void testVariableTypeDouble() {
+    checkVariableValue(new Double(5.7));
+  }
+
+  public void testVariableTypeDate() {
+    checkVariableValue(new Date());
+  }
+  
+  public static class SerializeMe implements Serializable {
+    private static final long serialVersionUID = 1L;
+    String text;
+    public SerializeMe(String text) {
+      this.text = text;
+    }
+    public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((text == null) ? 0 : text.hashCode());
+      return result;
+    }
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (obj == null)
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      SerializeMe other = (SerializeMe) obj;
+      if (text == null) {
+        if (other.text != null)
+          return false;
+      } else if (!text.equals(other.text))
+        return false;
+      return true;
+    }
+  }
+  
+  public void testVariableTypeSerializable() {
+    SerializeMe originalValue = new SerializeMe(generateString("a lot of text ", 500));
+    checkVariableValue(originalValue);
+    
+    // now check if an update still works ok
+    // updating a serialized object might fail when the blob is cached by hibernate
+    SerializeMe newValue = new SerializeMe(generateString("another text ", 500));
+    executionService.setVariable("var/one", "msg", newValue);
+    assertEquals(newValue, executionService.getVariable("var/one", "msg"));
+  }
+  
+  protected String generateString(String base, int multiplier) {
+    StringBuffer buffer = new StringBuffer();
+    for (int i=0; i<multiplier; i++) {
+      buffer.append(base);
+    }
+    String string = buffer.toString();
+    return string;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+    
+    <process-service />
+    <execution-service />
+    <history-service />
+    <management-service />
+    <identity-service />
+    <task-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration resource="testDb-hibernate.cfg.xml">     
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    
+    <script-manager default-expression-language="juel"
+                    default-script-language="juel"
+                    read-contexts="execution, environment, process-engine"
+                    write-context="">
+        <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+    </script-manager>
+    
+    <job-executor auto-start="false" />
+    <job-test-helper />
+
+    <id-generator />
+    <types resource="jbpm.pvm.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <task-db-session />
+    <message-session />
+    <timer-session />
+    <history-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/main/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,32 @@
+handlers= java.util.logging.MemoryHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+java.util.logging.MemoryHandler.level=FINEST
+#java.util.logging.MemoryHandler.filter=
+java.util.logging.MemoryHandler.size=500 
+java.util.logging.MemoryHandler.push=SEVERE 
+java.util.logging.MemoryHandler.target=org.jbpm.internal.log.ConsoleHandler
+
+org.jbpm.internal.log.ConsoleHandler.level = FINEST
+org.jbpm.internal.log.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=FINEST
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=FINE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
+

Added: jbpm4/branches/tbaeyens/modules/test-load/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+  <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/test-classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/test-load/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test-load</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/test-load/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3843 2009-02-11 21:42:58Z heiko.braun at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Test Load</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-test-load</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-test-base</artifactId>
+      <version>${version}</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+      <version>${version}</version>
+    </dependency>
+    
+    <!-- TODO remove PVM dependency for compilation (keep it for test)-->
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+    
+  </dependencies>
+  
+    <!-- Plugins -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/*TestCase.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+
+      <plugin>                                                   
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack.jbpm.db</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jbpm.jbpm4</groupId>
+                  <artifactId>jbpm-jpdl</artifactId>
+                  <classifier>config</classifier>
+                  <overWrite>true</overWrite>
+                </artifactItem>
+              </artifactItems>
+              <excludeTransitive>true</excludeTransitive>
+              <outputDirectory>target/jpdl-config</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>install.hibernate.database.properties</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <copy file="target/jpdl-config/hibernate.cfg.${database}.xml"
+                      tofile="target/test-classes/hibernate.cfg.xml"
+                      overwrite="true" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>

Added: jbpm4/branches/tbaeyens/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.test.load;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Message;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * This class contains job executor tests which requires to have a read commited isolation level. 
+ * 
+ * @author Guillaume Porcher
+ *
+ */
+public class JobExecutorIsolationDbTest extends DbTestCase {
+  
+  static int jobExecutorTimeoutMillis = 500;
+  static int checkInterval = 400;
+  
+  public static class SimpleTestCommand implements Command<Object> {
+    private static final Log log = Log.getLog(SimpleTestCommand.class.getName());
+
+    public Object execute(Environment environment) throws Exception {
+      log.debug("command executed !");
+      return null;
+    }
+  }
+  
+  public void testInsertMessage() {
+    System.out.println("FIXME: JBPM-1769 fix db isolation test");
+  }
+  
+  
+  /*
+   * Basic test that only shows a simple situation in which we need to have a read commited isolation level.
+   */
+  
+  // FIX rename test method back to testInsertMessage 
+  public void dontTestInsertMessage() throws InterruptedException {
+    JobExecutorTest.processedMessageIds = new ArrayList<Integer>();
+    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+    jobExecutor.setIdleInterval(jobExecutorTimeoutMillis);
+    jobExecutor.start();
+    try {
+      processEngine.get(CommandService.class).execute(new Command<Object>() {
+        public Object execute(Environment environment) throws Exception {
+          MessageSession messageSession = environment.get(MessageSession.class);
+          CommandMessage commandMessage = new CommandMessage(new ObjectDescriptor(SimpleTestCommand.class));
+          messageSession.send(commandMessage);
+          List<Message> messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+          assertNotNull(messages);
+          assertEquals(1, messages.size());
+          Thread.sleep(jobExecutorTimeoutMillis * 2);
+          messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+          assertNotNull(messages);
+          assertEquals("Job has been executed before the transaction is committed !!", 1, messages.size());
+          return null;
+        }
+      });
+      Thread.sleep(jobExecutorTimeoutMillis * 2);
+    } finally {
+      jobExecutor.stop(true);
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/main/scripts/ant.properties.ant.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/main/scripts/ant.properties.ant.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/main/scripts/ant.properties.ant.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!--  JBoss, the OpenSource J2EE webOS                            -->
+<!--  Distributable under LGPL license.                           -->
+<!--  See terms of license at http://www.gnu.org.                 -->
+<!-- ============================================================ -->
+
+<!-- $Id: ant.properties.ant.xml 3400 2008-12-16 13:57:21Z tom.baeyens at jboss.com $ -->
+
+<project default="configure.db.properties">
+
+  <target name="configure.db.properties">
+  
+    <echo message="installing properties for db: ${database}" />
+
+    <copy file="target/test-classes/hibernate.properties" 
+          token="hibernate.dialect=org.hibernate.dialect.HSQLDialect" 
+          value="hibernate.dialect=${hibernate.property.dialect}" />
+
+    <replace file="target/test-classes/hibernate.properties" 
+             token="hibernate.connection.driver_class=org.hsqldb.jdbcDriver" 
+             value="hibernate.dialect=${hibernate.property.driver}" />
+  </target>
+  
+</project>

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Date;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class LoadTestCase extends JbpmTestCase {
+
+  protected static final long SECOND = 1000;  
+  protected static final long MINUTE = 60 * SECOND;  
+  protected static final long HOUR = 60 * MINUTE;  
+
+  protected static long checkInterval = 2000;
+
+  protected static String jobsAvailableQueryText =
+      "select count(*) "+
+      "from "+JobImpl.class.getName()+" as job "+
+      "where ( (job.dueDate is null) or (job.dueDate <= :now) ) "+ 
+      "  and ( job.retries > 0 )";
+
+  protected static boolean measureMemory = true;
+
+  protected CommandService commandService;
+  protected JobExecutor jobExecutor;
+  protected long startTime = -1;
+  protected long stopTime = -1;
+  protected PrintWriter logFileWriter;
+  
+
+  public void setUp() throws Exception {
+    super.setUp();
+    
+    if (measureMemory) {
+      openMemoryLogFile();
+    }
+    
+    commandService = processEngine.get(CommandService.class);
+    jobExecutor = processEngine.get(JobExecutor.class);
+  }
+  
+  protected void tearDown() throws Exception {
+    if (measureMemory) {
+      closeMemoryLogFile();
+    }
+    
+    super.tearDown();
+  }
+  
+  public void startMeasuringTime() {
+    if (stopTime==-1) {
+      startTime = System.currentTimeMillis();
+    } else {
+      startTime = startTime + (System.currentTimeMillis() - stopTime);
+      stopTime = -1;
+    }
+  }
+
+  public void stopMeasuringTime() {
+    stopTime = System.currentTimeMillis();
+  }
+
+  protected void openMemoryLogFile() throws Exception {
+    String testClass = ReflectUtil.getUnqualifiedClassName(getClass());
+    logFileWriter = new PrintWriter(new File("target/"+testClass +".txt"));
+    logColumnTitles();
+  }
+
+  protected void logColumnTitles() {
+    logFileWriter.println("Used Memory");
+  }
+
+  protected void closeMemoryLogFile() {
+    logFileWriter.close();
+  }
+
+  protected void logStatus() {
+    logFileWriter.println(getUsedMemory());
+  }
+
+  protected long getUsedMemory() {
+    Runtime runtime = Runtime.getRuntime();
+    long total = runtime.totalMemory();
+    long free = runtime.freeMemory();
+    long used = total - free;
+    return used;
+  }
+
+  protected void waitTillNoMoreMessages(JobExecutor jobExecutor) throws Exception {
+    boolean jobsAvailable = true;
+    while (jobsAvailable) {
+      log.debug("going to sleep for " + checkInterval + " millis, waiting for the job executor to process more jobs");
+      Thread.sleep(checkInterval);
+      jobsAvailable = areJobsAvailable();
+      logStatus();
+    }
+  }
+
+  public boolean areJobsAvailable() {
+    return commandService.execute(new Command<Boolean>() {
+      public Boolean execute(Environment environment) {
+        Session session = environment.get(Session.class);
+
+        Query query = session.createQuery(jobsAvailableQueryText);
+        query.setDate("now", new Date());
+        
+        Long jobs = (Long) query.uniqueResult();
+
+        if (jobs.longValue()>0) {
+          log.debug("found "+jobs+" more jobs to process");
+          return true;
+        }
+        log.debug("no more jobs to process");
+        
+        return false;
+      }
+    });
+  }
+  
+  public String getMeasuredTime() {
+    long stop = stopTime!=-1 ? stopTime : System.currentTimeMillis();
+    long diff = stop - startTime;
+    
+    long hours = diff / HOUR;
+    diff = diff - (hours * HOUR);
+    
+    long minutes = diff / MINUTE;
+    diff = diff - (minutes * MINUTE);
+    
+    long seconds = diff / SECOND;
+    
+    StringBuffer text = new StringBuffer();
+    if (hours!=0) {
+      text.append(hours+"h");
+    }
+    text.append(minutes);
+    text.append("'");
+    text.append(seconds);
+    text.append("\"");
+
+    // long millis = diff - (seconds * SECOND);
+    // text.append(","+millis);
+
+    return text.toString();
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/AutomaticActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/AutomaticActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+
+/** a activity behaviour implementation that records its execution and then 
+ * just proceeds.
+ *  
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements ActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+  
+  public AutomaticActivity() {
+  }
+  
+  public void execute(ActivityExecution execution) throws Exception {
+    ContinuationTest.recorder.record(execution.getDbid(), "execute("+execution.getActivity().getName()+")");
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ContinuationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ContinuationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ContinuationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ContinuationTest extends JobExecutorTestCase {
+
+  // private static final Log log = Log.getLog(ContinuationTest.class.getName());
+
+  static Recorder recorder = new Recorder();
+
+  int nbrOfExecutions = 100;
+
+  public void testContinuations() {
+    
+    try {
+      deployProcess();
+      startExecutions();
+      jobExecutor.start();
+      waitTillNoMoreMessages();
+
+    } finally {
+      jobExecutor.stop(true);
+    }
+
+    List<String> expectedLogs = new ArrayList<String>();
+    expectedLogs.add("execute(start)");
+    expectedLogs.add("execute(a)");
+    expectedLogs.add("execute(b)");
+    expectedLogs.add("execute(c)");
+    expectedLogs.add("execute(end)");
+    
+    assertEquals(nbrOfExecutions, recorder.executionEvents.size());
+    for (List<String> executionLogs : recorder.executionEvents.values()) {
+      assertEquals(expectedLogs, executionLogs);
+    }
+  }
+
+  public void deployProcess() {
+    commandService.execute(new Command<Object>() {
+      public Object execute(Environment environment) throws Exception {
+        OpenProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("continuations")
+          .key("continuations")
+          .startActivity("start", AutomaticActivity.class)
+            .initial()
+            .asyncExecute()
+            .transition("a")
+          .endActivity()
+          .startActivity("a", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("b")
+          .endActivity()
+          .startActivity("b", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("c")
+          .endActivity()
+          .startActivity("c", AutomaticActivity.class)
+            .asyncExecute()
+            .transition("end")
+          .endActivity()
+          .startActivity("end", WaitState.class)
+          .endActivity()
+        .endProcess();
+        
+        Session session = environment.get(Session.class);
+        session.save(processDefinition);
+        return null;
+      }
+    });
+  }
+
+  public void startExecutions() {
+    for (int i = 0; i < nbrOfExecutions; i++) {
+      executionService.startProcessInstanceByKey("continuations");
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.session.MessageSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveMessagesTest extends JobExecutorTestCase {
+
+  static Map<String, Set<Long>> exclusiveThreadIds;
+
+  static int nbrOfTestMessagesPerExecution = 5;
+  static int nbrOfTestExecutions = 20;
+
+  public void setUp() throws Exception {
+    super.setUp();
+
+    exclusiveThreadIds = new HashMap<String, Set<Long>>();
+  }
+
+  public void testExclusiveMessageProcessing() {
+    insertExclusiveTestMessages();
+
+    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+    jobExecutor.start();
+    try {
+
+      waitTillNoMoreMessages();
+
+    } finally {
+      jobExecutor.stop(true);
+    }
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) throws Exception {
+        // exclusiveMessageIds maps execution keys to a set of thread ids.
+        // the idea is that for each execution, all the exclusive jobs will
+        // be executed by 1 thread sequentially.
+
+        for (int i = 0; i < nbrOfTestExecutions; i++) {
+          String executionKey = "execution-" + i;
+          Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
+          assertNotNull("no thread id set for " + executionKey + " in: " + exclusiveThreadIds, threadIds);
+          assertEquals("exclusive messages for " + executionKey + " have been executed by multiple threads: " + threadIds, 1, threadIds.size());
+        }
+        return null;
+      }
+    });
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+
+    private static final long serialVersionUID = 1L;
+
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      execution.take(signalName);
+    }
+  }
+
+  public void insertExclusiveTestMessages() {
+    commandService.execute(new Command<Object>() {
+      public Object execute(Environment environment) throws Exception {
+        ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
+        .startProcess("excl")
+          .startActivity("wait", WaitState.class)
+            .initial()
+          .endActivity()
+        .endProcess();
+        processDefinition.setId("excl:1");
+        
+        Session session = environment.get(Session.class);
+        session.save(processDefinition);
+        return null;
+      }
+    });
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) throws Exception {
+        MessageSession messageSession = environment.get(MessageSession.class);
+        for (int i = 0; i < nbrOfTestExecutions; i++) {
+          Execution execution = new StartExecutionCmd("excl:1", null, "execution-" + i).execute(environment);
+
+          for (int j = 0; j < nbrOfTestMessagesPerExecution; j++) {
+            CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
+            messageSession.send(exclusiveTestMessage);
+          }
+        }
+        return null;
+      }
+    });
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveTestCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveTestCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveTestCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTestCommand implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(ExclusiveTestCommand.class.getName());
+  static Random random = new Random();
+  
+  long executionId;
+  
+  public ExclusiveTestCommand() {
+  }
+
+  public static CommandMessage createMessage(Execution execution) {
+    CommandMessage commandMessage = new CommandMessage();
+    commandMessage.setExecution((ExecutionImpl) execution);
+    commandMessage.setExclusive(true);
+    
+    ObjectDescriptor commandDescriptor = new ObjectDescriptor(ExclusiveTestCommand.class);
+    commandDescriptor.addInjection("executionId", new LongDescriptor(execution.getDbid()));
+    commandMessage.setCommandDescriptor(commandDescriptor);
+    return commandMessage;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Long threadId = Thread.currentThread().getId();
+    
+    Session session = environment.get(Session.class);
+    ExecutionImpl execution = (ExecutionImpl) session.get(ExecutionImpl.class, executionId);
+    
+    String executionKey = execution.getKey();
+
+    // exclusiveMessageIds maps execution keys to a set of thread ids.
+    // the idea is that for each execution, all the exclusive jobs will 
+    // be executed by 1 thread sequentially.  
+    
+    // in the end, each set should contain exactly 1 element
+    
+    Set<Long> groupMessages = ExclusiveMessagesTest.exclusiveThreadIds.get(executionKey);
+    if (groupMessages==null) {
+      groupMessages = new HashSet<Long>();
+      ExclusiveMessagesTest.exclusiveThreadIds.put(executionKey, groupMessages);
+    }
+    groupMessages.add(threadId);
+    
+    /*
+    // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+    int workTime = random.nextInt(150);
+    log.debug("executing exclusive message for "+execution+".  this is going to take "+workTime+"ms");
+    try {
+      Thread.sleep(workTime);
+    } catch (RuntimeException e) {
+      log.debug("sleeping was interrupted");
+    }
+    */
+    
+    return null;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceMessageTest extends JobExecutorTestCase {
+
+  private static final Log log = Log.getLog(FailOnceMessageTest.class.getName());
+    
+  static long nbrOfTestMessages = 50;
+  
+  static List<Integer> failOnceMessageIds = Collections.synchronizedList(new ArrayList<Integer>());
+  
+  public void testFailOnceMessages() {
+    failOnceMessageIds.clear();
+
+    jobExecutor.start();
+    try {
+      insertFailOnceTestMessages();
+      waitTillNoMoreMessages();
+
+    } finally {
+      log.debug("stopping job executor");
+      jobExecutor.stop(true);
+    }
+
+    for (int i = 0; i < nbrOfTestMessages; i++) {
+      assertTrue("message " + i + " is not failed once: " + failOnceMessageIds, failOnceMessageIds.contains(i));
+    }
+    assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
+    
+    log.debug("==== all messages processed, now checking if all messages have arrived exactly once ====");
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) throws Exception {
+        Session session = environment.get(Session.class);
+        List<Comment> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        
+        for (Comment comment : comments) {
+          log.debug("retrieved message: "+comment.getMessage());
+          Integer messageId = new Integer(comment.getMessage());
+          assertTrue("message " + messageId + " committed twice", failOnceMessageIds.remove(messageId));
+        }
+
+        assertTrue("not all messages made a successful commit: " + failOnceMessageIds, failOnceMessageIds.isEmpty());
+        return null;
+      }
+    });
+  }
+
+  public static class InsertFailOnceTestMsgCmd implements Command<Object> {
+    private static final long serialVersionUID = 1L;
+    int i;
+    public InsertFailOnceTestMsgCmd(int i) {
+      this.i = i;
+    }
+    public Object execute(Environment environment) throws Exception {
+      MessageSession messageSession = environment.get(MessageSession.class);
+      CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
+      messageSession.send(commandMessage);
+      return null;
+    }
+  }
+
+  void insertFailOnceTestMessages() {
+    for (int i = 0; i < nbrOfTestMessages; i++) {
+      commandService.execute(new InsertFailOnceTestMsgCmd(i));
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceTestCommand implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = Log.getLog(FailOnceTestCommand.class.getName());
+  
+  int messageId;
+  
+  public FailOnceTestCommand() {
+  }
+
+  public static CommandMessage createMessage(int messageId) {
+    CommandMessage commandMessage = new CommandMessage();
+    ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailOnceTestCommand.class);
+    commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
+    commandMessage.setCommandDescriptor(commandDescriptor);
+    return commandMessage;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+
+    // this message execution should be rolled back
+    Comment comment = new CommentImpl(Integer.toString(messageId));
+    dbSession.save(comment);
+
+    if (!FailOnceMessageTest.failOnceMessageIds.contains(messageId)) {
+      // registering the failed message in a non-transactional resource
+      // so the messageId will still be added even after the transaction has rolled back
+      log.debug("adding failonce message "+messageId);
+      FailOnceMessageTest.failOnceMessageIds.add(messageId);
+      
+      throw new RuntimeException("failing once"); 
+    }
+    
+    try {
+      Thread.sleep(700);
+    } catch (Exception e) {
+      log.error(e.toString());
+    }
+
+    log.debug("message "+messageId+" now succeeds");
+
+    return null;
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Job;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingMessageTest extends JobExecutorTestCase {
+
+  
+  public void testFailedMessageProcessing() {
+    jobExecutor.start();
+    try {
+      commandService.execute(new Command<Object>() {
+
+        public Object execute(Environment environment) throws Exception {
+          MessageSession messageSession = environment.get(MessageSession.class);
+          CommandMessage commandMessage = FailingTestCommand.createMessage();
+          messageSession.send(commandMessage);
+          return null;
+        }
+      });
+
+      waitTillNoMoreMessages();
+
+    } finally {
+      jobExecutor.stop(true);
+    }
+
+    commandService.execute(new Command<Object>() {
+
+      public Object execute(Environment environment) throws Exception {
+        PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+        List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
+        assertEquals("there should be one dead job", 1, deadJobs.size());
+
+        Session session = environment.get(Session.class);
+        List commands = session.createQuery("from " + CommentImpl.class.getName()).list();
+        assertTrue("command insertion should have been rolled back", commands.isEmpty());
+        return null;
+      }
+    });
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingTestCommand implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public Object execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    
+    // this message execution should be rolled back
+    Comment comment = new CommentImpl("failing update");
+    dbSession.save(comment);
+    
+    throw new RuntimeException("ooops"); 
+  }
+
+  public static CommandMessage createMessage() {
+    CommandMessage commandMessage = new CommandMessage();
+    ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailingTestCommand.class);
+    commandMessage.setCommandDescriptor(commandDescriptor);
+    return commandMessage;
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/GenerateExceptionTestCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/GenerateExceptionTestCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/GenerateExceptionTestCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ * 
+ * Simple command that will create an exception during execution. 
+ * The exception will generate a stacktrace with variable length 
+ * (controlled by the length parameter).
+ * 
+ * This class is to test the persistence of exception stacktrace in jobs.
+ */
+public class GenerateExceptionTestCommand implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  int length;
+  
+  public GenerateExceptionTestCommand() {
+  }
+  
+  public static CommandMessage createMessage(int recursionInitialDepth) {
+    CommandMessage commandMessage = new CommandMessage();
+    ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
+    commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
+    commandMessage.setCommandDescriptor(commandDescriptor);
+    return commandMessage;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    StringBuilder stringBuilder = new StringBuilder();
+    while (stringBuilder.length() < length) {
+      stringBuilder.append("This is a long test message. ");
+    }
+    throw new RuntimeException(stringBuilder.toString());
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/JobExecutorTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/JobExecutorTestCase.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/JobExecutorTestCase.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorTestCase extends JbpmTestCase {
+
+  long timeoutMillis = 20 * 1000; // 20 seconds
+  long checkInterval = 400;
+
+  static String jobsAvailableQueryText =
+      "select count(*) "+
+      "from "+JobImpl.class.getName()+" as job "+
+      "where ( (job.dueDate is null) or (job.dueDate <= :now) ) "+ 
+      "  and ( job.retries > 0 )";
+
+  protected CommandService commandService;
+  protected JobExecutor jobExecutor;
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    
+    commandService = processEngine.get(CommandService.class);
+    jobExecutor = processEngine.get(JobExecutor.class);
+  }
+  
+  protected void waitTillNoMoreMessages() {
+
+    // install a timer that will interrupt if it takes too long
+    // if that happens, it will lead to an interrupted exception and the test
+    // will fail
+    TimerTask interruptTask = new TimerTask() {
+
+      Thread testThread = Thread.currentThread();
+
+      public void run() {
+        log.debug("test " + getName() + " took too long. going to interrupt..." + testThread);
+        testThread.interrupt();
+      }
+    };
+    Timer timer = new Timer();
+    timer.schedule(interruptTask, timeoutMillis);
+
+    try {
+      boolean jobsAvailable = true;
+      while (jobsAvailable) {
+        log.debug("going to sleep for " + checkInterval + " millis, waiting for the job executor to process more jobs");
+        Thread.sleep(checkInterval);
+        jobsAvailable = areJobsAvailable();
+      }
+
+    } catch (InterruptedException e) {
+      fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
+    } finally {
+      timer.cancel();
+    }
+  }
+
+  public boolean areJobsAvailable() {
+    return commandService.execute(new Command<Boolean>() {
+      public Boolean execute(Environment environment) {
+        Session session = environment.get(Session.class);
+
+        Query query = session.createQuery(jobsAvailableQueryText);
+        query.setDate("now", new Date());
+        
+        Long jobs = (Long) query.uniqueResult();
+
+        if (jobs.longValue()>0) {
+          log.debug("found "+jobs+" more jobs to process");
+          return true;
+        }
+        log.debug("no more jobs to process");
+        
+        return false;
+      }
+    });
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.Random;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NormalMessageCommand implements Command<Void>  {
+  
+  private static final long serialVersionUID = 1L;
+  static Random random = new Random();
+  
+  int messageId;
+  
+  public NormalMessageCommand() {
+  }
+  
+  public NormalMessageCommand(int messageId) {
+    this.messageId = messageId;
+  }
+
+  public static CommandMessage createMessage(int messageId) {
+    CommandMessage commandMessage = new CommandMessage();
+    ObjectDescriptor commandDescriptor = new ObjectDescriptor(NormalMessageCommand.class);
+    commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
+    commandMessage.setCommandDescriptor(commandDescriptor);
+    return commandMessage;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    CommentImpl comment = new CommentImpl(Integer.toString(messageId));
+    Session session = environment.get(Session.class);
+    session.save(comment);
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.test.Db;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NormalMessageTest extends JobExecutorTestCase {
+
+  static long nbrOfTestMessages = 100;   
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    Db.clean(processEngine);
+  }
+
+  public void testNormalMessageProcessing() {
+    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+    jobExecutor.start();
+
+    try {
+      // insert ${nbrOfTestMessages} messages... 
+      for (int i = 0; i < nbrOfTestMessages; i++) {
+        commandService.execute(new InsertNormalMessageCmd(i));
+      }
+
+      // wait till all messages are processed
+      waitTillNoMoreMessages();
+
+    } finally {
+      jobExecutor.stop(true);
+    }
+    
+    List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
+      public List<Integer> execute(Environment environment) {
+        List<Integer> processedMessageNumbers = new ArrayList<Integer>();
+        Session session = environment.get(Session.class);
+        List<Comment> comments = session.createCriteria(CommentImpl.class).list();
+        for (Comment comment: comments) {
+          int processedMessageNumber = Integer.parseInt(comment.getMessage());
+          processedMessageNumbers.add(processedMessageNumber);
+          // make sure the db stays clean
+          session.delete(comment);
+        }
+        return processedMessageNumbers;
+      }
+    });
+    
+    for (int i = 0; i < nbrOfTestMessages; i++) {
+      assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
+    }
+  }
+  
+  public static class InsertNormalMessageCmd implements Command<Object> {
+    private static final long serialVersionUID = 1L;
+    int i;
+    public InsertNormalMessageCmd(int i) {
+      this.i = i;
+    }
+    public Object execute(Environment environment) throws Exception {
+      MessageSession messageSession = environment.get(MessageSession.class);
+      CommandMessage commandMessage = NormalMessageCommand.createMessage(i);
+      messageSession.send(commandMessage);
+      return null;
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/Recorder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/Recorder.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/Recorder.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** 
+ * @author Tom Baeyens
+ */
+public class Recorder {
+
+  public Map<Object, List<String>> executionEvents = null;
+  
+  public synchronized void record(long executionDbid, String event) {
+    if (executionEvents==null) {
+      executionEvents = new HashMap<Object, List<String>>();
+    }
+    List<String> events = executionEvents.get(executionDbid);
+    if (events == null) {
+      events = new ArrayList<String>();
+      executionEvents.put(executionDbid, events);
+    }
+    events.add(event); 
+  }
+  
+  public void reset() {
+    executionEvents = null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.async;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+  
+  public WaitState() {
+  }
+
+  public void execute(ActivityExecution execution) throws Exception {
+    ContinuationTest.recorder.record(execution.getDbid(), "execute("+execution.getActivity().getName()+")");
+  }
+
+  public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+    throw new UnsupportedOperationException();
+  }
+}
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/Automatic.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/Automatic.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/Automatic.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.executions;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Automatic {
+
+  public void doNothing() {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/ProcessExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/ProcessExecutionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/executions/ProcessExecutionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.executions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.internal.log.Log;
+import org.jbpm.test.load.LoadTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessExecutionTest extends LoadTestCase {
+  
+  private static Log log = Log.getLog(ProcessExecutionTest.class.getName());
+  
+  static int processes = 1000;
+  static int threads = 5;
+  
+  Throwable exception;
+  int finished;
+
+  public void logStatus() {
+    String measuredTime = getMeasuredTime();
+    logFileWriter.println(getUsedMemory()+"\t"+finished+"\t"+measuredTime);
+    logFileWriter.flush();
+    log.info(finished+" executions in "+measuredTime);
+  }
+  
+  protected void logColumnTitles() {
+    logFileWriter.println("Used Memory\tFinished Executions\tTime");
+    logFileWriter.flush();
+  }
+
+  public void testExecuteProcesses() throws Exception {
+    deployJpdlResource("org/jbpm/test/load/executions/process.jpdl.xml");
+    
+    startMeasuringTime();
+    
+    List<Thread> threadList = new ArrayList<Thread>();
+    for (int i=0; i<threads; i++) {
+      Thread thread = new ProcessExecutor();
+      thread.start();
+      threadList.add(thread);
+    }
+    
+    
+    for (Thread thread: threadList) {
+      while (thread.isAlive()) {
+        try {
+          thread.join(checkInterval);
+        } catch (InterruptedException e) {
+          log.info(e.toString());
+        }
+        logStatus();
+      }
+      if (exception!=null) {
+        break;
+      }
+    }
+    
+    if (exception!=null) {
+      throw new Exception("thread threw: "+exception.getMessage(), exception);
+    } else {
+      log.info(finished+" executions in "+getMeasuredTime());
+    }
+  }
+  
+  public class ProcessExecutor extends Thread {
+    public void run() {
+      try {
+        for (int i=0; i<processes; i++) {
+          executeProcess();
+        }
+      } catch (Throwable t) {
+        exception = t;
+      }
+    }
+    public void executeProcess() {
+      Execution execution = executionService.startProcessInstanceByKey("Process");
+      assertEquals("c", execution.getActivityName());
+      String executionId = execution.getId();
+      execution = executionService.signalExecutionById(executionId);
+      assertTrue(execution.isEnded());
+      processFinished();
+    }
+  }
+
+  public synchronized void processFinished() {
+    finished++;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.messages;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddCommentCmd implements Command<Void>  {
+  
+  private static final long serialVersionUID = 1L;
+  
+  protected String message;
+
+  public Void execute(Environment environment) throws Exception {
+    CommentImpl comment = new CommentImpl(message);
+    Session session = environment.get(Session.class);
+    session.save(comment);
+    MessageProcessingTest.commentAdded();
+    return null;
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.load.messages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.CompositeCmd;
+import org.jbpm.pvm.internal.cmd.SendMessageCmd;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.test.load.LoadTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class MessageProcessingTest extends LoadTestCase {
+
+  private static final Log log = Log.getLog(MessageProcessingTest.class.getName());
+
+  static long nbrOfTestMessages = 1000; // nbrOfTestMessages must be dividable by insertGroupSize  
+  static long insertGroupSize = 100;
+
+  static int commentsAdded = 0;
+  
+  public static synchronized void commentAdded() {
+    commentsAdded++;
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    
+    if ( (nbrOfTestMessages % insertGroupSize) != 0 ) {
+      fail("nbrOfTestMessages ("+nbrOfTestMessages+") is not dividable by insertGroupSize ("+insertGroupSize+")");
+    }
+  }
+  
+  protected void logColumnTitles() {
+    logFileWriter.println("Used Memory\tProcessed Messages\tTime");
+  }
+
+  public void logStatus() {
+    String measuredTime = getMeasuredTime();
+    logFileWriter.println(getUsedMemory()+"\t"+commentsAdded+"\t"+measuredTime);
+    logFileWriter.flush();
+    log.info(commentsAdded+" msgs in "+measuredTime);
+  }
+  
+  public void testMessageProcessing() throws Exception {
+    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+    
+    try {
+      int messageIndex = 0;
+      // insert ${nbrOfTestMessages} messages... 
+      for (int i = 0; i < nbrOfTestMessages; i+=insertGroupSize) {
+        CompositeCmd compositeCmd = new CompositeCmd();
+        // ...in groups of ${insertGroupSize}
+        for (int j = 0; j <insertGroupSize ; j++) {
+          String messageText = Integer.toString(messageIndex);
+          
+          ObjectDescriptor cmdDescriptor = new ObjectDescriptor(AddCommentCmd.class);
+          cmdDescriptor.addInjection("message", new StringDescriptor(messageText));
+          CommandMessage commandMessage = new CommandMessage(cmdDescriptor);
+          SendMessageCmd sendMessageCmd = new SendMessageCmd(commandMessage);
+          
+          compositeCmd.addCommand(sendMessageCmd);
+          
+          messageIndex++;
+        }
+        commandService.execute(compositeCmd);
+        
+        log.info("added "+messageIndex+" messages");
+      }
+
+      startMeasuringTime();
+      
+      jobExecutor.start();
+
+      // wait till all messages are processed
+      waitTillNoMoreMessages(jobExecutor);
+
+    } finally {
+      stopMeasuringTime();
+      
+      jobExecutor.stop(true);
+    }
+    
+    log.info("processing "+nbrOfTestMessages+" messages took "+getMeasuredTime());
+
+    List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
+      public List<Integer> execute(Environment environment) {
+        List<Integer> processedMessageNumbers = new ArrayList<Integer>();
+        Session session = environment.get(Session.class);
+        List<Comment> comments = session.createCriteria(CommentImpl.class).list();
+        for (Comment comment: comments) {
+          int processedMessageNumber = Integer.parseInt(comment.getMessage());
+          processedMessageNumbers.add(processedMessageNumber);
+          // make sure the db stays clean
+          session.delete(comment);
+        }
+        return processedMessageNumbers;
+      }
+    });
+    
+    for (int i = 0; i < nbrOfTestMessages; i++) {
+      assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
+    }
+  }
+  
+}

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.cfg.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+  <process-engine-context>
+  
+    <deployer-manager>
+      <assign-file-type>
+        <file extension=".jpdl.xml" type="jpdl" />
+      </assign-file-type>
+      <parse-jpdl />
+      <check-process />
+      <check-problems />
+      <save />
+    </deployer-manager>
+    
+    <process-service />
+    <execution-service />
+    <management-service />
+  
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+      <standard-transaction-interceptor />
+    </command-service>
+    
+    <hibernate-configuration resource="hibernate.cfg.xml">      
+      <cache-configuration resource="jbpm.pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    
+    <job-executor auto-start="false" />
+    <job-test-helper />
+
+    <id-generator />
+    <types resource="jbpm.pvm.types.xml" />
+
+    <business-calendar>
+      <monday    hours="9:00-12:00 and 12:30-17:00"/>
+      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
+      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
+      <friday    hours="9:00-12:00 and 12:30-17:00"/>
+      <holiday period="01/07/2008 - 31/08/2008"/>
+    </business-calendar>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session />
+    <transaction />
+    <pvm-db-session />
+    <job-db-session />
+    <message-session />
+    <timer-session />
+  </transaction-context>
+
+</jbpm-configuration>

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.load.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.load.hbm.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/jbpm.load.hbm.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC
+      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+	<subclass name="org.jbpm.test.load.AddCommentMessage" 
+         extends="org.jbpm.pvm.internal.job.MessageImpl" 
+         discriminator-value="AddMsg">
+  </subclass>
+  
+</hibernate-mapping>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,33 @@
+handlers=java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging=enabled
+
+java.util.logging.ConsoleHandler.level=FINEST
+java.util.logging.ConsoleHandler.formatter=org.jbpm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+# org.jbpm.pvm.internal.model.level=FINE
+# org.jbpm.pvm.internal.model.op.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.jbpm.test.load.level=INFO
+
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.level=FINE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.transaction.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST

Added: jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/executions/process.jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/executions/process.jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/resources/org/jbpm/test/load/executions/process.jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Process" xmlns="http://jbpm.org/4/jpdl">
+
+  <start>
+    <transition to="a" />
+  </start>
+
+  <java name="a" 
+        class="org.jbpm.test.load.executions.Automatic"
+        method="doNothing">
+    <transition to="b" />
+  </java>
+  
+  <java name="b" 
+        class="org.jbpm.test.load.executions.Automatic"
+        method="doNothing">
+    <transition to="c" />
+  </java>
+  
+  <state name="c">
+    <transition to="d" />
+  </state>
+
+  <java name="d" 
+        class="org.jbpm.test.load.executions.Automatic"
+        method="doNothing">
+    <transition to="e" />
+  </java>
+  
+  <java name="e" 
+        class="org.jbpm.test.load.executions.Automatic"
+        method="doNothing">
+    <transition to="end" />
+  </java>
+  
+  <end name="end" />
+  
+</process>

Added: jbpm4/branches/tbaeyens/modules/test-pojo/.classpath
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/.classpath	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/.classpath	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+  <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+  <classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: jbpm4/branches/tbaeyens/modules/test-pojo/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>test-pojo</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/test-pojo/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3560 2008-12-27 13:20:00Z tom.baeyens at jboss.com $ -->
+<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>
+  <name>jBPM 4 - Test POJO</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-test-pojo</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <!-- Dependencies -->
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+
+    <!-- TODO remove this once process factory api is complete -->
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+  </dependencies>
+  
+  <!-- Plugins -->
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <testSourceDirectory>src/main/java</testSourceDirectory>
+          <classesDirectory>target/classes</classesDirectory>
+          <testClassesDirectory>target/classes</testClassesDirectory>        
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements ActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/** shows an automatic decision.
+ * 
+ * @author Tom Baeyens
+ */
+public class AutomaticDecisionTest extends BaseJbpmTestCase {
+
+  public static class AutomaticCreditRating implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      int creditRate = (Integer) execution.getVariable("creditRate");
+      
+      if (creditRate > 5) {
+        execution.take("good");
+
+      } else if (creditRate < -5) {
+        execution.take("bad");
+        
+      } else {
+        execution.take("average");
+      }
+    }
+  }
+  
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+
+  public static ClientProcessDefinition createCreditProcess() {
+    return ProcessDefinitionBuilder.startProcess()
+      .startActivity("creditRate?", new AutomaticCreditRating())
+        .initial()
+        .transition("priority delivery", "good")
+        .transition("bulk delivery", "average")
+        .transition("payment upfront", "bad")
+      .endActivity()
+      .startActivity("priority delivery", new WaitState())
+      .endActivity()
+      .startActivity("bulk delivery", new WaitState())
+      .endActivity()
+      .startActivity("payment upfront", new WaitState())
+      .endActivity()
+    .endProcess();
+  }
+
+  public void testGoodRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", 7);
+    execution.start();
+
+    assertEquals("priority delivery", execution.getActivity().getName());
+  }
+
+  public void testAverageRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", 2);
+    execution.start();
+
+    assertEquals("bulk delivery", execution.getActivity().getName());
+  }
+  
+  public void testBadRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", -7);
+    execution.start();
+
+    assertEquals("payment upfront", execution.getActivity().getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,169 @@
+/*
+  * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/** shows wait states and automatic activities in a simple 
+ * sequence based on transitions.
+ * 
+ * @author Tom Baeyens
+ */
+public class BasicExecutionFlowTest extends BaseJbpmTestCase {
+  
+  // automatic activity will log an event in a given list
+  
+  public static class AutomaticActivity implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public AutomaticActivity(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      events.add("execute["+execution.getActivityName()+"]");
+    }
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public WaitState(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      events.add("execute["+execution.getActivityName()+"]");
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      events.add("signal["+execution.getActivityName()+"]");
+      execution.take(signalName);
+    }
+  }
+
+  public void testChainOfAutomaticActivitiesAndWaitStates() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
+    WaitState waitState = new WaitState(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("loan")
+      .startActivity("submit loan request", automaticActivity)
+        .initial()
+        .transition("evaluate")
+      .endActivity()
+      .startActivity("evaluate", waitState)
+        .transition("wire money", "approve")
+        .transition("end", "reject")
+      .endActivity()
+      .startActivity("wire money", automaticActivity)
+        .transition("archive")
+      .endActivity()
+      .startActivity("archive", waitState)
+        .transition("end")
+      .endActivity()
+      .startActivity("end", waitState)
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    
+    expectedEvents.add("execute[submit loan request]");
+    expectedEvents.add("execute[evaluate]");
+
+    assertEquals("evaluate", execution.getActivityName());
+    assertEquals(expectedEvents, recordedEvents);
+
+    execution.signal("approve");
+
+    expectedEvents.add("signal[evaluate]");
+    expectedEvents.add("execute[wire money]");
+    expectedEvents.add("execute[archive]");
+
+    assertEquals("archive", execution.getActivityName());
+    assertEquals(expectedEvents, recordedEvents);
+
+    execution.signal();
+
+    expectedEvents.add("signal[archive]");
+    expectedEvents.add("execute[end]");
+
+    assertEquals("end", execution.getActivityName());
+    assertEquals(expectedEvents, recordedEvents);
+  }
+  
+  public void testDelayedBegin() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
+    WaitState waitState = new WaitState(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("loan")
+      .startActivity("submit loan request", automaticActivity)
+        .initial()
+        .transition("evaluate")
+      .endActivity()
+      .startActivity("evaluate", waitState)
+        .transition("wire money", "approve")
+        .transition("end", "reject")
+      .endActivity()
+      .startActivity("wire money", automaticActivity)
+        .transition("archive")
+      .endActivity()
+      .startActivity("archive", waitState)
+        .transition("end")
+      .endActivity()
+      .startActivity("end", waitState)
+      .endActivity()
+    .endProcess();
+  
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    // here, inbetween create and start of a process instance, the variables can be initialized  
+    // or subprocessinstance-superprocessinstance relation can be set up
+
+    // so we verify that the process execution didn't start yet
+    List<String> expectedEvents = new ArrayList<String>();
+    assertEquals(expectedEvents, recordedEvents);
+    
+    processInstance.start();
+
+    expectedEvents.add("execute[submit loan request]");
+    expectedEvents.add("execute[evaluate]");
+
+    assertEquals("evaluate", processInstance.getActivityName());
+    assertEquals(expectedEvents, recordedEvents);
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,405 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Event;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventPropagationTest extends BaseJbpmTestCase {
+  
+  public class Recorder implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public List<Object> events = new ArrayList<Object>();
+    public void notify(EventListenerExecution execution) {
+      ObservableElement eventSource = execution.getEventSource();
+      events.add(execution.getEvent()+" on "+eventSource);
+    }
+  }
+  
+  public static class FireableState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.fire(signalName, execution.getActivity());
+    }
+  }
+
+  public void testListenToActivityLeaveOnProcessForProcessActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.END) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(end) on activity(initial)", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  public void testListenToActivityEnterOnProcessForProcessActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.START) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(start) on process(propagate)", recorder.events.get(0));
+    assertEquals("event(start) on activity(end)", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+  }
+
+  public void testListenToTransitionOnProcessForTransitionBetweenProcessActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.TAKE) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end", "go")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(take) on (initial)--go-->(end)", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  // propagation of process elements in composite activities ///////////////////////
+  
+  public static class Sequence implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      List<Activity> activities = execution.getActivity().getActivities();
+      if ( (activities!=null)
+           && (!activities.isEmpty())
+         ) {
+        execution.execute(activities.get(0));
+      }
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) {
+      Activity previous = execution.getPreviousActivity();
+      List<Activity> activities = execution.getActivity().getActivities();
+      int index = activities.indexOf(previous);
+      index++;
+      if (index < activities.size()) {
+        Activity next = activities.get(index);
+        execution.execute(next);
+      }
+    }
+  }
+
+  
+  public void testListenToActivityLeaveOnProcessForSequenceChildActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.END) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("sequence", new Sequence())
+        .initial()
+        .needsPrevious()
+        .startActivity("one", new WaitState())
+        .endActivity()
+        .startActivity("two", new WaitState())
+        .endActivity()
+        .startActivity("three", new WaitState())
+        .endActivity()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(end) on activity(one)", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+    execution.signal();
+    assertEquals("event(end) on activity(two)", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+    execution.signal();
+    assertEquals("event(end) on activity(three)", recorder.events.get(2));
+    assertEquals("event(end) on process(propagate)", recorder.events.get(3));
+    assertEquals(recorder.events.toString(), 4, recorder.events.size());
+  }
+
+  public void testListenToActivityLeaveOnProcessForTransitionBetweenSequenceChildActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.END) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("sequence", new Sequence())
+        .initial()
+        .startActivity("one", new WaitState())
+          .transition("two")
+        .endActivity()
+        .startActivity("two", new WaitState())
+        .endActivity()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(end) on activity(one)", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+    execution.signal();
+    assertEquals("event(end) on activity(two)", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+  }
+
+
+  public void testListenToActivityEnterOnProcessForSequenceChildActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.START) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("sequence", new Sequence())
+        .initial()
+        .needsPrevious()
+        .startActivity("one", new WaitState())
+        .endActivity()
+        .startActivity("two", new WaitState())
+        .endActivity()
+        .startActivity("three", new WaitState())
+        .endActivity()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    List<Object> expectedEvents = new ArrayList<Object>();
+    expectedEvents.add("event(start) on process(propagate)");
+    expectedEvents.add("event(start) on activity(one)");
+    assertEquals(expectedEvents, recorder.events);
+    
+    execution.signal();
+
+    expectedEvents.add("event(start) on activity(two)");
+    assertEquals(expectedEvents, recorder.events);
+
+    execution.signal();
+    
+    expectedEvents.add("event(start) on activity(three)");
+    assertEquals(expectedEvents, recorder.events);
+  }
+
+  public void testListenToTransitionTakeOnProcessForTransitionBetweenSequenceChildActivities(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent(Event.TAKE) 
+        .listener(recorder, true)
+      .endEvent()
+      .startActivity("sequence", new Sequence())
+        .initial()
+        .startActivity("one", new WaitState())
+          .transition("two", "increment")
+        .endActivity()
+        .startActivity("two", new WaitState())
+        .endActivity()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(take) on (one)--increment-->(two)", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  public void testDeeplyNestedCustomEvent(){
+    Recorder processRecorder = new Recorder();
+    Recorder outerRecorder = new Recorder();
+    Recorder middelRecorder = new Recorder();
+    Recorder innerRecorder = new Recorder();
+    Recorder nestedStateRecorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent("hello") 
+        .listener(processRecorder, true)
+      .endEvent()
+      .startActivity("outer", new Sequence())
+        .initial()
+        .startEvent("hello") 
+          .listener(outerRecorder, true)
+        .endEvent()
+        .startActivity("middel", new Sequence())
+          .startEvent("hello") 
+            .listener(middelRecorder, true)
+          .endEvent()
+          .startActivity("inner", new Sequence())
+            .startEvent("hello") 
+              .listener(innerRecorder, true)
+            .endEvent()
+            .startActivity("nested state", new FireableState())
+              .startEvent("hello") 
+                .listener(nestedStateRecorder, true)
+              .endEvent()
+            .endActivity()
+          .endActivity()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals(0, processRecorder.events.size());
+    execution.signal("hello");
+    
+    assertEquals("event(hello) on activity(nested state)", processRecorder.events.get(0));
+    assertEquals(1, processRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", outerRecorder.events.get(0));
+    assertEquals(1, outerRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", middelRecorder.events.get(0));
+    assertEquals(1, middelRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", innerRecorder.events.get(0));
+    assertEquals(1, innerRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", nestedStateRecorder.events.get(0));
+    assertEquals(1, nestedStateRecorder.events.size());
+  }
+
+  public void testPropagatedEventsDisabled(){
+    Recorder processRecorder = new Recorder();
+    Recorder outerRecorder = new Recorder();
+    Recorder middleRecorder = new Recorder();
+    Recorder innerRecorder = new Recorder();
+    Recorder nestedStateRecorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("propagate")
+      .startEvent("hello") 
+        .listener(processRecorder, true)
+      .endEvent()
+      .startActivity("outer", new Sequence())
+        .initial()
+        .startEvent("hello") 
+          .listener(outerRecorder, true)
+        .endEvent()
+        .startActivity("middle", new Sequence())
+          .startEvent("hello") 
+            .listener(middleRecorder)
+          .endEvent()
+          .startActivity("inner", new Sequence())
+            .startEvent("hello") 
+              .listener(innerRecorder, true)
+            .endEvent()
+            .startActivity("nested state", new FireableState())
+              .startEvent("hello") 
+                .listener(nestedStateRecorder)
+              .endEvent()
+            .endActivity()
+          .endActivity()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    // the middle action should not be executed for an event that was propagated from the nested state 
+    execution.signal("hello");
+    
+    assertEquals("event(hello) on activity(nested state)", processRecorder.events.get(0));
+    assertEquals(1, processRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", outerRecorder.events.get(0));
+    assertEquals(1, outerRecorder.events.size());
+
+    assertEquals(0, middleRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", innerRecorder.events.get(0));
+    assertEquals(1, innerRecorder.events.size());
+
+    assertEquals("event(hello) on activity(nested state)", nestedStateRecorder.events.get(0));
+    assertEquals(1, nestedStateRecorder.events.size());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.model.Activity;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/** shows how actions are listeners to following processDefinition events:
+ * <ul>
+ *   <li>activity-leave</li>
+ *   <li>transition</li>
+ *   <li>activity-enter</li>
+ *   <li>custom event</li>
+ * </ul>
+ *
+ * @author Tom Baeyens
+ */
+public class EventTest extends BaseJbpmTestCase {
+  
+  // activity leave action ////////////////////////////////////////////////////////
+  
+  public static class ActivityEndAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      execution.setVariable("msg", "Kilroy was here");
+
+      assertEquals("initial", execution.getActivity().getName());
+      assertEquals("initial", execution.getEventSource().getName());
+      assertEquals("leave activity action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnActivityEnd() {
+    ActivityEndAction activityEndAction = new ActivityEndAction();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("leave activity action test")
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .listener(activityEndAction)
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    execution.signal();
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // transition action ////////////////////////////////////////////////////////
+
+  public static class TransitionAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertNull(execution.getActivity());
+      assertEquals("t", execution.getEventSource().getName());
+      assertEquals("transition action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnTransition() {
+    TransitionAction transitionAction = new TransitionAction();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("transition action test")
+      .startActivity("initial", new WaitState())
+        .initial()
+        .startFlow("end")
+          .name("t")
+          .listener(transitionAction)
+        .endFlow()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    execution.signal("t");
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // activity enter action ////////////////////////////////////////////////////////
+
+  public static class ActivityStartAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertEquals("end", execution.getActivity().getName());
+      assertEquals("end", execution.getEventSource().getName());
+      assertEquals("enter activity action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnActivityStart() {
+    ActivityStartAction activityBeginAction = new ActivityStartAction();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("enter activity action test")
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+        .startEvent(Event.START)
+          .listener(activityBeginAction)
+        .endEvent()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    execution.signal();
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // custom event ////////////////////////////////////////////////////////////
+  
+  public static class WaitStateWithCustomEvent implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+      Activity activity = execution.getActivity();
+      if ( (signal!=null)
+           && (activity!=null)
+           && (activity.hasEvent(signal))
+         ) {
+        execution.fire(signal, activity);
+        execution.waitForSignal();
+      }
+    }
+  }
+
+  public static class CheckRivetsAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertEquals("initial", execution.getActivity().getName());
+      assertEquals("initial", execution.getEventSource().getName());
+      assertEquals("custom activity action test", execution.getProcessDefinition().getName());
+      assertNull(execution.getTransition());
+    }
+  }
+
+  public void testCustomEventInActivity() {
+    CheckRivetsAction checkRivetsAction = new CheckRivetsAction();
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("custom activity action test")
+      .startActivity("initial", new WaitStateWithCustomEvent())
+        .initial()
+        .transition("end")
+        .startEvent("end of riveter shift") // http://en.wikipedia.org/wiki/Kilroy_was_here
+          .listener(checkRivetsAction)
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertNull(execution.getVariable("msg"));
+
+    execution.signal("end of riveter shift");
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+    
+    execution.signal();
+
+    assertEquals("end", execution.getActivity().getName());
+  }
+
+  public static class EndState implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.end();
+    }
+  }
+
+  public static class RecordingProcessDefinition extends ProcessDefinitionImpl {
+    private static final long serialVersionUID = 1L;
+    protected ExecutionImpl newProcessInstance() {
+      return new RecordingExecution();
+    }
+  }
+  
+  public static class RecordingExecution extends ExecutionImpl {
+    private static final long serialVersionUID = 1L;
+    List<String> events = new ArrayList<String>();
+    public void fire(String eventName, ObservableElement eventSource) {
+      events.add(eventName+" on "+eventSource);
+    }
+  }
+  
+  public void testBasicEventSequence() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("basic", new RecordingProcessDefinition())
+      .startActivity("initial", new AutomaticActivity())
+        .initial()
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new EndState())
+      .endActivity()
+    .endProcess();
+
+    RecordingExecution execution = (RecordingExecution) processDefinition.startProcessInstance();
+
+    int index = 0;
+    assertEquals("start on process(basic)", execution.events.get(index));
+    index++;
+    assertEquals("end on activity(initial)", execution.events.get(index));
+    index++;
+    assertEquals("take on (initial)-->(end)", execution.events.get(index));
+    index++;
+    assertEquals("start on activity(end)", execution.events.get(index));
+    index++;
+    assertEquals("end on process(basic)", execution.events.get(index));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,277 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExceptionHandlerTest extends BaseJbpmTestCase
+{
+  
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+    }
+  }
+
+  public static class Catcher implements EventListener {
+    private static final long serialVersionUID = 1L;
+    int timesInvoked = 0;
+    public void notify(EventListenerExecution execution) {
+      timesInvoked++;
+    }
+  }
+
+  public static class Batter implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      throw new RuntimeException("catch me");
+    }
+  }
+  
+  public void testExceptionHandlerOnProcessDefinition() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startExceptionHandler(RuntimeException.class)
+        .listener(catcher)
+      .endExceptionHandler()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getActivity().getName());
+  }
+
+  public void testExceptionHandlerOnEvent() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .startExceptionHandler(RuntimeException.class)
+            .listener(catcher)
+          .endExceptionHandler()
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getActivity().getName());
+  }
+
+  public void testExceptionHandlerOnAction() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .listener(new Batter())
+          .startExceptionHandler(RuntimeException.class)
+            .listener(catcher)
+          .endExceptionHandler()
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getActivity().getName());
+  }
+
+  public void testExceptionHandlerOnOtherActivity() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial",new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+        .startExceptionHandler(RuntimeException.class)
+          .listener(catcher)
+        .endExceptionHandler()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    assertEquals(0, catcher.timesInvoked);
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public void testExceptionHandlerOnOtherEvent() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent("other")
+          .startExceptionHandler(RuntimeException.class)
+            .listener(catcher)
+          .endExceptionHandler()
+        .endEvent()
+        .startEvent(Event.END)
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public static class BehavedAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      // behaving.  not throwing any exception
+    }
+  }
+
+  public void testUnmatchedExceptionHandlerOnAction() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .startExceptionHandler(NullPointerException.class)
+            .listener(catcher)
+          .endExceptionHandler()
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("initial", execution.getActivity().getName());
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public static class RethrowingCatcher implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      // this exception handler will itself throw an exception
+      throw new RuntimeException("greetz from the retrhowing catcher");
+    }
+  }
+
+
+  public void testRethrowingExceptionHandler() {
+    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("initial", new WaitState())
+        .initial()
+        .transition("end")
+        .startEvent(Event.END)
+          .startExceptionHandler(RuntimeException.class)
+            .listener(rethrowingCatcher)
+          .endExceptionHandler()
+          .listener(new Batter())
+        .endEvent()
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/** shows the basics of the state property on the execution.
+ * 
+ * The state is automatically managed by the execution.
+ * An execution can only receive external triggers in case it is in 
+ * the active state.  
+ * 
+ * Nested executions can occur in case of scoped executions
+ * and in case of concurrent executions.  In both cases, only 
+ * leave executions in the execution hierarchy are active.
+ * 
+ * Executions are either locked or active.  So in any state which 
+ * is not active, the execution is locked and cannot accept external 
+ * signals.  Executions can be ended in 3 ways:
+ * 
+ *  1) with execution.end() : then the state will be set to 'ended'
+ *  2) with execution.cancel() : then the state will be set to 'cancelled'
+ *  3) with execution.end(String) : then the state will be set to the 
+ *     given state string.  An exception will be raised if the given 
+ *     state maches any of the known states.
+ * 
+ * @author Tom Baeyens
+ */
+public class ExecutionStateTest extends BaseJbpmTestCase {
+
+  public static class AutomaticActivity implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+    }
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.take(signalName);
+    }
+  }
+  
+  public void testBasicState() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new AutomaticActivity())
+      .endActivity()
+    .endProcess();
+
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    assertEquals(Execution.STATE_CREATED, processInstance.getState());
+    
+    processInstance.start();
+
+    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
+
+    processInstance.signal();
+
+    assertEquals(Execution.STATE_ENDED, processInstance.getState());
+  }
+
+  public void testSignalOnInactiveExecution() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope()
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new AutomaticActivity())
+      .endActivity()
+    .endProcess();
+  
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.start();
+  
+    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
+  
+    try {
+      processInstance.signal();
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("process-instance is not active: inactive", e.getMessage());
+    }
+  }
+  
+  public void testCustomEndState() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new AutomaticActivity())
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.start();
+    processInstance.end("error");
+    
+    assertEquals("error", processInstance.getState());
+    
+    try {
+      processInstance.signal();
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("process-instance is not active: error", e.getMessage());
+    }
+  }
+
+  public void testInvalidCustomStates() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new AutomaticActivity())
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.start();
+    
+    try {
+      processInstance.end("active");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("invalid end state: active", e.getMessage());
+    }
+    try {
+      processInstance.end("suspended");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("invalid end state: suspended", e.getMessage());
+    }
+    try {
+      processInstance.end("created");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("invalid end state: created", e.getMessage());
+    }
+    try {
+      processInstance.end("async");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("invalid end state: async", e.getMessage());
+    }
+    try {
+      processInstance.end("inactive");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("invalid end state: inactive", e.getMessage());
+    }
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExternalDecisionTest extends TestCase {
+  
+  public static class ExternalDecision implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      execution.take(signalName);
+    }
+  }
+  
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+
+  public static ClientProcessDefinition createCreditProcess() {
+    return ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("creditRate?", new ExternalDecision())
+        .initial()
+        .transition("priority delivery", "good")
+        .transition("bulk delivery", "average")
+        .transition("payment upfront", "bad")
+      .endActivity()
+      .startActivity("priority delivery", new WaitState())
+      .endActivity()
+      .startActivity("bulk delivery", new WaitState())
+      .endActivity()
+      .startActivity("payment upfront", new WaitState())
+      .endActivity()
+    .endProcess();
+  }
+
+  public void testGoodRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    execution.signal("good");
+
+    assertEquals("priority delivery", execution.getActivity().getName());
+  }
+
+  public void testAverageRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    execution.signal("average");
+    
+    assertEquals("bulk delivery", execution.getActivity().getName());
+  }
+  
+  public void testBadRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    execution.signal("bad");
+
+    assertEquals("payment upfront", execution.getActivity().getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/** shows how functional activities (activities that have a specific function 
+ * not related to control transition) can be implemented.
+ * 
+ * Examples of functional activities could be sending an email, doing a 
+ * SQL update on a database, generating a file and so on.
+ * 
+ * Functional activities can be used as activity behaviour in a transition based 
+ * process, event listener and as activity behaviour in nested activity 
+ * execution.
+ * 
+ * @author Tom Baeyens
+ */
+public class FunctionalActivityTest extends BaseJbpmTestCase {
+
+  public static class FunctionalActivity implements ActivityBehaviour, EventListener {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public FunctionalActivity(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      perform(execution);
+    }
+    public void notify(EventListenerExecution execution) {
+      perform(execution);
+    }
+    void perform(OpenExecution execution) {
+      events.add("performed automatic activity");
+    }
+  }
+
+  public void testFunctionalActivityAsActivityBehaviourWithTransitions() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", functionalActivity)
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", functionalActivity)
+        .transition("c")
+      .endActivity()
+      .startActivity("c", functionalActivity)
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    
+    assertEquals("a", processInstance.getActivityName());
+    assertFalse(processInstance.isEnded());
+    assertEquals(expectedEvents, recordedEvents);
+    
+    processInstance.start();
+    
+    expectedEvents.add("performed automatic activity");
+    expectedEvents.add("performed automatic activity");
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+  
+  public static class AutomaticActivity implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+
+  public void testFunctionalActivityAsEventListener() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .startFlow("b")
+          .listener(functionalActivity)
+        .endFlow()
+      .endActivity()
+      .startActivity("b", new AutomaticActivity())
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.start();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+  public static class Composite implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      Activity nestedActivity = execution.getActivity().getActivities().get(0);
+      execution.execute(nestedActivity);
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+
+  public void testFunctionalActivityAsNestedActivity() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new Composite())
+        .initial()
+        .startActivity(functionalActivity)
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.start();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,109 @@
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+public class LoopingTest extends BaseJbpmTestCase {
+  
+  public static class For implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+
+    int startIndex = 0;
+    int loops;
+    int increment = 1;
+    String indexKey = "index";
+
+    public For(int loops) {
+      this.loops = loops;
+    }
+
+    public void execute(ActivityExecution execution) throws Exception {
+      Integer index = (Integer) execution.getVariable(indexKey);
+
+      if (index==null) {
+        execution.setVariable(indexKey, startIndex);
+        execution.take("loop");
+        
+      } else {
+        index++;
+        if (index<(startIndex+loops)){
+          execution.setVariable(indexKey, index);
+          execution.take("loop");
+          
+        } else {
+          execution.removeVariable(indexKey);
+          execution.take("done");
+        }
+      }
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+      throw new UnsupportedOperationException();
+    }
+    
+    public void setStartIndex(int startIndex) {
+      this.startIndex = startIndex;
+    }
+    public void setLoops(int loops) {
+      this.loops = loops;
+    }
+    public void setIncrement(int increment) {
+      this.increment = increment;
+    }
+    public void setIndexVariable(String indexVariable) {
+      this.indexKey = indexVariable;
+    }
+  }
+
+  static List<Object> recordedIndexes = new ArrayList<Object>();
+  
+  public static class Recorder implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      recordedIndexes.add(execution.getVariable("index"));
+    }
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+    }
+  }
+
+  public void testWhile() {
+    int loops = 20;
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("for", new For(loops))
+        .initial()
+        .transition("recorder", "loop")
+        .transition("end", "done")
+      .endActivity()
+      .startActivity("recorder", new Recorder())
+        .transition("for")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    List<Object> expectedIndexes = new ArrayList<Object>();
+    for (int i=0; i<loops; i++) expectedIndexes.add(i); 
+
+    assertEquals(expectedIndexes, recordedIndexes);
+    assertEquals("end", execution.getActivity().getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeStateTest extends BaseJbpmTestCase
+{
+
+  public static class AutomaticActivity implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+    }
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.take(signalName);
+    }
+  }
+
+  public void testInactivationWhenCreatingNestedExecution() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new AutomaticActivity())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope()
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    assertEquals(Execution.STATE_CREATED, processInstance.getState());
+    
+    processInstance.start();
+    Execution scopeExecution = processInstance.getExecutions().iterator().next();
+
+    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
+    assertEquals(Execution.STATE_ACTIVE, scopeExecution.getState());
+    
+    processInstance.signal(scopeExecution);
+
+    assertEquals(Execution.STATE_ENDED, scopeExecution.getState());
+    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,277 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.test.BaseJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeVariableDeclarationTest extends BaseJbpmTestCase {
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+  
+  public static class Composite implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      Activity child = execution.getActivity().getActivities().get(0);
+      execution.execute(child);
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+  
+  public void testProcessInstanceVariableDeclaration() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .variable("flight")
+      .startActivity("a", new WaitState())
+        .initial()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    assertTrue(processInstance.hasVariable("flight"));
+    assertNull(processInstance.getVariable("flight"));
+  }
+
+  public void testProcessInstanceVariableDeclarationWithInitialValue() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startVariable("flight")
+        .initialValue(new StringDescriptor("B52"))
+      .endVariable()
+      .startActivity("a", new WaitState())
+        .initial()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    assertTrue(processInstance.hasVariable("flight"));
+    assertEquals("B52", processInstance.getVariable("flight"));
+  }
+
+  public void testNestedScopeDeclarations() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startVariable("flight")
+        .initialValue(new StringDescriptor("B52"))
+      .endVariable()
+      .startActivity("outer", new Composite())
+        .scope()
+        .startVariable("duration")
+          .initialValue(new StringDescriptor("22 minutes"))
+        .endVariable()
+        .startActivity("middle", new Composite())
+          .scope()
+          .startVariable("altitude")
+            .initialValue(new StringDescriptor("31000 ft"))
+          .endVariable()
+          .startActivity("inner", new Composite())
+          .scope()
+            .startVariable("passengers")
+              .initialValue(new StringDescriptor("52"))
+            .endVariable()
+            .startActivity("start", new WaitState())
+              .initial()
+              .scope()
+              .startVariable("fuel")
+                .initialValue(new StringDescriptor("kerosine"))
+              .endVariable()
+            .endActivity()
+          .endActivity()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    expectedVariables.put("flight", "B52");
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    OpenExecution outerExecution = processInstance.getExecution("outer");
+    expectedVariables.put("duration", "22 minutes");
+    assertEquals(expectedVariables, outerExecution.getVariables());
+
+    OpenExecution middleExecution = outerExecution.getExecution("middle");
+    expectedVariables.put("altitude", "31000 ft");
+    assertEquals(expectedVariables, middleExecution.getVariables());
+
+    OpenExecution innerExecution = middleExecution.getExecution("inner");
+    expectedVariables.put("passengers", "52");
+    assertEquals(expectedVariables, innerExecution.getVariables());
+
+    OpenExecution startExecution = innerExecution.getExecution("start");
+    expectedVariables.put("fuel", "kerosine");
+    assertEquals(expectedVariables, startExecution.getVariables());
+  }
+
+  public void testHiddenVariable() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startVariable("flight")
+        .initialValue(new StringDescriptor("B52"))
+      .endVariable()
+      .startActivity("c", new Composite())
+        .scope()
+        .startVariable("flight")
+          .initialValue(new StringDescriptor("U2"))
+        .endVariable()
+        .startActivity("i", new WaitState())
+          .scope()
+          .initial()
+          .startVariable("flight")
+            .initialValue(new StringDescriptor("C130"))
+          .endVariable()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    OpenExecution executionC = processInstance.getExecution("c");
+    OpenExecution executionI = executionC.getExecution("i");
+    
+    assertEquals("B52", processInstance.getVariable("flight"));
+    assertEquals("U2", executionC.getVariable("flight"));
+    assertEquals("C130", executionI.getVariable("flight"));
+  }
+
+  public void testAutomaticScopeManagement() {
+    /*
+    process 
+     ${flight} = 'B52'
+    +--------------------------------------------------------------------+
+    | outer                                                              |
+    |  ${duration} = '22 minutes'                                        |
+    | +-------------------------------+                                  |  
+    | | left-middle                   |                                  |
+    | |  ${altitude} = '31000 ft'     |                                  |
+    | | +---------------------------+ |   +----------------------------+ |
+    | | | left-inner                | |   | right-middle               | |       
+    | | |  ${passengers}            | |   |  ${customer} = 'coca cola' | |       
+    | | | +-----------------------+ | |   |  +--------------------+    | |
+    | | | | left-start            | -------> | right-inner        |    | |
+    | | | |  ${fuel} = 'kerosine' | | |   |  |  ${date} = 'today' |    | |
+    | | | +-----------------------+ | |   |  +--------------------+    | |
+    | | +---------------------------+ |   +----------------------------+ |
+    +--------------------------------------------------------------------+
+    */
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+      .startVariable("flight")
+        .initialValue(new StringDescriptor("B52"))
+      .endVariable()
+      .startActivity("outer", new Composite())
+        .scope()
+        .startVariable("duration")
+          .initialValue(new StringDescriptor("22 minutes"))
+        .endVariable()
+        .startActivity("left-middle", new Composite())
+          .scope()
+          .startVariable("altitude")
+            .initialValue(new StringDescriptor("31000 ft"))
+          .endVariable()
+          .startActivity("left-inner", new Composite())
+            .scope()
+            .startVariable("passengers")
+              .initialValue(new StringDescriptor("52"))
+            .endVariable()
+            .startActivity("left-start", new WaitState())
+              .initial()
+              .scope()
+              .transition("right-inner")
+              .startVariable("fuel")
+                .initialValue(new StringDescriptor("kerosine"))
+              .endVariable()
+            .endActivity()
+          .endActivity()
+        .endActivity()
+        .startActivity("right-middle", new Composite())
+          .scope()
+          .startVariable("customer")
+            .initialValue(new StringDescriptor("coca-cola"))
+          .endVariable()
+          .startActivity("right-inner", new WaitState())
+            .scope()
+            .startVariable("date")
+              .initialValue(new StringDescriptor("today"))
+            .endVariable()
+          .endActivity()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    OpenExecution outerExecution = processInstance.getExecution("outer");
+    OpenExecution leftMiddleExecution = outerExecution.getExecution("left-middle");
+    OpenExecution leftInnerExecution = leftMiddleExecution.getExecution("left-inner");
+    OpenExecution leftStartExecution = leftInnerExecution.getExecution("left-start");
+
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("flight", "B52");
+    expectedVariables.put("duration", "22 minutes");
+    expectedVariables.put("altitude", "31000 ft");
+    expectedVariables.put("passengers", "52");
+    expectedVariables.put("fuel", "kerosine");
+    assertEquals(expectedVariables, leftStartExecution.getVariables());
+
+    processInstance.signal(leftStartExecution);
+
+    OpenExecution rightMiddleExecution = outerExecution.getExecution("right-middle");
+    OpenExecution rightInnerExecution = rightMiddleExecution.getExecution("right-inner");
+
+    expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("flight", "B52");
+    expectedVariables.put("duration", "22 minutes");
+    
+    assertEquals(expectedVariables, outerExecution.getVariables());
+    
+    expectedVariables.put("customer", "coca-cola");
+    assertEquals(expectedVariables, rightMiddleExecution.getVariables());
+
+    expectedVariables.put("date", "today");
+    assertEquals(expectedVariables, rightInnerExecution.getVariables());
+  }
+
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ *  
+ *    +---+     +--------+     +---+ 
+ *    | a |     | b      |     | c |
+ *    |   | --> |        | --> |   |  
+ *    |   |     | SCOPE! |     |   |
+ *    +---+     +--------+     +---+  
+ *
+ * @author Tom Baeyens
+ */
+public class ScopeVariableTest extends BaseJbpmTestCase
+{
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+  
+  public void testOuterscopeLookup() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope() // !!!!
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    processInstance.setVariable("destination", "anywhere");
+    
+    processInstance.signal();
+    
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    // check if the global vars are still visible within the scope for b.
+    assertEquals("anywhere", bScope.getVariable("destination"));
+    
+    bScope.createVariable("temp", "23C");
+    assertEquals("23C", bScope.getVariable("temp"));
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testLocalVariableLookup() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope() // !!!!
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "23C");
+    
+    assertEquals("23C", bScope.getVariable("temp"));
+    assertNull(processInstance.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testLocalVariableUpdate() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope() // !!!!
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "23C");
+    bScope.setVariable("temp", "28C");
+    
+    assertEquals("28C", bScope.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testDefaultCreationOnGlobalScope() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope() // !!!!
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.setVariable("temp", "28C");
+    assertEquals("28C", bScope.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertEquals("28C", processInstance.getVariable("temp"));
+  }
+
+  public void testVariableUpdatesOnEndedScope() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+        .transition("b")
+      .endActivity()
+      .startActivity("b", new WaitState())
+        .scope() // !!!!
+        .transition("c")
+      .endActivity()
+      .startActivity("c", new WaitState())
+      .endActivity()
+    .endProcess();
+  
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "28C");
+    
+    processInstance.signal(bScope);
+    
+    try {
+      bScope.setVariable("temp", "21C");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      // OK
+      assertTextPresent("can't update variable 'temp' on execution[b]", e.getMessage());
+    }
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubProcessTest extends BaseJbpmTestCase
+{
+
+  public static class SubProcess implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    ClientProcessDefinition subProcess;
+    public SubProcess(ClientProcessDefinition subProcess) {
+      this.subProcess = subProcess;
+    }
+    public void execute(ActivityExecution execution) throws Exception {
+      ClientExecution subProcessInstance = execution.beginSubProcessInstance(subProcess);
+      if (!subProcessInstance.isEnded()) {
+        execution.waitForSignal();
+      }
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+    }
+  }
+  
+  public static class AutomaticActivity implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+  
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+    }
+  }
+
+  public static class EndState implements ActivityBehaviour {
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.end();
+    }
+  }
+
+  public void testSubProcess() {
+    ClientProcessDefinition subProcess = ProcessDefinitionBuilder
+    .startProcess("sub")
+      .startActivity("sub1", new AutomaticActivity())
+        .initial()
+        .transition("sub2")
+      .endActivity()
+      .startActivity("sub2", new WaitState())
+        .transition("sub3")
+      .endActivity()
+      .startActivity("sub3", new EndState())
+      .endActivity()
+    .endProcess();
+    
+    ClientProcessDefinition superProcess = ProcessDefinitionBuilder
+    .startProcess("super")
+      .startActivity("super1", new AutomaticActivity())
+        .initial()
+        .transition("super2")
+      .endActivity()
+      .startActivity("super2", new SubProcess(subProcess))
+        .transition("super3")
+      .endActivity()
+      .startActivity("super3", new WaitState())
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution superProcesInstance = superProcess.startProcessInstance();
+    assertEquals("super2", superProcesInstance.getActivity().getName());
+
+    ClientExecution subProcessInstance = (ClientExecution) superProcesInstance.getSubProcessInstance(); 
+    assertNotNull(subProcessInstance);
+    assertEquals("sub2", subProcessInstance.getActivity().getName());
+    
+    subProcessInstance.signal();
+    
+    assertEquals("sub3", subProcessInstance.getActivity().getName());
+    assertTrue(subProcessInstance.isEnded());
+    
+    assertEquals("super3", superProcesInstance.getActivity().getName());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,184 @@
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityBehaviour;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Activity;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * concurrent execution where synchronization is done by checking if the 
+ * number of expected child executions arrived at the join.
+ * 
+ * @author Tom Baeyens
+ */
+public class TransitionBasedConcurrencyTest extends BaseJbpmTestCase {
+  
+  public static class Fork implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      OpenExecution processInstance = execution.getProcessInstance();
+
+      Activity activity = execution.getActivity();
+      List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+
+      // for each outgoing transition
+      for (Transition outgoingTransition: outgoingTransitions) {
+        // launch a concurrent path of execution
+        String childExecutionName = outgoingTransition.getName();
+        // creating the execution will cause the execution to become inactive
+        Execution childExecution = execution.createExecution(childExecutionName, processInstance);
+        execution.take(outgoingTransition, childExecution);
+      }
+
+      // if this was the first fork
+      if (execution.isProcessInstance()) {
+        execution.setActivity(null);
+      }
+    }
+  }
+
+  public static class Join implements ActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      // end the child execution execution
+      // this will also remove the execution from it's parent
+      execution.setState(Execution.STATE_INACTIVE);
+      execution.waitForSignal();
+      
+      Activity join = execution.getActivity();
+      List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
+      
+      if (isComplete(joinedExecutions, join)) {
+        endJoinedExecutions(joinedExecutions, execution);
+
+        OpenExecution processInstance = execution.getProcessInstance();
+        
+        Execution outgoingExecution = null;
+        if ( processInstance.getExecutions()==null
+             || processInstance.getExecutions().isEmpty() 
+           ) {
+          outgoingExecution = processInstance;
+        } else {
+          outgoingExecution = execution.createExecution(processInstance);
+        }
+        
+        execution.setActivity(join, outgoingExecution);
+        Transition transition = join.getDefaultTransition();
+        execution.take(transition, outgoingExecution);
+      }
+    }
+    
+    List<OpenExecution> findJoinedExecutions(OpenExecution execution, Activity join) {
+      List<OpenExecution> joinedExecutions = new ArrayList<OpenExecution>();
+      scanRecursive(execution.getProcessInstance(), join, joinedExecutions);
+      return joinedExecutions;
+    }
+
+    void scanRecursive(OpenExecution execution, Activity join, List<OpenExecution> joinedExecutions) {
+      // if the execution is positioned in the join
+      if (join.equals(execution.getActivity())) {
+        joinedExecutions.add(execution);
+      }
+      Collection<OpenExecution> childExecutions = execution.getExecutions();
+      if (childExecutions!=null) {
+        for (OpenExecution childExecution: childExecutions) {
+          scanRecursive(childExecution, join, joinedExecutions);
+        }
+      }
+    }
+
+    boolean isComplete(List<OpenExecution> joinedExecutions, Activity join) {
+      int executionsToJoin = join.getIncomingTransitions().size();
+      return (executionsToJoin==joinedExecutions.size());
+    }
+
+    void endJoinedExecutions(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
+      for (OpenExecution joinedExecution: joinedExecutions) {
+        execution.end(joinedExecution);
+      }
+    }
+  }
+
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+
+  public void testTransitionBasedConcurrency() {
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("fork", new Fork())
+        .initial()
+        .transition("bill", "billing")
+        .transition("ship", "shipping")
+      .endActivity()
+      .startActivity("bill", new WaitState())
+        .transition("join")
+      .endActivity()
+      .startActivity("ship", new WaitState())
+        .transition("join")
+      .endActivity()
+      .startActivity("join", new Join())
+        .transition("end")
+      .endActivity()
+      .startActivity("end", new WaitState())
+      .endActivity()
+    .endProcess();
+
+    ClientExecution main = processDefinition.startProcessInstance();
+    
+    assertNull("fork", main.getActivity());
+    assertEquals(Execution.STATE_INACTIVE, main.getState());
+    
+    Execution billing = main.getExecution("billing");
+    assertNotNull(billing);
+    assertEquals("bill", billing.getActivityName());
+    assertFalse(billing.isEnded());
+    
+    Execution shipping = main.getExecution("shipping");
+    
+    assertNotNull(shipping);
+    assertEquals("ship", shipping.getActivityName());
+    assertFalse(shipping.isEnded());
+    assertTrue(main.getExecutions().contains(billing));
+    assertTrue(main.getExecutions().contains(shipping));
+
+    main.signal(billing);
+    
+    assertNull(main.getActivityName());
+    assertEquals("join", billing.getActivityName());
+    assertEquals("ship", shipping.getActivityName());
+    assertEquals(Execution.STATE_ACTIVE, shipping.getState());
+    assertEquals(Execution.STATE_INACTIVE, billing.getState());
+    assertEquals(Execution.STATE_INACTIVE, main.getState());
+
+    main.signal(shipping);
+    
+    assertEquals(Execution.STATE_ACTIVE, main.getState());
+    assertEquals("end", main.getActivityName());
+    assertEquals("join", billing.getActivityName());
+    assertTrue(billing.isEnded());
+    assertEquals("join", shipping.getActivityName());
+    assertTrue(shipping.isEnded());
+    assertFalse(main.getExecutions().contains(billing));
+    assertFalse(main.getExecutions().contains(shipping));
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,571 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionEventsTest extends BaseJbpmTestCase {
+  
+  public class Recorder implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public List<Object> events = new ArrayList<Object>();
+    public void notify(EventListenerExecution execution) {
+      events.add(execution.getEvent()+" on "+execution.getEventSource());
+    }
+  }
+
+
+  public void testCompositeLeave(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +--------------+
+    | composite    |
+    |  +--------+  |     +---------+    
+    |  | inside |------->| outside |
+    |  +--------+  |     +---------+    
+    +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener)
+      .endEvent()
+      .startActivity("composite")
+        .startEvent(Event.END) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(compositeListener)
+        .endEvent()
+        .startActivity("inside", new WaitState())
+          .initial()
+          .transition("outside")
+          .startEvent(Event.END) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(insideListener)
+          .endEvent()
+        .endActivity()
+      .endActivity()
+      .startActivity("outside", new WaitState())
+        .startEvent(Event.END) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(outsideListener)
+        .endEvent()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getActivity().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals("[event(start) on activity(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(end) on activity(composite)]",
+                 compositeListener.events.toString());
+    
+    assertEquals("[event(end) on activity(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testCompositeEnter(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+                   +--------------+
+                   | composite    |
+    +---------+    |  +--------+  |
+    | outside |------>| inside |  |
+    +---------+    |  +--------+  |
+                   +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener)
+      .endEvent()
+      .startActivity("outside", new WaitState())
+        .initial()
+        .transition("inside")
+        .startEvent(Event.END) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(outsideListener)
+        .endEvent()
+      .endActivity()
+      .startActivity("composite")
+        .startEvent(Event.END) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(compositeListener)
+        .endEvent()
+        .startActivity("inside", new WaitState())
+          .startEvent(Event.END) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(insideListener)
+          .endEvent()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+
+    execution.signal();
+    
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals("[event(end) on activity(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(start) on activity(composite)]",
+    		     compositeListener.events.toString());
+    
+    assertEquals("[event(start) on activity(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testSelfTransition(){
+    Recorder processListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +-----------------+
+    | composite       |
+    |  +--------+     |    
+    |  | inside |---+ |
+    |  |        |   | |
+    |  |        |<--+ |
+    |  +--------+     |    
+    +-----------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener)
+      .endEvent()
+      .startActivity("composite")
+        .startEvent(Event.END) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(compositeListener)
+        .endEvent()
+        .startActivity("inside", new WaitState())
+          .initial()
+          .transition("inside")
+          .startEvent(Event.END) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(insideListener)
+          .endEvent()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getActivity().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+    
+    assertEquals(0, compositeListener.events.size());
+    
+    assertEquals("[event(end) on activity(inside), " +
+    		      "event(start) on activity(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testPropagateSelfTransition(){
+    Recorder processListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+
+    /*
+    +-----------------+
+    | composite       |
+    |  +--------+     |    
+    |  | inside |---+ |
+    |  |        |   | |
+    |  |        |<--+ |
+    |  +--------+     |    
+    +-----------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener, true)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener, true)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener, true)
+      .endEvent()
+      .startActivity("composite")
+        .startEvent(Event.END) 
+          .listener(compositeListener, true)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(compositeListener, true)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(compositeListener, true)
+        .endEvent()
+        .startActivity("inside", new WaitState())
+          .initial()
+          .transition("inside")
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals(0, compositeListener.events.size());
+    
+    assertEquals("inside", execution.getActivity().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(end) on activity(inside), " +
+                  "event(take) on (inside)-->(inside), " +
+                  "event(start) on activity(inside)]",
+                 compositeListener.events.toString());
+
+    assertEquals("[event(start) on process(p), " +
+    		      "event(end) on activity(inside), " +
+                  "event(take) on (inside)-->(inside), " +
+                  "event(start) on activity(inside)]", 
+                 processListener.events.toString());
+  }
+
+
+  public void testCompositeLeaveInheritedTransition(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +--------------+        +---------+ 
+    | composite    |------->| outside |
+    |  +--------+  |        +---------+   
+    |  | inside |  |
+    |  +--------+  |
+    +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener)
+      .endEvent()
+      .startActivity("composite")
+        .transition("outside")
+        .startEvent(Event.END) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(compositeListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(compositeListener)
+        .endEvent()
+        .startActivity("inside", new WaitState())
+          .initial()
+          .startEvent(Event.END) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(insideListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(insideListener)
+          .endEvent()
+        .endActivity()
+      .endActivity()
+      .startActivity("outside", new WaitState())
+        .startEvent(Event.END) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(outsideListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(outsideListener)
+        .endEvent()
+      .endActivity()
+    .endProcess();
+
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getActivity().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+
+    assertEquals("[event(start) on activity(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(end) on activity(composite)]",
+                 compositeListener.events.toString());
+    
+    assertEquals("[event(end) on activity(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testCompositeLeaveInheritedTransitionExtraNesting(){
+    Recorder processListener = new Recorder();
+    Recorder sourceOutsideListener = new Recorder();
+    Recorder sourceMiddleListener = new Recorder();
+    Recorder sourceInsideListener = new Recorder();
+    Recorder destinationOutsideListener = new Recorder();
+    Recorder destinationInsideListener = new Recorder();
+
+    /*
+    +--------------------------+ 
+    | source outside           |
+    |  +--------------------+  |      +--------------------------+ 
+    |  | source middle      |  |      | destination outside      |
+    |  |  +---------------+ |  |      |  +--------------------+  |   
+    |  |  | source inside | |----------->| destination inside |  |
+    |  |  +---------------+ |  |      |  +--------------------+  |
+    |  +--------------------+  |      +--------------------------+
+    +--------------------------+
+    */
+
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess("p")
+      .startEvent(Event.END) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.START) 
+        .listener(processListener)
+      .endEvent()
+      .startEvent(Event.TAKE) 
+        .listener(processListener)
+      .endEvent()
+      .startActivity("source outside")
+        .startEvent(Event.END) 
+          .listener(sourceOutsideListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(sourceOutsideListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(sourceOutsideListener)
+        .endEvent()
+        .startActivity("source middle")
+          .transition("destination inside")
+          .startEvent(Event.END) 
+            .listener(sourceMiddleListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(sourceMiddleListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(sourceMiddleListener)
+          .endEvent()
+          .startActivity("source inside", new WaitState())
+            .initial()
+            .startEvent(Event.END) 
+              .listener(sourceInsideListener)
+            .endEvent()
+            .startEvent(Event.START) 
+              .listener(sourceInsideListener)
+            .endEvent()
+            .startEvent(Event.TAKE) 
+              .listener(sourceInsideListener)
+            .endEvent()
+          .endActivity()
+        .endActivity()
+      .endActivity()
+      .startActivity("destination outside")
+        .startEvent(Event.END) 
+          .listener(destinationOutsideListener)
+        .endEvent()
+        .startEvent(Event.START) 
+          .listener(destinationOutsideListener)
+        .endEvent()
+        .startEvent(Event.TAKE) 
+          .listener(destinationOutsideListener)
+        .endEvent()
+        .startActivity("destination inside", new WaitState())
+          .startEvent(Event.END) 
+            .listener(destinationInsideListener)
+          .endEvent()
+          .startEvent(Event.START) 
+            .listener(destinationInsideListener)
+          .endEvent()
+          .startEvent(Event.TAKE) 
+            .listener(destinationInsideListener)
+          .endEvent()
+        .endActivity()
+      .endActivity()
+    .endProcess();
+
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+
+    assertEquals("source inside", execution.getActivity().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(start) on process(p)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(end) on activity(source outside)]", 
+                 sourceOutsideListener.events.toString());
+    
+    assertEquals("[event(end) on activity(source middle)]", 
+                 sourceMiddleListener.events.toString());
+
+    assertEquals("[event(end) on activity(source inside)]", 
+                 sourceInsideListener.events.toString());
+
+    assertEquals("[event(start) on activity(destination outside)]", 
+                 destinationOutsideListener.events.toString());
+
+    assertEquals("[event(start) on activity(destination inside)]", 
+                 destinationInsideListener.events.toString());
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.test.BaseJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableTest extends BaseJbpmTestCase {
+  
+  public static class WaitState implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+    }
+  }
+
+  protected ClientProcessDefinition createProcessDefinition() {
+    return ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new WaitState())
+        .initial()
+      .endActivity()
+    .endProcess();
+  }
+
+
+  public void testSetAndGetVariable() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    assertEquals("coca-cola", processInstance.getVariable("customer"));
+    
+    processInstance.setVariable("address", "usa");
+    assertEquals("usa", processInstance.getVariable("address"));
+
+    processInstance.setVariable("size", "big");
+    assertEquals("big", processInstance.getVariable("size"));
+  }
+
+  public void testHasVariable() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+
+    assertTrue(processInstance.hasVariable("customer"));
+    assertFalse(processInstance.hasVariable("address"));
+  }
+
+  public void testSetVariables() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("customer", "coca-cola");
+    variables.put("address", "usa");
+    variables.put("size", "big");
+
+    processInstance.setVariables(variables);
+
+    assertEquals("coca-cola", processInstance.getVariable("customer"));
+    assertEquals("usa", processInstance.getVariable("address"));
+    assertEquals("big", processInstance.getVariable("size"));
+  }
+
+  public void testGetVariables() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("customer", "coca-cola");
+    expectedVariables.put("address", "usa");
+    expectedVariables.put("size", "big");
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testRemoveVariable() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("customer", "coca-cola");
+    expectedVariables.put("address", "usa");
+    expectedVariables.put("size", "big");
+    
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("address");
+    expectedVariables.remove("address");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("customer");
+    expectedVariables.remove("customer");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("size");
+    expectedVariables.remove("size");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testRemoveVariables() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    processInstance.removeVariables();
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testGetVariableKeys() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Set<String> expectedVariableKeys = new HashSet<String>();
+    expectedVariableKeys.add("customer");
+    expectedVariableKeys.add("address");
+    expectedVariableKeys.add("size");
+    assertEquals(expectedVariableKeys, new HashSet<String>(processInstance.getVariableKeys()));
+  }
+
+  public void testGetUnexistingVariable() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    assertNull(processInstance.getVariable("answer to life, the universe and everything"));
+  }
+
+  public static class VariableActivity implements ExternalActivityBehaviour {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals("coca-cola", execution.getVariable("customer"));
+      execution.setVariable("message", "Killroy was here");
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+
+  public void testInitialiseVariablesBeforeProcessInstanceBegin() {
+    ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+    .startProcess()
+      .startActivity("a", new VariableActivity())
+        .initial()
+      .endActivity()
+    .endProcess();
+    
+    // here, the process instance is created first, and only later it is begun
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.start();
+    assertEquals("Killroy was here", processInstance.getVariable("message"));
+  }
+  
+  public void testNullValue() {
+    ClientProcessDefinition processDefinition = createProcessDefinition();
+    
+    ClientExecution processInstance = processDefinition.startProcessInstance();
+    
+    processInstance.setVariable("niks", null);
+    processInstance.setVariable("nada", null);
+
+    assertTrue(processInstance.hasVariables());
+    assertTrue(processInstance.hasVariable("niks"));
+    assertTrue(processInstance.hasVariable("nada"));
+
+    assertNull(processInstance.getVariable("niks"));
+    assertNull(processInstance.getVariable("nada"));
+    
+    Set<String> expectedKeys = new HashSet<String>();
+    expectedKeys.add("niks");
+    expectedKeys.add("nada");
+    assertEquals(expectedKeys, new HashSet<String>(processInstance.getVariableKeys()));
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("niks", null);
+    expectedVariables.put("nada", null);
+    assertEquals(expectedVariables, new HashMap<String, Object>(processInstance.getVariables()));
+  }
+
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivityBehaviour {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, 
+                     String signalName, 
+                     Map<String, Object> parameters) {
+  }
+}

Added: jbpm4/branches/tbaeyens/modules/test-pojo/src/main/resources/logging.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-pojo/src/main/resources/logging.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-pojo/src/main/resources/logging.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST

Added: jbpm4/branches/tbaeyens/modules/userguide/.project
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/.project	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/.project	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>userguide</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.stp.bpmn.validation.BatchValidationBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+		<nature>org.eclipse.stp.bpmn.validation.BatchValidationBuildAbleNature</nature>
+	</natures>
+</projectDescription>

Added: jbpm4/branches/tbaeyens/modules/userguide/.settings/attachedFile.properties
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/.settings/attachedFile.properties	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/.settings/attachedFile.properties	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,2 @@
+## index of importer -> set(imports)
+#Wed Mar 04 10:44:26 CET 2009

Added: jbpm4/branches/tbaeyens/modules/userguide/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+  <!-- ====================================================================== -->
+  <!--                                                                        -->
+  <!--  JBoss, the OpenSource J2EE webOS                                      -->
+  <!--                                                                        -->
+  <!--  Distributable under LGPL license.                                     -->
+  <!--  See terms of license at http://www.gnu.org.                           -->
+  <!--                                                                        -->
+  <!-- ====================================================================== -->
+
+  <!-- $Id: pom.xml 2693 2008-10-31 09:12:32Z tom.baeyens at jboss.com $ -->
+
+<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>
+
+  <name>jBPM 4 - User Guide</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm-userguide</artifactId>
+  <packaging>pom</packaging>
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jbpm.jbpm4</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <dependencies>
+    <!-- 
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-pvm</artifactId>
+      <version>${version}</version>
+    </dependency>
+    -->
+  </dependencies>
+
+  <build>
+    <!-- ### PLUGINS ###################################################### -->
+    <plugins>
+
+      <plugin>
+        <groupId>org.jboss.maven.plugins</groupId>
+        <artifactId>maven-jdocbook-plugin</artifactId>
+        <version>2.1.2</version>
+        <extensions>true</extensions>
+
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>resources</goal>
+              <goal>generate</goal>
+            </goals>
+          </execution>
+         </executions>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jbossorg-docbook-xslt</artifactId>
+            <version>1.1.0</version>
+          </dependency>
+          <dependency>
+            <groupId>org.jbpm.jbpm4</groupId>
+            <artifactId>docbook-style</artifactId>
+            <version>1.0.0</version>
+            <type>jdocbook-style</type>
+          </dependency>
+        </dependencies>
+
+        <configuration>
+          <sourceDocumentName>master.xml</sourceDocumentName>
+          <masterTranslation>en</masterTranslation>
+          <imageResource>
+            <directory>${basedir}/src/main/docbook/en</directory>
+            <includes>
+              <include>images/*.png</include>
+            </includes>
+          </imageResource>
+          <formats>
+            <format>
+              <formatName>html_single</formatName>
+              <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+              <finalName>index.html</finalName>
+            </format>
+          </formats>
+        </configuration>
+
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/bpmn/loan.process.bpm
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/bpmn/loan.process.bpm
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/diagrams.mdzip
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/diagrams.mdzip
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/images.ppt
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/diagrams/images.ppt
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/gpd.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.executions.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.executions.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.definition.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.definition.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.instance.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/loan.process.instance.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.concurrency.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.multiple.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.multiple.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.state.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.end.state.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.esb.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.esb.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.exclusive.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.exclusive.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.hql.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.hql.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.java.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.java.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.script.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.script.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.choice.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.choice.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.sequence.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.state.sequence.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.task.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/process.task.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/show.view.data.source.explorer.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/images/show.view.data.source.explorer.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/master.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/master.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE book [
+  <!ENTITY ch01-Introduction       SYSTEM "modules/ch01-Introduction.xml">
+  <!ENTITY ch02-Installation       SYSTEM "modules/ch02-Installation.xml">
+  <!ENTITY ch03-Gpd                SYSTEM "modules/ch03-Gpd.xml">
+  <!ENTITY ch04-Services           SYSTEM "modules/ch04-Services.xml">
+  <!ENTITY ch05-Jpdl               SYSTEM "modules/ch05-Jpdl.xml">
+  <!ENTITY ch06-Variables          SYSTEM "modules/ch06-Variables.xml">
+  <!ENTITY ch07-Scripting          SYSTEM "modules/ch07-Scripting.xml">
+  <!ENTITY ch08-Identity           SYSTEM "modules/ch08-Identity.xml">
+]>
+
+<book lang="en">
+
+  <bookinfo>
+    <title>jBPM User Guide</title>
+  </bookinfo>
+
+  <toc />
+
+  &ch01-Introduction;
+  &ch02-Installation;
+  &ch03-Gpd;
+  &ch04-Services;
+  &ch05-Jpdl;
+  &ch06-Variables;
+  &ch07-Scripting;
+  &ch08-Identity;
+
+</book>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch01-Introduction.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,104 @@
+<chapter id="introduction">
+  <title>Introduction</title>
+  
+  <section>
+    <title>License and EULA</title>
+    <para>jBPM is distributed under the terms of the 
+    GNU Lesser General Public License (LGPL) and the JBoss End User License Agreement (EULA).  
+    See <ulink url="../../../lgpl.html">the full LGPL license text</ulink> and <ulink url="../../../JBossORG-EULA.txt">the 
+    full End User License Agreement</ulink>. 
+    </para>
+  </section>
+
+  <section>
+    <title>Downloads</title>
+    <para>The distribution packages can be downloaded from sourceforge
+    </para>
+    <ulink url="http://sourceforge.net/project/showfiles.php?group_id=70542&amp;package_id=268068">http://sourceforge.net/project/showfiles.php?group_id=70542&amp;package_id=268068</ulink>
+  </section>
+
+  <section>
+    <title>Sources</title>
+    <para>The source code for this component can be found in the jBPM SVN repository:
+    </para>
+    <ulink url="https://anonsvn.jboss.org/repos/jbpm/jbpm4/">https://anonsvn.jboss.org/repos/jbpm/jbpm4/</ulink>
+  </section>
+
+  <section>
+    <title>JVM version</title>
+    <para>jBPM requires a JDK (standard java) version 5 or higher.
+    </para>
+    <ulink url="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</ulink>
+  </section>
+
+  <section>
+    <title>What is it</title>
+    <para>jBPM is an extensible and flexible process engine that can run 
+    as a standalone server or embedded in any Java application.
+    jBPM can run multiple process languages and it supports multiple 
+    execution modes.
+    </para>
+  </section>  
+
+  <section>
+    <title>Contents of this userguide</title>
+    <para>In this user guide, we'll describe the jPDL 
+    process language in persistent execution mode.  Persistent 
+    execution mode means that process definitions, process executions 
+    and process history is stored in a relational DB.  This is the common way 
+    of how jBPM is used. 
+    </para>
+    <para>This user guide explains the supported way on how to use jBPM.
+    The developers guide explains more advanced customization options that 
+    are not supported. 
+    </para>
+    <para>TODO ?Explain what is meant by supported? Shouldn't it be clear to user's that it is more
+    geared towards extenders? That they can use it but that there is no guarantee of infinite stability?
+    END TODO 
+    </para>
+  </section>
+  
+  <section id="processdefinitionprocessinstanceandexecutions">
+    <title>Process definition, process instance and executions</title>
+    <para>A process definition is description of the steps in a procedure.
+    For example, an insurance company could have a <literal>loan</literal> 
+    process definition that describes the steps of how the company deals 
+    with loan requests.
+    </para> 
+    <figure id="loan.process.definition.example">
+      <title>The loan process definition example</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.definition.png"/></imageobject></mediaobject>
+    </figure>
+    <para>One process instance represents one particular run of a process definition.
+    For example, the loan request of John Doe last Friday to finance his new boat 
+    is represented in one process instance of the loan process definition.
+    </para>
+    <para>A process instance contains all the runtime state.  The 
+    most prominent property is the pointer that keeps track of the current activity.
+    </para>
+    <figure id="loan.process.instance.example">
+      <title>The loan process instance example</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/loan.process.instance.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Suppose that wiring the money and archiving can be done in parallel.
+    Then the main process instance will have two child executions to keep 
+    track of the state like this:   
+    </para>
+    <figure id="loan.executions.example">
+      <title>The loan executions example</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/loan.executions.png"/></imageobject></mediaobject>
+    </figure>
+    <para>More general, a process instance is the root of a tree of executions.
+    When a new process instance is started, the process instance is in fact the root 
+    execution scope.  Only leaf executions can be active.
+    </para>
+    <para>The motivation to work with a tree structure like this is that
+    this conceptually remains simple in the case where there is only one path 
+    of execution.  The services API doesn't need to make a functional difference 
+    between process instances and executions.  Therefore, the API has only 
+    one Execution type to refer to both <literal>ProcessInstance</literal>s and 
+    <literal>Execution</literal>s. 
+    </para>
+  </section>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,176 @@
+<chapter id="installation">
+  <title>Installation</title>
+  
+  <para>This chapter describes how to install jBPM in different 
+  application environments.
+  </para>
+
+  <section id="libraries">
+    <title>Libraries</title>
+    <para>jBPM can run on a JVM without a dependency on any library.
+    See object execution mode in the developers guide.  But in this 
+    userguide we'll cover the most common way to use jBPM, which is 
+    where jBPM stores its process definitions, executions and 
+    history in a relational database.  In that case, hibernate has to 
+    be added to the classpath.  Also some of the jPDL features require 
+    extra libraries.   Therefore, by including all the libraries in the 
+    lib directory, you get access to all those features and persistence.
+    </para>
+  </section>
+  
+  <section id="tomcat-xxx">
+    <title>Tomcat xxx</title>
+    <para>TODO: this will contain a description of how to use the 
+    installer to install jbpm on tomcat</para>
+  </section>
+
+  <section id="jboss-xxx">
+    <title>JBoss xxx</title>
+    <para>TODO: this will contain a description of how to use the 
+    installer to install jbpm on jboss</para>
+  </section>
+
+  <section id="database">
+    <title>Database</title>
+    <para>jBPM works with your database of choice.  That way, jBPM's data 
+    tables can be placed next to your application tables in the same 
+    database.  In case you're working outside an application server 
+    you can combine your application updates with jBPM's process updates in a 
+    single transaction by using the same JDBC connection. 
+    </para>
+    <section>
+      <title>For test</title>
+      <para></para>
+    </section>
+    <para>This section guides you through the steps that you should 
+    do to get 
+    </para>
+    <section>
+      <title>Install DB</title>
+      <para></para>
+    </section>
+    <section>
+      <title>Set up a connection</title>
+      <para></para>
+    </section>
+  </section>
+
+  <section id="graphicalprocessdesigner">
+    <title>Graphical Process Designer (GPD)</title>
+    <para>Eclipse is used as the platform to host the jPDL graphical process
+    designer. This section will describe how to obtain Eclipse, install it
+    the GPD.</para>
+    <section>
+      <title>Download Eclipse</title>
+      <para>You'll need Eclipse 3.4.1.
+      </para>
+      <para>Download the    
+      <ulink url="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-java-ganymede-SR1-win32.zip">Eclipse IDE for Java Developers (85 MB)</ulink> or
+      <ulink url="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-jee-ganymede-SR1-win32.zip">Eclipse IDE for Java EE Developers (163 MB)</ulink>.
+      </para>
+      <para>The classic version of eclipse will not be sufficient as it does 
+      not have an XML editor.
+      </para>
+    </section>
+    <section>
+      <title>Add the update site <literal>gpd/jbpm-gpd-site.zip</literal></title>
+      <para>The installation of the GPD uses the Eclipse Software Update 
+      mechanism and is pretty straightforward. There is an archived update 
+      site included in the runtime installation of jBPM when you unzip it 
+      at <literal>gpd/jbpm-gpd-site.zip</literal> 
+      </para>
+      <para>To add the update site to eclipse:
+      </para>
+      <itemizedlist>
+        <listitem><literal>Help</literal> --> <literal>Software Updates</literal></listitem> 
+        <listitem>Select tab <literal>Available Software</literal></listitem>
+        <listitem>Click <literal>Add Site...</literal> </listitem>
+        <listitem>In dialog <literal>Add Site</literal> dialog, click <literal>Archive...</literal></listitem>
+        <listitem>Navigate to <literal>gpd/jbpm-gpd-site.zip</literal></listitem>
+        <listitem>Clicking <literal>OK</literal> will bring you back to the dialog 'Software Updates and Add-ons'</listitem>
+        <listitem>Select the <literal>jPDL 4 GPD Update Site</literal> that has appeared</listitem>
+        <listitem>Click <literal>Install...</literal> </listitem>
+        <listitem>In dialog <literal>Install</literal>, select <literal>Flow Common Feature</literal> 
+          and <literal>jPDL 4 Feature</literal></listitem>
+        <listitem>Click <literal>Next</literal></listitem>
+        <listitem>Select <literal>Accept</literal> and click <literal>Finish</literal></listitem>
+        <listitem>Restart eclipse</listitem>
+      </itemizedlist>
+      <figure id="gpd.install.gpd.site">
+        <title>Adding the GPD local archive site</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.gpd.site.png"/></imageobject></mediaobject>
+      </figure>
+    </section>
+    <section>
+      <title>Define the jBPM User Library</title>
+      <para>This section shows how to define a user library for your workspace
+      that is a placeholder for the jBPM library as well as its dependencies. 
+      If you create a new Java project, it will be sufficient to add this user 
+      library to the build path.
+      </para>
+      <itemizedlist>
+        <listitem>Click <literal>Window</literal> --> <literal>Preferences</literal> </listitem>
+        <listitem>Select <literal>Java</literal> --> <literal>Build Path</literal> --> <literal>User Libraries</literal> </listitem>
+        <listitem>Click <literal>New...</literal> </listitem>
+        <listitem>Type name <literal>jBPM Libraries</literal> </listitem>
+        <listitem>Click <literal>Add JARs...</literal> </listitem>
+        <listitem>Navigate to the 'lib' folder of your jBPM installation</listitem>
+        <listitem>Select all jar files and click <literal>Open</literal> </listitem>
+        <listitem>Select the <literal>jBPM Libraries</literal> entry</listitem>
+        <listitem>Click <literal>Add JARs...</literal> again</listitem>
+        <listitem>Select the <literal>jbpm.jar</literal> file in the root of your jBPM installation</listitem>
+        <listitem>Click <literal>Open</literal> </listitem>
+        <listitem>Select entry <literal>Source attachment</literal> under <literal>jbpm.jar</literal> </listitem>
+        <listitem>Click <literal>Edit</literal> </listitem>
+        <listitem>In dialog <literal>Source Attachment Configuration</literal>, click <literal>External Folder...</literal> </listitem>
+        <listitem>Navigate to the <literal>src</literal> folder in your jBPM installation</listitem>
+        <listitem>Click <literal>Choose</literal> </listitem>
+        <listitem>Click <literal>OK</literal> twice to close all the open dialogs</listitem>
+      </itemizedlist>
+      <figure id="gpd.install.libraries">
+        <title>Defining jBPM Libraries</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.libraries.png"/></imageobject></mediaobject>
+      </figure>
+    </section>
+    
+    <section>
+      <title>Adding jPDL 4 schema to the catalog</title>
+      <para>In case you want to edit the process XML sources directly, it is best to specify 
+      your schema in the XML catalog.  This will give you better code completion while 
+      editing the process sources.
+      </para>
+      <itemizedlist>
+        <listitem>Click <literal>Window</literal> --> <literal>Preferences</literal> </listitem>
+        <listitem>Select <literal>XML</literal> --> <literal>XML Catalog</literal></listitem>
+        <listitem>Click 'Add...'</listitem>
+        <listitem>The 'Add XML Catalog Entry' dialog opens</listitem>
+        <listitem>Click the button with the map-icon next to location and select 'File System...'</listitem>
+        <listitem>In the dialog that opens, select file <literal>jpdl.xsd</literal> 
+        in the src directory of the jBPM installation root.</listitem>
+        <listitem>Click 'Open' and close all the dialogs</listitem>
+      </itemizedlist>
+      <figure id="gpd.install.xml.catalog">
+        <title>Adding jPDL 4 schema to the Catalog</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.xml.catalog.png"/></imageobject></mediaobject>
+      </figure>
+    </section>
+    
+    <section>
+      <title>Importing the Examples</title>
+      <para>In this section we will import the examples project in the 
+      installation in Eclipse
+      </para>
+      <itemizedlist>
+        <listitem>Select <literal>File</literal> --> <literal>Import...</literal> </listitem>
+        <listitem>Select <literal>General</literal> --> <literal>Existing Projects into Workspace</literal> </listitem>
+        <listitem>Click <literal>Next</literal></listitem>
+        <listitem>Click <literal>Browse...</literal> to select a root directory</listitem>
+        <listitem>Navigate to the jBPM root installation directory</listitem>
+        <listitem>Click <literal>OK</literal> </listitem>
+        <listitem>The <literal>examples</literal> project is automatically found and selected</listitem>
+        <listitem>Click <literal>Finish</literal> </listitem>
+      </itemizedlist>
+      <para>You're all set to start playing with the coolest Java process technology!</para>
+    </section>
+  </section>
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,50 @@
+<chapter id="gpd">
+  <title>GPD</title>
+  
+  <para>This chapter will explain how to work with the Graphical Process Designer. 
+  After installing the GPD and setting up the examples, you'll see that the 
+  jPDL process files will get a special icon.  Double clicking such a file 
+  in the package view will open up the jPDL process in the GPD.
+  </para>
+  <figure id="gpd">
+    <title>The GPD</title>
+    <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.png"/></imageobject></mediaobject>
+  </figure>
+  
+  <section id="creatingnewprocessfile">
+    <title>Creating a new process file</title>
+    <para>CRTL+N will open up the wizard selector.
+    </para>
+    <figure id="gpd.new.process.wizard">
+      <title>Select wizard dialog</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.new.process.wizard.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Select jBPM --> jPDL 4 File.  Click 'Next &gt;'.  Then the 
+    'New jPDL 4 File' wizard opens.  
+    </para>
+    <figure id="gpd.new.process.file">
+      <title>Create a new process dialog</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.new.process.file.png"/></imageobject></mediaobject>
+    </figure>
+    <para>Select the parent directory, enter a file name and click 'Finish'.  Voila, 
+    you've created your first jPDL process file.
+    </para>
+  </section>
+
+  <section id="editingtheprocesssource">
+    <title>Editing the process source</title>
+    <para>To edit the process XML sources directly, select the process file, right click
+    and select 'Open with...' --> 'XML editor'
+    </para>
+    <figure id="gpd.open.in.xml">
+      <title>Open a process file in XML editor</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.open.in.xml.png"/></imageobject></mediaobject>
+    </figure>
+    <para>After you've done this, eclipse will remember that and the next time 
+    you double click it, eclipse will open your process file in the XML Editor 
+    automatically.  To open up the process file in the GPD, perform the 
+    same Open-with-action, but select 'jPDL 4 Editor'  
+    </para>
+  </section>
+  
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,896 @@
+<chapter id="jpdl">
+  <title>jPDL</title>
+  
+  <para>This chapter will explain the jPDL file format for describing 
+  process definitions.  The schemadocs can also serve as a quick reference for this 
+  information. 
+  </para>
+  <para>An example jPDL process file looks like this: 
+  </para>
+  <programlisting>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+
+&lt;process name=&quot;Purchase order&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;Verify supplier&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;Verify supplier&quot;&gt;
+    &lt;transition name=&quot;Supplier ok&quot; to=&quot;Check supplier data&quot; /&gt;
+    &lt;transition name=&quot;Supplier not ok&quot; to=&quot;Error&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;exclusive name=&quot;Check supplier data&quot;&gt;
+    &lt;transition name=&quot;nok&quot; to=&quot;Error&quot; /&gt;
+    &lt;transition name=&quot;ok&quot; to=&quot;Completed&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;end name=&quot;Completed&quot; /&gt;
+
+  &lt;end name=&quot;Error&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+  
+  <section id="process">
+    <title><literal>process</literal></title>
+    <para>The top level element representing one process definition.
+    </para>
+    <table><title><literal>process</literal> attributes:</title>
+      <tgroup cols="5" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Attribute</entry>
+            <entry>Type</entry>
+            <entry>Default</entry>
+            <entry>Required?</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>name</literal></entry>
+            <entry>any text</entry>
+            <entry></entry>
+            <entry><emphasis role="bold">required</emphasis></entry>
+            <entry>name or label of the process used to display to the process 
+            name in user interactions.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>key</literal></entry>
+            <entry>alpha numeric characters and underscores</entry>
+            <entry>if omitted, the key will be generated based on the name by replacing 
+            all non-alpha-numeric characters with underscores</entry>
+            <entry>optional</entry>
+            <entry>identification to distinct different process definitions.
+            Multiple versions of a process with the same key can be deployed.
+            The key:name combination must remain exactly the same for all 
+            deployed versions.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>version</literal></entry>
+            <entry>integer</entry>
+            <entry>one higher then highest version number starting with 1 if no other process 
+            is deployed with the same name/key. 
+            </entry>
+            <entry>optional</entry>
+            <entry>version number of this process</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+
+    <table><title><literal>process</literal> elements:</title>
+      <tgroup cols="3" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Element</entry>
+            <entry>Multiplicity</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>description</literal></entry>
+            <entry>0..1</entry>
+            <entry>description text</entry>
+          </row>
+          <row>
+            <entry><link linkend="activities">activities</link></entry>
+            <entry>1..*</entry>
+            <entry>a list of any activity type can be placed here.  At least 
+            one <literal>start</literal> activity must be present.
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+  </section>
+
+  <section id="activities">
+    <title>Activities</title>
+    <para>(BPMN note: when we mention activities here, we are not only refering to BPMN 
+    activities, but also to BPMN events and BPMN gateways.)
+    </para>
+
+    <section id="start">
+      <title><literal>start</literal></title>
+      <para>Indicates where an execution for this process starts.  Typically there is 
+      exactly one start activity in a process.  A process has to have at least one start 
+      activity.  A start activity must have exactly one outgoing transition and that transition 
+      is taken when a process execution starts.
+      </para>
+      <table><title><literal>start</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>name</literal></entry>
+              <entry>any text</entry>
+              <entry></entry>
+              <entry>optional</entry>
+              <entry>name of the activity.  Since a start activity 
+              cannot have incoming transitions, the name is optional. 
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>start</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>transition</literal></entry>
+              <entry>1</entry>
+              <entry>the outgoing transition</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+
+    <section id="state">
+      <title><literal>state</literal></title>
+      <para>A wait state.  Process execution will wait until an external trigger is 
+      provided through the API.  Apart from the <link linkend="commonactivitycontent">
+      common activity content</link>, <literal>state</literal> doesn't have any extra
+      attributes or elements. 
+      </para>
+      <section id="statesequence">
+        <title><literal>state</literal> sequence</title>
+        <para>Let's look at an example which shows states connected with transitions 
+        as a sequence</para>
+        <figure id="state.sequence">
+          <title>A sequence of states</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/state.sequence.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;StateSequence&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;a&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;a&quot;&gt;
+    &lt;transition to=&quot;b&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;b&quot;&gt;
+    &lt;transition to=&quot;c&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;c&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>After you start an execution like this:</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <para>the created process instance will be positioned in 
+        state <literal>a</literal>.  Providing an external trigger can 
+        be done with the <literal>signalExecution</literal> methods.</para>
+        <programlisting>String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId);</programlisting>
+      </section>
+      <section id="statechoice">
+        <title><literal>state</literal> choice</title>
+        <para>In this second example with states, we'll show how you can use a 
+        <literal>state</literal> can be used to feed in an external choice of 
+        the path to take.
+        </para>
+        <figure id="state.choice">
+          <title>A choice between state</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/state.choice.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;StateChoice&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;wait for response&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;wait for response&quot;&gt;
+    &lt;transition name=&quot;accept&quot; to=&quot;submit document&quot; /&gt;
+    &lt;transition name=&quot;reject&quot; to=&quot;try again&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>Let's start a new process instance for this process definition:</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <para>Now, the execution is arrived in the <literal>wait for response</literal>. 
+        The execution will wait there until an external trigger is given.  In case 
+        a <literal>state</literal> has multiple outgoing transitions, the signalName given 
+        in the external trigger will be matched against the name of the outgoing transition 
+        to take.  So when we provide signalName <literal>accept</literal> like this:
+        </para>
+        <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
+        <para>Then the execution will continue over the outgoing transition named 
+        <literal>accept</literal>.  Analogue, when signalName <literal>reject</literal> 
+        is given in the signalExecutionXxx methods, the execution will continue over 
+        the outgoing transition named reject.  
+        </para>
+      </section>
+    </section>
+    
+    <section id="java">
+      <title><literal>java</literal></title>
+      <para>The Java task. A process execution will execute the method of the class that is configured
+      in this task.</para> 
+      <table><title><literal>java</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>class</literal></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+            <row>
+              <entry><literal>method</literal></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+            <row>
+              <entry><literal>var</literal></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>java</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>field</literal></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+            <row>
+              <entry><literal>arg</literal></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>Consider the following example.</para>
+      <figure id="java">
+        <title>A java task</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/java.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;Java&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;invoke java method&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;java name=&quot;invoke java method&quot; 
+        class=&quot;org.jbpm.examples.java.JohnDoe&quot;
+        method=&quot;hello&quot;
+        var=&quot;answer&quot;&gt;
+        
+    &lt;field name=&quot;state&quot;&gt;&lt;string value=&quot;fine&quot;/&gt;&lt;/field&gt;
+    &lt;field name=&quot;session&quot;&gt;&lt;env type=&quot;org.hibernate.Session&quot;/&gt;&lt;/field&gt;
+
+    &lt;arg&gt;&lt;string value=&quot;Hi, how are you?&quot;/&gt;&lt;/arg&gt;
+    
+    &lt;transition to=&quot;wait&quot; /&gt;
+  &lt;/java&gt;
+  
+  &lt;state name=&quot;wait&quot;&gt;
+
+&lt;/process&gt;
+      </programlisting>
+      <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
+      will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
+      <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
+      </para>
+      <programlisting>package org.jbpm.examples.java;
+
+import org.hibernate.Session;
+
+public class JohnDoe {
+  
+  String state;
+  Session session;
+  
+  public String hello(String msg) {
+    if ( (msg.indexOf(&quot;how are you?&quot;)!=-1)
+         &amp;&amp; (session.isOpen())
+       ) {
+      return &quot;I&#39;m &quot;+state+&quot;, thank you.&quot;;
+    }
+    return null;
+  }
+}
+    </programlisting>
+    <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
+    and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the 
+    <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
+    a process instance is that the process variable <literal>answer</literal> contains the string
+    <literal>I'm fine, thank you.</literal>.
+    </para>
+    </section>
+
+    <section id="script">
+      <title><literal>script</literal></title>
+      <para>The Script task. A process execution will execute a script that is specified by this task. The script can be 
+      specified by either the <literal>expr</literal> attribute or by the inclusion of the <literal>text</literal> nested
+      element. The result of the evaluation 
+      </para>
+      <table><title><literal>script</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>expr</literal></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+            <row>
+              <entry><literal>var</literal></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>script</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>text</literal></entry>
+              <entry></entry>
+              <entry></entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>Consider the following example.</para>
+      <figure id="script">
+        <title>A script task</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/script.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;ScriptExpression&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;invoke script&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;script name=&quot;invoke script&quot; 
+          expr=&quot;Send packet to #{person.address}&quot;
+          var=&quot;text&quot;&gt;
+
+    &lt;transition to=&quot;wait&quot; /&gt;
+  &lt;/script&gt;
+  
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+    </section>
+
+    <section id="esb">
+      <title><literal>esb</literal></title>
+    </section>
+
+    <section id="sql">
+      <title><literal>sql</literal></title>
+    </section>
+
+    <section id="hql">
+      <title><literal>hql</literal></title>
+    </section>
+
+    <section id="task">
+      <title><literal>task</literal></title>
+    </section>
+
+    <section id="exclusive">
+      <title><literal>exclusive</literal></title>
+      <para>Takes one path of many alternatives. Also known as a decision. An exclusive 
+      activity has multiple outgoing transitions and when an execution arrives in an exclusive 
+      activity, an automatic evaluation will decide which outgoing transition is taken.
+      </para>
+      <para>An exclusive activity should be configured in one of the three following ways:  
+      </para>
+      
+      <section id="exclusiveconditions">
+        <title>Exclusive conditions</title>
+        <para>An exclusive with conditions on the transitions evaluates the condition in each transition. 
+        The first transition for which the nested condition expression resolves to true or which does 
+        not have a condition is taken.
+        </para>
+        <table><title><literal>exclusive.transition.condition</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>expr</literal></entry>
+                <entry>expression</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>script that will be evaluated in the specified 
+                expression language.
+                </entry>
+              </row>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>expression language</entry>
+                <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+                <entry>optional</entry>
+                <entry>the language in which <literal>expr</literal> is 
+                to be evaluated.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Example:
+        </para>
+        <figure id="exclusive">
+          <title>The exclusive gateway</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/exclusive.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;ExclusiveConditions&quot; &gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;evaluate document&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;exclusive name=&quot;evaluate document&quot;&gt;
+    &lt;transition to=&quot;submit document&quot;&gt;
+      <emphasis role="bold">&lt;condition expr=&quot;#{content==&quot;good&quot;}&quot; /&gt;</emphasis>
+    &lt;/transition&gt;
+    &lt;transition to=&quot;try again&quot;&gt;
+      <emphasis role="bold">&lt;condition expr=&quot;#{content==&quot;not so good&quot;}&quot; /&gt;</emphasis>
+    &lt;/transition&gt;
+    &lt;transition to=&quot;give up&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+  &lt;state name=&quot;give up&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+      </section>
+
+      <section id="exclusiveexpression">
+        <title>Exclusive expression</title>
+        <para>An exclusive expression evaluates to a String representing the name of 
+        an outgoing transition.
+        </para>
+        <table><title><literal>exclusive</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>expr</literal></entry>
+                <entry>expression</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>script that will be evaluated in the specified 
+                expression language.
+                </entry>
+              </row>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>expression language</entry>
+                <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+                <entry>optional</entry>
+                <entry>the language in which <literal>expr</literal> is 
+                to be evaluated.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Example:
+        </para>
+        <para>Same picture as <link linkend="exclusive">above</link>.
+        </para>
+        <programlisting>&lt;process name=&quot;Poolcar&quot;&gt;
+  &lt;start&gt;
+    &lt;transition to=&quot;How far?&quot; /&gt;
+  &lt;/start&gt;
+  &lt;exclusive name=&quot;How far?&quot; <emphasis role="bold">expr=&quot;#{distance}&quot;</emphasis>&gt;
+    &lt;transition name=&quot;far&quot;    to=&quot;Big car&quot; /&gt;
+    &lt;transition name=&quot;nearby&quot; to=&quot;Small car&quot; /&gt;
+  &lt;/exclusive&gt;
+  &lt;state name=&quot;Big car&quot; /&gt;
+  &lt;state name=&quot;Small car&quot; /&gt;
+&lt;/process&gt;</programlisting>
+        <para>When you start an new process instance like this
+        </para>
+        <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+variables.put("distance", "far");
+Execution execution = executionService.startProcessInstanceByKey(&quot;Poolcar&quot;, variables);</programlisting>
+        <para>then the new execution will go to activity <literal>Big car</literal>.</para>
+      </section>
+
+      <section id="exclusivehandler">
+        <title>Exclusive handler</title>
+        <para>An exclusive handler is a java class that implements the 
+        <literal>ExclusiveHandler</literal> interface.  The exclusive handler 
+        will be responsible for selecting the name of the outgoing transition. 
+        </para>
+        <programlisting>public interface ExclusiveHandler {
+  String select(OpenExecution execution);
+}</programlisting>
+        <para>The handler is specified as a sub element of the exclusive</para>
+        <table><title><literal>exclusive.handler</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>class</literal></entry>
+                <entry>classname</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>fully qualified classname of the handler implementation class.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
+        <para>Same picture as <link linkend="exclusive">above</link>.
+        </para>
+        <programlisting>&lt;process name=&quot;ExclusiveHandler&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;evaluate document&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;exclusive name=&quot;evaluate document&quot;&gt;
+    &lt;handler class=&quot;org.jbpm.examples.exclusive.handler.ContentEvaluation&quot; /&gt;
+    &lt;transition name=&quot;good&quot; to=&quot;submit document&quot; /&gt;
+    &lt;transition name=&quot;bad&quot; to=&quot;try again&quot; /&gt;
+    &lt;transition name=&quot;ugly&quot; to=&quot;give up&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+  &lt;state name=&quot;give up&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>The ContentEvaluation class looks like this</para>
+        <programlisting>public class ContentEvaluation implements ExclusiveHandler {
+
+  public String select(OpenExecution execution) {
+    String content = (String) execution.getVariable(&quot;content&quot;);
+    if (content.equals(&quot;you're great&quot;)) {
+      return &quot;good&quot;;
+    }
+    if (content.equals(&quot;you gotta improve&quot;)) {
+      return &quot;bad&quot;;
+    }
+    return &quot;ugly&quot;;
+  }
+}</programlisting>
+        <para>Now, when we start a process instance and supply value
+        <literal>you're great</literal> for variable content, then the 
+        ContentEvaluation will return String <literal>good</literal> and 
+        the process instance will arrive in activity <literal>Submit document</literal>. 
+        </para>
+      </section>
+      
+    </section>
+
+    <section id="end">
+      <title><literal>end</literal></title>
+      <para>Ends the execution.
+      </para>
+      <section id="endprocessinstance">
+        <title><literal>end</literal> process instance</title>
+        <para>By default, an end activity will end the complete 
+        process instance.  In case multiple concurrent executions 
+        are still active within the same process instance, all of 
+        them will be ended. 
+        </para>
+        <figure id="end.processinstance">
+          <title>The end event</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/end.processinstance.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndProcessInstance&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;end&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;end name=&quot;end&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>When a new process instance is created, it immediately ends.</para>
+      </section>
+      <section id="endexecution">
+        <title><literal>end</literal> execution</title>
+        <para>Only the execution that arrives in the 
+        end activity will be ended and other concurrent executions  
+        should be left active.  To get this behaviour, set 
+        attribute <literal>ends=&quot;execution&quot;</literal>
+        </para>
+        <table><title><literal>end</literal> execution attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>ends</literal></entry>
+                <entry>{processinstance|execution}</entry>
+                <entry>processinstance</entry>
+                <entry>optional</entry>
+                <entry>specifies if the whole process instance should be ended or 
+                just the path of execution that arrives in the end activity. 
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+      </section>
+      <section id="endmultiple">
+        <title><literal>end</literal> multiple</title>
+        <para>A process can have multiple end events.  This can be handy to indicate 
+        different outcomes of a process instance.  For example
+        </para>
+        <figure id="end.multiple">
+          <title>Multiple end events</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/end.multiple.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndMultiple&quot; xmlns=&quot;http://;jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;get return code&quot; /&gt;
+  &lt;start&gt;
+  
+  &lt;state name=&quot;get return code&quot;&gt;
+    &lt;transition name=&quot;200&quot; to=&quot;ok&quot;/&gt;
+    &lt;transition name=&quot;400&quot; to=&quot;bad request&quot;/&gt;
+    &lt;transition name=&quot;500&quot; to=&quot;internal server error&quot;/&gt;
+  &lt;/state&gt;
+  
+  &lt;end name=&quot;ok&quot;/&gt;
+  &lt;end name=&quot;bad request&quot;/&gt;
+  &lt;end name=&quot;internal server error&quot;/&gt;
+  
+&lt;/process&gt;
+        </programlisting>
+        <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
+        following code, the execution would end with the <literal>bad request</literal> end event.</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndMultiple&quot;);
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
+        </programlisting>
+        <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+        to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
+        respectively.</para>
+      </section>
+      
+      <section id="endstate">
+        <title><literal>end</literal> state</title>
+        <para>An execution can also end with different states. It is another way to specify the outcome of a process. 
+        It is indicated by the <literal>state</literal> attribute of the end event or by the <literal>end-cancel</literal> 
+        and <literal>end-error</literal> shortcut notations.
+        </para>
+
+        <table><title><literal>end</literal> execution attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>state</literal></entry>
+                <entry>String</entry>
+                <entry></entry>
+                <entry>optional</entry>
+                <entry>the state assigned to the execution. 
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+
+        <para>Take for example the following process.
+        </para>
+        <figure id="end.state">
+          <title>Different end states</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/end.state.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndState&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+     &lt;transition to=&quot;get return code&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;get return code&quot;&gt;
+    &lt;transition name=&quot;200&quot; to=&quot;ok&quot;/&gt;
+    &lt;transition name=&quot;400&quot; to=&quot;bad request&quot; /&gt;
+    &lt;transition name=&quot;500&quot; to=&quot;internal server error&quot;/&gt;
+  &lt;/state&gt;
+
+  &lt;end name=&quot;ok&quot; state=&quot;completed&quot;/&gt;
+  &lt;end-cancel name=&quot;bad request&quot;/&gt;
+  &lt;end-error name=&quot;internal server error&quot;/&gt;
+
+&lt;/process&gt;
+        </programlisting>
+        <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
+        following code, the execution would end with the <literal>cancel</literal> state.</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndState&quot;);
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
+        </programlisting>
+        <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+        to end with the <literal>completed</literal> or with the <literal>error</literal> states
+        respectively.</para>
+        
+      </section>
+    </section>
+
+    <section id="commonactivitycontents">
+      <title>Common activity contents</title>
+      <para>Unless specified otherwise above, all activities also include this 
+      content model:
+      </para>
+      <table><title>Common activity attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>name</literal></entry>
+              <entry>any text</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>name of the activity</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title>Common activity elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>transition</literal></entry>
+              <entry>0..*</entry>
+              <entry>the outgoing transitions</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+  </section>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,292 @@
+<chapter id="services">
+  <title>Services</title>
+  
+  <para>Interacting with jBPM occurs through services.
+  The service interfaces can be obtained from the <literal>ProcessEngine</literal>
+  which is build from a <literal>Configuration</literal>. 
+  </para>
+  
+  <section id="processengine">
+    <title>ProcessEngine</title>
+  
+    <para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a 
+    static member field or even better in JNDI or some other central location.  
+    One <literal>ProcessEngine</literal> object can be used by all requests and 
+    threads in an application.  Here's how you can obtain a <literal>ProcessEngine</literal>
+    </para>
+    
+    <programlisting>ProcessEngine processEngine = new Configuration()
+      .buildProcessEngine();</programlisting>
+    
+    <para>The previous code snippet shows how to build a <literal>ProcessEngine</literal>
+    from the default configuration file <literal>jbpm.cfg.xml</literal> which is 
+    expected in the root of the classpath.  If you want to specify another 
+    resource location, use the <literal>setResource</literal> method like this: 
+    </para>
+    
+    <programlisting>ProcessEngine processEngine = new Configuration()
+      .setResource("my-own-configuration-file.xml")
+      .buildProcessEngine();</programlisting>
+    
+    <para>There are other <literal>setXxxx</literal> methods that allow to specify 
+    the configuration content as an <literal>InputStream</literal>, an 
+    <literal>xmlString</literal>, <literal>InputSource</literal>, 
+    <literal>URL</literal> or  <literal>File</literal>.  
+    </para>
+  
+    <para>From a <literal>ProcessEngine</literal> the following services 
+    can be obtained:
+    </para>
+    
+    <programlisting><emphasis role="bold">ProcessService</emphasis> processService = processEngine.getProcessService();
+<emphasis role="bold">ExecutionService</emphasis> executionService = processEngine.getExecutionService();
+<emphasis role="bold">ManagementService</emphasis> managementService = processEngine.getManagementService();
+<emphasis role="bold">TaskService</emphasis> taskService = processEngine.getTaskService();</programlisting>
+
+    <para>Process engine objects defined in the configuration can also be retrieved by 
+    type (<literal>processEngine.get(Class&lt;T&gt;)</literal>) 
+    or by name (<literal>processEngine.get(String)</literal>)</para>
+
+  </section>
+
+  <section id="deployingaprocess">
+    <title>Deploying a process</title>
+    <para>The <literal>ProcessService</literal> groups all methods that access 
+    the repository of process definitions.
+    </para>
+    <para>A jPDL process file like e.g. <literal>order.jpdl.xml</literal> that is 
+    accessible as a resource on the classpath can be deployed programmatically with the 
+    <literal>ProcessService</literal> like this:
+    </para>
+    <programlisting>processService.createDeployment()
+    .addResource("order.jpdl.xml")
+    .deploy();</programlisting>
+    <para>Analogue to the <literal>addResource</literal> method above, the source of 
+    the processes definitions XML can be picked up from a file, url, string, 
+    input stream, zip or jar archive and a directory.
+    </para>
+    <para>A deployment works with a set of named resources and can potentially contain 
+    multiple process descriptions and multiple other artifact types.  The jPDL deployer 
+    will recognise process files based on the <literal>.jpdl.xml</literal> 
+    extension automatically.  For files not adhering to that naming 
+    convention, the type can be set programmatically to <literal>jpdl</literal>
+    with method <literal>setFileType("my-jpdl-process.someotherextension", "jpdl")</literal>
+    </para>
+    <para>During deployment, an <literal>id</literal> is assigned to the process 
+    definitions.  The <literal>id</literal> will have format 
+    <literal>{key}:{version}</literal>
+    </para>
+    <para>If <literal>key</literal> is not provided, it is generated automatically 
+    based on the name.  All non alpha numeric characters in the name will be replaced 
+    by underscores to generate the key.
+    </para>
+    <para>The same <literal>name</literal> can only be associated to one 
+    <literal>key</literal> and vice verca.
+    </para>
+    <para>If <literal>version</literal> is not provided, a <literal>version</literal> 
+    will be automatically be assigned.  For version 
+    assignment, the versions of all deployed process definitions with the same name will 
+    be taken into account.  The assigned <literal>version</literal> will be one higher 
+    then the highest <literal>version</literal> number of deployed process definitions 
+    with the same <literal>key</literal>.  If no process definitions with a similar
+    <literal>key</literal> have been deployed, version number 1 is assigned. 
+    </para>
+    <para>In this first example, we'll supply a name and nothing else.</para>
+    <programlisting>&lt;process name=&quot;Insurance claim&quot;&gt;
+...
+&lt;/process&gt;</programlisting>
+    <para>Let's assume that this is the first time that this process gets deployed.
+    Then it will get the following properties:
+    </para>
+    <table><title>Process properties without key</title>
+      <tgroup cols="3" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Value</entry>
+            <entry>Source</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>name</literal></entry>
+            <entry>Insurance claim</entry>
+            <entry>process xml</entry>
+          </row>
+          <row>
+            <entry><literal>key</literal></entry>
+            <entry>Insurance_claim</entry>
+            <entry>generated</entry>
+          </row>
+          <row>
+            <entry><literal>version</literal></entry>
+            <entry>1</entry>
+            <entry>generated</entry>
+          </row>
+          <row>
+            <entry><literal>id</literal></entry>
+            <entry>Insurance_claim:1</entry>
+            <entry>generated</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+    <para>And as a second example, we'll show how you can get shorter ids by 
+    specifying a process key:</para>
+    <programlisting>&lt;process name=&quot;Insurance claim&quot; key=&quot;ICL&quot;&gt;
+...
+&lt;/process&gt;</programlisting>
+    <para>Then the process definition properties look like this:</para>
+    <table><title>Process properties with key</title>
+      <tgroup cols="2" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Property</entry>
+            <entry>Value</entry>
+            <entry>Source</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>name</literal></entry>
+            <entry>Insurance claim</entry>
+            <entry>process xml</entry>
+          </row>
+          <row>
+            <entry><literal>key</literal></entry>
+            <entry>ICL</entry>
+            <entry>process xml</entry>
+          </row>
+          <row>
+            <entry><literal>version</literal></entry>
+            <entry>1</entry>
+            <entry>generated</entry>
+          </row>
+          <row>
+            <entry><literal>id</literal></entry>
+            <entry>ICL:1</entry>
+            <entry>generated</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+  </section>
+
+  <section id="startinganewprocessinstance">
+    <title>Starting a new process instance</title>
+    
+    <section id="inlatest">
+      <title>In latest</title>
+      <para>Simplest and most common way to start a new process instance for a process 
+      definition is like this: 
+      </para>
+      <programlisting>executionService.startProcessInstanceByKey("ICL");</programlisting>
+      <para>In this case, the service method will first look up the latest version of 
+      the processes with key <literal>ICL</literal>.  Then a new 
+      process instance is started in that latest process definition.
+      </para>
+      <para>When a new version of the insurance claim process 
+      is deployed, all invocations of <literal>startProcessInstanceByKey</literal>
+      will automatically switch to the newly deployed version.
+      </para>
+    </section>
+
+    <section id="specificprocessversion">
+      <title>Specific process version</title>
+      <para>If instead you want to start a new process instance in a very 
+      specific version, you can use the id of the process definition like this:
+      </para>
+      <programlisting>executionService.startProcessInstanceById("ICL:1");</programlisting>
+    </section>
+
+    <section id="withakey">
+      <title>With a key</title>
+      <para>A new process instance can optionally be given a key.  A key is 
+      a user defined reference to the execution.  A key must be unique within the 
+      scope of all versions of a process definition.  Typically it is easy 
+      to find such a key in the domain of the business process.  For example, an 
+      order id or an insurance claim number.
+      </para>
+      <programlisting>executionService.startProcessInstanceByKey("ICL", "CL92837");</programlisting>
+      <para>The key is used to create the id of the process instance.  
+      The format used is <literal>{process-key}/{execution-id}</literal>.
+      So execution created in the previous code snippet will have id 
+      <literal>ICL/CL92837</literal>.
+      </para>  
+      <para>If no user defined key is provided, the DB primary key is taken
+      as the key.  In that case, the id can be retrieved like this:   
+      <programlisting>Execution execution = executionService.startProcessInstanceByKey("ICL");
+String executionId = execution.getId();</programlisting>
+      </para> 
+      <para>We recommend the use of a user defined keys.  Typically in your application 
+      code, you'll have the key available.  By providing a user defined key, you can 
+      then compose the id of the execution, rather then performing a query based 
+      on the process variables.
+      </para>
+    </section>
+    
+    <section id="withvariables">
+      <title>With variables</title>
+      <para>A map of named parameter objects can be provided when starting a 
+      new process instance.  These parameters will be set as variables on the process 
+      instance between creation and start of the process instance.
+      </para>
+      <programlisting>Map&lt;String,Object&gt; variables = new HashMap&lt;String,Object&gt;();
+variables.put("customer", "John Doe");
+variables.put("type", "Accident");
+variables.put("amount", new Float(763.74));
+
+executionService.startProcessInstanceByKey("ICL", variables);</programlisting>
+    </section>
+  </section>
+
+  <section id="singallingawaitingexecution">
+    <title>Signalling a waiting execution</title>
+    <para>A process definition describes what must be done in terms of activities.
+    Each activity in a process is either to be performed by the process 
+    system or by an external participant.  When an activity is to be performed 
+    by an external participant, then the execution must wait until the 
+    external participant notifies the process system that the activity is 
+    completed.  So an execution is either executing or waiting on an external 
+    participant.  Typically, you'll see that the processes are mostly 
+    waiting for external participants.  Especially humans tend to be slow :-)
+    The time consumed by the process system between two wait states is 
+    typically very small.
+    </para>
+    <para>A <literal>state</literal> is the basic activity that represents 
+    something has to be done by an external participant and the execution 
+    must wait until a signal (aka external trigger) is given.
+    </para>
+    <para>When an execution is in a wait state, it can be given an external trigger 
+    with one of the signal methods.  The recommended way to reference an execution 
+    is by using the process definition and execution key.  In the next code snippet,
+    <literal>ICL</literal> refers to the process definition key and <literal>82436</literal>
+    refers to the execution key.
+    </para>
+    <programlisting>executionService.signalExecutionByKey(&quot;ICL&quot;, &quot;82436&quot;);</programlisting>
+    <para>Alternatively, the execution that must be signaled can be referenced
+    by a unique execution id.  In the next snippet, <literal>ICL/82436</literal> 
+    refers to the executionId.</para>
+    <programlisting>executionService.signalExecutionById(&quot;ICL/82436&quot;);</programlisting>
+    <para>Optionally some data can be passed along with a signal: a <literal>signalName</literal> 
+    and <literal>parameters</literal>.  How the signalName gets used depends on 
+    the execution's current activity.  The parameters get stored as process variables.
+    </para>
+    <programlisting>Map&lt;String,Object&gt; parameters = new HashMap&lt;String,Object&gt;();
+parameters.put(&quot;quality&quot;, &quot;a+&quot;); 
+parameters.put(&quot;target&quot;, &quot;profit&quot;); 
+
+executionService.signalExecutionById("ICL/82436", &quot;Accept&quot;, parameters);</programlisting>
+  </section>
+
+  <section id="taskservice">
+    <title>TaskService</title>
+    <para></para>
+  </section>
+
+  <section id="managementservice">
+    <title>ManagementService</title>
+    <para></para>
+  </section>
+
+</chapter>
\ No newline at end of file

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,1312 @@
+<chapter id="jpdl">
+  <title>jPDL</title>
+  
+  <para>This chapter will explain the jPDL file format for describing 
+  process definitions.  The schemadocs can also serve as a quick reference for this 
+  information. 
+  </para>
+  <para>An example jPDL process file looks like this: 
+  </para>
+  <programlisting>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+
+&lt;process name=&quot;Purchase order&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;Verify supplier&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;Verify supplier&quot;&gt;
+    &lt;transition name=&quot;Supplier ok&quot; to=&quot;Check supplier data&quot; /&gt;
+    &lt;transition name=&quot;Supplier not ok&quot; to=&quot;Error&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;exclusive name=&quot;Check supplier data&quot;&gt;
+    &lt;transition name=&quot;nok&quot; to=&quot;Error&quot; /&gt;
+    &lt;transition name=&quot;ok&quot; to=&quot;Completed&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;end name=&quot;Completed&quot; /&gt;
+
+  &lt;end name=&quot;Error&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+  
+  <section id="process">
+    <title><literal>process</literal></title>
+    <para>The top level element representing one process definition.
+    </para>
+    <table><title><literal>process</literal> attributes:</title>
+      <tgroup cols="5" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Attribute</entry>
+            <entry>Type</entry>
+            <entry>Default</entry>
+            <entry>Required?</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>name</literal></entry>
+            <entry>any text</entry>
+            <entry></entry>
+            <entry><emphasis role="bold">required</emphasis></entry>
+            <entry>name or label of the process used to display to the process 
+            name in user interactions.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>key</literal></entry>
+            <entry>alpha numeric characters and underscores</entry>
+            <entry>if omitted, the key will be generated based on the name by replacing 
+            all non-alpha-numeric characters with underscores</entry>
+            <entry>optional</entry>
+            <entry>identification to distinct different process definitions.
+            Multiple versions of a process with the same key can be deployed.
+            The key:name combination must remain exactly the same for all 
+            deployed versions.
+            </entry>
+          </row>
+          <row>
+            <entry><literal>version</literal></entry>
+            <entry>integer</entry>
+            <entry>one higher then highest version number starting with 1 if no other process 
+            is deployed with the same name/key. 
+            </entry>
+            <entry>optional</entry>
+            <entry>version number of this process</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+
+    <table><title><literal>process</literal> elements:</title>
+      <tgroup cols="3" rowsep="1" colsep="1">
+        <thead>
+          <row>
+            <entry>Element</entry>
+            <entry>Multiplicity</entry>
+            <entry>Description</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><literal>description</literal></entry>
+            <entry>0..1</entry>
+            <entry>description text</entry>
+          </row>
+          <row>
+            <entry><link linkend="activities">activities</link></entry>
+            <entry>1..*</entry>
+            <entry>a list of any activity type can be placed here.  At least 
+            one <literal>start</literal> activity must be present.
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+  </section>
+
+  <section id="activities">
+    <title>Activities</title>
+    <para>(BPMN note: when we mention activities here, we are not only refering to BPMN 
+    activities, but also to BPMN events and BPMN gateways.)
+    </para>
+
+    <section id="start">
+      <title><literal>start</literal></title>
+      <para>Indicates where an execution for this process starts.  Typically there is 
+      exactly one start activity in a process.  A process has to have at least one start 
+      activity.  A start activity must have exactly one outgoing transition and that transition 
+      is taken when a process execution starts.
+      </para>
+      <para>Known limitation: for now, a process can not have more then 
+      one <literal>start</literal>. 
+      </para>
+      <table><title><literal>start</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>name</literal></entry>
+              <entry>any text</entry>
+              <entry></entry>
+              <entry>optional</entry>
+              <entry>name of the activity.  Since a start activity 
+              cannot have incoming transitions, the name is optional. 
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>start</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>transition</literal></entry>
+              <entry>1</entry>
+              <entry>the outgoing transition</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+
+    <section id="state">
+      <title><literal>state</literal></title>
+      <para>A wait state.  Process execution will wait until an external trigger is 
+      provided through the API.  Apart from the <link linkend="commonactivitycontent">
+      common activity content</link>, <literal>state</literal> doesn't have any extra
+      attributes or elements. 
+      </para>
+      <section id="statesequence">
+        <title><literal>state</literal> sequence</title>
+        <para>Let's look at an example which shows states connected with transitions 
+        as a sequence</para>
+        <figure id="process.state.sequence">
+          <title>A sequence of states</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.state.sequence.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;StateSequence&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;a&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;a&quot;&gt;
+    &lt;transition to=&quot;b&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;b&quot;&gt;
+    &lt;transition to=&quot;c&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;c&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>After you start an execution like this:</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <para>the created process instance will be positioned in 
+        state <literal>a</literal>.  Providing an external trigger can 
+        be done with the <literal>signalExecution</literal> methods.</para>
+        <programlisting>String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId);</programlisting>
+      </section>
+      <section id="statechoice">
+        <title><literal>state</literal> choice</title>
+        <para>In this second example with states, we'll show how you can use a 
+        <literal>state</literal> can be used to feed in an external choice of 
+        the path to take.
+        </para>
+        <figure id="process.state.choice">
+          <title>A choice between state</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.state.choice.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;StateChoice&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;wait for response&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;wait for response&quot;&gt;
+    &lt;transition name=&quot;accept&quot; to=&quot;submit document&quot; /&gt;
+    &lt;transition name=&quot;reject&quot; to=&quot;try again&quot; /&gt;
+  &lt;/state&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>Let's start a new process instance for this process definition:</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <para>Now, the execution is arrived in the <literal>wait for response</literal>. 
+        The execution will wait there until an external trigger is given.  In case 
+        a <literal>state</literal> has multiple outgoing transitions, the signalName given 
+        in the external trigger will be matched against the name of the outgoing transition 
+        to take.  So when we provide signalName <literal>accept</literal> like this:
+        </para>
+        <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
+        <para>Then the execution will continue over the outgoing transition named 
+        <literal>accept</literal>.  Analogue, when signalName <literal>reject</literal> 
+        is given in the signalExecutionXxx methods, the execution will continue over 
+        the outgoing transition named reject.  
+        </para>
+      </section>
+    </section>
+    
+    <section id="exclusive">
+      <title><literal>exclusive</literal></title>
+      <para>Takes one path of many alternatives. Also known as a decision. An exclusive 
+      activity has multiple outgoing transitions and when an execution arrives in an exclusive 
+      activity, an automatic evaluation will decide which outgoing transition is taken.
+      </para>
+      <para>An exclusive activity should be configured in one of the three following ways:  
+      </para>
+      
+      <section id="exclusiveconditions">
+        <title>Exclusive conditions</title>
+        <para>An exclusive with conditions on the transitions evaluates the condition in each transition. 
+        The first transition for which the nested condition expression resolves to true or which does 
+        not have a condition is taken.
+        </para>
+        <table><title><literal>exclusive.transition.condition</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>expr</literal></entry>
+                <entry>expression</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>script that will be evaluated in the specified 
+                expression language.
+                </entry>
+              </row>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>expression language</entry>
+                <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+                <entry>optional</entry>
+                <entry>the language in which <literal>expr</literal> is 
+                to be evaluated.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Example:
+        </para>
+        <figure id="process.exclusive.condition">
+          <title>The exclusive conditions example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;ExclusiveConditions&quot; &gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;evaluate document&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;exclusive name=&quot;evaluate document&quot;&gt;
+    &lt;transition to=&quot;submit document&quot;&gt;
+      <emphasis role="bold">&lt;condition expr=&quot;#{content==&quot;good&quot;}&quot; /&gt;</emphasis>
+    &lt;/transition&gt;
+    &lt;transition to=&quot;try again&quot;&gt;
+      <emphasis role="bold">&lt;condition expr=&quot;#{content==&quot;not so good&quot;}&quot; /&gt;</emphasis>
+    &lt;/transition&gt;
+    &lt;transition to=&quot;give up&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+  &lt;state name=&quot;give up&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+      </section>
+
+      <section id="exclusiveexpression">
+        <title>Exclusive expression</title>
+        <para>An exclusive expression evaluates to a String representing the name of 
+        an outgoing transition.
+        </para>
+        <table><title><literal>exclusive</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>expr</literal></entry>
+                <entry>expression</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>script that will be evaluated in the specified 
+                expression language.
+                </entry>
+              </row>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>expression language</entry>
+                <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+                <entry>optional</entry>
+                <entry>the language in which <literal>expr</literal> is 
+                to be evaluated.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Example:
+        </para>
+        <figure id="process.exclusive.expression">
+          <title>The exclusive expression example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;Poolcar&quot;&gt;
+  &lt;start&gt;
+    &lt;transition to=&quot;How far?&quot; /&gt;
+  &lt;/start&gt;
+  &lt;exclusive name=&quot;How far?&quot; <emphasis role="bold">expr=&quot;#{distance}&quot;</emphasis>&gt;
+    &lt;transition name=&quot;far&quot;    to=&quot;Big car&quot; /&gt;
+    &lt;transition name=&quot;nearby&quot; to=&quot;Small car&quot; /&gt;
+  &lt;/exclusive&gt;
+  &lt;state name=&quot;Big car&quot; /&gt;
+  &lt;state name=&quot;Small car&quot; /&gt;
+&lt;/process&gt;</programlisting>
+        <para>When you start an new process instance like this
+        </para>
+        <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+variables.put("distance", "far");
+Execution execution = executionService.startProcessInstanceByKey(&quot;Poolcar&quot;, variables);</programlisting>
+        <para>then the new execution will go to activity <literal>Big car</literal>.</para>
+      </section>
+
+      <section id="exclusivehandler">
+        <title>Exclusive handler</title>
+        <para>An exclusive handler is a java class that implements the 
+        <literal>ExclusiveHandler</literal> interface.  The exclusive handler 
+        will be responsible for selecting the name of the outgoing transition. 
+        </para>
+        <programlisting>public interface ExclusiveHandler {
+  String select(OpenExecution execution);
+}</programlisting>
+        <para>The handler is specified as a sub element of the exclusive</para>
+        <table><title><literal>exclusive.handler</literal> attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>class</literal></entry>
+                <entry>classname</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>fully qualified classname of the handler implementation class.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
+        <figure id="process.exclusive.handler">
+          <title>The exclusive handler example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;ExclusiveHandler&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;evaluate document&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;exclusive name=&quot;evaluate document&quot;&gt;
+    &lt;handler class=&quot;org.jbpm.examples.exclusive.handler.ContentEvaluation&quot; /&gt;
+    &lt;transition name=&quot;good&quot; to=&quot;submit document&quot; /&gt;
+    &lt;transition name=&quot;bad&quot; to=&quot;try again&quot; /&gt;
+    &lt;transition name=&quot;ugly&quot; to=&quot;give up&quot; /&gt;
+  &lt;/exclusive&gt;
+
+  &lt;state name=&quot;submit document&quot; /&gt;
+
+  &lt;state name=&quot;try again&quot; /&gt;
+
+  &lt;state name=&quot;give up&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>The ContentEvaluation class looks like this</para>
+        <programlisting>public class ContentEvaluation implements ExclusiveHandler {
+
+  public String select(OpenExecution execution) {
+    String content = (String) execution.getVariable(&quot;content&quot;);
+    if (content.equals(&quot;you're great&quot;)) {
+      return &quot;good&quot;;
+    }
+    if (content.equals(&quot;you gotta improve&quot;)) {
+      return &quot;bad&quot;;
+    }
+    return &quot;ugly&quot;;
+  }
+}</programlisting>
+        <para>Now, when we start a process instance and supply value
+        <literal>you're great</literal> for variable content, then the 
+        ContentEvaluation will return String <literal>good</literal> and 
+        the process instance will arrive in activity <literal>Submit document</literal>. 
+        </para>
+      </section>
+      
+    </section>
+
+    <section id="concurrency">
+      <title><literal>concurrency</literal></title>
+      <para>With the <literal>fork</literal> and <literal>join</literal> activities, 
+      concurrent paths of executions can be modeled.
+      </para>
+      <para>For example:</para>
+      <figure id="process.concurrency">
+        <title>The concurrency example process</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.concurrency.png"/></imageobject></mediaobject>
+      </figure>
+      
+      <programlisting>&lt;process name=&quot;ConcurrencyGraphBased&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+   &lt;start&gt;
+      &lt;transition to=&quot;fork&quot;/&gt;
+   &lt;/start&gt;
+   
+   <emphasis role="bold">&lt;fork name=&quot;fork&quot;&gt;
+      &lt;transition to=&quot;send invoice&quot; /&gt;
+      &lt;transition to=&quot;load truck&quot;/&gt;
+      &lt;transition to=&quot;print shipping documents&quot; /&gt;
+   &lt;/fork&gt;</emphasis>
+   
+   &lt;state name=&quot;send invoice&quot; &gt;
+      &lt;transition to=&quot;final join&quot; /&gt;
+   &lt;/state&gt;
+   
+   &lt;state name=&quot;load truck&quot; &gt;
+      &lt;transition to=&quot;shipping join&quot; /&gt;
+   &lt;/state&gt;
+   
+   &lt;state name=&quot;print shipping documents&quot;&gt;
+      &lt;transition to=&quot;shipping join&quot; /&gt;
+   &lt;/state&gt;
+   
+   <emphasis role="bold">&lt;join name=&quot;shipping join&quot; &gt;
+      &lt;transition to=&quot;drive truck to destination&quot; /&gt;
+   &lt;/join&gt;</emphasis>
+   
+   &lt;state name=&quot;drive truck to destination&quot; &gt;
+      &lt;transition to=&quot;final join&quot; /&gt;
+   &lt;/state&gt;
+   
+   <emphasis role="bold">&lt;join name=&quot;final join&quot; &gt;
+      &lt;transition to=&quot;end&quot;/&gt;
+   &lt;/join&gt;</emphasis>
+   
+   &lt;end name=&quot;end&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+    </section>
+
+
+
+
+
+
+
+
+
+    <section id="end">
+      <title><literal>end</literal></title>
+      <para>Ends the execution.
+      </para>
+      <section id="endprocessinstance">
+        <title><literal>end</literal> process instance</title>
+        <para>By default, an end activity will end the complete 
+        process instance.  In case multiple concurrent executions 
+        are still active within the same process instance, all of 
+        them will be ended. 
+        </para>
+        <figure id="process.end.processinstance">
+          <title>The end event</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.processinstance.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndProcessInstance&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;end&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;end name=&quot;end&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>When a new process instance is created, it immediately ends.</para>
+      </section>
+      <section id="endexecution">
+        <title><literal>end</literal> execution</title>
+        <para>Only the execution that arrives in the 
+        end activity will be ended and other concurrent executions  
+        should be left active.  To get this behaviour, set 
+        attribute <literal>ends=&quot;execution&quot;</literal>
+        </para>
+        <table><title><literal>end</literal> execution attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>ends</literal></entry>
+                <entry>{processinstance|execution}</entry>
+                <entry>processinstance</entry>
+                <entry>optional</entry>
+                <entry>specifies if the whole process instance should be ended or 
+                just the path of execution that arrives in the end activity. 
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+      </section>
+      <section id="endmultiple">
+        <title><literal>end</literal> multiple</title>
+        <para>A process can have multiple end events.  This can be handy to indicate 
+        different outcomes of a process instance.  For example
+        </para>
+        <figure id="process.end.multiple">
+          <title>Multiple end events</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.multiple.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndMultiple&quot; xmlns=&quot;http://;jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;get return code&quot; /&gt;
+  &lt;start&gt;
+  
+  &lt;state name=&quot;get return code&quot;&gt;
+    &lt;transition name=&quot;200&quot; to=&quot;ok&quot;/&gt;
+    &lt;transition name=&quot;400&quot; to=&quot;bad request&quot;/&gt;
+    &lt;transition name=&quot;500&quot; to=&quot;internal server error&quot;/&gt;
+  &lt;/state&gt;
+  
+  &lt;end name=&quot;ok&quot;/&gt;
+  &lt;end name=&quot;bad request&quot;/&gt;
+  &lt;end name=&quot;internal server error&quot;/&gt;
+  
+&lt;/process&gt;
+        </programlisting>
+        <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
+        following code, the execution would end with the <literal>bad request</literal> end event.</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndMultiple&quot;);
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
+        </programlisting>
+        <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+        to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
+        respectively.</para>
+      </section>
+      
+      <section id="endstate">
+        <title><literal>end</literal> state</title>
+        <para>An execution can also end with different states. It is another way to specify the outcome of a process. 
+        It is indicated by the <literal>state</literal> attribute of the end event or by the <literal>end-cancel</literal> 
+        and <literal>end-error</literal> shortcut notations.
+        </para>
+
+        <table><title><literal>end</literal> execution attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>state</literal></entry>
+                <entry>String</entry>
+                <entry></entry>
+                <entry>optional</entry>
+                <entry>the state assigned to the execution. 
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+
+        <para>Take for example the following process.
+        </para>
+        <figure id="process.end.state">
+          <title>Different end states</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.state.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;EndState&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+     &lt;transition to=&quot;get return code&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;state name=&quot;get return code&quot;&gt;
+    &lt;transition name=&quot;200&quot; to=&quot;ok&quot;/&gt;
+    &lt;transition name=&quot;400&quot; to=&quot;bad request&quot; /&gt;
+    &lt;transition name=&quot;500&quot; to=&quot;internal server error&quot;/&gt;
+  &lt;/state&gt;
+
+  &lt;end name=&quot;ok&quot; state=&quot;completed&quot;/&gt;
+  &lt;end-cancel name=&quot;bad request&quot;/&gt;
+  &lt;end-error name=&quot;internal server error&quot;/&gt;
+
+&lt;/process&gt;
+        </programlisting>
+        <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
+        following code, the execution would end with the <literal>cancel</literal> state.</para>
+        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndState&quot;);
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
+        </programlisting>
+        <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+        to end with the <literal>completed</literal> or with the <literal>error</literal> states
+        respectively.</para>
+      </section>
+    </section>
+      
+    <section id="java">
+      <title><literal>java</literal></title>
+      <para>The Java task. A process execution will execute the method of the class that is configured
+      in this activity.</para> 
+      <table><title><literal>java</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>class</literal></entry>
+              <entry>classname</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>The fully qualified classname.</entry>
+            </row>
+            <row>
+              <entry><literal>method</literal></entry>
+              <entry>methodname</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>The name of the method to invoke</entry>
+            </row>
+            <row>
+              <entry><literal>var</literal></entry>
+              <entry>variablename</entry>
+              <entry></entry>
+              <entry>optional</entry>
+              <entry>The name of the variable in which the return value 
+              should be stored.
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>java</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>field</literal></entry>
+              <entry>0..*</entry>
+              <entry>describes a configuration value to inject in a memberfield before 
+              the method is invoked.</entry>
+            </row>
+            <row>
+              <entry><literal>arg</literal></entry>
+              <entry>0..*</entry>
+              <entry>method parameters</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>Consider the following example.</para>
+      <figure id="process.java">
+        <title>A java task</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.java.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;Java&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;invoke java method&quot; /&gt;
+  &lt;/start&gt;
+
+  &lt;java name=&quot;invoke java method&quot; 
+        class=&quot;org.jbpm.examples.java.JohnDoe&quot;
+        method=&quot;hello&quot;
+        var=&quot;answer&quot;&gt;
+        
+    &lt;field name=&quot;state&quot;&gt;&lt;string value=&quot;fine&quot;/&gt;&lt;/field&gt;
+    &lt;field name=&quot;session&quot;&gt;&lt;env type=&quot;org.hibernate.Session&quot;/&gt;&lt;/field&gt;
+
+    &lt;arg&gt;&lt;string value=&quot;Hi, how are you?&quot;/&gt;&lt;/arg&gt;
+    
+    &lt;transition to=&quot;wait&quot; /&gt;
+  &lt;/java&gt;
+  
+  &lt;state name=&quot;wait&quot;&gt;
+
+&lt;/process&gt;
+      </programlisting>
+      <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
+      will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
+      <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
+      </para>
+      <programlisting>package org.jbpm.examples.java;
+
+import org.hibernate.Session;
+
+public class JohnDoe {
+  
+  String state;
+  Session session;
+  
+  public String hello(String msg) {
+    if ( (msg.indexOf(&quot;how are you?&quot;)!=-1)
+         &amp;&amp; (session.isOpen())
+       ) {
+      return &quot;I&#39;m &quot;+state+&quot;, thank you.&quot;;
+    }
+    return null;
+  }
+}</programlisting>
+      <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
+      and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the 
+      <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
+      a process instance is that the process variable <literal>answer</literal> contains the string
+      <literal>I'm fine, thank you.</literal>.
+      </para>
+    </section>
+
+    <section id="task">
+      <title><literal>task</literal></title>
+      <para>Creates a task for a person in the task component.  The configuration capabilities 
+      of the task activity will be expanded in the next releases.
+      </para>
+      <table><title><literal>task</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>assignee</literal></entry>
+              <entry>text</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>id of the person to which this task must be assigned</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>For example:</para>
+      <figure id="process.task">
+        <title>The task example process</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.task.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;Task&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;review&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;task name=&quot;review&quot; 
+        assignee=&quot;johndoe&quot;&gt;</emphasis>
+        
+    &lt;transition to=&quot;wait&quot; /&gt;
+  <emphasis role="bold">&lt;/task&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+      <para>After starting a process like this
+      </para>
+      <programlisting>executionService.startProcessInstanceByKey(&quot;Task&quot;);</programlisting>
+      <para>The task list for user johndoe can be obtained from the <literal>TaskService</literal>
+      like this</para>
+      <programlisting>taskService.getPersonalTaskList("johndoe", 0, 10);</programlisting>
+      <para>The task list for user 'johndoe' will contain a task named 'review'.</para>
+    </section>
+
+    <section id="script">
+      <title><literal>script</literal></title>
+      <para>A script activity evaluates a script.  Scripts can be specified in any language for 
+      which there is <ulink url="https://scripting.dev.java.net/">a JSR-223 compliant scripting engine</ulink>.
+      Configuration of scripting engines <link linkend="scripting">is explained below</link>.
+      </para>
+      <para>There are 2 ways of specifying a script:
+      </para>
+      <section id="script.expression">
+        <title><literal>script</literal> expression</title>
+        <para>The script is provided with the <literal>expr</literal> attribute.
+        This is for short expressions that are easier expressed in an attribute 
+        then in a text element.  If no <literal>lang</literal> is specified, 
+        the default-expression-language is used.
+        </para>
+        <table><title><literal>script</literal> expression attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>expr</literal></entry>
+                <entry>text</entry>
+                <entry></entry>
+                <entry><emphasis role="bold">required</emphasis></entry>
+                <entry>the expression text to evaluate.</entry>
+              </row>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>scripting language name as defined in <xref linkend="scripting"/></entry>
+                <entry>the default <emphasis role="bold">expression</emphasis> language as defined in <xref linkend="scripting"/></entry>
+                <entry>optional</entry>
+                <entry>the language in which the expression is specified.</entry>
+              </row>
+              <row>
+                <entry><literal>var</literal></entry>
+                <entry>variablename</entry>
+                <entry></entry>
+                <entry>optional</entry>
+                <entry>name of the variable in which the return value 
+                should be stored.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>In the next example, we'll see how a script activity with an expression and 
+        how the result is stored in a variable.
+        </para>
+        <figure id="process.script.expression">
+          <title>The script.expression example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.script.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;ScriptExpression&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;invoke script&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;script name=&quot;invoke script&quot; 
+          expr=&quot;Send packet to #{person.address}&quot;
+          var=&quot;text&quot;&gt;</emphasis>
+
+    &lt;transition to=&quot;wait&quot; /&gt;
+  <emphasis role="bold">&lt;/script&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+        <para>This example uses a <literal>Person</literal> class that looks like this.
+        </para>
+        <programlisting>public class Person implements Serializable {
+
+  String address;
+  
+  public Person(String address) {
+    this.address = address;
+  }
+  
+  public String getAddress() {
+    return address;
+  }
+  
+  public void setAddress(String address) {
+    this.address = address;
+  }
+}</programlisting>
+        <para>When starting a process instance for this process, we supply a person 
+        with a given address property as variable <literal>person</literal>. 
+        </para>
+        <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+variables.put("<emphasis role="bold">person</emphasis>", <emphasis role="bold">new Person(&quot;Honolulu&quot;)</emphasis>);
+   
+executionService.startProcessInstanceByKey(&quot;ScriptText&quot;, variables);</programlisting>
+        <para>After the execution of the script activity, variable <literal>text</literal>
+        will contain 'Send packet to Honolulu'. 
+        </para>
+      </section>
+      
+      <section id="script.text">
+        <title><literal>script</literal> text</title>
+        <para>The second way of specifying a script is with a <literal>text</literal> element.
+        This is convenient when the script text spans multiple lines. 
+        </para>
+        <table><title><literal>script</literal> text attributes:</title>
+          <tgroup cols="5" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Attribute</entry>
+                <entry>Type</entry>
+                <entry>Default</entry>
+                <entry>Required?</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>lang</literal></entry>
+                <entry>scripting language name as defined in <xref linkend="scripting"/></entry>
+                <entry>the default <emphasis role="bold">scripting</emphasis> language as defined in <xref linkend="scripting"/></entry>
+                <entry>optional</entry>
+                <entry>the language in which the script is specified.</entry>
+              </row>
+              <row>
+                <entry><literal>var</literal></entry>
+                <entry>variablename</entry>
+                <entry></entry>
+                <entry>optional</entry>
+                <entry>name of the variable in which the return value 
+                should be stored.
+                </entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <table><title><literal>script</literal> text elements:</title>
+          <tgroup cols="3" rowsep="1" colsep="1">
+            <thead>
+              <row>
+                <entry>Element</entry>
+                <entry>Multiplicity</entry>
+                <entry>Description</entry>
+              </row>
+            </thead>
+            <tbody>
+              <row>
+                <entry><literal>text</literal></entry>
+                <entry>1</entry>
+                <entry>contains the script text</entry>
+              </row>
+            </tbody>
+          </tgroup>
+        </table>
+        <para>For example</para>
+        <figure id="process.script.text">
+          <title>The script.text example process</title>
+          <mediaobject><imageobject><imagedata align="center" fileref="images/process.script.png"/></imageobject></mediaobject>
+        </figure>
+        <programlisting>&lt;process name=&quot;ScriptText&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;invoke script&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;script name=&quot;invoke script&quot; 
+          var=&quot;text&quot;&gt;
+    &lt;text&gt;
+      Send packet to #{person.address}
+    &lt;/text&gt;</emphasis>
+    &lt;transition to=&quot;wait&quot; /&gt;
+  <emphasis role="bold">&lt;/script&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+      </section>
+      <para>Execution of this process is exactly the same as with the script expression above.
+      </para>
+    </section>
+
+    <section id="esb">
+      <title><literal>esb</literal></title>
+      <para>An <literal>esb</literal> activity sends a message to a service over the ESB.  
+      The attributes <literal>category</literal> and <literal>service</literal> identify the 
+      service in the esb repository.  The message is composed with the 
+      <literal>part</literal> elements.   
+      </para>
+      <table><title><literal>esb</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>category</literal></entry>
+              <entry>string</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>the esb category where the service is defined.</entry>
+            </row>
+            <row>
+              <entry><literal>service</literal></entry>
+              <entry>string</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>the esb name of the service 
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>esb</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>part</literal></entry>
+              <entry>0..*</entry>
+              <entry>Parts of the message to be sent.</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>For example</para>
+      <figure id="process.esb">
+        <title>The esb example process</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.esb.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;Esb&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start &gt;
+    &lt;transition to=&quot;invoke esb service&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;esb name=&quot;invoke esb service&quot; 
+       category=&quot;orderProcessing&quot;
+       service=&quot;bookSold&quot;&gt;
+        
+    &lt;part name=&quot;bookTitle&quot; expr=&quot;#{title}&quot; /&gt;
+    &lt;part name=&quot;goal&quot;&gt;
+      &lt;string value=&quot;deliver asap&quot; /&gt;
+    &lt;/part&gt;</emphasis>
+    
+    &lt;transition to=&quot;wait&quot; /&gt;
+  <emphasis role="bold">&lt;/esb&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+      <para>When a new process is started, a message will be sent to the esb 
+      service <literal>bookSold</literal> in category <literal>orderProcessing</literal>.
+      The message will have 2 parts: one named <literal>bookTitle</literal> containing
+      the title process variable.  And one named <literal>goal</literal> which 
+      contains the text 'deliver asap'.  
+      </para>
+    </section>
+
+    <section id="hql">
+      <title><literal>hql</literal></title>
+      <para>With the<literal>hql</literal> activity, a HQL query can be performed 
+      on the database and the result is stored in a process variable. 
+      </para>
+      <table><title><literal>hql</literal> attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>var</literal></entry>
+              <entry>variablename</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>the name of the variable in which the result is stored.</entry>
+            </row>
+            <row>
+              <entry><literal>unique</literal></entry>
+              <entry>{true, false}</entry>
+              <entry>false</entry>
+              <entry>optional</entry>
+              <entry>a value of true means that the result from the hibernate 
+              query should be obtained with method <literal>uniqueResult()</literal>.
+              The default is false and in that case the <literal>list()</literal>
+              method will be used to get the result. 
+              </entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title><literal>hql</literal> elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>query</literal></entry>
+              <entry>1</entry>
+              <entry>The HQL query.</entry>
+            </row>
+            <row>
+              <entry><literal>parameter</literal></entry>
+              <entry>0..*</entry>
+              <entry>The query parameters</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <para>For example:</para>
+      <figure id="process.hql">
+        <title>The hql example process</title>
+        <mediaobject><imageobject><imagedata align="center" fileref="images/process.hql.png"/></imageobject></mediaobject>
+      </figure>
+      <programlisting>&lt;process name=&quot;Hql&quot; xmlns=&quot;http://jbpm.org/4/jpdl&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;get process names&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;hql name=&quot;get process names&quot;
+       var=&quot;activities with o&quot;&gt;
+    &lt;query&gt;
+      select activity.name
+      from org.jbpm.pvm.internal.model.ActivityImpl as activity
+      where activity.name like :activityName
+    &lt;/query&gt;
+    &lt;parameters&gt;
+      &lt;string name=&quot;activityName&quot; value=&quot;%o%&quot; /&gt;
+    &lt;/parameters&gt;</emphasis>
+    &lt;transition to=&quot;count activities&quot; /&gt;
+  <emphasis role="bold">&lt;/hql&gt;
+  
+  &lt;hql name=&quot;count activities&quot;
+       var=&quot;activities&quot;
+       unique=&quot;true&quot;&gt;
+    &lt;query&gt;
+      select count(*)
+      from org.jbpm.pvm.internal.model.ActivityImpl
+    &lt;/query&gt;</emphasis>
+    &lt;transition to=&quot;wait&quot; /&gt;
+  <emphasis role="bold">&lt;/hql&gt;</emphasis>
+
+  &lt;state name=&quot;wait&quot;/&gt;
+
+&lt;/process&gt;</programlisting>
+    </section>
+
+    <section id="sql">
+      <title><literal>sql</literal></title>
+      <para>The <literal>sql</literal> activity is exactly the same as the
+      <link linkend="hql">hql</link> activity, with the only difference that 
+      <literal>session.createSQLQuery(...)</literal> is used.   
+      </para>
+    </section>
+
+    <section id="commonactivitycontents">
+      <title>Common activity contents</title>
+      <para>Unless specified otherwise above, all activities also include this 
+      content model:
+      </para>
+      <table><title>Common activity attributes:</title>
+        <tgroup cols="5" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Attribute</entry>
+              <entry>Type</entry>
+              <entry>Default</entry>
+              <entry>Required?</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>name</literal></entry>
+              <entry>any text</entry>
+              <entry></entry>
+              <entry><emphasis role="bold">required</emphasis></entry>
+              <entry>name of the activity</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+      <table><title>Common activity elements:</title>
+        <tgroup cols="3" rowsep="1" colsep="1">
+          <thead>
+            <row>
+              <entry>Element</entry>
+              <entry>Multiplicity</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>transition</literal></entry>
+              <entry>0..*</entry>
+              <entry>the outgoing transitions</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+  </section>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,7 @@
+<chapter id="variables">
+  <title>Variables</title>
+  
+  <para>TODO  
+  </para>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,18 @@
+<chapter id="scripting">
+  <title>Scripting</title>
+  
+  <para>Scripting in jBPM is based on JSR 223: Scripting for the JavaTM Platform.
+  Scripting engines can be configured like this:
+  </para>
+  <programlisting>&lt;script-manager default-expression-language=&quot;juel&quot;
+                    default-script-language=&quot;juel&quot;
+                    read-contexts=&quot;execution, environment, process-engine&quot;
+                    write-context=&quot;&quot;&gt;
+  &lt;script-language name=&quot;juel&quot; factory=&quot;com.sun.script.juel.JuelScriptEngineFactory&quot; /&gt;
+&lt;/script-manager&gt;</programlisting>
+  <para>A jPDL process definition can contain scripts and expressions.  All 
+  of the configured scripting engines can be used in each situation.  But 
+  scripts and expressions each have their own default.  
+  </para>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch08-Identity.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch08-Identity.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/modules/userguide/src/main/docbook/en/modules/ch08-Identity.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,38 @@
+<chapter id="identity">
+  <title>Identity</title>
+  
+  <para>The default jBPM identity component is based on 
+  <ulink url="http://www.jboss.org/community/docs/DOC-13258">JBoss IDM</ulink>.  
+  Configuration is like this:
+  </para>
+  
+  <programlisting>&lt;jbpm-configuration xmlns=&quot;http://jbpm.org/xsd/cfg&quot;&gt;
+
+  <emphasis role="bold">&lt;process-engine-context&gt;</emphasis>
+    ...
+    &lt;identity-service /&gt;
+    ...
+  &lt;/process-engine-context&gt;
+
+  &lt;transaction-context&gt;
+    ...
+    <emphasis role="bold">&lt;identity-session realm=&quot;realm://jbpm-identity&quot; /&gt;</emphasis>
+  &lt;/transaction-context&gt;
+
+&lt;/jbpm-configuration&gt;</programlisting>
+
+  <para>To replace the identity component, keep the identity-service declaration, 
+  implement org.jbpm.session.IdentitySession and configure your identity session in 
+  the transaction context like this:
+  </para>
+
+  <programlisting>&lt;jbpm-configuration xmlns=&quot;http://jbpm.org/xsd/cfg&quot;&gt;
+  ...
+  &lt;transaction-context&gt;
+    ...
+    &lt;object class="your.package.YourIdentitySession" /&gt;
+  &lt;/transaction-context&gt;
+
+&lt;/jbpm-configuration&gt;</programlisting>
+
+</chapter>

Added: jbpm4/branches/tbaeyens/pom.xml
===================================================================
--- jbpm4/branches/tbaeyens/pom.xml	                        (rev 0)
+++ jbpm4/branches/tbaeyens/pom.xml	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,695 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--  JBoss, the OpenSource J2EE webOS                                      -->
+<!--                                                                        -->
+<!--  Distributable under LGPL license.                                     -->
+<!--  See terms of license at http://www.gnu.org.                           -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 4046 2009-02-26 13:05:50Z heiko.braun at jboss.com $ -->
+
+<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>
+ 
+  <name>jBPM 4</name>
+  <groupId>org.jbpm.jbpm4</groupId>
+  <artifactId>jbpm</artifactId>
+  <packaging>pom</packaging>
+
+  <version>4.0.0-SNAPSHOT</version>
+
+  <organization>
+    <name>JBoss, a division of Red Hat</name>
+    <url>http://www.jboss.org</url>
+  </organization>
+
+  <!-- Modules -->
+  <modules>
+    <module>modules/log</module>
+    <module>modules/api</module>
+    <module>modules/pvm</module>
+    <module>modules/examples</module>
+    <module>modules/jpdl</module>
+    <module>modules/enterprise</module>     
+    <module>modules/test-base</module>
+    <module>modules/test-db</module>
+    <module>modules/test-pojo</module>
+    <module>modules/db</module>
+    <!-- 
+     -->
+  </modules>
+
+  <!-- Properties -->
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <apache.ant.version>1.7.0</apache.ant.version>
+    <cactus.version>13-1.7.1</cactus.version>
+    <gwt.console.version>1.0.0-SNAPSHOT</gwt.console.version>
+    <hibernate.version>3.2.6.ga</hibernate.version>
+    <hibernate.annotations.version>3.3.1.GA</hibernate.annotations.version>
+    <hsqldb.version>1.8.0.7</hsqldb.version>
+    <izpack.version>4.1.0</izpack.version>
+    <jboss.identity.version>1.0.0-SNAPSHOT</jboss.identity.version>
+    <jboss.j2ee.version>4.2.2.GA</jboss.j2ee.version>
+    <jbossesb.version>4.4.0.GA</jbossesb.version>
+    <jboss.client.version>4.2.2.GA</jboss.client.version>
+    <jsr233.version>2.0.5</jsr233.version>
+    <juel.version>2.1.0</juel.version>
+    <junit.version>3.8.1</junit.version>
+    <log4j.version>1.2.14</log4j.version>
+    <servlet-api.version>2.5</servlet-api.version>
+    <spring.version>2.5.4</spring.version>
+    <stax.api.version>1.0.1</stax.api.version>
+    <woodstox.version>3.2.6</woodstox.version>
+    <!-- Database Driver Versions  -->
+    <hsqldb.version>1.8.0.7</hsqldb.version>
+    <mysql.connector.version>5.0.8</mysql.connector.version>
+    <postgresql.version>8.3-603.jdbc3</postgresql.version>
+    <jtds.version>1.2.2</jtds.version>
+    <oracle.version>10.0.2.0</oracle.version>
+  </properties>
+
+  <!-- DependencyManagement -->
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-api</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-log</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-test-base</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-pvm</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-db</artifactId>
+        <version>${version}</version>
+      </dependency>
+
+      <!-- GWT console -->
+      <dependency>
+        <groupId>org.jboss.bpm</groupId>
+        <artifactId>gwt-console</artifactId>
+        <version>${gwt.console.version}</version>
+        <type>war</type>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.bpm</groupId>
+        <artifactId>gwt-console-server</artifactId>
+        <version>${gwt.console.version}</version>
+        <type>war</type>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.bpm</groupId>
+        <artifactId>gwt-console-server-integration</artifactId>
+        <version>${gwt.console.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.bpm</groupId>
+        <artifactId>gwt-console-rpc</artifactId>
+        <version>${gwt.console.version}</version>
+        <scope>provided</scope>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jbpm.jbpm4</groupId>
+        <artifactId>jbpm-gpd</artifactId>
+        <type>zip</type>
+        <version>${version}</version>
+      </dependency>
+
+      <!-- Please sort by groupid -->
+      <dependency>
+        <groupId>org.apache.ant</groupId>
+        <artifactId>ant</artifactId>
+        <version>${apache.ant.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>cactus</groupId>
+        <artifactId>cactus</artifactId>
+        <version>${cactus.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.hibernate</groupId>
+        <artifactId>hibernate</artifactId>
+        <version>${hibernate.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.hibernate</groupId>
+        <artifactId>hibernate-annotations</artifactId>
+        <version>${hibernate.annotations.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.identity</groupId>
+        <artifactId>idm</artifactId>
+        <version>${jboss.identity.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>hsqldb</groupId>
+        <artifactId>hsqldb</artifactId>
+        <version>${hsqldb.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>izpack</groupId>
+        <artifactId>standalone-compiler</artifactId>
+        <version>${izpack.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>jboss</groupId>
+        <artifactId>jboss-j2ee</artifactId>
+        <version>${jboss.j2ee.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+        <artifactId>jbossesb-rosetta</artifactId>
+        <version>${jbossesb.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jbpm.jbpm4.dependencies.esb</groupId>
+        <artifactId>test-util</artifactId>
+        <version>${jbossesb.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.client</groupId>
+        <artifactId>jbossall-client</artifactId>
+        <version>${jboss.client.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>juel</groupId>
+        <artifactId>juel</artifactId>
+        <version>${juel.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>juel</groupId>
+        <artifactId>juel-impl</artifactId>
+        <version>${juel.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>juel</groupId>
+        <artifactId>juel-engine</artifactId>
+        <version>${juel.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>${junit.version}</version>
+      </dependency>
+       <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>servlet-api</artifactId>
+        <version>${servlet-api.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.livetribe</groupId>
+        <artifactId>livetribe-jsr223</artifactId>
+        <version>${jsr233.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring</artifactId>
+        <version>${spring.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.woodstox</groupId>
+        <artifactId>wstx-lgpl</artifactId>
+        <version>${woodstox.version}</version>
+      </dependency>
+
+      <!-- Database Driver Versions  -->
+      <dependency>
+        <groupId>hsqldb</groupId>
+        <artifactId>hsqldb</artifactId>
+        <version>${hsqldb.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>mysql</groupId>
+        <artifactId>mysql-connector-java</artifactId>
+        <version>${mysql.connector.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>postgresql</groupId>
+        <artifactId>postgresql</artifactId>
+        <version>${postgresql.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>net.sourceforge.jtds</groupId>
+        <artifactId>jtds</artifactId>
+        <version>${jtds.version}</version>
+      </dependency>      
+    </dependencies>
+  </dependencyManagement>
+
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbpm/jbpm4</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbpm/jbpm4</developerConnection>
+    <url>http://fisheye.jboss.com/browse/JbpmSvn/jbpm4</url>
+  </scm>
+
+  <!-- IssueManagement -->
+  <issueManagement>
+    <system>jira</system>
+    <url>http://jira.jboss.org/jira/browse/JBPM</url>
+  </issueManagement>
+
+  <!-- Licenses -->
+  <licenses>
+    <license>
+      <name>lgpl</name>
+      <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+    </license>
+  </licenses>
+
+  <!-- Plugins -->
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <optimize>true</optimize>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <failIfNoTests>false</failIfNoTests>
+          <trimStackTrace>false</trimStackTrace>
+          <systemProperties>
+            <property>
+              <name>log4j.output.dir</name>
+              <value>${project.build.directory}</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+
+    </plugins>
+
+    <!-- PluginManagement -->
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.0.2.SP1</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-assembly-plugin</artifactId>
+          <version>2.2-beta-2</version>
+        </plugin>
+        <!--
+          <plugin> <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-dependency-plugin</artifactId> </plugin>
+        -->
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>build-helper-maven-plugin</artifactId>
+          <version>1.1</version>
+        </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>buildnumber-maven-plugin</artifactId>
+          <version>1.0-beta-1</version>
+        </plugin>
+        <plugin>
+          <groupId>net.sourceforge.maven-taglib</groupId>
+          <artifactId>maven-taglib-plugin</artifactId>
+          <version>2.3</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>2.3</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <!-- Profiles -->
+  <profiles>
+
+    <profile>
+      <id>distro</id>
+      <modules>
+        <module>modules/integration</module>
+        <module>modules/devguide</module>
+        <module>modules/distro</module>
+        <module>modules/userguide</module>
+      </modules>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>attach-javadocs</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <artifactId>maven-source-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>attach-sources</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <profile>
+      <id>load</id>
+      <modules>
+        <module>modules/test-load</module>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>skiptests</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!--
+       Name:  no-database
+       Descr: Setup the default database
+       -->
+    <profile>
+      <id>no-database</id>
+      <activation>
+        <property>
+          <name>!database</name>
+        </property>
+      </activation>
+      <properties>
+        <database>hsqldb</database>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>hsqldb</groupId>
+          <artifactId>hsqldb</artifactId>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <!--
+        Name:  hsqldb
+        Descr: Hypersonic Database Setup
+        -->
+    <profile>
+      <id>hsqldb</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>hsqldb</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>hsqldb</groupId>
+          <artifactId>hsqldb</artifactId>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+
+    <!-- -Ddatabase=oracle -->
+    <profile>
+      <id>oracle</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>oracle</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.oracle</groupId>
+          <artifactId>ojdbc14</artifactId>
+          <version>${oracle.version}</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+      <repositories>
+        <repository>
+          <id>qa.jboss.com</id>
+          <url>http://www.qa.jboss.com/jdbc-drivers/maven2</url>
+        </repository>
+      </repositories>
+    </profile>
+
+    <!-- -Ddatabase=mysql -->
+    <profile>
+      <id>mysql</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>mysql</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>mysql</groupId>
+          <artifactId>mysql-connector-java</artifactId>
+          <version>5.0.8</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <!-- -Ddatabase=postgresql -->
+    <profile>
+      <id>postgresql</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>postgresql</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>postgresql</groupId>
+          <artifactId>postgresql</artifactId>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <!-- -Ddatabase=sybase -->
+    <profile>
+      <id>sybase</id>
+      <activation>
+        <property>
+          <name>database</name>
+          <value>sybase</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>net.sourceforge.jtds</groupId>
+          <artifactId>jtds</artifactId>
+          <scope>test</scope>
+        </dependency>
+        <dependency>
+          <groupId>com.sybase</groupId>
+          <artifactId>jconnect</artifactId>
+          <version>6.0.5</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+      <repositories>
+        <repository>
+          <id>qa.jboss.com</id>
+          <url>http://www.qa.jboss.com/jdbc-drivers/maven2</url>
+        </repository>
+      </repositories>
+    </profile>
+
+    <profile>
+      <id>report</id>
+      <!-- Report Customization 'mvn site:site'-->
+      <reporting>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-project-info-reports-plugin</artifactId>
+            <version>2.0.1</version>
+            <reportSets>
+              <reportSet>
+                <reports>
+                  <report>index</report>
+                  <report>summary</report>
+                  <report>issue-tracking</report>
+                  <report>mailing-list</report>
+                  <report>scm</report>
+                  <report>project-team</report>
+                  <report>license</report>
+                  <report>javadoc</report>
+                </reports>
+              </reportSet>
+            </reportSets>
+          </plugin>
+
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>jxr-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </reporting>
+    </profile>
+  </profiles>
+
+  <!-- Repositories -->
+  <repositories>
+    <repository>
+      <id>maven1.java.net</id>
+      <url>http://download.java.net/maven/1/</url>
+      <layout>legacy</layout>
+    </repository>
+    <repository>
+      <id>repository.jboss.org</id>
+      <url>http://repository.jboss.com/maven2</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>snapshots.jboss.org</id>
+      <url>http://snapshots.jboss.org/maven2</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>repository.codehaus.org</id>
+      <url>http://repository.codehaus.org</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>maven2.java.net</id>
+      <name>Java.net Repository for Maven 2</name>
+      <url>http://download.java.net/maven/2/</url>
+    </repository>
+    <repository>
+      <id>gwt-maven</id>
+      <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
+    </repository>
+  </repositories>
+
+  <!-- PluginRepositories -->
+  <pluginRepositories>
+    <pluginRepository>
+      <id>maven2.java.net</id>
+      <name>Java.net Repository for Maven 2</name>
+      <url>http://download.java.net/maven/2/</url>
+    </pluginRepository>
+    <pluginRepository>
+      <id>repository.jboss.com</id>
+      <url>http://repository.jboss.com/maven2</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </pluginRepository>
+    <pluginRepository>
+      <id>snapshots.jboss.org</id>
+      <url>http://snapshots.jboss.org/maven2</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </pluginRepository>
+    <pluginRepository>
+      <id>gwt-maven</id>
+      <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <!-- DistributionManagement -->
+  <distributionManagement>
+    <repository>
+      <id>repository.jboss.org</id>
+      <name>JBoss Maven Repository</name>
+      <url>file://${jboss.maven.repository}</url>
+    </repository>
+    <snapshotRepository>
+      <id>snapshots.jboss.org</id>
+      <name>JBoss Snapshot Repository</name>
+      <url>dav:https://snapshots.jboss.org/maven2</url>
+    </snapshotRepository>
+    <site>
+      <id>qabox</id>
+      <name>jbpm.dyndns.org</name>
+      <url>scpexe://hudson@jbpm.dyndns.org/var/www/html/jbpm4/</url>
+    </site>
+  </distributionManagement>
+
+</project>

Added: jbpm4/branches/tbaeyens/profiles.xml.example
===================================================================
--- jbpm4/branches/tbaeyens/profiles.xml.example	                        (rev 0)
+++ jbpm4/branches/tbaeyens/profiles.xml.example	2009-03-04 10:30:07 UTC (rev 4133)
@@ -0,0 +1,63 @@
+<profilesXml 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/xsd/profiles-1.0.0.xsd">
+
+  <profiles>
+
+    <!-- This profile can also be defined in ~/.m2/settings.xml -->
+
+    <profile>
+      <id>jboss-home-profile</id>
+      <activation>
+        <property>
+          <name>user.name</name>
+        </property>
+      </activation>
+      <properties>
+
+        <!--
+           JBOSS_HOME FOR INTEGRATION TESTS
+        -->
+
+        <jboss422.home>/jboss-4.2.2.GA</jboss422.home>
+        <jboss423.home>/jboss-4.2.3.GA</jboss423.home>
+        <jboss500.home>/jboss-5.0.0.GA</jboss500.home>
+
+        <!--
+          DEFAULT CONNECTION SETTINGS FOR THE JBPM QA ENV
+        -->       
+        <jdbc.mysql.server>localhost</jdbc.mysql.server>
+        <jdbc.mysql.port>3306</jdbc.mysql.port>
+        <jdbc.mysql.database>jbpm4</jdbc.mysql.database>
+        <jdbc.mysql.url>jdbc:mysql://${jdbc.mysql.server}:${jdbc.mysql.port}/${jdbc.mysql.database}</jdbc.mysql.url>
+        <jdbc.mysql.username>jbpmtest</jdbc.mysql.username>
+        <jdbc.mysql.password></jdbc.mysql.password>
+
+        <jdbc.postgresql.server>localhost</jdbc.postgresql.server>
+        <jdbc.postgresql.port>5432</jdbc.postgresql.port>
+        <jdbc.postgresql.database>jbpm4</jdbc.postgresql.database>
+        <jdbc.postgresql.url>jdbc:postgresql://${jdbc.postgresql.server}:${jdbc.postgresql.port}/${jdbc.postgresql.database}</jdbc.postgresql.url>
+        <jdbc.postgresql.username>jbpmtest</jdbc.postgresql.username>
+        <jdbc.postgresql.password></jdbc.postgresql.password>
+
+        <jdbc.sybase.server>localhost</jdbc.sybase.server>
+        <jdbc.sybase.port>5000</jdbc.sybase.port>
+        <jdbc.sybase.database>jbpm4</jdbc.sybase.database>
+        <jdbc.sybase.url>jdbc:sybase:Tds:${jdbc.sybase.server}:${jdbc.sybase.port}/${jdbc.sybase.database}</jdbc.sybase.url>
+        <jdbc.sybase.username>jbpmtest</jdbc.sybase.username>
+        <jdbc.sybase.password>jbpmtest</jdbc.sybase.password>
+        <jdbc.sybase.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.sybase.driver>
+        <jdbc.sybase.datasource>com.sybase.jdbc3.jdbc.SybXADataSource</jdbc.sybase.datasource>
+
+        <jdbc.oracle.server>localhost</jdbc.oracle.server>
+        <jdbc.oracle.port>1521</jdbc.oracle.port>
+        <jdbc.oracle.database>XE</jdbc.oracle.database>
+        <jdbc.oracle.username>jbpmtest</jdbc.oracle.username>
+        <jdbc.oracle.password>jbpmtest</jdbc.oracle.password>
+        <jdbc.oracle.url>jdbc:oracle:thin:${jdbc.oracle.username}/${jdbc.oracle.password}@${jdbc.oracle.server}:${jdbc.oracle.port}:${jdbc.oracle.database}</jdbc.oracle.url>
+      </properties>
+    </profile>
+
+  </profiles>
+
+</profilesXml>




More information about the jbpm-commits mailing list