1. 程式人生 > >【Activiti研究】關於Activiti變數範圍VariableScope的實現(子類ExecutionEntity,TaskEntity)

【Activiti研究】關於Activiti變數範圍VariableScope的實現(子類ExecutionEntity,TaskEntity)

void org.activiti.engine.impl.persistence.entity.VariableScopeImpl
//呼叫子類ExecutionEntity或taskEntity的loadVariableInstances載入本地變數
ensureVariableInstancesInitialized()
//只判斷ExecutionEntity當前AcitityImpl是否存在,存在則返回this
getSourceActivityExecution()
//載入子類ExecutionEntity或TaskEntity的本地變數
loadVariableInstances()
//查詢ExecutionEntity或TaskEntity的父類ExecutionEntity
getParentVariableScope()
//收集本地(ExecutionEntity或TaskEntity)和遞迴所有父類變數
collectVariables(HashMap<String, Object> variables)
//同理如上,只是收集的是VariableInstance
collectVariableInstances(HashMap<String, VariableInstance> variables)
//在本地(ExecutionEntity或TaskEntity)id查詢對應的變數
getSpecificVariables(Collection<String> variableNames)
//1.本地已使過的快取查詢載入
//2.判斷fetchAllVariables=true強制載入本層變數,
//否則false載入根據本地(ExecutionEntity或TaskEntity)id,並遞迴呼叫找不到查詢父親
getVariables(Collection<String> variableNames, boolean fetchAllVariables)
getVariableInstances(Collection<String> variableNames, boolean fetchAllVariables)
//1.從本地已使過的快取中
//2.判斷fetchAllVariables,是否強制載入本層變數
//3.最後遞迴父類getVariableInstance方法
getVariable(String variableName, boolean fetchAllVariables)
getVariableInstance(String variableName, boolean fetchAllVariables) 
//同上,但只查詢本層次(ExecutionEntity或TaskEntity)變數
getVariableLocal(String variableName, boolean fetchAllVariables)
getVariableInstanceLocal(String variableName, boolean fetchAllVariables)
//判斷本層級(ExecutionEntity或TaskEntity)及遞迴父層是否存在變數
hasVariables()
//本層級(ExecutionEntity或TaskEntity)是否存在變數
hasVariablesLocal()
//判斷本層級是否存在變數variableName
hasVariable(String variableName)
//先判斷本層級,再遞迴父級
hasVariableLocal(String variableName)
//收集所有層級變數名稱
collectVariableNames(Set<String> variableNames)
//為變數例項設定exectionId,processInstanceId(taskId)
initializeVariableInstanceBackPointer(VariableInstanceEntity variableInstance)
//查詢引擎配置中的所有變數型別,根據值查詢對應VariableType,新建儲存VariableInstanceEntity
//呼叫上面方法,變數例項與流程例項做關聯
//最後記錄歷史變數與歷史變數詳情
createVariableInstance(String variableName, Object value, ExecutionEntity sourceActivityExecution)
//獲取變數或本地變數,並進行型別強轉返回
getVariable(String variableName, Class<T> variableClass)
getVariableLocal(String variableName, Class<T> variableClass)
//更新變數例項的變數值或變數型別
updateVariableInstance(VariableInstanceEntity variableInstance, Object value, ExecutionEntity sourceActivityExecution)
//根據變數名查詢本地變數,不存在遞迴查詢父類變數
//找到具體變數例項後,deleteVariableInstanceForExplicitUserCall進行刪除,並作日誌記錄
removeVariable(String variableName)...
deleteVariableInstanceForExplicitUserCall(VariableInstanceEntity variableInstance, ExecutionEntity sourceActivityExecution) 
//本地已使用快取中查詢變數,找不到查本地所有變數中查詢,找到更新updateVariableInstance,找不到就建立createVariableLocal
setVariableLocal(String variableName, Object value, ExecutionEntity sourceActivityExecution, boolean fetchAllVariables)
//刪除本層級(ExecutionEntity或TaskEntity)所有變數
deleteVariablesInstanceForLeavingScope()
//記錄歷史變數詳情時,使用ExecutionEntity為true,TaskEntity為false
isActivityIdUsedForDetails()