jBPM-4.0 Chinese Development Guide-11th Chapter Environment

Source: Internet
Author: User
Tags finally block jbpm

11th Chapter Environment

11.1. Introduction

The environment component is a control inversion (IoC) container composed of a combination of connected environments. It reads configuration information, describes how objects should be instantiated, how they are configured, and how they are connected together.

The environment is used to obtain the resources and services required by the activity implementation and process virtual machines. The main purpose is to allow multiple parts of the process virtual machine to be configurable so that the PVM and running at the top of the language can work in a standard Java environment and can also be in an enterprise Java environment.

The environment is divided into a series of environments. Each environment can have its own lifecycle. For example, the process engine environment overwrites the full life time of the application. The block environment only works on the try-finally block cycle. Generally one block environment is responsible for a database transaction. Each environment exposes a key-value list. Pairs.

11.2. Environmentfactory

To start working with an environment, you need a environmentfactory. A single environment factory object can be used throughout the entire life of the application. So generally this is saved in a static member variable. Environmentfactory yourself in the process engine environment

A environmentfactory is generally obtained by parsing a configuration file, like this:

static EnvironmentFactory environmentFactory =
EnvironmentFactory.parse(new ResourceStreamSource("pvm.cfg.xml");

Refer to Javadocs packet org.jbpm.stream for more types of stream sources.

This is the default parser in an environment factory that creates defaultenvironmentfactory. The idea is that we will also support spring as the IOC container, but this is still in the TODO state. You are welcome to help us:-) in this respect. This parser can use the static setter method to configure Environmentfactory.setparser (Parser).

11.3. Environment block

An environment exists for the range of try-finally blocks. This is an environment block looks like how:

Environment environment = environmentFactory.openEnvironment();
try {

  ...

} finally {
  environment.close();
}

Environment blocks define another life part: the block environment. A transaction can be a common example of an object defined in a block environment.

In such a block, an object can be found in the environment by name or type. If an object can be found from the environment by Environment.get (String name) or <T> T environment.get (class<t>).

When an environment is created, it has a process-engine environment and a block environment.

In the default implementation, the Process-engine environment and the block environment are wirecontext. A wirecontext contains how objects are created and if they are bound to a formal object graph.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.