jbpm4源碼深入分析
jbpm4源碼分析---configuration hibernate主鍵生成政策--native(文檔不滿)
jbpm源碼分析---environmentjbpm 2010-04-26 11:30:05 閱讀105 評論7 字号:大中小 訂閱
environment是jbpm運作期環境,他提供了jbpm的所有的服務(service),我們通常會使用environmentfactory的openenvironment()方法來擷取environment,而jbpm的environment用到了threadlocal模式,他是這樣定義的:
static threadlocal<environment> currentenvironment = new threadlocal<environment>();
static threadlocal<stack<environment>> currentenvironmentstack = new threadlocal<stack<environment>>();
其中currentenvironment 是目前的運作期環境,而currentenvironmentstack 則提供了一個棧,可以壓入多個environment。
public static environment getcurrent() {
return currentenvironment.get();
//用來擷取目前的environment 。
}
其中主要的方法是用來擷取服務的:
public abstract object get(string name);
public abstract <t> t get(class<t> type);
上一次說到了configuration,預設的構造實際上擷取的是jbpmconfiguration,而這個jbpmconfiguration便實作了environmentfactory接口,當jbpmconfiguration加載jbpm.default.cfg.xml配置檔案的時候,他會将其中的<process-engine-context>和<transaction-context>初始化好,注入到environment中,就可以用來擷取各種服務類了。
jbpm4源碼分析---configurationjbpm 2010-04-26 10:00:42 閱讀172 評論0 字号:大中小 訂閱
在jbpm内部是通過各種服務互相作用, 服務接口可以從processengine中獲得, 所有線程和請求都可以使用同一個流程引擎對象,而processengine是由configuration建立的.通常我們使用預設的構造進行建立:
processengine processengine = new configuration().buildprocessengine(); /** default constructor */ public configuration() { this((string)null); }這個預設構造中的this((string)null)實際上調用的是另一個帶string type 參數的構造方法,方式如下:public configuration(string type) { string implementationclassname = getimplementationclassname(type); if (implementationclassname==null) { throw new jbpmexception("type is null"); } impl = instantiate(implementationclassname); }而在getimplementationclassname方法中,jbpm把configuration實作類implementationclassname設定為一個map,它實作了2種configuration: implementationclassnames.put(null, "org.jbpm.pvm.internal.cfg.jbpmconfiguration"); implementationclassnames.put("spring-test", "org.jbpm.pvm.internal.cfg.springconfiguration"); 是以說我們通常使用的預設構造實際上是建立的org.jbpm.pvm.internal.cfg.jbpmconfiguration在jbpmconfiguration中,他繼承了configuration,實作了context, processengine, environmentfactory等接口,這個類中主要的方法就是buildprocessengine和一些setx(),分别用來建立流程引擎和從inputstream中、 從xml字元串中、從inputsource中、 從url中或者從檔案(file)中指定配置
請問一下,jbpm中的流程定義xml檔案是如何存儲到資料庫中的? 該問題已經關閉: 超過15天由系統自動關閉,懸賞平分給所有參與回答的會員
問題答案可能在這裡 → 尋找更多解答
* 重新看待jbpm的流程定義
* jbpm工作流應用
* jbpm3.2.2源碼分析---org.jbpm.db*
* jbpm讀取流程定義檔案異常
* 請問下有沒有jbpm3.2高手在?請教幾個問題
回答
總體過程:讀取xml檔案->從檔案中提取所有node,task,transition等并設定到對應的domain object中->持久化到資料庫
詳細過程(代碼):
java代碼
1. processdefinition解析流程定義檔案相關方法
2. public static processdefinition parsexmlstring(string xml);
3. public static processdefinition parsexmlinputstream(inputstream inputstream);
4. public static processdefinition parsexmlreader(reader reader);
5. ..........................................
6. ..........................................
processdefinition解析流程定義檔案相關方法
public static processdefinition parsexmlstring(string xml);
public static processdefinition parsexmlinputstream(inputstream inputstream);
public static processdefinition parsexmlreader(reader reader);
..........................................
以上所有方法其實最終都會轉化為對jpdlxmlreader對象的readprocessdefinition方法的調用,
1. readprocessdefinition()方法具體實作
2.
3. // 建立一個新的流程定義對象
4. processdefinition = processdefinition.createnewprocessdefinition();
5.
6. // 初始化包含的各種清單
7. problems = new arraylist();
8. unresolvedtransitiondestinations = new arraylist();
9. unresolvedactionreferences = new arraylist();
10.
11. try {
12. //把流程定義文檔讀到記憶體dom樹中
13. document document = jpdlparser.parse(inputsource, this);
14. element root = document.getrootelement();
15.
16. // 讀取流程名稱
17. parseprocessdefinitionattributes(root);
18.
19. // 讀取流程描述
20. string description = root.elementtexttrim("description");
21. if (description!=null) {
22. processdefinition.setdescription(description);
23. }
24.
25. // 一次加工:讀取流程中各種資訊
26. readswimlanes(root);//讀取所有泳道
27. readactions(root, null, null);//讀取所有action
28. readnodes(root, processdefinition);//讀取所有node
29. readevents(root, processdefinition);//讀取所有event
30. readexceptionhandlers(root, processdefinition);//讀取所有異常處理器
31. readtasks(root, null);//讀取所有任務
32.
33. // 二次加工:處理各種transition和action的引用
34. resolvetransitiondestinations();
35. resolveactionreferences();
36. verifyswimlaneassignments();//确認泳道的配置設定政策
37.
38. } catch (exception e) {
39. log.error("couldn't parse process definition", e);
40. addproblem(new problem(problem.level_error, "couldn't parse process definition", e));
41. }
42.
43. if (problem.containsproblemsoflevel(problems, problem.level_error)) {
44. throw new jpdlexception(problems);
45. }
46.
47. if (problems!=null) {
48. iterator iter = problems.iterator();
49. while (iter.hasnext()) {
50. problem problem = (problem) iter.next();
51. log.warn("process parse warning: "+problem.getdescription());
52. }
53. }
54.
55. return processdefinition;//傳回processdefinition對象,已經完全把xml中定義的流程轉化為java中的對象,xml中的各種tag都已經轉換為jbpm中的相關圖形對象pojo并包含在processdefinition的所包含的各種清單中
56.