Shark工作流引擎启动流程是一个比较复杂的处理过程,根据JSPClientUtilities类的processStart方法进行代码分析如下:
public static void processStart(SharkConnection sc, String mgrName) throws Exception {
if (debug)
System.err.println("#_processStartName_#");
try {
if (!isProcessRunning(sc, mgrName)) {
WfProcessMgr mgr = sc.getProcessMgr(mgrName);//获得流程定义管理器
mgr.create_process(null).start();//创建流程并启动
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
其中的mgr是根据反射机制并通过工厂模式从 org.enhydra.shark.SharkObjectFactory.createProcessMgrWrapper()方法返回的 org.enhydra.shark.WfProcessMgrWrapper类。 WfProcessMgrWrapper.create_process()方法如下:
/**
* Create a WfProcess object
*/
public WfProcess create_process(WfRequester requester) throws Exception, NotEnabled, InvalidRequester,
RequesterRequired {
long tStamp = SharkUtilities.methodStart(shandle, "WfProcessMgrWrapper.create_process");
try {
checkSecurity("create_process", null);//检查权限
WfProcessMgrInternal mgr = getProcessMgrImpl(name);//获得内部流程定义管理器
// check if this process is allowed to be created only internally
if (mgr.category(shandle).equalsIgnoreCase(XPDLConstants.ACCESS_LEVEL_PRIVATE)) {//检查内部流程定义管理器的访问权限
throw new NotEnabled("The process definition defines only PRIVATE access!");
}
WfRequesterInternal req = SharkEngineManager.getInstance().getObjectFactory().createDefaultRequester(
shandle, SharkEngineManager.getInstance().getCallbackUtilities().getUserId(shandle), requester);//创建内部请求者
WfProcessInternal procInternal = mgr.create_process(shandle, req);//创建内部流程实例
WfProcess proc = SharkEngineManager.getInstance().getObjectFactory().createProcessWrapper(shandle,
procInternal.manager_name(shandle), procInternal.key(shandle));//创建内部流程的包装器
return proc;
} finally {
SharkUtilities.methodEnd(shandle, tStamp, "WfProcessMgrWrapper.create_process", this);
}
}
Shark对内部的流程定义管理器和流程实例都创建一个与之对应的包装器供外部程序访问,并处理安全检查&#x
Shark 工作流研究3-启动流程过程
最新推荐文章于 2023-04-12 21:20:48 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)