風(fēng)人園

          弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
          隨筆 - 99, 文章 - 181, 評(píng)論 - 56, 引用 - 0
          數(shù)據(jù)加載中……

          jBPM之JbpmContext

          The three most common persistence operations are:

          • Deploying a process
          • Starting a new execution of a process
          • Continuing an execution

          First deploying a process definition. Typically, this will be done directly from the graphical process designer or from the deployprocess ant task. But here you can see how this is done programmatically:

          JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
          try {
            ProcessDefinition processDefinition = ...;
            jbpmContext.deployProcessDefinition(processDefinition);
          } finally {
            jbpmContext.close();
          }

          For the creation of a new process execution, we need to specify of which process definition this execution will be an instance. The most common way to specify this is to refer to the name of the process and let jBPM find the latest version of that process in the database:

          JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
          try {
            String processName = ...;
            ProcessInstance processInstance = 
                jbpmContext.newProcessInstance(processName);
          } finally {
            jbpmContext.close();
          }

          For continuing a process execution, we need to fetch the process instance, the token or the taskInstance from the database, invoke some methods on the POJO jBPM objects and afterwards save the updates made to the processInstance into the database again.

          JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
          try {
            long processInstanceId = ...;
            ProcessInstance processInstance = 
                jbpmContext.loadProcessInstance(processInstanceId);
            processInstance.signal();
            jbpmContext.save(processInstance);
          } finally {
            jbpmContext.close();
          }

          Note that if you use the xxxForUpdate methods in the JbpmContext, an explicit invocation of the jbpmContext.save is not necessary any more because it will then occur automatically during the close of the jbpmContext. E.g. suppose we want to inform jBPM about a taskInstance that has been completed. Note that task instance completion can trigger execution to continue so the processInstance related to the taskInstance must be saved. The most convenient way to do this is to use the loadTaskInstanceForUpdate method:

          JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
          try {
            long taskInstanceId = ...;
            TaskInstance taskInstance = 
                jbpmContext.loadTaskInstanceForUpdate(taskInstanceId);
            taskInstance.end();
          } finally {
            jbpmContext.close();
          }

          posted on 2007-01-18 11:39 風(fēng)人園 閱讀(1824) 評(píng)論(0)  編輯  收藏 所屬分類: jBPM

          主站蜘蛛池模板: 浠水县| 禹州市| 蕉岭县| 科尔| 隆德县| 汕尾市| 鹤壁市| 壶关县| 江安县| 乌什县| 苍山县| 来宾市| 石屏县| 荣昌县| 团风县| 厦门市| 怀远县| 洪湖市| 邵东县| 始兴县| 恩施市| 滦平县| 兴业县| 德清县| 新巴尔虎左旗| 郧西县| 鸡泽县| 德钦县| 武平县| 麟游县| 遂川县| 凤山县| 晋中市| 福建省| 容城县| 盘锦市| 黄浦区| 常州市| 泰来县| 农安县| 昆山市|