Camunda流程調用梳理

1、userTask調用邏輯

  • 接口調用:
  1. 從接口(resources)進入
  2. 實現類(xxxImpl)
  3. Executor.execute(new xxxCmd())
  4. xxxCmd中執行execute()方法
  • 內部創建調用:(BpmnParser是關鍵調用類)
  1. xxxCmd 執行邏輯調用
  2. 獲取TaskManager(可選):TaskManager taskManager = commandContext.getTaskManager();
  3. 獲取TaskEntity:通過taskManager.findTaskById(id)
  4. taskEntity.update()/delete()....
  5. fireEvent( eventName ) :最後操作都是通過fireEvent獲取到對應的Listener通過觀察者模式進行調用。
  • fireEvent調用邏輯:
  1. 獲取ExecutionEntity / (CoreExecution):Context .getCommandContext() .getExecutionManager() .findExecutionById(executionId);
  2. 包裝對應taskListener+實例(delegateTask)+根據實例的executionId獲取的execution,得到TaskListenerInvocation:new TaskListenerInvocation(taskListener, delegateTask, execution)                                  注:此處listener會在後續操作中執行對應的notify()方法
  3. xxxInvocation.handleInvocation(TaskListenerInvocation)真正執行對應操作:Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(listenerInvocation);
  4. DefaultDelegateInterceptor.handleInvocation(listenerInvocation):通過Interceptor來進行底層操作
  5. listenerInvocation.proceed() 
  6. 對應執行器(xxxInvocation)執行:xxxInvocation.invoke()
  7. behaviourInstance.execute(execution)
  8. 對應listener執行notify()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章