ExecutionEntity内部含有parent,是一个执行树或执行路径,应该是一个流程实例的执行过程,一个实例对应一个ExecutionEntity,通过getActivity得到的是当前正在执行的activity.
Activiti之流程部署:
流程文件部署主要涉及到3个表,分别是:ACT_GE_BYTEARRAY、ACT_RE_DEPLOYMENT、ACT_RE_PROCDEF。主要完成“部署包”-->“流程定义文件”-->“所有包内文件”的解析部署关系
流程定义的部署需要完成如下操作:
●初始化到数据库,完成三张表的插入,一个部署包里可以有N个流程定义,所以
PROCDEF表内对应N条数据,BYTEARRAY表内对应N+条记录,每个xml文件一条记录,图片也会另外存放一条记录。DEPLOYMENT内会存放一条记录
●解析后的流程定义存入DeploymentCache
流程部署的序列图:
repositoryService DeploymentBuilder commandExecutor DeploymentManager DbSqlSession ResourceManager DeploymentCache createDeployment
execute(new DeployCmd(deploymentBuilder))
insertDeployment(DeploymentEntity)
insert(DeploymentEntity)
流程部署已后,启动流程时,会调用StartProcessInstanceCmd,来启动流程。StartProcessInstanceCmd在查ProcessDefinitionEntity时,会从deploymentCache 中查,当cache中不存在时,会执行deploymentCache.deploy()
Activiti之Query查询:
缓存查询:
Activiti 之manager:
创建流程实例:
创建流程实例:runtimeService.startProcessInstanceByKey("financialReport") 执行步骤:
1.0 首先根据” financialReport”在数据库中查流程定义
2.0 查到流程定义后,再从processDefinitionCache 中获取已经缓存的、部署完成的(xml
文件被解析的)流程定义,如果processDefinitionCache 中不存在,那么执行流程的解析过程
query
+++++++
升续 ()降续 ()list ()
listPage ()
Operation_5 ()singleResult ()count ()
userQuery
+++++
userId ()
userFirstName ()userEmail ()
memberOfGroup ()orderByUserId ()...
: userQuery : userQuery : userQuery : userQuery : userQuery
Command
+execute (CommandContext context): T
AbstractQuery
++++++
升序 ()降序 ()list ()
listPage ()count ()
sigleResult ()
UserQueryImpl
TaskQuery
TaskQueryImpl
session ++flush ()close ()...
AbstractManager
++++
insert (PersistentObject record)delete (PersistentObject record)getDbSqlSession ()getManager ()
TaskManager
++deleteTask ()findTask (): TaskEntity
ExecutionManager
+
++++
deleteProcessInstances ()findProcessInstance ()findExecutions ()
findChildExecutions ()findSubProcessInstance ()...
: ProcessInstance : ExecutionEntity : ExecutionEntity : ExecutionEntity
3.0创建流程实例
代码执行过程:
1.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationProcessStart
2.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationProcessStartInitial 3.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationActivityExecute
4.ProcessInstance[805] executes Activity(theStart):
ine.impl.bpmn.behavior.NoneStartEventActivityBehavior  5.Leaving activity 'theStart'
流程启动:
流程启动执行:ExecutionEntity.performOperation(AtomicOperation.PROCESS_START) ,接着执行:execution.performOperation(PROCESS_START_INITIAL);
接着执行:execution.performOperation(ACTIVITY_EXECUTE);其内部执行逻辑为:ActivityBehavior activityBehavior = ActivityBehavior();
activityBehavior有很多的实现类,比如:当流程启动时,启动节点的activityBehavior实际上是NoneStartEventActivityBehavior的实例。给每个节点装配ActivityBehavior应该是在流程解析时完成的,一个类型的节点装配特定类型的Behavior,固定写死的。
Activiti之数据操作
Insert、update、delete三种操作,先更新cache,在一个cmd中,把所有需要insert的数据放入一个map,执行完cmd后,统一进行insert、update、delete操作
每个Service的“命令执行者”都是由
“LogInterceptor-->CommandContextInterceptor-->CommandExecutorImpl”组成的执行链状结构。日志—>执行前后操作(比如:transaction的开启及commit) 执行命令
Activiti之任务分配
任务分配时,根据流程定义,首先根据人工活动定义的Assignee,直接进行分配,如果Assignee有值,此时该任务处于已认领状态。然后继续执行任务的候选人分配,候选人分两种:候选组表达式及候选人表达式,解析表达式,进行公共任务分配。任务应该没有状态,标记是已经被认领时,是根据该任务的属性:Assignee()是否有值进行判断
Activiti之任务认领
1.0没有到判断是否有权限进行认领操作
2.0 如果该任务属性:Assignee()有值,说明已经被认领,如果和当前认领人不同,抛出异常,is already claimed by someone else
执行认领操作,数据库操作步骤(分别对应三张表):
1.update HistoricActivityInstanceEntity
2.update HistoricTaskInstanceEntity
3.update TaskEntity
Activiti之任务完成
在创建一个新人工任务时,在数据表IdentityLinkEntity中删除当前已完成的这条数据,当流程实例结束时,删除execution表中的当前流程数据。
完成一个人工任务时,完成的数据库表操作:
1.insert HistoricActivityInstanceEntity
2.insert TaskEntity
3.insert HistoricTaskInstanceEntity
4.insert IdentityLinkEntity
5.update ExecutionEntity
6.update HistoricActivityInstanceEntity
7.update HistoricTaskInstanceEntity
8.delete IdentityLinkEntity
9.delete TaskEntity
完成任务时,走的过程:
1.Leaving activity 'writeReportTask'
[ine.impl.bpmn.behavior.BpmnActivityBehavior]
2.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLis tenerEnd
3.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLis tenerEnd@1c09624
4.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionDestroySc ope
5.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLis tenerTake
6.ProcessInstance[605] takes transition
(writeReportTask)--flow2-->(verifyReportTask)
[ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLi stenerTake]
7.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionCreateSco pe
8.AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLis tenerStart  9. AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationTransitionNotifyLis tenerStart  10. AtomicOperation:
ine.impl.pvm.runtime.AtomicOperationActivityExecute@1478a2d on ine.impl.interceptor.CommandContext  11. ProcessInstance[605] executes Activity(verifyReportTask):
ine.impl.bpmn.behavior.UserTaskActivityBehavior
Activiti 其它
Activiti 之executionEntity:
PvmExecution +++++
signal ()
getActivity ()hasVariable ()setVariable ()getVariable ()...
PvmProcessInstance
+++++
start ()
findExecution ()
findActiveActivityIds ()isEnded ()
deleteCascade ()...InterpretableExecution
ActivityExecution
++++++++
getActivity ()take (PvmTransition 入参)createExecution ()createSubProcessInstance ()getParent ()end ()
executeActivity ()takeAll ()...
: PvmActivity : ActivityExecution : ActivityExecution DelegateExecution
++++
getProcessBusinessKey ()getId ()
getProcessInstanceId ()getEventName ()...
VariableScope ++++
getVariables ()setVariable ()hasVariables ()removeVariable ()...
ExecutionListenerExecution
+++getEventName ()
getEventSource ()getDeleteReason ()...
: PvmProcessElement VariableScopeImpl
ExecutionEntity
Execution
+++getId ()isEnded ()
getProcessInstanceId ()...
ProcessInstance
++getProcessDefinitionId ()getBusinessKey ()...
ExecutionImpl

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。