Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Documentation.doc
Скачиваний:
5
Добавлен:
01.05.2025
Размер:
1.72 Mб
Скачать

2.2.4Engine api

The engine API is the most common way of interacting with Activiti. The central starting point is the ProcessEngine (Figure 2.26), which can be created in several ways as described in the configuration section. From the ProcessEngine, you can obtain the various services that contain the workflow/BPM methods. ProcessEngine and the services objects are thread safe. So you can keep a reference to 1 of those for a whole server.

Figure 2.26 – engine structure

2.2.5Business archives

To deploy processes, they have to be wrapped in a business archive. A business archive is the unit of deployment to an Activiti Engine. Basically a business archive is equivalent to a zip file. It can contain BPMN 2.0 processes, task forms, rules and any other type of file. In general, a business archive contains a collection of named resources.

When a business archive is deployed, it is scanned for BPMN files with a .bpmn20.xml extension. Each of those will be parsed and potentially contains multiple process definitions.

2.2.6Versioning of process definitions

BPMN doesn't have a notion of versioning. And that is good because the executable BPMN process file will probably live in an SVN repository as part of your development project. Versions of process definitions are created during deployment. During deployment, Activiti will assign a version to the ProcessDefinition before it is stored in the Activiti DB.

For each process definition in a business archive the following steps are performed to initialize the properties key, version, name and id:

  • The process definition id attribute in the XML file is used as the process definition key property

  • The process definition name attribute in the XML file is used as the process definition name property. If the name attribute is not specified, then id attribute is used as the name.

  • The first time a process with a particular key is deployed, version 1 is assigned. For all subsequent deployments of process definitions with the same key, the version will be set 1 higher then the max currently deployed version. The key property is used to distinct process definitions.

  • The id property is set to {processDefinitionKey}:{processDefinitionVersion}:{generated-id}, where generated-id is a unique number added to guarantee uniquencess of the process id for the process definition caches in a clustered environment.

2.2.7Generating a process diagram

In case no image is provided in the deployment, as described in the previous section, the Activiti engine will generate a diagram image when the process definition contains the necessary 'diagram interchange' information. This is the case when using the Activiti Modeler (and in the near future when using the Activiti Eclipse Designer).

The resource can be retrieved in exactly the same way as when an image is provided in the deployment (Figure 2.27).

Figure 2.27 – generating a process diagram

2.3Integrating bpm into project

From Chapter 2.2.4 we have a good sight of Activiti Engine API. This services are just java interfaces, which we implement as EJB bean and deploy into server.

Using dependency injection of that interfaces we could use everywhere in our project, the flexibility of EJB as a components gives us reusable code.

In many instances, I do not want to deploy the activiti process engine for each application, but instead, install a managed, centralized engine which can be used by each deployed application, without having the individual applications interfere with each other. The main reason for this is ensuring manageability. If I have a central process engine shared by different applications, I can access it with a uniform set of management and monitoring tools.

Activiti-deployer scans deployment archives for *.bpmn20.xml files, deploys the processes to a central process engine and takes care of classloading. Figure 2.28 shows the overall architecture. The deployer is shown in the bottom left corner of Figure 2.28. In addition, Figure 2.28 shows a schematic client application named client-app.ear. Such applications can be composed (but need not be) of different modules, like multiple jar modules containing EJBs, a WAR module and libraries. Figure 2.29 also shows a module named “process archive”. Process Archives are deployments such that the name ends in “.bar” (business archive) or a regular deployment (.jar / .war) containing a processes.xml –marker file. As already indicated, we deploy a central acitiviti process engine instance, labeled “activiti service” in Figure 2.28. The activiti service exposes the activiti CommandExecutor as an EJB with both local and remote interfaces. Client applications access the activiti service either by running commands on the CommandExecutor-EJB or by looking up the process engine in Jndi. This is handled by the “activiti client”, which makes the activiti services (such as the RuntimeService or the TaskService) available for injection (using the @EJB-annotation). Figure 2.29 shows the deployment infrastructure in more detail. Note that this is just an example. As already explained above, different “types” of deployments are supported, like .war/.jar/.ear etc.

Figure 2.29 – Activiti components overview

Figure 2.28 – Activiti as an EJB component

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]