Business Process Engine

Source: Internet
Author: User
Tags list of attributes

In general, we all use programming development, the benefits of programming development is very obvious: direct, efficient, free, of course, its shortcomings are also some, and its advantages are just relative, because directly, so some changes are to make code changes; Because of the efficiency, so once the problem, the result is more serious, because of freedom,  So the risk of change is also relatively large. This is one of the important reasons that many big companies are doing process development, such as: Shanghai Pu Yuan, Livebos, Justep, and many well-known and unknown companies have similar process development engine exist, through the process development, enhance the reusability of code, reduce software development cost and test cost, Improve software maintainability and reduce maintenance costs.
The tiny framework also has its own programme in this regard, and tiny mainly considers several aspects:
A. Ease of component expansion
The convenience of component expansion means that the process actually plays the component, if the component is very difficult to expand, it will directly affect the usability of the process engine. So the tiny framework of the process engine component structure is very simple, there is only one interface method, process component registration and loading is also very important, if the expansion process components, the need for complex registration or configuration process, this time the process of expansion of the ease of use will be greatly reduced. The tiny framework uses a reference-to-register scheme, so long as the process component is placed between the operating environment of the system, the process component is registered, that is, it can be used in the process, and the expansion of the process components is greatly improved.
B. Object-oriented nature of the process support for feature-oriented support for processes is defined as the object-oriented nature of the process in the tiny framework. The process can be inherited, so that one benefit is that the repeated parts of multiple processes can be defined in a parent process, and then as long as the child process inherits the parent process, the process node can be overwritten, that is, in the parent process can define an empty node, but the flow relationship is defined in the process, But the implementation of the process node is left in the sub-process;
C. Easy editing of the process
The process of editing must be convenient, easy, there is a special process editing tools better, no time, the use of ordinary XML editor can also be easily edited.
D. Re-entry of processes
The general process engine is non-reentrant, that is, it can only be done from the beginning and after execution to the end node. The tiny process engine supports process re-entry, that is, not necessarily from the start node execution, can be executed from any node. This mechanism provides a very large degree of freedom for the logic of the program, which can be easily built using this feature to build a page flow engine or workflow engine. Even the business process engine will gain greater degrees of freedom.
Due to the reentrant nature of the support process, in this process, not only can be switched and transferred in the current process, but also flow into the nodes of other processes, which in the Business processing and page processing, process processing has provided a great deal, but this is also a double-edged sword, in providing such a flexible function at the same time, can also cause business processes to look more complex, so the control aspect is best written by an architect or core developer, and the general developer only develops specific business points.
Hehe, said so much, we understand may be still more abstract, that is an example to see:

1
2
3
4
5
6
7
8
9
<flow
All
id= "" name= "Hello" >
    <nodes>
          <node id= "Begin";
                 <component class-name= " Org.tinygroup.flow.HelloWorldComponent,
                     <properties>,
                         <property name= "name" value= "World"/>
                     </properties>
                 </component>
          </node>
    </nodes>
</flow>



The source code of Helloworldcomponent is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
public class Helloworldcomponent implements Componentinterface {
String name;
Public String GetName () {
return name;
}
public void SetName (String name) {
THIS.name = name;
}
public void execute (context context) {
Context.put ("Result", String.Format ("Hello,%s", name));
}
}



As you can see, all components must implement the Componentinterface interface
From its implementation logic can be seen, it is the "Hello," plus the input name, placed in the environment variable result.
take a look at the results:
A. Start execution by default start node

1
2
3
Context context = new Contextimpl ();
Flowexecutor.execute ("+", context);
Assertequals ("Hello, World", context.get ("result"));



B. Starting execution from a specified node

1
2
3
Context context = new Contextimpl ();
Flowexecutor.execute ("n", "Begin", context);
Assertequals ("Hello, World", context.get ("result"));



You can see that the result is actually executed and returned, but what is the mechanism of its execution??
In fact, the above process is a simplified process, that is, some parameters of the tiny process engine are not input, but also in accordance with the Convention of the correct execution, in fact, the case is complete, the example is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<flow id= "" "version=" 1.0 "privatecontext=" false "extend-flow-id=" "name=" Hello "title=" hello example "default-node-id=" End "begin-node-id=" Begin "end-node-id=" End "enable=" true ">
<description>some thing....</description>
<nodes>
<node id= "Begin" >
<component class-name= "Org.tinygroup.flow.HelloWorldComponent" >
<properties>
<property name= "name" value= "World"/> <span></span> </properties>
</component>
<next-nodes>
<next-node exception-type= "java.lang.Exception" next-node-id= "End"/>
</next-nodes>
</node>
</nodes>
</flow>



Where the flow node's properties mean:
ID, uniquely identifying a process
Privatecontext, if true, apply a context separately in the process, otherwise share the caller's context, which effectively avoids the conflict of environment variables
Extend-flow-id, the inherited process ID, this inheritance ID is a very powerful feature, which is explained in detail later
Version number, the process of the same ID can have multiple versions, and when accessed, the latest version is used by default if no version is specified
Name,title is only used to explain its English, Chinese name, easy to understand.
Default-node-id indicates that the default execution node, that is, if a component finishes executing and its item value does not specify the next processing node, executes the default node
Begin-node-id, starting node
End-node-id, End node
If not specified, Begin-node-id defaults to Begin,end-node-id default to end

Node: ID must be specified, and the ID must be unique within a process.
Component node
Class-name used to specify the organization implementation class name
Properties is a list of attributes for a component
The name and value in the property are the values of the properties of the component, value, which is passed in as a string, but can be handled in real-world can be very flexible, later introduced.
Next-nodes refers to the rules for subsequent processing based on the results of the execution.
Next-node, a specific rule, component-result, matches, supports regular expressions, matches the results of the component execution in the node, and the next node in this rule executes successfully.
Exception-type is the class name of the exception, and if an exception occurs and matches the type defined here, the next node in this rule is executed.
As mentioned above, process inheritance is very simple to implement, as long as it is specified in the Extend-flow-id property.
Inheritance does not support multiple inheritance, that is, a process can inherit from only one process, but it can support multiple layers of inheritance, i.e.
A>b>c>d .....
In the actual development process, do not make the inheritance too complicated, this will make the procedural logic more difficult to understand.


What is the role of inheritance in practice?
First, some attributes are inherited, and the node information is inherited.
Simply put: Both have, the current process to decide, not currently, the parent process to decide.


What scenario does inheritance apply to??
Inheritance is very similar to the pattern applied to business processing, only when the intermediate processing environment is different.
Like what:
A B C D---O----d-c-b-a
Type of business process, only o different, the other processing mode is exactly the same, at this time the adoption of inheritance is very comfortable,
As long as the parent process is defined, only one process node can be defined in the sub-process. In the future, the process can be adjusted uniformly, as long as the parent process is adjusted.

For example, Flow AA is defined as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<flow id= "AA" name= "AA";
  <nodes>
    <node id= "Begin";
      <next-nodes>
        <next-node component-result= " Begin "Next-node-id=" Hello "/>
      </next-nodes>
    </node>
    <node id= "Hello",
      <component class-name= " Org.tinygroup.flow.HelloWorldComponent,
        <properties>
          <property name= "name" value= "World"/>
         </properties>
      </component>
      < Next-nodes>
        <next-node next-node-id= "End"/>
       </next-nodes>
    </node>
  </nodes>
</flow>



Flow BB is defined as

1
2
3
4
5
6
7
8
9
10
11
<flow id= "BB" name= "BB" extend-flow-id= "AA" >
< nodes>
< node id= "Hello" >
< component Class-name= "Org.tinygroup.flow.HelloWorldComponent" >
< properties>
< name= "name" value= "World"/>
</properties>
</component>
</node>
</nodes>
</flow>





The process BB can also execute smoothly, and the execution result is Hello, world


A very important highlight is the attribute assignment.
The ease of use of the framework is determined by whether the property assignment is useful.


You can support constant assignment "1" to denote numeric constants
A AA indicates that a string constant can be supported, an environment variable is assigned a value
For example: XX is the object that takes xx key from environment variable
can support property assignment
For example: XX.ABC the attribute ABC that takes environment variable XX
For example: Xx.abc.def the attribute of the property ABC that takes the environment variable XX to def
can support combination assignment

For example: ${in:aa.abc.def}-${in:bb.cc.dd}
The DD property that represents the attribute of the attribute ABC in the Environment AA and the Def Middle Plus "-" plus the CC attribute in the environment variable BB
Where the hierarchy of attributes is not restricted.


In addition, the value method also supports self-scaling:
For example, you can use ${IN:XMLKEY.AA} to also take the AA attribute of the corresponding XML node in the environment Xmlkey
So, only unexpected, not do not.

Application development and deployment methods, compared with the typical B/s and b/a/s,c/a/s and so on. For the b/a/s and C/A/S modes, because A and B and C are separate deployments, all content needs to be passed through the context.

If you are using a detached deployment, you need to pass the request environment data over the network.

If you want to build the system through the B/s environment, you will expect to process the results with the cloth by using HTTP processing threads.
At the same time, sometimes the process of processing data may be in the Request,requestattribute,session,cookie, if the data copied into the environment, in fact, there is a large performance consumption.

This process engine supports invocation by service mode or by short circuit.
Although we recommend the use of the B/A/S architecture, but there is no denying that many of our products are still operating under the B/S architecture.

But fortunately, for the process engine, he does not directly access content such as request and Session,cookie, so even if the integration is deployed together, does not hinder the separation of the deployment, still can guarantee the stateless nature of the service, if it is necessary to implement a context interface.
Summary:
Tiny's process engine, which offers quite a bit of functionality and extensibility, is only part of it, some of it is not entirely clear, and in fact, it provides many advanced features, including El expressions, which are well supported for the expectation of process orchestration development.
Currently in the tiny framework, business process orchestration and page flow orchestration are built on this engine, and the application effect is very good. The future will build the workflow engine based on it.

Business Process Engine

Related Article

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.