Process resources can be files of various types that are read during the START process or process instance run. The following describes the common process resources.
first, process resources
Process definition file: extension bpmn20.xml and BPMN;
Picture of the process definition: depicted in various graphs with BPMN2.0 specifications, generally in PNG format;
Form files: Save the contents of the form in a file with the extension DRL;
Rule file: Its extension is DRL;
II. Deployment Process Resources
There are a number of ways to deploy process resources, including classpath, InputStream, strings, zip-format compression packages, which are described below.
1.classpath Mode
public class Processdefinitiontest {
/** process engine (core object), named activiti.cfg.xml*/under the default load class path
Processengine Processengine = Processengines.getdefaultprocessengine ();
Deployment process Definition
@Test public
void Deployementprocessdefinition () {
Deployment Deployment = Processengine.getrepositoryservice ()//Gets the service that the process definition and the deployment object are related to
. Createdeployment ()//Create a Deployment Object
. Name (" HelloWorld demo ")//the name of the declaration process
. Addclasspathresource (" DIAGRAMS/HELLOWORLD.BPMN ")//load resource file, only one file can be loaded at a time
. Addclasspathresource ("diagrams/helloworld.png")//
. Deploy ();//Complete Deployment
SYSTEM.OUT.PRINTLN ("Deployment ID:" + Deployment.getid ());//1
System.out.println ("Deployment Time:" +deployment.getdeploymenttime ());
}
}
2.InputStream Mode
Deploying a process resource using the InputStream method requires the name of an input stream and resource, which can be either read from Classpath or read from an absolute path file or from the network.
InputStream Way
@Test public
void Deployementprocessdefinitionbyinputstream () throws FileNotFoundException {
//Get resource relative path
String bpmnpath = "DIAGRAMS/HELLOWORLD.BPMN";
String Pngpath = "Diagrams/helloworld.png";
Read the resource as an input stream
fileinputstream bpmnfileinputstream = new FileInputStream (bpmnpath);
FileInputStream Pngfileinputstream = new FileInputStream (pngpath);
Deployment Deployment = Processengine.getrepositoryservice ()//Gets the service associated with the process definition and Deployment Object
. Createdeployment ()// Create a Deployment Object
. Addinputstream ("HELLOWORLD.BPMN", Bpmnfileinputstream)
. Addinputstream ("Helloworld.png", Pngfileinputstream)
. deploy ();//Complete Deployment
SYSTEM.OUT.PRINTLN ("Deployment ID:" +deployment.getid ());//1
SYSTEM.OUT.PRINTLN ("Deployment Time:" +deployment.getdeploymenttime ());
}
3. String Mode
The use of strings can be passed directly into plain text as the source of resources, and the first two ways, similar to the way the string is implemented by converting the contents of a set of strings into a byte stream before deployment.
String Way
@Test public
void Deployementprocessdefinitionbystring () throws filenotfoundexception{
//String
String Text = "<?xml version=\" 1.0\ "encoding=\" utf-8\ "?><definitions>...</definitions>";
Deployment Deployment = Processengine.getrepositoryservice ()//Gets the service associated with the process definition and Deployment Object
. Createdeployment ()// Create the Deployment Object
. AddString ("HELLOWORLD.BPMN", text)
. deploy ();//Complete Deployment
SYSTEM.OUT.PRINTLN ("Deployment ID:" + Deployment.getid ());//1
System.out.println ("Deployment Time:" +deployment.getdeploymenttime ());
}
4.zip/bar Format Compression package mode
The above 3 deployment methods can only deploy one resource at a time, unless you execute multiple deployment.addxxx () methods to deploy more than one resource at a time. Very simply, we can use the Zip/bar format to compress the package. To manually or use an ant script for a resource file, the package file extension can be a bar or normal zip that is officially recommended by Activiti.
Deployment process definition (Zip)
@Test public
void Deployementprocessdefinitionbyzip () {
//Read resource file
from Classpath path InputStream in = This.getclass (). getClassLoader (). getResourceAsStream ("Diagrams/helloworld.zip");
Zipinputstream Zipinputstream = new Zipinputstream (in);
Deployment Deployment = Processengine.getrepositoryservice ()//Gets the service associated with the process definition and Deployment Object
. Createdeployment ()// Create a Deployment Object
. Addzipinputstream (Zipinputstream)//Use zip-mode deployment to compress HELLOWORLD.BPMN and helloworld.png into a zip-formatted file
. Deploy ();//Complete Deployment
SYSTEM.OUT.PRINTLN ("Deployment ID:" +deployment.getid ());//1
System.out.println ("Deployment time:" + Deployment.getdeploymenttime ());
}
third, database table changes
In the deployment process definition step, the database operates three tables:
1) Act_re_deployment (Deployment Object table)
Store the display name and deployment time for the process definition, adding one record at a time per deployment
2) act_re_procdef (Process definition table)
Storing the property information for the process definition, and deploying each new process definition adds a record to this table.
Note: When the process definition key is the same, the version upgrade is used
3) Act_ge_bytearray (resource File table)
The storage process definition related deployment information. The location where the process definition document is stored. Each deployment is incremented by two records, one for the BPMN rule file, one for the picture (if only BPMN one file is specified at deployment time, Activiti automatically generates a flowchart when the BPMN file content is parsed at deployment time). Two files are not very large and are stored in binary form in the database.
4) Act_ge_property (primary key generation table)
The assertion table will generate the primary key ID for the next process deployment.