Simple factory model for learning design patterns with jbpm

Source: Internet
Author: User
Tags jbpm

Simple factory model for learning design patterns with jbpm

 

Mode Overview

The simple factory mode is the class creation mode. It is responsible for instantiating a large number of product classes with common interfaces or basic classes. The simple factory mode dynamically determines the class to be instantiated based on the input parameters during the factory class operation. In this way, the customer only needs to understand the product base class and remove the customer's dependency on the specific product class. Shows the structure of the simple factory mode.

 

 

Figure 1. Simple factory mode structure

 

We can see that the simple factory model mainly involves three structural roles.

1. factory class, which has a client to call directly and create corresponding product object instances according to specific business logic requirements;

2. The product base class, the base class or interface of all specific product classes, encapsulates the behavior (and data) shared by all specific products. The customer needs to understand the product base class;

3. Specific product categories, the types of instances to be created in this mode;

Simple factory model in jbpm

The simple factory mode is used for instantiation of Process Engine objects in jbpm. The specific schema structure is as follows:

 

 

Figure 2. jbpm simple factory Structure

 

We can see that processengine acts as the product base class, because of the special position of the Process Engine in jbpm, therefore, this interface needs to be able to obtain some object instances that need to be used in various services and businesses.

The specific product classes are processengineimpl and springprocessengine. The jbpm process engine can use spring as the bearer environment. The former is used by default. If we need spring, we only need to use jbpm. cfg. introduce jbpm in XML. TX. spring. cfg. XML.

The role of the factory class is implemented by configurationimpl, which instantiates a specific process engine object based on whether spring is enabled in the configuration file.

In fact, springprocessengine is also a Simplified Simple factory model. springprocessengine is responsible for instantiating itself and taking on the role of both the factory and specific products. The structure of the class chart is as follows:

 

 

Figure 3. springprocessengine lite simple factory design model

 

Advantages and disadvantages of the simple factory Model

The core of this model is the factory class, which is responsible for the necessary logical judgment (reflection is not required) and determines which product class instance to create. The customer is not responsible for product class instantiation, but only uses the returned product to achieve separation of duties between the two.

In this mode, the factory class is responsible for the Creation logic of all specific product classes, so it forms a strong dependency on all product classes. If there are many product classes, modifications to the factory class may affect the entire system.

When we expand a new product class, we need to modify the factory class, in violation of the open and closed principle.

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.