Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Note
titleversion status: 0.0.1 alpha released

feedback needed!! please give us your feedback via the tynamo mailing list.

tapestry-activiti is brought to you by Omar Carvajal and Carvajal Consultants, Inc. They did all the work and we thank them for it!.

Activiti is a workflow and Business Process Management (BPM) platform. Its core is a super-fast and rock-solid BPMN 2 process engine for Java. It's extremely lightweight and based on simple concepts.
The Tapestry-Activiti module allows you to interact with your Activiti instance and its key process entities from Tapestry. You can also call Tapestry services from within your process definition. 

Setup

Requirements

In order to start using Tapestry-Activiti, you need to meet the following requirements:

  • Some basic knowledge of Activiti, check out their User Manual if you haven't already.
  • Have a working BPMN2 process (which can be created using the Eclipse Designer or any other Activit designer tool).
Dependencies

You need the following module in order to use Activiti in your Tapestry application:

  • tapestry-activiti

Maven2 configuration:

Code Block
xml
xml
<dependency>
	<groupId>org.tynamo</groupId>
	<artifactId>tapestry-activiti</artifactId>
	<version>0.0.1</version>
</dependency>

These artifacts are available in the maven main repository. No need to configure any additional repositories.

Configuration

For the module to work, you first need to tell tapestry-activiti what processes need to be deployed:

Code Block
titleAppModule.java
public void contributeProcessEngine(Configuration<Resource> deploymentResources) {
	/**
	 * Remember: the name of the resource must end with "bpmn20.xml".
	 * @see: BpmnDeployer.BPMN_RESOURCE_SUFFIX
	 */
	deploymentResources.add(new ClasspathResource("SimpleTest.bpmn20.xml"));
}

There are various configuration options that may be set, for example if you want to use a different database other than the default H2 database:

Code Block
titleAppModule.java
public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration) {
	configuration.add(ActivitiSymbols.DATABASE_TYPE, "postgres");
	configuration.add(ActivitiSymbols.JDBC_URL, "jdbc:postgresql://localhost/activiti");
	configuration.add(ActivitiSymbols.JDBC_DRIVER, "org.postgresql.Driver");
	configuration.add(ActivitiSymbols.DATABASE_SCHEMA_UPDATE, "true");
}

Make sure to check the Tapestry-Activiti Javadocs and the Activiti User Manual for a list of the configuration options that may be set.

How to use Tapestry Activiti

Services

Tapestry-Activiti defines various Activiti services, including:

  • ProcessEngine

  • RepositoryService
  • RuntimeService
  • FormServiceTaskService
  • HistoryService
  • ManagementService

These can be used throughout your Tapestry application to manipulate the Activiti process.

Initiating a Process Instance

You may use the Activiti services throughout your application using Tapestry injection, for example:

Code Block
languagejava
public class MyPage {
    @Inject
    private RuntimeService runtimeService;

    void onActionFromStart() {
        runtimeService.startProcessInstanceByKey("SimpleProcess");
    }
}
Calling a service method from a process

You may at one point need to call a method defined in a Tapestry service from an Activiti process.

Suppose we have the following service defined:

Code Block
titleService
languagejava
public class ServiceA {
    public void doWork() {
        //Service logic here
    }
}

We could then call this service method from a process by using an Activiti expression:

Code Block
languagehtml/xml
<serviceTask id="simple" activiti:expression="#{ServiceA.doWork()}"/>

The service's service-id is always used to reference a service from an Activiti process.