天天看點

shark工作流的流程建立和持久化

最近一直在看shark工作流的相關資料,在網上查到的一些資料有好多是1.1版本的,與目前使用的2.0以上的版本的API有些差别,經過幾天的熟悉和實踐,終于在建立流程和持久化方面開竅了一些,現記錄下來以備以後檢視,也給有需要的初學者參考一下。

代碼:

//建立并持久化流程執行個體

public void createProcess(String pkgID) throws Exception{

            SharkInterfaceWrapper.getShark();

            UserTransaction ut = SharkInterfaceWrapper.getUserTransaction();

            ut.begin();

            WMConnectInfo wmci = new WMConnectInfo(username, password, "", "");

            shandle = wapi.connect(wmci);

            String procId = wapi.createProcessInstance(shandle, pkgID, null);

            wapi.startProcess(shandle, procId);

            ut.commit();

            wapi.disconnect(shandle);

            System.out.println("Process " + procId + " successfully created and started!");

}

需要注意的是在使用SharkInterfaceWrapper時需要對其進行配置,代碼為:

        String confFilePath = "D:/tws-community-2.4-8-25/conf/Shark.conf";

        SharkInterfaceWrapper.setProperties(confFilePath, true);

        wapi = SharkInterfaceWrapper.getShark().getWAPIConnection();

繼續閱讀