本站不再更新,歡迎光臨 java開發技術網
          隨筆-230  評論-230  文章-8  trackbacks-0
             看了這么久jbpm還沒有一個頭緒,需要繼續分析。jbpm把流程部署到數據庫有好幾種方法,今晚終于調試通過了java直接部署 的子,僅為述于此,不做分析。
           static JbpmConfiguration cfg=JbpmConfiguration.getInstance(); //jbpm一切一切的基礎
           
           public void setUp(){
            //cfg.createSchema();  //重建jbpm存儲層..
           }
          以下是一個部署的方法
              public void testDeployProcessDefinition()throws Exception{
                  assertNotNull(
          "JbpmConfiguration is null",cfg);
                  FileInputStream fis 
          = new FileInputStream("src/proc1.xml");
                  ProcessDefinition pd
          =ProcessDefinition.parseXmlInputStream(fis);
                  assertNotNull(
          "definition should not be null",pd);
                  JbpmContext jc
          =cfg.createJbpmContext();
                  
          try{
                      jc.deployProcessDefinition(pd);
                  }
          finally{
                      jc.close();
                  }
              }
          實例化并生成流程實例的方法
              public void testLoadProcessAndInstance() throws Exception {
                  JbpmContext jbpmContext 
          = cfg.createJbpmContext() ;            
                  
          try {
                        GraphSession graphSession 
          = jbpmContext.getGraphSession();                  
                        ProcessDefinition processDefinition 
          = 
                        graphSession.findLatestProcessDefinition(
          "pro1"); 
                        
                        ProcessInstance processInstance 
          = 
                            
          new ProcessInstance(processDefinition);
                        Token token 
          = processInstance.getRootToken(); 
                        
                        assertEquals(
          "start", token.getNode().getName());
                        
          // Let's start the process execution
                       token.signal();
                        assertEquals(
          "state1", token.getNode().getName());
                        jbpmContext.save(processInstance);
                      } 
          finally {
                        
          // Tear down the pojo persistence context.
                        jbpmContext.close();
                      }
              }
          再執行上面生成的流程方法
              public void testLoadInstanceAndDoActionAndEnd() throws Exception {

                  JbpmContext jbpmContext 
          = cfg.createJbpmContext() ;            
                    
          try {
                        GraphSession graphSession 
          = jbpmContext.getGraphSession();
                        ProcessDefinition processDefinition 
          = graphSession.findLatestProcessDefinition("pro1");
                        List processInstances 
          = graphSession.findProcessInstances(processDefinition.getId());                   
                        ProcessInstance processInstance 
          =  (ProcessInstance) processInstances.get(0);                  
                       
          // this.assertEquals("message",(String)(processInstance.getContextInstance().getVariable("message")));
                        processInstance.signal();
                        assertTrue(processInstance.hasEnded());
                        jbpmContext.save(processInstance);
                      } 
          finally {
                        jbpmContext.close();
                      }

              }

          實際上,上面的幾段代碼中寫來寫去就這幾句話吧。加載流程,生成實例,然后簽收執行。
          明天繼續......
          posted on 2007-04-09 23:27 有貓相伴的日子 閱讀(1519) 評論(0)  編輯  收藏 所屬分類: workflow
          本站不再更新,歡迎光臨 java開發技術網
          主站蜘蛛池模板: 正宁县| 永和县| 淳化县| 瑞丽市| 扬州市| 时尚| 喀喇沁旗| 和政县| 景洪市| 新绛县| 乐业县| 亚东县| 靖宇县| 镇雄县| 平陆县| 新晃| 和林格尔县| 礼泉县| 南华县| 湖北省| 佛山市| 沈丘县| 筠连县| 济南市| 乳山市| 沙河市| 莎车县| 固始县| 宁安市| 阿瓦提县| 莒南县| 昌江| 黄浦区| 嘉义市| 阿鲁科尔沁旗| 白水县| 灵武市| 澳门| 日照市| 行唐县| 溆浦县|